Conditions | 11 |
Paths | 4 |
Total Lines | 135 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
43 | public function createElements() |
||
44 | { |
||
45 | $Price = &$this->Obj; |
||
46 | $today = (int)(date('d')); |
||
47 | $MouthDays = (int)($this->MouthDays(date('m'))); |
||
48 | |||
49 | $js = '<script type=\'text/javascript\'> |
||
50 | jQuery.noConflict(); |
||
51 | jQuery(document).ready(function($){ |
||
52 | $("#sub").click(function(){ |
||
53 | var result = true; |
||
54 | $("form input[type=text]").each(function(Element){ |
||
55 | if($.trim($(this).val()) == "" && $.trim($(this).attr("class")) != "") |
||
56 | { |
||
57 | $(this).focus(); |
||
58 | result = false; |
||
59 | return false; |
||
60 | } |
||
61 | }); |
||
62 | if(result) |
||
63 | { |
||
64 | $("#op").submit(); |
||
65 | }else{ |
||
66 | alert("只能数字,不能为空"); |
||
67 | } |
||
68 | }); |
||
69 | $(".sel").click(function(){ |
||
70 | var Check = $(this).prev("input[type=checkbox]").attr("checked") ? false : true; |
||
71 | $(this).prev("input[type=checkbox]").attr("checked",Check); |
||
72 | }); |
||
73 | /*$(".even").parent("tr").click(function(){ |
||
74 | var Check = $(this).find("input[type=checkbox]").attr("checked") ? false : true; |
||
75 | $(this).find("input[type=checkbox]").attr("checked",Check); |
||
76 | $(this).attr("style","background-color: rgb(0, 255, 0);"); |
||
77 | });*/ |
||
78 | $("#room_price_all").click(function(){ |
||
79 | var value = $(this).next("input").val(); |
||
80 | if(!parseFloat(value)){alert("this must be Number.");$(this).focus();return false;} |
||
81 | $(".room_price").val(value); |
||
82 | }); |
||
83 | $("#room_advisory_range_max_all").click(function(){ |
||
84 | var value = $(this).next("input").val(); |
||
85 | if(!parseFloat(value)){alert("this must be Number.");$(this).focus();return false;} |
||
86 | $(".room_advisory_range_max").val(value); |
||
87 | }); |
||
88 | $("#room_advisory_range_min_all").click(function(){ |
||
89 | var value = $(this).next("input").val(); |
||
90 | if(!parseFloat(value)){alert("this must be Number.");$(this).focus();return false;} |
||
91 | $(".room_advisory_range_small").val(value); |
||
92 | }); |
||
93 | $("#room_sented_coupon_all").click(function(){ |
||
94 | var value = $(this).next("input").val(); |
||
95 | if(!parseFloat(value)){alert("this must be Number.");$(this).focus();return false;} |
||
96 | $(".room_sented_coupon").val(value); |
||
97 | }); |
||
98 | }); |
||
99 | </script>'; |
||
100 | $button_str = ' |
||
101 | <table><tr><td width="150px;align=center;"><input type="button" id="room_price_all" value="ALL"> <input type="text" size=5></td> |
||
102 | <td width="100px;align=center;"><input type="button" id="room_advisory_range_min_all" value="ALL"> <input type="text" size=5></td> |
||
103 | <td width="150px;align=center;"><input type="button" id="room_advisory_range_max_all" value="ALL"> <input type="text" size=5></td> |
||
104 | <td width="150px;align=center;"><input type="button" id="room_sented_coupon_all" value="ALL"> <input type="text" size=5></td></tr></table> |
||
105 | '; |
||
106 | //var_dump($Price); |
||
107 | if (!empty($Price) && is_array($Price) && isset($Price['room_price'])) { |
||
108 | $PriceArea = new XoopsFormElementTray($js . '房间价格'); |
||
109 | $RoomElement = new XoopsFormSelect(_AM_MARTIN_GUEST_ROOM, 'room_id', $Price['room_id'], 1); |
||
110 | $RoomElement->addOptionArray($this->RoomList); |
||
111 | $PriceArea->addElement($RoomElement, true); |
||
112 | $PriceArea->addElement(new XoopsFormText(_AM_MARTIN_PRICE . ':', 'room_price', 11, 11, $Price['room_price']), true); |
||
113 | $PriceArea->addElement(new XoopsFormText(_AM_MARTIN_PRICE_RANGE . ':', 'room_advisory_range_small', 11, 11, $Price['room_advisory_range_small']), true); |
||
114 | $PriceArea->addElement(new XoopsFormText('-', 'room_advisory_range_max', 11, 11, $Price['room_advisory_range_max']), true); |
||
115 | //_AM_MARTIN_GIFT_VOUCHER |
||
116 | $PriceArea->addElement(new XoopsFormText(_AM_MARTIN_GIFT_VOUCHER . ':', 'room_sented_coupon', 11, 11, $Price['room_sented_coupon']), true); |
||
117 | $Special = new XoopsFormCheckBox('', "room_is_today_special", $Price['room_is_today_special']); |
||
118 | $Special->addOption(1, '<label for="room_is_today_special">' . _YES . ' ' . _AM_MARTIN_LAST_MINUTE . '</label>'); |
||
119 | //$PriceArea->addElement(new XoopsFormText('时间:', 'room_date', 11, 11, date("Y-m-d",$Price['room_date'])), true); |
||
120 | $PriceArea->addElement(new XoopsFormHidden('room_date[]', $Price['room_date'])); |
||
121 | $PriceArea->addElement($Special, false); |
||
122 | $this->addElement($PriceArea, false); |
||
123 | } else { |
||
124 | $RoomElement = new XoopsFormSelect($js . _AM_MARTIN_GUEST_ROOM . '<br><font color=red><b>' . _AM_MARTIN_DO_NOT_MODIFY_TIME . '</b></font>', 'room_id', '', 1); |
||
125 | $RoomElement->addOptionArray($this->RoomList); |
||
126 | $this->addElement($RoomElement); |
||
127 | $Select = new XoopsFormElementTray(_AM_MARTIN_BATCH_PROCESSING); |
||
128 | $Select->addElement(new XoopsFormLabel("", $button_str)); |
||
129 | |||
130 | $this->addElement($Select); |
||
131 | |||
132 | //var_dump($Price[1277395200]); |
||
133 | //$countDate = count($Price) > 0 ? count($Price) + $today : $MouthDays + $today; |
||
134 | $countDate = $MouthDays + $today; |
||
135 | for ($today; $today <= $countDate; $today++) { |
||
136 | $date = ($today > $MouthDays) ? date("Y") . '-' . (date("m") + 1) . '-' . ($today - $MouthDays) : date("Y") . '-' . date("m") . '-' . $today; |
||
137 | $dateTime = strtotime($date); |
||
138 | |||
139 | //var_dump($Price[$dateTime]); |
||
140 | // ${"PriceArea" . $today} = new XoopsFormElementTray(_AM_MARTIN_ROOM . $date . ' ' . _AM_MARTIN_PRICE_ON); |
||
141 | ${"PriceArea" . $today} = new XoopsFormElementTray(_AM_MARTIN_ROOM_PRICE_ON_DATE . $date ); |
||
142 | $room_price = new XoopsFormText(_AM_MARTIN_PRICE . ':', 'room_price[]', 11, 11, isset($Price[$dateTime]) ? $Price[$dateTime]['room_price'] : '0.00'); |
||
143 | $room_price->setExtra("class='room_price'"); |
||
144 | ${"PriceArea" . $today}->addElement($room_price, true); |
||
145 | |||
146 | $room_advisory_range_small = new XoopsFormText(_AM_MARTIN_PRICE_RANGE . ':', 'room_advisory_range_small[]', 11, 11, isset($Price[$dateTime]) ? $Price[$dateTime]['room_advisory_range_small'] : '0.00'); |
||
147 | $room_advisory_range_small->setExtra("class='room_advisory_range_small'"); |
||
148 | ${"PriceArea" . $today}->addElement($room_advisory_range_small, true); |
||
149 | |||
150 | $room_advisory_range_max = new XoopsFormText('-', 'room_advisory_range_max[]', 11, 11, isset($Price[$dateTime]) ? $Price[$dateTime]['room_advisory_range_max'] : '0.00'); |
||
151 | $room_advisory_range_max->setExtra("class='room_advisory_range_max'"); |
||
152 | ${"PriceArea" . $today}->addElement($room_advisory_range_max, true); |
||
153 | //_AM_MARTIN_GIFT_VOUCHER |
||
154 | $room_sented_coupon = new XoopsFormText(_AM_MARTIN_GIFT_VOUCHER . ':', 'room_sented_coupon[]', 11, 11, isset($Price[$dateTime]) ? $Price[$dateTime]['room_sented_coupon'] : '0.00'); |
||
155 | $room_sented_coupon->setExtra("class='room_sented_coupon'"); |
||
156 | ${"PriceArea" . $today}->addElement($room_sented_coupon, true); |
||
157 | |||
158 | $Special = new XoopsFormCheckBox('', "room_is_today_special[$dateTime]", isset($Price[$dateTime]) ? $Price[$dateTime]['room_is_today_special'] : 0); |
||
159 | $Special->addOption(1, '<label class="sel">' . _YES . ' ' . _AM_MARTIN_LAST_MINUTE . '</label>'); |
||
160 | //echo isset($Price[$dateTime]) ? $Price[$dateTime]['room_is_today_special'] : 0;echo '<br>'; |
||
161 | //hide time |
||
162 | //${"PriceArea".$today}->addElement(new XoopsFormText('时间:', 'room_date[]', 11, 11, $date), true); |
||
163 | ${"PriceArea" . $today}->addElement(new XoopsFormHidden('room_date[]', $date)); |
||
164 | ${"PriceArea" . $today}->addElement($Special, false); |
||
165 | $this->addElement(${"PriceArea" . $today}, false); |
||
166 | unset(${"PriceArea" . $today}, $dateTime, $date, $room_price, $room_advisory_range_max, $room_advisory_range_small, $room_sented_coupon, $Special); |
||
167 | } |
||
168 | } |
||
169 | /*$this->addElement( new XoopsFormText(_AM_MARTIN_ROOM_NAME, 'room_name', 45, 45, $this->Obj->room_name()), true); |
||
170 | $this->addElement( new XoopsFormText(_AM_MARTIN_ROOMS_AREA, 'room_area', 11, 11, $this->Obj->room_area()), true); |
||
171 | $this->addElement( new XoopsFormText(_AM_MARTIN_ROOM_FLOOR, 'room_floor', 45, 45, $this->Obj->room_floor()), true); |
||
172 | |||
173 | $this->addElement( new XoopsFormText('加价', 'room_add_money', 11, 11, $this->Obj->room_add_money()), false); |
||
174 | $this->addElement( new XoopsFormTextArea('床描述', 'room_bed_info', $this->Obj->room_bed_info()) , false); |
||
175 | $this->addElement( new XoopsFormRadioYN(_AM_MARTIN_ROOM_STATUS, 'room_status', $this->Obj->room_status(), _AM_MARTIN_PUBLISHED, _AM_MARTIN_DRAFT) , true); |
||
176 | $this->addElement( new XoopsFormText(_AM_MARTIN_GIFT_VOUCHER, 'room_sented_coupon', 11, 11, (int)($this->Obj->room_sented_coupon())), false);*/ |
||
177 | } |
||
178 | |||
236 |