@@ -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 | |
| 30 | 35 | $TNotElements = array ('invoice_supplier', 'order_supplier'); |
@@ -36,7 +41,9 @@ discard block |
||
| 36 | 41 | /** |
| 37 | 42 | * @var $object Facture |
| 38 | 43 | */ |
| 39 | - 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); |
|
| 44 | + if($object->element=='facture') { |
|
| 45 | + $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); |
|
| 46 | + } |
|
| 40 | 47 | /** |
| 41 | 48 | * @var $object Facture fournisseur |
| 42 | 49 | */ |
@@ -48,16 +55,22 @@ discard block |
||
| 48 | 55 | /** |
| 49 | 56 | * @var $object Propal |
| 50 | 57 | */ |
| 51 | - 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); |
|
| 58 | + else if($object->element=='propal') { |
|
| 59 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
| 60 | + } |
|
| 52 | 61 | /** |
| 53 | 62 | * @var $object Propal Fournisseur |
| 54 | 63 | */ |
| 55 | - 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); |
|
| 64 | + else if($object->element=='supplier_proposal') { |
|
| 65 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
| 66 | + } |
|
| 56 | 67 | |
| 57 | 68 | /** |
| 58 | 69 | * @var $object Commande |
| 59 | 70 | */ |
| 60 | - 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); |
|
| 71 | + else if($object->element=='commande') { |
|
| 72 | + $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 | + } |
|
| 61 | 74 | /** |
| 62 | 75 | * @var $object Commande fournisseur |
| 63 | 76 | */ |
@@ -68,7 +81,9 @@ discard block |
||
| 68 | 81 | /** |
| 69 | 82 | * @var $object Facturerec |
| 70 | 83 | */ |
| 71 | - 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); |
|
| 84 | + else if($object->element=='facturerec') { |
|
| 85 | + $res = $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); |
|
| 86 | + } |
|
| 72 | 87 | |
| 73 | 88 | } |
| 74 | 89 | |
@@ -90,8 +105,9 @@ discard block |
||
| 90 | 105 | // Define output language |
| 91 | 106 | $outputlangs = $langs; |
| 92 | 107 | $newlang = GETPOST('lang_id', 'alpha'); |
| 93 | - if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) |
|
| 94 | - $newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang; |
|
| 108 | + if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { |
|
| 109 | + $newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang; |
|
| 110 | + } |
|
| 95 | 111 | if (! empty($newlang)) { |
| 96 | 112 | $outputlangs = new Translate("", $conf); |
| 97 | 113 | $outputlangs->setDefaultLang($newlang); |
@@ -100,13 +116,18 @@ discard block |
||
| 100 | 116 | $ret = $object->fetch($object->id); // Reload to get new records |
| 101 | 117 | if ((float) DOL_VERSION <= 3.6) |
| 102 | 118 | { |
| 103 | - if ($object->element == 'propal') propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 104 | - elseif ($object->element == 'commande') commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 105 | - elseif ($object->element == 'facture') facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 106 | - } |
|
| 107 | - else |
|
| 119 | + if ($object->element == 'propal') { |
|
| 120 | + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 121 | + } elseif ($object->element == 'commande') { |
|
| 122 | + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 123 | + } elseif ($object->element == 'facture') { |
|
| 124 | + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 125 | + } |
|
| 126 | + } else |
|
| 108 | 127 | { |
| 109 | - if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 128 | + if ($object->element!= 'facturerec') { |
|
| 129 | + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 130 | + } |
|
| 110 | 131 | } |
| 111 | 132 | } |
| 112 | 133 | } |
@@ -120,7 +141,9 @@ discard block |
||
| 120 | 141 | */ |
| 121 | 142 | public static function updateRang(&$object, $rang_start, $move_to=1) |
| 122 | 143 | { |
| 123 | - if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
|
| 144 | + if (!class_exists('GenericObject')) { |
|
| 145 | + require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
|
| 146 | + } |
|
| 124 | 147 | |
| 125 | 148 | $row=new GenericObject($object->db); |
| 126 | 149 | $row->table_element_line = $object->table_element_line; |
@@ -129,7 +152,9 @@ discard block |
||
| 129 | 152 | |
| 130 | 153 | foreach ($object->lines as &$line) |
| 131 | 154 | { |
| 132 | - if ($line->rang < $rang_start) continue; |
|
| 155 | + if ($line->rang < $rang_start) { |
|
| 156 | + continue; |
|
| 157 | + } |
|
| 133 | 158 | |
| 134 | 159 | $row->updateRangOfLine($line->id, $line->rang+$move_to); |
| 135 | 160 | } |
@@ -152,21 +177,28 @@ discard block |
||
| 152 | 177 | foreach ($TTitle_reverse as $k => $title_line) |
| 153 | 178 | { |
| 154 | 179 | $title_niveau = self::getNiveau($title_line); |
| 155 | - if ($title_niveau < $level_new_title) break; |
|
| 180 | + if ($title_niveau < $level_new_title) { |
|
| 181 | + break; |
|
| 182 | + } |
|
| 156 | 183 | |
| 157 | 184 | $rang_to_add = self::titleHasTotalLine($object, $title_line, true, true); |
| 158 | 185 | |
| 159 | 186 | if (is_numeric($rang_to_add)) |
| 160 | 187 | { |
| 161 | - if ($rang_to_add != -1) self::updateRang($object, $rang_to_add); |
|
| 188 | + if ($rang_to_add != -1) { |
|
| 189 | + self::updateRang($object, $rang_to_add); |
|
| 190 | + } |
|
| 162 | 191 | |
| 163 | 192 | self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add); |
| 164 | 193 | |
| 165 | 194 | $object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas) |
| 166 | 195 | if ($rang_to_add != -1) |
| 167 | 196 | { |
| 168 | - if (method_exists($object, 'fetch_lines')) $object->fetch_lines(); |
|
| 169 | - else $object->fetch($object->id); |
|
| 197 | + if (method_exists($object, 'fetch_lines')) { |
|
| 198 | + $object->fetch_lines(); |
|
| 199 | + } else { |
|
| 200 | + $object->fetch($object->id); |
|
| 201 | + } |
|
| 170 | 202 | } |
| 171 | 203 | } |
| 172 | 204 | } |
@@ -196,7 +228,9 @@ discard block |
||
| 196 | 228 | |
| 197 | 229 | foreach ($TTitle as $k => $title_line) |
| 198 | 230 | { |
| 199 | - if (self::titleHasTotalLine($object, $title_line)) unset($TTitle[$k]); |
|
| 231 | + if (self::titleHasTotalLine($object, $title_line)) { |
|
| 232 | + unset($TTitle[$k]); |
|
| 233 | + } |
|
| 200 | 234 | } |
| 201 | 235 | |
| 202 | 236 | return $TTitle; |
@@ -213,23 +247,41 @@ discard block |
||
| 213 | 247 | */ |
| 214 | 248 | public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false) |
| 215 | 249 | { |
| 216 | - if (empty($object->lines) || !is_array($object->lines)) return false; |
|
| 250 | + if (empty($object->lines) || !is_array($object->lines)) { |
|
| 251 | + return false; |
|
| 252 | + } |
|
| 217 | 253 | |
| 218 | 254 | $title_niveau = self::getNiveau($title_line); |
| 219 | 255 | foreach ($object->lines as &$line) |
| 220 | 256 | { |
| 221 | - if ($line->rang <= $title_line->rang) continue; |
|
| 222 | - 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 |
|
| 223 | - if (!self::isSubtotal($line)) continue; |
|
| 257 | + if ($line->rang <= $title_line->rang) { |
|
| 258 | + continue; |
|
| 259 | + } |
|
| 260 | + if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) { |
|
| 261 | + return false; |
|
| 262 | + } |
|
| 263 | + // 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 |
|
| 264 | + if (!self::isSubtotal($line)) { |
|
| 265 | + continue; |
|
| 266 | + } |
|
| 224 | 267 | |
| 225 | 268 | $subtotal_niveau = self::getNiveau($line); |
| 226 | 269 | |
| 227 | 270 | // Comparaison du niveau de la ligne de sous-total avec celui du titre |
| 228 | - if ($subtotal_niveau == $title_niveau) return true; // niveau égale => Ok mon titre a un sous-total |
|
| 229 | - elseif ($subtotal_niveau < $title_niveau) // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3) |
|
| 271 | + if ($subtotal_niveau == $title_niveau) { |
|
| 272 | + return true; |
|
| 273 | + } |
|
| 274 | + // niveau égale => Ok mon titre a un sous-total |
|
| 275 | + elseif ($subtotal_niveau < $title_niveau) { |
|
| 276 | + // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3) |
|
| 230 | 277 | { |
| 231 | - if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; // mode strict niveau pas égale donc faux |
|
| 232 | - else return true; // mode libre => OK je considère que mon titre à un sous-total |
|
| 278 | + if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; |
|
| 279 | + } |
|
| 280 | + // mode strict niveau pas égale donc faux |
|
| 281 | + else { |
|
| 282 | + return true; |
|
| 283 | + } |
|
| 284 | + // mode libre => OK je considère que mon titre à un sous-total |
|
| 233 | 285 | } |
| 234 | 286 | } |
| 235 | 287 | |
@@ -277,16 +329,19 @@ discard block |
||
| 277 | 329 | |
| 278 | 330 | foreach ($object->lines as &$l) |
| 279 | 331 | { |
| 280 | - if ($l->rang <= $line->rang) continue; |
|
| 281 | - elseif (self::isSubtotal($l) && self::getNiveau($l) == $line->qty) break; |
|
| 282 | - elseif (self::isModSubtotalLine($l)) continue; |
|
| 332 | + if ($l->rang <= $line->rang) { |
|
| 333 | + continue; |
|
| 334 | + } elseif (self::isSubtotal($l) && self::getNiveau($l) == $line->qty) { |
|
| 335 | + break; |
|
| 336 | + } elseif (self::isModSubtotalLine($l)) { |
|
| 337 | + continue; |
|
| 338 | + } |
|
| 283 | 339 | |
| 284 | 340 | if (!empty($l->array_options['options_subtotal_nc'])) |
| 285 | 341 | { |
| 286 | 342 | $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); |
| 287 | 343 | $TTot['total_options'] += $tabprice[0]; // total ht |
| 288 | - } |
|
| 289 | - else |
|
| 344 | + } else |
|
| 290 | 345 | { |
| 291 | 346 | $TTot['total_pa_ht'] += $l->pa_ht * $l->qty; |
| 292 | 347 | $TTot['total_subprice'] += $l->subprice * $l->qty; |
@@ -306,29 +361,41 @@ discard block |
||
| 306 | 361 | |
| 307 | 362 | public static function getOrderIdFromLineId(&$db, $fk_commandedet) |
| 308 | 363 | { |
| 309 | - if (empty($fk_commandedet)) return false; |
|
| 364 | + if (empty($fk_commandedet)) { |
|
| 365 | + return false; |
|
| 366 | + } |
|
| 310 | 367 | |
| 311 | 368 | $sql = 'SELECT fk_commande FROM '.MAIN_DB_PREFIX.'commandedet WHERE rowid = '.$fk_commandedet; |
| 312 | 369 | $resql = $db->query($sql); |
| 313 | 370 | |
| 314 | - if ($resql && ($row = $db->fetch_object($resql))) return $row->fk_commande; |
|
| 315 | - else return false; |
|
| 371 | + if ($resql && ($row = $db->fetch_object($resql))) { |
|
| 372 | + return $row->fk_commande; |
|
| 373 | + } else { |
|
| 374 | + return false; |
|
| 375 | + } |
|
| 316 | 376 | } |
| 317 | 377 | |
| 318 | 378 | public static function getLastLineOrderId(&$db, $fk_commande) |
| 319 | 379 | { |
| 320 | - if (empty($fk_commande)) return false; |
|
| 380 | + if (empty($fk_commande)) { |
|
| 381 | + return false; |
|
| 382 | + } |
|
| 321 | 383 | |
| 322 | 384 | $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'commandedet WHERE fk_commande = '.$fk_commande.' ORDER BY rang DESC LIMIT 1'; |
| 323 | 385 | $resql = $db->query($sql); |
| 324 | 386 | |
| 325 | - if ($resql && ($row = $db->fetch_object($resql))) return $row->rowid; |
|
| 326 | - else return false; |
|
| 387 | + if ($resql && ($row = $db->fetch_object($resql))) { |
|
| 388 | + return $row->rowid; |
|
| 389 | + } else { |
|
| 390 | + return false; |
|
| 391 | + } |
|
| 327 | 392 | } |
| 328 | 393 | |
| 329 | 394 | public static function getParentTitleOfLine(&$object, $i) |
| 330 | 395 | { |
| 331 | - if ($i <= 0) return false; |
|
| 396 | + if ($i <= 0) { |
|
| 397 | + return false; |
|
| 398 | + } |
|
| 332 | 399 | |
| 333 | 400 | $skip_title = 0; |
| 334 | 401 | // Je parcours les lignes précédentes |
@@ -347,8 +414,7 @@ discard block |
||
| 347 | 414 | //@INFO J'ai ma ligne titre qui contient ma ligne, par contre je check pas s'il y a un sous-total |
| 348 | 415 | return $line; |
| 349 | 416 | break; |
| 350 | - } |
|
| 351 | - elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99) |
|
| 417 | + } elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99) |
|
| 352 | 418 | { |
| 353 | 419 | // 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) |
| 354 | 420 | $skip_title++; |
@@ -363,7 +429,9 @@ discard block |
||
| 363 | 429 | $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9; |
| 364 | 430 | if($res && $level > -1) { |
| 365 | 431 | return $line->qty == $level; |
| 366 | - } else return $res; |
|
| 432 | + } else { |
|
| 433 | + return $res; |
|
| 434 | + } |
|
| 367 | 435 | |
| 368 | 436 | } |
| 369 | 437 | |
@@ -372,7 +440,9 @@ discard block |
||
| 372 | 440 | $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90; |
| 373 | 441 | if($res && $level > -1) { |
| 374 | 442 | return self::getNiveau($line) == $level; |
| 375 | - } else return $res; |
|
| 443 | + } else { |
|
| 444 | + return $res; |
|
| 445 | + } |
|
| 376 | 446 | } |
| 377 | 447 | |
| 378 | 448 | public static function isFreeText(&$line) |
@@ -393,10 +463,14 @@ discard block |
||
| 393 | 463 | // editeur wysiwyg |
| 394 | 464 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
| 395 | 465 | $nbrows=ROWS_2; |
| 396 | - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
| 466 | + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) { |
|
| 467 | + $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
| 468 | + } |
|
| 397 | 469 | $enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); |
| 398 | 470 | $toolbarname='dolibarr_details'; |
| 399 | - if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; |
|
| 471 | + if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) { |
|
| 472 | + $toolbarname='dolibarr_notes'; |
|
| 473 | + } |
|
| 400 | 474 | $text = !empty($line->description)?$line->description:$line->label; |
| 401 | 475 | $doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly); |
| 402 | 476 | return $doleditor->Create(1); |
@@ -411,12 +485,10 @@ discard block |
||
| 411 | 485 | { |
| 412 | 486 | $object->statut = 0; // hack for facture rec |
| 413 | 487 | $createRight = $user->rights->facture->creer; |
| 414 | - } |
|
| 415 | - elseif($object->element == 'order_supplier' ) |
|
| 488 | + } elseif($object->element == 'order_supplier' ) |
|
| 416 | 489 | { |
| 417 | 490 | $createRight = $user->rights->fournisseur->commande->creer; |
| 418 | - } |
|
| 419 | - elseif($object->element == 'invoice_supplier' ) |
|
| 491 | + } elseif($object->element == 'invoice_supplier' ) |
|
| 420 | 492 | { |
| 421 | 493 | $createRight = $user->rights->fournisseur->facture->creer; |
| 422 | 494 | } |
@@ -489,8 +561,9 @@ discard block |
||
| 489 | 561 | |
| 490 | 562 | $TLineAdded[] = $object->line; |
| 491 | 563 | // Error from addline |
| 492 | - if ($res <= 0) break; |
|
| 493 | - else |
|
| 564 | + if ($res <= 0) { |
|
| 565 | + break; |
|
| 566 | + } else |
|
| 494 | 567 | { |
| 495 | 568 | $object->line_from = $line; |
| 496 | 569 | // Call trigger |
@@ -512,8 +585,7 @@ discard block |
||
| 512 | 585 | _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']); |
| 513 | 586 | } |
| 514 | 587 | return count($TLineAdded); |
| 515 | - } |
|
| 516 | - else |
|
| 588 | + } else |
|
| 517 | 589 | { |
| 518 | 590 | $object->db->rollback(); |
| 519 | 591 | return -1; |
@@ -529,10 +601,14 @@ discard block |
||
| 529 | 601 | global $langs; |
| 530 | 602 | |
| 531 | 603 | // Besoin de comparer sur les 2 formes d'écriture |
| 532 | - if (!$key_is_id) $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad)); |
|
| 604 | + if (!$key_is_id) { |
|
| 605 | + $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad)); |
|
| 606 | + } |
|
| 533 | 607 | |
| 534 | 608 | $TTitle_under_search = array(); |
| 535 | - if (!empty($under_title)) $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title)); |
|
| 609 | + if (!empty($under_title)) { |
|
| 610 | + $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title)); |
|
| 611 | + } |
|
| 536 | 612 | |
| 537 | 613 | $TLine = array(); |
| 538 | 614 | $add_line = false; |
@@ -542,28 +618,37 @@ discard block |
||
| 542 | 618 | { |
| 543 | 619 | if (!$under_title_found && !empty($TTitle_under_search)) |
| 544 | 620 | { |
| 545 | - if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true; |
|
| 546 | - } |
|
| 547 | - else |
|
| 621 | + if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) { |
|
| 622 | + $under_title_found = true; |
|
| 623 | + } |
|
| 624 | + } else |
|
| 548 | 625 | { |
| 549 | 626 | 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) ))) |
| 550 | 627 | { |
| 551 | - if ($key_is_id) $level = $line->qty; |
|
| 628 | + if ($key_is_id) { |
|
| 629 | + $level = $line->qty; |
|
| 630 | + } |
|
| 552 | 631 | |
| 553 | 632 | $add_line = true; |
| 554 | - if ($withBlockLine) $TLine[] = $line; |
|
| 633 | + if ($withBlockLine) { |
|
| 634 | + $TLine[] = $line; |
|
| 635 | + } |
|
| 555 | 636 | continue; |
| 556 | - } |
|
| 557 | - elseif ($add_line && TSubtotal::isModSubtotalLine($line) && TSubtotal::getNiveau($line) == $level) // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre |
|
| 637 | + } elseif ($add_line && TSubtotal::isModSubtotalLine($line) && TSubtotal::getNiveau($line) == $level) { |
|
| 638 | + // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre |
|
| 558 | 639 | { |
| 559 | 640 | if ($withBlockLine) $TLine[] = $line; |
| 641 | + } |
|
| 560 | 642 | break; |
| 561 | 643 | } |
| 562 | 644 | |
| 563 | 645 | if ($add_line) |
| 564 | 646 | { |
| 565 | - if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue; |
|
| 566 | - else $TLine[] = $line; |
|
| 647 | + if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) { |
|
| 648 | + continue; |
|
| 649 | + } else { |
|
| 650 | + $TLine[] = $line; |
|
| 651 | + } |
|
| 567 | 652 | } |
| 568 | 653 | } |
| 569 | 654 | } |
@@ -597,7 +682,9 @@ discard block |
||
| 597 | 682 | |
| 598 | 683 | case 'order_supplier': |
| 599 | 684 | $object->special_code = SELF::$module_number; |
| 600 | - if (empty($desc)) $desc = $label; |
|
| 685 | + if (empty($desc)) { |
|
| 686 | + $desc = $label; |
|
| 687 | + } |
|
| 601 | 688 | $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); |
| 602 | 689 | break; |
| 603 | 690 | |
@@ -607,7 +694,9 @@ discard block |
||
| 607 | 694 | |
| 608 | 695 | case 'invoice_supplier': |
| 609 | 696 | $object->special_code = SELF::$module_number; |
| 610 | - if (empty($desc)) $desc = $label; |
|
| 697 | + if (empty($desc)) { |
|
| 698 | + $desc = $label; |
|
| 699 | + } |
|
| 611 | 700 | $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); |
| 612 | 701 | break; |
| 613 | 702 | |
@@ -624,8 +713,11 @@ discard block |
||
| 624 | 713 | break; |
| 625 | 714 | } |
| 626 | 715 | |
| 627 | - if ($res <= 0) $object->db->rollback(); |
|
| 628 | - else $object->db->commit(); |
|
| 716 | + if ($res <= 0) { |
|
| 717 | + $object->db->rollback(); |
|
| 718 | + } else { |
|
| 719 | + $object->db->commit(); |
|
| 720 | + } |
|
| 629 | 721 | |
| 630 | 722 | return $res; |
| 631 | 723 | } |
@@ -635,24 +727,20 @@ discard block |
||
| 635 | 727 | global $db, $object; |
| 636 | 728 | |
| 637 | 729 | $TTitle = array(); |
| 638 | - if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} |
|
| 639 | - else { |
|
| 730 | + if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} else { |
|
| 640 | 731 | if ($origin_line->element == 'propaldet') |
| 641 | 732 | { |
| 642 | 733 | $object = new Propal($db); |
| 643 | 734 | $object->fetch($origin_line->fk_propal); |
| 644 | - } |
|
| 645 | - else if ($origin_line->element == 'commandedet') |
|
| 735 | + } else if ($origin_line->element == 'commandedet') |
|
| 646 | 736 | { |
| 647 | 737 | $object = new Commande($db); |
| 648 | 738 | $object->fetch($origin_line->fk_commande); |
| 649 | - } |
|
| 650 | - else if ($origin_line->element == 'facturedet') |
|
| 739 | + } else if ($origin_line->element == 'facturedet') |
|
| 651 | 740 | { |
| 652 | 741 | $object = new Facture($db); |
| 653 | 742 | $object->fetch($origin_line->fk_facture); |
| 654 | - } |
|
| 655 | - else |
|
| 743 | + } else |
|
| 656 | 744 | { |
| 657 | 745 | return $TTitle; |
| 658 | 746 | } |
@@ -662,8 +750,11 @@ discard block |
||
| 662 | 750 | $i = 0; |
| 663 | 751 | foreach ($object->lines as &$line) |
| 664 | 752 | { |
| 665 | - if ($origin_line->id == $line->id) break; |
|
| 666 | - else $i++; |
|
| 753 | + if ($origin_line->id == $line->id) { |
|
| 754 | + break; |
|
| 755 | + } else { |
|
| 756 | + $i++; |
|
| 757 | + } |
|
| 667 | 758 | } |
| 668 | 759 | |
| 669 | 760 | $i--; // Skip la ligne d'origine |
@@ -678,35 +769,43 @@ discard block |
||
| 678 | 769 | if (self::isSubtotal($object->lines[$y])) |
| 679 | 770 | { |
| 680 | 771 | $next_title_lvl_to_skip = self::getNiveau($object->lines[$y]); |
| 681 | - } |
|
| 682 | - elseif (self::isTitle($object->lines[$y])) |
|
| 772 | + } elseif (self::isTitle($object->lines[$y])) |
|
| 683 | 773 | { |
| 684 | 774 | if ($object->lines[$y]->qty == $next_title_lvl_to_skip) |
| 685 | 775 | { |
| 686 | 776 | $next_title_lvl_to_skip = 0; |
| 687 | 777 | continue; |
| 688 | - } |
|
| 689 | - else |
|
| 778 | + } else |
|
| 690 | 779 | { |
| 691 | - if (empty($object->lines[$y]->array_options)) $object->lines[$y]->fetch_optionals(); |
|
| 780 | + if (empty($object->lines[$y]->array_options)) { |
|
| 781 | + $object->lines[$y]->fetch_optionals(); |
|
| 782 | + } |
|
| 692 | 783 | $TTitle[$object->lines[$y]->id] = $object->lines[$y]; |
| 693 | 784 | |
| 694 | - if ($object->lines[$y]->qty == 1) break; |
|
| 785 | + if ($object->lines[$y]->qty == 1) { |
|
| 786 | + break; |
|
| 787 | + } |
|
| 695 | 788 | } |
| 696 | 789 | } |
| 697 | 790 | } |
| 698 | 791 | } |
| 699 | 792 | |
| 700 | - if ($reverse) $TTitle = array_reverse($TTitle, true); |
|
| 793 | + if ($reverse) { |
|
| 794 | + $TTitle = array_reverse($TTitle, true); |
|
| 795 | + } |
|
| 701 | 796 | |
| 702 | 797 | return $TTitle; |
| 703 | 798 | } |
| 704 | 799 | |
| 705 | 800 | public static function getNiveau(&$line) |
| 706 | 801 | { |
| 707 | - if (self::isTitle($line)) return $line->qty; |
|
| 708 | - elseif (self::isSubtotal($line)) return 100 - $line->qty; |
|
| 709 | - else return 0; |
|
| 802 | + if (self::isTitle($line)) { |
|
| 803 | + return $line->qty; |
|
| 804 | + } elseif (self::isSubtotal($line)) { |
|
| 805 | + return 100 - $line->qty; |
|
| 806 | + } else { |
|
| 807 | + return 0; |
|
| 808 | + } |
|
| 710 | 809 | } |
| 711 | 810 | |
| 712 | 811 | /** |
@@ -731,10 +830,16 @@ discard block |
||
| 731 | 830 | $objmarge->marge_droite = 10; |
| 732 | 831 | |
| 733 | 832 | $objectref = dol_sanitizeFileName($object->ref); |
| 734 | - if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref; |
|
| 735 | - elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref; |
|
| 736 | - elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref; |
|
| 737 | - elseif ($object->element == 'facturerec') return; // no PDF for facturerec |
|
| 833 | + if ($object->element == 'propal') { |
|
| 834 | + $dir = $conf->propal->dir_output . '/' . $objectref; |
|
| 835 | + } elseif ($object->element == 'commande') { |
|
| 836 | + $dir = $conf->commande->dir_output . '/' . $objectref; |
|
| 837 | + } elseif ($object->element == 'facture') { |
|
| 838 | + $dir = $conf->facture->dir_output . '/' . $objectref; |
|
| 839 | + } elseif ($object->element == 'facturerec') { |
|
| 840 | + return; |
|
| 841 | + } |
|
| 842 | + // no PDF for facturerec |
|
| 738 | 843 | else |
| 739 | 844 | { |
| 740 | 845 | setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings'); |
@@ -769,7 +874,9 @@ discard block |
||
| 769 | 874 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
| 770 | 875 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
| 771 | 876 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
| 772 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 877 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
| 878 | + $pdf->SetCompression(false); |
|
| 879 | + } |
|
| 773 | 880 | |
| 774 | 881 | $pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right |
| 775 | 882 | |
@@ -779,7 +886,9 @@ discard block |
||
| 779 | 886 | |
| 780 | 887 | // New page |
| 781 | 888 | $pdf->AddPage(); |
| 782 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 889 | + if (! empty($tplidx)) { |
|
| 890 | + $pdf->useTemplate($tplidx); |
|
| 891 | + } |
|
| 783 | 892 | $pagenb++; |
| 784 | 893 | |
| 785 | 894 | |
@@ -835,8 +944,10 @@ discard block |
||
| 835 | 944 | { |
| 836 | 945 | $TTot['TTotal_tva_multicurrency'][$tx] += $amount; |
| 837 | 946 | } |
| 947 | + } else { |
|
| 948 | + $pdf->SetFont('','', $default_font_size - 1); |
|
| 838 | 949 | } |
| 839 | - else $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
| 950 | + // Into loop to work with multipage |
|
| 840 | 951 | |
| 841 | 952 | $pdf->SetTextColor(0,0,0); |
| 842 | 953 | |
@@ -858,9 +969,11 @@ discard block |
||
| 858 | 969 | $pdf->startTransaction(); |
| 859 | 970 | $pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true); |
| 860 | 971 | $pageposafter=$pdf->getPage(); |
| 861 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
| 972 | + if ($pageposafter > $pageposbefore) { |
|
| 973 | + // There is a pagebreak |
|
| 862 | 974 | { |
| 863 | 975 | $pdf->rollbackTransaction(true); |
| 976 | + } |
|
| 864 | 977 | $pageposafter=$pageposbefore; |
| 865 | 978 | //print $pageposafter.'-'.$pageposbefore;exit; |
| 866 | 979 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
@@ -869,23 +982,27 @@ discard block |
||
| 869 | 982 | $pageposafter=$pdf->getPage(); |
| 870 | 983 | $posyafter=$pdf->GetY(); |
| 871 | 984 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
| 872 | - if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) // There is no space left for total+free text |
|
| 985 | + if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) { |
|
| 986 | + // There is no space left for total+free text |
|
| 873 | 987 | { |
| 874 | 988 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
| 875 | 989 | { |
| 876 | 990 | $pdf->AddPage('','',true); |
| 877 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 878 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
| 991 | + } |
|
| 992 | + if (! empty($tplidx)) { |
|
| 993 | + $pdf->useTemplate($tplidx); |
|
| 994 | + } |
|
| 995 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
| 996 | + self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
| 997 | + } |
|
| 879 | 998 | $pdf->setPage($pageposafter+1); |
| 880 | 999 | } |
| 881 | - } |
|
| 882 | - else |
|
| 1000 | + } else |
|
| 883 | 1001 | { |
| 884 | 1002 | // We found a page break |
| 885 | 1003 | $showpricebeforepagebreak=0; |
| 886 | 1004 | } |
| 887 | - } |
|
| 888 | - else // No pagebreak |
|
| 1005 | + } else // No pagebreak |
|
| 889 | 1006 | { |
| 890 | 1007 | $pdf->commitTransaction(); |
| 891 | 1008 | } |
@@ -925,8 +1042,7 @@ discard block |
||
| 925 | 1042 | if ($pagenb == 1) |
| 926 | 1043 | { |
| 927 | 1044 | 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); |
| 928 | - } |
|
| 929 | - else |
|
| 1045 | + } else |
|
| 930 | 1046 | { |
| 931 | 1047 | 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); |
| 932 | 1048 | } |
@@ -934,7 +1050,9 @@ discard block |
||
| 934 | 1050 | $pagenb++; |
| 935 | 1051 | $pdf->setPage($pagenb); |
| 936 | 1052 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
| 937 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
| 1053 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
| 1054 | + self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
| 1055 | + } |
|
| 938 | 1056 | } |
| 939 | 1057 | } |
| 940 | 1058 | } |
@@ -944,8 +1062,7 @@ discard block |
||
| 944 | 1062 | { |
| 945 | 1063 | 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); |
| 946 | 1064 | $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
| 947 | - } |
|
| 948 | - else |
|
| 1065 | + } else |
|
| 949 | 1066 | { |
| 950 | 1067 | 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); |
| 951 | 1068 | $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
@@ -959,7 +1076,9 @@ discard block |
||
| 959 | 1076 | |
| 960 | 1077 | $pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file); |
| 961 | 1078 | |
| 962 | - if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) unlink($file); |
|
| 1079 | + if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) { |
|
| 1080 | + unlink($file); |
|
| 1081 | + } |
|
| 963 | 1082 | } |
| 964 | 1083 | |
| 965 | 1084 | private static function printLevel($objmarge, $pdf, $line, $curY, $posx_designation) |
@@ -1002,8 +1121,7 @@ discard block |
||
| 1002 | 1121 | { |
| 1003 | 1122 | $height=pdf_getHeightForLogo($logo); |
| 1004 | 1123 | $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto) |
| 1005 | - } |
|
| 1006 | - else |
|
| 1124 | + } else |
|
| 1007 | 1125 | { |
| 1008 | 1126 | $pdf->SetTextColor(200,0,0); |
| 1009 | 1127 | $pdf->SetFont('','B',$default_font_size - 2); |
@@ -1012,8 +1130,7 @@ discard block |
||
| 1012 | 1130 | } |
| 1013 | 1131 | |
| 1014 | 1132 | $posy+=35; |
| 1015 | - } |
|
| 1016 | - else |
|
| 1133 | + } else |
|
| 1017 | 1134 | { |
| 1018 | 1135 | $text=$mysoc->name; |
| 1019 | 1136 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -1027,9 +1144,13 @@ discard block |
||
| 1027 | 1144 | $pdf->SetXY($objmarge->marge_gauche,$posy); |
| 1028 | 1145 | |
| 1029 | 1146 | $key = 'subtotalPropalTitle'; |
| 1030 | - if ($object->element == 'commande') $key = 'subtotalCommandeTitle'; |
|
| 1031 | - elseif ($object->element == 'facture') $key = 'subtotalInvoiceTitle'; |
|
| 1032 | - elseif ($object->element == 'facturerec') $key = 'subtotalInvoiceTitle'; |
|
| 1147 | + if ($object->element == 'commande') { |
|
| 1148 | + $key = 'subtotalCommandeTitle'; |
|
| 1149 | + } elseif ($object->element == 'facture') { |
|
| 1150 | + $key = 'subtotalInvoiceTitle'; |
|
| 1151 | + } elseif ($object->element == 'facturerec') { |
|
| 1152 | + $key = 'subtotalInvoiceTitle'; |
|
| 1153 | + } |
|
| 1033 | 1154 | |
| 1034 | 1155 | $pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L'); |
| 1035 | 1156 | |
@@ -1064,7 +1185,9 @@ discard block |
||
| 1064 | 1185 | |
| 1065 | 1186 | // Force to disable hidetop and hidebottom |
| 1066 | 1187 | $hidebottom=0; |
| 1067 | - if ($hidetop) $hidetop=-1; |
|
| 1188 | + if ($hidetop) { |
|
| 1189 | + $hidetop=-1; |
|
| 1190 | + } |
|
| 1068 | 1191 | |
| 1069 | 1192 | $currency = !empty($currency) ? $currency : $conf->currency; |
| 1070 | 1193 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
@@ -1079,7 +1202,9 @@ discard block |
||
| 1079 | 1202 | $pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5); |
| 1080 | 1203 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
| 1081 | 1204 | |
| 1082 | - 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)); |
|
| 1205 | + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { |
|
| 1206 | + $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)); |
|
| 1207 | + } |
|
| 1083 | 1208 | |
| 1084 | 1209 | |
| 1085 | 1210 | $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 |
@@ -1092,8 +1217,7 @@ discard block |
||
| 1092 | 1217 | $pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R'); |
| 1093 | 1218 | |
| 1094 | 1219 | $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 |
| 1095 | - } |
|
| 1096 | - else |
|
| 1220 | + } else |
|
| 1097 | 1221 | { |
| 1098 | 1222 | $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 |
| 1099 | 1223 | } |
@@ -1114,10 +1238,12 @@ discard block |
||
| 1114 | 1238 | |
| 1115 | 1239 | // Tableau total |
| 1116 | 1240 | $col1x = 120; $col2x = 170; |
| 1117 | - if ($objmarge->page_largeur < 210) // To work with US executive format |
|
| 1241 | + if ($objmarge->page_largeur < 210) { |
|
| 1242 | + // To work with US executive format |
|
| 1118 | 1243 | { |
| 1119 | 1244 | $col2x-=20; |
| 1120 | 1245 | } |
| 1246 | + } |
|
| 1121 | 1247 | $largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x); |
| 1122 | 1248 | |
| 1123 | 1249 | $useborder=0; |
@@ -1139,9 +1265,11 @@ discard block |
||
| 1139 | 1265 | $atleastoneratenotnull=0; |
| 1140 | 1266 | foreach($TTot['TTotal_tva'] as $tvakey => $tvaval) |
| 1141 | 1267 | { |
| 1142 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
| 1268 | + if ($tvakey != 0) { |
|
| 1269 | + // On affiche pas taux 0 |
|
| 1143 | 1270 | { |
| 1144 | 1271 | $atleastoneratenotnull++; |
| 1272 | + } |
|
| 1145 | 1273 | |
| 1146 | 1274 | $index++; |
| 1147 | 1275 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -1194,9 +1322,13 @@ discard block |
||
| 1194 | 1322 | */ |
| 1195 | 1323 | private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
| 1196 | 1324 | { |
| 1197 | - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
| 1325 | + if (empty($hidetop) || $hidetop==-1) { |
|
| 1326 | + $pdf->line($x, $y, $x+$l, $y); |
|
| 1327 | + } |
|
| 1198 | 1328 | $pdf->line($x+$l, $y, $x+$l, $y+$h); |
| 1199 | - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
| 1329 | + if (empty($hidebottom)) { |
|
| 1330 | + $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
| 1331 | + } |
|
| 1200 | 1332 | $pdf->line($x, $y+$h, $x, $y); |
| 1201 | 1333 | } |
| 1202 | 1334 | |
@@ -1205,7 +1337,9 @@ discard block |
||
| 1205 | 1337 | { |
| 1206 | 1338 | global $conf; |
| 1207 | 1339 | |
| 1208 | - if (empty($fileoutput)) $fileoutput = $file[0]; |
|
| 1340 | + if (empty($fileoutput)) { |
|
| 1341 | + $fileoutput = $file[0]; |
|
| 1342 | + } |
|
| 1209 | 1343 | |
| 1210 | 1344 | $pdf=pdf_getInstance(); |
| 1211 | 1345 | if (class_exists('TCPDF')) |
@@ -1215,7 +1349,9 @@ discard block |
||
| 1215 | 1349 | } |
| 1216 | 1350 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
| 1217 | 1351 | |
| 1218 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 1352 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
| 1353 | + $pdf->SetCompression(false); |
|
| 1354 | + } |
|
| 1219 | 1355 | |
| 1220 | 1356 | |
| 1221 | 1357 | foreach($files as $file) |
@@ -1231,7 +1367,9 @@ discard block |
||
| 1231 | 1367 | } |
| 1232 | 1368 | |
| 1233 | 1369 | $pdf->Output($fileoutput,'F'); |
| 1234 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 1370 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 1371 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 1372 | + } |
|
| 1235 | 1373 | |
| 1236 | 1374 | return $pagecount; |
| 1237 | 1375 | } |
@@ -1244,7 +1382,9 @@ discard block |
||
| 1244 | 1382 | */ |
| 1245 | 1383 | public static function hasNcTitle(&$line) |
| 1246 | 1384 | { |
| 1247 | - if(isset($line->has_nc_title)) return $line->has_nc_title; |
|
| 1385 | + if(isset($line->has_nc_title)) { |
|
| 1386 | + return $line->has_nc_title; |
|
| 1387 | + } |
|
| 1248 | 1388 | |
| 1249 | 1389 | $TTitle = self::getAllTitleFromLine($line); |
| 1250 | 1390 | foreach ($TTitle as &$line_title) |
@@ -1269,7 +1409,9 @@ discard block |
||
| 1269 | 1409 | public static function getTitleLabel($line) |
| 1270 | 1410 | { |
| 1271 | 1411 | $title = $line->label; |
| 1272 | - if (empty($title)) $title = !empty($line->description) ? $line->description : $line->desc; |
|
| 1412 | + if (empty($title)) { |
|
| 1413 | + $title = !empty($line->description) ? $line->description : $line->desc; |
|
| 1414 | + } |
|
| 1273 | 1415 | return $title; |
| 1274 | 1416 | } |
| 1275 | 1417 | } |