-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmdv_modules.php
More file actions
114 lines (99 loc) · 3.09 KB
/
mdv_modules.php
File metadata and controls
114 lines (99 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Inventory Plugin
*
* Fetch specific types of inventory
*
* @package MDV_CMS
* @author MDV.com Dev Team
* @copyright Copyright (c) 2010 - 2011, MDV.com
*
* Usage: {pyro:mdv_modules:quick_search limit="10"}
*
*/
class Plugin_mdv_modules extends Plugin
{
/**
* Private Variables
*/
private $mod_cms_vars;
private $mdv_db;
/**
* Plugin Constructor
*/
public function Plugin_mdv_modules()
{
// Connect to MDV DB
$this->mdv_db = $this->load->database( $this->config->item( 'mdvdb_creds' ), TRUE );
// Fetch certain CMS vars
$this->mod_cms_vars = extractVars( varsToExtract() );
// Extend CMS vars
$this->mod_cms_vars['skip_stock_vehicles'] = parseStr( '{pyro:variables:skip_stock_vehicles}' );
$this->mod_cms_vars['filtered_inventory_allowed'] = parseStr( '{pyro:variables:filtered_inventory_allowed}' );
}
/**
* Used Inventory Fetcher
*
* @return used car inventory
*/
public function quick_search()
{
// Fetch Attributes
$return_html = $this->attribute( 'return_html', true );
$manual_condition = $this->attribute( 'conditions', false );
// Prepare query
$sql = "SELECT DISTINCT `MAKE` FROM `vehicles_available_to_viewer_final` WHERE `CLIENT_ID` IN (".$this->mod_cms_vars['mdv_ids'].")";
// Restrict inventory (if enabled)
if ( $this->mod_cms_vars['filtered_inventory_allowed'] != '' ) {
$sql .= " AND `CONDITION` IN (".$this->mod_cms_vars['filtered_inventory_allowed'].")";
} else if ( $manual_condition != false ) {
$sql .= " AND `CONDITION` IN ('".$manual_condition."')";
}
// Remove stock vehicles (if enabled)
if( $this->mod_cms_vars['skip_stock_vehicles'] == 'yes' )
$sql .= " AND `IOL_IMAGE` = '0'";
// Finish query
$sql .= " ORDER BY `MAKE` ASC";
// Return makes of vehicles
$results = $this->mdv_db->query( $sql );
$makes = $results->result_array();
// Determine what to return
if( $return_html && $return_html != "false" )
{
$html_to_return =
'<div class="box_quicksearch">
<h2>Búsqueda Rápida</h2>
<ul>
<form action="'.parseStr( '{pyro:url:base}' ).'inventario" method="get" id="quick_search">
<li>
<select name="makes" id="jq_quick_search_make">
<option value="">Marca</option>';
foreach( $makes as $m )
$html_to_return .= '<option value="'.$m['MAKE'].'">'.$m['MAKE'].'</option>';
$html_to_return .=
' </select>
</li>
<li>
<select name="models" id="jq_quick_search_model" disabled="disabled">
<option value="">Modelo</option>
</select>
</li>
<li>
<div class="btn_2">
<a href="inventario" title="Búsqueda Rápida" id="jq_quick_search_submit"><span>Buscar</span></a>
</div>
<div class="jq_quick_search_loader jq_hide">
'.parseStr( '{pyro:theme:image file="quick_search_loader.gif"}' ).'
</div>
</li>
</form>
</ul>
</div>';
// return html
return $html_to_return;
}
// Return makes in array
return $makes;
}
}
/* End of file session.php */