@@ -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,28 +41,38 @@ 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 | */ |
| 43 | 50 | else if($object->element=='invoice_supplier') { |
| 44 | 51 | $object->special_code = TSubtotal::$module_number; |
| 45 | - if( (float)DOL_VERSION < 6 ) $rang = $object->line_max() + 1; |
|
| 52 | + if( (float)DOL_VERSION < 6 ) { |
|
| 53 | + $rang = $object->line_max() + 1; |
|
| 54 | + } |
|
| 46 | 55 | $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
| 47 | 56 | } |
| 48 | 57 | /** |
| 49 | 58 | * @var $object Propal |
| 50 | 59 | */ |
| 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); |
|
| 60 | + else if($object->element=='propal') { |
|
| 61 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
| 62 | + } |
|
| 52 | 63 | /** |
| 53 | 64 | * @var $object Propal Fournisseur |
| 54 | 65 | */ |
| 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); |
|
| 66 | + else if($object->element=='supplier_proposal') { |
|
| 67 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
| 68 | + } |
|
| 56 | 69 | |
| 57 | 70 | /** |
| 58 | 71 | * @var $object Commande |
| 59 | 72 | */ |
| 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); |
|
| 73 | + else if($object->element=='commande') { |
|
| 74 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label); |
|
| 75 | + } |
|
| 61 | 76 | /** |
| 62 | 77 | * @var $object Commande fournisseur |
| 63 | 78 | */ |
@@ -68,7 +83,9 @@ discard block |
||
| 68 | 83 | /** |
| 69 | 84 | * @var $object Facturerec |
| 70 | 85 | */ |
| 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); |
|
| 86 | + else if($object->element=='facturerec') { |
|
| 87 | + $res = $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); |
|
| 88 | + } |
|
| 72 | 89 | |
| 73 | 90 | } |
| 74 | 91 | |
@@ -90,8 +107,9 @@ discard block |
||
| 90 | 107 | // Define output language |
| 91 | 108 | $outputlangs = $langs; |
| 92 | 109 | $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; |
|
| 110 | + if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { |
|
| 111 | + $newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang; |
|
| 112 | + } |
|
| 95 | 113 | if (! empty($newlang)) { |
| 96 | 114 | $outputlangs = new Translate("", $conf); |
| 97 | 115 | $outputlangs->setDefaultLang($newlang); |
@@ -100,13 +118,18 @@ discard block |
||
| 100 | 118 | $ret = $object->fetch($object->id); // Reload to get new records |
| 101 | 119 | if ((float) DOL_VERSION <= 3.6) |
| 102 | 120 | { |
| 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 |
|
| 121 | + if ($object->element == 'propal') { |
|
| 122 | + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 123 | + } elseif ($object->element == 'commande') { |
|
| 124 | + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 125 | + } elseif ($object->element == 'facture') { |
|
| 126 | + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 127 | + } |
|
| 128 | + } else |
|
| 108 | 129 | { |
| 109 | - if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 130 | + if ($object->element!= 'facturerec') { |
|
| 131 | + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 132 | + } |
|
| 110 | 133 | } |
| 111 | 134 | } |
| 112 | 135 | } |
@@ -120,7 +143,9 @@ discard block |
||
| 120 | 143 | */ |
| 121 | 144 | public static function updateRang(&$object, $rang_start, $move_to=1) |
| 122 | 145 | { |
| 123 | - if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
|
| 146 | + if (!class_exists('GenericObject')) { |
|
| 147 | + require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
|
| 148 | + } |
|
| 124 | 149 | |
| 125 | 150 | $row=new GenericObject($object->db); |
| 126 | 151 | $row->table_element_line = $object->table_element_line; |
@@ -129,7 +154,9 @@ discard block |
||
| 129 | 154 | |
| 130 | 155 | foreach ($object->lines as &$line) |
| 131 | 156 | { |
| 132 | - if ($line->rang < $rang_start) continue; |
|
| 157 | + if ($line->rang < $rang_start) { |
|
| 158 | + continue; |
|
| 159 | + } |
|
| 133 | 160 | |
| 134 | 161 | $row->updateRangOfLine($line->id, $line->rang+$move_to); |
| 135 | 162 | } |
@@ -152,21 +179,28 @@ discard block |
||
| 152 | 179 | foreach ($TTitle_reverse as $k => $title_line) |
| 153 | 180 | { |
| 154 | 181 | $title_niveau = self::getNiveau($title_line); |
| 155 | - if ($title_niveau < $level_new_title) break; |
|
| 182 | + if ($title_niveau < $level_new_title) { |
|
| 183 | + break; |
|
| 184 | + } |
|
| 156 | 185 | |
| 157 | 186 | $rang_to_add = self::titleHasTotalLine($object, $title_line, true, true); |
| 158 | 187 | |
| 159 | 188 | if (is_numeric($rang_to_add)) |
| 160 | 189 | { |
| 161 | - if ($rang_to_add != -1) self::updateRang($object, $rang_to_add); |
|
| 190 | + if ($rang_to_add != -1) { |
|
| 191 | + self::updateRang($object, $rang_to_add); |
|
| 192 | + } |
|
| 162 | 193 | |
| 163 | 194 | self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add); |
| 164 | 195 | |
| 165 | 196 | $object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas) |
| 166 | 197 | if ($rang_to_add != -1) |
| 167 | 198 | { |
| 168 | - if (method_exists($object, 'fetch_lines')) $object->fetch_lines(); |
|
| 169 | - else $object->fetch($object->id); |
|
| 199 | + if (method_exists($object, 'fetch_lines')) { |
|
| 200 | + $object->fetch_lines(); |
|
| 201 | + } else { |
|
| 202 | + $object->fetch($object->id); |
|
| 203 | + } |
|
| 170 | 204 | } |
| 171 | 205 | } |
| 172 | 206 | } |
@@ -196,7 +230,9 @@ discard block |
||
| 196 | 230 | |
| 197 | 231 | foreach ($TTitle as $k => $title_line) |
| 198 | 232 | { |
| 199 | - if (self::titleHasTotalLine($object, $title_line)) unset($TTitle[$k]); |
|
| 233 | + if (self::titleHasTotalLine($object, $title_line)) { |
|
| 234 | + unset($TTitle[$k]); |
|
| 235 | + } |
|
| 200 | 236 | } |
| 201 | 237 | |
| 202 | 238 | return $TTitle; |
@@ -213,23 +249,41 @@ discard block |
||
| 213 | 249 | */ |
| 214 | 250 | public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false) |
| 215 | 251 | { |
| 216 | - if (empty($object->lines) || !is_array($object->lines)) return false; |
|
| 252 | + if (empty($object->lines) || !is_array($object->lines)) { |
|
| 253 | + return false; |
|
| 254 | + } |
|
| 217 | 255 | |
| 218 | 256 | $title_niveau = self::getNiveau($title_line); |
| 219 | 257 | foreach ($object->lines as &$line) |
| 220 | 258 | { |
| 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; |
|
| 259 | + if ($line->rang <= $title_line->rang) { |
|
| 260 | + continue; |
|
| 261 | + } |
|
| 262 | + if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) { |
|
| 263 | + return false; |
|
| 264 | + } |
|
| 265 | + // Oups on croise un titre d'un niveau inférieur ou égale (exemple : je croise un titre niveau 2 alors que je suis sur un titre de niveau 3) pas lieu de continuer car un nouveau bloc commence |
|
| 266 | + if (!self::isSubtotal($line)) { |
|
| 267 | + continue; |
|
| 268 | + } |
|
| 224 | 269 | |
| 225 | 270 | $subtotal_niveau = self::getNiveau($line); |
| 226 | 271 | |
| 227 | 272 | // 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) |
|
| 273 | + if ($subtotal_niveau == $title_niveau) { |
|
| 274 | + return true; |
|
| 275 | + } |
|
| 276 | + // niveau égale => Ok mon titre a un sous-total |
|
| 277 | + elseif ($subtotal_niveau < $title_niveau) { |
|
| 278 | + // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3) |
|
| 230 | 279 | { |
| 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 |
|
| 280 | + if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; |
|
| 281 | + } |
|
| 282 | + // mode strict niveau pas égale donc faux |
|
| 283 | + else { |
|
| 284 | + return true; |
|
| 285 | + } |
|
| 286 | + // mode libre => OK je considère que mon titre à un sous-total |
|
| 233 | 287 | } |
| 234 | 288 | } |
| 235 | 289 | |
@@ -277,16 +331,19 @@ discard block |
||
| 277 | 331 | |
| 278 | 332 | foreach ($object->lines as &$l) |
| 279 | 333 | { |
| 280 | - if ($l->rang <= $line->rang) continue; |
|
| 281 | - elseif (self::isSubtotal($l) && self::getNiveau($l) <= self::getNiveau($line)) break; |
|
| 282 | - elseif ($breakOnTitle && self::isTitle($l) && self::getNiveau($l) <= self::getNiveau($line)) break; |
|
| 334 | + if ($l->rang <= $line->rang) { |
|
| 335 | + continue; |
|
| 336 | + } elseif (self::isSubtotal($l) && self::getNiveau($l) <= self::getNiveau($line)) { |
|
| 337 | + break; |
|
| 338 | + } elseif ($breakOnTitle && self::isTitle($l) && self::getNiveau($l) <= self::getNiveau($line)) { |
|
| 339 | + break; |
|
| 340 | + } |
|
| 283 | 341 | |
| 284 | 342 | if (!empty($l->array_options['options_subtotal_nc'])) |
| 285 | 343 | { |
| 286 | 344 | $tabprice = calcul_price_total($l->qty, $l->subprice, $l->remise_percent, $l->tva_tx, $l->localtax1_tx, $l->localtax2_tx, 0, 'HT', $l->info_bits, $l->product_type); |
| 287 | 345 | $TTot['total_options'] += $tabprice[0]; // total ht |
| 288 | - } |
|
| 289 | - else |
|
| 346 | + } else |
|
| 290 | 347 | { |
| 291 | 348 | $TTot['total_pa_ht'] += $l->pa_ht * $l->qty; |
| 292 | 349 | $TTot['total_subprice'] += $l->subprice * $l->qty; |
@@ -307,35 +364,51 @@ discard block |
||
| 307 | 364 | |
| 308 | 365 | public static function getOrderIdFromLineId(&$db, $fk_commandedet, $supplier = false) |
| 309 | 366 | { |
| 310 | - if (empty($fk_commandedet)) return false; |
|
| 367 | + if (empty($fk_commandedet)) { |
|
| 368 | + return false; |
|
| 369 | + } |
|
| 311 | 370 | |
| 312 | 371 | $table = 'commandedet'; |
| 313 | - if ($supplier) $table = 'commande_fournisseurdet'; |
|
| 372 | + if ($supplier) { |
|
| 373 | + $table = 'commande_fournisseurdet'; |
|
| 374 | + } |
|
| 314 | 375 | |
| 315 | 376 | $sql = 'SELECT fk_commande FROM '.MAIN_DB_PREFIX.$table.' WHERE rowid = '.$fk_commandedet; |
| 316 | 377 | $resql = $db->query($sql); |
| 317 | 378 | |
| 318 | - if ($resql && ($row = $db->fetch_object($resql))) return $row->fk_commande; |
|
| 319 | - else return false; |
|
| 379 | + if ($resql && ($row = $db->fetch_object($resql))) { |
|
| 380 | + return $row->fk_commande; |
|
| 381 | + } else { |
|
| 382 | + return false; |
|
| 383 | + } |
|
| 320 | 384 | } |
| 321 | 385 | |
| 322 | 386 | public static function getLastLineOrderId(&$db, $fk_commande, $supplier = false) |
| 323 | 387 | { |
| 324 | - if (empty($fk_commande)) return false; |
|
| 388 | + if (empty($fk_commande)) { |
|
| 389 | + return false; |
|
| 390 | + } |
|
| 325 | 391 | |
| 326 | 392 | $table = 'commandedet'; |
| 327 | - if ($supplier) $table = 'commande_fournisseurdet'; |
|
| 393 | + if ($supplier) { |
|
| 394 | + $table = 'commande_fournisseurdet'; |
|
| 395 | + } |
|
| 328 | 396 | |
| 329 | 397 | $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$table.' WHERE fk_commande = '.$fk_commande.' ORDER BY rang DESC LIMIT 1'; |
| 330 | 398 | $resql = $db->query($sql); |
| 331 | 399 | |
| 332 | - if ($resql && ($row = $db->fetch_object($resql))) return $row->rowid; |
|
| 333 | - else return false; |
|
| 400 | + if ($resql && ($row = $db->fetch_object($resql))) { |
|
| 401 | + return $row->rowid; |
|
| 402 | + } else { |
|
| 403 | + return false; |
|
| 404 | + } |
|
| 334 | 405 | } |
| 335 | 406 | |
| 336 | 407 | public static function getParentTitleOfLine(&$object, $i) |
| 337 | 408 | { |
| 338 | - if ($i <= 0) return false; |
|
| 409 | + if ($i <= 0) { |
|
| 410 | + return false; |
|
| 411 | + } |
|
| 339 | 412 | |
| 340 | 413 | $skip_title = 0; |
| 341 | 414 | // Je parcours les lignes précédentes |
@@ -354,8 +427,7 @@ discard block |
||
| 354 | 427 | //@INFO J'ai ma ligne titre qui contient ma ligne, par contre je check pas s'il y a un sous-total |
| 355 | 428 | return $line; |
| 356 | 429 | break; |
| 357 | - } |
|
| 358 | - elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99) |
|
| 430 | + } elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99) |
|
| 359 | 431 | { |
| 360 | 432 | // 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) |
| 361 | 433 | $skip_title++; |
@@ -370,7 +442,9 @@ discard block |
||
| 370 | 442 | $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9; |
| 371 | 443 | if($res && $level > -1) { |
| 372 | 444 | return $line->qty == $level; |
| 373 | - } else return $res; |
|
| 445 | + } else { |
|
| 446 | + return $res; |
|
| 447 | + } |
|
| 374 | 448 | |
| 375 | 449 | } |
| 376 | 450 | |
@@ -379,7 +453,9 @@ discard block |
||
| 379 | 453 | $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90; |
| 380 | 454 | if($res && $level > -1) { |
| 381 | 455 | return self::getNiveau($line) == $level; |
| 382 | - } else return $res; |
|
| 456 | + } else { |
|
| 457 | + return $res; |
|
| 458 | + } |
|
| 383 | 459 | } |
| 384 | 460 | |
| 385 | 461 | public static function isFreeText(&$line) |
@@ -400,10 +476,14 @@ discard block |
||
| 400 | 476 | // editeur wysiwyg |
| 401 | 477 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
| 402 | 478 | $nbrows=ROWS_2; |
| 403 | - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
| 479 | + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) { |
|
| 480 | + $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
| 481 | + } |
|
| 404 | 482 | $enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); |
| 405 | 483 | $toolbarname='dolibarr_details'; |
| 406 | - if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; |
|
| 484 | + if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) { |
|
| 485 | + $toolbarname='dolibarr_notes'; |
|
| 486 | + } |
|
| 407 | 487 | $text = !empty($line->description)?$line->description:$line->label; |
| 408 | 488 | $doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly); |
| 409 | 489 | return $doleditor->Create(1); |
@@ -418,12 +498,10 @@ discard block |
||
| 418 | 498 | { |
| 419 | 499 | $object->statut = 0; // hack for facture rec |
| 420 | 500 | $createRight = $user->rights->facture->creer; |
| 421 | - } |
|
| 422 | - elseif($object->element == 'order_supplier' ) |
|
| 501 | + } elseif($object->element == 'order_supplier' ) |
|
| 423 | 502 | { |
| 424 | 503 | $createRight = $user->rights->fournisseur->commande->creer; |
| 425 | - } |
|
| 426 | - elseif($object->element == 'invoice_supplier' ) |
|
| 504 | + } elseif($object->element == 'invoice_supplier' ) |
|
| 427 | 505 | { |
| 428 | 506 | $createRight = $user->rights->fournisseur->facture->creer; |
| 429 | 507 | } |
@@ -434,11 +512,16 @@ discard block |
||
| 434 | 512 | |
| 435 | 513 | if(!empty($object->lines)) { |
| 436 | 514 | foreach($object->lines as $line) { |
| 437 | - if($line->id == $lineid) $duplicateLine = $line; |
|
| 515 | + if($line->id == $lineid) { |
|
| 516 | + $duplicateLine = $line; |
|
| 517 | + } |
|
| 438 | 518 | } |
| 439 | 519 | } |
| 440 | - if(!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) $TLine = array($duplicateLine); |
|
| 441 | - else $TLine = self::getLinesFromTitleId($object, $lineid, $withBlockLine); |
|
| 520 | + if(!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) { |
|
| 521 | + $TLine = array($duplicateLine); |
|
| 522 | + } else { |
|
| 523 | + $TLine = self::getLinesFromTitleId($object, $lineid, $withBlockLine); |
|
| 524 | + } |
|
| 442 | 525 | |
| 443 | 526 | if (!empty($TLine)) |
| 444 | 527 | { |
@@ -502,8 +585,9 @@ discard block |
||
| 502 | 585 | |
| 503 | 586 | $TLineAdded[] = $object->line; |
| 504 | 587 | // Error from addline |
| 505 | - if ($res <= 0) break; |
|
| 506 | - else |
|
| 588 | + if ($res <= 0) { |
|
| 589 | + break; |
|
| 590 | + } else |
|
| 507 | 591 | { |
| 508 | 592 | $object->line_from = $line; |
| 509 | 593 | // Call trigger |
@@ -525,8 +609,7 @@ discard block |
||
| 525 | 609 | _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']); |
| 526 | 610 | } |
| 527 | 611 | return count($TLineAdded); |
| 528 | - } |
|
| 529 | - else |
|
| 612 | + } else |
|
| 530 | 613 | { |
| 531 | 614 | $object->db->rollback(); |
| 532 | 615 | return -1; |
@@ -542,10 +625,14 @@ discard block |
||
| 542 | 625 | global $langs; |
| 543 | 626 | |
| 544 | 627 | // Besoin de comparer sur les 2 formes d'écriture |
| 545 | - if (!$key_is_id) $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad)); |
|
| 628 | + if (!$key_is_id) { |
|
| 629 | + $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad)); |
|
| 630 | + } |
|
| 546 | 631 | |
| 547 | 632 | $TTitle_under_search = array(); |
| 548 | - if (!empty($under_title)) $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title)); |
|
| 633 | + if (!empty($under_title)) { |
|
| 634 | + $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title)); |
|
| 635 | + } |
|
| 549 | 636 | |
| 550 | 637 | $TLine = array(); |
| 551 | 638 | $add_line = false; |
@@ -555,28 +642,37 @@ discard block |
||
| 555 | 642 | { |
| 556 | 643 | if (!$under_title_found && !empty($TTitle_under_search)) |
| 557 | 644 | { |
| 558 | - if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true; |
|
| 559 | - } |
|
| 560 | - else |
|
| 645 | + if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) { |
|
| 646 | + $under_title_found = true; |
|
| 647 | + } |
|
| 648 | + } else |
|
| 561 | 649 | { |
| 562 | 650 | 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) ))) |
| 563 | 651 | { |
| 564 | - if ($key_is_id) $level = $line->qty; |
|
| 652 | + if ($key_is_id) { |
|
| 653 | + $level = $line->qty; |
|
| 654 | + } |
|
| 565 | 655 | |
| 566 | 656 | $add_line = true; |
| 567 | - if ($withBlockLine) $TLine[] = $line; |
|
| 657 | + if ($withBlockLine) { |
|
| 658 | + $TLine[] = $line; |
|
| 659 | + } |
|
| 568 | 660 | continue; |
| 569 | - } |
|
| 570 | - 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 |
|
| 661 | + } elseif ($add_line && TSubtotal::isModSubtotalLine($line) && TSubtotal::getNiveau($line) == $level) { |
|
| 662 | + // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre |
|
| 571 | 663 | { |
| 572 | 664 | if ($withBlockLine) $TLine[] = $line; |
| 665 | + } |
|
| 573 | 666 | break; |
| 574 | 667 | } |
| 575 | 668 | |
| 576 | 669 | if ($add_line) |
| 577 | 670 | { |
| 578 | - if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue; |
|
| 579 | - else $TLine[] = $line; |
|
| 671 | + if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) { |
|
| 672 | + continue; |
|
| 673 | + } else { |
|
| 674 | + $TLine[] = $line; |
|
| 675 | + } |
|
| 580 | 676 | } |
| 581 | 677 | } |
| 582 | 678 | } |
@@ -610,7 +706,9 @@ discard block |
||
| 610 | 706 | |
| 611 | 707 | case 'order_supplier': |
| 612 | 708 | $object->special_code = SELF::$module_number; |
| 613 | - if (empty($desc)) $desc = $label; |
|
| 709 | + if (empty($desc)) { |
|
| 710 | + $desc = $label; |
|
| 711 | + } |
|
| 614 | 712 | $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); |
| 615 | 713 | break; |
| 616 | 714 | |
@@ -620,7 +718,9 @@ discard block |
||
| 620 | 718 | |
| 621 | 719 | case 'invoice_supplier': |
| 622 | 720 | $object->special_code = SELF::$module_number; |
| 623 | - if (empty($desc)) $desc = $label; |
|
| 721 | + if (empty($desc)) { |
|
| 722 | + $desc = $label; |
|
| 723 | + } |
|
| 624 | 724 | $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); |
| 625 | 725 | break; |
| 626 | 726 | |
@@ -637,8 +737,11 @@ discard block |
||
| 637 | 737 | break; |
| 638 | 738 | } |
| 639 | 739 | |
| 640 | - if ($res <= 0) $object->db->rollback(); |
|
| 641 | - else $object->db->commit(); |
|
| 740 | + if ($res <= 0) { |
|
| 741 | + $object->db->rollback(); |
|
| 742 | + } else { |
|
| 743 | + $object->db->commit(); |
|
| 744 | + } |
|
| 642 | 745 | |
| 643 | 746 | return $res; |
| 644 | 747 | } |
@@ -648,24 +751,20 @@ discard block |
||
| 648 | 751 | global $db, $object; |
| 649 | 752 | |
| 650 | 753 | $TTitle = array(); |
| 651 | - if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} |
|
| 652 | - else { |
|
| 754 | + if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} else { |
|
| 653 | 755 | if ($origin_line->element == 'propaldet') |
| 654 | 756 | { |
| 655 | 757 | $object = new Propal($db); |
| 656 | 758 | $object->fetch($origin_line->fk_propal); |
| 657 | - } |
|
| 658 | - else if ($origin_line->element == 'commandedet') |
|
| 759 | + } else if ($origin_line->element == 'commandedet') |
|
| 659 | 760 | { |
| 660 | 761 | $object = new Commande($db); |
| 661 | 762 | $object->fetch($origin_line->fk_commande); |
| 662 | - } |
|
| 663 | - else if ($origin_line->element == 'facturedet') |
|
| 763 | + } else if ($origin_line->element == 'facturedet') |
|
| 664 | 764 | { |
| 665 | 765 | $object = new Facture($db); |
| 666 | 766 | $object->fetch($origin_line->fk_facture); |
| 667 | - } |
|
| 668 | - else |
|
| 767 | + } else |
|
| 669 | 768 | { |
| 670 | 769 | return $TTitle; |
| 671 | 770 | } |
@@ -675,8 +774,11 @@ discard block |
||
| 675 | 774 | $i = 0; |
| 676 | 775 | foreach ($object->lines as &$line) |
| 677 | 776 | { |
| 678 | - if ($origin_line->id == $line->id) break; |
|
| 679 | - else $i++; |
|
| 777 | + if ($origin_line->id == $line->id) { |
|
| 778 | + break; |
|
| 779 | + } else { |
|
| 780 | + $i++; |
|
| 781 | + } |
|
| 680 | 782 | } |
| 681 | 783 | |
| 682 | 784 | $i--; // Skip la ligne d'origine |
@@ -691,35 +793,43 @@ discard block |
||
| 691 | 793 | if (self::isSubtotal($object->lines[$y])) |
| 692 | 794 | { |
| 693 | 795 | $next_title_lvl_to_skip = self::getNiveau($object->lines[$y]); |
| 694 | - } |
|
| 695 | - elseif (self::isTitle($object->lines[$y])) |
|
| 796 | + } elseif (self::isTitle($object->lines[$y])) |
|
| 696 | 797 | { |
| 697 | 798 | if ($object->lines[$y]->qty == $next_title_lvl_to_skip) |
| 698 | 799 | { |
| 699 | 800 | $next_title_lvl_to_skip = 0; |
| 700 | 801 | continue; |
| 701 | - } |
|
| 702 | - else |
|
| 802 | + } else |
|
| 703 | 803 | { |
| 704 | - if (empty($object->lines[$y]->array_options)) $object->lines[$y]->fetch_optionals(); |
|
| 804 | + if (empty($object->lines[$y]->array_options)) { |
|
| 805 | + $object->lines[$y]->fetch_optionals(); |
|
| 806 | + } |
|
| 705 | 807 | $TTitle[$object->lines[$y]->id] = $object->lines[$y]; |
| 706 | 808 | |
| 707 | - if ($object->lines[$y]->qty == 1) break; |
|
| 809 | + if ($object->lines[$y]->qty == 1) { |
|
| 810 | + break; |
|
| 811 | + } |
|
| 708 | 812 | } |
| 709 | 813 | } |
| 710 | 814 | } |
| 711 | 815 | } |
| 712 | 816 | |
| 713 | - if ($reverse) $TTitle = array_reverse($TTitle, true); |
|
| 817 | + if ($reverse) { |
|
| 818 | + $TTitle = array_reverse($TTitle, true); |
|
| 819 | + } |
|
| 714 | 820 | |
| 715 | 821 | return $TTitle; |
| 716 | 822 | } |
| 717 | 823 | |
| 718 | 824 | public static function getNiveau(&$line) |
| 719 | 825 | { |
| 720 | - if (self::isTitle($line)) return $line->qty; |
|
| 721 | - elseif (self::isSubtotal($line)) return 100 - $line->qty; |
|
| 722 | - else return 0; |
|
| 826 | + if (self::isTitle($line)) { |
|
| 827 | + return $line->qty; |
|
| 828 | + } elseif (self::isSubtotal($line)) { |
|
| 829 | + return 100 - $line->qty; |
|
| 830 | + } else { |
|
| 831 | + return 0; |
|
| 832 | + } |
|
| 723 | 833 | } |
| 724 | 834 | |
| 725 | 835 | /** |
@@ -744,10 +854,16 @@ discard block |
||
| 744 | 854 | $objmarge->marge_droite = 10; |
| 745 | 855 | |
| 746 | 856 | $objectref = dol_sanitizeFileName($object->ref); |
| 747 | - if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref; |
|
| 748 | - elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref; |
|
| 749 | - elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref; |
|
| 750 | - elseif ($object->element == 'facturerec') return; // no PDF for facturerec |
|
| 857 | + if ($object->element == 'propal') { |
|
| 858 | + $dir = $conf->propal->dir_output . '/' . $objectref; |
|
| 859 | + } elseif ($object->element == 'commande') { |
|
| 860 | + $dir = $conf->commande->dir_output . '/' . $objectref; |
|
| 861 | + } elseif ($object->element == 'facture') { |
|
| 862 | + $dir = $conf->facture->dir_output . '/' . $objectref; |
|
| 863 | + } elseif ($object->element == 'facturerec') { |
|
| 864 | + return; |
|
| 865 | + } |
|
| 866 | + // no PDF for facturerec |
|
| 751 | 867 | else |
| 752 | 868 | { |
| 753 | 869 | setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings'); |
@@ -782,7 +898,9 @@ discard block |
||
| 782 | 898 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
| 783 | 899 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
| 784 | 900 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
| 785 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 901 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
| 902 | + $pdf->SetCompression(false); |
|
| 903 | + } |
|
| 786 | 904 | |
| 787 | 905 | $pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right |
| 788 | 906 | |
@@ -792,7 +910,9 @@ discard block |
||
| 792 | 910 | |
| 793 | 911 | // New page |
| 794 | 912 | $pdf->AddPage(); |
| 795 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 913 | + if (! empty($tplidx)) { |
|
| 914 | + $pdf->useTemplate($tplidx); |
|
| 915 | + } |
|
| 796 | 916 | $pagenb++; |
| 797 | 917 | |
| 798 | 918 | |
@@ -848,8 +968,10 @@ discard block |
||
| 848 | 968 | { |
| 849 | 969 | $TTot['TTotal_tva_multicurrency'][$tx] += $amount; |
| 850 | 970 | } |
| 971 | + } else { |
|
| 972 | + $pdf->SetFont('','', $default_font_size - 1); |
|
| 851 | 973 | } |
| 852 | - else $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
| 974 | + // Into loop to work with multipage |
|
| 853 | 975 | |
| 854 | 976 | $pdf->SetTextColor(0,0,0); |
| 855 | 977 | |
@@ -871,9 +993,11 @@ discard block |
||
| 871 | 993 | $pdf->startTransaction(); |
| 872 | 994 | $pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true); |
| 873 | 995 | $pageposafter=$pdf->getPage(); |
| 874 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
| 996 | + if ($pageposafter > $pageposbefore) { |
|
| 997 | + // There is a pagebreak |
|
| 875 | 998 | { |
| 876 | 999 | $pdf->rollbackTransaction(true); |
| 1000 | + } |
|
| 877 | 1001 | $pageposafter=$pageposbefore; |
| 878 | 1002 | //print $pageposafter.'-'.$pageposbefore;exit; |
| 879 | 1003 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
@@ -882,23 +1006,27 @@ discard block |
||
| 882 | 1006 | $pageposafter=$pdf->getPage(); |
| 883 | 1007 | $posyafter=$pdf->GetY(); |
| 884 | 1008 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
| 885 | - if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) // There is no space left for total+free text |
|
| 1009 | + if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) { |
|
| 1010 | + // There is no space left for total+free text |
|
| 886 | 1011 | { |
| 887 | 1012 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
| 888 | 1013 | { |
| 889 | 1014 | $pdf->AddPage('','',true); |
| 890 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 891 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
| 1015 | + } |
|
| 1016 | + if (! empty($tplidx)) { |
|
| 1017 | + $pdf->useTemplate($tplidx); |
|
| 1018 | + } |
|
| 1019 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
| 1020 | + self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
| 1021 | + } |
|
| 892 | 1022 | $pdf->setPage($pageposafter+1); |
| 893 | 1023 | } |
| 894 | - } |
|
| 895 | - else |
|
| 1024 | + } else |
|
| 896 | 1025 | { |
| 897 | 1026 | // We found a page break |
| 898 | 1027 | $showpricebeforepagebreak=0; |
| 899 | 1028 | } |
| 900 | - } |
|
| 901 | - else // No pagebreak |
|
| 1029 | + } else // No pagebreak |
|
| 902 | 1030 | { |
| 903 | 1031 | $pdf->commitTransaction(); |
| 904 | 1032 | } |
@@ -938,8 +1066,7 @@ discard block |
||
| 938 | 1066 | if ($pagenb == 1) |
| 939 | 1067 | { |
| 940 | 1068 | 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); |
| 941 | - } |
|
| 942 | - else |
|
| 1069 | + } else |
|
| 943 | 1070 | { |
| 944 | 1071 | 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); |
| 945 | 1072 | } |
@@ -947,7 +1074,9 @@ discard block |
||
| 947 | 1074 | $pagenb++; |
| 948 | 1075 | $pdf->setPage($pagenb); |
| 949 | 1076 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
| 950 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
| 1077 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
| 1078 | + self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
| 1079 | + } |
|
| 951 | 1080 | } |
| 952 | 1081 | } |
| 953 | 1082 | } |
@@ -957,8 +1086,7 @@ discard block |
||
| 957 | 1086 | { |
| 958 | 1087 | 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); |
| 959 | 1088 | $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
| 960 | - } |
|
| 961 | - else |
|
| 1089 | + } else |
|
| 962 | 1090 | { |
| 963 | 1091 | 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); |
| 964 | 1092 | $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
@@ -972,7 +1100,9 @@ discard block |
||
| 972 | 1100 | |
| 973 | 1101 | $pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file); |
| 974 | 1102 | |
| 975 | - if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) unlink($file); |
|
| 1103 | + if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) { |
|
| 1104 | + unlink($file); |
|
| 1105 | + } |
|
| 976 | 1106 | } |
| 977 | 1107 | |
| 978 | 1108 | private static function printLevel($objmarge, $pdf, $line, $curY, $posx_designation) |
@@ -1015,8 +1145,7 @@ discard block |
||
| 1015 | 1145 | { |
| 1016 | 1146 | $height=pdf_getHeightForLogo($logo); |
| 1017 | 1147 | $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto) |
| 1018 | - } |
|
| 1019 | - else |
|
| 1148 | + } else |
|
| 1020 | 1149 | { |
| 1021 | 1150 | $pdf->SetTextColor(200,0,0); |
| 1022 | 1151 | $pdf->SetFont('','B',$default_font_size - 2); |
@@ -1025,8 +1154,7 @@ discard block |
||
| 1025 | 1154 | } |
| 1026 | 1155 | |
| 1027 | 1156 | $posy+=35; |
| 1028 | - } |
|
| 1029 | - else |
|
| 1157 | + } else |
|
| 1030 | 1158 | { |
| 1031 | 1159 | $text=$mysoc->name; |
| 1032 | 1160 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -1040,9 +1168,13 @@ discard block |
||
| 1040 | 1168 | $pdf->SetXY($objmarge->marge_gauche,$posy); |
| 1041 | 1169 | |
| 1042 | 1170 | $key = 'subtotalPropalTitle'; |
| 1043 | - if ($object->element == 'commande') $key = 'subtotalCommandeTitle'; |
|
| 1044 | - elseif ($object->element == 'facture') $key = 'subtotalInvoiceTitle'; |
|
| 1045 | - elseif ($object->element == 'facturerec') $key = 'subtotalInvoiceTitle'; |
|
| 1171 | + if ($object->element == 'commande') { |
|
| 1172 | + $key = 'subtotalCommandeTitle'; |
|
| 1173 | + } elseif ($object->element == 'facture') { |
|
| 1174 | + $key = 'subtotalInvoiceTitle'; |
|
| 1175 | + } elseif ($object->element == 'facturerec') { |
|
| 1176 | + $key = 'subtotalInvoiceTitle'; |
|
| 1177 | + } |
|
| 1046 | 1178 | |
| 1047 | 1179 | $pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L'); |
| 1048 | 1180 | |
@@ -1077,7 +1209,9 @@ discard block |
||
| 1077 | 1209 | |
| 1078 | 1210 | // Force to disable hidetop and hidebottom |
| 1079 | 1211 | $hidebottom=0; |
| 1080 | - if ($hidetop) $hidetop=-1; |
|
| 1212 | + if ($hidetop) { |
|
| 1213 | + $hidetop=-1; |
|
| 1214 | + } |
|
| 1081 | 1215 | |
| 1082 | 1216 | $currency = !empty($currency) ? $currency : $conf->currency; |
| 1083 | 1217 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
@@ -1092,7 +1226,9 @@ discard block |
||
| 1092 | 1226 | $pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5); |
| 1093 | 1227 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
| 1094 | 1228 | |
| 1095 | - 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)); |
|
| 1229 | + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { |
|
| 1230 | + $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)); |
|
| 1231 | + } |
|
| 1096 | 1232 | |
| 1097 | 1233 | |
| 1098 | 1234 | $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 |
@@ -1105,8 +1241,7 @@ discard block |
||
| 1105 | 1241 | $pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R'); |
| 1106 | 1242 | |
| 1107 | 1243 | $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 |
| 1108 | - } |
|
| 1109 | - else |
|
| 1244 | + } else |
|
| 1110 | 1245 | { |
| 1111 | 1246 | $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 |
| 1112 | 1247 | } |
@@ -1127,10 +1262,12 @@ discard block |
||
| 1127 | 1262 | |
| 1128 | 1263 | // Tableau total |
| 1129 | 1264 | $col1x = 120; $col2x = 170; |
| 1130 | - if ($objmarge->page_largeur < 210) // To work with US executive format |
|
| 1265 | + if ($objmarge->page_largeur < 210) { |
|
| 1266 | + // To work with US executive format |
|
| 1131 | 1267 | { |
| 1132 | 1268 | $col2x-=20; |
| 1133 | 1269 | } |
| 1270 | + } |
|
| 1134 | 1271 | $largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x); |
| 1135 | 1272 | |
| 1136 | 1273 | $useborder=0; |
@@ -1152,9 +1289,11 @@ discard block |
||
| 1152 | 1289 | $atleastoneratenotnull=0; |
| 1153 | 1290 | foreach($TTot['TTotal_tva'] as $tvakey => $tvaval) |
| 1154 | 1291 | { |
| 1155 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
| 1292 | + if ($tvakey != 0) { |
|
| 1293 | + // On affiche pas taux 0 |
|
| 1156 | 1294 | { |
| 1157 | 1295 | $atleastoneratenotnull++; |
| 1296 | + } |
|
| 1158 | 1297 | |
| 1159 | 1298 | $index++; |
| 1160 | 1299 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -1207,9 +1346,13 @@ discard block |
||
| 1207 | 1346 | */ |
| 1208 | 1347 | private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
| 1209 | 1348 | { |
| 1210 | - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
| 1349 | + if (empty($hidetop) || $hidetop==-1) { |
|
| 1350 | + $pdf->line($x, $y, $x+$l, $y); |
|
| 1351 | + } |
|
| 1211 | 1352 | $pdf->line($x+$l, $y, $x+$l, $y+$h); |
| 1212 | - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
| 1353 | + if (empty($hidebottom)) { |
|
| 1354 | + $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
| 1355 | + } |
|
| 1213 | 1356 | $pdf->line($x, $y+$h, $x, $y); |
| 1214 | 1357 | } |
| 1215 | 1358 | |
@@ -1218,7 +1361,9 @@ discard block |
||
| 1218 | 1361 | { |
| 1219 | 1362 | global $conf; |
| 1220 | 1363 | |
| 1221 | - if (empty($fileoutput)) $fileoutput = $file[0]; |
|
| 1364 | + if (empty($fileoutput)) { |
|
| 1365 | + $fileoutput = $file[0]; |
|
| 1366 | + } |
|
| 1222 | 1367 | |
| 1223 | 1368 | $pdf=pdf_getInstance(); |
| 1224 | 1369 | if (class_exists('TCPDF')) |
@@ -1228,7 +1373,9 @@ discard block |
||
| 1228 | 1373 | } |
| 1229 | 1374 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
| 1230 | 1375 | |
| 1231 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 1376 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
| 1377 | + $pdf->SetCompression(false); |
|
| 1378 | + } |
|
| 1232 | 1379 | |
| 1233 | 1380 | |
| 1234 | 1381 | foreach($files as $file) |
@@ -1244,7 +1391,9 @@ discard block |
||
| 1244 | 1391 | } |
| 1245 | 1392 | |
| 1246 | 1393 | $pdf->Output($fileoutput,'F'); |
| 1247 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 1394 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 1395 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 1396 | + } |
|
| 1248 | 1397 | |
| 1249 | 1398 | return $pagecount; |
| 1250 | 1399 | } |
@@ -1257,7 +1406,9 @@ discard block |
||
| 1257 | 1406 | */ |
| 1258 | 1407 | public static function hasNcTitle(&$line) |
| 1259 | 1408 | { |
| 1260 | - if(isset($line->has_nc_title)) return $line->has_nc_title; |
|
| 1409 | + if(isset($line->has_nc_title)) { |
|
| 1410 | + return $line->has_nc_title; |
|
| 1411 | + } |
|
| 1261 | 1412 | |
| 1262 | 1413 | $TTitle = self::getAllTitleFromLine($line); |
| 1263 | 1414 | foreach ($TTitle as &$line_title) |
@@ -1282,7 +1433,9 @@ discard block |
||
| 1282 | 1433 | public static function getTitleLabel($line) |
| 1283 | 1434 | { |
| 1284 | 1435 | $title = $line->label; |
| 1285 | - if (empty($title)) $title = !empty($line->description) ? $line->description : $line->desc; |
|
| 1436 | + if (empty($title)) { |
|
| 1437 | + $title = !empty($line->description) ? $line->description : $line->desc; |
|
| 1438 | + } |
|
| 1286 | 1439 | return $title; |
| 1287 | 1440 | } |
| 1288 | 1441 | } |