@@ -54,7 +54,9 @@ discard block |
||
54 | 54 | dol_include_once('/subtotal/class/subtotal.class.php'); |
55 | 55 | $TTitle = TSubtotal::getAllTitleFromDocument($object); |
56 | 56 | $html = ''; |
57 | - if ($showLabel) $html.= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>'; |
|
57 | + if ($showLabel) { |
|
58 | + $html.= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>'; |
|
59 | + } |
|
58 | 60 | $html.= '<select onChange="$(\'select[name=under_title]\').val(this.value);" name="under_title" class="under_title minwidth200"><option value="-1"></option>'; |
59 | 61 | |
60 | 62 | $nbsp = ' '; |
@@ -95,7 +97,9 @@ discard block |
||
95 | 97 | $TFreeText = getTFreeText(); |
96 | 98 | $html = '<label for="free_text">'.$langs->trans('subtotalLabelForFreeText').'</label>'; |
97 | 99 | $html.= '<select onChange="getTFreeText($(this));" name="free_text" class="minwidth200">'; |
98 | - if ($withEmpty) $html.= '<option value=""></option>'; |
|
100 | + if ($withEmpty) { |
|
101 | + $html.= '<option value=""></option>'; |
|
102 | + } |
|
99 | 103 | |
100 | 104 | $TFreeTextContents = array(); |
101 | 105 | foreach ($TFreeText as $id => $tab) |
@@ -136,8 +140,13 @@ discard block |
||
136 | 140 | $level = GETPOST('subtotal_level', 'int'); |
137 | 141 | if (!empty($level)) |
138 | 142 | { |
139 | - if ($line->qty > 90) $line->qty = 100 - $level; // Si on edit une ligne sous-total |
|
140 | - else $line->qty = $level; |
|
143 | + if ($line->qty > 90) { |
|
144 | + $line->qty = 100 - $level; |
|
145 | + } |
|
146 | + // Si on edit une ligne sous-total |
|
147 | + else { |
|
148 | + $line->qty = $level; |
|
149 | + } |
|
141 | 150 | } |
142 | 151 | $line->array_options['options_show_total_ht'] = $showTotalHT; |
143 | 152 | $line->array_options['options_show_reduc'] = $showReduc; |
@@ -166,13 +175,18 @@ discard block |
||
166 | 175 | { |
167 | 176 | $subtotal_tva_tx = $subtotal_tva_tx_init; // ré-init car la variable peut évoluer |
168 | 177 | |
169 | - if (!empty($showBlockExtrafields)) $line->array_options = $array_options; |
|
170 | - if ($subtotal_tva_tx == '') $subtotal_tva_tx = $line->tva_tx; |
|
178 | + if (!empty($showBlockExtrafields)) { |
|
179 | + $line->array_options = $array_options; |
|
180 | + } |
|
181 | + if ($subtotal_tva_tx == '') { |
|
182 | + $subtotal_tva_tx = $line->tva_tx; |
|
183 | + } |
|
171 | 184 | if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) |
172 | 185 | { |
173 | 186 | $subtotal_progress = $subtotal_progress_init; |
174 | - if ($subtotal_progress == '') $subtotal_progress = $line->situation_percent; |
|
175 | - else |
|
187 | + if ($subtotal_progress == '') { |
|
188 | + $subtotal_progress = $line->situation_percent; |
|
189 | + } else |
|
176 | 190 | { |
177 | 191 | $prev_percent = $line->get_prev_progress($object->id); |
178 | 192 | if ($subtotal_progress < $prev_percent) |
@@ -185,14 +199,21 @@ discard block |
||
185 | 199 | |
186 | 200 | $res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $subtotal_tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $subtotal_progress, $line->fk_unit); |
187 | 201 | |
188 | - if ($res > 0) $success_updated_line++; |
|
189 | - else $error_updated_line++; |
|
202 | + if ($res > 0) { |
|
203 | + $success_updated_line++; |
|
204 | + } else { |
|
205 | + $error_updated_line++; |
|
206 | + } |
|
190 | 207 | } |
191 | 208 | } |
192 | 209 | |
193 | - if ($nb_progress_not_updated > 0) setEventMessage($langs->trans('subtotal_nb_progress_not_updated', $nb_progress_not_updated), 'warnings'); |
|
210 | + if ($nb_progress_not_updated > 0) { |
|
211 | + setEventMessage($langs->trans('subtotal_nb_progress_not_updated', $nb_progress_not_updated), 'warnings'); |
|
212 | + } |
|
194 | 213 | |
195 | - if ($success_updated_line > 0) setEventMessage($langs->trans('subtotal_success_updated_line', $success_updated_line)); |
|
214 | + if ($success_updated_line > 0) { |
|
215 | + setEventMessage($langs->trans('subtotal_success_updated_line', $success_updated_line)); |
|
216 | + } |
|
196 | 217 | if ($error_updated_line > 0) |
197 | 218 | { |
198 | 219 | setEventMessage($langs->trans('subtotal_error_updated_line', $error_updated_line), 'errors'); |
@@ -233,15 +254,16 @@ discard block |
||
233 | 254 | global $db,$langs,$tmp_object_nc; |
234 | 255 | |
235 | 256 | $error = 0; |
236 | - if (empty($element)) $error++; |
|
257 | + if (empty($element)) { |
|
258 | + $error++; |
|
259 | + } |
|
237 | 260 | |
238 | 261 | if (!$error) |
239 | 262 | { |
240 | 263 | if (!empty($tmp_object_nc) && $tmp_object_nc->element == $element && $tmp_object_nc->id == $elementid) |
241 | 264 | { |
242 | 265 | $object = $tmp_object_nc; |
243 | - } |
|
244 | - else |
|
266 | + } else |
|
245 | 267 | { |
246 | 268 | $classname = ucfirst($element); |
247 | 269 | |
@@ -261,8 +283,11 @@ discard block |
||
261 | 283 | |
262 | 284 | $object = new $classname($db); // Propal | Commande | Facture |
263 | 285 | $res = $object->fetch($elementid); |
264 | - if ($res < 0) $error++; |
|
265 | - else $tmp_object_nc = $object; |
|
286 | + if ($res < 0) { |
|
287 | + $error++; |
|
288 | + } else { |
|
289 | + $tmp_object_nc = $object; |
|
290 | + } |
|
266 | 291 | } |
267 | 292 | } |
268 | 293 | |
@@ -290,21 +315,21 @@ discard block |
||
290 | 315 | $res = doUpdate($object, $line_block, $subtotal_nc, $notrigger); |
291 | 316 | } |
292 | 317 | } |
293 | - } |
|
294 | - else |
|
318 | + } else |
|
295 | 319 | { |
296 | 320 | $res = doUpdate($object, $line, $subtotal_nc, $notrigger); |
297 | 321 | } |
298 | 322 | |
299 | 323 | $res = $object->update_price(1); |
300 | - if ($res <= 0) $error++; |
|
324 | + if ($res <= 0) { |
|
325 | + $error++; |
|
326 | + } |
|
301 | 327 | |
302 | 328 | if (!$error) |
303 | 329 | { |
304 | 330 | setEventMessage($langs->trans('subtotal_update_nc_success')); |
305 | 331 | $db->commit(); |
306 | - } |
|
307 | - else |
|
332 | + } else |
|
308 | 333 | { |
309 | 334 | setEventMessage($langs->trans('subtotal_update_nc_error'), 'errors'); |
310 | 335 | $db->rollback(); |
@@ -317,7 +342,9 @@ discard block |
||
317 | 342 | { |
318 | 343 | global $user; |
319 | 344 | |
320 | - if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) return 1; |
|
345 | + if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) { |
|
346 | + return 1; |
|
347 | + } |
|
321 | 348 | // Update extrafield et total |
322 | 349 | if(! empty($subtotal_nc)) { |
323 | 350 | $line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = |
@@ -325,12 +352,17 @@ discard block |
||
325 | 352 | |
326 | 353 | $line->array_options['options_subtotal_nc'] = 1; |
327 | 354 | |
328 | - if ($line->element == 'propaldet') $res = $line->update($notrigger); |
|
329 | - else $res = $line->update($user, $notrigger); |
|
330 | - } |
|
331 | - else { |
|
355 | + if ($line->element == 'propaldet') { |
|
356 | + $res = $line->update($notrigger); |
|
357 | + } else { |
|
358 | + $res = $line->update($user, $notrigger); |
|
359 | + } |
|
360 | + } else { |
|
332 | 361 | if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) { |
333 | - if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label |
|
362 | + if(empty($line->label)) { |
|
363 | + $line->label = $line->description; |
|
364 | + } |
|
365 | + // supplier lines don't have the field label |
|
334 | 366 | |
335 | 367 | require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); |
336 | 368 | $extrafields=new ExtraFields($object->db); |
@@ -338,7 +370,9 @@ discard block |
||
338 | 370 | $line->fetch_optionals($line->id,$extralabels); |
339 | 371 | } |
340 | 372 | $line->array_options['options_subtotal_nc'] = 0; |
341 | - if($object->element == 'order_supplier') $line->update($user); |
|
373 | + if($object->element == 'order_supplier') { |
|
374 | + $line->update($user); |
|
375 | + } |
|
342 | 376 | $res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $notrigger); |
343 | 377 | } |
344 | 378 |
@@ -13,18 +13,23 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * @var $object Facture |
15 | 15 | */ |
16 | - if($object->element=='facture') $res = $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number); |
|
16 | + if($object->element=='facture') { |
|
17 | + $res = $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number); |
|
18 | + } |
|
17 | 19 | /** |
18 | 20 | * @var $object Propal |
19 | 21 | */ |
20 | - else if($object->element=='propal') $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number); |
|
22 | + else if($object->element=='propal') { |
|
23 | + $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number); |
|
24 | + } |
|
21 | 25 | /** |
22 | 26 | * @var $object Commande |
23 | 27 | */ |
24 | - else if($object->element=='commande') $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number); |
|
28 | + else if($object->element=='commande') { |
|
29 | + $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number); |
|
30 | + } |
|
25 | 31 | |
26 | - } |
|
27 | - else { |
|
32 | + } else { |
|
28 | 33 | $desc = ''; |
29 | 34 | if ((float) DOL_VERSION < 6 || $qty==50) { |
30 | 35 | $desc = $label; |
@@ -34,29 +39,40 @@ discard block |
||
34 | 39 | /** |
35 | 40 | * @var $object Facture |
36 | 41 | */ |
37 | - if($object->element=='facture') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label); |
|
42 | + if($object->element=='facture') { |
|
43 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label); |
|
44 | + } |
|
38 | 45 | /** |
39 | 46 | * @var $object Facture fournisseur |
40 | 47 | */ |
41 | 48 | else if($object->element=='invoice_supplier') { |
42 | 49 | $object->special_code = TSubtotal::$module_number; |
43 | 50 | $rang = $object->line_max() + 1; |
44 | - if($qty==50) $res = $object->addline($desc,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
|
45 | - else $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
|
51 | + if($qty==50) { |
|
52 | + $res = $object->addline($desc,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
|
53 | + } else { |
|
54 | + $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
|
55 | + } |
|
46 | 56 | } |
47 | 57 | /** |
48 | 58 | * @var $object Propal |
49 | 59 | */ |
50 | - else if($object->element=='propal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
60 | + else if($object->element=='propal') { |
|
61 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
62 | + } |
|
51 | 63 | /** |
52 | 64 | * @var $object Propal Fournisseur |
53 | 65 | */ |
54 | - else if($object->element=='supplier_proposal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
66 | + else if($object->element=='supplier_proposal') { |
|
67 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
68 | + } |
|
55 | 69 | |
56 | 70 | /** |
57 | 71 | * @var $object Commande |
58 | 72 | */ |
59 | - else if($object->element=='commande') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label); |
|
73 | + else if($object->element=='commande') { |
|
74 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label); |
|
75 | + } |
|
60 | 76 | /** |
61 | 77 | * @var $object Commande fournisseur |
62 | 78 | */ |
@@ -67,7 +83,9 @@ discard block |
||
67 | 83 | /** |
68 | 84 | * @var $object Facturerec |
69 | 85 | */ |
70 | - else if($object->element=='facturerec') $res = $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); |
|
86 | + else if($object->element=='facturerec') { |
|
87 | + $res = $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); |
|
88 | + } |
|
71 | 89 | |
72 | 90 | } |
73 | 91 | |
@@ -89,8 +107,9 @@ discard block |
||
89 | 107 | // Define output language |
90 | 108 | $outputlangs = $langs; |
91 | 109 | $newlang = GETPOST('lang_id', 'alpha'); |
92 | - if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) |
|
93 | - $newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang; |
|
110 | + if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { |
|
111 | + $newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang; |
|
112 | + } |
|
94 | 113 | if (! empty($newlang)) { |
95 | 114 | $outputlangs = new Translate("", $conf); |
96 | 115 | $outputlangs->setDefaultLang($newlang); |
@@ -99,13 +118,18 @@ discard block |
||
99 | 118 | $ret = $object->fetch($object->id); // Reload to get new records |
100 | 119 | if ((float) DOL_VERSION <= 3.6) |
101 | 120 | { |
102 | - if ($object->element == 'propal') propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
103 | - elseif ($object->element == 'commande') commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
104 | - elseif ($object->element == 'facture') facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
105 | - } |
|
106 | - else |
|
121 | + if ($object->element == 'propal') { |
|
122 | + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
123 | + } elseif ($object->element == 'commande') { |
|
124 | + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
125 | + } elseif ($object->element == 'facture') { |
|
126 | + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
127 | + } |
|
128 | + } else |
|
107 | 129 | { |
108 | - if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
130 | + if ($object->element!= 'facturerec') { |
|
131 | + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
132 | + } |
|
109 | 133 | } |
110 | 134 | } |
111 | 135 | } |
@@ -119,7 +143,9 @@ discard block |
||
119 | 143 | */ |
120 | 144 | public static function updateRang(&$object, $rang_start, $move_to=1) |
121 | 145 | { |
122 | - if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
|
146 | + if (!class_exists('GenericObject')) { |
|
147 | + require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
|
148 | + } |
|
123 | 149 | |
124 | 150 | $row=new GenericObject($object->db); |
125 | 151 | $row->table_element_line = $object->table_element_line; |
@@ -128,7 +154,9 @@ discard block |
||
128 | 154 | |
129 | 155 | foreach ($object->lines as &$line) |
130 | 156 | { |
131 | - if ($line->rang < $rang_start) continue; |
|
157 | + if ($line->rang < $rang_start) { |
|
158 | + continue; |
|
159 | + } |
|
132 | 160 | |
133 | 161 | $row->updateRangOfLine($line->id, $line->rang+$move_to); |
134 | 162 | } |
@@ -151,21 +179,28 @@ discard block |
||
151 | 179 | foreach ($TTitle_reverse as $k => $title_line) |
152 | 180 | { |
153 | 181 | $title_niveau = self::getNiveau($title_line); |
154 | - if ($title_niveau < $level_new_title) break; |
|
182 | + if ($title_niveau < $level_new_title) { |
|
183 | + break; |
|
184 | + } |
|
155 | 185 | |
156 | 186 | $rang_to_add = self::titleHasTotalLine($object, $title_line, true, true); |
157 | 187 | |
158 | 188 | if (is_numeric($rang_to_add)) |
159 | 189 | { |
160 | - if ($rang_to_add != -1) self::updateRang($object, $rang_to_add); |
|
190 | + if ($rang_to_add != -1) { |
|
191 | + self::updateRang($object, $rang_to_add); |
|
192 | + } |
|
161 | 193 | |
162 | 194 | self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add); |
163 | 195 | |
164 | 196 | $object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas) |
165 | 197 | if ($rang_to_add != -1) |
166 | 198 | { |
167 | - if (method_exists($object, 'fetch_lines')) $object->fetch_lines(); |
|
168 | - else $object->fetch($object->id); |
|
199 | + if (method_exists($object, 'fetch_lines')) { |
|
200 | + $object->fetch_lines(); |
|
201 | + } else { |
|
202 | + $object->fetch($object->id); |
|
203 | + } |
|
169 | 204 | } |
170 | 205 | } |
171 | 206 | } |
@@ -195,7 +230,9 @@ discard block |
||
195 | 230 | |
196 | 231 | foreach ($TTitle as $k => $title_line) |
197 | 232 | { |
198 | - if (self::titleHasTotalLine($object, $title_line)) unset($TTitle[$k]); |
|
233 | + if (self::titleHasTotalLine($object, $title_line)) { |
|
234 | + unset($TTitle[$k]); |
|
235 | + } |
|
199 | 236 | } |
200 | 237 | |
201 | 238 | return $TTitle; |
@@ -212,23 +249,41 @@ discard block |
||
212 | 249 | */ |
213 | 250 | public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false) |
214 | 251 | { |
215 | - if (empty($object->lines) || !is_array($object->lines)) return false; |
|
252 | + if (empty($object->lines) || !is_array($object->lines)) { |
|
253 | + return false; |
|
254 | + } |
|
216 | 255 | |
217 | 256 | $title_niveau = self::getNiveau($title_line); |
218 | 257 | foreach ($object->lines as &$line) |
219 | 258 | { |
220 | - if ($line->rang <= $title_line->rang) continue; |
|
221 | - if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) return false; // Oups on croise un titre d'un niveau inférieur ou égale (exemple : je croise un titre niveau 2 alors que je suis sur un titre de niveau 3) pas lieu de continuer car un nouveau bloc commence |
|
222 | - if (!self::isSubtotal($line)) continue; |
|
259 | + if ($line->rang <= $title_line->rang) { |
|
260 | + continue; |
|
261 | + } |
|
262 | + if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) { |
|
263 | + return false; |
|
264 | + } |
|
265 | + // Oups on croise un titre d'un niveau inférieur ou égale (exemple : je croise un titre niveau 2 alors que je suis sur un titre de niveau 3) pas lieu de continuer car un nouveau bloc commence |
|
266 | + if (!self::isSubtotal($line)) { |
|
267 | + continue; |
|
268 | + } |
|
223 | 269 | |
224 | 270 | $subtotal_niveau = self::getNiveau($line); |
225 | 271 | |
226 | 272 | // Comparaison du niveau de la ligne de sous-total avec celui du titre |
227 | - if ($subtotal_niveau == $title_niveau) return true; // niveau égale => Ok mon titre a un sous-total |
|
228 | - elseif ($subtotal_niveau < $title_niveau) // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3) |
|
273 | + if ($subtotal_niveau == $title_niveau) { |
|
274 | + return true; |
|
275 | + } |
|
276 | + // niveau égale => Ok mon titre a un sous-total |
|
277 | + elseif ($subtotal_niveau < $title_niveau) { |
|
278 | + // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3) |
|
229 | 279 | { |
230 | - if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; // mode strict niveau pas égale donc faux |
|
231 | - else return true; // mode libre => OK je considère que mon titre à un sous-total |
|
280 | + if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; |
|
281 | + } |
|
282 | + // mode strict niveau pas égale donc faux |
|
283 | + else { |
|
284 | + return true; |
|
285 | + } |
|
286 | + // mode libre => OK je considère que mon titre à un sous-total |
|
232 | 287 | } |
233 | 288 | } |
234 | 289 | |
@@ -276,16 +331,19 @@ discard block |
||
276 | 331 | |
277 | 332 | foreach ($object->lines as &$l) |
278 | 333 | { |
279 | - if ($l->rang <= $line->rang) continue; |
|
280 | - elseif (self::isSubtotal($l) && self::getNiveau($l) == $line->qty) break; |
|
281 | - elseif (self::isModSubtotalLine($l)) continue; |
|
334 | + if ($l->rang <= $line->rang) { |
|
335 | + continue; |
|
336 | + } elseif (self::isSubtotal($l) && self::getNiveau($l) == $line->qty) { |
|
337 | + break; |
|
338 | + } elseif (self::isModSubtotalLine($l)) { |
|
339 | + continue; |
|
340 | + } |
|
282 | 341 | |
283 | 342 | if (!empty($l->array_options['options_subtotal_nc'])) |
284 | 343 | { |
285 | 344 | $tabprice = calcul_price_total($l->qty, $l->subprice, $l->remise_percent, $l->tva_tx, $l->localtax1_tx, $l->localtax2_tx, 0, 'HT', $l->info_bits, $l->product_type); |
286 | 345 | $TTot['total_options'] += $tabprice[0]; // total ht |
287 | - } |
|
288 | - else |
|
346 | + } else |
|
289 | 347 | { |
290 | 348 | $TTot['total_pa_ht'] += $l->pa_ht * $l->qty; |
291 | 349 | $TTot['total_subprice'] += $l->subprice * $l->qty; |
@@ -305,29 +363,41 @@ discard block |
||
305 | 363 | |
306 | 364 | public static function getOrderIdFromLineId(&$db, $fk_commandedet) |
307 | 365 | { |
308 | - if (empty($fk_commandedet)) return false; |
|
366 | + if (empty($fk_commandedet)) { |
|
367 | + return false; |
|
368 | + } |
|
309 | 369 | |
310 | 370 | $sql = 'SELECT fk_commande FROM '.MAIN_DB_PREFIX.'commandedet WHERE rowid = '.$fk_commandedet; |
311 | 371 | $resql = $db->query($sql); |
312 | 372 | |
313 | - if ($resql && ($row = $db->fetch_object($resql))) return $row->fk_commande; |
|
314 | - else return false; |
|
373 | + if ($resql && ($row = $db->fetch_object($resql))) { |
|
374 | + return $row->fk_commande; |
|
375 | + } else { |
|
376 | + return false; |
|
377 | + } |
|
315 | 378 | } |
316 | 379 | |
317 | 380 | public static function getLastLineOrderId(&$db, $fk_commande) |
318 | 381 | { |
319 | - if (empty($fk_commande)) return false; |
|
382 | + if (empty($fk_commande)) { |
|
383 | + return false; |
|
384 | + } |
|
320 | 385 | |
321 | 386 | $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'commandedet WHERE fk_commande = '.$fk_commande.' ORDER BY rang DESC LIMIT 1'; |
322 | 387 | $resql = $db->query($sql); |
323 | 388 | |
324 | - if ($resql && ($row = $db->fetch_object($resql))) return $row->rowid; |
|
325 | - else return false; |
|
389 | + if ($resql && ($row = $db->fetch_object($resql))) { |
|
390 | + return $row->rowid; |
|
391 | + } else { |
|
392 | + return false; |
|
393 | + } |
|
326 | 394 | } |
327 | 395 | |
328 | 396 | public static function getParentTitleOfLine(&$object, $i) |
329 | 397 | { |
330 | - if ($i <= 0) return false; |
|
398 | + if ($i <= 0) { |
|
399 | + return false; |
|
400 | + } |
|
331 | 401 | |
332 | 402 | $skip_title = 0; |
333 | 403 | // Je parcours les lignes précédentes |
@@ -346,8 +416,7 @@ discard block |
||
346 | 416 | //@INFO J'ai ma ligne titre qui contient ma ligne, par contre je check pas s'il y a un sous-total |
347 | 417 | return $line; |
348 | 418 | break; |
349 | - } |
|
350 | - elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99) |
|
419 | + } elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99) |
|
351 | 420 | { |
352 | 421 | // Il s'agit d'un sous-total, ça veut dire que le prochain titre théoriquement doit être ignorer (je travail avec un incrément au cas ou je croise plusieurs sous-totaux) |
353 | 422 | $skip_title++; |
@@ -362,7 +431,9 @@ discard block |
||
362 | 431 | $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9; |
363 | 432 | if($res && $level > -1) { |
364 | 433 | return $line->qty == $level; |
365 | - } else return $res; |
|
434 | + } else { |
|
435 | + return $res; |
|
436 | + } |
|
366 | 437 | |
367 | 438 | } |
368 | 439 | |
@@ -389,10 +460,14 @@ discard block |
||
389 | 460 | // editeur wysiwyg |
390 | 461 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
391 | 462 | $nbrows=ROWS_2; |
392 | - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
463 | + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) { |
|
464 | + $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
465 | + } |
|
393 | 466 | $enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); |
394 | 467 | $toolbarname='dolibarr_details'; |
395 | - if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; |
|
468 | + if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) { |
|
469 | + $toolbarname='dolibarr_notes'; |
|
470 | + } |
|
396 | 471 | $text = !empty($line->description)?$line->description:$line->label; |
397 | 472 | $doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly); |
398 | 473 | return $doleditor->Create(1); |
@@ -407,12 +482,10 @@ discard block |
||
407 | 482 | { |
408 | 483 | $object->statut = 0; // hack for facture rec |
409 | 484 | $createRight = $user->rights->facture->creer; |
410 | - } |
|
411 | - elseif($object->element == 'order_supplier' ) |
|
485 | + } elseif($object->element == 'order_supplier' ) |
|
412 | 486 | { |
413 | 487 | $createRight = $user->rights->fournisseur->commande->creer; |
414 | - } |
|
415 | - elseif($object->element == 'invoice_supplier' ) |
|
488 | + } elseif($object->element == 'invoice_supplier' ) |
|
416 | 489 | { |
417 | 490 | $createRight = $user->rights->fournisseur->facture->creer; |
418 | 491 | } |
@@ -485,8 +558,9 @@ discard block |
||
485 | 558 | |
486 | 559 | $TLineAdded[] = $object->line; |
487 | 560 | // Error from addline |
488 | - if ($res <= 0) break; |
|
489 | - else |
|
561 | + if ($res <= 0) { |
|
562 | + break; |
|
563 | + } else |
|
490 | 564 | { |
491 | 565 | $object->line_from = $line; |
492 | 566 | // Call trigger |
@@ -508,8 +582,7 @@ discard block |
||
508 | 582 | _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']); |
509 | 583 | } |
510 | 584 | return count($TLineAdded); |
511 | - } |
|
512 | - else |
|
585 | + } else |
|
513 | 586 | { |
514 | 587 | $object->db->rollback(); |
515 | 588 | return -1; |
@@ -525,10 +598,14 @@ discard block |
||
525 | 598 | global $langs; |
526 | 599 | |
527 | 600 | // Besoin de comparer sur les 2 formes d'écriture |
528 | - if (!$key_is_id) $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad)); |
|
601 | + if (!$key_is_id) { |
|
602 | + $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad)); |
|
603 | + } |
|
529 | 604 | |
530 | 605 | $TTitle_under_search = array(); |
531 | - if (!empty($under_title)) $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title)); |
|
606 | + if (!empty($under_title)) { |
|
607 | + $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title)); |
|
608 | + } |
|
532 | 609 | |
533 | 610 | $TLine = array(); |
534 | 611 | $add_line = false; |
@@ -538,28 +615,37 @@ discard block |
||
538 | 615 | { |
539 | 616 | if (!$under_title_found && !empty($TTitle_under_search)) |
540 | 617 | { |
541 | - if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true; |
|
542 | - } |
|
543 | - else |
|
618 | + if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) { |
|
619 | + $under_title_found = true; |
|
620 | + } |
|
621 | + } else |
|
544 | 622 | { |
545 | 623 | if ( ($key_is_id && $line->id == $key_trad) || (!$key_is_id && $line->product_type == 9 && $line->qty == $level && (in_array($line->desc, $TTitle_search) || in_array($line->label, $TTitle_search) ))) |
546 | 624 | { |
547 | - if ($key_is_id) $level = $line->qty; |
|
625 | + if ($key_is_id) { |
|
626 | + $level = $line->qty; |
|
627 | + } |
|
548 | 628 | |
549 | 629 | $add_line = true; |
550 | - if ($withBlockLine) $TLine[] = $line; |
|
630 | + if ($withBlockLine) { |
|
631 | + $TLine[] = $line; |
|
632 | + } |
|
551 | 633 | continue; |
552 | - } |
|
553 | - elseif ($add_line && $line->product_type == 9 && (100 - $line->qty == $level) ) // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre |
|
634 | + } elseif ($add_line && $line->product_type == 9 && (100 - $line->qty == $level) ) { |
|
635 | + // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre |
|
554 | 636 | { |
555 | 637 | if ($withBlockLine) $TLine[] = $line; |
638 | + } |
|
556 | 639 | break; |
557 | 640 | } |
558 | 641 | |
559 | 642 | if ($add_line) |
560 | 643 | { |
561 | - if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue; |
|
562 | - else $TLine[] = $line; |
|
644 | + if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) { |
|
645 | + continue; |
|
646 | + } else { |
|
647 | + $TLine[] = $line; |
|
648 | + } |
|
563 | 649 | } |
564 | 650 | } |
565 | 651 | } |
@@ -593,7 +679,9 @@ discard block |
||
593 | 679 | |
594 | 680 | case 'order_supplier': |
595 | 681 | $object->special_code = SELF::$module_number; |
596 | - if (empty($desc)) $desc = $label; |
|
682 | + if (empty($desc)) { |
|
683 | + $desc = $label; |
|
684 | + } |
|
597 | 685 | $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, 0, $date_start, $date_end, $array_options, $fk_unit); |
598 | 686 | break; |
599 | 687 | |
@@ -603,7 +691,9 @@ discard block |
||
603 | 691 | |
604 | 692 | case 'invoice_supplier': |
605 | 693 | $object->special_code = SELF::$module_number; |
606 | - if (empty($desc)) $desc = $label; |
|
694 | + if (empty($desc)) { |
|
695 | + $desc = $label; |
|
696 | + } |
|
607 | 697 | $res = $object->updateline($rowid, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, 0, $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $fk_unit); |
608 | 698 | break; |
609 | 699 | |
@@ -620,8 +710,11 @@ discard block |
||
620 | 710 | break; |
621 | 711 | } |
622 | 712 | |
623 | - if ($res <= 0) $object->db->rollback(); |
|
624 | - else $object->db->commit(); |
|
713 | + if ($res <= 0) { |
|
714 | + $object->db->rollback(); |
|
715 | + } else { |
|
716 | + $object->db->commit(); |
|
717 | + } |
|
625 | 718 | |
626 | 719 | return $res; |
627 | 720 | } |
@@ -631,24 +724,20 @@ discard block |
||
631 | 724 | global $db, $object; |
632 | 725 | |
633 | 726 | $TTitle = array(); |
634 | - if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} |
|
635 | - else { |
|
727 | + if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} else { |
|
636 | 728 | if ($origin_line->element == 'propaldet') |
637 | 729 | { |
638 | 730 | $object = new Propal($db); |
639 | 731 | $object->fetch($origin_line->fk_propal); |
640 | - } |
|
641 | - else if ($origin_line->element == 'commandedet') |
|
732 | + } else if ($origin_line->element == 'commandedet') |
|
642 | 733 | { |
643 | 734 | $object = new Commande($db); |
644 | 735 | $object->fetch($origin_line->fk_commande); |
645 | - } |
|
646 | - else if ($origin_line->element == 'facturedet') |
|
736 | + } else if ($origin_line->element == 'facturedet') |
|
647 | 737 | { |
648 | 738 | $object = new Facture($db); |
649 | 739 | $object->fetch($origin_line->fk_facture); |
650 | - } |
|
651 | - else |
|
740 | + } else |
|
652 | 741 | { |
653 | 742 | return $TTitle; |
654 | 743 | } |
@@ -658,8 +747,11 @@ discard block |
||
658 | 747 | $i = 0; |
659 | 748 | foreach ($object->lines as &$line) |
660 | 749 | { |
661 | - if ($origin_line->id == $line->id) break; |
|
662 | - else $i++; |
|
750 | + if ($origin_line->id == $line->id) { |
|
751 | + break; |
|
752 | + } else { |
|
753 | + $i++; |
|
754 | + } |
|
663 | 755 | } |
664 | 756 | |
665 | 757 | $i--; // Skip la ligne d'origine |
@@ -674,35 +766,43 @@ discard block |
||
674 | 766 | if (self::isSubtotal($object->lines[$y])) |
675 | 767 | { |
676 | 768 | $next_title_lvl_to_skip = self::getNiveau($object->lines[$y]); |
677 | - } |
|
678 | - elseif (self::isTitle($object->lines[$y])) |
|
769 | + } elseif (self::isTitle($object->lines[$y])) |
|
679 | 770 | { |
680 | 771 | if ($object->lines[$y]->qty == $next_title_lvl_to_skip) |
681 | 772 | { |
682 | 773 | $next_title_lvl_to_skip = 0; |
683 | 774 | continue; |
684 | - } |
|
685 | - else |
|
775 | + } else |
|
686 | 776 | { |
687 | - if (empty($object->lines[$y]->array_options)) $object->lines[$y]->fetch_optionals(); |
|
777 | + if (empty($object->lines[$y]->array_options)) { |
|
778 | + $object->lines[$y]->fetch_optionals(); |
|
779 | + } |
|
688 | 780 | $TTitle[$object->lines[$y]->id] = $object->lines[$y]; |
689 | 781 | |
690 | - if ($object->lines[$y]->qty == 1) break; |
|
782 | + if ($object->lines[$y]->qty == 1) { |
|
783 | + break; |
|
784 | + } |
|
691 | 785 | } |
692 | 786 | } |
693 | 787 | } |
694 | 788 | } |
695 | 789 | |
696 | - if ($reverse) $TTitle = array_reverse($TTitle, true); |
|
790 | + if ($reverse) { |
|
791 | + $TTitle = array_reverse($TTitle, true); |
|
792 | + } |
|
697 | 793 | |
698 | 794 | return $TTitle; |
699 | 795 | } |
700 | 796 | |
701 | 797 | public static function getNiveau(&$line) |
702 | 798 | { |
703 | - if (self::isTitle($line)) return $line->qty; |
|
704 | - elseif (self::isSubtotal($line)) return 100 - $line->qty; |
|
705 | - else return 0; |
|
799 | + if (self::isTitle($line)) { |
|
800 | + return $line->qty; |
|
801 | + } elseif (self::isSubtotal($line)) { |
|
802 | + return 100 - $line->qty; |
|
803 | + } else { |
|
804 | + return 0; |
|
805 | + } |
|
706 | 806 | } |
707 | 807 | |
708 | 808 | /** |
@@ -727,10 +827,16 @@ discard block |
||
727 | 827 | $objmarge->marge_droite = 10; |
728 | 828 | |
729 | 829 | $objectref = dol_sanitizeFileName($object->ref); |
730 | - if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref; |
|
731 | - elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref; |
|
732 | - elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref; |
|
733 | - elseif ($object->element == 'facturerec') return; // no PDF for facturerec |
|
830 | + if ($object->element == 'propal') { |
|
831 | + $dir = $conf->propal->dir_output . '/' . $objectref; |
|
832 | + } elseif ($object->element == 'commande') { |
|
833 | + $dir = $conf->commande->dir_output . '/' . $objectref; |
|
834 | + } elseif ($object->element == 'facture') { |
|
835 | + $dir = $conf->facture->dir_output . '/' . $objectref; |
|
836 | + } elseif ($object->element == 'facturerec') { |
|
837 | + return; |
|
838 | + } |
|
839 | + // no PDF for facturerec |
|
734 | 840 | else |
735 | 841 | { |
736 | 842 | setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings'); |
@@ -765,7 +871,9 @@ discard block |
||
765 | 871 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
766 | 872 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
767 | 873 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
768 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
874 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
875 | + $pdf->SetCompression(false); |
|
876 | + } |
|
769 | 877 | |
770 | 878 | $pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right |
771 | 879 | |
@@ -775,7 +883,9 @@ discard block |
||
775 | 883 | |
776 | 884 | // New page |
777 | 885 | $pdf->AddPage(); |
778 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
886 | + if (! empty($tplidx)) { |
|
887 | + $pdf->useTemplate($tplidx); |
|
888 | + } |
|
779 | 889 | $pagenb++; |
780 | 890 | |
781 | 891 | |
@@ -831,8 +941,10 @@ discard block |
||
831 | 941 | { |
832 | 942 | $TTot['TTotal_tva_multicurrency'][$tx] += $amount; |
833 | 943 | } |
944 | + } else { |
|
945 | + $pdf->SetFont('','', $default_font_size - 1); |
|
834 | 946 | } |
835 | - else $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
947 | + // Into loop to work with multipage |
|
836 | 948 | |
837 | 949 | $pdf->SetTextColor(0,0,0); |
838 | 950 | |
@@ -854,9 +966,11 @@ discard block |
||
854 | 966 | $pdf->startTransaction(); |
855 | 967 | $pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true); |
856 | 968 | $pageposafter=$pdf->getPage(); |
857 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
969 | + if ($pageposafter > $pageposbefore) { |
|
970 | + // There is a pagebreak |
|
858 | 971 | { |
859 | 972 | $pdf->rollbackTransaction(true); |
973 | + } |
|
860 | 974 | $pageposafter=$pageposbefore; |
861 | 975 | //print $pageposafter.'-'.$pageposbefore;exit; |
862 | 976 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
@@ -865,23 +979,27 @@ discard block |
||
865 | 979 | $pageposafter=$pdf->getPage(); |
866 | 980 | $posyafter=$pdf->GetY(); |
867 | 981 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
868 | - if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) // There is no space left for total+free text |
|
982 | + if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) { |
|
983 | + // There is no space left for total+free text |
|
869 | 984 | { |
870 | 985 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
871 | 986 | { |
872 | 987 | $pdf->AddPage('','',true); |
873 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
874 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
988 | + } |
|
989 | + if (! empty($tplidx)) { |
|
990 | + $pdf->useTemplate($tplidx); |
|
991 | + } |
|
992 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
993 | + self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
994 | + } |
|
875 | 995 | $pdf->setPage($pageposafter+1); |
876 | 996 | } |
877 | - } |
|
878 | - else |
|
997 | + } else |
|
879 | 998 | { |
880 | 999 | // We found a page break |
881 | 1000 | $showpricebeforepagebreak=0; |
882 | 1001 | } |
883 | - } |
|
884 | - else // No pagebreak |
|
1002 | + } else // No pagebreak |
|
885 | 1003 | { |
886 | 1004 | $pdf->commitTransaction(); |
887 | 1005 | } |
@@ -921,8 +1039,7 @@ discard block |
||
921 | 1039 | if ($pagenb == 1) |
922 | 1040 | { |
923 | 1041 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
924 | - } |
|
925 | - else |
|
1042 | + } else |
|
926 | 1043 | { |
927 | 1044 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code); |
928 | 1045 | } |
@@ -930,7 +1047,9 @@ discard block |
||
930 | 1047 | $pagenb++; |
931 | 1048 | $pdf->setPage($pagenb); |
932 | 1049 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
933 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
1050 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
1051 | + self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
1052 | + } |
|
934 | 1053 | } |
935 | 1054 | } |
936 | 1055 | } |
@@ -940,8 +1059,7 @@ discard block |
||
940 | 1059 | { |
941 | 1060 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
942 | 1061 | $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
943 | - } |
|
944 | - else |
|
1062 | + } else |
|
945 | 1063 | { |
946 | 1064 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); |
947 | 1065 | $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
@@ -955,7 +1073,9 @@ discard block |
||
955 | 1073 | |
956 | 1074 | $pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file); |
957 | 1075 | |
958 | - if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) unlink($file); |
|
1076 | + if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) { |
|
1077 | + unlink($file); |
|
1078 | + } |
|
959 | 1079 | } |
960 | 1080 | |
961 | 1081 | private static function printLevel($objmarge, $pdf, $line, $curY, $posx_designation) |
@@ -998,8 +1118,7 @@ discard block |
||
998 | 1118 | { |
999 | 1119 | $height=pdf_getHeightForLogo($logo); |
1000 | 1120 | $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto) |
1001 | - } |
|
1002 | - else |
|
1121 | + } else |
|
1003 | 1122 | { |
1004 | 1123 | $pdf->SetTextColor(200,0,0); |
1005 | 1124 | $pdf->SetFont('','B',$default_font_size - 2); |
@@ -1008,8 +1127,7 @@ discard block |
||
1008 | 1127 | } |
1009 | 1128 | |
1010 | 1129 | $posy+=35; |
1011 | - } |
|
1012 | - else |
|
1130 | + } else |
|
1013 | 1131 | { |
1014 | 1132 | $text=$mysoc->name; |
1015 | 1133 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -1023,9 +1141,13 @@ discard block |
||
1023 | 1141 | $pdf->SetXY($objmarge->marge_gauche,$posy); |
1024 | 1142 | |
1025 | 1143 | $key = 'subtotalPropalTitle'; |
1026 | - if ($object->element == 'commande') $key = 'subtotalCommandeTitle'; |
|
1027 | - elseif ($object->element == 'facture') $key = 'subtotalInvoiceTitle'; |
|
1028 | - elseif ($object->element == 'facturerec') $key = 'subtotalInvoiceTitle'; |
|
1144 | + if ($object->element == 'commande') { |
|
1145 | + $key = 'subtotalCommandeTitle'; |
|
1146 | + } elseif ($object->element == 'facture') { |
|
1147 | + $key = 'subtotalInvoiceTitle'; |
|
1148 | + } elseif ($object->element == 'facturerec') { |
|
1149 | + $key = 'subtotalInvoiceTitle'; |
|
1150 | + } |
|
1029 | 1151 | |
1030 | 1152 | $pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L'); |
1031 | 1153 | |
@@ -1060,7 +1182,9 @@ discard block |
||
1060 | 1182 | |
1061 | 1183 | // Force to disable hidetop and hidebottom |
1062 | 1184 | $hidebottom=0; |
1063 | - if ($hidetop) $hidetop=-1; |
|
1185 | + if ($hidetop) { |
|
1186 | + $hidetop=-1; |
|
1187 | + } |
|
1064 | 1188 | |
1065 | 1189 | $currency = !empty($currency) ? $currency : $conf->currency; |
1066 | 1190 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
@@ -1075,7 +1199,9 @@ discard block |
||
1075 | 1199 | $pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5); |
1076 | 1200 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
1077 | 1201 | |
1078 | - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
1202 | + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { |
|
1203 | + $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
1204 | + } |
|
1079 | 1205 | |
1080 | 1206 | |
1081 | 1207 | $pdf->line($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top); // line prend une position y en 2eme param et 4eme param |
@@ -1088,8 +1214,7 @@ discard block |
||
1088 | 1214 | $pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R'); |
1089 | 1215 | |
1090 | 1216 | $pdf->line($objmarge->marge_gauche, $tab_top+8, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top+8); // line prend une position y en 2eme param et 4eme param |
1091 | - } |
|
1092 | - else |
|
1217 | + } else |
|
1093 | 1218 | { |
1094 | 1219 | $pdf->line($objmarge->marge_gauche, $tab_top-2, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top-2); // line prend une position y en 2eme param et 4eme param |
1095 | 1220 | } |
@@ -1110,10 +1235,12 @@ discard block |
||
1110 | 1235 | |
1111 | 1236 | // Tableau total |
1112 | 1237 | $col1x = 120; $col2x = 170; |
1113 | - if ($objmarge->page_largeur < 210) // To work with US executive format |
|
1238 | + if ($objmarge->page_largeur < 210) { |
|
1239 | + // To work with US executive format |
|
1114 | 1240 | { |
1115 | 1241 | $col2x-=20; |
1116 | 1242 | } |
1243 | + } |
|
1117 | 1244 | $largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x); |
1118 | 1245 | |
1119 | 1246 | $useborder=0; |
@@ -1135,9 +1262,11 @@ discard block |
||
1135 | 1262 | $atleastoneratenotnull=0; |
1136 | 1263 | foreach($TTot['TTotal_tva'] as $tvakey => $tvaval) |
1137 | 1264 | { |
1138 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1265 | + if ($tvakey != 0) { |
|
1266 | + // On affiche pas taux 0 |
|
1139 | 1267 | { |
1140 | 1268 | $atleastoneratenotnull++; |
1269 | + } |
|
1141 | 1270 | |
1142 | 1271 | $index++; |
1143 | 1272 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -1190,9 +1319,13 @@ discard block |
||
1190 | 1319 | */ |
1191 | 1320 | private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
1192 | 1321 | { |
1193 | - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
1322 | + if (empty($hidetop) || $hidetop==-1) { |
|
1323 | + $pdf->line($x, $y, $x+$l, $y); |
|
1324 | + } |
|
1194 | 1325 | $pdf->line($x+$l, $y, $x+$l, $y+$h); |
1195 | - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
1326 | + if (empty($hidebottom)) { |
|
1327 | + $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
1328 | + } |
|
1196 | 1329 | $pdf->line($x, $y+$h, $x, $y); |
1197 | 1330 | } |
1198 | 1331 | |
@@ -1201,7 +1334,9 @@ discard block |
||
1201 | 1334 | { |
1202 | 1335 | global $conf; |
1203 | 1336 | |
1204 | - if (empty($fileoutput)) $fileoutput = $file[0]; |
|
1337 | + if (empty($fileoutput)) { |
|
1338 | + $fileoutput = $file[0]; |
|
1339 | + } |
|
1205 | 1340 | |
1206 | 1341 | $pdf=pdf_getInstance(); |
1207 | 1342 | if (class_exists('TCPDF')) |
@@ -1211,7 +1346,9 @@ discard block |
||
1211 | 1346 | } |
1212 | 1347 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
1213 | 1348 | |
1214 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
1349 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
1350 | + $pdf->SetCompression(false); |
|
1351 | + } |
|
1215 | 1352 | |
1216 | 1353 | |
1217 | 1354 | foreach($files as $file) |
@@ -1227,7 +1364,9 @@ discard block |
||
1227 | 1364 | } |
1228 | 1365 | |
1229 | 1366 | $pdf->Output($fileoutput,'F'); |
1230 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
1367 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
1368 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
1369 | + } |
|
1231 | 1370 | |
1232 | 1371 | return $pagecount; |
1233 | 1372 | } |
@@ -1240,7 +1379,9 @@ discard block |
||
1240 | 1379 | */ |
1241 | 1380 | public static function hasNcTitle(&$line) |
1242 | 1381 | { |
1243 | - if(isset($line->has_nc_title)) return $line->has_nc_title; |
|
1382 | + if(isset($line->has_nc_title)) { |
|
1383 | + return $line->has_nc_title; |
|
1384 | + } |
|
1244 | 1385 | |
1245 | 1386 | $TTitle = self::getAllTitleFromLine($line); |
1246 | 1387 | foreach ($TTitle as &$line_title) |
@@ -1265,7 +1406,9 @@ discard block |
||
1265 | 1406 | public static function getTitleLabel($line) |
1266 | 1407 | { |
1267 | 1408 | $title = $line->label; |
1268 | - if (empty($title)) $title = !empty($line->description) ? $line->description : $line->desc; |
|
1409 | + if (empty($title)) { |
|
1410 | + $title = !empty($line->description) ? $line->description : $line->desc; |
|
1411 | + } |
|
1269 | 1412 | return $title; |
1270 | 1413 | } |
1271 | 1414 | } |
@@ -45,7 +45,9 @@ discard block |
||
45 | 45 | $value = ''; |
46 | 46 | $sql = 'SELECT content FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text WHERE rowid = '.GETPOST('rowid'); |
47 | 47 | $resql = $this->db->query($sql); |
48 | - if ($resql && ($obj = $this->db->fetch_object($resql))) $value = $obj->content; |
|
48 | + if ($resql && ($obj = $this->db->fetch_object($resql))) { |
|
49 | + $value = $obj->content; |
|
50 | + } |
|
49 | 51 | } |
50 | 52 | |
51 | 53 | ?> |
@@ -129,8 +131,11 @@ discard block |
||
129 | 131 | if ($object->statut == 0 && $createRight) { |
130 | 132 | |
131 | 133 | |
132 | - if($object->element=='facture')$idvar = 'facid'; |
|
133 | - else $idvar='id'; |
|
134 | + if($object->element=='facture') { |
|
135 | + $idvar = 'facid'; |
|
136 | + } else { |
|
137 | + $idvar='id'; |
|
138 | + } |
|
134 | 139 | |
135 | 140 | if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) ) |
136 | 141 | { |
@@ -138,10 +143,11 @@ discard block |
||
138 | 143 | |
139 | 144 | if($action=='add_title_line') { |
140 | 145 | $title = GETPOST('title'); |
141 | - if(empty($title)) $title = $langs->trans('title'); |
|
146 | + if(empty($title)) { |
|
147 | + $title = $langs->trans('title'); |
|
148 | + } |
|
142 | 149 | $qty = $level<1 ? 1 : $level ; |
143 | - } |
|
144 | - else if($action=='add_free_text') { |
|
150 | + } else if($action=='add_free_text') { |
|
145 | 151 | $title = GETPOST('title'); |
146 | 152 | |
147 | 153 | if (empty($title)) { |
@@ -153,29 +159,31 @@ discard block |
||
153 | 159 | } |
154 | 160 | } |
155 | 161 | } |
156 | - if(empty($title)) $title = $langs->trans('subtotalAddLineDescription'); |
|
162 | + if(empty($title)) { |
|
163 | + $title = $langs->trans('subtotalAddLineDescription'); |
|
164 | + } |
|
157 | 165 | $qty = 50; |
158 | - } |
|
159 | - else if($action=='add_subtitle_line') { |
|
166 | + } else if($action=='add_subtitle_line') { |
|
160 | 167 | $title = GETPOST('title'); |
161 | - if(empty($title)) $title = $langs->trans('subtitle'); |
|
168 | + if(empty($title)) { |
|
169 | + $title = $langs->trans('subtitle'); |
|
170 | + } |
|
162 | 171 | $qty = 2; |
163 | - } |
|
164 | - else if($action=='add_subtotal_line') { |
|
172 | + } else if($action=='add_subtotal_line') { |
|
165 | 173 | $title = $langs->trans('SubSubTotal'); |
166 | 174 | $qty = 98; |
167 | - } |
|
168 | - else { |
|
175 | + } else { |
|
169 | 176 | $title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal'); |
170 | 177 | $qty = $level ? 100-$level : 99; |
171 | 178 | } |
172 | 179 | dol_include_once('/subtotal/class/subtotal.class.php'); |
173 | 180 | |
174 | - if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty); |
|
181 | + if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) { |
|
182 | + TSubtotal::addSubtotalMissing($object, $qty); |
|
183 | + } |
|
175 | 184 | |
176 | 185 | TSubtotal::addSubTotalLine($object, $title, $qty); |
177 | - } |
|
178 | - else if($action==='ask_deleteallline') { |
|
186 | + } else if($action==='ask_deleteallline') { |
|
179 | 187 | $form=new Form($db); |
180 | 188 | |
181 | 189 | $lineid = GETPOST('lineid','integer'); |
@@ -198,8 +206,7 @@ discard block |
||
198 | 206 | $this->printNewFormat($object, $conf, $langs, $idvar); |
199 | 207 | } |
200 | 208 | } |
201 | - } |
|
202 | - elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts)) |
|
209 | + } elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts)) |
|
203 | 210 | { |
204 | 211 | ?> |
205 | 212 | <script type="text/javascript"> |
@@ -217,8 +224,13 @@ discard block |
||
217 | 224 | |
218 | 225 | function printNewFormat(&$object, &$conf, &$langs, $idvar) |
219 | 226 | { |
220 | - if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) return false; |
|
221 | - if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) return false; // Si facture de situation |
|
227 | + if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) { |
|
228 | + return false; |
|
229 | + } |
|
230 | + if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) { |
|
231 | + return false; |
|
232 | + } |
|
233 | + // Si facture de situation |
|
222 | 234 | ?> |
223 | 235 | <script type="text/javascript"> |
224 | 236 | $(document).ready(function() { |
@@ -504,8 +516,7 @@ discard block |
||
504 | 516 | } |
505 | 517 | |
506 | 518 | |
507 | - } |
|
508 | - else{ |
|
519 | + } else{ |
|
509 | 520 | $substitutionarray['line_not_modsubtotal'] = true; |
510 | 521 | $substitutionarray['line_modsubtotal'] = 0; |
511 | 522 | } |
@@ -563,8 +574,11 @@ discard block |
||
563 | 574 | |
564 | 575 | $showBlockExtrafields = GETPOST('showBlockExtrafields'); |
565 | 576 | |
566 | - if($object->element=='facture') $idvar = 'facid'; |
|
567 | - else $idvar = 'id'; |
|
577 | + if($object->element=='facture') { |
|
578 | + $idvar = 'facid'; |
|
579 | + } else { |
|
580 | + $idvar = 'id'; |
|
581 | + } |
|
568 | 582 | |
569 | 583 | if ($action == 'updateligne' || $action == 'updateline') |
570 | 584 | { |
@@ -594,8 +608,7 @@ discard block |
||
594 | 608 | header('Location: '.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id); |
595 | 609 | exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne |
596 | 610 | } |
597 | - } |
|
598 | - else if($action === 'builddoc') { |
|
611 | + } else if($action === 'builddoc') { |
|
599 | 612 | |
600 | 613 | if ( |
601 | 614 | in_array('invoicecard',explode(':',$parameters['context'])) |
@@ -610,33 +623,27 @@ discard block |
||
610 | 623 | $sessname = 'subtotal_hideInnerLines_facture'; |
611 | 624 | $sessname2 = 'subtotal_hidedetails_facture'; |
612 | 625 | $sessname3 = 'subtotal_hideprices_facture'; |
613 | - } |
|
614 | - elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) { |
|
626 | + } elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) { |
|
615 | 627 | $sessname = 'subtotal_hideInnerLines_facture_fournisseur'; |
616 | 628 | $sessname2 = 'subtotal_hidedetails_facture_fournisseur'; |
617 | 629 | $sessname3 = 'subtotal_hideprices_facture_fournisseur'; |
618 | - } |
|
619 | - elseif(in_array('propalcard',explode(':',$parameters['context']))) { |
|
630 | + } elseif(in_array('propalcard',explode(':',$parameters['context']))) { |
|
620 | 631 | $sessname = 'subtotal_hideInnerLines_propal'; |
621 | 632 | $sessname2 = 'subtotal_hidedetails_propal'; |
622 | 633 | $sessname3 = 'subtotal_hideprices_propal'; |
623 | - } |
|
624 | - elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) { |
|
634 | + } elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) { |
|
625 | 635 | $sessname = 'subtotal_hideInnerLines_supplier_proposal'; |
626 | 636 | $sessname2 = 'subtotal_hidedetails_supplier_proposal'; |
627 | 637 | $sessname3 = 'subtotal_hideprices_supplier_proposal'; |
628 | - } |
|
629 | - elseif(in_array('ordercard',explode(':',$parameters['context']))) { |
|
638 | + } elseif(in_array('ordercard',explode(':',$parameters['context']))) { |
|
630 | 639 | $sessname = 'subtotal_hideInnerLines_commande'; |
631 | 640 | $sessname2 = 'subtotal_hidedetails_commande'; |
632 | 641 | $sessname3 = 'subtotal_hideprices_commande'; |
633 | - } |
|
634 | - elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) { |
|
642 | + } elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) { |
|
635 | 643 | $sessname = 'subtotal_hideInnerLines_commande_fournisseur'; |
636 | 644 | $sessname2 = 'subtotal_hidedetails_commande_fournisseur'; |
637 | 645 | $sessname3 = 'subtotal_hideprices_commande_fournisseur'; |
638 | - } |
|
639 | - else { |
|
646 | + } else { |
|
640 | 647 | $sessname = 'subtotal_hideInnerLines_unknown'; |
641 | 648 | $sessname2 = 'subtotal_hidedetails_unknown'; |
642 | 649 | $sessname3 = 'subtotal_hideprices_unknown'; |
@@ -645,15 +652,24 @@ discard block |
||
645 | 652 | global $hideprices; |
646 | 653 | |
647 | 654 | $hideInnerLines = (int)GETPOST('hideInnerLines'); |
648 | - if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) $_SESSION[$sessname] = array(); // prevent old system |
|
655 | + if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) { |
|
656 | + $_SESSION[$sessname] = array(); |
|
657 | + } |
|
658 | + // prevent old system |
|
649 | 659 | $_SESSION[$sessname][$object->id] = $hideInnerLines; |
650 | 660 | |
651 | 661 | $hidedetails= (int)GETPOST('hidedetails'); |
652 | - if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) $_SESSION[$sessname2] = array(); // prevent old system |
|
662 | + if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) { |
|
663 | + $_SESSION[$sessname2] = array(); |
|
664 | + } |
|
665 | + // prevent old system |
|
653 | 666 | $_SESSION[$sessname2][$object->id] = $hidedetails; |
654 | 667 | |
655 | 668 | $hideprices= (int)GETPOST('hideprices'); |
656 | - if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) $_SESSION[$sessname3] = array(); // prevent old system |
|
669 | + if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) { |
|
670 | + $_SESSION[$sessname3] = array(); |
|
671 | + } |
|
672 | + // prevent old system |
|
657 | 673 | $_SESSION[$sessname3][$object->id] = $hideprices; |
658 | 674 | |
659 | 675 | foreach($object->lines as &$line) { |
@@ -661,8 +677,7 @@ discard block |
||
661 | 677 | |
662 | 678 | if($line->qty>=90) { |
663 | 679 | $line->modsubtotal_total = 1; |
664 | - } |
|
665 | - else{ |
|
680 | + } else{ |
|
666 | 681 | $line->modsubtotal_title = 1; |
667 | 682 | } |
668 | 683 | |
@@ -671,8 +686,7 @@ discard block |
||
671 | 686 | } |
672 | 687 | } |
673 | 688 | |
674 | - } |
|
675 | - else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') { |
|
689 | + } else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') { |
|
676 | 690 | |
677 | 691 | $Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid')); |
678 | 692 | |
@@ -680,7 +694,9 @@ discard block |
||
680 | 694 | /** |
681 | 695 | * @var $object Facture |
682 | 696 | */ |
683 | - if($object->element=='facture') $object->deleteline($idLine); |
|
697 | + if($object->element=='facture') { |
|
698 | + $object->deleteline($idLine); |
|
699 | + } |
|
684 | 700 | /** |
685 | 701 | * @var $object Facture fournisseur |
686 | 702 | */ |
@@ -691,18 +707,25 @@ discard block |
||
691 | 707 | /** |
692 | 708 | * @var $object Propal |
693 | 709 | */ |
694 | - else if($object->element=='propal') $object->deleteline($idLine); |
|
710 | + else if($object->element=='propal') { |
|
711 | + $object->deleteline($idLine); |
|
712 | + } |
|
695 | 713 | /** |
696 | 714 | * @var $object Propal Fournisseur |
697 | 715 | */ |
698 | - else if($object->element=='supplier_proposal') $object->deleteline($idLine); |
|
716 | + else if($object->element=='supplier_proposal') { |
|
717 | + $object->deleteline($idLine); |
|
718 | + } |
|
699 | 719 | /** |
700 | 720 | * @var $object Commande |
701 | 721 | */ |
702 | 722 | else if($object->element=='commande') |
703 | 723 | { |
704 | - if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine); |
|
705 | - else $object->deleteline($idLine); |
|
724 | + if ((float) DOL_VERSION >= 5.0) { |
|
725 | + $object->deleteline($user, $idLine); |
|
726 | + } else { |
|
727 | + $object->deleteline($idLine); |
|
728 | + } |
|
706 | 729 | } |
707 | 730 | /** |
708 | 731 | * @var $object Commande fournisseur |
@@ -714,21 +737,26 @@ discard block |
||
714 | 737 | /** |
715 | 738 | * @var $object Facturerec |
716 | 739 | */ |
717 | - else if($object->element=='facturerec') $object->deleteline($idLine); |
|
740 | + else if($object->element=='facturerec') { |
|
741 | + $object->deleteline($idLine); |
|
742 | + } |
|
718 | 743 | } |
719 | 744 | |
720 | 745 | header('location:?id='.$object->id); |
721 | 746 | exit; |
722 | 747 | |
723 | - } |
|
724 | - else if ($action == 'duplicate') |
|
748 | + } else if ($action == 'duplicate') |
|
725 | 749 | { |
726 | 750 | $lineid = GETPOST('lineid', 'int'); |
727 | 751 | $nbDuplicate = TSubtotal::duplicateLines($object, $lineid, true); |
728 | 752 | |
729 | - if ($nbDuplicate > 0) setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate)); |
|
730 | - elseif ($nbDuplicate == 0) setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings'); |
|
731 | - else setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors'); |
|
753 | + if ($nbDuplicate > 0) { |
|
754 | + setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate)); |
|
755 | + } elseif ($nbDuplicate == 0) { |
|
756 | + setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings'); |
|
757 | + } else { |
|
758 | + setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors'); |
|
759 | + } |
|
732 | 760 | |
733 | 761 | header('Location: ?id='.$object->id); |
734 | 762 | exit; |
@@ -746,21 +774,26 @@ discard block |
||
746 | 774 | global $conf; |
747 | 775 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && !empty($object->table_element_line) && in_array($object->element, array('commande', 'facture', 'propal'))) |
748 | 776 | { |
749 | - if ($object->element == 'commande') |
|
750 | - $obj = new OrderLine($object->db); |
|
751 | - if ($object->element == 'propal') |
|
752 | - $obj = new PropaleLigne($object->db); |
|
753 | - if ($object->element == 'facture') |
|
754 | - $obj = new FactureLigne($object->db); |
|
777 | + if ($object->element == 'commande') { |
|
778 | + $obj = new OrderLine($object->db); |
|
779 | + } |
|
780 | + if ($object->element == 'propal') { |
|
781 | + $obj = new PropaleLigne($object->db); |
|
782 | + } |
|
783 | + if ($object->element == 'facture') { |
|
784 | + $obj = new FactureLigne($object->db); |
|
785 | + } |
|
755 | 786 | if (!empty($parameters['fk_element'])) |
756 | 787 | { |
757 | 788 | |
758 | 789 | if($obj->fetch($parameters['fk_element'])){ |
759 | 790 | $obj->id= $obj->rowid; |
760 | - if (empty($obj->array_options)) |
|
761 | - $obj->fetch_optionals(); |
|
762 | - if (!empty($obj->array_options['options_subtotal_nc'])) |
|
763 | - return 1; |
|
791 | + if (empty($obj->array_options)) { |
|
792 | + $obj->fetch_optionals(); |
|
793 | + } |
|
794 | + if (!empty($obj->array_options['options_subtotal_nc'])) { |
|
795 | + return 1; |
|
796 | + } |
|
764 | 797 | } |
765 | 798 | } |
766 | 799 | } |
@@ -835,17 +868,18 @@ discard block |
||
835 | 868 | //print $l->rang.'>='.$rang.' '.$total.'<br/>'; |
836 | 869 | if($l->rang>=$rang) { |
837 | 870 | //echo 'return!<br>'; |
838 | - if (!$return_all) return $total; |
|
839 | - else return array($total, $total_tva, $total_ttc, $TTotal_tva); |
|
840 | - } |
|
841 | - else if(TSubtotal::isTitle($l, 100 - $qty_line)) |
|
871 | + if (!$return_all) { |
|
872 | + return $total; |
|
873 | + } else { |
|
874 | + return array($total, $total_tva, $total_ttc, $TTotal_tva); |
|
875 | + } |
|
876 | + } else if(TSubtotal::isTitle($l, 100 - $qty_line)) |
|
842 | 877 | { |
843 | 878 | $total = 0; |
844 | 879 | $total_tva = 0; |
845 | 880 | $total_ttc = 0; |
846 | 881 | $TTotal_tva = array(); |
847 | - } |
|
848 | - elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) { |
|
882 | + } elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) { |
|
849 | 883 | $total += $l->total_ht; |
850 | 884 | $total_tva += $l->total_tva; |
851 | 885 | $TTotal_tva[$l->tva_tx] += $l->total_tva; |
@@ -853,8 +887,11 @@ discard block |
||
853 | 887 | } |
854 | 888 | |
855 | 889 | } |
856 | - if (!$return_all) return $total; |
|
857 | - else return array($total, $total_tva, $total_ttc, $TTotal_tva); |
|
890 | + if (!$return_all) { |
|
891 | + return $total; |
|
892 | + } else { |
|
893 | + return array($total, $total_tva, $total_ttc, $TTotal_tva); |
|
894 | + } |
|
858 | 895 | } |
859 | 896 | |
860 | 897 | /* |
@@ -922,15 +959,18 @@ discard block |
||
922 | 959 | } |
923 | 960 | |
924 | 961 | |
925 | - if($line->qty==99) |
|
926 | - $pdf->SetFillColor(220,220,220); |
|
927 | - elseif ($line->qty==98) |
|
928 | - $pdf->SetFillColor(230,230,230); |
|
929 | - else |
|
930 | - $pdf->SetFillColor(240,240,240); |
|
962 | + if($line->qty==99) { |
|
963 | + $pdf->SetFillColor(220,220,220); |
|
964 | + } elseif ($line->qty==98) { |
|
965 | + $pdf->SetFillColor(230,230,230); |
|
966 | + } else { |
|
967 | + $pdf->SetFillColor(240,240,240); |
|
968 | + } |
|
931 | 969 | |
932 | 970 | $style = 'B'; |
933 | - if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE; |
|
971 | + if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) { |
|
972 | + $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE; |
|
973 | + } |
|
934 | 974 | |
935 | 975 | $pdf->SetFont('', $style, 9); |
936 | 976 | |
@@ -969,8 +1009,7 @@ discard block |
||
969 | 1009 | // $line->total_tva |
970 | 1010 | // $line->total |
971 | 1011 | // $line->total_ttc |
972 | - } |
|
973 | - else |
|
1012 | + } else |
|
974 | 1013 | { |
975 | 1014 | list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1); |
976 | 1015 | if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation |
@@ -987,11 +1026,14 @@ discard block |
||
987 | 1026 | } |
988 | 1027 | |
989 | 1028 | $pdf->SetXY($pdf->postotalht, $posy); |
990 | - if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); |
|
1029 | + if($set_pagebreak_margin) { |
|
1030 | + $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); |
|
1031 | + } |
|
991 | 1032 | $pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0); |
992 | - } |
|
993 | - else{ |
|
994 | - if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); |
|
1033 | + } else{ |
|
1034 | + if($set_pagebreak_margin) { |
|
1035 | + $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); |
|
1036 | + } |
|
995 | 1037 | } |
996 | 1038 | |
997 | 1039 | $posy = $posy + $cell_height; |
@@ -1023,25 +1065,40 @@ discard block |
||
1023 | 1065 | |
1024 | 1066 | |
1025 | 1067 | $style = ($line->qty==1) ? 'BU' : 'BUI'; |
1026 | - if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE; |
|
1068 | + if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) { |
|
1069 | + $style = $conf->global->SUBTOTAL_TITLE_STYLE; |
|
1070 | + } |
|
1027 | 1071 | |
1028 | 1072 | if($hideInnerLines) { |
1029 | - if($line->qty==1)$pdf->SetFont('', $style, 9); |
|
1030 | - else |
|
1073 | + if($line->qty==1) { |
|
1074 | + $pdf->SetFont('', $style, 9); |
|
1075 | + } else |
|
1031 | 1076 | { |
1032 | - if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES; |
|
1077 | + if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) { |
|
1078 | + $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES; |
|
1079 | + } |
|
1033 | 1080 | $pdf->SetFont('', $style, 9); |
1034 | 1081 | } |
1035 | - } |
|
1036 | - else { |
|
1082 | + } else { |
|
1037 | 1083 | |
1038 | - if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile |
|
1039 | - else $pdf->SetFont('', $style, 9); |
|
1084 | + if($line->qty==1) { |
|
1085 | + $pdf->SetFont('', $style, 9); |
|
1086 | + } |
|
1087 | + //TODO if super utile |
|
1088 | + else { |
|
1089 | + $pdf->SetFont('', $style, 9); |
|
1090 | + } |
|
1040 | 1091 | |
1041 | 1092 | } |
1042 | 1093 | |
1043 | - if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) $pdf->MultiCell($w, $h, $label, 0, 'L'); // Pas de HTML dans la chaine |
|
1044 | - else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML |
|
1094 | + if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) { |
|
1095 | + $pdf->MultiCell($w, $h, $label, 0, 'L'); |
|
1096 | + } |
|
1097 | + // Pas de HTML dans la chaine |
|
1098 | + else { |
|
1099 | + $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); |
|
1100 | + } |
|
1101 | + // et maintenant avec du HTML |
|
1045 | 1102 | |
1046 | 1103 | if($description && !$hidedesc) { |
1047 | 1104 | $posy = $pdf->GetY(); |
@@ -1065,8 +1122,7 @@ discard block |
||
1065 | 1122 | |
1066 | 1123 | if(is_array($parameters)) { |
1067 | 1124 | $i = & $parameters['i']; |
1068 | - } |
|
1069 | - else { |
|
1125 | + } else { |
|
1070 | 1126 | $i = (int)$parameters; |
1071 | 1127 | } |
1072 | 1128 | |
@@ -1088,17 +1144,14 @@ discard block |
||
1088 | 1144 | |
1089 | 1145 | if((float)DOL_VERSION<=3.6) { |
1090 | 1146 | return ''; |
1091 | - } |
|
1092 | - else if((float)DOL_VERSION>=3.8) { |
|
1147 | + } else if((float)DOL_VERSION>=3.8) { |
|
1093 | 1148 | return 1; |
1094 | 1149 | } |
1095 | 1150 | |
1096 | - } |
|
1097 | - elseif(!empty($hideprices)) { |
|
1151 | + } elseif(!empty($hideprices)) { |
|
1098 | 1152 | $this->resprints = $object->lines[$parameters['i']]->qty; |
1099 | 1153 | return 1; |
1100 | - } |
|
1101 | - elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY)) |
|
1154 | + } elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY)) |
|
1102 | 1155 | { |
1103 | 1156 | $hideInnerLines = (int)GETPOST('hideInnerLines'); |
1104 | 1157 | $hidedetails = (int)GETPOST('hidedetails'); |
@@ -1108,12 +1161,20 @@ discard block |
||
1108 | 1161 | } |
1109 | 1162 | } |
1110 | 1163 | |
1111 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1112 | - else $i = (int)$parameters; |
|
1164 | + if(is_array($parameters)) { |
|
1165 | + $i = & $parameters['i']; |
|
1166 | + } else { |
|
1167 | + $i = (int)$parameters; |
|
1168 | + } |
|
1113 | 1169 | |
1114 | - if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) |
|
1170 | + if (empty($object->lines[$i])) { |
|
1171 | + return 0; |
|
1172 | + } |
|
1173 | + // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) |
|
1115 | 1174 | |
1116 | - if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals(); |
|
1175 | + if(empty($object->lines[$i]->array_options)) { |
|
1176 | + $object->lines[$i]->fetch_optionals(); |
|
1177 | + } |
|
1117 | 1178 | |
1118 | 1179 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
1119 | 1180 | { |
@@ -1130,8 +1191,11 @@ discard block |
||
1130 | 1191 | function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') { |
1131 | 1192 | global $conf, $hideprices, $hookmanager; |
1132 | 1193 | |
1133 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1134 | - else $i = (int)$parameters; |
|
1194 | + if(is_array($parameters)) { |
|
1195 | + $i = & $parameters['i']; |
|
1196 | + } else { |
|
1197 | + $i = (int)$parameters; |
|
1198 | + } |
|
1135 | 1199 | |
1136 | 1200 | if($this->isModSubtotalLine($parameters,$object) ){ |
1137 | 1201 | |
@@ -1139,13 +1203,11 @@ discard block |
||
1139 | 1203 | |
1140 | 1204 | if((float)DOL_VERSION<=3.6) { |
1141 | 1205 | return ''; |
1142 | - } |
|
1143 | - else if((float)DOL_VERSION>=3.8) { |
|
1206 | + } else if((float)DOL_VERSION>=3.8) { |
|
1144 | 1207 | return 1; |
1145 | 1208 | } |
1146 | 1209 | |
1147 | - } |
|
1148 | - elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS)) |
|
1210 | + } elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS)) |
|
1149 | 1211 | { |
1150 | 1212 | if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
1151 | 1213 | { |
@@ -1217,12 +1279,10 @@ discard block |
||
1217 | 1279 | $this->error = $hookmanager->error; |
1218 | 1280 | $this->errors = $hookmanager->errors; |
1219 | 1281 | return -1; |
1220 | - } |
|
1221 | - elseif (empty($reshook)) |
|
1282 | + } elseif (empty($reshook)) |
|
1222 | 1283 | { |
1223 | 1284 | $this->resprints .= $hookmanager->resprints; |
1224 | - } |
|
1225 | - else |
|
1285 | + } else |
|
1226 | 1286 | { |
1227 | 1287 | $this->resprints = $hookmanager->resprints; |
1228 | 1288 | |
@@ -1245,14 +1305,16 @@ discard block |
||
1245 | 1305 | |
1246 | 1306 | if((float)DOL_VERSION<=3.6) { |
1247 | 1307 | return ''; |
1248 | - } |
|
1249 | - else if((float)DOL_VERSION>=3.8) { |
|
1308 | + } else if((float)DOL_VERSION>=3.8) { |
|
1250 | 1309 | return 1; |
1251 | 1310 | } |
1252 | 1311 | } |
1253 | 1312 | |
1254 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1255 | - else $i = (int)$parameters; |
|
1313 | + if(is_array($parameters)) { |
|
1314 | + $i = & $parameters['i']; |
|
1315 | + } else { |
|
1316 | + $i = (int)$parameters; |
|
1317 | + } |
|
1256 | 1318 | |
1257 | 1319 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
1258 | 1320 | { |
@@ -1274,14 +1336,16 @@ discard block |
||
1274 | 1336 | |
1275 | 1337 | if((float)DOL_VERSION<=3.6) { |
1276 | 1338 | return ''; |
1277 | - } |
|
1278 | - else if((float)DOL_VERSION>=3.8) { |
|
1339 | + } else if((float)DOL_VERSION>=3.8) { |
|
1279 | 1340 | return 1; |
1280 | 1341 | } |
1281 | 1342 | } |
1282 | 1343 | |
1283 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1284 | - else $i = (int)$parameters; |
|
1344 | + if(is_array($parameters)) { |
|
1345 | + $i = & $parameters['i']; |
|
1346 | + } else { |
|
1347 | + $i = (int)$parameters; |
|
1348 | + } |
|
1285 | 1349 | |
1286 | 1350 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
1287 | 1351 | { |
@@ -1298,8 +1362,11 @@ discard block |
||
1298 | 1362 | function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') { |
1299 | 1363 | global $conf,$hideprices,$hookmanager; |
1300 | 1364 | |
1301 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1302 | - else $i = (int)$parameters; |
|
1365 | + if(is_array($parameters)) { |
|
1366 | + $i = & $parameters['i']; |
|
1367 | + } else { |
|
1368 | + $i = (int)$parameters; |
|
1369 | + } |
|
1303 | 1370 | |
1304 | 1371 | if($this->isModSubtotalLine($parameters,$object) ) { |
1305 | 1372 | $this->resprints = ' '; |
@@ -1318,8 +1385,7 @@ discard block |
||
1318 | 1385 | |
1319 | 1386 | if((float)DOL_VERSION<=3.6) { |
1320 | 1387 | return ''; |
1321 | - } |
|
1322 | - else if((float)DOL_VERSION>=3.8) { |
|
1388 | + } else if((float)DOL_VERSION>=3.8) { |
|
1323 | 1389 | return 1; |
1324 | 1390 | } |
1325 | 1391 | } |
@@ -1364,8 +1430,11 @@ discard block |
||
1364 | 1430 | function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') { |
1365 | 1431 | global $conf,$hideprices,$hookmanager; |
1366 | 1432 | |
1367 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1368 | - else $i = (int) $parameters; |
|
1433 | + if(is_array($parameters)) { |
|
1434 | + $i = & $parameters['i']; |
|
1435 | + } else { |
|
1436 | + $i = (int) $parameters; |
|
1437 | + } |
|
1369 | 1438 | |
1370 | 1439 | if($this->isModSubtotalLine($parameters,$object) ) { |
1371 | 1440 | $this->resprints = ' '; |
@@ -1384,8 +1453,7 @@ discard block |
||
1384 | 1453 | |
1385 | 1454 | if((float)DOL_VERSION<=3.6) { |
1386 | 1455 | return ''; |
1387 | - } |
|
1388 | - else if((float)DOL_VERSION>=3.8) { |
|
1456 | + } else if((float)DOL_VERSION>=3.8) { |
|
1389 | 1457 | return 1; |
1390 | 1458 | } |
1391 | 1459 | } |
@@ -1400,14 +1468,16 @@ discard block |
||
1400 | 1468 | $this->resprints = ' '; |
1401 | 1469 | if((float)DOL_VERSION<=3.6) { |
1402 | 1470 | return ''; |
1403 | - } |
|
1404 | - else if((float)DOL_VERSION>=3.8) { |
|
1471 | + } else if((float)DOL_VERSION>=3.8) { |
|
1405 | 1472 | return 1; |
1406 | 1473 | } |
1407 | 1474 | } |
1408 | 1475 | |
1409 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1410 | - else $i = (int)$parameters; |
|
1476 | + if(is_array($parameters)) { |
|
1477 | + $i = & $parameters['i']; |
|
1478 | + } else { |
|
1479 | + $i = (int)$parameters; |
|
1480 | + } |
|
1411 | 1481 | |
1412 | 1482 | if (!empty($hideprices) |
1413 | 1483 | || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
@@ -1431,16 +1501,21 @@ discard block |
||
1431 | 1501 | |
1432 | 1502 | if((float)DOL_VERSION<=3.6) { |
1433 | 1503 | return ''; |
1434 | - } |
|
1435 | - else if((float)DOL_VERSION>=3.8) { |
|
1504 | + } else if((float)DOL_VERSION>=3.8) { |
|
1436 | 1505 | return 1; |
1437 | 1506 | } |
1438 | 1507 | } |
1439 | 1508 | |
1440 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1441 | - else $i = (int)$parameters; |
|
1509 | + if(is_array($parameters)) { |
|
1510 | + $i = & $parameters['i']; |
|
1511 | + } else { |
|
1512 | + $i = (int)$parameters; |
|
1513 | + } |
|
1442 | 1514 | |
1443 | - if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) |
|
1515 | + if (empty($object->lines[$i])) { |
|
1516 | + return 0; |
|
1517 | + } |
|
1518 | + // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) |
|
1444 | 1519 | |
1445 | 1520 | $object->lines[$i]->fetch_optionals(); |
1446 | 1521 | // Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché |
@@ -1486,14 +1561,16 @@ discard block |
||
1486 | 1561 | $this->resprints = ' '; |
1487 | 1562 | if((float)DOL_VERSION<=3.6) { |
1488 | 1563 | return ''; |
1489 | - } |
|
1490 | - else if((float)DOL_VERSION>=3.8) { |
|
1564 | + } else if((float)DOL_VERSION>=3.8) { |
|
1491 | 1565 | return 1; |
1492 | 1566 | } |
1493 | 1567 | } |
1494 | 1568 | |
1495 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1496 | - else $i = (int)$parameters; |
|
1569 | + if(is_array($parameters)) { |
|
1570 | + $i = & $parameters['i']; |
|
1571 | + } else { |
|
1572 | + $i = (int)$parameters; |
|
1573 | + } |
|
1497 | 1574 | |
1498 | 1575 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
1499 | 1576 | { |
@@ -1523,7 +1600,9 @@ discard block |
||
1523 | 1600 | } |
1524 | 1601 | } |
1525 | 1602 | |
1526 | - if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle); |
|
1603 | + if (!empty($TLineTitle)) { |
|
1604 | + $TTitleNumeroted = $this->formatNumerotation($TLineTitle); |
|
1605 | + } |
|
1527 | 1606 | } |
1528 | 1607 | |
1529 | 1608 | } |
@@ -1537,8 +1616,12 @@ discard block |
||
1537 | 1616 | $j=0; |
1538 | 1617 | foreach ($TLineTitle as $k => &$line) |
1539 | 1618 | { |
1540 | - if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue; |
|
1541 | - if (!empty($line_reference) && $line->qty <= $line_reference->qty) break; |
|
1619 | + if (!empty($line_reference) && $line->rang <= $line_reference->rang) { |
|
1620 | + continue; |
|
1621 | + } |
|
1622 | + if (!empty($line_reference) && $line->qty <= $line_reference->qty) { |
|
1623 | + break; |
|
1624 | + } |
|
1542 | 1625 | |
1543 | 1626 | if ($line->qty == $level) |
1544 | 1627 | { |
@@ -1572,7 +1655,9 @@ discard block |
||
1572 | 1655 | |
1573 | 1656 | $hidedetails = (int)GETPOST('hidedetails'); |
1574 | 1657 | |
1575 | - if(empty($hidedetails)) return false; |
|
1658 | + if(empty($hidedetails)) { |
|
1659 | + return false; |
|
1660 | + } |
|
1576 | 1661 | |
1577 | 1662 | // TODO can't add VAT to document without lines... :-/ |
1578 | 1663 | |
@@ -1633,7 +1718,9 @@ discard block |
||
1633 | 1718 | */ |
1634 | 1719 | list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1); |
1635 | 1720 | |
1636 | - if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TTotal_tva; |
|
1721 | + if (TSubtotal::getNiveau($line) == 1) { |
|
1722 | + $line->TTotal_tva = $TTotal_tva; |
|
1723 | + } |
|
1637 | 1724 | $line->total_ht = $total; |
1638 | 1725 | $line->total_tva = $total_tva; |
1639 | 1726 | $line->total = $line->total_ht; |
@@ -1697,8 +1784,7 @@ discard block |
||
1697 | 1784 | } |
1698 | 1785 | |
1699 | 1786 | |
1700 | - } |
|
1701 | - elseif ($hidedetails) |
|
1787 | + } elseif ($hidedetails) |
|
1702 | 1788 | { |
1703 | 1789 | $TLines[] = $line; //Cas où je cache uniquement les prix des produits |
1704 | 1790 | } |
@@ -1769,7 +1855,9 @@ discard block |
||
1769 | 1855 | |
1770 | 1856 | if(!empty($hideprices)) { |
1771 | 1857 | foreach($object->lines as &$line) { |
1772 | - if($line->fk_product_type!=9) $line->fk_parent_line = -1; |
|
1858 | + if($line->fk_product_type!=9) { |
|
1859 | + $line->fk_parent_line = -1; |
|
1860 | + } |
|
1773 | 1861 | } |
1774 | 1862 | } |
1775 | 1863 | |
@@ -1790,7 +1878,9 @@ discard block |
||
1790 | 1878 | |
1791 | 1879 | if($line->qty>90) { |
1792 | 1880 | |
1793 | - if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) $label .= ' '.$this->getTitle($object, $line); |
|
1881 | + if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) { |
|
1882 | + $label .= ' '.$this->getTitle($object, $line); |
|
1883 | + } |
|
1794 | 1884 | |
1795 | 1885 | $pageBefore = $pdf->getPage(); |
1796 | 1886 | $this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); |
@@ -1808,8 +1898,7 @@ discard block |
||
1808 | 1898 | |
1809 | 1899 | $posy = $pdf->GetY(); |
1810 | 1900 | return 1; |
1811 | - } |
|
1812 | - else if ($line->qty < 10) { |
|
1901 | + } else if ($line->qty < 10) { |
|
1813 | 1902 | $pageBefore = $pdf->getPage(); |
1814 | 1903 | |
1815 | 1904 | $this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); |
@@ -1833,8 +1922,7 @@ discard block |
||
1833 | 1922 | // if($line->rowid==47) exit; |
1834 | 1923 | |
1835 | 1924 | return 0; |
1836 | - } |
|
1837 | - elseif (empty($object->lines[$parameters['i']])) |
|
1925 | + } elseif (empty($object->lines[$parameters['i']])) |
|
1838 | 1926 | { |
1839 | 1927 | $this->resprints = -1; |
1840 | 1928 | } |
@@ -1867,7 +1955,9 @@ discard block |
||
1867 | 1955 | |
1868 | 1956 | foreach ($object->lines as $line) |
1869 | 1957 | { |
1870 | - if ($line->id == $currentLine->id) break; |
|
1958 | + if ($line->id == $currentLine->id) { |
|
1959 | + break; |
|
1960 | + } |
|
1871 | 1961 | |
1872 | 1962 | $qty_search = 100 - $currentLine->qty; |
1873 | 1963 | |
@@ -1904,23 +1994,23 @@ discard block |
||
1904 | 1994 | { |
1905 | 1995 | $object->statut = 0; // hack for facture rec |
1906 | 1996 | $createRight = $user->rights->facture->creer; |
1907 | - } |
|
1908 | - elseif($object->element == 'order_supplier' ) |
|
1997 | + } elseif($object->element == 'order_supplier' ) |
|
1909 | 1998 | { |
1910 | 1999 | $createRight = $user->rights->fournisseur->commande->creer; |
1911 | - } |
|
1912 | - elseif($object->element == 'invoice_supplier' ) |
|
2000 | + } elseif($object->element == 'invoice_supplier' ) |
|
1913 | 2001 | { |
1914 | 2002 | $createRight = $user->rights->fournisseur->facture->creer; |
1915 | 2003 | } |
1916 | 2004 | |
1917 | 2005 | if($line->special_code!=$this->module_number || $line->product_type!=9) { |
1918 | 2006 | null; |
1919 | - } |
|
1920 | - else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) |
|
2007 | + } else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) |
|
1921 | 2008 | { |
1922 | - if($object->element=='facture')$idvar = 'facid'; |
|
1923 | - else $idvar='id'; |
|
2009 | + if($object->element=='facture') { |
|
2010 | + $idvar = 'facid'; |
|
2011 | + } else { |
|
2012 | + $idvar='id'; |
|
2013 | + } |
|
1924 | 2014 | |
1925 | 2015 | if((float)DOL_VERSION <= 3.4) |
1926 | 2016 | { |
@@ -1946,20 +2036,44 @@ discard block |
||
1946 | 2036 | <?php |
1947 | 2037 | } |
1948 | 2038 | |
1949 | - if(empty($line->description)) $line->description = $line->desc; |
|
2039 | + if(empty($line->description)) { |
|
2040 | + $line->description = $line->desc; |
|
2041 | + } |
|
1950 | 2042 | |
1951 | 2043 | $colspan = 5; |
1952 | - if($object->element == 'facturerec' ) $colspan = 3; |
|
1953 | - if($object->element == 'order_supplier') $colspan = 3; |
|
1954 | - if($object->element == 'invoice_supplier') $colspan = 4; |
|
1955 | - if($object->element == 'supplier_proposal') $colspan = 4; |
|
1956 | - if(!empty($conf->multicurrency->enabled)) $colspan+=2; |
|
1957 | - if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++; |
|
1958 | - if(!empty($conf->margin->enabled)) $colspan++; |
|
1959 | - if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; |
|
1960 | - if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; |
|
1961 | - if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++; |
|
1962 | - if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++; |
|
2044 | + if($object->element == 'facturerec' ) { |
|
2045 | + $colspan = 3; |
|
2046 | + } |
|
2047 | + if($object->element == 'order_supplier') { |
|
2048 | + $colspan = 3; |
|
2049 | + } |
|
2050 | + if($object->element == 'invoice_supplier') { |
|
2051 | + $colspan = 4; |
|
2052 | + } |
|
2053 | + if($object->element == 'supplier_proposal') { |
|
2054 | + $colspan = 4; |
|
2055 | + } |
|
2056 | + if(!empty($conf->multicurrency->enabled)) { |
|
2057 | + $colspan+=2; |
|
2058 | + } |
|
2059 | + if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) { |
|
2060 | + $colspan++; |
|
2061 | + } |
|
2062 | + if(!empty($conf->margin->enabled)) { |
|
2063 | + $colspan++; |
|
2064 | + } |
|
2065 | + if(!empty($conf->global->DISPLAY_MARGIN_RATES)) { |
|
2066 | + $colspan++; |
|
2067 | + } |
|
2068 | + if(!empty($conf->global->DISPLAY_MARK_RATES)) { |
|
2069 | + $colspan++; |
|
2070 | + } |
|
2071 | + if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) { |
|
2072 | + $colspan++; |
|
2073 | + } |
|
2074 | + if(!empty($conf->global->PRODUCT_USE_UNITS)) { |
|
2075 | + $colspan++; |
|
2076 | + } |
|
1963 | 2077 | |
1964 | 2078 | /* Titre */ |
1965 | 2079 | //var_dump($line); |
@@ -1972,23 +2086,36 @@ discard block |
||
1972 | 2086 | <tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php |
1973 | 2087 | if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT)) |
1974 | 2088 | { |
1975 | - if($line->qty==99) print 'background:#adadcf'; |
|
1976 | - else if($line->qty==98) print 'background:#ddddff;'; |
|
1977 | - else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;'; |
|
1978 | - else if($line->qty==1) print 'background:#adadcf;'; |
|
1979 | - else if($line->qty==2) print 'background:#ddddff;'; |
|
1980 | - else if($line->qty==50) print ''; |
|
1981 | - else print 'background:#eeeeff;'; |
|
2089 | + if($line->qty==99) { |
|
2090 | + print 'background:#adadcf'; |
|
2091 | + } else if($line->qty==98) { |
|
2092 | + print 'background:#ddddff;'; |
|
2093 | + } else if($line->qty<=97 && $line->qty>=91) { |
|
2094 | + print 'background:#eeeeff;'; |
|
2095 | + } else if($line->qty==1) { |
|
2096 | + print 'background:#adadcf;'; |
|
2097 | + } else if($line->qty==2) { |
|
2098 | + print 'background:#ddddff;'; |
|
2099 | + } else if($line->qty==50) { |
|
2100 | + print ''; |
|
2101 | + } else { |
|
2102 | + print 'background:#eeeeff;'; |
|
2103 | + } |
|
1982 | 2104 | |
1983 | 2105 | //A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9 |
1984 | - } |
|
1985 | - else |
|
2106 | + } else |
|
1986 | 2107 | { |
1987 | - if($line->qty==99) print 'background:#ddffdd'; |
|
1988 | - else if($line->qty==98) print 'background:#ddddff;'; |
|
1989 | - else if($line->qty==2) print 'background:#eeeeff; '; |
|
1990 | - else if($line->qty==50) print ''; |
|
1991 | - else print 'background:#eeffee;' ; |
|
2108 | + if($line->qty==99) { |
|
2109 | + print 'background:#ddffdd'; |
|
2110 | + } else if($line->qty==98) { |
|
2111 | + print 'background:#ddddff;'; |
|
2112 | + } else if($line->qty==2) { |
|
2113 | + print 'background:#eeeeff; '; |
|
2114 | + } else if($line->qty==50) { |
|
2115 | + print ''; |
|
2116 | + } else { |
|
2117 | + print 'background:#eeffee;' ; |
|
2118 | + } |
|
1992 | 2119 | } |
1993 | 2120 | |
1994 | 2121 | ?>;"> |
@@ -2011,13 +2138,11 @@ discard block |
||
2011 | 2138 | $qty_displayed = $line->qty; |
2012 | 2139 | print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span> '; |
2013 | 2140 | |
2014 | - } |
|
2015 | - else if (TSubtotal::isSubtotal($line)) |
|
2141 | + } else if (TSubtotal::isSubtotal($line)) |
|
2016 | 2142 | { |
2017 | 2143 | $qty_displayed = 100 - $line->qty; |
2018 | 2144 | print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span> '; |
2019 | - } |
|
2020 | - else |
|
2145 | + } else |
|
2021 | 2146 | { |
2022 | 2147 | $isFreeText = true; |
2023 | 2148 | } |
@@ -2038,9 +2163,13 @@ discard block |
||
2038 | 2163 | } |
2039 | 2164 | |
2040 | 2165 | $readonlyForSituation = ''; |
2041 | - if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) $readonlyForSituation = 'readonly'; |
|
2166 | + if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) { |
|
2167 | + $readonlyForSituation = 'readonly'; |
|
2168 | + } |
|
2042 | 2169 | |
2043 | - if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/> '; |
|
2170 | + if (!$isFreeText) { |
|
2171 | + echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/> '; |
|
2172 | + } |
|
2044 | 2173 | |
2045 | 2174 | if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) ) |
2046 | 2175 | { |
@@ -2048,8 +2177,12 @@ discard block |
||
2048 | 2177 | for ($j=1; $j<10; $j++) |
2049 | 2178 | { |
2050 | 2179 | if (!empty($readonlyForSituation)) { |
2051 | - if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
2052 | - } else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
2180 | + if ($qty_displayed == $j) { |
|
2181 | + $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
2182 | + } |
|
2183 | + } else { |
|
2184 | + $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
2185 | + } |
|
2053 | 2186 | } |
2054 | 2187 | $select .= '</select> '; |
2055 | 2188 | |
@@ -2069,7 +2202,9 @@ discard block |
||
2069 | 2202 | echo '<div>'; |
2070 | 2203 | echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>'; |
2071 | 2204 | echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>'; |
2072 | - if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true)); |
|
2205 | + if (empty($readonlyForSituation)) { |
|
2206 | + echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true)); |
|
2207 | + } |
|
2073 | 2208 | echo '</select>'; |
2074 | 2209 | echo '</div>'; |
2075 | 2210 | |
@@ -2088,8 +2223,9 @@ discard block |
||
2088 | 2223 | echo '<input style="vertical-align:sub;" type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' /> '; |
2089 | 2224 | echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>'; |
2090 | 2225 | echo '</div>'; |
2226 | + } else if ($isFreeText) { |
|
2227 | + echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation); |
|
2091 | 2228 | } |
2092 | - else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation); |
|
2093 | 2229 | echo '</div>'; |
2094 | 2230 | |
2095 | 2231 | if($line->qty<10) { |
@@ -2109,8 +2245,7 @@ discard block |
||
2109 | 2245 | $doleditor->Create(); |
2110 | 2246 | } |
2111 | 2247 | |
2112 | - } |
|
2113 | - else { |
|
2248 | + } else { |
|
2114 | 2249 | |
2115 | 2250 | if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) |
2116 | 2251 | { |
@@ -2118,14 +2253,19 @@ discard block |
||
2118 | 2253 | { |
2119 | 2254 | echo str_repeat(' ', $line->qty-1); |
2120 | 2255 | |
2121 | - if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span> '; |
|
2122 | - else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span> '; |
|
2256 | + if (TSubtotal::isTitle($line)) { |
|
2257 | + print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span> '; |
|
2258 | + } else { |
|
2259 | + print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span> '; |
|
2260 | + } |
|
2123 | 2261 | } |
2124 | - } |
|
2125 | - else |
|
2262 | + } else |
|
2126 | 2263 | { |
2127 | - if($line->qty<=1) print img_picto('', 'subtotal@subtotal'); |
|
2128 | - else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').' '; |
|
2264 | + if($line->qty<=1) { |
|
2265 | + print img_picto('', 'subtotal@subtotal'); |
|
2266 | + } else if($line->qty==2) { |
|
2267 | + print img_picto('', 'subsubtotal@subtotal').' '; |
|
2268 | + } |
|
2129 | 2269 | } |
2130 | 2270 | |
2131 | 2271 | |
@@ -2135,21 +2275,26 @@ discard block |
||
2135 | 2275 | $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;'; |
2136 | 2276 | |
2137 | 2277 | if (empty($line->label)) { |
2138 | - if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print $line->description.' '.$this->getTitle($object, $line); |
|
2139 | - else print $line->description; |
|
2140 | - } |
|
2141 | - else { |
|
2278 | + if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) { |
|
2279 | + print $line->description.' '.$this->getTitle($object, $line); |
|
2280 | + } else { |
|
2281 | + print $line->description; |
|
2282 | + } |
|
2283 | + } else { |
|
2142 | 2284 | |
2143 | 2285 | if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) { |
2144 | 2286 | print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>'; |
2145 | - } |
|
2146 | - else{ |
|
2287 | + } else{ |
|
2147 | 2288 | print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>'; |
2148 | 2289 | } |
2149 | 2290 | |
2150 | 2291 | } |
2151 | - if($line->qty>90) print ' : '; |
|
2152 | - if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal'); |
|
2292 | + if($line->qty>90) { |
|
2293 | + print ' : '; |
|
2294 | + } |
|
2295 | + if($line->info_bits > 0) { |
|
2296 | + echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal'); |
|
2297 | + } |
|
2153 | 2298 | |
2154 | 2299 | |
2155 | 2300 | |
@@ -2186,11 +2331,12 @@ discard block |
||
2186 | 2331 | </script> |
2187 | 2332 | <?php |
2188 | 2333 | |
2189 | - } |
|
2190 | - else{ |
|
2334 | + } else{ |
|
2191 | 2335 | if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier') |
2192 | 2336 | { |
2193 | - if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>'; |
|
2337 | + if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) { |
|
2338 | + echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>'; |
|
2339 | + } |
|
2194 | 2340 | } |
2195 | 2341 | |
2196 | 2342 | if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) |
@@ -2259,7 +2405,9 @@ discard block |
||
2259 | 2405 | $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); |
2260 | 2406 | |
2261 | 2407 | $colspan+=3; $mode = 'view'; |
2262 | - if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit'; |
|
2408 | + if($action === 'editline' && $line->rowid == GETPOST('lineid')) { |
|
2409 | + $mode = 'edit'; |
|
2410 | + } |
|
2263 | 2411 | |
2264 | 2412 | $ex_element = $line->element; |
2265 | 2413 | $line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr |
@@ -2441,10 +2589,9 @@ discard block |
||
2441 | 2589 | |
2442 | 2590 | if(TSubtotal::isTitle($line)){ |
2443 | 2591 | $ThtmlData['data-issubtotal'] = 'title'; |
2444 | - }elseif(TSubtotal::isSubtotal($line)){ |
|
2592 | + } elseif(TSubtotal::isSubtotal($line)){ |
|
2445 | 2593 | $ThtmlData['data-issubtotal'] = 'subtotal'; |
2446 | - } |
|
2447 | - else{ |
|
2594 | + } else{ |
|
2448 | 2595 | $ThtmlData['data-issubtotal'] = 'freetext'; |
2449 | 2596 | } |
2450 | 2597 | |
@@ -2454,7 +2601,9 @@ discard block |
||
2454 | 2601 | |
2455 | 2602 | // hook |
2456 | 2603 | $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
2457 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
2604 | + if ($reshook < 0) { |
|
2605 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
2606 | + } |
|
2458 | 2607 | if ($reshook>0) |
2459 | 2608 | { |
2460 | 2609 | $ThtmlData = $hookmanager->resArray; |