@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | |
70 | 70 | if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers |
71 | 71 | { |
72 | - $type=""; |
|
73 | - $sall=""; |
|
72 | + $type=""; |
|
73 | + $sall=""; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
@@ -84,111 +84,111 @@ discard block |
||
84 | 84 | |
85 | 85 | if ($cancel) { |
86 | 86 | |
87 | - $action=''; |
|
87 | + $action=''; |
|
88 | 88 | |
89 | - if (! empty($backtopage)) |
|
90 | - { |
|
91 | - header("Location: ".$backtopage); |
|
92 | - exit; |
|
93 | - } |
|
89 | + if (! empty($backtopage)) |
|
90 | + { |
|
91 | + header("Location: ".$backtopage); |
|
92 | + exit; |
|
93 | + } |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | if ($action == 'add' && $user->rights->asset->write) |
97 | 97 | { |
98 | - $object->label = trim($label); |
|
99 | - $object->accountancy_code_asset = trim($accountancy_code_asset); |
|
100 | - $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); |
|
101 | - $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense); |
|
102 | - $object->note = trim($comment); |
|
103 | - |
|
104 | - // Fill array 'array_options' with data from add form |
|
105 | - $ret = $extrafields->setOptionalsFromPost($extralabels,$object); |
|
106 | - if ($ret < 0) $error++; |
|
107 | - |
|
108 | - if (empty($object->label)) { |
|
109 | - $error++; |
|
110 | - setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), null, 'errors'); |
|
111 | - } |
|
112 | - else { |
|
113 | - $sql = "SELECT label FROM ".MAIN_DB_PREFIX."asset_type WHERE label='".$db->escape($object->label)."'"; |
|
114 | - $result = $db->query($sql); |
|
115 | - if ($result) { |
|
116 | - $num = $db->num_rows($result); |
|
117 | - } |
|
118 | - if ($num) { |
|
119 | - $error++; |
|
120 | - $langs->load("errors"); |
|
121 | - setEventMessages($langs->trans("ErrorLabelAlreadyExists",$login), null, 'errors'); |
|
122 | - } |
|
123 | - } |
|
124 | - |
|
125 | - if (! $error) |
|
126 | - { |
|
127 | - $id=$object->create($user); |
|
128 | - if ($id > 0) |
|
129 | - { |
|
130 | - header("Location: ".$_SERVER["PHP_SELF"]); |
|
131 | - exit; |
|
132 | - } |
|
133 | - else |
|
134 | - { |
|
135 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
136 | - $action = 'create'; |
|
137 | - } |
|
138 | - } |
|
139 | - else |
|
140 | - { |
|
141 | - $action = 'create'; |
|
142 | - } |
|
98 | + $object->label = trim($label); |
|
99 | + $object->accountancy_code_asset = trim($accountancy_code_asset); |
|
100 | + $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); |
|
101 | + $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense); |
|
102 | + $object->note = trim($comment); |
|
103 | + |
|
104 | + // Fill array 'array_options' with data from add form |
|
105 | + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); |
|
106 | + if ($ret < 0) $error++; |
|
107 | + |
|
108 | + if (empty($object->label)) { |
|
109 | + $error++; |
|
110 | + setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), null, 'errors'); |
|
111 | + } |
|
112 | + else { |
|
113 | + $sql = "SELECT label FROM ".MAIN_DB_PREFIX."asset_type WHERE label='".$db->escape($object->label)."'"; |
|
114 | + $result = $db->query($sql); |
|
115 | + if ($result) { |
|
116 | + $num = $db->num_rows($result); |
|
117 | + } |
|
118 | + if ($num) { |
|
119 | + $error++; |
|
120 | + $langs->load("errors"); |
|
121 | + setEventMessages($langs->trans("ErrorLabelAlreadyExists",$login), null, 'errors'); |
|
122 | + } |
|
123 | + } |
|
124 | + |
|
125 | + if (! $error) |
|
126 | + { |
|
127 | + $id=$object->create($user); |
|
128 | + if ($id > 0) |
|
129 | + { |
|
130 | + header("Location: ".$_SERVER["PHP_SELF"]); |
|
131 | + exit; |
|
132 | + } |
|
133 | + else |
|
134 | + { |
|
135 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
136 | + $action = 'create'; |
|
137 | + } |
|
138 | + } |
|
139 | + else |
|
140 | + { |
|
141 | + $action = 'create'; |
|
142 | + } |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | if ($action == 'update' && $user->rights->asset->write) |
146 | 146 | { |
147 | - $object->fetch($rowid); |
|
147 | + $object->fetch($rowid); |
|
148 | 148 | |
149 | - $object->oldcopy = clone $object; |
|
149 | + $object->oldcopy = clone $object; |
|
150 | 150 | |
151 | - $object->label = trim($label); |
|
152 | - $object->accountancy_code_asset = trim($accountancy_code_asset); |
|
153 | - $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); |
|
154 | - $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense); |
|
155 | - $object->note = trim($comment); |
|
151 | + $object->label = trim($label); |
|
152 | + $object->accountancy_code_asset = trim($accountancy_code_asset); |
|
153 | + $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); |
|
154 | + $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense); |
|
155 | + $object->note = trim($comment); |
|
156 | 156 | |
157 | - // Fill array 'array_options' with data from add form |
|
158 | - $ret = $extrafields->setOptionalsFromPost($extralabels,$object); |
|
159 | - if ($ret < 0) $error++; |
|
157 | + // Fill array 'array_options' with data from add form |
|
158 | + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); |
|
159 | + if ($ret < 0) $error++; |
|
160 | 160 | |
161 | - $ret=$object->update($user); |
|
161 | + $ret=$object->update($user); |
|
162 | 162 | |
163 | - if ($ret >= 0 && ! count($object->errors)) |
|
164 | - { |
|
165 | - setEventMessages($langs->trans("AssetsTypeModified"), null, 'mesgs'); |
|
166 | - } |
|
167 | - else |
|
168 | - { |
|
169 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
170 | - } |
|
163 | + if ($ret >= 0 && ! count($object->errors)) |
|
164 | + { |
|
165 | + setEventMessages($langs->trans("AssetsTypeModified"), null, 'mesgs'); |
|
166 | + } |
|
167 | + else |
|
168 | + { |
|
169 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
170 | + } |
|
171 | 171 | |
172 | - header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$object->id); |
|
173 | - exit; |
|
172 | + header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$object->id); |
|
173 | + exit; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | if ($action == 'confirm_delete' && $user->rights->asset->write) |
177 | 177 | { |
178 | - $object->fetch($rowid); |
|
179 | - $res=$object->delete(); |
|
180 | - |
|
181 | - if ($res > 0) |
|
182 | - { |
|
183 | - setEventMessages($langs->trans("AssetsTypeDeleted"), null, 'mesgs'); |
|
184 | - header("Location: ".$_SERVER["PHP_SELF"]); |
|
185 | - exit; |
|
186 | - } |
|
187 | - else |
|
188 | - { |
|
189 | - setEventMessages($langs->trans("AssetsTypeCanNotBeDeleted"), null, 'errors'); |
|
190 | - $action=''; |
|
191 | - } |
|
178 | + $object->fetch($rowid); |
|
179 | + $res=$object->delete(); |
|
180 | + |
|
181 | + if ($res > 0) |
|
182 | + { |
|
183 | + setEventMessages($langs->trans("AssetsTypeDeleted"), null, 'mesgs'); |
|
184 | + header("Location: ".$_SERVER["PHP_SELF"]); |
|
185 | + exit; |
|
186 | + } |
|
187 | + else |
|
188 | + { |
|
189 | + setEventMessages($langs->trans("AssetsTypeCanNotBeDeleted"), null, 'errors'); |
|
190 | + $action=''; |
|
191 | + } |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | |
@@ -204,116 +204,116 @@ discard block |
||
204 | 204 | // List of asset type |
205 | 205 | if (! $rowid && $action != 'create' && $action != 'edit') |
206 | 206 | { |
207 | - //dol_fiche_head(''); |
|
208 | - |
|
209 | - $sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note"; |
|
210 | - $sql.= " FROM ".MAIN_DB_PREFIX."asset_type as d"; |
|
211 | - $sql.= " WHERE d.entity IN (".getEntity('asset_type').")"; |
|
212 | - |
|
213 | - $result = $db->query($sql); |
|
214 | - if ($result) |
|
215 | - { |
|
216 | - $num = $db->num_rows($result); |
|
217 | - $nbtotalofrecords = $num; |
|
218 | - |
|
219 | - $i = 0; |
|
220 | - |
|
221 | - $param = ''; |
|
222 | - |
|
223 | - print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; |
|
224 | - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
225 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
226 | - print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
|
227 | - print '<input type="hidden" name="action" value="list">'; |
|
228 | - print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; |
|
229 | - print '<input type="hidden" name="page" value="'.$page.'">'; |
|
230 | - print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; |
|
231 | - |
|
232 | - print_barre_liste($langs->trans("AssetsTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); |
|
233 | - |
|
234 | - $moreforfilter = ''; |
|
235 | - |
|
236 | - print '<div class="div-table-responsive">'; |
|
237 | - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; |
|
238 | - |
|
239 | - print '<tr class="liste_titre">'; |
|
240 | - print '<th>'.$langs->trans("Ref").'</th>'; |
|
241 | - print '<th>'.$langs->trans("Label").'</th>'; |
|
242 | - print '<th align="center">'.$langs->trans("AccountancyCodeAsset").'</th>'; |
|
243 | - print '<th align="center">'.$langs->trans("AccountancyCodeDepreciationAsset").'</th>'; |
|
244 | - print '<th align="center">'.$langs->trans("AccountancyCodeDepreciationExpense").'</th>'; |
|
245 | - print '<th> </th>'; |
|
246 | - print "</tr>\n"; |
|
247 | - |
|
248 | - $assettype = new AssetType($db); |
|
249 | - |
|
250 | - while ($i < $num) |
|
251 | - { |
|
252 | - $objp = $db->fetch_object($result); |
|
253 | - |
|
254 | - $assettype->id = $objp->rowid; |
|
255 | - $assettype->ref = $objp->rowid; |
|
256 | - $assettype->label = $objp->rowid; |
|
257 | - |
|
258 | - print '<tr class="oddeven">'; |
|
259 | - print '<td>'; |
|
260 | - print $assettype->getNomUrl(1); |
|
261 | - //<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a> |
|
262 | - print '</td>'; |
|
263 | - print '<td>'.dol_escape_htmltag($objp->label).'</td>'; |
|
264 | - |
|
265 | - print '<td class="center">'; |
|
266 | - if (! empty($conf->accounting->enabled)) |
|
267 | - { |
|
268 | - $accountingaccount = new AccountingAccount($db); |
|
269 | - $accountingaccount->fetch('',$objp->accountancy_code_asset,1); |
|
270 | - |
|
271 | - print $accountingaccount->getNomUrl(0,0,0,'',0); |
|
272 | - } else { |
|
273 | - print $objp->accountancy_code_asset; |
|
274 | - } |
|
275 | - print '</td>'; |
|
276 | - |
|
277 | - print '<td class="center">'; |
|
278 | - if (! empty($conf->accounting->enabled)) |
|
279 | - { |
|
280 | - $accountingaccount2 = new AccountingAccount($db); |
|
281 | - $accountingaccount2->fetch('',$objp->accountancy_code_depreciation_asset,1); |
|
282 | - |
|
283 | - print $accountingaccount2->getNomUrl(0,0,0,'',0); |
|
284 | - } else { |
|
285 | - print $objp->accountancy_code_depreciation_asset; |
|
286 | - } |
|
287 | - print '</td>'; |
|
288 | - |
|
289 | - print '<td class="center">'; |
|
290 | - if (! empty($conf->accounting->enabled)) |
|
291 | - { |
|
292 | - $accountingaccount3 = new AccountingAccount($db); |
|
293 | - $accountingaccount3->fetch('',$objp->accountancy_code_depreciation_expense,1); |
|
294 | - |
|
295 | - print $accountingaccount3->getNomUrl(0,0,0,'',0); |
|
296 | - } else { |
|
297 | - print $objp->accountancy_code_depreciation_expense; |
|
298 | - } |
|
299 | - print '</td>'; |
|
300 | - |
|
301 | - if ($user->rights->asset->write) |
|
302 | - print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>'; |
|
303 | - else |
|
304 | - print '<td align="right"> </td>'; |
|
305 | - print "</tr>"; |
|
306 | - $i++; |
|
307 | - } |
|
308 | - print "</table>"; |
|
309 | - print '</div>'; |
|
310 | - |
|
311 | - print '</form>'; |
|
312 | - } |
|
313 | - else |
|
314 | - { |
|
315 | - dol_print_error($db); |
|
316 | - } |
|
207 | + //dol_fiche_head(''); |
|
208 | + |
|
209 | + $sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note"; |
|
210 | + $sql.= " FROM ".MAIN_DB_PREFIX."asset_type as d"; |
|
211 | + $sql.= " WHERE d.entity IN (".getEntity('asset_type').")"; |
|
212 | + |
|
213 | + $result = $db->query($sql); |
|
214 | + if ($result) |
|
215 | + { |
|
216 | + $num = $db->num_rows($result); |
|
217 | + $nbtotalofrecords = $num; |
|
218 | + |
|
219 | + $i = 0; |
|
220 | + |
|
221 | + $param = ''; |
|
222 | + |
|
223 | + print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; |
|
224 | + if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
225 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
226 | + print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
|
227 | + print '<input type="hidden" name="action" value="list">'; |
|
228 | + print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; |
|
229 | + print '<input type="hidden" name="page" value="'.$page.'">'; |
|
230 | + print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; |
|
231 | + |
|
232 | + print_barre_liste($langs->trans("AssetsTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); |
|
233 | + |
|
234 | + $moreforfilter = ''; |
|
235 | + |
|
236 | + print '<div class="div-table-responsive">'; |
|
237 | + print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; |
|
238 | + |
|
239 | + print '<tr class="liste_titre">'; |
|
240 | + print '<th>'.$langs->trans("Ref").'</th>'; |
|
241 | + print '<th>'.$langs->trans("Label").'</th>'; |
|
242 | + print '<th align="center">'.$langs->trans("AccountancyCodeAsset").'</th>'; |
|
243 | + print '<th align="center">'.$langs->trans("AccountancyCodeDepreciationAsset").'</th>'; |
|
244 | + print '<th align="center">'.$langs->trans("AccountancyCodeDepreciationExpense").'</th>'; |
|
245 | + print '<th> </th>'; |
|
246 | + print "</tr>\n"; |
|
247 | + |
|
248 | + $assettype = new AssetType($db); |
|
249 | + |
|
250 | + while ($i < $num) |
|
251 | + { |
|
252 | + $objp = $db->fetch_object($result); |
|
253 | + |
|
254 | + $assettype->id = $objp->rowid; |
|
255 | + $assettype->ref = $objp->rowid; |
|
256 | + $assettype->label = $objp->rowid; |
|
257 | + |
|
258 | + print '<tr class="oddeven">'; |
|
259 | + print '<td>'; |
|
260 | + print $assettype->getNomUrl(1); |
|
261 | + //<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a> |
|
262 | + print '</td>'; |
|
263 | + print '<td>'.dol_escape_htmltag($objp->label).'</td>'; |
|
264 | + |
|
265 | + print '<td class="center">'; |
|
266 | + if (! empty($conf->accounting->enabled)) |
|
267 | + { |
|
268 | + $accountingaccount = new AccountingAccount($db); |
|
269 | + $accountingaccount->fetch('',$objp->accountancy_code_asset,1); |
|
270 | + |
|
271 | + print $accountingaccount->getNomUrl(0,0,0,'',0); |
|
272 | + } else { |
|
273 | + print $objp->accountancy_code_asset; |
|
274 | + } |
|
275 | + print '</td>'; |
|
276 | + |
|
277 | + print '<td class="center">'; |
|
278 | + if (! empty($conf->accounting->enabled)) |
|
279 | + { |
|
280 | + $accountingaccount2 = new AccountingAccount($db); |
|
281 | + $accountingaccount2->fetch('',$objp->accountancy_code_depreciation_asset,1); |
|
282 | + |
|
283 | + print $accountingaccount2->getNomUrl(0,0,0,'',0); |
|
284 | + } else { |
|
285 | + print $objp->accountancy_code_depreciation_asset; |
|
286 | + } |
|
287 | + print '</td>'; |
|
288 | + |
|
289 | + print '<td class="center">'; |
|
290 | + if (! empty($conf->accounting->enabled)) |
|
291 | + { |
|
292 | + $accountingaccount3 = new AccountingAccount($db); |
|
293 | + $accountingaccount3->fetch('',$objp->accountancy_code_depreciation_expense,1); |
|
294 | + |
|
295 | + print $accountingaccount3->getNomUrl(0,0,0,'',0); |
|
296 | + } else { |
|
297 | + print $objp->accountancy_code_depreciation_expense; |
|
298 | + } |
|
299 | + print '</td>'; |
|
300 | + |
|
301 | + if ($user->rights->asset->write) |
|
302 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>'; |
|
303 | + else |
|
304 | + print '<td align="right"> </td>'; |
|
305 | + print "</tr>"; |
|
306 | + $i++; |
|
307 | + } |
|
308 | + print "</table>"; |
|
309 | + print '</div>'; |
|
310 | + |
|
311 | + print '</form>'; |
|
312 | + } |
|
313 | + else |
|
314 | + { |
|
315 | + dol_print_error($db); |
|
316 | + } |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | |
@@ -324,83 +324,83 @@ discard block |
||
324 | 324 | /* ************************************************************************** */ |
325 | 325 | if ($action == 'create') |
326 | 326 | { |
327 | - $object = new AssetType($db); |
|
328 | - if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); |
|
329 | - |
|
330 | - print load_fiche_titre($langs->trans("NewAssetType")); |
|
331 | - |
|
332 | - print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">'; |
|
333 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
334 | - print '<input type="hidden" name="action" value="add">'; |
|
335 | - |
|
336 | - dol_fiche_head(''); |
|
337 | - |
|
338 | - print '<table class="border" width="100%">'; |
|
339 | - print '<tbody>'; |
|
340 | - |
|
341 | - print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40"></td></tr>'; |
|
342 | - |
|
343 | - if (! empty($conf->accounting->enabled)) |
|
344 | - { |
|
345 | - // Accountancy_code_asset |
|
346 | - print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>'; |
|
347 | - print '<td>'; |
|
348 | - print $formaccounting->select_account($object->accountancy_code_asset, 'accountancy_code_asset', 1, '', 1, 1); |
|
349 | - print '</td></tr>'; |
|
350 | - |
|
351 | - // Accountancy_code_depreciation_expense |
|
352 | - print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationAsset").'</td>'; |
|
353 | - print '<td>'; |
|
354 | - print $formaccounting->select_account($object->accountancy_code_depreciation_asset, 'accountancy_code_depreciation_asset', 1, '', 1, 1); |
|
355 | - print '</td></tr>'; |
|
356 | - |
|
357 | - // Accountancy_code_depreciation_expense |
|
358 | - print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationExpense").'</td>'; |
|
359 | - print '<td>'; |
|
360 | - print $formaccounting->select_account($object->accountancy_code_depreciation_expense, 'accountancy_code_depreciation_expense', 1, '', 1, 1); |
|
361 | - print '</td></tr>'; |
|
362 | - } |
|
363 | - else // For external software |
|
364 | - { |
|
365 | - // Accountancy_code_asset |
|
366 | - print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>'; |
|
367 | - print '<td><input name="accountancy_code_asset" class="maxwidth200" value="'.$object->accountancy_code_asset.'">'; |
|
368 | - print '</td></tr>'; |
|
369 | - |
|
370 | - // Accountancy_code_depreciation_asset |
|
371 | - print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationAsset").'</td>'; |
|
372 | - print '<td><input name="accountancy_code_depreciation_asset" class="maxwidth200" value="'.$object->accountancy_code_depreciation_asset.'">'; |
|
373 | - print '</td></tr>'; |
|
374 | - |
|
375 | - // Accountancy_code_depreciation_expense |
|
376 | - print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationExpense").'</td>'; |
|
377 | - print '<td><input name="accountancy_code_depreciation_expense" class="maxwidth200" value="'.$object->accountancy_code_depreciation_expense.'">'; |
|
378 | - print '</td></tr>'; |
|
379 | - } |
|
380 | - |
|
381 | - print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>'; |
|
382 | - print '<textarea name="comment" wrap="soft" class="centpercent" rows="3"></textarea></td></tr>'; |
|
383 | - |
|
384 | - // Other attributes |
|
385 | - $parameters=array(); |
|
386 | - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook |
|
387 | - print $hookmanager->resPrint; |
|
388 | - if (empty($reshook)) |
|
389 | - { |
|
390 | - print $object->showOptionals($extrafields,'edit'); |
|
391 | - } |
|
392 | - print '<tbody>'; |
|
393 | - print "</table>\n"; |
|
394 | - |
|
395 | - dol_fiche_end(); |
|
396 | - |
|
397 | - print '<div class="center">'; |
|
398 | - print '<input type="submit" name="button" class="button" value="'.$langs->trans("Add").'">'; |
|
399 | - print ' '; |
|
400 | - print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" />'; |
|
401 | - print '</div>'; |
|
402 | - |
|
403 | - print "</form>\n"; |
|
327 | + $object = new AssetType($db); |
|
328 | + if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); |
|
329 | + |
|
330 | + print load_fiche_titre($langs->trans("NewAssetType")); |
|
331 | + |
|
332 | + print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">'; |
|
333 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
334 | + print '<input type="hidden" name="action" value="add">'; |
|
335 | + |
|
336 | + dol_fiche_head(''); |
|
337 | + |
|
338 | + print '<table class="border" width="100%">'; |
|
339 | + print '<tbody>'; |
|
340 | + |
|
341 | + print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40"></td></tr>'; |
|
342 | + |
|
343 | + if (! empty($conf->accounting->enabled)) |
|
344 | + { |
|
345 | + // Accountancy_code_asset |
|
346 | + print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>'; |
|
347 | + print '<td>'; |
|
348 | + print $formaccounting->select_account($object->accountancy_code_asset, 'accountancy_code_asset', 1, '', 1, 1); |
|
349 | + print '</td></tr>'; |
|
350 | + |
|
351 | + // Accountancy_code_depreciation_expense |
|
352 | + print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationAsset").'</td>'; |
|
353 | + print '<td>'; |
|
354 | + print $formaccounting->select_account($object->accountancy_code_depreciation_asset, 'accountancy_code_depreciation_asset', 1, '', 1, 1); |
|
355 | + print '</td></tr>'; |
|
356 | + |
|
357 | + // Accountancy_code_depreciation_expense |
|
358 | + print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationExpense").'</td>'; |
|
359 | + print '<td>'; |
|
360 | + print $formaccounting->select_account($object->accountancy_code_depreciation_expense, 'accountancy_code_depreciation_expense', 1, '', 1, 1); |
|
361 | + print '</td></tr>'; |
|
362 | + } |
|
363 | + else // For external software |
|
364 | + { |
|
365 | + // Accountancy_code_asset |
|
366 | + print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>'; |
|
367 | + print '<td><input name="accountancy_code_asset" class="maxwidth200" value="'.$object->accountancy_code_asset.'">'; |
|
368 | + print '</td></tr>'; |
|
369 | + |
|
370 | + // Accountancy_code_depreciation_asset |
|
371 | + print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationAsset").'</td>'; |
|
372 | + print '<td><input name="accountancy_code_depreciation_asset" class="maxwidth200" value="'.$object->accountancy_code_depreciation_asset.'">'; |
|
373 | + print '</td></tr>'; |
|
374 | + |
|
375 | + // Accountancy_code_depreciation_expense |
|
376 | + print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationExpense").'</td>'; |
|
377 | + print '<td><input name="accountancy_code_depreciation_expense" class="maxwidth200" value="'.$object->accountancy_code_depreciation_expense.'">'; |
|
378 | + print '</td></tr>'; |
|
379 | + } |
|
380 | + |
|
381 | + print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>'; |
|
382 | + print '<textarea name="comment" wrap="soft" class="centpercent" rows="3"></textarea></td></tr>'; |
|
383 | + |
|
384 | + // Other attributes |
|
385 | + $parameters=array(); |
|
386 | + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook |
|
387 | + print $hookmanager->resPrint; |
|
388 | + if (empty($reshook)) |
|
389 | + { |
|
390 | + print $object->showOptionals($extrafields,'edit'); |
|
391 | + } |
|
392 | + print '<tbody>'; |
|
393 | + print "</table>\n"; |
|
394 | + |
|
395 | + dol_fiche_end(); |
|
396 | + |
|
397 | + print '<div class="center">'; |
|
398 | + print '<input type="submit" name="button" class="button" value="'.$langs->trans("Add").'">'; |
|
399 | + print ' '; |
|
400 | + print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" />'; |
|
401 | + print '</div>'; |
|
402 | + |
|
403 | + print "</form>\n"; |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | /* ************************************************************************** */ |
@@ -410,232 +410,232 @@ discard block |
||
410 | 410 | /* ************************************************************************** */ |
411 | 411 | if ($rowid > 0) |
412 | 412 | { |
413 | - if ($action != 'edit') |
|
414 | - { |
|
415 | - $object = new AssetType($db); |
|
416 | - $object->fetch($rowid); |
|
417 | - $object->fetch_optionals(); |
|
413 | + if ($action != 'edit') |
|
414 | + { |
|
415 | + $object = new AssetType($db); |
|
416 | + $object->fetch($rowid); |
|
417 | + $object->fetch_optionals(); |
|
418 | 418 | |
419 | - /* |
|
419 | + /* |
|
420 | 420 | * Confirmation suppression |
421 | 421 | */ |
422 | - if ($action == 'delete') |
|
423 | - { |
|
424 | - print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id,$langs->trans("DeleteAnAssetType"),$langs->trans("ConfirmDeleteAssetType",$object->label),"confirm_delete", '',0,1); |
|
425 | - } |
|
426 | - |
|
427 | - $head = asset_type_prepare_head($object); |
|
428 | - |
|
429 | - dol_fiche_head($head, 'card', $langs->trans("AssetType"), -1, 'setup'); |
|
430 | - |
|
431 | - $linkback = '<a href="'.DOL_URL_ROOT.'/asset/type.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; |
|
432 | - |
|
433 | - $morehtmlref='<div class="refidno">'; |
|
434 | - // Ref asset type |
|
435 | - $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', 0, 1); |
|
436 | - $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', null, null, '', 1); |
|
437 | - $morehtmlref.='</div>'; |
|
438 | - |
|
439 | - dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); |
|
440 | - |
|
441 | - print '<div class="fichecenter">'; |
|
442 | - print '<div class="underbanner clearboth"></div>'; |
|
443 | - |
|
444 | - print '<table class="border" width="100%">'; |
|
445 | - |
|
446 | - print '<tr>'; |
|
447 | - print '<td class="nowrap">'; |
|
448 | - print $langs->trans("AccountancyCodeAsset"); |
|
449 | - print '</td><td>'; |
|
450 | - if (! empty($conf->accounting->enabled)) |
|
451 | - { |
|
452 | - $accountingaccount = new AccountingAccount($db); |
|
453 | - $accountingaccount->fetch('',$object->accountancy_code_asset,1); |
|
454 | - |
|
455 | - print $accountingaccount->getNomUrl(0,1,1,'',1); |
|
456 | - } else { |
|
457 | - print $object->accountancy_code_asset; |
|
458 | - } |
|
459 | - print '</td>'; |
|
460 | - print '</tr>'; |
|
461 | - |
|
462 | - print '<tr>'; |
|
463 | - print '<td class="nowrap">'; |
|
464 | - print $langs->trans("AccountancyCodeDepreciationAsset"); |
|
465 | - print '</td><td>'; |
|
466 | - if (! empty($conf->accounting->enabled)) |
|
467 | - { |
|
468 | - $accountingaccount2 = new AccountingAccount($db); |
|
469 | - $accountingaccount2->fetch('',$object->accountancy_code_depreciation_asset,1); |
|
470 | - |
|
471 | - print $accountingaccount2->getNomUrl(0,1,1,'',1); |
|
472 | - } else { |
|
473 | - print $object->accountancy_code_depreciation_asset; |
|
474 | - } |
|
475 | - print '</td>'; |
|
476 | - print '</tr>'; |
|
477 | - |
|
478 | - print '<tr>'; |
|
479 | - print '<td class="nowrap">'; |
|
480 | - print $langs->trans("AccountancyCodeDepreciationExpense"); |
|
481 | - print '</td><td>'; |
|
482 | - if (! empty($conf->accounting->enabled)) |
|
483 | - { |
|
484 | - $accountingaccount3 = new AccountingAccount($db); |
|
485 | - $accountingaccount3->fetch('',$object->accountancy_code_depreciation_expense,1); |
|
486 | - |
|
487 | - print $accountingaccount3->getNomUrl(0,1,1,'',1); |
|
488 | - } else { |
|
489 | - print $object->accountancy_code_depreciation_expense; |
|
490 | - } |
|
491 | - print '</td>'; |
|
492 | - print '</tr>'; |
|
493 | - |
|
494 | - print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>'; |
|
495 | - print nl2br($object->note)."</td></tr>"; |
|
496 | - |
|
497 | - // Other attributes |
|
498 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
499 | - |
|
500 | - print '</table>'; |
|
501 | - print '</div>'; |
|
502 | - |
|
503 | - dol_fiche_end(); |
|
504 | - |
|
505 | - /* |
|
422 | + if ($action == 'delete') |
|
423 | + { |
|
424 | + print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id,$langs->trans("DeleteAnAssetType"),$langs->trans("ConfirmDeleteAssetType",$object->label),"confirm_delete", '',0,1); |
|
425 | + } |
|
426 | + |
|
427 | + $head = asset_type_prepare_head($object); |
|
428 | + |
|
429 | + dol_fiche_head($head, 'card', $langs->trans("AssetType"), -1, 'setup'); |
|
430 | + |
|
431 | + $linkback = '<a href="'.DOL_URL_ROOT.'/asset/type.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; |
|
432 | + |
|
433 | + $morehtmlref='<div class="refidno">'; |
|
434 | + // Ref asset type |
|
435 | + $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', 0, 1); |
|
436 | + $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', null, null, '', 1); |
|
437 | + $morehtmlref.='</div>'; |
|
438 | + |
|
439 | + dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); |
|
440 | + |
|
441 | + print '<div class="fichecenter">'; |
|
442 | + print '<div class="underbanner clearboth"></div>'; |
|
443 | + |
|
444 | + print '<table class="border" width="100%">'; |
|
445 | + |
|
446 | + print '<tr>'; |
|
447 | + print '<td class="nowrap">'; |
|
448 | + print $langs->trans("AccountancyCodeAsset"); |
|
449 | + print '</td><td>'; |
|
450 | + if (! empty($conf->accounting->enabled)) |
|
451 | + { |
|
452 | + $accountingaccount = new AccountingAccount($db); |
|
453 | + $accountingaccount->fetch('',$object->accountancy_code_asset,1); |
|
454 | + |
|
455 | + print $accountingaccount->getNomUrl(0,1,1,'',1); |
|
456 | + } else { |
|
457 | + print $object->accountancy_code_asset; |
|
458 | + } |
|
459 | + print '</td>'; |
|
460 | + print '</tr>'; |
|
461 | + |
|
462 | + print '<tr>'; |
|
463 | + print '<td class="nowrap">'; |
|
464 | + print $langs->trans("AccountancyCodeDepreciationAsset"); |
|
465 | + print '</td><td>'; |
|
466 | + if (! empty($conf->accounting->enabled)) |
|
467 | + { |
|
468 | + $accountingaccount2 = new AccountingAccount($db); |
|
469 | + $accountingaccount2->fetch('',$object->accountancy_code_depreciation_asset,1); |
|
470 | + |
|
471 | + print $accountingaccount2->getNomUrl(0,1,1,'',1); |
|
472 | + } else { |
|
473 | + print $object->accountancy_code_depreciation_asset; |
|
474 | + } |
|
475 | + print '</td>'; |
|
476 | + print '</tr>'; |
|
477 | + |
|
478 | + print '<tr>'; |
|
479 | + print '<td class="nowrap">'; |
|
480 | + print $langs->trans("AccountancyCodeDepreciationExpense"); |
|
481 | + print '</td><td>'; |
|
482 | + if (! empty($conf->accounting->enabled)) |
|
483 | + { |
|
484 | + $accountingaccount3 = new AccountingAccount($db); |
|
485 | + $accountingaccount3->fetch('',$object->accountancy_code_depreciation_expense,1); |
|
486 | + |
|
487 | + print $accountingaccount3->getNomUrl(0,1,1,'',1); |
|
488 | + } else { |
|
489 | + print $object->accountancy_code_depreciation_expense; |
|
490 | + } |
|
491 | + print '</td>'; |
|
492 | + print '</tr>'; |
|
493 | + |
|
494 | + print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>'; |
|
495 | + print nl2br($object->note)."</td></tr>"; |
|
496 | + |
|
497 | + // Other attributes |
|
498 | + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
499 | + |
|
500 | + print '</table>'; |
|
501 | + print '</div>'; |
|
502 | + |
|
503 | + dol_fiche_end(); |
|
504 | + |
|
505 | + /* |
|
506 | 506 | * Buttons |
507 | 507 | */ |
508 | 508 | |
509 | - print '<div class="tabsAction">'; |
|
510 | - |
|
511 | - // Edit |
|
512 | - if ($user->rights->asset->write) |
|
513 | - { |
|
514 | - print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&rowid='.$object->id.'">'.$langs->trans("Modify").'</a></div>'; |
|
515 | - } |
|
516 | - |
|
517 | - // Delete |
|
518 | - if ($user->rights->asset->write) |
|
519 | - { |
|
520 | - print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&rowid='.$object->id.'">'.$langs->trans("DeleteType").'</a></div>'; |
|
521 | - } |
|
522 | - |
|
523 | - print "</div>"; |
|
524 | - } |
|
525 | - |
|
526 | - /* ************************************************************************** */ |
|
527 | - /* */ |
|
528 | - /* Edition mode */ |
|
529 | - /* */ |
|
530 | - /* ************************************************************************** */ |
|
531 | - |
|
532 | - if ($action == 'edit') |
|
533 | - { |
|
534 | - $object = new AssetType($db); |
|
535 | - $object->fetch($rowid); |
|
536 | - $object->fetch_optionals(); |
|
537 | - if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); |
|
538 | - |
|
539 | - $head = asset_type_prepare_head($object); |
|
540 | - |
|
541 | - print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'">'; |
|
542 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
543 | - print '<input type="hidden" name="rowid" value="'.$object->id.'">'; |
|
544 | - print '<input type="hidden" name="action" value="update">'; |
|
545 | - |
|
546 | - dol_fiche_head($head, 'card', $langs->trans("AssetsType"), -1, 'setup'); |
|
547 | - |
|
548 | - print '<table class="border" width="100%">'; |
|
549 | - |
|
550 | - print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>'; |
|
551 | - |
|
552 | - print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>'; |
|
553 | - |
|
554 | - if (! empty($conf->accounting->enabled)) |
|
555 | - { |
|
556 | - // Accountancy_code_asset |
|
557 | - print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>'; |
|
558 | - print '<td>'; |
|
559 | - print $formaccounting->select_account($object->accountancy_code_asset, 'accountancy_code_asset', 1, '', 1, 1); |
|
560 | - print '</td></tr>'; |
|
561 | - |
|
562 | - // Accountancy_code_depreciation_expense |
|
563 | - print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationAsset").'</td>'; |
|
564 | - print '<td>'; |
|
565 | - print $formaccounting->select_account($object->accountancy_code_depreciation_asset, 'accountancy_code_depreciation_asset', 1, '', 1, 1); |
|
566 | - print '</td></tr>'; |
|
567 | - |
|
568 | - // Accountancy_code_depreciation_expense |
|
569 | - print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationExpense").'</td>'; |
|
570 | - print '<td>'; |
|
571 | - print $formaccounting->select_account($object->accountancy_code_depreciation_expense, 'accountancy_code_depreciation_expense', 1, '', 1, 1); |
|
572 | - print '</td></tr>'; |
|
573 | - } |
|
574 | - else // For external software |
|
575 | - { |
|
576 | - // Accountancy_code_asset |
|
577 | - print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>'; |
|
578 | - print '<td><input name="accountancy_code_asset" class="maxwidth200" value="'.$object->accountancy_code_asset.'">'; |
|
579 | - print '</td></tr>'; |
|
580 | - |
|
581 | - // Accountancy_code_depreciation_asset |
|
582 | - print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationAsset").'</td>'; |
|
583 | - print '<td><input name="accountancy_code_depreciation_asset" class="maxwidth200" value="'.$object->accountancy_code_depreciation_asset.'">'; |
|
584 | - print '</td></tr>'; |
|
585 | - |
|
586 | - // Accountancy_code_depreciation_expense |
|
587 | - print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationExpense").'</td>'; |
|
588 | - print '<td><input name="accountancy_code_depreciation_expense" class="maxwidth200" value="'.$object->accountancy_code_depreciation_expense.'">'; |
|
589 | - print '</td></tr>'; |
|
590 | - } |
|
591 | - |
|
592 | - print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>'; |
|
593 | - print '<textarea name="comment" wrap="soft" class="centpercent" rows="3">'.$object->note.'</textarea></td></tr>'; |
|
594 | - |
|
595 | - // Other attributes |
|
596 | - $parameters=array(); |
|
597 | - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook |
|
598 | - print $hookmanager->resPrint; |
|
599 | - if (empty($reshook)) |
|
600 | - { |
|
601 | - print $object->showOptionals($extrafields,'edit'); |
|
602 | - } |
|
603 | - |
|
604 | - print '</table>'; |
|
605 | - |
|
606 | - // Extra field |
|
607 | - if (empty($reshook)) |
|
608 | - { |
|
609 | - print '<br><br><table class="border" width="100%">'; |
|
610 | - foreach($extrafields->attribute_label as $key=>$label) |
|
611 | - { |
|
612 | - if (isset($_POST["options_" . $key])) { |
|
613 | - if (is_array($_POST["options_" . $key])) { |
|
614 | - // $_POST["options"] is an array but following code expects a comma separated string |
|
615 | - $value = implode(",", $_POST["options_" . $key]); |
|
616 | - } else { |
|
617 | - $value = $_POST["options_" . $key]; |
|
618 | - } |
|
619 | - } else { |
|
620 | - $value = $adht->array_options["options_" . $key]; |
|
621 | - } |
|
622 | - print '<tr><td width="30%">'.$label.'</td><td>'; |
|
623 | - print $extrafields->showInputField($key,$value); |
|
624 | - print "</td></tr>\n"; |
|
625 | - } |
|
626 | - print '</table><br><br>'; |
|
627 | - } |
|
628 | - |
|
629 | - dol_fiche_end(); |
|
630 | - |
|
631 | - print '<div class="center">'; |
|
632 | - print '<input type="submit" class="button" value="'.$langs->trans("Save").'">'; |
|
633 | - print ' '; |
|
634 | - print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">'; |
|
635 | - print '</div>'; |
|
636 | - |
|
637 | - print "</form>"; |
|
638 | - } |
|
509 | + print '<div class="tabsAction">'; |
|
510 | + |
|
511 | + // Edit |
|
512 | + if ($user->rights->asset->write) |
|
513 | + { |
|
514 | + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&rowid='.$object->id.'">'.$langs->trans("Modify").'</a></div>'; |
|
515 | + } |
|
516 | + |
|
517 | + // Delete |
|
518 | + if ($user->rights->asset->write) |
|
519 | + { |
|
520 | + print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&rowid='.$object->id.'">'.$langs->trans("DeleteType").'</a></div>'; |
|
521 | + } |
|
522 | + |
|
523 | + print "</div>"; |
|
524 | + } |
|
525 | + |
|
526 | + /* ************************************************************************** */ |
|
527 | + /* */ |
|
528 | + /* Edition mode */ |
|
529 | + /* */ |
|
530 | + /* ************************************************************************** */ |
|
531 | + |
|
532 | + if ($action == 'edit') |
|
533 | + { |
|
534 | + $object = new AssetType($db); |
|
535 | + $object->fetch($rowid); |
|
536 | + $object->fetch_optionals(); |
|
537 | + if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); |
|
538 | + |
|
539 | + $head = asset_type_prepare_head($object); |
|
540 | + |
|
541 | + print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'">'; |
|
542 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
543 | + print '<input type="hidden" name="rowid" value="'.$object->id.'">'; |
|
544 | + print '<input type="hidden" name="action" value="update">'; |
|
545 | + |
|
546 | + dol_fiche_head($head, 'card', $langs->trans("AssetsType"), -1, 'setup'); |
|
547 | + |
|
548 | + print '<table class="border" width="100%">'; |
|
549 | + |
|
550 | + print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>'; |
|
551 | + |
|
552 | + print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>'; |
|
553 | + |
|
554 | + if (! empty($conf->accounting->enabled)) |
|
555 | + { |
|
556 | + // Accountancy_code_asset |
|
557 | + print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>'; |
|
558 | + print '<td>'; |
|
559 | + print $formaccounting->select_account($object->accountancy_code_asset, 'accountancy_code_asset', 1, '', 1, 1); |
|
560 | + print '</td></tr>'; |
|
561 | + |
|
562 | + // Accountancy_code_depreciation_expense |
|
563 | + print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationAsset").'</td>'; |
|
564 | + print '<td>'; |
|
565 | + print $formaccounting->select_account($object->accountancy_code_depreciation_asset, 'accountancy_code_depreciation_asset', 1, '', 1, 1); |
|
566 | + print '</td></tr>'; |
|
567 | + |
|
568 | + // Accountancy_code_depreciation_expense |
|
569 | + print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationExpense").'</td>'; |
|
570 | + print '<td>'; |
|
571 | + print $formaccounting->select_account($object->accountancy_code_depreciation_expense, 'accountancy_code_depreciation_expense', 1, '', 1, 1); |
|
572 | + print '</td></tr>'; |
|
573 | + } |
|
574 | + else // For external software |
|
575 | + { |
|
576 | + // Accountancy_code_asset |
|
577 | + print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>'; |
|
578 | + print '<td><input name="accountancy_code_asset" class="maxwidth200" value="'.$object->accountancy_code_asset.'">'; |
|
579 | + print '</td></tr>'; |
|
580 | + |
|
581 | + // Accountancy_code_depreciation_asset |
|
582 | + print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationAsset").'</td>'; |
|
583 | + print '<td><input name="accountancy_code_depreciation_asset" class="maxwidth200" value="'.$object->accountancy_code_depreciation_asset.'">'; |
|
584 | + print '</td></tr>'; |
|
585 | + |
|
586 | + // Accountancy_code_depreciation_expense |
|
587 | + print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationExpense").'</td>'; |
|
588 | + print '<td><input name="accountancy_code_depreciation_expense" class="maxwidth200" value="'.$object->accountancy_code_depreciation_expense.'">'; |
|
589 | + print '</td></tr>'; |
|
590 | + } |
|
591 | + |
|
592 | + print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>'; |
|
593 | + print '<textarea name="comment" wrap="soft" class="centpercent" rows="3">'.$object->note.'</textarea></td></tr>'; |
|
594 | + |
|
595 | + // Other attributes |
|
596 | + $parameters=array(); |
|
597 | + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook |
|
598 | + print $hookmanager->resPrint; |
|
599 | + if (empty($reshook)) |
|
600 | + { |
|
601 | + print $object->showOptionals($extrafields,'edit'); |
|
602 | + } |
|
603 | + |
|
604 | + print '</table>'; |
|
605 | + |
|
606 | + // Extra field |
|
607 | + if (empty($reshook)) |
|
608 | + { |
|
609 | + print '<br><br><table class="border" width="100%">'; |
|
610 | + foreach($extrafields->attribute_label as $key=>$label) |
|
611 | + { |
|
612 | + if (isset($_POST["options_" . $key])) { |
|
613 | + if (is_array($_POST["options_" . $key])) { |
|
614 | + // $_POST["options"] is an array but following code expects a comma separated string |
|
615 | + $value = implode(",", $_POST["options_" . $key]); |
|
616 | + } else { |
|
617 | + $value = $_POST["options_" . $key]; |
|
618 | + } |
|
619 | + } else { |
|
620 | + $value = $adht->array_options["options_" . $key]; |
|
621 | + } |
|
622 | + print '<tr><td width="30%">'.$label.'</td><td>'; |
|
623 | + print $extrafields->showInputField($key,$value); |
|
624 | + print "</td></tr>\n"; |
|
625 | + } |
|
626 | + print '</table><br><br>'; |
|
627 | + } |
|
628 | + |
|
629 | + dol_fiche_end(); |
|
630 | + |
|
631 | + print '<div class="center">'; |
|
632 | + print '<input type="submit" class="button" value="'.$langs->trans("Save").'">'; |
|
633 | + print ' '; |
|
634 | + print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">'; |
|
635 | + print '</div>'; |
|
636 | + |
|
637 | + print "</form>"; |
|
638 | + } |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | // End of page |
@@ -26,9 +26,15 @@ discard block |
||
26 | 26 | require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; |
27 | 27 | require_once DOL_DOCUMENT_ROOT.'/asset/class/asset_type.class.php'; |
28 | 28 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
29 | -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
30 | -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; |
|
31 | -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; |
|
29 | +if (! empty($conf->accounting->enabled)) { |
|
30 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
31 | +} |
|
32 | +if (! empty($conf->accounting->enabled)) { |
|
33 | + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; |
|
34 | +} |
|
35 | +if (! empty($conf->accounting->enabled)) { |
|
36 | + require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; |
|
37 | +} |
|
32 | 38 | |
33 | 39 | // Load translation files required by the page |
34 | 40 | $langs->load("assets"); |
@@ -67,9 +73,11 @@ discard block |
||
67 | 73 | // fetch optionals attributes and labels |
68 | 74 | $extralabels=$extrafields->fetch_name_optionals_label('asset_type'); |
69 | 75 | |
70 | -if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers |
|
76 | +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) { |
|
77 | + // All tests are required to be compatible with all browsers |
|
71 | 78 | { |
72 | 79 | $type=""; |
80 | +} |
|
73 | 81 | $sall=""; |
74 | 82 | } |
75 | 83 | |
@@ -103,13 +111,14 @@ discard block |
||
103 | 111 | |
104 | 112 | // Fill array 'array_options' with data from add form |
105 | 113 | $ret = $extrafields->setOptionalsFromPost($extralabels,$object); |
106 | - if ($ret < 0) $error++; |
|
114 | + if ($ret < 0) { |
|
115 | + $error++; |
|
116 | + } |
|
107 | 117 | |
108 | 118 | if (empty($object->label)) { |
109 | 119 | $error++; |
110 | 120 | setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), null, 'errors'); |
111 | - } |
|
112 | - else { |
|
121 | + } else { |
|
113 | 122 | $sql = "SELECT label FROM ".MAIN_DB_PREFIX."asset_type WHERE label='".$db->escape($object->label)."'"; |
114 | 123 | $result = $db->query($sql); |
115 | 124 | if ($result) { |
@@ -129,14 +138,12 @@ discard block |
||
129 | 138 | { |
130 | 139 | header("Location: ".$_SERVER["PHP_SELF"]); |
131 | 140 | exit; |
132 | - } |
|
133 | - else |
|
141 | + } else |
|
134 | 142 | { |
135 | 143 | setEventMessages($object->error, $object->errors, 'errors'); |
136 | 144 | $action = 'create'; |
137 | 145 | } |
138 | - } |
|
139 | - else |
|
146 | + } else |
|
140 | 147 | { |
141 | 148 | $action = 'create'; |
142 | 149 | } |
@@ -156,15 +163,16 @@ discard block |
||
156 | 163 | |
157 | 164 | // Fill array 'array_options' with data from add form |
158 | 165 | $ret = $extrafields->setOptionalsFromPost($extralabels,$object); |
159 | - if ($ret < 0) $error++; |
|
166 | + if ($ret < 0) { |
|
167 | + $error++; |
|
168 | + } |
|
160 | 169 | |
161 | 170 | $ret=$object->update($user); |
162 | 171 | |
163 | 172 | if ($ret >= 0 && ! count($object->errors)) |
164 | 173 | { |
165 | 174 | setEventMessages($langs->trans("AssetsTypeModified"), null, 'mesgs'); |
166 | - } |
|
167 | - else |
|
175 | + } else |
|
168 | 176 | { |
169 | 177 | setEventMessages($object->error, $object->errors, 'errors'); |
170 | 178 | } |
@@ -183,8 +191,7 @@ discard block |
||
183 | 191 | setEventMessages($langs->trans("AssetsTypeDeleted"), null, 'mesgs'); |
184 | 192 | header("Location: ".$_SERVER["PHP_SELF"]); |
185 | 193 | exit; |
186 | - } |
|
187 | - else |
|
194 | + } else |
|
188 | 195 | { |
189 | 196 | setEventMessages($langs->trans("AssetsTypeCanNotBeDeleted"), null, 'errors'); |
190 | 197 | $action=''; |
@@ -221,7 +228,9 @@ discard block |
||
221 | 228 | $param = ''; |
222 | 229 | |
223 | 230 | print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; |
224 | - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
231 | + if ($optioncss != '') { |
|
232 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
233 | + } |
|
225 | 234 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
226 | 235 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
227 | 236 | print '<input type="hidden" name="action" value="list">'; |
@@ -298,10 +307,11 @@ discard block |
||
298 | 307 | } |
299 | 308 | print '</td>'; |
300 | 309 | |
301 | - if ($user->rights->asset->write) |
|
302 | - print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>'; |
|
303 | - else |
|
304 | - print '<td align="right"> </td>'; |
|
310 | + if ($user->rights->asset->write) { |
|
311 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>'; |
|
312 | + } else { |
|
313 | + print '<td align="right"> </td>'; |
|
314 | + } |
|
305 | 315 | print "</tr>"; |
306 | 316 | $i++; |
307 | 317 | } |
@@ -309,8 +319,7 @@ discard block |
||
309 | 319 | print '</div>'; |
310 | 320 | |
311 | 321 | print '</form>'; |
312 | - } |
|
313 | - else |
|
322 | + } else |
|
314 | 323 | { |
315 | 324 | dol_print_error($db); |
316 | 325 | } |
@@ -325,7 +334,9 @@ discard block |
||
325 | 334 | if ($action == 'create') |
326 | 335 | { |
327 | 336 | $object = new AssetType($db); |
328 | - if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); |
|
337 | + if (! empty($conf->accounting->enabled)) { |
|
338 | + $formaccounting = new FormAccounting($db); |
|
339 | + } |
|
329 | 340 | |
330 | 341 | print load_fiche_titre($langs->trans("NewAssetType")); |
331 | 342 | |
@@ -359,8 +370,7 @@ discard block |
||
359 | 370 | print '<td>'; |
360 | 371 | print $formaccounting->select_account($object->accountancy_code_depreciation_expense, 'accountancy_code_depreciation_expense', 1, '', 1, 1); |
361 | 372 | print '</td></tr>'; |
362 | - } |
|
363 | - else // For external software |
|
373 | + } else // For external software |
|
364 | 374 | { |
365 | 375 | // Accountancy_code_asset |
366 | 376 | print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>'; |
@@ -534,7 +544,9 @@ discard block |
||
534 | 544 | $object = new AssetType($db); |
535 | 545 | $object->fetch($rowid); |
536 | 546 | $object->fetch_optionals(); |
537 | - if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); |
|
547 | + if (! empty($conf->accounting->enabled)) { |
|
548 | + $formaccounting = new FormAccounting($db); |
|
549 | + } |
|
538 | 550 | |
539 | 551 | $head = asset_type_prepare_head($object); |
540 | 552 | |
@@ -570,8 +582,7 @@ discard block |
||
570 | 582 | print '<td>'; |
571 | 583 | print $formaccounting->select_account($object->accountancy_code_depreciation_expense, 'accountancy_code_depreciation_expense', 1, '', 1, 1); |
572 | 584 | print '</td></tr>'; |
573 | - } |
|
574 | - else // For external software |
|
585 | + } else // For external software |
|
575 | 586 | { |
576 | 587 | // Accountancy_code_asset |
577 | 588 | print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>'; |
@@ -24,62 +24,62 @@ discard block |
||
24 | 24 | |
25 | 25 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
26 | 26 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
27 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
27 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
28 | 28 | |
29 | 29 | require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; |
30 | 30 | require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; |
31 | 31 | require_once DOL_DOCUMENT_ROOT.'/asset/class/asset_type.class.php'; |
32 | 32 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
33 | -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
34 | -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; |
|
35 | -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; |
|
33 | +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
34 | +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; |
|
35 | +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; |
|
36 | 36 | |
37 | 37 | // Load translation files required by the page |
38 | 38 | $langs->load("assets"); |
39 | 39 | |
40 | -$rowid = GETPOST('rowid','int'); |
|
41 | -$action = GETPOST('action','alpha'); |
|
42 | -$cancel = GETPOST('cancel','alpha'); |
|
43 | -$backtopage = GETPOST('backtopage','alpha'); |
|
40 | +$rowid = GETPOST('rowid', 'int'); |
|
41 | +$action = GETPOST('action', 'alpha'); |
|
42 | +$cancel = GETPOST('cancel', 'alpha'); |
|
43 | +$backtopage = GETPOST('backtopage', 'alpha'); |
|
44 | 44 | |
45 | -$type = GETPOST('type','alpha'); |
|
45 | +$type = GETPOST('type', 'alpha'); |
|
46 | 46 | |
47 | -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
|
48 | -$sortfield = GETPOST("sortfield",'alpha'); |
|
49 | -$sortorder = GETPOST("sortorder",'alpha'); |
|
50 | -$page = GETPOST("page",'int'); |
|
47 | +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; |
|
48 | +$sortfield = GETPOST("sortfield", 'alpha'); |
|
49 | +$sortorder = GETPOST("sortorder", 'alpha'); |
|
50 | +$page = GETPOST("page", 'int'); |
|
51 | 51 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
52 | -$offset = $limit * $page ; |
|
52 | +$offset = $limit * $page; |
|
53 | 53 | $pageprev = $page - 1; |
54 | 54 | $pagenext = $page + 1; |
55 | -if (! $sortorder) { $sortorder="DESC"; } |
|
56 | -if (! $sortfield) { $sortfield="a.label"; } |
|
55 | +if (!$sortorder) { $sortorder = "DESC"; } |
|
56 | +if (!$sortfield) { $sortfield = "a.label"; } |
|
57 | 57 | |
58 | -$label=GETPOST("label","alpha"); |
|
59 | -$accountancy_code_asset=GETPOST('accountancy_code_asset','string'); |
|
60 | -$accountancy_code_depreciation_asset=GETPOST('accountancy_code_depreciation_asset','string'); |
|
61 | -$accountancy_code_depreciation_expense=GETPOST('accountancy_code_depreciation_expense','string'); |
|
62 | -$comment=GETPOST('comment','string'); |
|
58 | +$label = GETPOST("label", "alpha"); |
|
59 | +$accountancy_code_asset = GETPOST('accountancy_code_asset', 'string'); |
|
60 | +$accountancy_code_depreciation_asset = GETPOST('accountancy_code_depreciation_asset', 'string'); |
|
61 | +$accountancy_code_depreciation_expense = GETPOST('accountancy_code_depreciation_expense', 'string'); |
|
62 | +$comment = GETPOST('comment', 'string'); |
|
63 | 63 | |
64 | 64 | // Security check |
65 | -$result=restrictedArea($user,'asset',$rowid,'asset_type'); |
|
65 | +$result = restrictedArea($user, 'asset', $rowid, 'asset_type'); |
|
66 | 66 | |
67 | 67 | $object = new AssetType($db); |
68 | 68 | |
69 | 69 | $extrafields = new ExtraFields($db); |
70 | 70 | |
71 | 71 | // fetch optionals attributes and labels |
72 | -$extralabels=$extrafields->fetch_name_optionals_label('asset_type'); |
|
72 | +$extralabels = $extrafields->fetch_name_optionals_label('asset_type'); |
|
73 | 73 | |
74 | -if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers |
|
74 | +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers |
|
75 | 75 | { |
76 | - $type=""; |
|
77 | - $sall=""; |
|
76 | + $type = ""; |
|
77 | + $sall = ""; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
81 | 81 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
82 | -$hookmanager->initHooks(array('assettypecard','globalcard')); |
|
82 | +$hookmanager->initHooks(array('assettypecard', 'globalcard')); |
|
83 | 83 | |
84 | 84 | |
85 | 85 | /* |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | |
89 | 89 | if ($cancel) { |
90 | 90 | |
91 | - $action=''; |
|
91 | + $action = ''; |
|
92 | 92 | |
93 | - if (! empty($backtopage)) |
|
93 | + if (!empty($backtopage)) |
|
94 | 94 | { |
95 | 95 | header("Location: ".$backtopage); |
96 | 96 | exit; |
@@ -99,19 +99,19 @@ discard block |
||
99 | 99 | |
100 | 100 | if ($action == 'add' && $user->rights->asset->write) |
101 | 101 | { |
102 | - $object->label = trim($label); |
|
103 | - $object->accountancy_code_asset = trim($accountancy_code_asset); |
|
104 | - $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); |
|
105 | - $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense); |
|
106 | - $object->note = trim($comment); |
|
102 | + $object->label = trim($label); |
|
103 | + $object->accountancy_code_asset = trim($accountancy_code_asset); |
|
104 | + $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); |
|
105 | + $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense); |
|
106 | + $object->note = trim($comment); |
|
107 | 107 | |
108 | 108 | // Fill array 'array_options' with data from add form |
109 | - $ret = $extrafields->setOptionalsFromPost($extralabels,$object); |
|
109 | + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); |
|
110 | 110 | if ($ret < 0) $error++; |
111 | 111 | |
112 | 112 | if (empty($object->label)) { |
113 | 113 | $error++; |
114 | - setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), null, 'errors'); |
|
114 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); |
|
115 | 115 | } |
116 | 116 | else { |
117 | 117 | $sql = "SELECT label FROM ".MAIN_DB_PREFIX."asset_type WHERE label='".$db->escape($object->label)."'"; |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | if ($num) { |
123 | 123 | $error++; |
124 | 124 | $langs->load("errors"); |
125 | - setEventMessages($langs->trans("ErrorLabelAlreadyExists",$login), null, 'errors'); |
|
125 | + setEventMessages($langs->trans("ErrorLabelAlreadyExists", $login), null, 'errors'); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | - if (! $error) |
|
129 | + if (!$error) |
|
130 | 130 | { |
131 | - $id=$object->create($user); |
|
131 | + $id = $object->create($user); |
|
132 | 132 | if ($id > 0) |
133 | 133 | { |
134 | 134 | header("Location: ".$_SERVER["PHP_SELF"]); |
@@ -152,19 +152,19 @@ discard block |
||
152 | 152 | |
153 | 153 | $object->oldcopy = clone $object; |
154 | 154 | |
155 | - $object->label = trim($label); |
|
156 | - $object->accountancy_code_asset = trim($accountancy_code_asset); |
|
157 | - $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); |
|
158 | - $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense); |
|
159 | - $object->note = trim($comment); |
|
155 | + $object->label = trim($label); |
|
156 | + $object->accountancy_code_asset = trim($accountancy_code_asset); |
|
157 | + $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); |
|
158 | + $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense); |
|
159 | + $object->note = trim($comment); |
|
160 | 160 | |
161 | 161 | // Fill array 'array_options' with data from add form |
162 | - $ret = $extrafields->setOptionalsFromPost($extralabels,$object); |
|
162 | + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); |
|
163 | 163 | if ($ret < 0) $error++; |
164 | 164 | |
165 | - $ret=$object->update($user); |
|
165 | + $ret = $object->update($user); |
|
166 | 166 | |
167 | - if ($ret >= 0 && ! count($object->errors)) |
|
167 | + if ($ret >= 0 && !count($object->errors)) |
|
168 | 168 | { |
169 | 169 | setEventMessages($langs->trans("AssetsTypeModified"), null, 'mesgs'); |
170 | 170 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | if ($action == 'confirm_delete' && $user->rights->asset->write) |
181 | 181 | { |
182 | 182 | $object->fetch($rowid); |
183 | - $res=$object->delete(); |
|
183 | + $res = $object->delete(); |
|
184 | 184 | |
185 | 185 | if ($res > 0) |
186 | 186 | { |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | else |
192 | 192 | { |
193 | 193 | setEventMessages($langs->trans("AssetsTypeCanNotBeDeleted"), null, 'errors'); |
194 | - $action=''; |
|
194 | + $action = ''; |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
@@ -200,19 +200,19 @@ discard block |
||
200 | 200 | * View |
201 | 201 | */ |
202 | 202 | |
203 | -$form=new Form($db); |
|
204 | -$helpurl=''; |
|
205 | -llxHeader('',$langs->trans("AssetsTypeSetup"),$helpurl); |
|
203 | +$form = new Form($db); |
|
204 | +$helpurl = ''; |
|
205 | +llxHeader('', $langs->trans("AssetsTypeSetup"), $helpurl); |
|
206 | 206 | |
207 | 207 | |
208 | 208 | // List of asset type |
209 | -if (! $rowid && $action != 'create' && $action != 'edit') |
|
209 | +if (!$rowid && $action != 'create' && $action != 'edit') |
|
210 | 210 | { |
211 | 211 | //dol_fiche_head(''); |
212 | 212 | |
213 | 213 | $sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note"; |
214 | - $sql.= " FROM ".MAIN_DB_PREFIX."asset_type as d"; |
|
215 | - $sql.= " WHERE d.entity IN (".getEntity('asset_type').")"; |
|
214 | + $sql .= " FROM ".MAIN_DB_PREFIX."asset_type as d"; |
|
215 | + $sql .= " WHERE d.entity IN (".getEntity('asset_type').")"; |
|
216 | 216 | |
217 | 217 | $result = $db->query($sql); |
218 | 218 | if ($result) |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | $moreforfilter = ''; |
239 | 239 | |
240 | 240 | print '<div class="div-table-responsive">'; |
241 | - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; |
|
241 | + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; |
|
242 | 242 | |
243 | 243 | print '<tr class="liste_titre">'; |
244 | 244 | print '<th>'.$langs->trans("Ref").'</th>'; |
@@ -267,36 +267,36 @@ discard block |
||
267 | 267 | print '<td>'.dol_escape_htmltag($objp->label).'</td>'; |
268 | 268 | |
269 | 269 | print '<td class="center">'; |
270 | - if (! empty($conf->accounting->enabled)) |
|
270 | + if (!empty($conf->accounting->enabled)) |
|
271 | 271 | { |
272 | 272 | $accountingaccount = new AccountingAccount($db); |
273 | - $accountingaccount->fetch('',$objp->accountancy_code_asset,1); |
|
273 | + $accountingaccount->fetch('', $objp->accountancy_code_asset, 1); |
|
274 | 274 | |
275 | - print $accountingaccount->getNomUrl(0,0,0,'',0); |
|
275 | + print $accountingaccount->getNomUrl(0, 0, 0, '', 0); |
|
276 | 276 | } else { |
277 | 277 | print $objp->accountancy_code_asset; |
278 | 278 | } |
279 | 279 | print '</td>'; |
280 | 280 | |
281 | 281 | print '<td class="center">'; |
282 | - if (! empty($conf->accounting->enabled)) |
|
282 | + if (!empty($conf->accounting->enabled)) |
|
283 | 283 | { |
284 | 284 | $accountingaccount2 = new AccountingAccount($db); |
285 | - $accountingaccount2->fetch('',$objp->accountancy_code_depreciation_asset,1); |
|
285 | + $accountingaccount2->fetch('', $objp->accountancy_code_depreciation_asset, 1); |
|
286 | 286 | |
287 | - print $accountingaccount2->getNomUrl(0,0,0,'',0); |
|
287 | + print $accountingaccount2->getNomUrl(0, 0, 0, '', 0); |
|
288 | 288 | } else { |
289 | 289 | print $objp->accountancy_code_depreciation_asset; |
290 | 290 | } |
291 | 291 | print '</td>'; |
292 | 292 | |
293 | 293 | print '<td class="center">'; |
294 | - if (! empty($conf->accounting->enabled)) |
|
294 | + if (!empty($conf->accounting->enabled)) |
|
295 | 295 | { |
296 | 296 | $accountingaccount3 = new AccountingAccount($db); |
297 | - $accountingaccount3->fetch('',$objp->accountancy_code_depreciation_expense,1); |
|
297 | + $accountingaccount3->fetch('', $objp->accountancy_code_depreciation_expense, 1); |
|
298 | 298 | |
299 | - print $accountingaccount3->getNomUrl(0,0,0,'',0); |
|
299 | + print $accountingaccount3->getNomUrl(0, 0, 0, '', 0); |
|
300 | 300 | } else { |
301 | 301 | print $objp->accountancy_code_depreciation_expense; |
302 | 302 | } |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | if ($action == 'create') |
330 | 330 | { |
331 | 331 | $object = new AssetType($db); |
332 | - if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); |
|
332 | + if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); |
|
333 | 333 | |
334 | 334 | print load_fiche_titre($langs->trans("NewAssetType")); |
335 | 335 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | |
345 | 345 | print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40"></td></tr>'; |
346 | 346 | |
347 | - if (! empty($conf->accounting->enabled)) |
|
347 | + if (!empty($conf->accounting->enabled)) |
|
348 | 348 | { |
349 | 349 | // Accountancy_code_asset |
350 | 350 | print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>'; |
@@ -386,12 +386,12 @@ discard block |
||
386 | 386 | print '<textarea name="comment" wrap="soft" class="centpercent" rows="3"></textarea></td></tr>'; |
387 | 387 | |
388 | 388 | // Other attributes |
389 | - $parameters=array(); |
|
390 | - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook |
|
389 | + $parameters = array(); |
|
390 | + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook |
|
391 | 391 | print $hookmanager->resPrint; |
392 | 392 | if (empty($reshook)) |
393 | 393 | { |
394 | - print $object->showOptionals($extrafields,'edit'); |
|
394 | + print $object->showOptionals($extrafields, 'edit'); |
|
395 | 395 | } |
396 | 396 | print '<tbody>'; |
397 | 397 | print "</table>\n"; |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | */ |
426 | 426 | if ($action == 'delete') |
427 | 427 | { |
428 | - print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id,$langs->trans("DeleteAnAssetType"),$langs->trans("ConfirmDeleteAssetType",$object->label),"confirm_delete", '',0,1); |
|
428 | + print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id, $langs->trans("DeleteAnAssetType"), $langs->trans("ConfirmDeleteAssetType", $object->label), "confirm_delete", '', 0, 1); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | $head = asset_type_prepare_head($object); |
@@ -434,11 +434,11 @@ discard block |
||
434 | 434 | |
435 | 435 | $linkback = '<a href="'.DOL_URL_ROOT.'/asset/type.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; |
436 | 436 | |
437 | - $morehtmlref='<div class="refidno">'; |
|
437 | + $morehtmlref = '<div class="refidno">'; |
|
438 | 438 | // Ref asset type |
439 | - $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', 0, 1); |
|
440 | - $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', null, null, '', 1); |
|
441 | - $morehtmlref.='</div>'; |
|
439 | + $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', 0, 1); |
|
440 | + $morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', null, null, '', 1); |
|
441 | + $morehtmlref .= '</div>'; |
|
442 | 442 | |
443 | 443 | dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); |
444 | 444 | |
@@ -451,12 +451,12 @@ discard block |
||
451 | 451 | print '<td class="nowrap">'; |
452 | 452 | print $langs->trans("AccountancyCodeAsset"); |
453 | 453 | print '</td><td>'; |
454 | - if (! empty($conf->accounting->enabled)) |
|
454 | + if (!empty($conf->accounting->enabled)) |
|
455 | 455 | { |
456 | 456 | $accountingaccount = new AccountingAccount($db); |
457 | - $accountingaccount->fetch('',$object->accountancy_code_asset,1); |
|
457 | + $accountingaccount->fetch('', $object->accountancy_code_asset, 1); |
|
458 | 458 | |
459 | - print $accountingaccount->getNomUrl(0,1,1,'',1); |
|
459 | + print $accountingaccount->getNomUrl(0, 1, 1, '', 1); |
|
460 | 460 | } else { |
461 | 461 | print $object->accountancy_code_asset; |
462 | 462 | } |
@@ -467,12 +467,12 @@ discard block |
||
467 | 467 | print '<td class="nowrap">'; |
468 | 468 | print $langs->trans("AccountancyCodeDepreciationAsset"); |
469 | 469 | print '</td><td>'; |
470 | - if (! empty($conf->accounting->enabled)) |
|
470 | + if (!empty($conf->accounting->enabled)) |
|
471 | 471 | { |
472 | 472 | $accountingaccount2 = new AccountingAccount($db); |
473 | - $accountingaccount2->fetch('',$object->accountancy_code_depreciation_asset,1); |
|
473 | + $accountingaccount2->fetch('', $object->accountancy_code_depreciation_asset, 1); |
|
474 | 474 | |
475 | - print $accountingaccount2->getNomUrl(0,1,1,'',1); |
|
475 | + print $accountingaccount2->getNomUrl(0, 1, 1, '', 1); |
|
476 | 476 | } else { |
477 | 477 | print $object->accountancy_code_depreciation_asset; |
478 | 478 | } |
@@ -483,12 +483,12 @@ discard block |
||
483 | 483 | print '<td class="nowrap">'; |
484 | 484 | print $langs->trans("AccountancyCodeDepreciationExpense"); |
485 | 485 | print '</td><td>'; |
486 | - if (! empty($conf->accounting->enabled)) |
|
486 | + if (!empty($conf->accounting->enabled)) |
|
487 | 487 | { |
488 | 488 | $accountingaccount3 = new AccountingAccount($db); |
489 | - $accountingaccount3->fetch('',$object->accountancy_code_depreciation_expense,1); |
|
489 | + $accountingaccount3->fetch('', $object->accountancy_code_depreciation_expense, 1); |
|
490 | 490 | |
491 | - print $accountingaccount3->getNomUrl(0,1,1,'',1); |
|
491 | + print $accountingaccount3->getNomUrl(0, 1, 1, '', 1); |
|
492 | 492 | } else { |
493 | 493 | print $object->accountancy_code_depreciation_expense; |
494 | 494 | } |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | print nl2br($object->note)."</td></tr>"; |
500 | 500 | |
501 | 501 | // Other attributes |
502 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
502 | + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; |
|
503 | 503 | |
504 | 504 | print '</table>'; |
505 | 505 | print '</div>'; |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | $object = new AssetType($db); |
539 | 539 | $object->fetch($rowid); |
540 | 540 | $object->fetch_optionals(); |
541 | - if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); |
|
541 | + if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); |
|
542 | 542 | |
543 | 543 | $head = asset_type_prepare_head($object); |
544 | 544 | |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | |
556 | 556 | print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>'; |
557 | 557 | |
558 | - if (! empty($conf->accounting->enabled)) |
|
558 | + if (!empty($conf->accounting->enabled)) |
|
559 | 559 | { |
560 | 560 | // Accountancy_code_asset |
561 | 561 | print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>'; |
@@ -597,12 +597,12 @@ discard block |
||
597 | 597 | print '<textarea name="comment" wrap="soft" class="centpercent" rows="3">'.$object->note.'</textarea></td></tr>'; |
598 | 598 | |
599 | 599 | // Other attributes |
600 | - $parameters=array(); |
|
601 | - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook |
|
600 | + $parameters = array(); |
|
601 | + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook |
|
602 | 602 | print $hookmanager->resPrint; |
603 | 603 | if (empty($reshook)) |
604 | 604 | { |
605 | - print $object->showOptionals($extrafields,'edit'); |
|
605 | + print $object->showOptionals($extrafields, 'edit'); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | print '</table>'; |
@@ -611,20 +611,20 @@ discard block |
||
611 | 611 | if (empty($reshook)) |
612 | 612 | { |
613 | 613 | print '<br><br><table class="border" width="100%">'; |
614 | - foreach($extrafields->attribute_label as $key=>$label) |
|
614 | + foreach ($extrafields->attribute_label as $key=>$label) |
|
615 | 615 | { |
616 | - if (isset($_POST["options_" . $key])) { |
|
617 | - if (is_array($_POST["options_" . $key])) { |
|
616 | + if (isset($_POST["options_".$key])) { |
|
617 | + if (is_array($_POST["options_".$key])) { |
|
618 | 618 | // $_POST["options"] is an array but following code expects a comma separated string |
619 | - $value = implode(",", $_POST["options_" . $key]); |
|
619 | + $value = implode(",", $_POST["options_".$key]); |
|
620 | 620 | } else { |
621 | - $value = $_POST["options_" . $key]; |
|
621 | + $value = $_POST["options_".$key]; |
|
622 | 622 | } |
623 | 623 | } else { |
624 | - $value = $adht->array_options["options_" . $key]; |
|
624 | + $value = $adht->array_options["options_".$key]; |
|
625 | 625 | } |
626 | 626 | print '<tr><td width="30%">'.$label.'</td><td>'; |
627 | - print $extrafields->showInputField($key,$value); |
|
627 | + print $extrafields->showInputField($key, $value); |
|
628 | 628 | print "</td></tr>\n"; |
629 | 629 | } |
630 | 630 | print '</table><br><br>'; |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | // Buttons |
75 | 75 | if ($action != 'create' && $action != 'edit') |
76 | 76 | { |
77 | - print '<div class="tabsAction">'; |
|
78 | - print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute").'</a></div>'; |
|
79 | - print "</div>"; |
|
77 | + print '<div class="tabsAction">'; |
|
78 | + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute").'</a></div>'; |
|
79 | + print "</div>"; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | |
89 | 89 | if ($action == 'create') |
90 | 90 | { |
91 | - print "<br>"; |
|
92 | - print load_fiche_titre($langs->trans('NewAttribute')); |
|
91 | + print "<br>"; |
|
92 | + print load_fiche_titre($langs->trans('NewAttribute')); |
|
93 | 93 | |
94 | 94 | require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; |
95 | 95 | } |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | /* ************************************************************************** */ |
102 | 102 | if ($action == 'edit' && ! empty($attrname)) |
103 | 103 | { |
104 | - print "<br>"; |
|
105 | - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); |
|
104 | + print "<br>"; |
|
105 | + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); |
|
106 | 106 | |
107 | 107 | require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; |
108 | 108 | } |
@@ -34,13 +34,17 @@ |
||
34 | 34 | // List of supported format |
35 | 35 | $tmptype2label=ExtraFields::$type2label; |
36 | 36 | $type2label=array(''); |
37 | -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); |
|
37 | +foreach ($tmptype2label as $key => $val) { |
|
38 | + $type2label[$key]=$langs->transnoentitiesnoconv($val); |
|
39 | +} |
|
38 | 40 | |
39 | 41 | $action=GETPOST('action', 'alpha'); |
40 | 42 | $attrname=GETPOST('attrname', 'alpha'); |
41 | 43 | $elementtype='adherent_type'; //Must be the $table_element of the class that manage extrafield |
42 | 44 | |
43 | -if (!$user->admin) accessforbidden(); |
|
45 | +if (!$user->admin) { |
|
46 | + accessforbidden(); |
|
47 | +} |
|
44 | 48 | |
45 | 49 | |
46 | 50 | /* |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
26 | 26 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
27 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
27 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
28 | 28 | require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; |
29 | 29 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
30 | 30 | |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | $form = new Form($db); |
36 | 36 | |
37 | 37 | // List of supported format |
38 | -$tmptype2label=ExtraFields::$type2label; |
|
39 | -$type2label=array(''); |
|
40 | -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); |
|
38 | +$tmptype2label = ExtraFields::$type2label; |
|
39 | +$type2label = array(''); |
|
40 | +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); |
|
41 | 41 | |
42 | -$action=GETPOST('action', 'alpha'); |
|
43 | -$attrname=GETPOST('attrname', 'alpha'); |
|
44 | -$elementtype='adherent_type'; //Must be the $table_element of the class that manage extrafield |
|
42 | +$action = GETPOST('action', 'alpha'); |
|
43 | +$attrname = GETPOST('attrname', 'alpha'); |
|
44 | +$elementtype = 'adherent_type'; //Must be the $table_element of the class that manage extrafield |
|
45 | 45 | |
46 | 46 | if (!$user->admin) accessforbidden(); |
47 | 47 | |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | * View |
59 | 59 | */ |
60 | 60 | |
61 | -$textobject=$langs->transnoentitiesnoconv("AssetsTypes"); |
|
61 | +$textobject = $langs->transnoentitiesnoconv("AssetsTypes"); |
|
62 | 62 | |
63 | -llxHeader('',$langs->trans("AssetsSetup")); |
|
63 | +llxHeader('', $langs->trans("AssetsSetup")); |
|
64 | 64 | |
65 | -$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; |
|
66 | -print load_fiche_titre($langs->trans("AssetsSetup"),$linkback,'title_setup'); |
|
65 | +$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; |
|
66 | +print load_fiche_titre($langs->trans("AssetsSetup"), $linkback, 'title_setup'); |
|
67 | 67 | |
68 | 68 | |
69 | 69 | $head = asset_admin_prepare_head(); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | /* Edition of an optional field */ |
103 | 103 | /* */ |
104 | 104 | /* ************************************************************************** */ |
105 | -if ($action == 'edit' && ! empty($attrname)) |
|
105 | +if ($action == 'edit' && !empty($attrname)) |
|
106 | 106 | { |
107 | 107 | print "<br>"; |
108 | 108 | print load_fiche_titre($langs->trans("FieldEdition", $attrname)); |
@@ -65,46 +65,46 @@ |
||
65 | 65 | |
66 | 66 | if ($action == 'edit') |
67 | 67 | { |
68 | - print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; |
|
69 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
70 | - print '<input type="hidden" name="action" value="update">'; |
|
68 | + print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; |
|
69 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
70 | + print '<input type="hidden" name="action" value="update">'; |
|
71 | 71 | |
72 | - print '<table class="noborder" width="100%">'; |
|
73 | - print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; |
|
72 | + print '<table class="noborder" width="100%">'; |
|
73 | + print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; |
|
74 | 74 | |
75 | - foreach($arrayofparameters as $key => $val) |
|
76 | - { |
|
77 | - print '<tr class="oddeven"><td>'; |
|
78 | - print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip')); |
|
79 | - print '</td><td><input name="'.$key.'" class="flat '.(empty($val['css'])?'minwidth200':$val['css']).'" value="' . $conf->global->$key . '"></td></tr>'; |
|
80 | - } |
|
75 | + foreach($arrayofparameters as $key => $val) |
|
76 | + { |
|
77 | + print '<tr class="oddeven"><td>'; |
|
78 | + print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip')); |
|
79 | + print '</td><td><input name="'.$key.'" class="flat '.(empty($val['css'])?'minwidth200':$val['css']).'" value="' . $conf->global->$key . '"></td></tr>'; |
|
80 | + } |
|
81 | 81 | |
82 | - print '</table>'; |
|
82 | + print '</table>'; |
|
83 | 83 | |
84 | - print '<br><div class="center">'; |
|
85 | - print '<input class="button" type="submit" value="'.$langs->trans("Save").'">'; |
|
86 | - print '</div>'; |
|
84 | + print '<br><div class="center">'; |
|
85 | + print '<input class="button" type="submit" value="'.$langs->trans("Save").'">'; |
|
86 | + print '</div>'; |
|
87 | 87 | |
88 | - print '</form>'; |
|
89 | - print '<br>'; |
|
88 | + print '</form>'; |
|
89 | + print '<br>'; |
|
90 | 90 | } |
91 | 91 | else |
92 | 92 | { |
93 | - print '<table class="noborder" width="100%">'; |
|
94 | - print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; |
|
93 | + print '<table class="noborder" width="100%">'; |
|
94 | + print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; |
|
95 | 95 | |
96 | - foreach($arrayofparameters as $key => $val) |
|
97 | - { |
|
98 | - print '<tr class="oddeven"><td>'; |
|
99 | - print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip')); |
|
100 | - print '</td><td>' . $conf->global->$key . '</td></tr>'; |
|
101 | - } |
|
96 | + foreach($arrayofparameters as $key => $val) |
|
97 | + { |
|
98 | + print '<tr class="oddeven"><td>'; |
|
99 | + print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip')); |
|
100 | + print '</td><td>' . $conf->global->$key . '</td></tr>'; |
|
101 | + } |
|
102 | 102 | |
103 | - print '</table>'; |
|
103 | + print '</table>'; |
|
104 | 104 | |
105 | - print '<div class="tabsAction">'; |
|
106 | - print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>'; |
|
107 | - print '</div>'; |
|
105 | + print '<div class="tabsAction">'; |
|
106 | + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>'; |
|
107 | + print '</div>'; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | dol_fiche_end(); |
@@ -32,7 +32,9 @@ discard block |
||
32 | 32 | $langs->loadLangs(array("admin", "assets")); |
33 | 33 | |
34 | 34 | // Access control |
35 | -if (! $user->admin) accessforbidden(); |
|
35 | +if (! $user->admin) { |
|
36 | + accessforbidden(); |
|
37 | +} |
|
36 | 38 | |
37 | 39 | // Parameters |
38 | 40 | $action = GETPOST('action', 'alpha'); |
@@ -87,8 +89,7 @@ discard block |
||
87 | 89 | |
88 | 90 | print '</form>'; |
89 | 91 | print '<br>'; |
90 | -} |
|
91 | -else |
|
92 | +} else |
|
92 | 93 | { |
93 | 94 | print '<table class="noborder" width="100%">'; |
94 | 95 | print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | |
26 | 26 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
27 | 27 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
28 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
28 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
29 | 29 | require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; |
30 | -require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; |
|
30 | +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; |
|
31 | 31 | |
32 | 32 | global $langs, $user; |
33 | 33 | |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | $langs->loadLangs(array("admin", "assets")); |
36 | 36 | |
37 | 37 | // Access control |
38 | -if (! $user->admin) accessforbidden(); |
|
38 | +if (!$user->admin) accessforbidden(); |
|
39 | 39 | |
40 | 40 | // Parameters |
41 | 41 | $action = GETPOST('action', 'alpha'); |
42 | 42 | $backtopage = GETPOST('backtopage', 'alpha'); |
43 | 43 | |
44 | -$arrayofparameters=array('FIXEDASSETS_MYPARAM1'=>array('css'=>'minwidth200'), 'FIXEDASSETS_MYPARAM2'=>array('css'=>'minwidth500')); |
|
44 | +$arrayofparameters = array('FIXEDASSETS_MYPARAM1'=>array('css'=>'minwidth200'), 'FIXEDASSETS_MYPARAM2'=>array('css'=>'minwidth500')); |
|
45 | 45 | |
46 | 46 | |
47 | 47 | /* |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | * View |
56 | 56 | */ |
57 | 57 | |
58 | -llxHeader('',$langs->trans("AssetsSetup")); |
|
58 | +llxHeader('', $langs->trans("AssetsSetup")); |
|
59 | 59 | |
60 | -$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; |
|
61 | -print load_fiche_titre($langs->trans("AssetsSetup"),$linkback,'title_setup'); |
|
60 | +$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; |
|
61 | +print load_fiche_titre($langs->trans("AssetsSetup"), $linkback, 'title_setup'); |
|
62 | 62 | |
63 | 63 | |
64 | 64 | $head = asset_admin_prepare_head(); |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | print '<table class="noborder" width="100%">'; |
76 | 76 | print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; |
77 | 77 | |
78 | - foreach($arrayofparameters as $key => $val) |
|
78 | + foreach ($arrayofparameters as $key => $val) |
|
79 | 79 | { |
80 | 80 | print '<tr class="oddeven"><td>'; |
81 | - print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip')); |
|
82 | - print '</td><td><input name="'.$key.'" class="flat '.(empty($val['css'])?'minwidth200':$val['css']).'" value="' . $conf->global->$key . '"></td></tr>'; |
|
81 | + print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); |
|
82 | + print '</td><td><input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'"></td></tr>'; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | print '</table>'; |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | print '<table class="noborder" width="100%">'; |
97 | 97 | print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; |
98 | 98 | |
99 | - foreach($arrayofparameters as $key => $val) |
|
99 | + foreach ($arrayofparameters as $key => $val) |
|
100 | 100 | { |
101 | 101 | print '<tr class="oddeven"><td>'; |
102 | - print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip')); |
|
103 | - print '</td><td>' . $conf->global->$key . '</td></tr>'; |
|
102 | + print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); |
|
103 | + print '</td><td>'.$conf->global->$key.'</td></tr>'; |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | print '</table>'; |
@@ -35,13 +35,17 @@ |
||
35 | 35 | // List of supported format |
36 | 36 | $tmptype2label=ExtraFields::$type2label; |
37 | 37 | $type2label=array(''); |
38 | -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); |
|
38 | +foreach ($tmptype2label as $key => $val) { |
|
39 | + $type2label[$key]=$langs->transnoentitiesnoconv($val); |
|
40 | +} |
|
39 | 41 | |
40 | 42 | $action=GETPOST('action', 'alpha'); |
41 | 43 | $attrname=GETPOST('attrname', 'alpha'); |
42 | 44 | $elementtype='don'; //Must be the $table_element of the class that manage extrafield |
43 | 45 | |
44 | -if (!$user->admin) accessforbidden(); |
|
46 | +if (!$user->admin) { |
|
47 | + accessforbidden(); |
|
48 | +} |
|
45 | 49 | |
46 | 50 | |
47 | 51 | /* |
@@ -25,24 +25,24 @@ discard block |
||
25 | 25 | |
26 | 26 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
27 | 27 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
28 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
28 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
29 | 29 | require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; |
30 | 30 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
31 | 31 | |
32 | 32 | // Load translation files required by the page |
33 | -$langs->loadLangs(array("assets","admin","companies")); |
|
33 | +$langs->loadLangs(array("assets", "admin", "companies")); |
|
34 | 34 | |
35 | 35 | $extrafields = new ExtraFields($db); |
36 | 36 | $form = new Form($db); |
37 | 37 | |
38 | 38 | // List of supported format |
39 | -$tmptype2label=ExtraFields::$type2label; |
|
40 | -$type2label=array(''); |
|
41 | -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); |
|
39 | +$tmptype2label = ExtraFields::$type2label; |
|
40 | +$type2label = array(''); |
|
41 | +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); |
|
42 | 42 | |
43 | -$action=GETPOST('action', 'alpha'); |
|
44 | -$attrname=GETPOST('attrname', 'alpha'); |
|
45 | -$elementtype='don'; //Must be the $table_element of the class that manage extrafield |
|
43 | +$action = GETPOST('action', 'alpha'); |
|
44 | +$attrname = GETPOST('attrname', 'alpha'); |
|
45 | +$elementtype = 'don'; //Must be the $table_element of the class that manage extrafield |
|
46 | 46 | |
47 | 47 | if (!$user->admin) accessforbidden(); |
48 | 48 | |
@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | * View |
60 | 60 | */ |
61 | 61 | |
62 | -$textobject=$langs->transnoentitiesnoconv("Assets"); |
|
62 | +$textobject = $langs->transnoentitiesnoconv("Assets"); |
|
63 | 63 | |
64 | -llxHeader('',$langs->trans("AssetsSetup")); |
|
64 | +llxHeader('', $langs->trans("AssetsSetup")); |
|
65 | 65 | |
66 | -$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; |
|
67 | -print load_fiche_titre($langs->trans("AssetsSetup"),$linkback,'title_setup'); |
|
66 | +$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; |
|
67 | +print load_fiche_titre($langs->trans("AssetsSetup"), $linkback, 'title_setup'); |
|
68 | 68 | |
69 | 69 | |
70 | 70 | $head = asset_admin_prepare_head(); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | /* Edit optional field */ |
105 | 105 | /* */ |
106 | 106 | /* ************************************************************************** */ |
107 | -if ($action == 'edit' && ! empty($attrname)) |
|
107 | +if ($action == 'edit' && !empty($attrname)) |
|
108 | 108 | { |
109 | 109 | print "<br>"; |
110 | 110 | print load_fiche_titre($langs->trans("FieldEdition", $attrname)); |
@@ -76,18 +76,18 @@ discard block |
||
76 | 76 | |
77 | 77 | if ($id > 0 || ! empty($ref)) |
78 | 78 | { |
79 | - $object->fetch_thirdparty(); |
|
79 | + $object->fetch_thirdparty(); |
|
80 | 80 | |
81 | - $head = asset_prepare_head($object); |
|
81 | + $head = asset_prepare_head($object); |
|
82 | 82 | |
83 | - dol_fiche_head($head, 'note', $langs->trans("Asset"), -1, 'generic'); |
|
83 | + dol_fiche_head($head, 'note', $langs->trans("Asset"), -1, 'generic'); |
|
84 | 84 | |
85 | - // Object card |
|
86 | - // ------------------------------------------------------------ |
|
87 | - $linkback = '<a href="' .dol_buildpath('/asset/list.php',1) . '?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
85 | + // Object card |
|
86 | + // ------------------------------------------------------------ |
|
87 | + $linkback = '<a href="' .dol_buildpath('/asset/list.php',1) . '?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
88 | 88 | |
89 | - $morehtmlref='<div class="refidno">'; |
|
90 | - /* |
|
89 | + $morehtmlref='<div class="refidno">'; |
|
90 | + /* |
|
91 | 91 | // Ref customer |
92 | 92 | $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
93 | 93 | $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
@@ -126,22 +126,22 @@ discard block |
||
126 | 126 | } |
127 | 127 | } |
128 | 128 | }*/ |
129 | - $morehtmlref.='</div>'; |
|
129 | + $morehtmlref.='</div>'; |
|
130 | 130 | |
131 | 131 | |
132 | - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
|
132 | + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
|
133 | 133 | |
134 | 134 | |
135 | - print '<div class="fichecenter">'; |
|
136 | - print '<div class="underbanner clearboth"></div>'; |
|
135 | + print '<div class="fichecenter">'; |
|
136 | + print '<div class="underbanner clearboth"></div>'; |
|
137 | 137 | |
138 | 138 | |
139 | - $cssclass="titlefield"; |
|
140 | - include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; |
|
139 | + $cssclass="titlefield"; |
|
140 | + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; |
|
141 | 141 | |
142 | - print '</div>'; |
|
142 | + print '</div>'; |
|
143 | 143 | |
144 | - dol_fiche_end(); |
|
144 | + dol_fiche_end(); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | // End of page |
@@ -51,7 +51,9 @@ |
||
51 | 51 | |
52 | 52 | // Load object |
53 | 53 | include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals |
54 | -if ($id > 0 || ! empty($ref)) $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id; |
|
54 | +if ($id > 0 || ! empty($ref)) { |
|
55 | + $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id; |
|
56 | +} |
|
55 | 57 | |
56 | 58 | $permissionnote=1; |
57 | 59 | //$permissionnote=$user->rights->asset->creer; // Used by the include of actions_setnotes.inc.php |
@@ -25,26 +25,26 @@ discard block |
||
25 | 25 | |
26 | 26 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
27 | 27 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
28 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
28 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
29 | 29 | |
30 | 30 | require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; |
31 | 31 | require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; |
32 | 32 | |
33 | 33 | // Load translation files required by the page |
34 | -$langs->loadLangs(array("asset","companies")); |
|
34 | +$langs->loadLangs(array("asset", "companies")); |
|
35 | 35 | |
36 | 36 | // Get parameters |
37 | -$id = GETPOST('id', 'int'); |
|
37 | +$id = GETPOST('id', 'int'); |
|
38 | 38 | $ref = GETPOST('ref', 'alpha'); |
39 | -$action = GETPOST('action', 'alpha'); |
|
39 | +$action = GETPOST('action', 'alpha'); |
|
40 | 40 | $cancel = GETPOST('cancel', 'aZ09'); |
41 | 41 | $backtopage = GETPOST('backtopage', 'alpha'); |
42 | 42 | |
43 | 43 | // Initialize technical objects |
44 | -$object=new Asset($db); |
|
44 | +$object = new Asset($db); |
|
45 | 45 | $extrafields = new ExtraFields($db); |
46 | -$diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->id; |
|
47 | -$hookmanager->initHooks(array('assetnote')); // Note that conf->hooks_modules contains array |
|
46 | +$diroutputmassaction = $conf->asset->dir_output.'/temp/massgeneration/'.$user->id; |
|
47 | +$hookmanager->initHooks(array('assetnote')); // Note that conf->hooks_modules contains array |
|
48 | 48 | // Fetch optionals attributes and labels |
49 | 49 | $extralabels = $extrafields->fetch_name_optionals_label('asset'); |
50 | 50 | |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | //$result = restrictedArea($user, 'asset', $id); |
55 | 55 | |
56 | 56 | // Load object |
57 | -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals |
|
58 | -if ($id > 0 || ! empty($ref)) $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id; |
|
57 | +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals |
|
58 | +if ($id > 0 || !empty($ref)) $upload_dir = $conf->asset->multidir_output[$object->entity]."/".$object->id; |
|
59 | 59 | |
60 | -$permissionnote=1; |
|
60 | +$permissionnote = 1; |
|
61 | 61 | //$permissionnote=$user->rights->asset->creer; // Used by the include of actions_setnotes.inc.php |
62 | 62 | |
63 | 63 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * Actions |
66 | 66 | */ |
67 | 67 | |
68 | -include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once |
|
68 | +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once |
|
69 | 69 | |
70 | 70 | |
71 | 71 | /* |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | $form = new Form($db); |
76 | 76 | |
77 | 77 | //$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; |
78 | -$help_url=''; |
|
79 | -llxHeader('',$langs->trans('Assets'),$help_url); |
|
78 | +$help_url = ''; |
|
79 | +llxHeader('', $langs->trans('Assets'), $help_url); |
|
80 | 80 | |
81 | -if ($id > 0 || ! empty($ref)) |
|
81 | +if ($id > 0 || !empty($ref)) |
|
82 | 82 | { |
83 | 83 | $object->fetch_thirdparty(); |
84 | 84 | |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | |
89 | 89 | // Object card |
90 | 90 | // ------------------------------------------------------------ |
91 | - $linkback = '<a href="' .dol_buildpath('/asset/list.php',1) . '?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
91 | + $linkback = '<a href="'.dol_buildpath('/asset/list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; |
|
92 | 92 | |
93 | - $morehtmlref='<div class="refidno">'; |
|
93 | + $morehtmlref = '<div class="refidno">'; |
|
94 | 94 | /* |
95 | 95 | // Ref customer |
96 | 96 | $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | } |
131 | 131 | } |
132 | 132 | }*/ |
133 | - $morehtmlref.='</div>'; |
|
133 | + $morehtmlref .= '</div>'; |
|
134 | 134 | |
135 | 135 | |
136 | 136 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | print '<div class="underbanner clearboth"></div>'; |
141 | 141 | |
142 | 142 | |
143 | - $cssclass="titlefield"; |
|
143 | + $cssclass = "titlefield"; |
|
144 | 144 | include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; |
145 | 145 | |
146 | 146 | print '</div>'; |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | $socid=0; |
73 | 73 | if ($user->societe_id > 0) |
74 | 74 | { |
75 | - //$socid = $user->societe_id; |
|
76 | - accessforbidden(); |
|
75 | + //$socid = $user->societe_id; |
|
76 | + accessforbidden(); |
|
77 | 77 | } |
78 | 78 | //$result = restrictedArea($user, 'asset', $id,''); |
79 | 79 | |
@@ -82,30 +82,30 @@ discard block |
||
82 | 82 | $search=array(); |
83 | 83 | foreach($object->fields as $key => $val) |
84 | 84 | { |
85 | - if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
85 | + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | // List of fields to search into when doing a "search in all" |
89 | 89 | $fieldstosearchall = array(); |
90 | 90 | foreach($object->fields as $key => $val) |
91 | 91 | { |
92 | - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; |
|
92 | + if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | // Definition of fields for list |
96 | 96 | $arrayfields=array(); |
97 | 97 | foreach($object->fields as $key => $val) |
98 | 98 | { |
99 | - // If $val['visible']==0, then we never show the field |
|
100 | - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); |
|
99 | + // If $val['visible']==0, then we never show the field |
|
100 | + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); |
|
101 | 101 | } |
102 | 102 | // Extra fields |
103 | 103 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
104 | 104 | { |
105 | - foreach($extrafields->attribute_label as $key => $val) |
|
106 | - { |
|
107 | - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); |
|
108 | - } |
|
105 | + foreach($extrafields->attribute_label as $key => $val) |
|
106 | + { |
|
107 | + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); |
|
108 | + } |
|
109 | 109 | } |
110 | 110 | $object->fields = dol_sort_array($object->fields, 'position'); |
111 | 111 | $arrayfields = dol_sort_array($arrayfields, 'position'); |
@@ -127,32 +127,32 @@ discard block |
||
127 | 127 | |
128 | 128 | if (empty($reshook)) |
129 | 129 | { |
130 | - // Selection of new fields |
|
131 | - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
|
132 | - |
|
133 | - // Purge search criteria |
|
134 | - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers |
|
135 | - { |
|
136 | - foreach($object->fields as $key => $val) |
|
137 | - { |
|
138 | - $search[$key]=''; |
|
139 | - } |
|
140 | - $toselect=''; |
|
141 | - $search_array_options=array(); |
|
142 | - } |
|
143 | - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') |
|
144 | - || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) |
|
145 | - { |
|
146 | - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation |
|
147 | - } |
|
148 | - |
|
149 | - // Mass actions |
|
150 | - $objectclass='Asset'; |
|
151 | - $objectlabel='Asset'; |
|
152 | - $permtoread = $user->rights->asset->read; |
|
153 | - $permtodelete = $user->rights->asset->delete; |
|
154 | - $uploaddir = $conf->asset->dir_output; |
|
155 | - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; |
|
130 | + // Selection of new fields |
|
131 | + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
|
132 | + |
|
133 | + // Purge search criteria |
|
134 | + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers |
|
135 | + { |
|
136 | + foreach($object->fields as $key => $val) |
|
137 | + { |
|
138 | + $search[$key]=''; |
|
139 | + } |
|
140 | + $toselect=''; |
|
141 | + $search_array_options=array(); |
|
142 | + } |
|
143 | + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') |
|
144 | + || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) |
|
145 | + { |
|
146 | + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation |
|
147 | + } |
|
148 | + |
|
149 | + // Mass actions |
|
150 | + $objectclass='Asset'; |
|
151 | + $objectlabel='Asset'; |
|
152 | + $permtoread = $user->rights->asset->read; |
|
153 | + $permtodelete = $user->rights->asset->delete; |
|
154 | + $uploaddir = $conf->asset->dir_output; |
|
155 | + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $sql = 'SELECT '; |
178 | 178 | foreach($object->fields as $key => $val) |
179 | 179 | { |
180 | - $sql.='t.'.$key.', '; |
|
180 | + $sql.='t.'.$key.', '; |
|
181 | 181 | } |
182 | 182 | // Add fields from extrafields |
183 | 183 | foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | else $sql.=" WHERE 1 = 1"; |
193 | 193 | foreach($search as $key => $val) |
194 | 194 | { |
195 | - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); |
|
196 | - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); |
|
195 | + $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); |
|
196 | + if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); |
|
197 | 197 | } |
198 | 198 | if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); |
199 | 199 | // Add where from extra fields |
@@ -223,13 +223,13 @@ discard block |
||
223 | 223 | $nbtotalofrecords = ''; |
224 | 224 | if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) |
225 | 225 | { |
226 | - $result = $db->query($sql); |
|
227 | - $nbtotalofrecords = $db->num_rows($result); |
|
228 | - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 |
|
229 | - { |
|
230 | - $page = 0; |
|
231 | - $offset = 0; |
|
232 | - } |
|
226 | + $result = $db->query($sql); |
|
227 | + $nbtotalofrecords = $db->num_rows($result); |
|
228 | + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 |
|
229 | + { |
|
230 | + $page = 0; |
|
231 | + $offset = 0; |
|
232 | + } |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | $sql.= $db->plimit($limit+1, $offset); |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | $resql=$db->query($sql); |
238 | 238 | if (! $resql) |
239 | 239 | { |
240 | - dol_print_error($db); |
|
241 | - exit; |
|
240 | + dol_print_error($db); |
|
241 | + exit; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | $num = $db->num_rows($resql); |
@@ -246,10 +246,10 @@ discard block |
||
246 | 246 | // Direct jump if only one record found |
247 | 247 | if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) |
248 | 248 | { |
249 | - $obj = $db->fetch_object($resql); |
|
250 | - $id = $obj->rowid; |
|
251 | - header("Location: ".DOL_URL_ROOT.'/assets/card.php?id='.$id); |
|
252 | - exit; |
|
249 | + $obj = $db->fetch_object($resql); |
|
250 | + $id = $obj->rowid; |
|
251 | + header("Location: ".DOL_URL_ROOT.'/assets/card.php?id='.$id); |
|
252 | + exit; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); |
281 | 281 | foreach($search as $key => $val) |
282 | 282 | { |
283 | - $param.= '&search_'.$key.'='.urlencode($search[$key]); |
|
283 | + $param.= '&search_'.$key.'='.urlencode($search[$key]); |
|
284 | 284 | } |
285 | 285 | if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); |
286 | 286 | // Add $param from extra fields |
@@ -288,8 +288,8 @@ discard block |
||
288 | 288 | |
289 | 289 | // List of mass actions available |
290 | 290 | $arrayofmassactions = array( |
291 | - //'presend'=>$langs->trans("SendByMail"), |
|
292 | - //'builddoc'=>$langs->trans("PDFMerge"), |
|
291 | + //'presend'=>$langs->trans("SendByMail"), |
|
292 | + //'builddoc'=>$langs->trans("PDFMerge"), |
|
293 | 293 | ); |
294 | 294 | if ($user->rights->asset->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); |
295 | 295 | if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); |
@@ -316,8 +316,8 @@ discard block |
||
316 | 316 | |
317 | 317 | if ($sall) |
318 | 318 | { |
319 | - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); |
|
320 | - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>'; |
|
319 | + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); |
|
320 | + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>'; |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | $moreforfilter = ''; |
@@ -332,9 +332,9 @@ discard block |
||
332 | 332 | |
333 | 333 | if (! empty($moreforfilter)) |
334 | 334 | { |
335 | - print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
|
336 | - print $moreforfilter; |
|
337 | - print '</div>'; |
|
335 | + print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
|
336 | + print $moreforfilter; |
|
337 | + print '</div>'; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; |
@@ -350,11 +350,11 @@ discard block |
||
350 | 350 | print '<tr class="liste_titre">'; |
351 | 351 | foreach($object->fields as $key => $val) |
352 | 352 | { |
353 | - $align=''; |
|
354 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; |
|
355 | - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; |
|
356 | - if ($key == 'status') $align.=($align?' ':'').'center'; |
|
357 | - if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; |
|
353 | + $align=''; |
|
354 | + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; |
|
355 | + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; |
|
356 | + if ($key == 'status') $align.=($align?' ':'').'center'; |
|
357 | + if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; |
|
358 | 358 | } |
359 | 359 | // Extra fields |
360 | 360 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; |
@@ -376,11 +376,11 @@ discard block |
||
376 | 376 | print '<tr class="liste_titre">'; |
377 | 377 | foreach($object->fields as $key => $val) |
378 | 378 | { |
379 | - $align=''; |
|
380 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; |
|
381 | - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; |
|
382 | - if ($key == 'status') $align.=($align?' ':'').'center'; |
|
383 | - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; |
|
379 | + $align=''; |
|
380 | + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; |
|
381 | + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; |
|
382 | + if ($key == 'status') $align.=($align?' ':'').'center'; |
|
383 | + if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; |
|
384 | 384 | } |
385 | 385 | // Extra fields |
386 | 386 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | $needToFetchEachLine=0; |
397 | 397 | foreach ($extrafields->attribute_computed as $key => $val) |
398 | 398 | { |
399 | - if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object |
|
399 | + if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | |
@@ -406,89 +406,89 @@ discard block |
||
406 | 406 | $totalarray=array(); |
407 | 407 | while ($i < min($num, $limit)) |
408 | 408 | { |
409 | - $obj = $db->fetch_object($resql); |
|
410 | - if (empty($obj)) break; // Should not happen |
|
411 | - |
|
412 | - // Store properties in $object |
|
413 | - $object->id = $obj->rowid; |
|
414 | - foreach($object->fields as $key => $val) |
|
415 | - { |
|
416 | - if (isset($obj->$key)) $object->$key = $obj->$key; |
|
417 | - } |
|
418 | - |
|
419 | - // Show here line of result |
|
420 | - print '<tr class="oddeven">'; |
|
421 | - foreach($object->fields as $key => $val) |
|
422 | - { |
|
423 | - $align=''; |
|
424 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; |
|
425 | - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; |
|
426 | - if ($key == 'status') $align.=($align?' ':'').'center'; |
|
427 | - if (! empty($arrayfields['t.'.$key]['checked'])) |
|
428 | - { |
|
429 | - print '<td'; |
|
430 | - if ($align) print ' class="'.$align.'"'; |
|
431 | - print '>'; |
|
432 | - print $object->showOutputField($val, $key, $obj->$key, ''); |
|
433 | - print '</td>'; |
|
434 | - if (! $i) $totalarray['nbfield']++; |
|
435 | - if (! empty($val['isameasure'])) |
|
436 | - { |
|
437 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; |
|
438 | - $totalarray['val']['t.'.$key] += $obj->$key; |
|
439 | - } |
|
440 | - } |
|
441 | - } |
|
442 | - // Extra fields |
|
443 | - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; |
|
444 | - // Fields from hook |
|
445 | - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); |
|
446 | - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook |
|
447 | - print $hookmanager->resPrint; |
|
448 | - // Action column |
|
449 | - print '<td class="nowrap" align="center">'; |
|
450 | - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
|
451 | - { |
|
452 | - $selected=0; |
|
453 | - if (in_array($obj->rowid, $arrayofselected)) $selected=1; |
|
454 | - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; |
|
455 | - } |
|
456 | - print '</td>'; |
|
457 | - if (! $i) $totalarray['nbfield']++; |
|
458 | - |
|
459 | - print '</tr>'; |
|
460 | - |
|
461 | - $i++; |
|
409 | + $obj = $db->fetch_object($resql); |
|
410 | + if (empty($obj)) break; // Should not happen |
|
411 | + |
|
412 | + // Store properties in $object |
|
413 | + $object->id = $obj->rowid; |
|
414 | + foreach($object->fields as $key => $val) |
|
415 | + { |
|
416 | + if (isset($obj->$key)) $object->$key = $obj->$key; |
|
417 | + } |
|
418 | + |
|
419 | + // Show here line of result |
|
420 | + print '<tr class="oddeven">'; |
|
421 | + foreach($object->fields as $key => $val) |
|
422 | + { |
|
423 | + $align=''; |
|
424 | + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; |
|
425 | + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; |
|
426 | + if ($key == 'status') $align.=($align?' ':'').'center'; |
|
427 | + if (! empty($arrayfields['t.'.$key]['checked'])) |
|
428 | + { |
|
429 | + print '<td'; |
|
430 | + if ($align) print ' class="'.$align.'"'; |
|
431 | + print '>'; |
|
432 | + print $object->showOutputField($val, $key, $obj->$key, ''); |
|
433 | + print '</td>'; |
|
434 | + if (! $i) $totalarray['nbfield']++; |
|
435 | + if (! empty($val['isameasure'])) |
|
436 | + { |
|
437 | + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; |
|
438 | + $totalarray['val']['t.'.$key] += $obj->$key; |
|
439 | + } |
|
440 | + } |
|
441 | + } |
|
442 | + // Extra fields |
|
443 | + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; |
|
444 | + // Fields from hook |
|
445 | + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); |
|
446 | + $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook |
|
447 | + print $hookmanager->resPrint; |
|
448 | + // Action column |
|
449 | + print '<td class="nowrap" align="center">'; |
|
450 | + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
|
451 | + { |
|
452 | + $selected=0; |
|
453 | + if (in_array($obj->rowid, $arrayofselected)) $selected=1; |
|
454 | + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; |
|
455 | + } |
|
456 | + print '</td>'; |
|
457 | + if (! $i) $totalarray['nbfield']++; |
|
458 | + |
|
459 | + print '</tr>'; |
|
460 | + |
|
461 | + $i++; |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | // Show total line |
465 | 465 | if (isset($totalarray['pos'])) |
466 | 466 | { |
467 | - print '<tr class="liste_total">'; |
|
468 | - $i=0; |
|
469 | - while ($i < $totalarray['nbfield']) |
|
470 | - { |
|
471 | - $i++; |
|
472 | - if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; |
|
473 | - else |
|
474 | - { |
|
475 | - if ($i == 1) |
|
476 | - { |
|
477 | - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; |
|
478 | - else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
|
479 | - } |
|
480 | - else print '<td></td>'; |
|
481 | - } |
|
482 | - } |
|
483 | - print '</tr>'; |
|
467 | + print '<tr class="liste_total">'; |
|
468 | + $i=0; |
|
469 | + while ($i < $totalarray['nbfield']) |
|
470 | + { |
|
471 | + $i++; |
|
472 | + if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; |
|
473 | + else |
|
474 | + { |
|
475 | + if ($i == 1) |
|
476 | + { |
|
477 | + if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; |
|
478 | + else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
|
479 | + } |
|
480 | + else print '<td></td>'; |
|
481 | + } |
|
482 | + } |
|
483 | + print '</tr>'; |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | // If no record found |
487 | 487 | if ($num == 0) |
488 | 488 | { |
489 | - $colspan=1; |
|
490 | - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } |
|
491 | - print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; |
|
489 | + $colspan=1; |
|
490 | + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } |
|
491 | + print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | |
@@ -505,25 +505,25 @@ discard block |
||
505 | 505 | |
506 | 506 | if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) |
507 | 507 | { |
508 | - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) |
|
509 | - { |
|
510 | - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
|
511 | - $formfile = new FormFile($db); |
|
512 | - |
|
513 | - // Show list of available documents |
|
514 | - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; |
|
515 | - $urlsource.=str_replace('&','&',$param); |
|
516 | - |
|
517 | - $filedir=$diroutputmassaction; |
|
518 | - $genallowed=$user->rights->asset->read; |
|
519 | - $delallowed=$user->rights->asset->create; |
|
520 | - |
|
521 | - print $formfile->showdocuments('massfilesarea_asset','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); |
|
522 | - } |
|
523 | - else |
|
524 | - { |
|
525 | - print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>'; |
|
526 | - } |
|
508 | + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) |
|
509 | + { |
|
510 | + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
|
511 | + $formfile = new FormFile($db); |
|
512 | + |
|
513 | + // Show list of available documents |
|
514 | + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; |
|
515 | + $urlsource.=str_replace('&','&',$param); |
|
516 | + |
|
517 | + $filedir=$diroutputmassaction; |
|
518 | + $genallowed=$user->rights->asset->read; |
|
519 | + $delallowed=$user->rights->asset->create; |
|
520 | + |
|
521 | + print $formfile->showdocuments('massfilesarea_asset','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); |
|
522 | + } |
|
523 | + else |
|
524 | + { |
|
525 | + print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>'; |
|
526 | + } |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | // End of page |
@@ -65,8 +65,13 @@ discard block |
||
65 | 65 | $search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); |
66 | 66 | |
67 | 67 | // Default sort order (if not yet defined by previous GETPOST) |
68 | -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. |
|
69 | -if (! $sortorder) $sortorder="ASC"; |
|
68 | +if (! $sortfield) { |
|
69 | + $sortfield="t.".key($object->fields); |
|
70 | +} |
|
71 | +// Set here default search field. By default 1st field in definition. |
|
72 | +if (! $sortorder) { |
|
73 | + $sortorder="ASC"; |
|
74 | +} |
|
70 | 75 | |
71 | 76 | // Protection if external user |
72 | 77 | $socid=0; |
@@ -82,29 +87,37 @@ discard block |
||
82 | 87 | $search=array(); |
83 | 88 | foreach($object->fields as $key => $val) |
84 | 89 | { |
85 | - if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
86 | -} |
|
90 | + if (GETPOST('search_'.$key,'alpha')) { |
|
91 | + $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
92 | + } |
|
93 | + } |
|
87 | 94 | |
88 | 95 | // List of fields to search into when doing a "search in all" |
89 | 96 | $fieldstosearchall = array(); |
90 | 97 | foreach($object->fields as $key => $val) |
91 | 98 | { |
92 | - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; |
|
93 | -} |
|
99 | + if ($val['searchall']) { |
|
100 | + $fieldstosearchall['t.'.$key]=$val['label']; |
|
101 | + } |
|
102 | + } |
|
94 | 103 | |
95 | 104 | // Definition of fields for list |
96 | 105 | $arrayfields=array(); |
97 | 106 | foreach($object->fields as $key => $val) |
98 | 107 | { |
99 | 108 | // If $val['visible']==0, then we never show the field |
100 | - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); |
|
101 | -} |
|
109 | + if (! empty($val['visible'])) { |
|
110 | + $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); |
|
111 | + } |
|
112 | + } |
|
102 | 113 | // Extra fields |
103 | 114 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
104 | 115 | { |
105 | 116 | foreach($extrafields->attribute_label as $key => $val) |
106 | 117 | { |
107 | - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); |
|
118 | + if (! empty($extrafields->attribute_list[$key])) { |
|
119 | + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); |
|
120 | + } |
|
108 | 121 | } |
109 | 122 | } |
110 | 123 | $object->fields = dol_sort_array($object->fields, 'position'); |
@@ -123,7 +136,9 @@ discard block |
||
123 | 136 | |
124 | 137 | $parameters=array(); |
125 | 138 | $reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
126 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
139 | +if ($reshook < 0) { |
|
140 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
141 | +} |
|
127 | 142 | |
128 | 143 | if (empty($reshook)) |
129 | 144 | { |
@@ -131,11 +146,13 @@ discard block |
||
131 | 146 | include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
132 | 147 | |
133 | 148 | // Purge search criteria |
134 | - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers |
|
149 | + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) { |
|
150 | + // All tests are required to be compatible with all browsers |
|
135 | 151 | { |
136 | 152 | foreach($object->fields as $key => $val) |
137 | 153 | { |
138 | 154 | $search[$key]=''; |
155 | + } |
|
139 | 156 | } |
140 | 157 | $toselect=''; |
141 | 158 | $search_array_options=array(); |
@@ -180,22 +197,33 @@ discard block |
||
180 | 197 | $sql.='t.'.$key.', '; |
181 | 198 | } |
182 | 199 | // Add fields from extrafields |
183 | -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); |
|
200 | +foreach ($extrafields->attribute_label as $key => $val) { |
|
201 | + $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); |
|
202 | +} |
|
184 | 203 | // Add fields from hooks |
185 | 204 | $parameters=array(); |
186 | 205 | $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook |
187 | 206 | $sql.=$hookmanager->resPrint; |
188 | 207 | $sql=preg_replace('/, $/','', $sql); |
189 | 208 | $sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; |
190 | -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."assets_extrafields as ef on (t.rowid = ef.fk_object)"; |
|
191 | -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('assets').")"; |
|
192 | -else $sql.=" WHERE 1 = 1"; |
|
209 | +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { |
|
210 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."assets_extrafields as ef on (t.rowid = ef.fk_object)"; |
|
211 | +} |
|
212 | +if ($object->ismultientitymanaged == 1) { |
|
213 | + $sql.= " WHERE t.entity IN (".getEntity('assets').")"; |
|
214 | +} else { |
|
215 | + $sql.=" WHERE 1 = 1"; |
|
216 | +} |
|
193 | 217 | foreach($search as $key => $val) |
194 | 218 | { |
195 | 219 | $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); |
196 | - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); |
|
220 | + if ($search[$key] != '') { |
|
221 | + $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); |
|
222 | + } |
|
223 | + } |
|
224 | +if ($search_all) { |
|
225 | + $sql.= natural_search(array_keys($fieldstosearchall), $search_all); |
|
197 | 226 | } |
198 | -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); |
|
199 | 227 | // Add where from extra fields |
200 | 228 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; |
201 | 229 | // Add where from hooks |
@@ -225,9 +253,11 @@ discard block |
||
225 | 253 | { |
226 | 254 | $result = $db->query($sql); |
227 | 255 | $nbtotalofrecords = $db->num_rows($result); |
228 | - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 |
|
256 | + if (($page * $limit) > $nbtotalofrecords) { |
|
257 | + // if total resultset is smaller then paging size (filtering), goto and load page 0 |
|
229 | 258 | { |
230 | 259 | $page = 0; |
260 | + } |
|
231 | 261 | $offset = 0; |
232 | 262 | } |
233 | 263 | } |
@@ -276,13 +306,19 @@ discard block |
||
276 | 306 | $arrayofselected=is_array($toselect)?$toselect:array(); |
277 | 307 | |
278 | 308 | $param=''; |
279 | -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); |
|
280 | -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); |
|
309 | +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { |
|
310 | + $param.='&contextpage='.urlencode($contextpage); |
|
311 | +} |
|
312 | +if ($limit > 0 && $limit != $conf->liste_limit) { |
|
313 | + $param.='&limit='.urlencode($limit); |
|
314 | +} |
|
281 | 315 | foreach($search as $key => $val) |
282 | 316 | { |
283 | 317 | $param.= '&search_'.$key.'='.urlencode($search[$key]); |
284 | 318 | } |
285 | -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); |
|
319 | +if ($optioncss != '') { |
|
320 | + $param.='&optioncss='.urlencode($optioncss); |
|
321 | +} |
|
286 | 322 | // Add $param from extra fields |
287 | 323 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; |
288 | 324 | |
@@ -291,12 +327,18 @@ discard block |
||
291 | 327 | //'presend'=>$langs->trans("SendByMail"), |
292 | 328 | //'builddoc'=>$langs->trans("PDFMerge"), |
293 | 329 | ); |
294 | -if ($user->rights->asset->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); |
|
295 | -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); |
|
330 | +if ($user->rights->asset->delete) { |
|
331 | + $arrayofmassactions['predelete']=$langs->trans("Delete"); |
|
332 | +} |
|
333 | +if (in_array($massaction, array('presend','predelete'))) { |
|
334 | + $arrayofmassactions=array(); |
|
335 | +} |
|
296 | 336 | $massactionbutton=$form->selectMassAction('', $arrayofmassactions); |
297 | 337 | |
298 | 338 | print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; |
299 | -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
339 | +if ($optioncss != '') { |
|
340 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
341 | +} |
|
300 | 342 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
301 | 343 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
302 | 344 | print '<input type="hidden" name="action" value="list">'; |
@@ -316,7 +358,9 @@ discard block |
||
316 | 358 | |
317 | 359 | if ($sall) |
318 | 360 | { |
319 | - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); |
|
361 | + foreach($fieldstosearchall as $key => $val) { |
|
362 | + $fieldstosearchall[$key]=$langs->trans($val); |
|
363 | + } |
|
320 | 364 | print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>'; |
321 | 365 | } |
322 | 366 | |
@@ -327,8 +371,11 @@ discard block |
||
327 | 371 | |
328 | 372 | $parameters=array(); |
329 | 373 | $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook |
330 | -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; |
|
331 | -else $moreforfilter = $hookmanager->resPrint; |
|
374 | +if (empty($reshook)) { |
|
375 | + $moreforfilter .= $hookmanager->resPrint; |
|
376 | +} else { |
|
377 | + $moreforfilter = $hookmanager->resPrint; |
|
378 | +} |
|
332 | 379 | |
333 | 380 | if (! empty($moreforfilter)) |
334 | 381 | { |
@@ -351,11 +398,19 @@ discard block |
||
351 | 398 | foreach($object->fields as $key => $val) |
352 | 399 | { |
353 | 400 | $align=''; |
354 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; |
|
355 | - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; |
|
356 | - if ($key == 'status') $align.=($align?' ':'').'center'; |
|
357 | - if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; |
|
358 | -} |
|
401 | + if (in_array($val['type'], array('date','datetime','timestamp'))) { |
|
402 | + $align.=($align?' ':'').'center'; |
|
403 | + } |
|
404 | + if (in_array($val['type'], array('timestamp'))) { |
|
405 | + $align.=($align?' ':'').'nowrap'; |
|
406 | + } |
|
407 | + if ($key == 'status') { |
|
408 | + $align.=($align?' ':'').'center'; |
|
409 | + } |
|
410 | + if (! empty($arrayfields['t.'.$key]['checked'])) { |
|
411 | + print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; |
|
412 | + } |
|
413 | + } |
|
359 | 414 | // Extra fields |
360 | 415 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; |
361 | 416 | |
@@ -377,11 +432,19 @@ discard block |
||
377 | 432 | foreach($object->fields as $key => $val) |
378 | 433 | { |
379 | 434 | $align=''; |
380 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; |
|
381 | - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; |
|
382 | - if ($key == 'status') $align.=($align?' ':'').'center'; |
|
383 | - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; |
|
384 | -} |
|
435 | + if (in_array($val['type'], array('date','datetime','timestamp'))) { |
|
436 | + $align.=($align?' ':'').'center'; |
|
437 | + } |
|
438 | + if (in_array($val['type'], array('timestamp'))) { |
|
439 | + $align.=($align?' ':'').'nowrap'; |
|
440 | + } |
|
441 | + if ($key == 'status') { |
|
442 | + $align.=($align?' ':'').'center'; |
|
443 | + } |
|
444 | + if (! empty($arrayfields['t.'.$key]['checked'])) { |
|
445 | + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; |
|
446 | + } |
|
447 | + } |
|
385 | 448 | // Extra fields |
386 | 449 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; |
387 | 450 | // Hook fields |
@@ -396,7 +459,10 @@ discard block |
||
396 | 459 | $needToFetchEachLine=0; |
397 | 460 | foreach ($extrafields->attribute_computed as $key => $val) |
398 | 461 | { |
399 | - if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object |
|
462 | + if (preg_match('/\$object/',$val)) { |
|
463 | + $needToFetchEachLine++; |
|
464 | + } |
|
465 | + // There is at least one compute field that use $object |
|
400 | 466 | } |
401 | 467 | |
402 | 468 | |
@@ -407,13 +473,18 @@ discard block |
||
407 | 473 | while ($i < min($num, $limit)) |
408 | 474 | { |
409 | 475 | $obj = $db->fetch_object($resql); |
410 | - if (empty($obj)) break; // Should not happen |
|
476 | + if (empty($obj)) { |
|
477 | + break; |
|
478 | + } |
|
479 | + // Should not happen |
|
411 | 480 | |
412 | 481 | // Store properties in $object |
413 | 482 | $object->id = $obj->rowid; |
414 | 483 | foreach($object->fields as $key => $val) |
415 | 484 | { |
416 | - if (isset($obj->$key)) $object->$key = $obj->$key; |
|
485 | + if (isset($obj->$key)) { |
|
486 | + $object->$key = $obj->$key; |
|
487 | + } |
|
417 | 488 | } |
418 | 489 | |
419 | 490 | // Show here line of result |
@@ -421,20 +492,32 @@ discard block |
||
421 | 492 | foreach($object->fields as $key => $val) |
422 | 493 | { |
423 | 494 | $align=''; |
424 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; |
|
425 | - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; |
|
426 | - if ($key == 'status') $align.=($align?' ':'').'center'; |
|
495 | + if (in_array($val['type'], array('date','datetime','timestamp'))) { |
|
496 | + $align.=($align?' ':'').'center'; |
|
497 | + } |
|
498 | + if (in_array($val['type'], array('timestamp'))) { |
|
499 | + $align.=($align?' ':'').'nowrap'; |
|
500 | + } |
|
501 | + if ($key == 'status') { |
|
502 | + $align.=($align?' ':'').'center'; |
|
503 | + } |
|
427 | 504 | if (! empty($arrayfields['t.'.$key]['checked'])) |
428 | 505 | { |
429 | 506 | print '<td'; |
430 | - if ($align) print ' class="'.$align.'"'; |
|
507 | + if ($align) { |
|
508 | + print ' class="'.$align.'"'; |
|
509 | + } |
|
431 | 510 | print '>'; |
432 | 511 | print $object->showOutputField($val, $key, $obj->$key, ''); |
433 | 512 | print '</td>'; |
434 | - if (! $i) $totalarray['nbfield']++; |
|
513 | + if (! $i) { |
|
514 | + $totalarray['nbfield']++; |
|
515 | + } |
|
435 | 516 | if (! empty($val['isameasure'])) |
436 | 517 | { |
437 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; |
|
518 | + if (! $i) { |
|
519 | + $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; |
|
520 | + } |
|
438 | 521 | $totalarray['val']['t.'.$key] += $obj->$key; |
439 | 522 | } |
440 | 523 | } |
@@ -447,14 +530,20 @@ discard block |
||
447 | 530 | print $hookmanager->resPrint; |
448 | 531 | // Action column |
449 | 532 | print '<td class="nowrap" align="center">'; |
450 | - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
|
533 | + if ($massactionbutton || $massaction) { |
|
534 | + // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
|
451 | 535 | { |
452 | 536 | $selected=0; |
453 | - if (in_array($obj->rowid, $arrayofselected)) $selected=1; |
|
537 | + } |
|
538 | + if (in_array($obj->rowid, $arrayofselected)) { |
|
539 | + $selected=1; |
|
540 | + } |
|
454 | 541 | print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; |
455 | 542 | } |
456 | 543 | print '</td>'; |
457 | - if (! $i) $totalarray['nbfield']++; |
|
544 | + if (! $i) { |
|
545 | + $totalarray['nbfield']++; |
|
546 | + } |
|
458 | 547 | |
459 | 548 | print '</tr>'; |
460 | 549 | |
@@ -469,15 +558,20 @@ discard block |
||
469 | 558 | while ($i < $totalarray['nbfield']) |
470 | 559 | { |
471 | 560 | $i++; |
472 | - if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; |
|
473 | - else |
|
561 | + if (! empty($totalarray['pos'][$i])) { |
|
562 | + print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; |
|
563 | + } else |
|
474 | 564 | { |
475 | 565 | if ($i == 1) |
476 | 566 | { |
477 | - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; |
|
478 | - else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
|
567 | + if ($num < $limit) { |
|
568 | + print '<td align="left">'.$langs->trans("Total").'</td>'; |
|
569 | + } else { |
|
570 | + print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
|
571 | + } |
|
572 | + } else { |
|
573 | + print '<td></td>'; |
|
479 | 574 | } |
480 | - else print '<td></td>'; |
|
481 | 575 | } |
482 | 576 | } |
483 | 577 | print '</tr>'; |
@@ -487,7 +581,10 @@ discard block |
||
487 | 581 | if ($num == 0) |
488 | 582 | { |
489 | 583 | $colspan=1; |
490 | - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } |
|
584 | + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) { |
|
585 | + $colspan++; |
|
586 | + } |
|
587 | + } |
|
491 | 588 | print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; |
492 | 589 | } |
493 | 590 | |
@@ -519,8 +616,7 @@ discard block |
||
519 | 616 | $delallowed=$user->rights->asset->create; |
520 | 617 | |
521 | 618 | print $formfile->showdocuments('massfilesarea_asset','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); |
522 | - } |
|
523 | - else |
|
619 | + } else |
|
524 | 620 | { |
525 | 621 | print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>'; |
526 | 622 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
29 | 29 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
30 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
30 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
31 | 31 | |
32 | 32 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; |
33 | 33 | require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
@@ -37,43 +37,43 @@ discard block |
||
37 | 37 | // Load translation files required by the page |
38 | 38 | $langs->loadLangs(array("assets")); |
39 | 39 | |
40 | -$action = GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... |
|
41 | -$massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists) |
|
42 | -$show_files = GETPOST('show_files','int'); // Show files area generated by bulk actions ? |
|
43 | -$confirm = GETPOST('confirm','alpha'); // Result of a confirmation |
|
44 | -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button |
|
45 | -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list |
|
46 | -$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'assetslist'; // To manage different context of search |
|
47 | -$backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page |
|
48 | -$optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print') |
|
40 | +$action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... |
|
41 | +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) |
|
42 | +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? |
|
43 | +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation |
|
44 | +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button |
|
45 | +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list |
|
46 | +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'assetslist'; // To manage different context of search |
|
47 | +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page |
|
48 | +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') |
|
49 | 49 | |
50 | -$id = GETPOST('id','int'); |
|
50 | +$id = GETPOST('id', 'int'); |
|
51 | 51 | |
52 | 52 | // Load variable for pagination |
53 | -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
|
54 | -$sortfield = GETPOST('sortfield','alpha'); |
|
55 | -$sortorder = GETPOST('sortorder','alpha'); |
|
56 | -$page = GETPOST('page','int'); |
|
53 | +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; |
|
54 | +$sortfield = GETPOST('sortfield', 'alpha'); |
|
55 | +$sortorder = GETPOST('sortorder', 'alpha'); |
|
56 | +$page = GETPOST('page', 'int'); |
|
57 | 57 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
58 | 58 | $offset = $limit * $page; |
59 | 59 | $pageprev = $page - 1; |
60 | 60 | $pagenext = $page + 1; |
61 | 61 | |
62 | 62 | // Initialize technical objects |
63 | -$object=new Asset($db); |
|
63 | +$object = new Asset($db); |
|
64 | 64 | $extrafields = new ExtraFields($db); |
65 | -$diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->id; |
|
66 | -$hookmanager->initHooks(array('assetlist')); // Note that conf->hooks_modules contains array |
|
65 | +$diroutputmassaction = $conf->asset->dir_output.'/temp/massgeneration/'.$user->id; |
|
66 | +$hookmanager->initHooks(array('assetlist')); // Note that conf->hooks_modules contains array |
|
67 | 67 | // Fetch optionals attributes and labels |
68 | 68 | $extralabels = $extrafields->fetch_name_optionals_label('asset'); |
69 | -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); |
|
69 | +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); |
|
70 | 70 | |
71 | 71 | // Default sort order (if not yet defined by previous GETPOST) |
72 | -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. |
|
73 | -if (! $sortorder) $sortorder="ASC"; |
|
72 | +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. |
|
73 | +if (!$sortorder) $sortorder = "ASC"; |
|
74 | 74 | |
75 | 75 | // Protection if external user |
76 | -$socid=0; |
|
76 | +$socid = 0; |
|
77 | 77 | if ($user->societe_id > 0) |
78 | 78 | { |
79 | 79 | //$socid = $user->societe_id; |
@@ -82,33 +82,33 @@ discard block |
||
82 | 82 | //$result = restrictedArea($user, 'asset', $id,''); |
83 | 83 | |
84 | 84 | // Initialize array of search criterias |
85 | -$search_all=trim(GETPOST("search_all",'alpha')); |
|
86 | -$search=array(); |
|
87 | -foreach($object->fields as $key => $val) |
|
85 | +$search_all = trim(GETPOST("search_all", 'alpha')); |
|
86 | +$search = array(); |
|
87 | +foreach ($object->fields as $key => $val) |
|
88 | 88 | { |
89 | - if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
89 | + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | // List of fields to search into when doing a "search in all" |
93 | 93 | $fieldstosearchall = array(); |
94 | -foreach($object->fields as $key => $val) |
|
94 | +foreach ($object->fields as $key => $val) |
|
95 | 95 | { |
96 | - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; |
|
96 | + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | // Definition of fields for list |
100 | -$arrayfields=array(); |
|
101 | -foreach($object->fields as $key => $val) |
|
100 | +$arrayfields = array(); |
|
101 | +foreach ($object->fields as $key => $val) |
|
102 | 102 | { |
103 | 103 | // If $val['visible']==0, then we never show the field |
104 | - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); |
|
104 | + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); |
|
105 | 105 | } |
106 | 106 | // Extra fields |
107 | 107 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
108 | 108 | { |
109 | - foreach($extrafields->attribute_label as $key => $val) |
|
109 | + foreach ($extrafields->attribute_label as $key => $val) |
|
110 | 110 | { |
111 | - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); |
|
111 | + if (!empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key] = array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key] < 0) ? 0 : 1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key]) != 3 && $extrafields->attribute_perms[$key])); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | $object->fields = dol_sort_array($object->fields, 'position'); |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | * Put here all code to do according to value of "$action" parameter |
123 | 123 | */ |
124 | 124 | |
125 | -if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } |
|
126 | -if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } |
|
125 | +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } |
|
126 | +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } |
|
127 | 127 | |
128 | -$parameters=array(); |
|
129 | -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
128 | +$parameters = array(); |
|
129 | +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
130 | 130 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
131 | 131 | |
132 | 132 | if (empty($reshook)) |
@@ -135,24 +135,24 @@ discard block |
||
135 | 135 | include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
136 | 136 | |
137 | 137 | // Purge search criteria |
138 | - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers |
|
138 | + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers |
|
139 | 139 | { |
140 | - foreach($object->fields as $key => $val) |
|
140 | + foreach ($object->fields as $key => $val) |
|
141 | 141 | { |
142 | - $search[$key]=''; |
|
142 | + $search[$key] = ''; |
|
143 | 143 | } |
144 | - $toselect=''; |
|
145 | - $search_array_options=array(); |
|
144 | + $toselect = ''; |
|
145 | + $search_array_options = array(); |
|
146 | 146 | } |
147 | - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') |
|
148 | - || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) |
|
147 | + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') |
|
148 | + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) |
|
149 | 149 | { |
150 | - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation |
|
150 | + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // Mass actions |
154 | - $objectclass='Asset'; |
|
155 | - $objectlabel='Asset'; |
|
154 | + $objectclass = 'Asset'; |
|
155 | + $objectlabel = 'Asset'; |
|
156 | 156 | $permtoread = $user->rights->asset->read; |
157 | 157 | $permtodelete = $user->rights->asset->delete; |
158 | 158 | $uploaddir = $conf->asset->dir_output; |
@@ -167,45 +167,45 @@ discard block |
||
167 | 167 | * Put here all code to render page |
168 | 168 | */ |
169 | 169 | |
170 | -$form=new Form($db); |
|
170 | +$form = new Form($db); |
|
171 | 171 | |
172 | -$now=dol_now(); |
|
172 | +$now = dol_now(); |
|
173 | 173 | |
174 | 174 | //$help_url="EN:Module_Asset|FR:Module_Asset_FR|ES:Módulo_Asset"; |
175 | -$help_url=''; |
|
175 | +$help_url = ''; |
|
176 | 176 | $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Assets")); |
177 | 177 | |
178 | 178 | |
179 | 179 | // Build and execute select |
180 | 180 | // -------------------------------------------------------------------- |
181 | 181 | $sql = 'SELECT '; |
182 | -foreach($object->fields as $key => $val) |
|
182 | +foreach ($object->fields as $key => $val) |
|
183 | 183 | { |
184 | - $sql.='t.'.$key.', '; |
|
184 | + $sql .= 't.'.$key.', '; |
|
185 | 185 | } |
186 | 186 | // Add fields from extrafields |
187 | -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); |
|
187 | +foreach ($extrafields->attribute_label as $key => $val) $sql .= ($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); |
|
188 | 188 | // Add fields from hooks |
189 | -$parameters=array(); |
|
190 | -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook |
|
191 | -$sql.=$hookmanager->resPrint; |
|
192 | -$sql=preg_replace('/, $/','', $sql); |
|
193 | -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; |
|
194 | -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."assets_extrafields as ef on (t.rowid = ef.fk_object)"; |
|
195 | -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('assets').")"; |
|
196 | -else $sql.=" WHERE 1 = 1"; |
|
197 | -foreach($search as $key => $val) |
|
189 | +$parameters = array(); |
|
190 | +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook |
|
191 | +$sql .= $hookmanager->resPrint; |
|
192 | +$sql = preg_replace('/, $/', '', $sql); |
|
193 | +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; |
|
194 | +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."assets_extrafields as ef on (t.rowid = ef.fk_object)"; |
|
195 | +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity('assets').")"; |
|
196 | +else $sql .= " WHERE 1 = 1"; |
|
197 | +foreach ($search as $key => $val) |
|
198 | 198 | { |
199 | - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); |
|
200 | - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); |
|
199 | + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); |
|
200 | + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); |
|
201 | 201 | } |
202 | -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); |
|
202 | +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); |
|
203 | 203 | // Add where from extra fields |
204 | 204 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; |
205 | 205 | // Add where from hooks |
206 | -$parameters=array(); |
|
207 | -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook |
|
208 | -$sql.=$hookmanager->resPrint; |
|
206 | +$parameters = array(); |
|
207 | +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook |
|
208 | +$sql .= $hookmanager->resPrint; |
|
209 | 209 | |
210 | 210 | /* If a group by is required |
211 | 211 | $sql.= " GROUP BY " |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | $sql.=$hookmanager->resPrint; |
222 | 222 | */ |
223 | 223 | |
224 | -$sql.=$db->order($sortfield,$sortorder); |
|
224 | +$sql .= $db->order($sortfield, $sortorder); |
|
225 | 225 | |
226 | 226 | // Count total nb of records |
227 | 227 | $nbtotalofrecords = ''; |
@@ -236,10 +236,10 @@ discard block |
||
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | -$sql.= $db->plimit($limit+1, $offset); |
|
239 | +$sql .= $db->plimit($limit + 1, $offset); |
|
240 | 240 | |
241 | -$resql=$db->query($sql); |
|
242 | -if (! $resql) |
|
241 | +$resql = $db->query($sql); |
|
242 | +if (!$resql) |
|
243 | 243 | { |
244 | 244 | dol_print_error($db); |
245 | 245 | exit; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | $num = $db->num_rows($resql); |
249 | 249 | |
250 | 250 | // Direct jump if only one record found |
251 | -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) |
|
251 | +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) |
|
252 | 252 | { |
253 | 253 | $obj = $db->fetch_object($resql); |
254 | 254 | $id = $obj->rowid; |
@@ -277,27 +277,27 @@ discard block |
||
277 | 277 | }); |
278 | 278 | </script>'; |
279 | 279 | |
280 | -$arrayofselected=is_array($toselect)?$toselect:array(); |
|
280 | +$arrayofselected = is_array($toselect) ? $toselect : array(); |
|
281 | 281 | |
282 | -$param=''; |
|
283 | -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); |
|
284 | -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); |
|
285 | -foreach($search as $key => $val) |
|
282 | +$param = ''; |
|
283 | +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); |
|
284 | +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); |
|
285 | +foreach ($search as $key => $val) |
|
286 | 286 | { |
287 | - $param.= '&search_'.$key.'='.urlencode($search[$key]); |
|
287 | + $param .= '&search_'.$key.'='.urlencode($search[$key]); |
|
288 | 288 | } |
289 | -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); |
|
289 | +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); |
|
290 | 290 | // Add $param from extra fields |
291 | 291 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; |
292 | 292 | |
293 | 293 | // List of mass actions available |
294 | -$arrayofmassactions = array( |
|
294 | +$arrayofmassactions = array( |
|
295 | 295 | //'presend'=>$langs->trans("SendByMail"), |
296 | 296 | //'builddoc'=>$langs->trans("PDFMerge"), |
297 | 297 | ); |
298 | -if ($user->rights->asset->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); |
|
299 | -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); |
|
300 | -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); |
|
298 | +if ($user->rights->asset->delete) $arrayofmassactions['predelete'] = $langs->trans("Delete"); |
|
299 | +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); |
|
300 | +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); |
|
301 | 301 | |
302 | 302 | print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; |
303 | 303 | if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
@@ -312,16 +312,16 @@ discard block |
||
312 | 312 | print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); |
313 | 313 | |
314 | 314 | // Add code for pre mass action (confirmation or email presend form) |
315 | -$topicmail="SendAssetsRef"; |
|
316 | -$modelmail="asset"; |
|
317 | -$objecttmp=new Asset($db); |
|
318 | -$trackid='xxxx'.$object->id; |
|
315 | +$topicmail = "SendAssetsRef"; |
|
316 | +$modelmail = "asset"; |
|
317 | +$objecttmp = new Asset($db); |
|
318 | +$trackid = 'xxxx'.$object->id; |
|
319 | 319 | include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; |
320 | 320 | |
321 | 321 | if ($sall) |
322 | 322 | { |
323 | - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); |
|
324 | - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>'; |
|
323 | + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); |
|
324 | + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | $moreforfilter = ''; |
@@ -329,47 +329,47 @@ discard block |
||
329 | 329 | $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">'; |
330 | 330 | $moreforfilter.= '</div>';*/ |
331 | 331 | |
332 | -$parameters=array(); |
|
333 | -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook |
|
332 | +$parameters = array(); |
|
333 | +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook |
|
334 | 334 | if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; |
335 | 335 | else $moreforfilter = $hookmanager->resPrint; |
336 | 336 | |
337 | -if (! empty($moreforfilter)) |
|
337 | +if (!empty($moreforfilter)) |
|
338 | 338 | { |
339 | 339 | print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
340 | 340 | print $moreforfilter; |
341 | 341 | print '</div>'; |
342 | 342 | } |
343 | 343 | |
344 | -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; |
|
345 | -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
|
346 | -$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); |
|
344 | +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; |
|
345 | +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
|
346 | +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); |
|
347 | 347 | |
348 | -print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table |
|
349 | -print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; |
|
348 | +print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table |
|
349 | +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; |
|
350 | 350 | |
351 | 351 | |
352 | 352 | // Fields title search |
353 | 353 | // -------------------------------------------------------------------- |
354 | 354 | print '<tr class="liste_titre">'; |
355 | -foreach($object->fields as $key => $val) |
|
355 | +foreach ($object->fields as $key => $val) |
|
356 | 356 | { |
357 | - $align=''; |
|
358 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; |
|
359 | - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; |
|
360 | - if ($key == 'status') $align.=($align?' ':'').'center'; |
|
361 | - if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; |
|
357 | + $align = ''; |
|
358 | + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; |
|
359 | + if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; |
|
360 | + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; |
|
361 | + if (!empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align ? ' '.$align : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; |
|
362 | 362 | } |
363 | 363 | // Extra fields |
364 | 364 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; |
365 | 365 | |
366 | 366 | // Fields from hook |
367 | -$parameters=array('arrayfields'=>$arrayfields); |
|
368 | -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook |
|
367 | +$parameters = array('arrayfields'=>$arrayfields); |
|
368 | +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook |
|
369 | 369 | print $hookmanager->resPrint; |
370 | 370 | // Action column |
371 | 371 | print '<td class="liste_titre" align="right">'; |
372 | -$searchpicto=$form->showFilterButtons(); |
|
372 | +$searchpicto = $form->showFilterButtons(); |
|
373 | 373 | print $searchpicto; |
374 | 374 | print '</td>'; |
375 | 375 | print '</tr>'."\n"; |
@@ -378,67 +378,67 @@ discard block |
||
378 | 378 | // Fields title label |
379 | 379 | // -------------------------------------------------------------------- |
380 | 380 | print '<tr class="liste_titre">'; |
381 | -foreach($object->fields as $key => $val) |
|
381 | +foreach ($object->fields as $key => $val) |
|
382 | 382 | { |
383 | - $align=''; |
|
384 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; |
|
385 | - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; |
|
386 | - if ($key == 'status') $align.=($align?' ':'').'center'; |
|
387 | - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; |
|
383 | + $align = ''; |
|
384 | + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; |
|
385 | + if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; |
|
386 | + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; |
|
387 | + if (!empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; |
|
388 | 388 | } |
389 | 389 | // Extra fields |
390 | 390 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; |
391 | 391 | // Hook fields |
392 | -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); |
|
393 | -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook |
|
392 | +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); |
|
393 | +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook |
|
394 | 394 | print $hookmanager->resPrint; |
395 | -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],'','','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; |
|
395 | +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; |
|
396 | 396 | print '</tr>'."\n"; |
397 | 397 | |
398 | 398 | |
399 | 399 | // Detect if we need a fetch on each output line |
400 | -$needToFetchEachLine=0; |
|
400 | +$needToFetchEachLine = 0; |
|
401 | 401 | foreach ($extrafields->attribute_computed as $key => $val) |
402 | 402 | { |
403 | - if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object |
|
403 | + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
407 | 407 | // Loop on record |
408 | 408 | // -------------------------------------------------------------------- |
409 | -$i=0; |
|
410 | -$totalarray=array(); |
|
409 | +$i = 0; |
|
410 | +$totalarray = array(); |
|
411 | 411 | while ($i < min($num, $limit)) |
412 | 412 | { |
413 | 413 | $obj = $db->fetch_object($resql); |
414 | - if (empty($obj)) break; // Should not happen |
|
414 | + if (empty($obj)) break; // Should not happen |
|
415 | 415 | |
416 | 416 | // Store properties in $object |
417 | 417 | $object->id = $obj->rowid; |
418 | - foreach($object->fields as $key => $val) |
|
418 | + foreach ($object->fields as $key => $val) |
|
419 | 419 | { |
420 | 420 | if (isset($obj->$key)) $object->$key = $obj->$key; |
421 | 421 | } |
422 | 422 | |
423 | 423 | // Show here line of result |
424 | 424 | print '<tr class="oddeven">'; |
425 | - foreach($object->fields as $key => $val) |
|
425 | + foreach ($object->fields as $key => $val) |
|
426 | 426 | { |
427 | - $align=''; |
|
428 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; |
|
429 | - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; |
|
430 | - if ($key == 'status') $align.=($align?' ':'').'center'; |
|
431 | - if (! empty($arrayfields['t.'.$key]['checked'])) |
|
427 | + $align = ''; |
|
428 | + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; |
|
429 | + if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; |
|
430 | + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; |
|
431 | + if (!empty($arrayfields['t.'.$key]['checked'])) |
|
432 | 432 | { |
433 | 433 | print '<td'; |
434 | 434 | if ($align) print ' class="'.$align.'"'; |
435 | 435 | print '>'; |
436 | 436 | print $object->showOutputField($val, $key, $obj->$key, ''); |
437 | 437 | print '</td>'; |
438 | - if (! $i) $totalarray['nbfield']++; |
|
439 | - if (! empty($val['isameasure'])) |
|
438 | + if (!$i) $totalarray['nbfield']++; |
|
439 | + if (!empty($val['isameasure'])) |
|
440 | 440 | { |
441 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; |
|
441 | + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; |
|
442 | 442 | $totalarray['val']['t.'.$key] += $obj->$key; |
443 | 443 | } |
444 | 444 | } |
@@ -446,19 +446,19 @@ discard block |
||
446 | 446 | // Extra fields |
447 | 447 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; |
448 | 448 | // Fields from hook |
449 | - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); |
|
450 | - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook |
|
449 | + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); |
|
450 | + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook |
|
451 | 451 | print $hookmanager->resPrint; |
452 | 452 | // Action column |
453 | 453 | print '<td class="nowrap" align="center">'; |
454 | 454 | if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
455 | 455 | { |
456 | - $selected=0; |
|
457 | - if (in_array($obj->rowid, $arrayofselected)) $selected=1; |
|
458 | - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; |
|
456 | + $selected = 0; |
|
457 | + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; |
|
458 | + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; |
|
459 | 459 | } |
460 | 460 | print '</td>'; |
461 | - if (! $i) $totalarray['nbfield']++; |
|
461 | + if (!$i) $totalarray['nbfield']++; |
|
462 | 462 | |
463 | 463 | print '</tr>'; |
464 | 464 | |
@@ -469,11 +469,11 @@ discard block |
||
469 | 469 | if (isset($totalarray['pos'])) |
470 | 470 | { |
471 | 471 | print '<tr class="liste_total">'; |
472 | - $i=0; |
|
472 | + $i = 0; |
|
473 | 473 | while ($i < $totalarray['nbfield']) |
474 | 474 | { |
475 | 475 | $i++; |
476 | - if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; |
|
476 | + if (!empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; |
|
477 | 477 | else |
478 | 478 | { |
479 | 479 | if ($i == 1) |
@@ -490,16 +490,16 @@ discard block |
||
490 | 490 | // If no record found |
491 | 491 | if ($num == 0) |
492 | 492 | { |
493 | - $colspan=1; |
|
494 | - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } |
|
493 | + $colspan = 1; |
|
494 | + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } |
|
495 | 495 | print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; |
496 | 496 | } |
497 | 497 | |
498 | 498 | |
499 | 499 | $db->free($resql); |
500 | 500 | |
501 | -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); |
|
502 | -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook |
|
501 | +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); |
|
502 | +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook |
|
503 | 503 | print $hookmanager->resPrint; |
504 | 504 | |
505 | 505 | print '</table>'."\n"; |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | |
508 | 508 | print '</form>'."\n"; |
509 | 509 | |
510 | -if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) |
|
510 | +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) |
|
511 | 511 | { |
512 | 512 | if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) |
513 | 513 | { |
@@ -515,14 +515,14 @@ discard block |
||
515 | 515 | $formfile = new FormFile($db); |
516 | 516 | |
517 | 517 | // Show list of available documents |
518 | - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; |
|
519 | - $urlsource.=str_replace('&','&',$param); |
|
518 | + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; |
|
519 | + $urlsource .= str_replace('&', '&', $param); |
|
520 | 520 | |
521 | - $filedir=$diroutputmassaction; |
|
522 | - $genallowed=$user->rights->asset->read; |
|
523 | - $delallowed=$user->rights->asset->create; |
|
521 | + $filedir = $diroutputmassaction; |
|
522 | + $genallowed = $user->rights->asset->read; |
|
523 | + $delallowed = $user->rights->asset->create; |
|
524 | 524 | |
525 | - print $formfile->showdocuments('massfilesarea_asset','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); |
|
525 | + print $formfile->showdocuments('massfilesarea_asset', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, ''); |
|
526 | 526 | } |
527 | 527 | else |
528 | 528 | { |
@@ -40,180 +40,180 @@ |
||
40 | 40 | public $errors = array(); |
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @var array Hook results. Propagated to $hookmanager->resArray for later reuse |
|
45 | - */ |
|
46 | - public $results = array(); |
|
47 | - |
|
48 | - /** |
|
49 | - * @var string String displayed by executeHook() immediately after return |
|
50 | - */ |
|
51 | - public $resprints; |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * Constructor |
|
56 | - * |
|
57 | - * @param DoliDB $db Database handler |
|
58 | - */ |
|
59 | - public function __construct($db) |
|
60 | - { |
|
61 | - $this->db = $db; |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * Overloading the doActions function : replacing the parent's function with the one below |
|
66 | - * |
|
67 | - * @param array() $parameters Hook metadatas (context, etc...) |
|
68 | - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) |
|
69 | - * @param string $action Current action (if set). Generally create or edit or null |
|
70 | - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook |
|
71 | - * @return int < 0 on error, 0 on success, 1 to replace standard code |
|
72 | - */ |
|
73 | - public function doActions($parameters, &$object, &$action, $hookmanager) |
|
74 | - { |
|
75 | - global $conf, $user, $langs; |
|
76 | - |
|
77 | - $error = 0; // Error counter |
|
43 | + /** |
|
44 | + * @var array Hook results. Propagated to $hookmanager->resArray for later reuse |
|
45 | + */ |
|
46 | + public $results = array(); |
|
47 | + |
|
48 | + /** |
|
49 | + * @var string String displayed by executeHook() immediately after return |
|
50 | + */ |
|
51 | + public $resprints; |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * Constructor |
|
56 | + * |
|
57 | + * @param DoliDB $db Database handler |
|
58 | + */ |
|
59 | + public function __construct($db) |
|
60 | + { |
|
61 | + $this->db = $db; |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * Overloading the doActions function : replacing the parent's function with the one below |
|
66 | + * |
|
67 | + * @param array() $parameters Hook metadatas (context, etc...) |
|
68 | + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) |
|
69 | + * @param string $action Current action (if set). Generally create or edit or null |
|
70 | + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook |
|
71 | + * @return int < 0 on error, 0 on success, 1 to replace standard code |
|
72 | + */ |
|
73 | + public function doActions($parameters, &$object, &$action, $hookmanager) |
|
74 | + { |
|
75 | + global $conf, $user, $langs; |
|
76 | + |
|
77 | + $error = 0; // Error counter |
|
78 | + |
|
79 | + /* print_r($parameters); print_r($object); echo "action: " . $action; */ |
|
80 | + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
81 | + { |
|
82 | + // Do what you want here... |
|
83 | + // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values. |
|
84 | + } |
|
85 | + |
|
86 | + if (! $error) { |
|
87 | + $this->results = array('myreturn' => 999); |
|
88 | + $this->resprints = 'A text to show'; |
|
89 | + return 0; // or return 1 to replace standard code |
|
90 | + } else { |
|
91 | + $this->errors[] = 'Error message'; |
|
92 | + return -1; |
|
93 | + } |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * Overloading the doActions function : replacing the parent's function with the one below |
|
99 | + * |
|
100 | + * @param array() $parameters Hook metadatas (context, etc...) |
|
101 | + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) |
|
102 | + * @param string $action Current action (if set). Generally create or edit or null |
|
103 | + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook |
|
104 | + * @return int < 0 on error, 0 on success, 1 to replace standard code |
|
105 | + */ |
|
106 | + public function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) |
|
107 | + { |
|
108 | + global $conf, $user, $langs; |
|
109 | + |
|
110 | + $error = 0; // Error counter |
|
111 | + |
|
112 | + /* print_r($parameters); print_r($object); echo "action: " . $action; */ |
|
113 | + if (in_array($parameters['currentcontext'], array('invoicecard'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
114 | + { |
|
115 | + |
|
116 | + $receipt_url=DOL_URL_ROOT."/takepos/receipt.php"; |
|
117 | + print '<div class="inline-block divButAction"><a target="_blank" class="butAction" href="' . $receipt_url . '?facid=' . $object->id.'">' . $langs->trans('Ticket') .'</a></div>'; |
|
118 | + } |
|
119 | + |
|
120 | + if (! $error) { |
|
121 | + $this->results = array('myreturn' => 999); |
|
122 | + $this->resprints = 'A text to show'; |
|
123 | + return 0; // or return 1 to replace standard code |
|
124 | + } else { |
|
125 | + $this->errors[] = 'Error message'; |
|
126 | + return -1; |
|
127 | + } |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * Overloading the addMoreMassActions function : replacing the parent's function with the one below |
|
133 | + * |
|
134 | + * @param array() $parameters Hook metadatas (context, etc...) |
|
135 | + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) |
|
136 | + * @param string $action Current action (if set). Generally create or edit or null |
|
137 | + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook |
|
138 | + * @return int < 0 on error, 0 on success, 1 to replace standard code |
|
139 | + */ |
|
140 | + public function addMoreMassActions($parameters, &$object, &$action, $hookmanager) |
|
141 | + { |
|
142 | + global $conf, $user, $langs; |
|
143 | + |
|
144 | + $error = 0; // Error counter |
|
78 | 145 | |
79 | 146 | /* print_r($parameters); print_r($object); echo "action: " . $action; */ |
80 | - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
81 | - { |
|
82 | - // Do what you want here... |
|
83 | - // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values. |
|
84 | - } |
|
85 | - |
|
86 | - if (! $error) { |
|
87 | - $this->results = array('myreturn' => 999); |
|
88 | - $this->resprints = 'A text to show'; |
|
89 | - return 0; // or return 1 to replace standard code |
|
90 | - } else { |
|
91 | - $this->errors[] = 'Error message'; |
|
92 | - return -1; |
|
93 | - } |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * Overloading the doActions function : replacing the parent's function with the one below |
|
99 | - * |
|
100 | - * @param array() $parameters Hook metadatas (context, etc...) |
|
101 | - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) |
|
102 | - * @param string $action Current action (if set). Generally create or edit or null |
|
103 | - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook |
|
104 | - * @return int < 0 on error, 0 on success, 1 to replace standard code |
|
105 | - */ |
|
106 | - public function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) |
|
107 | - { |
|
108 | - global $conf, $user, $langs; |
|
109 | - |
|
110 | - $error = 0; // Error counter |
|
147 | + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
148 | + { |
|
149 | + $this->resprints = '<option value="0"'.($disabled?' disabled="disabled"':'').'>'.$langs->trans("TakePosMassAction").'</option>'; |
|
150 | + } |
|
151 | + |
|
152 | + if (! $error) { |
|
153 | + return 0; // or return 1 to replace standard code |
|
154 | + } else { |
|
155 | + $this->errors[] = 'Error message'; |
|
156 | + return -1; |
|
157 | + } |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * Execute action |
|
164 | + * |
|
165 | + * @param array $parameters Array of parameters |
|
166 | + * @param Object $object Object output on PDF |
|
167 | + * @param string $action 'add', 'update', 'view' |
|
168 | + * @return int <0 if KO, |
|
169 | + * =0 if OK but we want to process standard actions too, |
|
170 | + * >0 if OK and we want to replace standard actions. |
|
171 | + */ |
|
172 | + function beforePDFCreation($parameters, &$object, &$action) |
|
173 | + { |
|
174 | + global $langs,$conf; |
|
175 | + global $hookmanager; |
|
176 | + |
|
177 | + $outputlangs=$langs; |
|
178 | + |
|
179 | + $ret=0; $deltemp=array(); |
|
180 | + dol_syslog(get_class($this).'::executeHooks action='.$action); |
|
111 | 181 | |
112 | 182 | /* print_r($parameters); print_r($object); echo "action: " . $action; */ |
113 | - if (in_array($parameters['currentcontext'], array('invoicecard'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
114 | - { |
|
115 | - |
|
116 | - $receipt_url=DOL_URL_ROOT."/takepos/receipt.php"; |
|
117 | - print '<div class="inline-block divButAction"><a target="_blank" class="butAction" href="' . $receipt_url . '?facid=' . $object->id.'">' . $langs->trans('Ticket') .'</a></div>'; |
|
118 | - } |
|
119 | - |
|
120 | - if (! $error) { |
|
121 | - $this->results = array('myreturn' => 999); |
|
122 | - $this->resprints = 'A text to show'; |
|
123 | - return 0; // or return 1 to replace standard code |
|
124 | - } else { |
|
125 | - $this->errors[] = 'Error message'; |
|
126 | - return -1; |
|
127 | - } |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * Overloading the addMoreMassActions function : replacing the parent's function with the one below |
|
133 | - * |
|
134 | - * @param array() $parameters Hook metadatas (context, etc...) |
|
135 | - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) |
|
136 | - * @param string $action Current action (if set). Generally create or edit or null |
|
137 | - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook |
|
138 | - * @return int < 0 on error, 0 on success, 1 to replace standard code |
|
139 | - */ |
|
140 | - public function addMoreMassActions($parameters, &$object, &$action, $hookmanager) |
|
141 | - { |
|
142 | - global $conf, $user, $langs; |
|
143 | - |
|
144 | - $error = 0; // Error counter |
|
183 | + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
184 | + { |
|
185 | + |
|
186 | + } |
|
187 | + |
|
188 | + return $ret; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Execute action |
|
193 | + * |
|
194 | + * @param array $parameters Array of parameters |
|
195 | + * @param Object $pdfhandler PDF builder handler |
|
196 | + * @param string $action 'add', 'update', 'view' |
|
197 | + * @return int <0 if KO, |
|
198 | + * =0 if OK but we want to process standard actions too, |
|
199 | + * >0 if OK and we want to replace standard actions. |
|
200 | + */ |
|
201 | + function afterPDFCreation($parameters, &$pdfhandler, &$action) |
|
202 | + { |
|
203 | + global $langs,$conf; |
|
204 | + global $hookmanager; |
|
205 | + |
|
206 | + $outputlangs=$langs; |
|
207 | + |
|
208 | + $ret=0; $deltemp=array(); |
|
209 | + dol_syslog(get_class($this).'::executeHooks action='.$action); |
|
145 | 210 | |
146 | 211 | /* print_r($parameters); print_r($object); echo "action: " . $action; */ |
147 | - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
148 | - { |
|
149 | - $this->resprints = '<option value="0"'.($disabled?' disabled="disabled"':'').'>'.$langs->trans("TakePosMassAction").'</option>'; |
|
150 | - } |
|
151 | - |
|
152 | - if (! $error) { |
|
153 | - return 0; // or return 1 to replace standard code |
|
154 | - } else { |
|
155 | - $this->errors[] = 'Error message'; |
|
156 | - return -1; |
|
157 | - } |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * Execute action |
|
164 | - * |
|
165 | - * @param array $parameters Array of parameters |
|
166 | - * @param Object $object Object output on PDF |
|
167 | - * @param string $action 'add', 'update', 'view' |
|
168 | - * @return int <0 if KO, |
|
169 | - * =0 if OK but we want to process standard actions too, |
|
170 | - * >0 if OK and we want to replace standard actions. |
|
171 | - */ |
|
172 | - function beforePDFCreation($parameters, &$object, &$action) |
|
173 | - { |
|
174 | - global $langs,$conf; |
|
175 | - global $hookmanager; |
|
176 | - |
|
177 | - $outputlangs=$langs; |
|
178 | - |
|
179 | - $ret=0; $deltemp=array(); |
|
180 | - dol_syslog(get_class($this).'::executeHooks action='.$action); |
|
181 | - |
|
182 | - /* print_r($parameters); print_r($object); echo "action: " . $action; */ |
|
183 | - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
184 | - { |
|
185 | - |
|
186 | - } |
|
187 | - |
|
188 | - return $ret; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Execute action |
|
193 | - * |
|
194 | - * @param array $parameters Array of parameters |
|
195 | - * @param Object $pdfhandler PDF builder handler |
|
196 | - * @param string $action 'add', 'update', 'view' |
|
197 | - * @return int <0 if KO, |
|
198 | - * =0 if OK but we want to process standard actions too, |
|
199 | - * >0 if OK and we want to replace standard actions. |
|
200 | - */ |
|
201 | - function afterPDFCreation($parameters, &$pdfhandler, &$action) |
|
202 | - { |
|
203 | - global $langs,$conf; |
|
204 | - global $hookmanager; |
|
205 | - |
|
206 | - $outputlangs=$langs; |
|
207 | - |
|
208 | - $ret=0; $deltemp=array(); |
|
209 | - dol_syslog(get_class($this).'::executeHooks action='.$action); |
|
210 | - |
|
211 | - /* print_r($parameters); print_r($object); echo "action: " . $action; */ |
|
212 | - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
213 | - { |
|
214 | - |
|
215 | - } |
|
216 | - |
|
217 | - return $ret; |
|
218 | - } |
|
212 | + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
213 | + { |
|
214 | + |
|
215 | + } |
|
216 | + |
|
217 | + return $ret; |
|
218 | + } |
|
219 | 219 | } |
@@ -77,16 +77,16 @@ discard block |
||
77 | 77 | $error = 0; // Error counter |
78 | 78 | |
79 | 79 | /* print_r($parameters); print_r($object); echo "action: " . $action; */ |
80 | - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
80 | + if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
81 | 81 | { |
82 | 82 | // Do what you want here... |
83 | 83 | // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values. |
84 | 84 | } |
85 | 85 | |
86 | - if (! $error) { |
|
86 | + if (!$error) { |
|
87 | 87 | $this->results = array('myreturn' => 999); |
88 | 88 | $this->resprints = 'A text to show'; |
89 | - return 0; // or return 1 to replace standard code |
|
89 | + return 0; // or return 1 to replace standard code |
|
90 | 90 | } else { |
91 | 91 | $this->errors[] = 'Error message'; |
92 | 92 | return -1; |
@@ -113,14 +113,14 @@ discard block |
||
113 | 113 | if (in_array($parameters['currentcontext'], array('invoicecard'))) // do something only for the context 'somecontext1' or 'somecontext2' |
114 | 114 | { |
115 | 115 | |
116 | - $receipt_url=DOL_URL_ROOT."/takepos/receipt.php"; |
|
117 | - print '<div class="inline-block divButAction"><a target="_blank" class="butAction" href="' . $receipt_url . '?facid=' . $object->id.'">' . $langs->trans('Ticket') .'</a></div>'; |
|
116 | + $receipt_url = DOL_URL_ROOT."/takepos/receipt.php"; |
|
117 | + print '<div class="inline-block divButAction"><a target="_blank" class="butAction" href="'.$receipt_url.'?facid='.$object->id.'">'.$langs->trans('Ticket').'</a></div>'; |
|
118 | 118 | } |
119 | 119 | |
120 | - if (! $error) { |
|
120 | + if (!$error) { |
|
121 | 121 | $this->results = array('myreturn' => 999); |
122 | 122 | $this->resprints = 'A text to show'; |
123 | - return 0; // or return 1 to replace standard code |
|
123 | + return 0; // or return 1 to replace standard code |
|
124 | 124 | } else { |
125 | 125 | $this->errors[] = 'Error message'; |
126 | 126 | return -1; |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | $error = 0; // Error counter |
145 | 145 | |
146 | 146 | /* print_r($parameters); print_r($object); echo "action: " . $action; */ |
147 | - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
147 | + if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
148 | 148 | { |
149 | - $this->resprints = '<option value="0"'.($disabled?' disabled="disabled"':'').'>'.$langs->trans("TakePosMassAction").'</option>'; |
|
149 | + $this->resprints = '<option value="0"'.($disabled ? ' disabled="disabled"' : '').'>'.$langs->trans("TakePosMassAction").'</option>'; |
|
150 | 150 | } |
151 | 151 | |
152 | - if (! $error) { |
|
153 | - return 0; // or return 1 to replace standard code |
|
152 | + if (!$error) { |
|
153 | + return 0; // or return 1 to replace standard code |
|
154 | 154 | } else { |
155 | 155 | $this->errors[] = 'Error message'; |
156 | 156 | return -1; |
@@ -171,16 +171,16 @@ discard block |
||
171 | 171 | */ |
172 | 172 | function beforePDFCreation($parameters, &$object, &$action) |
173 | 173 | { |
174 | - global $langs,$conf; |
|
174 | + global $langs, $conf; |
|
175 | 175 | global $hookmanager; |
176 | 176 | |
177 | - $outputlangs=$langs; |
|
177 | + $outputlangs = $langs; |
|
178 | 178 | |
179 | - $ret=0; $deltemp=array(); |
|
179 | + $ret = 0; $deltemp = array(); |
|
180 | 180 | dol_syslog(get_class($this).'::executeHooks action='.$action); |
181 | 181 | |
182 | 182 | /* print_r($parameters); print_r($object); echo "action: " . $action; */ |
183 | - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
183 | + if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
184 | 184 | { |
185 | 185 | |
186 | 186 | } |
@@ -200,16 +200,16 @@ discard block |
||
200 | 200 | */ |
201 | 201 | function afterPDFCreation($parameters, &$pdfhandler, &$action) |
202 | 202 | { |
203 | - global $langs,$conf; |
|
203 | + global $langs, $conf; |
|
204 | 204 | global $hookmanager; |
205 | 205 | |
206 | - $outputlangs=$langs; |
|
206 | + $outputlangs = $langs; |
|
207 | 207 | |
208 | - $ret=0; $deltemp=array(); |
|
208 | + $ret = 0; $deltemp = array(); |
|
209 | 209 | dol_syslog(get_class($this).'::executeHooks action='.$action); |
210 | 210 | |
211 | 211 | /* print_r($parameters); print_r($object); echo "action: " . $action; */ |
212 | - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
212 | + if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
213 | 213 | { |
214 | 214 | |
215 | 215 | } |
@@ -77,7 +77,8 @@ discard block |
||
77 | 77 | $error = 0; // Error counter |
78 | 78 | |
79 | 79 | /* print_r($parameters); print_r($object); echo "action: " . $action; */ |
80 | - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
80 | + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) { |
|
81 | + // do something only for the context 'somecontext1' or 'somecontext2' |
|
81 | 82 | { |
82 | 83 | // Do what you want here... |
83 | 84 | // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values. |
@@ -85,6 +86,7 @@ discard block |
||
85 | 86 | |
86 | 87 | if (! $error) { |
87 | 88 | $this->results = array('myreturn' => 999); |
89 | + } |
|
88 | 90 | $this->resprints = 'A text to show'; |
89 | 91 | return 0; // or return 1 to replace standard code |
90 | 92 | } else { |
@@ -110,10 +112,12 @@ discard block |
||
110 | 112 | $error = 0; // Error counter |
111 | 113 | |
112 | 114 | /* print_r($parameters); print_r($object); echo "action: " . $action; */ |
113 | - if (in_array($parameters['currentcontext'], array('invoicecard'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
115 | + if (in_array($parameters['currentcontext'], array('invoicecard'))) { |
|
116 | + // do something only for the context 'somecontext1' or 'somecontext2' |
|
114 | 117 | { |
115 | 118 | |
116 | 119 | $receipt_url=DOL_URL_ROOT."/takepos/receipt.php"; |
120 | + } |
|
117 | 121 | print '<div class="inline-block divButAction"><a target="_blank" class="butAction" href="' . $receipt_url . '?facid=' . $object->id.'">' . $langs->trans('Ticket') .'</a></div>'; |
118 | 122 | } |
119 | 123 | |
@@ -144,10 +148,12 @@ discard block |
||
144 | 148 | $error = 0; // Error counter |
145 | 149 | |
146 | 150 | /* print_r($parameters); print_r($object); echo "action: " . $action; */ |
147 | - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
151 | + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) { |
|
152 | + // do something only for the context 'somecontext1' or 'somecontext2' |
|
148 | 153 | { |
149 | 154 | $this->resprints = '<option value="0"'.($disabled?' disabled="disabled"':'').'>'.$langs->trans("TakePosMassAction").'</option>'; |
150 | 155 | } |
156 | + } |
|
151 | 157 | |
152 | 158 | if (! $error) { |
153 | 159 | return 0; // or return 1 to replace standard code |
@@ -180,12 +186,14 @@ discard block |
||
180 | 186 | dol_syslog(get_class($this).'::executeHooks action='.$action); |
181 | 187 | |
182 | 188 | /* print_r($parameters); print_r($object); echo "action: " . $action; */ |
183 | - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
189 | + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) { |
|
190 | + // do something only for the context 'somecontext1' or 'somecontext2' |
|
184 | 191 | { |
185 | 192 | |
186 | 193 | } |
187 | 194 | |
188 | 195 | return $ret; |
196 | + } |
|
189 | 197 | } |
190 | 198 | |
191 | 199 | /** |
@@ -209,11 +217,13 @@ discard block |
||
209 | 217 | dol_syslog(get_class($this).'::executeHooks action='.$action); |
210 | 218 | |
211 | 219 | /* print_r($parameters); print_r($object); echo "action: " . $action; */ |
212 | - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' |
|
220 | + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) { |
|
221 | + // do something only for the context 'somecontext1' or 'somecontext2' |
|
213 | 222 | { |
214 | 223 | |
215 | 224 | } |
216 | 225 | |
217 | 226 | return $ret; |
227 | + } |
|
218 | 228 | } |
219 | 229 | } |
@@ -28,31 +28,31 @@ |
||
28 | 28 | */ |
29 | 29 | function takeposAdminPrepareHead() |
30 | 30 | { |
31 | - global $langs, $conf; |
|
31 | + global $langs, $conf; |
|
32 | 32 | |
33 | - $langs->load("cashdesk"); |
|
33 | + $langs->load("cashdesk"); |
|
34 | 34 | |
35 | - $h = 0; |
|
36 | - $head = array(); |
|
35 | + $h = 0; |
|
36 | + $head = array(); |
|
37 | 37 | |
38 | - $head[$h][0] = dol_buildpath("/takepos/admin/setup.php", 1); |
|
39 | - $head[$h][1] = $langs->trans("Settings"); |
|
40 | - $head[$h][2] = 'settings'; |
|
41 | - $h++; |
|
42 | - $head[$h][0] = dol_buildpath("/takepos/admin/about.php", 1); |
|
43 | - $head[$h][1] = $langs->trans("About"); |
|
44 | - $head[$h][2] = 'about'; |
|
45 | - $h++; |
|
38 | + $head[$h][0] = dol_buildpath("/takepos/admin/setup.php", 1); |
|
39 | + $head[$h][1] = $langs->trans("Settings"); |
|
40 | + $head[$h][2] = 'settings'; |
|
41 | + $h++; |
|
42 | + $head[$h][0] = dol_buildpath("/takepos/admin/about.php", 1); |
|
43 | + $head[$h][1] = $langs->trans("About"); |
|
44 | + $head[$h][2] = 'about'; |
|
45 | + $h++; |
|
46 | 46 | |
47 | - // Show more tabs from modules |
|
48 | - // Entries must be declared in modules descriptor with line |
|
49 | - //$this->tabs = array( |
|
50 | - // 'entity:+tabname:Title:@takepos:/takepos/mypage.php?id=__ID__' |
|
51 | - //); // to add new tab |
|
52 | - //$this->tabs = array( |
|
53 | - // 'entity:-tabname:Title:@takepos:/takepos/mypage.php?id=__ID__' |
|
54 | - //); // to remove a tab |
|
55 | - complete_head_from_modules($conf, $langs, $object, $head, $h, 'takepos'); |
|
47 | + // Show more tabs from modules |
|
48 | + // Entries must be declared in modules descriptor with line |
|
49 | + //$this->tabs = array( |
|
50 | + // 'entity:+tabname:Title:@takepos:/takepos/mypage.php?id=__ID__' |
|
51 | + //); // to add new tab |
|
52 | + //$this->tabs = array( |
|
53 | + // 'entity:-tabname:Title:@takepos:/takepos/mypage.php?id=__ID__' |
|
54 | + //); // to remove a tab |
|
55 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'takepos'); |
|
56 | 56 | |
57 | - return $head; |
|
57 | + return $head; |
|
58 | 58 | } |
@@ -65,23 +65,34 @@ discard block |
||
65 | 65 | |
66 | 66 | if ($action == 'valid' && $user->rights->facture->creer) |
67 | 67 | { |
68 | - if ($pay=="cash") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CASH; |
|
69 | - else if ($pay=="card") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CB; |
|
70 | - else if ($pay=="cheque") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; |
|
68 | + if ($pay=="cash") { |
|
69 | + $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CASH; |
|
70 | + } else if ($pay=="card") { |
|
71 | + $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CB; |
|
72 | + } else if ($pay=="cheque") { |
|
73 | + $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; |
|
74 | + } |
|
71 | 75 | $now=dol_now(); |
72 | 76 | $invoice = new Facture($db); |
73 | 77 | $invoice->fetch($placeid); |
74 | - if (! empty($conf->stock->enabled) and $conf->global->CASHDESK_NO_DECREASE_STOCK!="1") $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE); |
|
75 | - else $invoice->validate($user); |
|
78 | + if (! empty($conf->stock->enabled) and $conf->global->CASHDESK_NO_DECREASE_STOCK!="1") { |
|
79 | + $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE); |
|
80 | + } else { |
|
81 | + $invoice->validate($user); |
|
82 | + } |
|
76 | 83 | // Add the payment |
77 | 84 | $payment=new Paiement($db); |
78 | 85 | $payment->datepaye=$now; |
79 | 86 | $payment->bank_account=$bankaccount; |
80 | 87 | $payment->amounts[$invoice->id]=$invoice->total_ttc; |
81 | 88 | |
82 | - if ($pay=="cash") $payment->paiementid=4; |
|
83 | - else if ($pay=="card") $payment->paiementid=6; |
|
84 | - else if ($pay=="cheque") $payment->paiementid=7; |
|
89 | + if ($pay=="cash") { |
|
90 | + $payment->paiementid=4; |
|
91 | + } else if ($pay=="card") { |
|
92 | + $payment->paiementid=6; |
|
93 | + } else if ($pay=="cheque") { |
|
94 | + $payment->paiementid=7; |
|
95 | + } |
|
85 | 96 | $payment->num_paiement=$invoice->ref; |
86 | 97 | |
87 | 98 | $payment->create($user); |
@@ -124,8 +135,7 @@ discard block |
||
124 | 135 | if ($idline > 0 and $placeid > 0) { //If exist invoice and line, to avoid errors if deleted from other device or no line selected |
125 | 136 | $invoice->deleteline($idline); |
126 | 137 | $invoice->fetch($placeid); |
127 | - } |
|
128 | - else |
|
138 | + } else |
|
129 | 139 | if ($placeid > 0) { //If exist invoice, but no line selected, proced to delete last line |
130 | 140 | $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "facturedet where fk_facture='$placeid' order by rowid DESC"; |
131 | 141 | $resql = $db->query($sql); |
@@ -398,15 +408,20 @@ discard block |
||
398 | 408 | |
399 | 409 | print '<p style="font-size:120%;" align="right"><b>'.$langs->trans('TotalTTC'); |
400 | 410 | |
401 | -if($conf->global->TAKEPOS_BAR_RESTAURANT) print " ".$langs->trans('Place')." ".$place; |
|
411 | +if($conf->global->TAKEPOS_BAR_RESTAURANT) { |
|
412 | + print " ".$langs->trans('Place')." ".$place; |
|
413 | +} |
|
402 | 414 | |
403 | 415 | print ': '.price($invoice->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).' </b></p>'; |
404 | 416 | |
405 | 417 | if ($invoice->socid != $conf->global->CASHDESK_ID_THIRDPARTY) |
406 | 418 | { |
407 | 419 | $soc = new Societe($db); |
408 | - if ($invoice->socid > 0) $soc->fetch($invoice->socid); |
|
409 | - else $soc->fetch($conf->global->CASHDESK_ID_THIRDPARTY); |
|
420 | + if ($invoice->socid > 0) { |
|
421 | + $soc->fetch($invoice->socid); |
|
422 | + } else { |
|
423 | + $soc->fetch($conf->global->CASHDESK_ID_THIRDPARTY); |
|
424 | + } |
|
410 | 425 | print '<p style="font-size:120%;" align="right">'; |
411 | 426 | print $langs->trans("Customer").': '.$soc->name; |
412 | 427 | print '</p>'; |
@@ -414,9 +429,12 @@ discard block |
||
414 | 429 | if ($action=="valid") |
415 | 430 | { |
416 | 431 | print '<p style="font-size:120%;" align="center"><b>'.$invoice->ref." ".$langs->trans('BillShortStatusValidated').'</b></p>'; |
417 | - if ($conf->global->TAKEPOSCONNECTOR) print '<center><button type="button" onclick="TakeposPrinting('.$placeid.');">'.$langs->trans('PrintTicket').'</button><center>'; |
|
418 | - else print '<center><button type="button" onclick="Print('.$placeid.');">'.$langs->trans('PrintTicket').'</button><center>'; |
|
419 | -} |
|
432 | + if ($conf->global->TAKEPOSCONNECTOR) { |
|
433 | + print '<center><button type="button" onclick="TakeposPrinting('.$placeid.');">'.$langs->trans('PrintTicket').'</button><center>'; |
|
434 | + } else { |
|
435 | + print '<center><button type="button" onclick="Print('.$placeid.');">'.$langs->trans('PrintTicket').'</button><center>'; |
|
436 | + } |
|
437 | + } |
|
420 | 438 | |
421 | 439 | if ($action == "search") |
422 | 440 | { |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | require DOL_BASE_PATH . '/main.inc.php'; |
32 | 32 | |
33 | 33 | |
34 | - // Load $user and permissions |
|
34 | + // Load $user and permissions |
|
35 | 35 | |
36 | 36 | require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; |
37 | 37 | |
@@ -69,47 +69,47 @@ discard block |
||
69 | 69 | |
70 | 70 | if ($action == 'valid' && $user->rights->facture->creer) |
71 | 71 | { |
72 | - if ($pay=="cash") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CASH; |
|
73 | - else if ($pay=="card") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CB; |
|
74 | - else if ($pay=="cheque") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; |
|
75 | - $now=dol_now(); |
|
76 | - $invoice = new Facture($db); |
|
77 | - $invoice->fetch($placeid); |
|
78 | - if (! empty($conf->stock->enabled) and $conf->global->CASHDESK_NO_DECREASE_STOCK!="1") $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE); |
|
79 | - else $invoice->validate($user); |
|
80 | - // Add the payment |
|
81 | - $payment=new Paiement($db); |
|
82 | - $payment->datepaye=$now; |
|
83 | - $payment->bank_account=$bankaccount; |
|
84 | - $payment->amounts[$invoice->id]=$invoice->total_ttc; |
|
72 | + if ($pay=="cash") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CASH; |
|
73 | + else if ($pay=="card") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CB; |
|
74 | + else if ($pay=="cheque") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; |
|
75 | + $now=dol_now(); |
|
76 | + $invoice = new Facture($db); |
|
77 | + $invoice->fetch($placeid); |
|
78 | + if (! empty($conf->stock->enabled) and $conf->global->CASHDESK_NO_DECREASE_STOCK!="1") $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE); |
|
79 | + else $invoice->validate($user); |
|
80 | + // Add the payment |
|
81 | + $payment=new Paiement($db); |
|
82 | + $payment->datepaye=$now; |
|
83 | + $payment->bank_account=$bankaccount; |
|
84 | + $payment->amounts[$invoice->id]=$invoice->total_ttc; |
|
85 | 85 | |
86 | - if ($pay=="cash") $payment->paiementid=4; |
|
87 | - else if ($pay=="card") $payment->paiementid=6; |
|
88 | - else if ($pay=="cheque") $payment->paiementid=7; |
|
89 | - $payment->num_paiement=$invoice->ref; |
|
86 | + if ($pay=="cash") $payment->paiementid=4; |
|
87 | + else if ($pay=="card") $payment->paiementid=6; |
|
88 | + else if ($pay=="cheque") $payment->paiementid=7; |
|
89 | + $payment->num_paiement=$invoice->ref; |
|
90 | 90 | |
91 | - $payment->create($user); |
|
92 | - $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); |
|
91 | + $payment->create($user); |
|
92 | + $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); |
|
93 | 93 | |
94 | - $invoice->set_paid($user); |
|
94 | + $invoice->set_paid($user); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | if (($action=="addline" || $action=="freezone") && $placeid==0) |
98 | 98 | { |
99 | - // $place is id of POS, $placeid is id of invoice |
|
100 | - if ($placeid==0) |
|
101 | - { |
|
102 | - $invoice = new Facture($db); |
|
103 | - $invoice->socid=$conf->global->CASHDESK_ID_THIRDPARTY; |
|
104 | - $invoice->date=dol_now(); |
|
105 | - $invoice->ref="(PROV-POS)"; |
|
106 | - $invoice->module_source = 'takepos'; |
|
107 | - $invoice->pos_source = (string) (empty($place)?'0':$place); |
|
108 | - |
|
109 | - $placeid=$invoice->create($user); |
|
110 | - $sql="UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS-".$place.")' where rowid=".$placeid; |
|
111 | - $db->query($sql); |
|
112 | - } |
|
99 | + // $place is id of POS, $placeid is id of invoice |
|
100 | + if ($placeid==0) |
|
101 | + { |
|
102 | + $invoice = new Facture($db); |
|
103 | + $invoice->socid=$conf->global->CASHDESK_ID_THIRDPARTY; |
|
104 | + $invoice->date=dol_now(); |
|
105 | + $invoice->ref="(PROV-POS)"; |
|
106 | + $invoice->module_source = 'takepos'; |
|
107 | + $invoice->pos_source = (string) (empty($place)?'0':$place); |
|
108 | + |
|
109 | + $placeid=$invoice->create($user); |
|
110 | + $sql="UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS-".$place.")' where rowid=".$placeid; |
|
111 | + $db->query($sql); |
|
112 | + } |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | if ($action == "addline") { |
@@ -417,9 +417,9 @@ discard block |
||
417 | 417 | } |
418 | 418 | if ($action=="valid") |
419 | 419 | { |
420 | - print '<p style="font-size:120%;" align="center"><b>'.$invoice->ref." ".$langs->trans('BillShortStatusValidated').'</b></p>'; |
|
421 | - if ($conf->global->TAKEPOSCONNECTOR) print '<center><button type="button" onclick="TakeposPrinting('.$placeid.');">'.$langs->trans('PrintTicket').'</button><center>'; |
|
422 | - else print '<center><button type="button" onclick="Print('.$placeid.');">'.$langs->trans('PrintTicket').'</button><center>'; |
|
420 | + print '<p style="font-size:120%;" align="center"><b>'.$invoice->ref." ".$langs->trans('BillShortStatusValidated').'</b></p>'; |
|
421 | + if ($conf->global->TAKEPOSCONNECTOR) print '<center><button type="button" onclick="TakeposPrinting('.$placeid.');">'.$langs->trans('PrintTicket').'</button><center>'; |
|
422 | + else print '<center><button type="button" onclick="Print('.$placeid.');">'.$langs->trans('PrintTicket').'</button><center>'; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | if ($action == "search") |
@@ -20,22 +20,22 @@ discard block |
||
20 | 20 | // if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language |
21 | 21 | // if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
22 | 22 | // if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
23 | -if (!defined('NOCSRFCHECK')) { define('NOCSRFCHECK', '1'); } |
|
23 | +if (!defined('NOCSRFCHECK')) { define('NOCSRFCHECK', '1'); } |
|
24 | 24 | if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } |
25 | -if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); } |
|
26 | -if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', '1'); } |
|
27 | -if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } |
|
25 | +if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); } |
|
26 | +if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', '1'); } |
|
27 | +if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } |
|
28 | 28 | |
29 | 29 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
30 | 30 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
31 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
31 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
32 | 32 | |
33 | 33 | |
34 | 34 | // Load $user and permissions |
35 | 35 | |
36 | -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; |
|
36 | +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
37 | 37 | |
38 | -require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; |
|
38 | +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; |
|
39 | 39 | |
40 | 40 | $langs->loadLangs( |
41 | 41 | array( |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $idline = GETPOST('idline'); |
52 | 52 | $desc = GETPOST('desc', 'alpha'); |
53 | 53 | $pay = GETPOST('pay'); |
54 | -$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS-".$place.")'"; |
|
54 | +$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS-".$place.")'"; |
|
55 | 55 | $resql = $db->query($sql); |
56 | 56 | $row = $db->fetch_array($resql); |
57 | 57 | $placeid = $row[0]; |
@@ -69,24 +69,24 @@ discard block |
||
69 | 69 | |
70 | 70 | if ($action == 'valid' && $user->rights->facture->creer) |
71 | 71 | { |
72 | - if ($pay=="cash") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CASH; |
|
73 | - else if ($pay=="card") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CB; |
|
74 | - else if ($pay=="cheque") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; |
|
75 | - $now=dol_now(); |
|
72 | + if ($pay == "cash") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CASH; |
|
73 | + else if ($pay == "card") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CB; |
|
74 | + else if ($pay == "cheque") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; |
|
75 | + $now = dol_now(); |
|
76 | 76 | $invoice = new Facture($db); |
77 | 77 | $invoice->fetch($placeid); |
78 | - if (! empty($conf->stock->enabled) and $conf->global->CASHDESK_NO_DECREASE_STOCK!="1") $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE); |
|
78 | + if (!empty($conf->stock->enabled) and $conf->global->CASHDESK_NO_DECREASE_STOCK != "1") $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE); |
|
79 | 79 | else $invoice->validate($user); |
80 | 80 | // Add the payment |
81 | - $payment=new Paiement($db); |
|
82 | - $payment->datepaye=$now; |
|
83 | - $payment->bank_account=$bankaccount; |
|
84 | - $payment->amounts[$invoice->id]=$invoice->total_ttc; |
|
81 | + $payment = new Paiement($db); |
|
82 | + $payment->datepaye = $now; |
|
83 | + $payment->bank_account = $bankaccount; |
|
84 | + $payment->amounts[$invoice->id] = $invoice->total_ttc; |
|
85 | 85 | |
86 | - if ($pay=="cash") $payment->paiementid=4; |
|
87 | - else if ($pay=="card") $payment->paiementid=6; |
|
88 | - else if ($pay=="cheque") $payment->paiementid=7; |
|
89 | - $payment->num_paiement=$invoice->ref; |
|
86 | + if ($pay == "cash") $payment->paiementid = 4; |
|
87 | + else if ($pay == "card") $payment->paiementid = 6; |
|
88 | + else if ($pay == "cheque") $payment->paiementid = 7; |
|
89 | + $payment->num_paiement = $invoice->ref; |
|
90 | 90 | |
91 | 91 | $payment->create($user); |
92 | 92 | $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); |
@@ -94,20 +94,20 @@ discard block |
||
94 | 94 | $invoice->set_paid($user); |
95 | 95 | } |
96 | 96 | |
97 | -if (($action=="addline" || $action=="freezone") && $placeid==0) |
|
97 | +if (($action == "addline" || $action == "freezone") && $placeid == 0) |
|
98 | 98 | { |
99 | 99 | // $place is id of POS, $placeid is id of invoice |
100 | - if ($placeid==0) |
|
100 | + if ($placeid == 0) |
|
101 | 101 | { |
102 | 102 | $invoice = new Facture($db); |
103 | - $invoice->socid=$conf->global->CASHDESK_ID_THIRDPARTY; |
|
104 | - $invoice->date=dol_now(); |
|
105 | - $invoice->ref="(PROV-POS)"; |
|
103 | + $invoice->socid = $conf->global->CASHDESK_ID_THIRDPARTY; |
|
104 | + $invoice->date = dol_now(); |
|
105 | + $invoice->ref = "(PROV-POS)"; |
|
106 | 106 | $invoice->module_source = 'takepos'; |
107 | - $invoice->pos_source = (string) (empty($place)?'0':$place); |
|
107 | + $invoice->pos_source = (string) (empty($place) ? '0' : $place); |
|
108 | 108 | |
109 | - $placeid=$invoice->create($user); |
|
110 | - $sql="UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS-".$place.")' where rowid=".$placeid; |
|
109 | + $placeid = $invoice->create($user); |
|
110 | + $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS-".$place.")' where rowid=".$placeid; |
|
111 | 111 | $db->query($sql); |
112 | 112 | } |
113 | 113 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | } |
132 | 132 | else |
133 | 133 | if ($placeid > 0) { //If exist invoice, but no line selected, proced to delete last line |
134 | - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "facturedet where fk_facture='$placeid' order by rowid DESC"; |
|
134 | + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture='$placeid' order by rowid DESC"; |
|
135 | 135 | $resql = $db->query($sql); |
136 | 136 | $row = $db->fetch_array($resql); |
137 | 137 | $deletelineid = $row[0]; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | if ($action == "updateqty") { |
144 | - foreach($invoice->lines as $line) |
|
144 | + foreach ($invoice->lines as $line) |
|
145 | 145 | { |
146 | 146 | if ($line->id == $idline) { $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); |
147 | 147 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | if ($action == "updateprice") { |
154 | - foreach($invoice->lines as $line) |
|
154 | + foreach ($invoice->lines as $line) |
|
155 | 155 | { |
156 | 156 | if ($line->id == $idline) { $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); |
157 | 157 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | if ($action == "updatereduction") { |
164 | - foreach($invoice->lines as $line) |
|
164 | + foreach ($invoice->lines as $line) |
|
165 | 165 | { |
166 | 166 | if ($line->id == $idline) { $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); |
167 | 167 | } |
@@ -171,15 +171,15 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | if ($action == "order" and $placeid != 0) { |
174 | - include_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; |
|
174 | + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
|
175 | 175 | |
176 | - $headerorder = '<html><br><b>' . $langs->trans('Place') . ' ' . $place . '<br><table width="65%"><thead><tr><th align="left">' . $langs->trans("Label") . '</th><th align="right">' . $langs->trans("Qty") . '</th></tr></thead><tbody>'; |
|
177 | - $footerorder = '</tbody></table>' . dol_print_date(dol_now(), 'dayhour') . '<br></html>'; |
|
176 | + $headerorder = '<html><br><b>'.$langs->trans('Place').' '.$place.'<br><table width="65%"><thead><tr><th align="left">'.$langs->trans("Label").'</th><th align="right">'.$langs->trans("Qty").'</th></tr></thead><tbody>'; |
|
177 | + $footerorder = '</tbody></table>'.dol_print_date(dol_now(), 'dayhour').'<br></html>'; |
|
178 | 178 | $order_receipt_printer1 = ""; |
179 | 179 | $order_receipt_printer2 = ""; |
180 | 180 | $catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1); |
181 | 181 | $catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2); |
182 | - foreach($invoice->lines as $line) |
|
182 | + foreach ($invoice->lines as $line) |
|
183 | 183 | { |
184 | 184 | if ($line->special_code == "3") { continue; |
185 | 185 | } |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | $result = array_intersect($catsprinter1, $existing); |
189 | 189 | $count = count($result); |
190 | 190 | if ($count > 0) { |
191 | - $sql = "UPDATE " . MAIN_DB_PREFIX . "facturedet set special_code='3' where rowid=$line->rowid"; |
|
191 | + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=$line->rowid"; |
|
192 | 192 | $db->query($sql); |
193 | - $order_receipt_printer1.= '<tr>' . $line->product_label . '<td align="right">' . $line->qty . '</td></tr>'; |
|
193 | + $order_receipt_printer1 .= '<tr>'.$line->product_label.'<td align="right">'.$line->qty.'</td></tr>'; |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | - foreach($invoice->lines as $line) |
|
197 | + foreach ($invoice->lines as $line) |
|
198 | 198 | { |
199 | 199 | if ($line->special_code == "3") { continue; |
200 | 200 | } |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | $result = array_intersect($catsprinter2, $existing); |
204 | 204 | $count = count($result); |
205 | 205 | if ($count > 0) { |
206 | - $sql = "UPDATE " . MAIN_DB_PREFIX . "facturedet set special_code='3' where rowid=$line->rowid"; |
|
206 | + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=$line->rowid"; |
|
207 | 207 | $db->query($sql); |
208 | - $order_receipt_printer2.= '<tr>' . $line->product_label . '<td align="right">' . $line->qty . '</td></tr>'; |
|
208 | + $order_receipt_printer2 .= '<tr>'.$line->product_label.'<td align="right">'.$line->qty.'</td></tr>'; |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | // temporary ticket feature |
216 | 216 | |
217 | 217 | if ($action == "temp" and $placeid != 0) { |
218 | - include_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; |
|
218 | + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
|
219 | 219 | |
220 | 220 | // issues with special characters with jPosBoxprinting ->javascript, stringCleanCharts() temporarily fix them until to find a more elegant solution. |
221 | 221 | |
@@ -250,13 +250,13 @@ discard block |
||
250 | 250 | $mysoczip = stringCleanCharts($mysoc->zip); |
251 | 251 | $mysocphone = stringCleanCharts($mysoc->phone); |
252 | 252 | $mysocurl = stringCleanCharts($mysoc->url); |
253 | - $header_soc = '<html><center><font size="4"><b>' . $mysocname . '</b><br>' . $mysocaddress . '<br>' . $mysoczip . ' ' . $mysoctown . '</font></center><br>' . $langs->trans("Phone") . ': ' . $mysocphone . '<br>' . $mysocurl; |
|
254 | - $header_ticket = '<br><br>' . $langs->trans("Temporary ticket") . '<br>' . $langs->trans("date") . ':<br>' . dol_print_date(dol_now(), 'dayhour') . '<br>' . $langs->trans('Place') . ' ' . $place . '<br><br><br><div width="100%" style="border-top-style: double;"></div>'; |
|
255 | - $body_ticket = '<table width="100%"><thead><tr><th align="left">' . $langs->trans("Label") . '</th><th align="left">' . $langs->trans("Qty") . '</th><th align="left">' . $langs->trans("Price") . '</th><th align="left">' . $langs->trans("TotalTTC") . '</th></tr></thead>'; |
|
256 | - $footer_ticket = '<br><br>' . $langs->trans("Cashier") . ': ' . $user->firstname . '<br><center>' . $langs->trans("Thanks for your coming !") . '</center></html>'; |
|
253 | + $header_soc = '<html><center><font size="4"><b>'.$mysocname.'</b><br>'.$mysocaddress.'<br>'.$mysoczip.' '.$mysoctown.'</font></center><br>'.$langs->trans("Phone").': '.$mysocphone.'<br>'.$mysocurl; |
|
254 | + $header_ticket = '<br><br>'.$langs->trans("Temporary ticket").'<br>'.$langs->trans("date").':<br>'.dol_print_date(dol_now(), 'dayhour').'<br>'.$langs->trans('Place').' '.$place.'<br><br><br><div width="100%" style="border-top-style: double;"></div>'; |
|
255 | + $body_ticket = '<table width="100%"><thead><tr><th align="left">'.$langs->trans("Label").'</th><th align="left">'.$langs->trans("Qty").'</th><th align="left">'.$langs->trans("Price").'</th><th align="left">'.$langs->trans("TotalTTC").'</th></tr></thead>'; |
|
256 | + $footer_ticket = '<br><br>'.$langs->trans("Cashier").': '.$user->firstname.'<br><center>'.$langs->trans("Thanks for your coming !").'</center></html>'; |
|
257 | 257 | $ticket_printer1 = ""; |
258 | 258 | $catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1); |
259 | - foreach($invoice->lines as $line) |
|
259 | + foreach ($invoice->lines as $line) |
|
260 | 260 | { |
261 | 261 | if ($line->special_code == "3") { continue; |
262 | 262 | } |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | $result = array_intersect($catsprinter1, $existing); |
266 | 266 | $count = count($result); |
267 | 267 | if ($count > 0) { |
268 | - $sql = "UPDATE " . MAIN_DB_PREFIX . "facturedet set special_code='3' where rowid=$line->rowid"; |
|
268 | + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=$line->rowid"; |
|
269 | 269 | $db->query($sql); |
270 | - $ticket_printer1.= '<tbody><tr><td align="left">' . $line->product_label . '</td><td align="left">' . $line->qty . '</td><td align="left">' . $line->total_ttc / $line->qty . '</td><td align="left">' . $line->total_ttc . '</td></tr></tbody>'; |
|
271 | - $ticket_total = '</table><div width="100%" style="border-top-style: double;"></div><table align="right"><tr><th>' . $langs->trans("TotalHT") . ': ' . price($invoice->total_ht, 1, '', 1, -1, -1, $conf->currency) . '</th></tr><tr><th>' . $langs->trans("TotalVAT") . ': ' . price($invoice->total_tva, 1, '', 1, -1, -1, $conf->currency) . '</th></tr><tr><th>' . $langs->trans("TotalTTC") . ': ' . price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency) . '</th></tr></tbody></table>'; |
|
270 | + $ticket_printer1 .= '<tbody><tr><td align="left">'.$line->product_label.'</td><td align="left">'.$line->qty.'</td><td align="left">'.$line->total_ttc / $line->qty.'</td><td align="left">'.$line->total_ttc.'</td></tr></tbody>'; |
|
271 | + $ticket_total = '</table><div width="100%" style="border-top-style: double;"></div><table align="right"><tr><th>'.$langs->trans("TotalHT").': '.price($invoice->total_ht, 1, '', 1, -1, -1, $conf->currency).'</th></tr><tr><th>'.$langs->trans("TotalVAT").': '.price($invoice->total_tva, 1, '', 1, -1, -1, $conf->currency).'</th></tr><tr><th>'.$langs->trans("TotalTTC").': '.price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency).'</th></tr></tbody></table>'; |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | type: "POST", |
304 | 304 | url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print', |
305 | 305 | data: '<?php |
306 | - print $headerorder . $order_receipt_printer1 . $footerorder; ?>' |
|
306 | + print $headerorder.$order_receipt_printer1.$footerorder; ?>' |
|
307 | 307 | }); |
308 | 308 | <?php |
309 | 309 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | type: "POST", |
315 | 315 | url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print2', |
316 | 316 | data: '<?php |
317 | - print $headerorder . $order_receipt_printer2 . $footerorder; ?>' |
|
317 | + print $headerorder.$order_receipt_printer2.$footerorder; ?>' |
|
318 | 318 | }); |
319 | 319 | <?php |
320 | 320 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | type: "POST", |
345 | 345 | url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print', |
346 | 346 | data: '<?php |
347 | - print $header_soc . $header_ticket . $body_ticket . $ticket_printer1 . $ticket_total . $footer_ticket; ?>' |
|
347 | + print $header_soc.$header_ticket.$body_ticket.$ticket_printer1.$ticket_total.$footer_ticket; ?>' |
|
348 | 348 | }); |
349 | 349 | <?php |
350 | 350 | } |
@@ -379,21 +379,21 @@ discard block |
||
379 | 379 | print '<div class="div-table-responsive-no-min invoice">'; |
380 | 380 | print '<table id="tablelines" class="noborder noshadow" width="100%">'; |
381 | 381 | print '<tr class="liste_titre nodrag nodrop">'; |
382 | -print '<td class="linecoldescription">' . $langs->trans('Description') . '</td>'; |
|
383 | -print '<td class="linecolqty" align="right">' . $langs->trans('Qty') . '</td>'; |
|
384 | -print '<td class="linecolht" align="right">' . $langs->trans('TotalHTShort') . '</td>'; |
|
382 | +print '<td class="linecoldescription">'.$langs->trans('Description').'</td>'; |
|
383 | +print '<td class="linecolqty" align="right">'.$langs->trans('Qty').'</td>'; |
|
384 | +print '<td class="linecolht" align="right">'.$langs->trans('TotalHTShort').'</td>'; |
|
385 | 385 | print "</tr>\n"; |
386 | 386 | |
387 | 387 | if ($placeid > 0) { |
388 | - foreach($invoice->lines as $line) |
|
388 | + foreach ($invoice->lines as $line) |
|
389 | 389 | { |
390 | 390 | print '<tr class="drag drop oddeven'; |
391 | 391 | if ($line->special_code == "3") { print ' order'; |
392 | 392 | } |
393 | - print '" id="' . $line->rowid . '">'; |
|
394 | - print '<td>' . $line->product_label . $line->desc . '</td>'; |
|
395 | - print '<td align="right">' . $line->qty . '</td>'; |
|
396 | - print '<td align="right">' . price($line->total_ttc) . '</td>'; |
|
393 | + print '" id="'.$line->rowid.'">'; |
|
394 | + print '<td>'.$line->product_label.$line->desc.'</td>'; |
|
395 | + print '<td align="right">'.$line->qty.'</td>'; |
|
396 | + print '<td align="right">'.price($line->total_ttc).'</td>'; |
|
397 | 397 | print '</tr>'; |
398 | 398 | } |
399 | 399 | } |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | |
403 | 403 | print '<p style="font-size:120%;" align="right"><b>'.$langs->trans('TotalTTC'); |
404 | 404 | |
405 | -if($conf->global->TAKEPOS_BAR_RESTAURANT) print " ".$langs->trans('Place')." ".$place; |
|
405 | +if ($conf->global->TAKEPOS_BAR_RESTAURANT) print " ".$langs->trans('Place')." ".$place; |
|
406 | 406 | |
407 | 407 | print ': '.price($invoice->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).' </b></p>'; |
408 | 408 | |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | print $langs->trans("Customer").': '.$soc->name; |
416 | 416 | print '</p>'; |
417 | 417 | } |
418 | -if ($action=="valid") |
|
418 | +if ($action == "valid") |
|
419 | 419 | { |
420 | 420 | print '<p style="font-size:120%;" align="center"><b>'.$invoice->ref." ".$langs->trans('BillShortStatusValidated').'</b></p>'; |
421 | 421 | if ($conf->global->TAKEPOSCONNECTOR) print '<center><button type="button" onclick="TakeposPrinting('.$placeid.');">'.$langs->trans('PrintTicket').'</button><center>'; |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | if ($action == "search") |
426 | 426 | { |
427 | 427 | print '<center> |
428 | - <input type="text" id="search" name="search" onkeyup="Search2();" name="search" style="width:80%;font-size: 150%;" placeholder=' . $langs->trans('Search') . ' |
|
428 | + <input type="text" id="search" name="search" onkeyup="Search2();" name="search" style="width:80%;font-size: 150%;" placeholder=' . $langs->trans('Search').' |
|
429 | 429 | </center>'; |
430 | 430 | } |
431 | 431 |