1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/** |
3
|
|
|
* @城市表单 |
4
|
|
|
* @license http://www.blags.org/ |
5
|
|
|
* @created :2010年05月20日 23时52分 |
6
|
|
|
* @copyright 1997-2010 The Martin Group |
7
|
|
|
* @author Martin <[email protected]> |
8
|
|
|
* */ |
9
|
|
|
if (!defined('XOOPS_ROOT_PATH')) { |
10
|
|
|
return; |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class form_group |
17
|
|
|
*/ |
18
|
|
|
class form_group extends XoopsThemeForm |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* form_group constructor. |
22
|
|
|
* @param $GroupObj |
23
|
|
|
* @param $RoomList |
24
|
|
|
* @param $HotelList |
25
|
|
|
*/ |
26
|
|
|
public function __construct(&$GroupObj, &$RoomList, &$HotelList) |
27
|
|
|
{ |
28
|
|
|
$this->Obj = &$GroupObj; |
29
|
|
|
$this->RoomList = &$RoomList; |
30
|
|
|
$this->HotelList = &$HotelList; |
31
|
|
|
parent::__construct(_AM_MARTIN_HOTEL_GROUP_BUY, "op", xoops_getenv('PHP_SELF') . "?action=save"); |
32
|
|
|
$this->setExtra('enctype="multipart/form-data"'); |
33
|
|
|
|
34
|
|
|
$this->createElements(); |
35
|
|
|
$this->createButtons(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* created elements |
40
|
|
|
* @license http://www.blags.org/ |
41
|
|
|
* @created :2010年05月21日 20时40分 |
42
|
|
|
* @copyright 1997-2010 The Martin Group |
43
|
|
|
* @author Martin <[email protected]> |
44
|
|
|
* */ |
45
|
|
|
public function createElements() |
46
|
|
|
{ |
47
|
|
|
//include_once MARTIN_ROOT_PATH . '/include/formdatetime.php'; |
|
|
|
|
48
|
|
|
include_once XOOPS_ROOT_PATH . "/modules/martin/class/xoopsformloader.php"; |
49
|
|
|
include_once MARTIN_ROOT_PATH . '/include/formdatetime.php'; |
50
|
|
|
|
51
|
|
|
$RoomStr = ''; |
52
|
|
View Code Duplication |
foreach ($this->RoomList as $room) { |
|
|
|
|
53
|
|
|
$RoomStr .= "<br><input type=checkbox name=room_id[] value={$room['room_id']} id=room_{$room['room_id']} checked=\"checked\" click=\"RoomRemove(this)\"> <label for=room_{$room['room_id']}>{$room['room_name']}</label> "._AM_MARTIN_NUMBER_OF_ROOMS.":<input type=text name=\"room_count_{$room['room_id']}\" value={$room['room_count']}>"; |
54
|
|
|
} |
55
|
|
|
$js = '<script type=\'text/javascript\'> |
56
|
|
|
jQuery.noConflict(); |
57
|
|
|
jQuery(document).ready(function($){ |
58
|
|
|
$("#hotel_id").click(function(){ |
59
|
|
|
var hotel_id = Number($(this).val()); |
60
|
|
|
$.post("martin.ajax.php?action=getroomlist",{hotel_id:hotel_id},function(data){ |
61
|
|
|
$("#room").html(data); |
62
|
|
|
}); |
63
|
|
|
}); |
64
|
|
|
}); |
65
|
|
|
function roomSelect(event) |
66
|
|
|
{ |
67
|
|
|
var room_id = Number(jQuery("#ajaxroom").val()); |
68
|
|
|
var room_name = jQuery.trim(jQuery("#ajaxroom option:selected").text()); |
69
|
|
|
var roomExist = document.getElementById("room_"+room_id); |
70
|
|
|
if(roomExist) return false; |
71
|
|
|
if(room_id > 0) |
72
|
|
|
{ |
73
|
|
|
var Str = "<br><input type=checkbox name=room_id[] value="+room_id+" id=room_"+room_id+" checked=\"checked\" click=\"RoomRemove(this)\"> "+"<label for=room_"+room_id+">" + room_name + "</label>"; |
74
|
|
|
var inputStr = " "._AM_MARTIN_NUMBER_OF_ROOMS.":<input type=text name=\"room_count_"+room_id+"\" value=1>"; |
75
|
|
|
jQuery("#rooms").append(Str + inputStr); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
</script>'; |
79
|
|
|
$Room = new XoopsFormElementTray($js . _AM_MARTIN_SELECT_ROOMS . '<br>' . _AM_MARTIN_FILTER_BY_HOTEL); |
80
|
|
|
$RoomElement = new XoopsFormSelect('', 'hotel_id', $this->HotelList, 5, false); |
81
|
|
|
$RoomElement->addOptionArray($this->HotelList); |
82
|
|
|
//$RoomElement->addOption('class','hotel'); |
|
|
|
|
83
|
|
|
$Room->addElement($RoomElement, false); |
84
|
|
|
$Room->addElement(new XoopsFormElementTray('<br><br><div id="room"></div><div id="rooms">' . $RoomStr . '</div>'), false); |
85
|
|
|
|
86
|
|
|
$this->addElement($Room, false); |
87
|
|
|
|
88
|
|
|
$this->addElement(new XoopsFormTextDateSelect(_AM_MARTIN_CHECK_IN, 'check_in_date', $size = 15, $this->Obj->check_in_date(), false), true); |
89
|
|
|
|
90
|
|
|
$this->addElement(new XoopsFormTextDateSelect(_AM_MARTIN_LAUNCH_TIME, 'check_out_date', $size = 15, $this->Obj->check_out_date(), false), true); |
91
|
|
|
//$this->addElement( new XoopsFormTextDateSelect(_AM_MARTIN_HOTEL_APPLY_START_TIME, 'apply_start_date', $size = 15, $this->Obj->apply_start_date(),false ) ,true); |
|
|
|
|
92
|
|
|
$this->addElement(new MartinFormDateTime(_AM_MARTIN_HOTEL_APPLY_START_TIME, 'apply_start_date', $size = 15, $this->Obj->apply_start_date()), true); |
93
|
|
|
//$this->addElement( new XoopsFormTextDateSelect(_AM_MARTIN_END_BUY_TIME, 'apply_end_date', $size = 15, $this->Obj->apply_end_date() ) ,true); |
|
|
|
|
94
|
|
|
$this->addElement(new MartinFormDateTime(_AM_MARTIN_END_BUY_TIME, 'apply_end_date', $size = 15, $this->Obj->apply_end_date()), true); |
95
|
|
|
|
96
|
|
|
$this->addElement(new XoopsFormText(_AM_MARTIN_PRICE, 'group_price', 11, 11, $this->Obj->group_price()), true); |
97
|
|
|
$this->addElement(new XoopsFormText(_AM_MARTIN_GIFT_VOUCHER . '?', 'group_sented_coupon', 11, 11, (int)($this->Obj->group_sented_coupon())), true); |
98
|
|
|
$this->addElement(new XoopsFormRadioYN(_AM_MARTIN_CAN_YOU_USE_CASH_VOLUME, 'group_can_use_coupon', $this->Obj->group_can_use_coupon(), _YES, _NO), true); |
99
|
|
|
$this->addElement(new XoopsFormRadioYN(_AM_MARTIN_STATUS, 'group_status', $this->Obj->group_status(), _AM_MARTIN_PUBLISHED, _AM_MARTIN_DRAFT), true); |
100
|
|
|
|
101
|
|
|
$this->addElement(new XoopsFormText(_AM_MARTIN_TITLE, 'group_name', 50, 255, $this->Obj->group_name()), true); |
102
|
|
|
$editor = 'tinymce'; |
103
|
|
|
$group_info = $this->Obj->group_info(); |
104
|
|
|
//var_dump($group_info); |
105
|
|
|
$editor_configs = array(); |
106
|
|
|
$editor_configs["name"] = "group_info"; |
107
|
|
|
$editor_configs["value"] = $group_info; |
108
|
|
|
$editor_configs["rows"] = empty($xoopsModuleConfig["editor_rows"]) ? 35 : $xoopsModuleConfig["editor_rows"]; |
|
|
|
|
109
|
|
|
$editor_configs["cols"] = empty($xoopsModuleConfig["editor_cols"]) ? 60 : $xoopsModuleConfig["editor_cols"]; |
110
|
|
|
$editor_configs["width"] = empty($xoopsModuleConfig["editor_width"]) ? "100%" : $xoopsModuleConfig["editor_width"]; |
111
|
|
|
$editor_configs["height"] = empty($xoopsModuleConfig["editor_height"]) ? "400px" : $xoopsModuleConfig["editor_height"]; |
112
|
|
|
|
113
|
|
|
$this->addElement(new XoopsFormEditor(_AM_MARTIN_CUSTOMERS_DETAILS, $editor, $editor_configs, false, $onfailure = null), false); |
114
|
|
|
$this->addElement(new XoopsFormHidden('id', $this->Obj->group_id())); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @创建按钮 |
119
|
|
|
* @license http://www.blags.org/ |
120
|
|
|
* @created :2010年05月20日 23时52分 |
121
|
|
|
* @copyright 1997-2010 The Martin Group |
122
|
|
|
* @author Martin <[email protected]> |
123
|
|
|
* */ |
124
|
|
View Code Duplication |
public function createButtons() |
|
|
|
|
125
|
|
|
{ |
126
|
|
|
$button_tray = new XoopsFormElementTray('', ''); |
127
|
|
|
// No ID for category -- then it's new category, button says 'Create' |
128
|
|
|
if (!$this->Obj->group_id()) { |
129
|
|
|
$butt_create = new XoopsFormButton('', '', _SUBMIT, 'submit'); |
130
|
|
|
$butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"'); |
131
|
|
|
$button_tray->addElement($butt_create); |
132
|
|
|
|
133
|
|
|
$butt_clear = new XoopsFormButton('', '', _RESET, 'reset'); |
134
|
|
|
$button_tray->addElement($butt_clear); |
135
|
|
|
|
136
|
|
|
$butt_cancel = new XoopsFormButton('', '', _CANCEL, 'button'); |
137
|
|
|
$butt_cancel->setExtra('onclick="history.go(-1)"'); |
138
|
|
|
$button_tray->addElement($butt_cancel); |
139
|
|
|
|
140
|
|
|
$this->addElement($button_tray); |
141
|
|
|
} else { |
142
|
|
|
// button says 'Update' |
143
|
|
|
$butt_create = new XoopsFormButton('', '', _EDIT, 'submit'); |
144
|
|
|
$butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"'); |
145
|
|
|
$button_tray->addElement($butt_create); |
146
|
|
|
|
147
|
|
|
$butt_clear = new XoopsFormButton('', '', _RESET, 'reset'); |
148
|
|
|
$button_tray->addElement($butt_clear); |
149
|
|
|
|
150
|
|
|
$butt_cancel = new XoopsFormButton('', '', _CANCEL, 'button'); |
151
|
|
|
$butt_cancel->setExtra('onclick="history.go(-1)"'); |
152
|
|
|
$button_tray->addElement($butt_cancel); |
153
|
|
|
|
154
|
|
|
$this->addElement($button_tray); |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.