-
Notifications
You must be signed in to change notification settings - Fork 1
/
vehicle.php
144 lines (121 loc) · 5.66 KB
/
vehicle.php
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* Module: cardealer
*
* @category Module
* @package cardealer
* @author XOOPS Development Team <[email protected]> - <https://xoops.org>
* @copyright {@link https://xoops.org/ XOOPS Project}
* @license GPL 2.0 or later
* @link https://xoops.org/
* @since 1.0.0
*/
use Xmf\Request;
use XoopsModules\Cardealer;
$GLOBALS['xoopsOption']['template_main'] = 'cardealer_vehicle_list0.tpl';
require __DIR__ . '/header.php';
$start = Request::getInt('start', 0);
// Define Stylesheet
$xoTheme->addStylesheet($stylesheet);
$db = \XoopsDatabaseFactory::getDatabaseConnection();
// Get Handler
/** @var \XoopsPersistableObjectHandler $vehicleHandler */
$vehicleHandler = new Cardealer\VehicleHandler($db);
$vehiclePaginationLimit = $helper->getConfig('userpager');
$criteria = new \CriteriaCompo();
$criteria->setOrder('DESC');
$criteria->setLimit($vehiclePaginationLimit);
$criteria->setStart($start);
$vehicleCount = $vehicleHandler->getCount($criteria);
$vehicleArray = $vehicleHandler->getAll($criteria);
$op = Request::getCmd('op', '');
$id = Request::getInt('id', 0, 'GET');
switch ($op) {
case 'view':
// viewItem();
$GLOBALS['xoopsOption']['template_main'] = 'cardealer_vehicle.tpl';
$vehiclePaginationLimit = 1;
$myid = $id;
//id
$vehicleObject = $vehicleHandler->get($myid);
$criteria = new \CriteriaCompo();
$criteria->setSort('id');
$criteria->setOrder('DESC');
$criteria->setLimit($vehiclePaginationLimit);
$criteria->setStart($start);
$vehicle['id'] = $vehicleObject->getVar('id');
/** @var \XoopsPersistableObjectHandler $customerHandler */
$customerHandler = new Cardealer\CustomerHandler($db);
$vehicle['custnum'] = $customerHandler->get($vehicleObject->getVar('custnum'))->getVar('custname');
$vehicle['make'] = $vehicleObject->getVar('make');
$vehicle['model'] = $vehicleObject->getVar('model');
$vehicle['year'] = $vehicleObject->getVar('year');
$vehicle['pictures'] = $vehicleObject->getVar('pictures');
$vehicle['serialnum'] = $vehicleObject->getVar('serialnum');
// $GLOBALS['xoopsTpl']->append('vehicle', $vehicle);
$keywords[] = $vehicleObject->getVar('serialnum');
$GLOBALS['xoopsTpl']->assign('vehicle', $vehicle);
$start = $id;
// Display Navigation
if ($vehicleCount > $vehiclePaginationLimit) {
$GLOBALS['xoopsTpl']->assign('xoops_mpageurl', CARDEALER_URL . '/vehicle.php');
xoops_load('XoopsPageNav');
$pagenav = new \XoopsPageNav($vehicleCount, $vehiclePaginationLimit, $start, 'op=view&id');
$GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4));
}
break;
case 'list':
default:
// viewall();
$GLOBALS['xoopsOption']['template_main'] = 'cardealer_vehicle_list0.tpl';
// require __DIR__ . '/header.php';
if ($vehicleCount > 0) {
foreach (array_keys($vehicleArray) as $i) {
$vehicle['id'] = $vehicleArray[$i]->getVar('id');
/** @var \XoopsPersistableObjectHandler $customerHandler */
$customerHandler = new Cardealer\CustomerHandler($db);
$vehicle['custnum'] = $customerHandler->get($vehicleArray[$i]->getVar('custnum'))->getVar('custname');
$vehicle['make'] = $vehicleArray[$i]->getVar('make');
$vehicle['model'] = $vehicleArray[$i]->getVar('model');
$vehicle['year'] = $vehicleArray[$i]->getVar('year');
$vehicle['pictures'] = $vehicleArray[$i]->getVar('pictures');
$vehicle['serialnum'] = $vehicleArray[$i]->getVar('serialnum');
$GLOBALS['xoopsTpl']->append('vehicle', $vehicle);
$keywords[] = $vehicleArray[$i]->getVar('serialnum');
unset($vehicle);
}
// Display Navigation
if ($vehicleCount > $vehiclePaginationLimit) {
$GLOBALS['xoopsTpl']->assign('xoops_mpageurl', CARDEALER_URL . '/vehicle.php');
xoops_load('XoopsPageNav');
$pagenav = new \XoopsPageNav($vehicleCount, $vehiclePaginationLimit, $start, 'start');
$GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4));
}
}
}
//keywords
if (isset($keywords)) {
$utility::metaKeywords(xoops_getModuleOption('keywords', $moduleDirName) . ', ' . implode(', ', $keywords));
}
//description
$utility::metaDescription(MD_CARDEALER_VEHICLE_DESC);
//
$GLOBALS['xoopsTpl']->assign('xoops_mpageurl', CARDEALER_URL . '/vehicle.php');
$GLOBALS['xoopsTpl']->assign('cardealer_url', CARDEALER_URL);
$GLOBALS['xoopsTpl']->assign('adv', xoops_getModuleOption('advertise', $moduleDirName));
//
$GLOBALS['xoopsTpl']->assign('bookmarks', xoops_getModuleOption('bookmarks', $moduleDirName));
$GLOBALS['xoopsTpl']->assign('fbcomments', xoops_getModuleOption('fbcomments', $moduleDirName));
//
$GLOBALS['xoopsTpl']->assign('admin', CARDEALER_ADMIN);
$GLOBALS['xoopsTpl']->assign('copyright', $copyright);
//
require XOOPS_ROOT_PATH . '/footer.php';