|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* Module: SmartCourse |
|
5
|
|
|
* Author: The SmartFactory <www.smartfactory.ca> |
|
6
|
|
|
* Licence: GNU |
|
7
|
|
|
* @param bool $showmenu |
|
8
|
|
|
* @param int $offerid |
|
9
|
|
|
* @param string $fct |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
function editoffer($showmenu = false, $offerid = 0, $fct = '') |
|
13
|
|
|
{ |
|
14
|
|
|
global $smartPartnerOfferHandler, $smartPartnerCategoryHandler, $smartPartnerPartnerHandler; |
|
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
$offerObj = $smartPartnerOfferHandler->get($offerid); |
|
17
|
|
|
|
|
18
|
|
|
if ($offerObj->isNew()) { |
|
19
|
|
|
$breadcrumb = _AM_SPARTNER_OFFERS . ' > ' . _AM_SPARTNER_CREATINGNEW; |
|
20
|
|
|
$title = _AM_SPARTNER_OFFER_CREATE; |
|
21
|
|
|
$info = _AM_SPARTNER_OFFER_CREATE_INFO; |
|
22
|
|
|
$collaps_name = 'offercreate'; |
|
23
|
|
|
$form_name = _AM_SPARTNER_OFFER_CREATE; |
|
24
|
|
|
$submit_button_caption = null; |
|
25
|
|
|
$offerObj->setVar('date_sub', time()); |
|
26
|
|
|
} else { |
|
27
|
|
|
$breadcrumb = _AM_SPARTNER_OFFERS . ' > ' . _AM_SPARTNER_EDITING; |
|
28
|
|
|
$title = _AM_SPARTNER_OFFER_EDIT; |
|
29
|
|
|
$info = _AM_SPARTNER_OFFER_EDIT_INFO; |
|
30
|
|
|
$collaps_name = 'offeredit'; |
|
31
|
|
|
$form_name = _AM_SPARTNER_OFFER_EDIT; |
|
32
|
|
|
$submit_button_caption = null; |
|
33
|
|
|
} |
|
34
|
|
|
$partnerObj = $smartPartnerPartnerHandler->get($offerObj->getVar('partnerid', 'e')); |
|
35
|
|
|
$offerObj->hideFieldFromForm('date_sub'); |
|
36
|
|
|
$menuTab = 3; |
|
37
|
|
|
|
|
38
|
|
|
if ($showmenu) { |
|
39
|
|
|
//smart_adminMenu($menuTab, $breadcrumb); |
|
40
|
|
|
} |
|
41
|
|
|
echo "<br>\n"; |
|
42
|
|
|
smart_collapsableBar($collaps_name, $title, $info); |
|
43
|
|
|
|
|
44
|
|
|
$sform = $offerObj->getForm($form_name, 'addoffer', false, $submit_button_caption); |
|
45
|
|
|
if ($fct === 'app') { |
|
46
|
|
|
$sform->addElement(new XoopsFormHidden('fct', 'app')); |
|
47
|
|
|
} |
|
48
|
|
|
$sform->display(); |
|
49
|
|
|
smart_close_collapsable($collaps_name); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
include_once __DIR__ . '/admin_header.php'; |
|
53
|
|
|
|
|
54
|
|
|
$op = ''; |
|
55
|
|
|
if (isset($_GET['op'])) { |
|
56
|
|
|
$op = $_GET['op']; |
|
57
|
|
|
} |
|
58
|
|
|
if (isset($_POST['op'])) { |
|
59
|
|
|
$op = $_POST['op']; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
switch ($op) { |
|
63
|
|
|
case 'mod': |
|
64
|
|
|
$offerid = isset($_GET['offerid']) ? (int)$_GET['offerid'] : 0; |
|
65
|
|
|
$fct = isset($_GET['fct']) ? $_GET['fct'] : ''; |
|
66
|
|
|
smart_xoops_cp_header(); |
|
67
|
|
|
|
|
68
|
|
|
editoffer(true, $offerid, $fct); |
|
69
|
|
|
break; |
|
70
|
|
|
|
|
71
|
|
|
case 'addoffer': |
|
72
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
73
|
|
|
|
|
74
|
|
|
$controller = new SmartObjectController($smartPartnerOfferHandler); |
|
75
|
|
|
$offerObj = $controller->storeSmartObject(); |
|
76
|
|
|
$fct = isset($_POST['fct']) ? $_POST['fct'] : ''; |
|
77
|
|
|
|
|
78
|
|
|
if ($offerObj->hasError()) { |
|
79
|
|
|
redirect_header($smart_previous_page, 3, _CO_SOBJECT_SAVE_ERROR . $offerObj->getHtmlErrors()); |
|
80
|
|
|
} else { |
|
81
|
|
|
$partnerObj = $smartPartnerPartnerHandler->get($offerObj->getVar('partnerid', 'e')); |
|
82
|
|
|
$partnerObj->setUpdated(); |
|
83
|
|
|
if ($_POST['offerid'] == '') { |
|
84
|
|
|
$offerObj->sendNotifications(array(_SPARTNER_NOT_OFFER_NEW)); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
redirect_header(smart_get_page_before_form(), 3, _CO_SOBJECT_SAVE_SUCCESS); |
|
88
|
|
|
} |
|
89
|
|
|
exit; |
|
90
|
|
|
break; |
|
91
|
|
|
|
|
92
|
|
|
case 'del': |
|
93
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
94
|
|
|
$controller = new SmartObjectController($smartPartnerOfferHandler); |
|
95
|
|
|
$controller->handleObjectDeletion(); |
|
96
|
|
|
break; |
|
97
|
|
|
|
|
98
|
|
|
case 'default': |
|
99
|
|
|
default: |
|
100
|
|
|
include_once(XOOPS_ROOT_PATH . '/modules/smartobject/include/functions.php'); |
|
101
|
|
|
smart_xoops_cp_header(); |
|
102
|
|
|
|
|
103
|
|
|
//add navigation icon |
|
104
|
|
|
$indexAdmin = new ModuleAdmin(); |
|
105
|
|
|
echo $indexAdmin->addNavigation(basename(__FILE__)); |
|
106
|
|
|
|
|
107
|
|
|
//add button for creating a new offer |
|
108
|
|
|
$indexAdmin->addItemButton(_AM_SPARTNER_OFFER_CREATE, 'offer.php?op=mod', 'add', ''); |
|
109
|
|
|
echo $indexAdmin->renderButton('left', ''); |
|
110
|
|
|
|
|
111
|
|
|
//smart_adminMenu(3, _AM_SPARTNER_OFFERS); |
|
112
|
|
|
|
|
113
|
|
|
// echo "<br>\n"; |
|
114
|
|
|
// echo "<form><div style=\"margin-bottom: 12px;\">"; |
|
115
|
|
|
// echo "<input type='button' name='button' onclick=\"location='offer.php?op=mod'\" value='" . _AM_SPARTNER_OFFER_CREATE . "'> "; |
|
116
|
|
|
// echo "</div></form>"; |
|
117
|
|
|
|
|
118
|
|
|
smart_collapsableBar('createdoffers', _AM_SPARTNER_OFFERS, _AM_SPARTNER_OFFERS_DSC); |
|
119
|
|
|
|
|
120
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjecttable.php'; |
|
121
|
|
|
$objectTable = new SmartObjectTable($smartPartnerOfferHandler); |
|
122
|
|
|
$objectTable->addFilter('partnerid', 'getPartnerList'); |
|
123
|
|
|
$objectTable->addFilter('status', 'getStatusList'); |
|
124
|
|
|
$objectTable->addColumn(new SmartObjectColumn('title', 'left')); |
|
125
|
|
|
$objectTable->addColumn(new SmartObjectColumn('partnerid', 'center', 100)); |
|
126
|
|
|
$objectTable->addColumn(new SmartObjectColumn('status', 'center', 100)); |
|
127
|
|
|
$objectTable->render(); |
|
128
|
|
|
|
|
129
|
|
|
echo '<br>'; |
|
130
|
|
|
smart_close_collapsable('createdoffers'); |
|
131
|
|
|
echo '<br>'; |
|
132
|
|
|
|
|
133
|
|
|
break; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
//smart_modFooter(); |
|
137
|
|
|
//xoops_cp_footer(); |
|
138
|
|
|
include_once __DIR__ . '/admin_footer.php'; |
|
139
|
|
|
|
Instead of relying on
globalstate, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state