@@ -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,7 +39,9 @@ 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 | */ |
@@ -46,16 +53,22 @@ discard block |
||
| 46 | 53 | /** |
| 47 | 54 | * @var $object Propal |
| 48 | 55 | */ |
| 49 | - 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); |
|
| 56 | + else if($object->element=='propal') { |
|
| 57 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
| 58 | + } |
|
| 50 | 59 | /** |
| 51 | 60 | * @var $object Propal Fournisseur |
| 52 | 61 | */ |
| 53 | - 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); |
|
| 62 | + else if($object->element=='supplier_proposal') { |
|
| 63 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
| 64 | + } |
|
| 54 | 65 | |
| 55 | 66 | /** |
| 56 | 67 | * @var $object Commande |
| 57 | 68 | */ |
| 58 | - 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); |
|
| 69 | + else if($object->element=='commande') { |
|
| 70 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label); |
|
| 71 | + } |
|
| 59 | 72 | /** |
| 60 | 73 | * @var $object Commande fournisseur |
| 61 | 74 | */ |
@@ -66,7 +79,9 @@ discard block |
||
| 66 | 79 | /** |
| 67 | 80 | * @var $object Facturerec |
| 68 | 81 | */ |
| 69 | - 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); |
|
| 82 | + else if($object->element=='facturerec') { |
|
| 83 | + $res = $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); |
|
| 84 | + } |
|
| 70 | 85 | |
| 71 | 86 | } |
| 72 | 87 | |
@@ -88,8 +103,9 @@ discard block |
||
| 88 | 103 | // Define output language |
| 89 | 104 | $outputlangs = $langs; |
| 90 | 105 | $newlang = GETPOST('lang_id', 'alpha'); |
| 91 | - if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) |
|
| 92 | - $newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang; |
|
| 106 | + if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { |
|
| 107 | + $newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang; |
|
| 108 | + } |
|
| 93 | 109 | if (! empty($newlang)) { |
| 94 | 110 | $outputlangs = new Translate("", $conf); |
| 95 | 111 | $outputlangs->setDefaultLang($newlang); |
@@ -98,13 +114,18 @@ discard block |
||
| 98 | 114 | $ret = $object->fetch($object->id); // Reload to get new records |
| 99 | 115 | if ((float) DOL_VERSION <= 3.6) |
| 100 | 116 | { |
| 101 | - if ($object->element == 'propal') propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 102 | - elseif ($object->element == 'commande') commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 103 | - elseif ($object->element == 'facture') facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 104 | - } |
|
| 105 | - else |
|
| 117 | + if ($object->element == 'propal') { |
|
| 118 | + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 119 | + } elseif ($object->element == 'commande') { |
|
| 120 | + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 121 | + } elseif ($object->element == 'facture') { |
|
| 122 | + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 123 | + } |
|
| 124 | + } else |
|
| 106 | 125 | { |
| 107 | - if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 126 | + if ($object->element!= 'facturerec') { |
|
| 127 | + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 128 | + } |
|
| 108 | 129 | } |
| 109 | 130 | } |
| 110 | 131 | } |
@@ -118,7 +139,9 @@ discard block |
||
| 118 | 139 | */ |
| 119 | 140 | public static function updateRang(&$object, $rang_start, $move_to=1) |
| 120 | 141 | { |
| 121 | - if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
|
| 142 | + if (!class_exists('GenericObject')) { |
|
| 143 | + require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
|
| 144 | + } |
|
| 122 | 145 | |
| 123 | 146 | $row=new GenericObject($object->db); |
| 124 | 147 | $row->table_element_line = $object->table_element_line; |
@@ -127,7 +150,9 @@ discard block |
||
| 127 | 150 | |
| 128 | 151 | foreach ($object->lines as &$line) |
| 129 | 152 | { |
| 130 | - if ($line->rang < $rang_start) continue; |
|
| 153 | + if ($line->rang < $rang_start) { |
|
| 154 | + continue; |
|
| 155 | + } |
|
| 131 | 156 | |
| 132 | 157 | $row->updateRangOfLine($line->id, $line->rang+$move_to); |
| 133 | 158 | } |
@@ -150,21 +175,28 @@ discard block |
||
| 150 | 175 | foreach ($TTitle_reverse as $k => $title_line) |
| 151 | 176 | { |
| 152 | 177 | $title_niveau = self::getNiveau($title_line); |
| 153 | - if ($title_niveau < $level_new_title) break; |
|
| 178 | + if ($title_niveau < $level_new_title) { |
|
| 179 | + break; |
|
| 180 | + } |
|
| 154 | 181 | |
| 155 | 182 | $rang_to_add = self::titleHasTotalLine($object, $title_line, true, true); |
| 156 | 183 | |
| 157 | 184 | if (is_numeric($rang_to_add)) |
| 158 | 185 | { |
| 159 | - if ($rang_to_add != -1) self::updateRang($object, $rang_to_add); |
|
| 186 | + if ($rang_to_add != -1) { |
|
| 187 | + self::updateRang($object, $rang_to_add); |
|
| 188 | + } |
|
| 160 | 189 | |
| 161 | 190 | self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add); |
| 162 | 191 | |
| 163 | 192 | $object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas) |
| 164 | 193 | if ($rang_to_add != -1) |
| 165 | 194 | { |
| 166 | - if (method_exists($object, 'fetch_lines')) $object->fetch_lines(); |
|
| 167 | - else $object->fetch($object->id); |
|
| 195 | + if (method_exists($object, 'fetch_lines')) { |
|
| 196 | + $object->fetch_lines(); |
|
| 197 | + } else { |
|
| 198 | + $object->fetch($object->id); |
|
| 199 | + } |
|
| 168 | 200 | } |
| 169 | 201 | } |
| 170 | 202 | } |
@@ -194,7 +226,9 @@ discard block |
||
| 194 | 226 | |
| 195 | 227 | foreach ($TTitle as $k => $title_line) |
| 196 | 228 | { |
| 197 | - if (self::titleHasTotalLine($object, $title_line)) unset($TTitle[$k]); |
|
| 229 | + if (self::titleHasTotalLine($object, $title_line)) { |
|
| 230 | + unset($TTitle[$k]); |
|
| 231 | + } |
|
| 198 | 232 | } |
| 199 | 233 | |
| 200 | 234 | return $TTitle; |
@@ -211,23 +245,41 @@ discard block |
||
| 211 | 245 | */ |
| 212 | 246 | public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false) |
| 213 | 247 | { |
| 214 | - if (empty($object->lines) || !is_array($object->lines)) return false; |
|
| 248 | + if (empty($object->lines) || !is_array($object->lines)) { |
|
| 249 | + return false; |
|
| 250 | + } |
|
| 215 | 251 | |
| 216 | 252 | $title_niveau = self::getNiveau($title_line); |
| 217 | 253 | foreach ($object->lines as &$line) |
| 218 | 254 | { |
| 219 | - if ($line->rang <= $title_line->rang) continue; |
|
| 220 | - 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 |
|
| 221 | - if (!self::isSubtotal($line)) continue; |
|
| 255 | + if ($line->rang <= $title_line->rang) { |
|
| 256 | + continue; |
|
| 257 | + } |
|
| 258 | + if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) { |
|
| 259 | + return false; |
|
| 260 | + } |
|
| 261 | + // 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 |
|
| 262 | + if (!self::isSubtotal($line)) { |
|
| 263 | + continue; |
|
| 264 | + } |
|
| 222 | 265 | |
| 223 | 266 | $subtotal_niveau = self::getNiveau($line); |
| 224 | 267 | |
| 225 | 268 | // Comparaison du niveau de la ligne de sous-total avec celui du titre |
| 226 | - if ($subtotal_niveau == $title_niveau) return true; // niveau égale => Ok mon titre a un sous-total |
|
| 227 | - elseif ($subtotal_niveau < $title_niveau) // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3) |
|
| 269 | + if ($subtotal_niveau == $title_niveau) { |
|
| 270 | + return true; |
|
| 271 | + } |
|
| 272 | + // niveau égale => Ok mon titre a un sous-total |
|
| 273 | + elseif ($subtotal_niveau < $title_niveau) { |
|
| 274 | + // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3) |
|
| 228 | 275 | { |
| 229 | - if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; // mode strict niveau pas égale donc faux |
|
| 230 | - else return true; // mode libre => OK je considère que mon titre à un sous-total |
|
| 276 | + if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; |
|
| 277 | + } |
|
| 278 | + // mode strict niveau pas égale donc faux |
|
| 279 | + else { |
|
| 280 | + return true; |
|
| 281 | + } |
|
| 282 | + // mode libre => OK je considère que mon titre à un sous-total |
|
| 231 | 283 | } |
| 232 | 284 | } |
| 233 | 285 | |
@@ -275,16 +327,19 @@ discard block |
||
| 275 | 327 | |
| 276 | 328 | foreach ($object->lines as &$l) |
| 277 | 329 | { |
| 278 | - if ($l->rang <= $line->rang) continue; |
|
| 279 | - elseif (self::isSubtotal($l) && self::getNiveau($l) == $line->qty) break; |
|
| 280 | - elseif (self::isModSubtotalLine($l)) continue; |
|
| 330 | + if ($l->rang <= $line->rang) { |
|
| 331 | + continue; |
|
| 332 | + } elseif (self::isSubtotal($l) && self::getNiveau($l) == $line->qty) { |
|
| 333 | + break; |
|
| 334 | + } elseif (self::isModSubtotalLine($l)) { |
|
| 335 | + continue; |
|
| 336 | + } |
|
| 281 | 337 | |
| 282 | 338 | if (!empty($l->array_options['options_subtotal_nc'])) |
| 283 | 339 | { |
| 284 | 340 | $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); |
| 285 | 341 | $TTot['total_options'] += $tabprice[0]; // total ht |
| 286 | - } |
|
| 287 | - else |
|
| 342 | + } else |
|
| 288 | 343 | { |
| 289 | 344 | $TTot['total_pa_ht'] += $l->pa_ht * $l->qty; |
| 290 | 345 | $TTot['total_ht'] += $l->total_ht; |
@@ -303,29 +358,41 @@ discard block |
||
| 303 | 358 | |
| 304 | 359 | public static function getOrderIdFromLineId(&$db, $fk_commandedet) |
| 305 | 360 | { |
| 306 | - if (empty($fk_commandedet)) return false; |
|
| 361 | + if (empty($fk_commandedet)) { |
|
| 362 | + return false; |
|
| 363 | + } |
|
| 307 | 364 | |
| 308 | 365 | $sql = 'SELECT fk_commande FROM '.MAIN_DB_PREFIX.'commandedet WHERE rowid = '.$fk_commandedet; |
| 309 | 366 | $resql = $db->query($sql); |
| 310 | 367 | |
| 311 | - if ($resql && ($row = $db->fetch_object($resql))) return $row->fk_commande; |
|
| 312 | - else return false; |
|
| 368 | + if ($resql && ($row = $db->fetch_object($resql))) { |
|
| 369 | + return $row->fk_commande; |
|
| 370 | + } else { |
|
| 371 | + return false; |
|
| 372 | + } |
|
| 313 | 373 | } |
| 314 | 374 | |
| 315 | 375 | public static function getLastLineOrderId(&$db, $fk_commande) |
| 316 | 376 | { |
| 317 | - if (empty($fk_commande)) return false; |
|
| 377 | + if (empty($fk_commande)) { |
|
| 378 | + return false; |
|
| 379 | + } |
|
| 318 | 380 | |
| 319 | 381 | $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'commandedet WHERE fk_commande = '.$fk_commande.' ORDER BY rang DESC LIMIT 1'; |
| 320 | 382 | $resql = $db->query($sql); |
| 321 | 383 | |
| 322 | - if ($resql && ($row = $db->fetch_object($resql))) return $row->rowid; |
|
| 323 | - else return false; |
|
| 384 | + if ($resql && ($row = $db->fetch_object($resql))) { |
|
| 385 | + return $row->rowid; |
|
| 386 | + } else { |
|
| 387 | + return false; |
|
| 388 | + } |
|
| 324 | 389 | } |
| 325 | 390 | |
| 326 | 391 | public static function getParentTitleOfLine(&$object, $i) |
| 327 | 392 | { |
| 328 | - if ($i <= 0) return false; |
|
| 393 | + if ($i <= 0) { |
|
| 394 | + return false; |
|
| 395 | + } |
|
| 329 | 396 | |
| 330 | 397 | $skip_title = 0; |
| 331 | 398 | // Je parcours les lignes précédentes |
@@ -344,8 +411,7 @@ discard block |
||
| 344 | 411 | //@INFO J'ai ma ligne titre qui contient ma ligne, par contre je check pas s'il y a un sous-total |
| 345 | 412 | return $line; |
| 346 | 413 | break; |
| 347 | - } |
|
| 348 | - elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99) |
|
| 414 | + } elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99) |
|
| 349 | 415 | { |
| 350 | 416 | // 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) |
| 351 | 417 | $skip_title++; |
@@ -360,7 +426,9 @@ discard block |
||
| 360 | 426 | $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9; |
| 361 | 427 | if($res && $level > -1) { |
| 362 | 428 | return $line->qty == $level; |
| 363 | - } else return $res; |
|
| 429 | + } else { |
|
| 430 | + return $res; |
|
| 431 | + } |
|
| 364 | 432 | |
| 365 | 433 | } |
| 366 | 434 | |
@@ -387,10 +455,14 @@ discard block |
||
| 387 | 455 | // editeur wysiwyg |
| 388 | 456 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
| 389 | 457 | $nbrows=ROWS_2; |
| 390 | - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
| 458 | + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) { |
|
| 459 | + $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
| 460 | + } |
|
| 391 | 461 | $enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); |
| 392 | 462 | $toolbarname='dolibarr_details'; |
| 393 | - if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; |
|
| 463 | + if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) { |
|
| 464 | + $toolbarname='dolibarr_notes'; |
|
| 465 | + } |
|
| 394 | 466 | $text = !empty($line->description)?$line->description:$line->label; |
| 395 | 467 | $doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly); |
| 396 | 468 | return $doleditor->Create(1); |
@@ -405,12 +477,10 @@ discard block |
||
| 405 | 477 | { |
| 406 | 478 | $object->statut = 0; // hack for facture rec |
| 407 | 479 | $createRight = $user->rights->facture->creer; |
| 408 | - } |
|
| 409 | - elseif($object->element == 'order_supplier' ) |
|
| 480 | + } elseif($object->element == 'order_supplier' ) |
|
| 410 | 481 | { |
| 411 | 482 | $createRight = $user->rights->fournisseur->commande->creer; |
| 412 | - } |
|
| 413 | - elseif($object->element == 'invoice_supplier' ) |
|
| 483 | + } elseif($object->element == 'invoice_supplier' ) |
|
| 414 | 484 | { |
| 415 | 485 | $createRight = $user->rights->fournisseur->facture->creer; |
| 416 | 486 | } |
@@ -483,8 +553,9 @@ discard block |
||
| 483 | 553 | |
| 484 | 554 | $TLineAdded[] = $object->line; |
| 485 | 555 | // Error from addline |
| 486 | - if ($res <= 0) break; |
|
| 487 | - else |
|
| 556 | + if ($res <= 0) { |
|
| 557 | + break; |
|
| 558 | + } else |
|
| 488 | 559 | { |
| 489 | 560 | $object->line_from = $line; |
| 490 | 561 | // Call trigger |
@@ -506,8 +577,7 @@ discard block |
||
| 506 | 577 | _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']); |
| 507 | 578 | } |
| 508 | 579 | return count($TLineAdded); |
| 509 | - } |
|
| 510 | - else |
|
| 580 | + } else |
|
| 511 | 581 | { |
| 512 | 582 | $object->db->rollback(); |
| 513 | 583 | return -1; |
@@ -523,10 +593,14 @@ discard block |
||
| 523 | 593 | global $langs; |
| 524 | 594 | |
| 525 | 595 | // Besoin de comparer sur les 2 formes d'écriture |
| 526 | - if (!$key_is_id) $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad)); |
|
| 596 | + if (!$key_is_id) { |
|
| 597 | + $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad)); |
|
| 598 | + } |
|
| 527 | 599 | |
| 528 | 600 | $TTitle_under_search = array(); |
| 529 | - if (!empty($under_title)) $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title)); |
|
| 601 | + if (!empty($under_title)) { |
|
| 602 | + $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title)); |
|
| 603 | + } |
|
| 530 | 604 | |
| 531 | 605 | $TLine = array(); |
| 532 | 606 | $add_line = false; |
@@ -536,28 +610,37 @@ discard block |
||
| 536 | 610 | { |
| 537 | 611 | if (!$under_title_found && !empty($TTitle_under_search)) |
| 538 | 612 | { |
| 539 | - if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true; |
|
| 540 | - } |
|
| 541 | - else |
|
| 613 | + if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) { |
|
| 614 | + $under_title_found = true; |
|
| 615 | + } |
|
| 616 | + } else |
|
| 542 | 617 | { |
| 543 | 618 | 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) ))) |
| 544 | 619 | { |
| 545 | - if ($key_is_id) $level = $line->qty; |
|
| 620 | + if ($key_is_id) { |
|
| 621 | + $level = $line->qty; |
|
| 622 | + } |
|
| 546 | 623 | |
| 547 | 624 | $add_line = true; |
| 548 | - if ($withBlockLine) $TLine[] = $line; |
|
| 625 | + if ($withBlockLine) { |
|
| 626 | + $TLine[] = $line; |
|
| 627 | + } |
|
| 549 | 628 | continue; |
| 550 | - } |
|
| 551 | - 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 |
|
| 629 | + } elseif ($add_line && $line->product_type == 9 && (100 - $line->qty == $level) ) { |
|
| 630 | + // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre |
|
| 552 | 631 | { |
| 553 | 632 | if ($withBlockLine) $TLine[] = $line; |
| 633 | + } |
|
| 554 | 634 | break; |
| 555 | 635 | } |
| 556 | 636 | |
| 557 | 637 | if ($add_line) |
| 558 | 638 | { |
| 559 | - if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue; |
|
| 560 | - else $TLine[] = $line; |
|
| 639 | + if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) { |
|
| 640 | + continue; |
|
| 641 | + } else { |
|
| 642 | + $TLine[] = $line; |
|
| 643 | + } |
|
| 561 | 644 | } |
| 562 | 645 | } |
| 563 | 646 | } |
@@ -591,7 +674,9 @@ discard block |
||
| 591 | 674 | |
| 592 | 675 | case 'order_supplier': |
| 593 | 676 | $object->special_code = SELF::$module_number; |
| 594 | - if (empty($desc)) $desc = $label; |
|
| 677 | + if (empty($desc)) { |
|
| 678 | + $desc = $label; |
|
| 679 | + } |
|
| 595 | 680 | $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); |
| 596 | 681 | break; |
| 597 | 682 | |
@@ -601,7 +686,9 @@ discard block |
||
| 601 | 686 | |
| 602 | 687 | case 'invoice_supplier': |
| 603 | 688 | $object->special_code = SELF::$module_number; |
| 604 | - if (empty($desc)) $desc = $label; |
|
| 689 | + if (empty($desc)) { |
|
| 690 | + $desc = $label; |
|
| 691 | + } |
|
| 605 | 692 | $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); |
| 606 | 693 | break; |
| 607 | 694 | |
@@ -618,8 +705,11 @@ discard block |
||
| 618 | 705 | break; |
| 619 | 706 | } |
| 620 | 707 | |
| 621 | - if ($res <= 0) $object->db->rollback(); |
|
| 622 | - else $object->db->commit(); |
|
| 708 | + if ($res <= 0) { |
|
| 709 | + $object->db->rollback(); |
|
| 710 | + } else { |
|
| 711 | + $object->db->commit(); |
|
| 712 | + } |
|
| 623 | 713 | |
| 624 | 714 | return $res; |
| 625 | 715 | } |
@@ -629,24 +719,20 @@ discard block |
||
| 629 | 719 | global $db, $object; |
| 630 | 720 | |
| 631 | 721 | $TTitle = array(); |
| 632 | - if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} |
|
| 633 | - else { |
|
| 722 | + if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} else { |
|
| 634 | 723 | if ($origin_line->element == 'propaldet') |
| 635 | 724 | { |
| 636 | 725 | $object = new Propal($db); |
| 637 | 726 | $object->fetch($origin_line->fk_propal); |
| 638 | - } |
|
| 639 | - else if ($origin_line->element == 'commandedet') |
|
| 727 | + } else if ($origin_line->element == 'commandedet') |
|
| 640 | 728 | { |
| 641 | 729 | $object = new Commande($db); |
| 642 | 730 | $object->fetch($origin_line->fk_commande); |
| 643 | - } |
|
| 644 | - else if ($origin_line->element == 'facturedet') |
|
| 731 | + } else if ($origin_line->element == 'facturedet') |
|
| 645 | 732 | { |
| 646 | 733 | $object = new Facture($db); |
| 647 | 734 | $object->fetch($origin_line->fk_facture); |
| 648 | - } |
|
| 649 | - else |
|
| 735 | + } else |
|
| 650 | 736 | { |
| 651 | 737 | return $TTitle; |
| 652 | 738 | } |
@@ -656,8 +742,11 @@ discard block |
||
| 656 | 742 | $i = 0; |
| 657 | 743 | foreach ($object->lines as &$line) |
| 658 | 744 | { |
| 659 | - if ($origin_line->id == $line->id) break; |
|
| 660 | - else $i++; |
|
| 745 | + if ($origin_line->id == $line->id) { |
|
| 746 | + break; |
|
| 747 | + } else { |
|
| 748 | + $i++; |
|
| 749 | + } |
|
| 661 | 750 | } |
| 662 | 751 | |
| 663 | 752 | $i--; // Skip la ligne d'origine |
@@ -672,35 +761,43 @@ discard block |
||
| 672 | 761 | if (self::isSubtotal($object->lines[$y])) |
| 673 | 762 | { |
| 674 | 763 | $next_title_lvl_to_skip = self::getNiveau($object->lines[$y]); |
| 675 | - } |
|
| 676 | - elseif (self::isTitle($object->lines[$y])) |
|
| 764 | + } elseif (self::isTitle($object->lines[$y])) |
|
| 677 | 765 | { |
| 678 | 766 | if ($object->lines[$y]->qty == $next_title_lvl_to_skip) |
| 679 | 767 | { |
| 680 | 768 | $next_title_lvl_to_skip = 0; |
| 681 | 769 | continue; |
| 682 | - } |
|
| 683 | - else |
|
| 770 | + } else |
|
| 684 | 771 | { |
| 685 | - if (empty($object->lines[$y]->array_options)) $object->lines[$y]->fetch_optionals(); |
|
| 772 | + if (empty($object->lines[$y]->array_options)) { |
|
| 773 | + $object->lines[$y]->fetch_optionals(); |
|
| 774 | + } |
|
| 686 | 775 | $TTitle[$object->lines[$y]->id] = $object->lines[$y]; |
| 687 | 776 | |
| 688 | - if ($object->lines[$y]->qty == 1) break; |
|
| 777 | + if ($object->lines[$y]->qty == 1) { |
|
| 778 | + break; |
|
| 779 | + } |
|
| 689 | 780 | } |
| 690 | 781 | } |
| 691 | 782 | } |
| 692 | 783 | } |
| 693 | 784 | |
| 694 | - if ($reverse) $TTitle = array_reverse($TTitle, true); |
|
| 785 | + if ($reverse) { |
|
| 786 | + $TTitle = array_reverse($TTitle, true); |
|
| 787 | + } |
|
| 695 | 788 | |
| 696 | 789 | return $TTitle; |
| 697 | 790 | } |
| 698 | 791 | |
| 699 | 792 | public static function getNiveau(&$line) |
| 700 | 793 | { |
| 701 | - if (self::isTitle($line)) return $line->qty; |
|
| 702 | - elseif (self::isSubtotal($line)) return 100 - $line->qty; |
|
| 703 | - else return 0; |
|
| 794 | + if (self::isTitle($line)) { |
|
| 795 | + return $line->qty; |
|
| 796 | + } elseif (self::isSubtotal($line)) { |
|
| 797 | + return 100 - $line->qty; |
|
| 798 | + } else { |
|
| 799 | + return 0; |
|
| 800 | + } |
|
| 704 | 801 | } |
| 705 | 802 | |
| 706 | 803 | /** |
@@ -725,10 +822,16 @@ discard block |
||
| 725 | 822 | $objmarge->marge_droite = 10; |
| 726 | 823 | |
| 727 | 824 | $objectref = dol_sanitizeFileName($object->ref); |
| 728 | - if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref; |
|
| 729 | - elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref; |
|
| 730 | - elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref; |
|
| 731 | - elseif ($object->element == 'facturerec') return; // no PDF for facturerec |
|
| 825 | + if ($object->element == 'propal') { |
|
| 826 | + $dir = $conf->propal->dir_output . '/' . $objectref; |
|
| 827 | + } elseif ($object->element == 'commande') { |
|
| 828 | + $dir = $conf->commande->dir_output . '/' . $objectref; |
|
| 829 | + } elseif ($object->element == 'facture') { |
|
| 830 | + $dir = $conf->facture->dir_output . '/' . $objectref; |
|
| 831 | + } elseif ($object->element == 'facturerec') { |
|
| 832 | + return; |
|
| 833 | + } |
|
| 834 | + // no PDF for facturerec |
|
| 732 | 835 | else |
| 733 | 836 | { |
| 734 | 837 | setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings'); |
@@ -763,7 +866,9 @@ discard block |
||
| 763 | 866 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
| 764 | 867 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
| 765 | 868 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
| 766 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 869 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
| 870 | + $pdf->SetCompression(false); |
|
| 871 | + } |
|
| 767 | 872 | |
| 768 | 873 | $pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right |
| 769 | 874 | |
@@ -773,7 +878,9 @@ discard block |
||
| 773 | 878 | |
| 774 | 879 | // New page |
| 775 | 880 | $pdf->AddPage(); |
| 776 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 881 | + if (! empty($tplidx)) { |
|
| 882 | + $pdf->useTemplate($tplidx); |
|
| 883 | + } |
|
| 777 | 884 | $pagenb++; |
| 778 | 885 | |
| 779 | 886 | |
@@ -829,8 +936,10 @@ discard block |
||
| 829 | 936 | { |
| 830 | 937 | $TTot['TTotal_tva_multicurrency'][$tx] += $amount; |
| 831 | 938 | } |
| 939 | + } else { |
|
| 940 | + $pdf->SetFont('','', $default_font_size - 1); |
|
| 832 | 941 | } |
| 833 | - else $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
| 942 | + // Into loop to work with multipage |
|
| 834 | 943 | |
| 835 | 944 | $pdf->SetTextColor(0,0,0); |
| 836 | 945 | |
@@ -852,9 +961,11 @@ discard block |
||
| 852 | 961 | $pdf->startTransaction(); |
| 853 | 962 | $pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true); |
| 854 | 963 | $pageposafter=$pdf->getPage(); |
| 855 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
| 964 | + if ($pageposafter > $pageposbefore) { |
|
| 965 | + // There is a pagebreak |
|
| 856 | 966 | { |
| 857 | 967 | $pdf->rollbackTransaction(true); |
| 968 | + } |
|
| 858 | 969 | $pageposafter=$pageposbefore; |
| 859 | 970 | //print $pageposafter.'-'.$pageposbefore;exit; |
| 860 | 971 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
@@ -863,23 +974,27 @@ discard block |
||
| 863 | 974 | $pageposafter=$pdf->getPage(); |
| 864 | 975 | $posyafter=$pdf->GetY(); |
| 865 | 976 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
| 866 | - if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) // There is no space left for total+free text |
|
| 977 | + if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) { |
|
| 978 | + // There is no space left for total+free text |
|
| 867 | 979 | { |
| 868 | 980 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
| 869 | 981 | { |
| 870 | 982 | $pdf->AddPage('','',true); |
| 871 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 872 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
| 983 | + } |
|
| 984 | + if (! empty($tplidx)) { |
|
| 985 | + $pdf->useTemplate($tplidx); |
|
| 986 | + } |
|
| 987 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
| 988 | + self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
| 989 | + } |
|
| 873 | 990 | $pdf->setPage($pageposafter+1); |
| 874 | 991 | } |
| 875 | - } |
|
| 876 | - else |
|
| 992 | + } else |
|
| 877 | 993 | { |
| 878 | 994 | // We found a page break |
| 879 | 995 | $showpricebeforepagebreak=0; |
| 880 | 996 | } |
| 881 | - } |
|
| 882 | - else // No pagebreak |
|
| 997 | + } else // No pagebreak |
|
| 883 | 998 | { |
| 884 | 999 | $pdf->commitTransaction(); |
| 885 | 1000 | } |
@@ -919,8 +1034,7 @@ discard block |
||
| 919 | 1034 | if ($pagenb == 1) |
| 920 | 1035 | { |
| 921 | 1036 | 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); |
| 922 | - } |
|
| 923 | - else |
|
| 1037 | + } else |
|
| 924 | 1038 | { |
| 925 | 1039 | 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); |
| 926 | 1040 | } |
@@ -928,7 +1042,9 @@ discard block |
||
| 928 | 1042 | $pagenb++; |
| 929 | 1043 | $pdf->setPage($pagenb); |
| 930 | 1044 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
| 931 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
| 1045 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
| 1046 | + self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
| 1047 | + } |
|
| 932 | 1048 | } |
| 933 | 1049 | } |
| 934 | 1050 | } |
@@ -938,8 +1054,7 @@ discard block |
||
| 938 | 1054 | { |
| 939 | 1055 | 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); |
| 940 | 1056 | $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
| 941 | - } |
|
| 942 | - else |
|
| 1057 | + } else |
|
| 943 | 1058 | { |
| 944 | 1059 | 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); |
| 945 | 1060 | $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
@@ -953,7 +1068,9 @@ discard block |
||
| 953 | 1068 | |
| 954 | 1069 | $pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file); |
| 955 | 1070 | |
| 956 | - if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) unlink($file); |
|
| 1071 | + if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) { |
|
| 1072 | + unlink($file); |
|
| 1073 | + } |
|
| 957 | 1074 | } |
| 958 | 1075 | |
| 959 | 1076 | private static function printLevel($objmarge, $pdf, $line, $curY, $posx_designation) |
@@ -996,8 +1113,7 @@ discard block |
||
| 996 | 1113 | { |
| 997 | 1114 | $height=pdf_getHeightForLogo($logo); |
| 998 | 1115 | $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto) |
| 999 | - } |
|
| 1000 | - else |
|
| 1116 | + } else |
|
| 1001 | 1117 | { |
| 1002 | 1118 | $pdf->SetTextColor(200,0,0); |
| 1003 | 1119 | $pdf->SetFont('','B',$default_font_size - 2); |
@@ -1006,8 +1122,7 @@ discard block |
||
| 1006 | 1122 | } |
| 1007 | 1123 | |
| 1008 | 1124 | $posy+=35; |
| 1009 | - } |
|
| 1010 | - else |
|
| 1125 | + } else |
|
| 1011 | 1126 | { |
| 1012 | 1127 | $text=$mysoc->name; |
| 1013 | 1128 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -1021,9 +1136,13 @@ discard block |
||
| 1021 | 1136 | $pdf->SetXY($objmarge->marge_gauche,$posy); |
| 1022 | 1137 | |
| 1023 | 1138 | $key = 'subtotalPropalTitle'; |
| 1024 | - if ($object->element == 'commande') $key = 'subtotalCommandeTitle'; |
|
| 1025 | - elseif ($object->element == 'facture') $key = 'subtotalInvoiceTitle'; |
|
| 1026 | - elseif ($object->element == 'facturerec') $key = 'subtotalInvoiceTitle'; |
|
| 1139 | + if ($object->element == 'commande') { |
|
| 1140 | + $key = 'subtotalCommandeTitle'; |
|
| 1141 | + } elseif ($object->element == 'facture') { |
|
| 1142 | + $key = 'subtotalInvoiceTitle'; |
|
| 1143 | + } elseif ($object->element == 'facturerec') { |
|
| 1144 | + $key = 'subtotalInvoiceTitle'; |
|
| 1145 | + } |
|
| 1027 | 1146 | |
| 1028 | 1147 | $pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L'); |
| 1029 | 1148 | |
@@ -1058,7 +1177,9 @@ discard block |
||
| 1058 | 1177 | |
| 1059 | 1178 | // Force to disable hidetop and hidebottom |
| 1060 | 1179 | $hidebottom=0; |
| 1061 | - if ($hidetop) $hidetop=-1; |
|
| 1180 | + if ($hidetop) { |
|
| 1181 | + $hidetop=-1; |
|
| 1182 | + } |
|
| 1062 | 1183 | |
| 1063 | 1184 | $currency = !empty($currency) ? $currency : $conf->currency; |
| 1064 | 1185 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
@@ -1073,7 +1194,9 @@ discard block |
||
| 1073 | 1194 | $pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5); |
| 1074 | 1195 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
| 1075 | 1196 | |
| 1076 | - 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)); |
|
| 1197 | + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { |
|
| 1198 | + $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)); |
|
| 1199 | + } |
|
| 1077 | 1200 | |
| 1078 | 1201 | |
| 1079 | 1202 | $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 |
@@ -1086,8 +1209,7 @@ discard block |
||
| 1086 | 1209 | $pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R'); |
| 1087 | 1210 | |
| 1088 | 1211 | $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 |
| 1089 | - } |
|
| 1090 | - else |
|
| 1212 | + } else |
|
| 1091 | 1213 | { |
| 1092 | 1214 | $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 |
| 1093 | 1215 | } |
@@ -1108,10 +1230,12 @@ discard block |
||
| 1108 | 1230 | |
| 1109 | 1231 | // Tableau total |
| 1110 | 1232 | $col1x = 120; $col2x = 170; |
| 1111 | - if ($objmarge->page_largeur < 210) // To work with US executive format |
|
| 1233 | + if ($objmarge->page_largeur < 210) { |
|
| 1234 | + // To work with US executive format |
|
| 1112 | 1235 | { |
| 1113 | 1236 | $col2x-=20; |
| 1114 | 1237 | } |
| 1238 | + } |
|
| 1115 | 1239 | $largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x); |
| 1116 | 1240 | |
| 1117 | 1241 | $useborder=0; |
@@ -1133,9 +1257,11 @@ discard block |
||
| 1133 | 1257 | $atleastoneratenotnull=0; |
| 1134 | 1258 | foreach($TTot['TTotal_tva'] as $tvakey => $tvaval) |
| 1135 | 1259 | { |
| 1136 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
| 1260 | + if ($tvakey != 0) { |
|
| 1261 | + // On affiche pas taux 0 |
|
| 1137 | 1262 | { |
| 1138 | 1263 | $atleastoneratenotnull++; |
| 1264 | + } |
|
| 1139 | 1265 | |
| 1140 | 1266 | $index++; |
| 1141 | 1267 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -1188,9 +1314,13 @@ discard block |
||
| 1188 | 1314 | */ |
| 1189 | 1315 | private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
| 1190 | 1316 | { |
| 1191 | - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
| 1317 | + if (empty($hidetop) || $hidetop==-1) { |
|
| 1318 | + $pdf->line($x, $y, $x+$l, $y); |
|
| 1319 | + } |
|
| 1192 | 1320 | $pdf->line($x+$l, $y, $x+$l, $y+$h); |
| 1193 | - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
| 1321 | + if (empty($hidebottom)) { |
|
| 1322 | + $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
| 1323 | + } |
|
| 1194 | 1324 | $pdf->line($x, $y+$h, $x, $y); |
| 1195 | 1325 | } |
| 1196 | 1326 | |
@@ -1199,7 +1329,9 @@ discard block |
||
| 1199 | 1329 | { |
| 1200 | 1330 | global $conf; |
| 1201 | 1331 | |
| 1202 | - if (empty($fileoutput)) $fileoutput = $file[0]; |
|
| 1332 | + if (empty($fileoutput)) { |
|
| 1333 | + $fileoutput = $file[0]; |
|
| 1334 | + } |
|
| 1203 | 1335 | |
| 1204 | 1336 | $pdf=pdf_getInstance(); |
| 1205 | 1337 | if (class_exists('TCPDF')) |
@@ -1209,7 +1341,9 @@ discard block |
||
| 1209 | 1341 | } |
| 1210 | 1342 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
| 1211 | 1343 | |
| 1212 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 1344 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
| 1345 | + $pdf->SetCompression(false); |
|
| 1346 | + } |
|
| 1213 | 1347 | |
| 1214 | 1348 | |
| 1215 | 1349 | foreach($files as $file) |
@@ -1225,7 +1359,9 @@ discard block |
||
| 1225 | 1359 | } |
| 1226 | 1360 | |
| 1227 | 1361 | $pdf->Output($fileoutput,'F'); |
| 1228 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 1362 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 1363 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 1364 | + } |
|
| 1229 | 1365 | |
| 1230 | 1366 | return $pagecount; |
| 1231 | 1367 | } |
@@ -1238,7 +1374,9 @@ discard block |
||
| 1238 | 1374 | */ |
| 1239 | 1375 | public static function hasNcTitle(&$line) |
| 1240 | 1376 | { |
| 1241 | - if(isset($line->has_nc_title)) return $line->has_nc_title; |
|
| 1377 | + if(isset($line->has_nc_title)) { |
|
| 1378 | + return $line->has_nc_title; |
|
| 1379 | + } |
|
| 1242 | 1380 | |
| 1243 | 1381 | $TTitle = self::getAllTitleFromLine($line); |
| 1244 | 1382 | foreach ($TTitle as &$line_title) |
@@ -1263,7 +1401,9 @@ discard block |
||
| 1263 | 1401 | public static function getTitleLabel($line) |
| 1264 | 1402 | { |
| 1265 | 1403 | $title = $line->label; |
| 1266 | - if (empty($title)) $title = !empty($line->description) ? $line->description : $line->desc; |
|
| 1404 | + if (empty($title)) { |
|
| 1405 | + $title = !empty($line->description) ? $line->description : $line->desc; |
|
| 1406 | + } |
|
| 1267 | 1407 | return $title; |
| 1268 | 1408 | } |
| 1269 | 1409 | } |
@@ -75,8 +75,11 @@ discard block |
||
| 75 | 75 | if ($object->statut == 0 && $createRight) { |
| 76 | 76 | |
| 77 | 77 | |
| 78 | - if($object->element=='facture')$idvar = 'facid'; |
|
| 79 | - else $idvar='id'; |
|
| 78 | + if($object->element=='facture') { |
|
| 79 | + $idvar = 'facid'; |
|
| 80 | + } else { |
|
| 81 | + $idvar='id'; |
|
| 82 | + } |
|
| 80 | 83 | |
| 81 | 84 | if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) ) |
| 82 | 85 | { |
@@ -84,10 +87,11 @@ discard block |
||
| 84 | 87 | |
| 85 | 88 | if($action=='add_title_line') { |
| 86 | 89 | $title = GETPOST('title'); |
| 87 | - if(empty($title)) $title = $langs->trans('title'); |
|
| 90 | + if(empty($title)) { |
|
| 91 | + $title = $langs->trans('title'); |
|
| 92 | + } |
|
| 88 | 93 | $qty = $level<1 ? 1 : $level ; |
| 89 | - } |
|
| 90 | - else if($action=='add_free_text') { |
|
| 94 | + } else if($action=='add_free_text') { |
|
| 91 | 95 | $title = GETPOST('title'); |
| 92 | 96 | |
| 93 | 97 | if (empty($title)) { |
@@ -99,29 +103,31 @@ discard block |
||
| 99 | 103 | } |
| 100 | 104 | } |
| 101 | 105 | } |
| 102 | - if(empty($title)) $title = $langs->trans('subtotalAddLineDescription'); |
|
| 106 | + if(empty($title)) { |
|
| 107 | + $title = $langs->trans('subtotalAddLineDescription'); |
|
| 108 | + } |
|
| 103 | 109 | $qty = 50; |
| 104 | - } |
|
| 105 | - else if($action=='add_subtitle_line') { |
|
| 110 | + } else if($action=='add_subtitle_line') { |
|
| 106 | 111 | $title = GETPOST('title'); |
| 107 | - if(empty($title)) $title = $langs->trans('subtitle'); |
|
| 112 | + if(empty($title)) { |
|
| 113 | + $title = $langs->trans('subtitle'); |
|
| 114 | + } |
|
| 108 | 115 | $qty = 2; |
| 109 | - } |
|
| 110 | - else if($action=='add_subtotal_line') { |
|
| 116 | + } else if($action=='add_subtotal_line') { |
|
| 111 | 117 | $title = $langs->trans('SubSubTotal'); |
| 112 | 118 | $qty = 98; |
| 113 | - } |
|
| 114 | - else { |
|
| 119 | + } else { |
|
| 115 | 120 | $title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal'); |
| 116 | 121 | $qty = $level ? 100-$level : 99; |
| 117 | 122 | } |
| 118 | 123 | dol_include_once('/subtotal/class/subtotal.class.php'); |
| 119 | 124 | |
| 120 | - if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty); |
|
| 125 | + if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) { |
|
| 126 | + TSubtotal::addSubtotalMissing($object, $qty); |
|
| 127 | + } |
|
| 121 | 128 | |
| 122 | 129 | TSubtotal::addSubTotalLine($object, $title, $qty); |
| 123 | - } |
|
| 124 | - else if($action==='ask_deleteallline') { |
|
| 130 | + } else if($action==='ask_deleteallline') { |
|
| 125 | 131 | $form=new Form($db); |
| 126 | 132 | |
| 127 | 133 | $lineid = GETPOST('lineid','integer'); |
@@ -144,8 +150,7 @@ discard block |
||
| 144 | 150 | $this->printNewFormat($object, $conf, $langs, $idvar); |
| 145 | 151 | } |
| 146 | 152 | } |
| 147 | - } |
|
| 148 | - elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts)) |
|
| 153 | + } elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts)) |
|
| 149 | 154 | { |
| 150 | 155 | ?> |
| 151 | 156 | <script type="text/javascript"> |
@@ -163,8 +168,13 @@ discard block |
||
| 163 | 168 | |
| 164 | 169 | function printNewFormat(&$object, &$conf, &$langs, $idvar) |
| 165 | 170 | { |
| 166 | - if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) return false; |
|
| 167 | - if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) return false; // Si facture de situation |
|
| 171 | + if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) { |
|
| 172 | + return false; |
|
| 173 | + } |
|
| 174 | + if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) { |
|
| 175 | + return false; |
|
| 176 | + } |
|
| 177 | + // Si facture de situation |
|
| 168 | 178 | ?> |
| 169 | 179 | <script type="text/javascript"> |
| 170 | 180 | $(document).ready(function() { |
@@ -449,8 +459,7 @@ discard block |
||
| 449 | 459 | } |
| 450 | 460 | |
| 451 | 461 | |
| 452 | - } |
|
| 453 | - else{ |
|
| 462 | + } else{ |
|
| 454 | 463 | $substitutionarray['line_not_modsubtotal'] = true; |
| 455 | 464 | $substitutionarray['line_modsubtotal'] = 0; |
| 456 | 465 | } |
@@ -508,8 +517,11 @@ discard block |
||
| 508 | 517 | |
| 509 | 518 | $showBlockExtrafields = GETPOST('showBlockExtrafields'); |
| 510 | 519 | |
| 511 | - if($object->element=='facture') $idvar = 'facid'; |
|
| 512 | - else $idvar = 'id'; |
|
| 520 | + if($object->element=='facture') { |
|
| 521 | + $idvar = 'facid'; |
|
| 522 | + } else { |
|
| 523 | + $idvar = 'id'; |
|
| 524 | + } |
|
| 513 | 525 | |
| 514 | 526 | if ($action == 'updateligne' || $action == 'updateline') |
| 515 | 527 | { |
@@ -539,8 +551,7 @@ discard block |
||
| 539 | 551 | header('Location: '.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id); |
| 540 | 552 | exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne |
| 541 | 553 | } |
| 542 | - } |
|
| 543 | - else if($action === 'builddoc') { |
|
| 554 | + } else if($action === 'builddoc') { |
|
| 544 | 555 | |
| 545 | 556 | if ( |
| 546 | 557 | in_array('invoicecard',explode(':',$parameters['context'])) |
@@ -555,33 +566,27 @@ discard block |
||
| 555 | 566 | $sessname = 'subtotal_hideInnerLines_facture'; |
| 556 | 567 | $sessname2 = 'subtotal_hidedetails_facture'; |
| 557 | 568 | $sessname3 = 'subtotal_hideprices_facture'; |
| 558 | - } |
|
| 559 | - elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) { |
|
| 569 | + } elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) { |
|
| 560 | 570 | $sessname = 'subtotal_hideInnerLines_facture_fournisseur'; |
| 561 | 571 | $sessname2 = 'subtotal_hidedetails_facture_fournisseur'; |
| 562 | 572 | $sessname3 = 'subtotal_hideprices_facture_fournisseur'; |
| 563 | - } |
|
| 564 | - elseif(in_array('propalcard',explode(':',$parameters['context']))) { |
|
| 573 | + } elseif(in_array('propalcard',explode(':',$parameters['context']))) { |
|
| 565 | 574 | $sessname = 'subtotal_hideInnerLines_propal'; |
| 566 | 575 | $sessname2 = 'subtotal_hidedetails_propal'; |
| 567 | 576 | $sessname3 = 'subtotal_hideprices_propal'; |
| 568 | - } |
|
| 569 | - elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) { |
|
| 577 | + } elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) { |
|
| 570 | 578 | $sessname = 'subtotal_hideInnerLines_supplier_proposal'; |
| 571 | 579 | $sessname2 = 'subtotal_hidedetails_supplier_proposal'; |
| 572 | 580 | $sessname3 = 'subtotal_hideprices_supplier_proposal'; |
| 573 | - } |
|
| 574 | - elseif(in_array('ordercard',explode(':',$parameters['context']))) { |
|
| 581 | + } elseif(in_array('ordercard',explode(':',$parameters['context']))) { |
|
| 575 | 582 | $sessname = 'subtotal_hideInnerLines_commande'; |
| 576 | 583 | $sessname2 = 'subtotal_hidedetails_commande'; |
| 577 | 584 | $sessname3 = 'subtotal_hideprices_commande'; |
| 578 | - } |
|
| 579 | - elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) { |
|
| 585 | + } elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) { |
|
| 580 | 586 | $sessname = 'subtotal_hideInnerLines_commande_fournisseur'; |
| 581 | 587 | $sessname2 = 'subtotal_hidedetails_commande_fournisseur'; |
| 582 | 588 | $sessname3 = 'subtotal_hideprices_commande_fournisseur'; |
| 583 | - } |
|
| 584 | - else { |
|
| 589 | + } else { |
|
| 585 | 590 | $sessname = 'subtotal_hideInnerLines_unknown'; |
| 586 | 591 | $sessname2 = 'subtotal_hidedetails_unknown'; |
| 587 | 592 | $sessname3 = 'subtotal_hideprices_unknown'; |
@@ -603,8 +608,7 @@ discard block |
||
| 603 | 608 | |
| 604 | 609 | if($line->qty>=90) { |
| 605 | 610 | $line->modsubtotal_total = 1; |
| 606 | - } |
|
| 607 | - else{ |
|
| 611 | + } else{ |
|
| 608 | 612 | $line->modsubtotal_title = 1; |
| 609 | 613 | } |
| 610 | 614 | |
@@ -613,8 +617,7 @@ discard block |
||
| 613 | 617 | } |
| 614 | 618 | } |
| 615 | 619 | |
| 616 | - } |
|
| 617 | - else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') { |
|
| 620 | + } else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') { |
|
| 618 | 621 | |
| 619 | 622 | $Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid')); |
| 620 | 623 | |
@@ -622,7 +625,9 @@ discard block |
||
| 622 | 625 | /** |
| 623 | 626 | * @var $object Facture |
| 624 | 627 | */ |
| 625 | - if($object->element=='facture') $object->deleteline($idLine); |
|
| 628 | + if($object->element=='facture') { |
|
| 629 | + $object->deleteline($idLine); |
|
| 630 | + } |
|
| 626 | 631 | /** |
| 627 | 632 | * @var $object Facture fournisseur |
| 628 | 633 | */ |
@@ -633,18 +638,25 @@ discard block |
||
| 633 | 638 | /** |
| 634 | 639 | * @var $object Propal |
| 635 | 640 | */ |
| 636 | - else if($object->element=='propal') $object->deleteline($idLine); |
|
| 641 | + else if($object->element=='propal') { |
|
| 642 | + $object->deleteline($idLine); |
|
| 643 | + } |
|
| 637 | 644 | /** |
| 638 | 645 | * @var $object Propal Fournisseur |
| 639 | 646 | */ |
| 640 | - else if($object->element=='supplier_proposal') $object->deleteline($idLine); |
|
| 647 | + else if($object->element=='supplier_proposal') { |
|
| 648 | + $object->deleteline($idLine); |
|
| 649 | + } |
|
| 641 | 650 | /** |
| 642 | 651 | * @var $object Commande |
| 643 | 652 | */ |
| 644 | 653 | else if($object->element=='commande') |
| 645 | 654 | { |
| 646 | - if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine); |
|
| 647 | - else $object->deleteline($idLine); |
|
| 655 | + if ((float) DOL_VERSION >= 5.0) { |
|
| 656 | + $object->deleteline($user, $idLine); |
|
| 657 | + } else { |
|
| 658 | + $object->deleteline($idLine); |
|
| 659 | + } |
|
| 648 | 660 | } |
| 649 | 661 | /** |
| 650 | 662 | * @var $object Commande fournisseur |
@@ -656,21 +668,26 @@ discard block |
||
| 656 | 668 | /** |
| 657 | 669 | * @var $object Facturerec |
| 658 | 670 | */ |
| 659 | - else if($object->element=='facturerec') $object->deleteline($idLine); |
|
| 671 | + else if($object->element=='facturerec') { |
|
| 672 | + $object->deleteline($idLine); |
|
| 673 | + } |
|
| 660 | 674 | } |
| 661 | 675 | |
| 662 | 676 | header('location:?id='.$object->id); |
| 663 | 677 | exit; |
| 664 | 678 | |
| 665 | - } |
|
| 666 | - else if ($action == 'duplicate') |
|
| 679 | + } else if ($action == 'duplicate') |
|
| 667 | 680 | { |
| 668 | 681 | $lineid = GETPOST('lineid', 'int'); |
| 669 | 682 | $nbDuplicate = TSubtotal::duplicateLines($object, $lineid, true); |
| 670 | 683 | |
| 671 | - if ($nbDuplicate > 0) setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate)); |
|
| 672 | - elseif ($nbDuplicate == 0) setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings'); |
|
| 673 | - else setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors'); |
|
| 684 | + if ($nbDuplicate > 0) { |
|
| 685 | + setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate)); |
|
| 686 | + } elseif ($nbDuplicate == 0) { |
|
| 687 | + setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings'); |
|
| 688 | + } else { |
|
| 689 | + setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors'); |
|
| 690 | + } |
|
| 674 | 691 | |
| 675 | 692 | header('Location: ?id='.$object->id); |
| 676 | 693 | exit; |
@@ -750,17 +767,18 @@ discard block |
||
| 750 | 767 | //print $l->rang.'>='.$rang.' '.$total.'<br/>'; |
| 751 | 768 | if($l->rang>=$rang) { |
| 752 | 769 | //echo 'return!<br>'; |
| 753 | - if (!$return_all) return $total; |
|
| 754 | - else return array($total, $total_tva, $total_ttc, $TTotal_tva); |
|
| 755 | - } |
|
| 756 | - else if(TSubtotal::isTitle($l, 100 - $qty_line)) |
|
| 770 | + if (!$return_all) { |
|
| 771 | + return $total; |
|
| 772 | + } else { |
|
| 773 | + return array($total, $total_tva, $total_ttc, $TTotal_tva); |
|
| 774 | + } |
|
| 775 | + } else if(TSubtotal::isTitle($l, 100 - $qty_line)) |
|
| 757 | 776 | { |
| 758 | 777 | $total = 0; |
| 759 | 778 | $total_tva = 0; |
| 760 | 779 | $total_ttc = 0; |
| 761 | 780 | $TTotal_tva = array(); |
| 762 | - } |
|
| 763 | - elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) { |
|
| 781 | + } elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) { |
|
| 764 | 782 | $total += $l->total_ht; |
| 765 | 783 | $total_tva += $l->total_tva; |
| 766 | 784 | $TTotal_tva[$l->tva_tx] += $l->total_tva; |
@@ -768,8 +786,11 @@ discard block |
||
| 768 | 786 | } |
| 769 | 787 | |
| 770 | 788 | } |
| 771 | - if (!$return_all) return $total; |
|
| 772 | - else return array($total, $total_tva, $total_ttc, $TTotal_tva); |
|
| 789 | + if (!$return_all) { |
|
| 790 | + return $total; |
|
| 791 | + } else { |
|
| 792 | + return array($total, $total_tva, $total_ttc, $TTotal_tva); |
|
| 793 | + } |
|
| 773 | 794 | } |
| 774 | 795 | |
| 775 | 796 | /* |
@@ -837,15 +858,18 @@ discard block |
||
| 837 | 858 | } |
| 838 | 859 | |
| 839 | 860 | |
| 840 | - if($line->qty==99) |
|
| 841 | - $pdf->SetFillColor(220,220,220); |
|
| 842 | - elseif ($line->qty==98) |
|
| 843 | - $pdf->SetFillColor(230,230,230); |
|
| 844 | - else |
|
| 845 | - $pdf->SetFillColor(240,240,240); |
|
| 861 | + if($line->qty==99) { |
|
| 862 | + $pdf->SetFillColor(220,220,220); |
|
| 863 | + } elseif ($line->qty==98) { |
|
| 864 | + $pdf->SetFillColor(230,230,230); |
|
| 865 | + } else { |
|
| 866 | + $pdf->SetFillColor(240,240,240); |
|
| 867 | + } |
|
| 846 | 868 | |
| 847 | 869 | $style = 'B'; |
| 848 | - if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE; |
|
| 870 | + if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) { |
|
| 871 | + $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE; |
|
| 872 | + } |
|
| 849 | 873 | |
| 850 | 874 | $pdf->SetFont('', $style, 9); |
| 851 | 875 | |
@@ -884,8 +908,7 @@ discard block |
||
| 884 | 908 | // $line->total_tva |
| 885 | 909 | // $line->total |
| 886 | 910 | // $line->total_ttc |
| 887 | - } |
|
| 888 | - else |
|
| 911 | + } else |
|
| 889 | 912 | { |
| 890 | 913 | list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1); |
| 891 | 914 | if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation |
@@ -902,11 +925,14 @@ discard block |
||
| 902 | 925 | } |
| 903 | 926 | |
| 904 | 927 | $pdf->SetXY($pdf->postotalht, $posy); |
| 905 | - if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); |
|
| 928 | + if($set_pagebreak_margin) { |
|
| 929 | + $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); |
|
| 930 | + } |
|
| 906 | 931 | $pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0); |
| 907 | - } |
|
| 908 | - else{ |
|
| 909 | - if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); |
|
| 932 | + } else{ |
|
| 933 | + if($set_pagebreak_margin) { |
|
| 934 | + $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); |
|
| 935 | + } |
|
| 910 | 936 | } |
| 911 | 937 | |
| 912 | 938 | $posy = $posy + $cell_height; |
@@ -938,25 +964,40 @@ discard block |
||
| 938 | 964 | |
| 939 | 965 | |
| 940 | 966 | $style = ($line->qty==1) ? 'BU' : 'BUI'; |
| 941 | - if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE; |
|
| 967 | + if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) { |
|
| 968 | + $style = $conf->global->SUBTOTAL_TITLE_STYLE; |
|
| 969 | + } |
|
| 942 | 970 | |
| 943 | 971 | if($hideInnerLines) { |
| 944 | - if($line->qty==1)$pdf->SetFont('', $style, 9); |
|
| 945 | - else |
|
| 972 | + if($line->qty==1) { |
|
| 973 | + $pdf->SetFont('', $style, 9); |
|
| 974 | + } else |
|
| 946 | 975 | { |
| 947 | - if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES; |
|
| 976 | + if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) { |
|
| 977 | + $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES; |
|
| 978 | + } |
|
| 948 | 979 | $pdf->SetFont('', $style, 9); |
| 949 | 980 | } |
| 950 | - } |
|
| 951 | - else { |
|
| 981 | + } else { |
|
| 952 | 982 | |
| 953 | - if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile |
|
| 954 | - else $pdf->SetFont('', $style, 9); |
|
| 983 | + if($line->qty==1) { |
|
| 984 | + $pdf->SetFont('', $style, 9); |
|
| 985 | + } |
|
| 986 | + //TODO if super utile |
|
| 987 | + else { |
|
| 988 | + $pdf->SetFont('', $style, 9); |
|
| 989 | + } |
|
| 955 | 990 | |
| 956 | 991 | } |
| 957 | 992 | |
| 958 | - 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 |
|
| 959 | - else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML |
|
| 993 | + if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) { |
|
| 994 | + $pdf->MultiCell($w, $h, $label, 0, 'L'); |
|
| 995 | + } |
|
| 996 | + // Pas de HTML dans la chaine |
|
| 997 | + else { |
|
| 998 | + $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); |
|
| 999 | + } |
|
| 1000 | + // et maintenant avec du HTML |
|
| 960 | 1001 | |
| 961 | 1002 | if($description && !$hidedesc) { |
| 962 | 1003 | $posy = $pdf->GetY(); |
@@ -980,8 +1021,7 @@ discard block |
||
| 980 | 1021 | |
| 981 | 1022 | if(is_array($parameters)) { |
| 982 | 1023 | $i = & $parameters['i']; |
| 983 | - } |
|
| 984 | - else { |
|
| 1024 | + } else { |
|
| 985 | 1025 | $i = (int)$parameters; |
| 986 | 1026 | } |
| 987 | 1027 | |
@@ -1003,17 +1043,14 @@ discard block |
||
| 1003 | 1043 | |
| 1004 | 1044 | if((float)DOL_VERSION<=3.6) { |
| 1005 | 1045 | return ''; |
| 1006 | - } |
|
| 1007 | - else if((float)DOL_VERSION>=3.8) { |
|
| 1046 | + } else if((float)DOL_VERSION>=3.8) { |
|
| 1008 | 1047 | return 1; |
| 1009 | 1048 | } |
| 1010 | 1049 | |
| 1011 | - } |
|
| 1012 | - elseif(!empty($hideprices)) { |
|
| 1050 | + } elseif(!empty($hideprices)) { |
|
| 1013 | 1051 | $this->resprints = $object->lines[$parameters['i']]->qty; |
| 1014 | 1052 | return 1; |
| 1015 | - } |
|
| 1016 | - elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY)) |
|
| 1053 | + } elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY)) |
|
| 1017 | 1054 | { |
| 1018 | 1055 | $hideInnerLines = (int)GETPOST('hideInnerLines'); |
| 1019 | 1056 | $hidedetails = (int)GETPOST('hidedetails'); |
@@ -1023,12 +1060,20 @@ discard block |
||
| 1023 | 1060 | } |
| 1024 | 1061 | } |
| 1025 | 1062 | |
| 1026 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
| 1027 | - else $i = (int)$parameters; |
|
| 1063 | + if(is_array($parameters)) { |
|
| 1064 | + $i = & $parameters['i']; |
|
| 1065 | + } else { |
|
| 1066 | + $i = (int)$parameters; |
|
| 1067 | + } |
|
| 1028 | 1068 | |
| 1029 | - 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) |
|
| 1069 | + if (empty($object->lines[$i])) { |
|
| 1070 | + return 0; |
|
| 1071 | + } |
|
| 1072 | + // 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) |
|
| 1030 | 1073 | |
| 1031 | - if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals(); |
|
| 1074 | + if(empty($object->lines[$i]->array_options)) { |
|
| 1075 | + $object->lines[$i]->fetch_optionals(); |
|
| 1076 | + } |
|
| 1032 | 1077 | |
| 1033 | 1078 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
| 1034 | 1079 | { |
@@ -1051,16 +1096,17 @@ discard block |
||
| 1051 | 1096 | |
| 1052 | 1097 | if((float)DOL_VERSION<=3.6) { |
| 1053 | 1098 | return ''; |
| 1054 | - } |
|
| 1055 | - else if((float)DOL_VERSION>=3.8) { |
|
| 1099 | + } else if((float)DOL_VERSION>=3.8) { |
|
| 1056 | 1100 | return 1; |
| 1057 | 1101 | } |
| 1058 | 1102 | |
| 1059 | - } |
|
| 1060 | - elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS)) |
|
| 1103 | + } elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS)) |
|
| 1061 | 1104 | { |
| 1062 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
| 1063 | - else $i = (int)$parameters; |
|
| 1105 | + if(is_array($parameters)) { |
|
| 1106 | + $i = & $parameters['i']; |
|
| 1107 | + } else { |
|
| 1108 | + $i = (int)$parameters; |
|
| 1109 | + } |
|
| 1064 | 1110 | |
| 1065 | 1111 | if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
| 1066 | 1112 | { |
@@ -1082,8 +1128,11 @@ discard block |
||
| 1082 | 1128 | } |
| 1083 | 1129 | } |
| 1084 | 1130 | if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){ |
| 1085 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
| 1086 | - else $i = (int)$parameters; |
|
| 1131 | + if(is_array($parameters)) { |
|
| 1132 | + $i = & $parameters['i']; |
|
| 1133 | + } else { |
|
| 1134 | + $i = (int)$parameters; |
|
| 1135 | + } |
|
| 1087 | 1136 | $this->resprints = price($object->lines[$i]->total_ht); |
| 1088 | 1137 | } |
| 1089 | 1138 | if (!empty($hideprices) |
@@ -1109,14 +1158,16 @@ discard block |
||
| 1109 | 1158 | |
| 1110 | 1159 | if((float)DOL_VERSION<=3.6) { |
| 1111 | 1160 | return ''; |
| 1112 | - } |
|
| 1113 | - else if((float)DOL_VERSION>=3.8) { |
|
| 1161 | + } else if((float)DOL_VERSION>=3.8) { |
|
| 1114 | 1162 | return 1; |
| 1115 | 1163 | } |
| 1116 | 1164 | } |
| 1117 | 1165 | |
| 1118 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
| 1119 | - else $i = (int)$parameters; |
|
| 1166 | + if(is_array($parameters)) { |
|
| 1167 | + $i = & $parameters['i']; |
|
| 1168 | + } else { |
|
| 1169 | + $i = (int)$parameters; |
|
| 1170 | + } |
|
| 1120 | 1171 | |
| 1121 | 1172 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
| 1122 | 1173 | { |
@@ -1138,14 +1189,16 @@ discard block |
||
| 1138 | 1189 | |
| 1139 | 1190 | if((float)DOL_VERSION<=3.6) { |
| 1140 | 1191 | return ''; |
| 1141 | - } |
|
| 1142 | - else if((float)DOL_VERSION>=3.8) { |
|
| 1192 | + } else if((float)DOL_VERSION>=3.8) { |
|
| 1143 | 1193 | return 1; |
| 1144 | 1194 | } |
| 1145 | 1195 | } |
| 1146 | 1196 | |
| 1147 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
| 1148 | - else $i = (int)$parameters; |
|
| 1197 | + if(is_array($parameters)) { |
|
| 1198 | + $i = & $parameters['i']; |
|
| 1199 | + } else { |
|
| 1200 | + $i = (int)$parameters; |
|
| 1201 | + } |
|
| 1149 | 1202 | |
| 1150 | 1203 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
| 1151 | 1204 | { |
@@ -1167,13 +1220,15 @@ discard block |
||
| 1167 | 1220 | |
| 1168 | 1221 | if((float)DOL_VERSION<=3.6) { |
| 1169 | 1222 | return ''; |
| 1170 | - } |
|
| 1171 | - else if((float)DOL_VERSION>=3.8) { |
|
| 1223 | + } else if((float)DOL_VERSION>=3.8) { |
|
| 1172 | 1224 | return 1; |
| 1173 | 1225 | } |
| 1174 | 1226 | } |
| 1175 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
| 1176 | - else $i = (int)$parameters; |
|
| 1227 | + if(is_array($parameters)) { |
|
| 1228 | + $i = & $parameters['i']; |
|
| 1229 | + } else { |
|
| 1230 | + $i = (int)$parameters; |
|
| 1231 | + } |
|
| 1177 | 1232 | |
| 1178 | 1233 | if (!empty($hideprices) |
| 1179 | 1234 | || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
@@ -1196,14 +1251,16 @@ discard block |
||
| 1196 | 1251 | $this->resprints = ' '; |
| 1197 | 1252 | if((float)DOL_VERSION<=3.6) { |
| 1198 | 1253 | return ''; |
| 1199 | - } |
|
| 1200 | - else if((float)DOL_VERSION>=3.8) { |
|
| 1254 | + } else if((float)DOL_VERSION>=3.8) { |
|
| 1201 | 1255 | return 1; |
| 1202 | 1256 | } |
| 1203 | 1257 | } |
| 1204 | 1258 | |
| 1205 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
| 1206 | - else $i = (int)$parameters; |
|
| 1259 | + if(is_array($parameters)) { |
|
| 1260 | + $i = & $parameters['i']; |
|
| 1261 | + } else { |
|
| 1262 | + $i = (int)$parameters; |
|
| 1263 | + } |
|
| 1207 | 1264 | |
| 1208 | 1265 | if (!empty($hideprices) |
| 1209 | 1266 | || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
@@ -1227,16 +1284,21 @@ discard block |
||
| 1227 | 1284 | |
| 1228 | 1285 | if((float)DOL_VERSION<=3.6) { |
| 1229 | 1286 | return ''; |
| 1230 | - } |
|
| 1231 | - else if((float)DOL_VERSION>=3.8) { |
|
| 1287 | + } else if((float)DOL_VERSION>=3.8) { |
|
| 1232 | 1288 | return 1; |
| 1233 | 1289 | } |
| 1234 | 1290 | } |
| 1235 | 1291 | |
| 1236 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
| 1237 | - else $i = (int)$parameters; |
|
| 1292 | + if(is_array($parameters)) { |
|
| 1293 | + $i = & $parameters['i']; |
|
| 1294 | + } else { |
|
| 1295 | + $i = (int)$parameters; |
|
| 1296 | + } |
|
| 1238 | 1297 | |
| 1239 | - 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) |
|
| 1298 | + if (empty($object->lines[$i])) { |
|
| 1299 | + return 0; |
|
| 1300 | + } |
|
| 1301 | + // 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) |
|
| 1240 | 1302 | |
| 1241 | 1303 | $object->lines[$i]->fetch_optionals(); |
| 1242 | 1304 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
@@ -1258,14 +1320,16 @@ discard block |
||
| 1258 | 1320 | $this->resprints = ' '; |
| 1259 | 1321 | if((float)DOL_VERSION<=3.6) { |
| 1260 | 1322 | return ''; |
| 1261 | - } |
|
| 1262 | - else if((float)DOL_VERSION>=3.8) { |
|
| 1323 | + } else if((float)DOL_VERSION>=3.8) { |
|
| 1263 | 1324 | return 1; |
| 1264 | 1325 | } |
| 1265 | 1326 | } |
| 1266 | 1327 | |
| 1267 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
| 1268 | - else $i = (int)$parameters; |
|
| 1328 | + if(is_array($parameters)) { |
|
| 1329 | + $i = & $parameters['i']; |
|
| 1330 | + } else { |
|
| 1331 | + $i = (int)$parameters; |
|
| 1332 | + } |
|
| 1269 | 1333 | |
| 1270 | 1334 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
| 1271 | 1335 | { |
@@ -1295,7 +1359,9 @@ discard block |
||
| 1295 | 1359 | } |
| 1296 | 1360 | } |
| 1297 | 1361 | |
| 1298 | - if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle); |
|
| 1362 | + if (!empty($TLineTitle)) { |
|
| 1363 | + $TTitleNumeroted = $this->formatNumerotation($TLineTitle); |
|
| 1364 | + } |
|
| 1299 | 1365 | } |
| 1300 | 1366 | |
| 1301 | 1367 | } |
@@ -1309,8 +1375,12 @@ discard block |
||
| 1309 | 1375 | $j=0; |
| 1310 | 1376 | foreach ($TLineTitle as $k => &$line) |
| 1311 | 1377 | { |
| 1312 | - if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue; |
|
| 1313 | - if (!empty($line_reference) && $line->qty <= $line_reference->qty) break; |
|
| 1378 | + if (!empty($line_reference) && $line->rang <= $line_reference->rang) { |
|
| 1379 | + continue; |
|
| 1380 | + } |
|
| 1381 | + if (!empty($line_reference) && $line->qty <= $line_reference->qty) { |
|
| 1382 | + break; |
|
| 1383 | + } |
|
| 1314 | 1384 | |
| 1315 | 1385 | if ($line->qty == $level) |
| 1316 | 1386 | { |
@@ -1344,7 +1414,9 @@ discard block |
||
| 1344 | 1414 | |
| 1345 | 1415 | $hidedetails = (int)GETPOST('hidedetails'); |
| 1346 | 1416 | |
| 1347 | - if(empty($hidedetails)) return false; |
|
| 1417 | + if(empty($hidedetails)) { |
|
| 1418 | + return false; |
|
| 1419 | + } |
|
| 1348 | 1420 | |
| 1349 | 1421 | // TODO can't add VAT to document without lines... :-/ |
| 1350 | 1422 | |
@@ -1397,7 +1469,9 @@ discard block |
||
| 1397 | 1469 | */ |
| 1398 | 1470 | list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1); |
| 1399 | 1471 | |
| 1400 | - if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TTotal_tva; |
|
| 1472 | + if (TSubtotal::getNiveau($line) == 1) { |
|
| 1473 | + $line->TTotal_tva = $TTotal_tva; |
|
| 1474 | + } |
|
| 1401 | 1475 | $line->total_ht = $total; |
| 1402 | 1476 | $line->total_tva = $total_tva; |
| 1403 | 1477 | $line->total = $line->total_ht; |
@@ -1452,8 +1526,7 @@ discard block |
||
| 1452 | 1526 | } |
| 1453 | 1527 | |
| 1454 | 1528 | |
| 1455 | - } |
|
| 1456 | - elseif ($hidedetails) |
|
| 1529 | + } elseif ($hidedetails) |
|
| 1457 | 1530 | { |
| 1458 | 1531 | $TLines[] = $line; //Cas où je cache uniquement les prix des produits |
| 1459 | 1532 | } |
@@ -1524,7 +1597,9 @@ discard block |
||
| 1524 | 1597 | |
| 1525 | 1598 | if(!empty($hideprices)) { |
| 1526 | 1599 | foreach($object->lines as &$line) { |
| 1527 | - if($line->fk_product_type!=9) $line->fk_parent_line = -1; |
|
| 1600 | + if($line->fk_product_type!=9) { |
|
| 1601 | + $line->fk_parent_line = -1; |
|
| 1602 | + } |
|
| 1528 | 1603 | } |
| 1529 | 1604 | } |
| 1530 | 1605 | |
@@ -1545,7 +1620,9 @@ discard block |
||
| 1545 | 1620 | |
| 1546 | 1621 | if($line->qty>90) { |
| 1547 | 1622 | |
| 1548 | - if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) $label .= ' '.$this->getTitle($object, $line); |
|
| 1623 | + if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) { |
|
| 1624 | + $label .= ' '.$this->getTitle($object, $line); |
|
| 1625 | + } |
|
| 1549 | 1626 | |
| 1550 | 1627 | $pageBefore = $pdf->getPage(); |
| 1551 | 1628 | $this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); |
@@ -1563,8 +1640,7 @@ discard block |
||
| 1563 | 1640 | |
| 1564 | 1641 | $posy = $pdf->GetY(); |
| 1565 | 1642 | return 1; |
| 1566 | - } |
|
| 1567 | - else if ($line->qty < 10) { |
|
| 1643 | + } else if ($line->qty < 10) { |
|
| 1568 | 1644 | $pageBefore = $pdf->getPage(); |
| 1569 | 1645 | |
| 1570 | 1646 | $this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); |
@@ -1588,8 +1664,7 @@ discard block |
||
| 1588 | 1664 | // if($line->rowid==47) exit; |
| 1589 | 1665 | |
| 1590 | 1666 | return 0; |
| 1591 | - } |
|
| 1592 | - elseif (empty($object->lines[$parameters['i']])) |
|
| 1667 | + } elseif (empty($object->lines[$parameters['i']])) |
|
| 1593 | 1668 | { |
| 1594 | 1669 | $this->resprints = -1; |
| 1595 | 1670 | } |
@@ -1622,7 +1697,9 @@ discard block |
||
| 1622 | 1697 | |
| 1623 | 1698 | foreach ($object->lines as $line) |
| 1624 | 1699 | { |
| 1625 | - if ($line->id == $currentLine->id) break; |
|
| 1700 | + if ($line->id == $currentLine->id) { |
|
| 1701 | + break; |
|
| 1702 | + } |
|
| 1626 | 1703 | |
| 1627 | 1704 | $qty_search = 100 - $currentLine->qty; |
| 1628 | 1705 | |
@@ -1659,23 +1736,23 @@ discard block |
||
| 1659 | 1736 | { |
| 1660 | 1737 | $object->statut = 0; // hack for facture rec |
| 1661 | 1738 | $createRight = $user->rights->facture->creer; |
| 1662 | - } |
|
| 1663 | - elseif($object->element == 'order_supplier' ) |
|
| 1739 | + } elseif($object->element == 'order_supplier' ) |
|
| 1664 | 1740 | { |
| 1665 | 1741 | $createRight = $user->rights->fournisseur->commande->creer; |
| 1666 | - } |
|
| 1667 | - elseif($object->element == 'invoice_supplier' ) |
|
| 1742 | + } elseif($object->element == 'invoice_supplier' ) |
|
| 1668 | 1743 | { |
| 1669 | 1744 | $createRight = $user->rights->fournisseur->facture->creer; |
| 1670 | 1745 | } |
| 1671 | 1746 | |
| 1672 | 1747 | if($line->special_code!=$this->module_number || $line->product_type!=9) { |
| 1673 | 1748 | null; |
| 1674 | - } |
|
| 1675 | - 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)) |
|
| 1749 | + } 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)) |
|
| 1676 | 1750 | { |
| 1677 | - if($object->element=='facture')$idvar = 'facid'; |
|
| 1678 | - else $idvar='id'; |
|
| 1751 | + if($object->element=='facture') { |
|
| 1752 | + $idvar = 'facid'; |
|
| 1753 | + } else { |
|
| 1754 | + $idvar='id'; |
|
| 1755 | + } |
|
| 1679 | 1756 | |
| 1680 | 1757 | if((float)DOL_VERSION <= 3.4) |
| 1681 | 1758 | { |
@@ -1701,20 +1778,44 @@ discard block |
||
| 1701 | 1778 | <?php |
| 1702 | 1779 | } |
| 1703 | 1780 | |
| 1704 | - if(empty($line->description)) $line->description = $line->desc; |
|
| 1781 | + if(empty($line->description)) { |
|
| 1782 | + $line->description = $line->desc; |
|
| 1783 | + } |
|
| 1705 | 1784 | |
| 1706 | 1785 | $colspan = 5; |
| 1707 | - if($object->element == 'facturerec' ) $colspan = 3; |
|
| 1708 | - if($object->element == 'order_supplier') $colspan = 3; |
|
| 1709 | - if($object->element == 'invoice_supplier') $colspan = 4; |
|
| 1710 | - if($object->element == 'supplier_proposal') $colspan = 4; |
|
| 1711 | - if(!empty($conf->multicurrency->enabled)) $colspan+=2; |
|
| 1712 | - if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++; |
|
| 1713 | - if(!empty($conf->margin->enabled)) $colspan++; |
|
| 1714 | - if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; |
|
| 1715 | - if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; |
|
| 1716 | - if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++; |
|
| 1717 | - if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++; |
|
| 1786 | + if($object->element == 'facturerec' ) { |
|
| 1787 | + $colspan = 3; |
|
| 1788 | + } |
|
| 1789 | + if($object->element == 'order_supplier') { |
|
| 1790 | + $colspan = 3; |
|
| 1791 | + } |
|
| 1792 | + if($object->element == 'invoice_supplier') { |
|
| 1793 | + $colspan = 4; |
|
| 1794 | + } |
|
| 1795 | + if($object->element == 'supplier_proposal') { |
|
| 1796 | + $colspan = 4; |
|
| 1797 | + } |
|
| 1798 | + if(!empty($conf->multicurrency->enabled)) { |
|
| 1799 | + $colspan+=2; |
|
| 1800 | + } |
|
| 1801 | + if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) { |
|
| 1802 | + $colspan++; |
|
| 1803 | + } |
|
| 1804 | + if(!empty($conf->margin->enabled)) { |
|
| 1805 | + $colspan++; |
|
| 1806 | + } |
|
| 1807 | + if(!empty($conf->global->DISPLAY_MARGIN_RATES)) { |
|
| 1808 | + $colspan++; |
|
| 1809 | + } |
|
| 1810 | + if(!empty($conf->global->DISPLAY_MARK_RATES)) { |
|
| 1811 | + $colspan++; |
|
| 1812 | + } |
|
| 1813 | + if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) { |
|
| 1814 | + $colspan++; |
|
| 1815 | + } |
|
| 1816 | + if(!empty($conf->global->PRODUCT_USE_UNITS)) { |
|
| 1817 | + $colspan++; |
|
| 1818 | + } |
|
| 1718 | 1819 | |
| 1719 | 1820 | /* Titre */ |
| 1720 | 1821 | //var_dump($line); |
@@ -1727,23 +1828,36 @@ discard block |
||
| 1727 | 1828 | <tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php |
| 1728 | 1829 | if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT)) |
| 1729 | 1830 | { |
| 1730 | - if($line->qty==99) print 'background:#adadcf'; |
|
| 1731 | - else if($line->qty==98) print 'background:#ddddff;'; |
|
| 1732 | - else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;'; |
|
| 1733 | - else if($line->qty==1) print 'background:#adadcf;'; |
|
| 1734 | - else if($line->qty==2) print 'background:#ddddff;'; |
|
| 1735 | - else if($line->qty==50) print ''; |
|
| 1736 | - else print 'background:#eeeeff;'; |
|
| 1831 | + if($line->qty==99) { |
|
| 1832 | + print 'background:#adadcf'; |
|
| 1833 | + } else if($line->qty==98) { |
|
| 1834 | + print 'background:#ddddff;'; |
|
| 1835 | + } else if($line->qty<=97 && $line->qty>=91) { |
|
| 1836 | + print 'background:#eeeeff;'; |
|
| 1837 | + } else if($line->qty==1) { |
|
| 1838 | + print 'background:#adadcf;'; |
|
| 1839 | + } else if($line->qty==2) { |
|
| 1840 | + print 'background:#ddddff;'; |
|
| 1841 | + } else if($line->qty==50) { |
|
| 1842 | + print ''; |
|
| 1843 | + } else { |
|
| 1844 | + print 'background:#eeeeff;'; |
|
| 1845 | + } |
|
| 1737 | 1846 | |
| 1738 | 1847 | //A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9 |
| 1739 | - } |
|
| 1740 | - else |
|
| 1848 | + } else |
|
| 1741 | 1849 | { |
| 1742 | - if($line->qty==99) print 'background:#ddffdd'; |
|
| 1743 | - else if($line->qty==98) print 'background:#ddddff;'; |
|
| 1744 | - else if($line->qty==2) print 'background:#eeeeff; '; |
|
| 1745 | - else if($line->qty==50) print ''; |
|
| 1746 | - else print 'background:#eeffee;' ; |
|
| 1850 | + if($line->qty==99) { |
|
| 1851 | + print 'background:#ddffdd'; |
|
| 1852 | + } else if($line->qty==98) { |
|
| 1853 | + print 'background:#ddddff;'; |
|
| 1854 | + } else if($line->qty==2) { |
|
| 1855 | + print 'background:#eeeeff; '; |
|
| 1856 | + } else if($line->qty==50) { |
|
| 1857 | + print ''; |
|
| 1858 | + } else { |
|
| 1859 | + print 'background:#eeffee;' ; |
|
| 1860 | + } |
|
| 1747 | 1861 | } |
| 1748 | 1862 | |
| 1749 | 1863 | ?>;"> |
@@ -1766,13 +1880,11 @@ discard block |
||
| 1766 | 1880 | $qty_displayed = $line->qty; |
| 1767 | 1881 | print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span> '; |
| 1768 | 1882 | |
| 1769 | - } |
|
| 1770 | - else if (TSubtotal::isSubtotal($line)) |
|
| 1883 | + } else if (TSubtotal::isSubtotal($line)) |
|
| 1771 | 1884 | { |
| 1772 | 1885 | $qty_displayed = 100 - $line->qty; |
| 1773 | 1886 | print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span> '; |
| 1774 | - } |
|
| 1775 | - else |
|
| 1887 | + } else |
|
| 1776 | 1888 | { |
| 1777 | 1889 | $isFreeText = true; |
| 1778 | 1890 | } |
@@ -1793,9 +1905,13 @@ discard block |
||
| 1793 | 1905 | } |
| 1794 | 1906 | |
| 1795 | 1907 | $readonlyForSituation = ''; |
| 1796 | - if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) $readonlyForSituation = 'readonly'; |
|
| 1908 | + if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) { |
|
| 1909 | + $readonlyForSituation = 'readonly'; |
|
| 1910 | + } |
|
| 1797 | 1911 | |
| 1798 | - if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/> '; |
|
| 1912 | + if (!$isFreeText) { |
|
| 1913 | + echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/> '; |
|
| 1914 | + } |
|
| 1799 | 1915 | |
| 1800 | 1916 | if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) ) |
| 1801 | 1917 | { |
@@ -1803,8 +1919,12 @@ discard block |
||
| 1803 | 1919 | for ($j=1; $j<10; $j++) |
| 1804 | 1920 | { |
| 1805 | 1921 | if (!empty($readonlyForSituation)) { |
| 1806 | - if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
| 1807 | - } else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
| 1922 | + if ($qty_displayed == $j) { |
|
| 1923 | + $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
| 1924 | + } |
|
| 1925 | + } else { |
|
| 1926 | + $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
| 1927 | + } |
|
| 1808 | 1928 | } |
| 1809 | 1929 | $select .= '</select> '; |
| 1810 | 1930 | |
@@ -1820,15 +1940,18 @@ discard block |
||
| 1820 | 1940 | $form = new Form($db); |
| 1821 | 1941 | echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>'; |
| 1822 | 1942 | echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>'; |
| 1823 | - if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true)); |
|
| 1943 | + if (empty($readonlyForSituation)) { |
|
| 1944 | + echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true)); |
|
| 1945 | + } |
|
| 1824 | 1946 | echo '</select> '; |
| 1825 | 1947 | |
| 1826 | 1948 | if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION) |
| 1827 | 1949 | { |
| 1828 | 1950 | echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%'; |
| 1829 | 1951 | } |
| 1952 | + } else if ($isFreeText) { |
|
| 1953 | + echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation); |
|
| 1830 | 1954 | } |
| 1831 | - else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation); |
|
| 1832 | 1955 | echo '</div>'; |
| 1833 | 1956 | |
| 1834 | 1957 | if($line->qty<10) { |
@@ -1848,8 +1971,7 @@ discard block |
||
| 1848 | 1971 | $doleditor->Create(); |
| 1849 | 1972 | } |
| 1850 | 1973 | |
| 1851 | - } |
|
| 1852 | - else { |
|
| 1974 | + } else { |
|
| 1853 | 1975 | |
| 1854 | 1976 | if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) |
| 1855 | 1977 | { |
@@ -1857,14 +1979,19 @@ discard block |
||
| 1857 | 1979 | { |
| 1858 | 1980 | echo str_repeat(' ', $line->qty-1); |
| 1859 | 1981 | |
| 1860 | - if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span> '; |
|
| 1861 | - else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span> '; |
|
| 1982 | + if (TSubtotal::isTitle($line)) { |
|
| 1983 | + print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span> '; |
|
| 1984 | + } else { |
|
| 1985 | + print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span> '; |
|
| 1986 | + } |
|
| 1862 | 1987 | } |
| 1863 | - } |
|
| 1864 | - else |
|
| 1988 | + } else |
|
| 1865 | 1989 | { |
| 1866 | - if($line->qty<=1) print img_picto('', 'subtotal@subtotal'); |
|
| 1867 | - else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').' '; |
|
| 1990 | + if($line->qty<=1) { |
|
| 1991 | + print img_picto('', 'subtotal@subtotal'); |
|
| 1992 | + } else if($line->qty==2) { |
|
| 1993 | + print img_picto('', 'subsubtotal@subtotal').' '; |
|
| 1994 | + } |
|
| 1868 | 1995 | } |
| 1869 | 1996 | |
| 1870 | 1997 | |
@@ -1874,21 +2001,26 @@ discard block |
||
| 1874 | 2001 | $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;'; |
| 1875 | 2002 | |
| 1876 | 2003 | if (empty($line->label)) { |
| 1877 | - if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print $line->description.' '.$this->getTitle($object, $line); |
|
| 1878 | - else print $line->description; |
|
| 1879 | - } |
|
| 1880 | - else { |
|
| 2004 | + if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) { |
|
| 2005 | + print $line->description.' '.$this->getTitle($object, $line); |
|
| 2006 | + } else { |
|
| 2007 | + print $line->description; |
|
| 2008 | + } |
|
| 2009 | + } else { |
|
| 1881 | 2010 | |
| 1882 | 2011 | if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) { |
| 1883 | 2012 | print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>'; |
| 1884 | - } |
|
| 1885 | - else{ |
|
| 2013 | + } else{ |
|
| 1886 | 2014 | print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>'; |
| 1887 | 2015 | } |
| 1888 | 2016 | |
| 1889 | 2017 | } |
| 1890 | - if($line->qty>90) print ' : '; |
|
| 1891 | - if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal'); |
|
| 2018 | + if($line->qty>90) { |
|
| 2019 | + print ' : '; |
|
| 2020 | + } |
|
| 2021 | + if($line->info_bits > 0) { |
|
| 2022 | + echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal'); |
|
| 2023 | + } |
|
| 1892 | 2024 | |
| 1893 | 2025 | |
| 1894 | 2026 | |
@@ -1925,11 +2057,12 @@ discard block |
||
| 1925 | 2057 | </script> |
| 1926 | 2058 | <?php |
| 1927 | 2059 | |
| 1928 | - } |
|
| 1929 | - else{ |
|
| 2060 | + } else{ |
|
| 1930 | 2061 | if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier') |
| 1931 | 2062 | { |
| 1932 | - 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>'; |
|
| 2063 | + if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) { |
|
| 2064 | + echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>'; |
|
| 2065 | + } |
|
| 1933 | 2066 | } |
| 1934 | 2067 | |
| 1935 | 2068 | if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) |
@@ -1998,7 +2131,9 @@ discard block |
||
| 1998 | 2131 | $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); |
| 1999 | 2132 | |
| 2000 | 2133 | $colspan+=3; $mode = 'view'; |
| 2001 | - if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit'; |
|
| 2134 | + if($action === 'editline' && $line->rowid == GETPOST('lineid')) { |
|
| 2135 | + $mode = 'edit'; |
|
| 2136 | + } |
|
| 2002 | 2137 | |
| 2003 | 2138 | $ex_element = $line->element; |
| 2004 | 2139 | $line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr |
@@ -2167,10 +2302,9 @@ discard block |
||
| 2167 | 2302 | |
| 2168 | 2303 | if(TSubtotal::isTitle($line)){ |
| 2169 | 2304 | $ThtmlData['data-issubtotal'] = 'title'; |
| 2170 | - }elseif(TSubtotal::isSubtotal($line)){ |
|
| 2305 | + } elseif(TSubtotal::isSubtotal($line)){ |
|
| 2171 | 2306 | $ThtmlData['data-issubtotal'] = 'subtotal'; |
| 2172 | - } |
|
| 2173 | - else{ |
|
| 2307 | + } else{ |
|
| 2174 | 2308 | $ThtmlData['data-issubtotal'] = 'freetext'; |
| 2175 | 2309 | } |
| 2176 | 2310 | |
@@ -2180,7 +2314,9 @@ discard block |
||
| 2180 | 2314 | |
| 2181 | 2315 | // hook |
| 2182 | 2316 | $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
| 2183 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 2317 | + if ($reshook < 0) { |
|
| 2318 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 2319 | + } |
|
| 2184 | 2320 | if ($reshook>0) |
| 2185 | 2321 | { |
| 2186 | 2322 | $ThtmlData = $hookmanager->resArray; |