@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | * @return void |
48 | 48 | */ |
49 | 49 | |
50 | - var $module_number = 104777; |
|
50 | + var $module_number = 104777; |
|
51 | 51 | |
52 | - function formObjectOptions($parameters, &$object, &$action, $hookmanager) |
|
53 | - { |
|
54 | - global $langs,$db,$user, $conf; |
|
52 | + function formObjectOptions($parameters, &$object, &$action, $hookmanager) |
|
53 | + { |
|
54 | + global $langs,$db,$user, $conf; |
|
55 | 55 | |
56 | 56 | $langs->load('subtotal@subtotal'); |
57 | 57 | |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | $createRight = $user->rights->facture->creer; |
67 | 67 | } elseif($object->element == 'order_supplier' ) |
68 | 68 | { |
69 | - $createRight = $user->rights->fournisseur->commande->creer; |
|
69 | + $createRight = $user->rights->fournisseur->commande->creer; |
|
70 | 70 | } elseif($object->element == 'invoice_supplier' ) |
71 | 71 | { |
72 | - $createRight = $user->rights->fournisseur->facture->creer; |
|
72 | + $createRight = $user->rights->fournisseur->facture->creer; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | if ($object->statut == 0 && $createRight) { |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty); |
121 | 121 | |
122 | - TSubtotal::addSubTotalLine($object, $title, $qty); |
|
122 | + TSubtotal::addSubTotalLine($object, $title, $qty); |
|
123 | 123 | } |
124 | 124 | else if($action==='ask_deleteallline') { |
125 | 125 | $form=new Form($db); |
@@ -341,36 +341,36 @@ discard block |
||
341 | 341 | $TContext = explode(':',$parameters['context']); |
342 | 342 | if ( |
343 | 343 | in_array('invoicecard',$TContext) |
344 | - || in_array('invoicesuppliercard',$TContext) |
|
344 | + || in_array('invoicesuppliercard',$TContext) |
|
345 | 345 | || in_array('propalcard',$TContext) |
346 | 346 | || in_array('ordercard',$TContext) |
347 | - || in_array('ordersuppliercard',$TContext) |
|
347 | + || in_array('ordersuppliercard',$TContext) |
|
348 | 348 | || in_array('invoicereccard',$TContext) |
349 | 349 | ) |
350 | - { |
|
350 | + { |
|
351 | 351 | $hideInnerLines = isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] ) ? $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0; |
352 | 352 | $hidedetails = isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] ) ? $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0; |
353 | 353 | $hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0; |
354 | 354 | $hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] ) ? $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : $hidepricesDefaultConf; |
355 | 355 | |
356 | 356 | $var=false; |
357 | - $out.= '<tr '.$bc[$var].'> |
|
357 | + $out.= '<tr '.$bc[$var].'> |
|
358 | 358 | <td colspan="4" align="right"> |
359 | 359 | <label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label> |
360 | 360 | <input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\') }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' /> |
361 | 361 | </td> |
362 | 362 | </tr>'; |
363 | 363 | |
364 | - $var=!$var; |
|
365 | - $out.= '<tr '.$bc[$var].'> |
|
364 | + $var=!$var; |
|
365 | + $out.= '<tr '.$bc[$var].'> |
|
366 | 366 | <td colspan="4" align="right"> |
367 | 367 | <label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label> |
368 | 368 | <input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' /> |
369 | 369 | </td> |
370 | 370 | </tr>'; |
371 | 371 | |
372 | - $var=!$var; |
|
373 | - $out.= '<tr '.$bc[$var].'> |
|
372 | + $var=!$var; |
|
373 | + $out.= '<tr '.$bc[$var].'> |
|
374 | 374 | <td colspan="4" align="right"> |
375 | 375 | <label for="hidedetails">'.$langs->trans('SubTotalhidePrice').'</label> |
376 | 376 | <input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' /> |
@@ -382,9 +382,9 @@ discard block |
||
382 | 382 | if ( |
383 | 383 | (in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP)) |
384 | 384 | || (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP)) |
385 | - || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP)) |
|
385 | + || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP)) |
|
386 | 386 | || (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP)) |
387 | - || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP)) |
|
387 | + || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP)) |
|
388 | 388 | || (in_array('invoicereccard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP )) |
389 | 389 | ) |
390 | 390 | { |
@@ -403,19 +403,19 @@ discard block |
||
403 | 403 | } |
404 | 404 | |
405 | 405 | |
406 | - return 1; |
|
406 | + return 1; |
|
407 | 407 | } |
408 | 408 | |
409 | - function formEditProductOptions($parameters, &$object, &$action, $hookmanager) |
|
410 | - { |
|
409 | + function formEditProductOptions($parameters, &$object, &$action, $hookmanager) |
|
410 | + { |
|
411 | 411 | |
412 | - if (in_array('invoicecard',explode(':',$parameters['context']))) |
|
413 | - { |
|
412 | + if (in_array('invoicecard',explode(':',$parameters['context']))) |
|
413 | + { |
|
414 | 414 | |
415 | - } |
|
415 | + } |
|
416 | 416 | |
417 | - return 0; |
|
418 | - } |
|
417 | + return 0; |
|
418 | + } |
|
419 | 419 | |
420 | 420 | function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) { |
421 | 421 | global $conf; |
@@ -464,11 +464,11 @@ discard block |
||
464 | 464 | |
465 | 465 | if ( |
466 | 466 | in_array('invoicecard',explode(':',$parameters['context'])) |
467 | - || in_array('invoicesuppliercard',explode(':',$parameters['context'])) |
|
467 | + || in_array('invoicesuppliercard',explode(':',$parameters['context'])) |
|
468 | 468 | || in_array('propalcard',explode(':',$parameters['context'])) |
469 | - || in_array('supplier_proposalcard',explode(':',$parameters['context'])) |
|
469 | + || in_array('supplier_proposalcard',explode(':',$parameters['context'])) |
|
470 | 470 | || in_array('ordercard',explode(':',$parameters['context'])) |
471 | - || in_array('ordersuppliercard',explode(':',$parameters['context'])) |
|
471 | + || in_array('ordersuppliercard',explode(':',$parameters['context'])) |
|
472 | 472 | || in_array('invoicereccard',explode(':',$parameters['context'])) |
473 | 473 | ) { |
474 | 474 | |
@@ -547,20 +547,20 @@ discard block |
||
547 | 547 | in_array('invoicecard',explode(':',$parameters['context'])) |
548 | 548 | || in_array('propalcard',explode(':',$parameters['context'])) |
549 | 549 | || in_array('ordercard',explode(':',$parameters['context'])) |
550 | - || in_array('ordersuppliercard',explode(':',$parameters['context'])) |
|
551 | - || in_array('invoicesuppliercard',explode(':',$parameters['context'])) |
|
552 | - || in_array('supplier_proposalcard',explode(':',$parameters['context'])) |
|
550 | + || in_array('ordersuppliercard',explode(':',$parameters['context'])) |
|
551 | + || in_array('invoicesuppliercard',explode(':',$parameters['context'])) |
|
552 | + || in_array('supplier_proposalcard',explode(':',$parameters['context'])) |
|
553 | 553 | ) |
554 | - { |
|
554 | + { |
|
555 | 555 | if(in_array('invoicecard',explode(':',$parameters['context']))) { |
556 | 556 | $sessname = 'subtotal_hideInnerLines_facture'; |
557 | 557 | $sessname2 = 'subtotal_hidedetails_facture'; |
558 | 558 | $sessname3 = 'subtotal_hideprices_facture'; |
559 | 559 | } |
560 | 560 | elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) { |
561 | - $sessname = 'subtotal_hideInnerLines_facture_fournisseur'; |
|
562 | - $sessname2 = 'subtotal_hidedetails_facture_fournisseur'; |
|
563 | - $sessname3 = 'subtotal_hideprices_facture_fournisseur'; |
|
561 | + $sessname = 'subtotal_hideInnerLines_facture_fournisseur'; |
|
562 | + $sessname2 = 'subtotal_hidedetails_facture_fournisseur'; |
|
563 | + $sessname3 = 'subtotal_hideprices_facture_fournisseur'; |
|
564 | 564 | } |
565 | 565 | elseif(in_array('propalcard',explode(':',$parameters['context']))) { |
566 | 566 | $sessname = 'subtotal_hideInnerLines_propal'; |
@@ -568,9 +568,9 @@ discard block |
||
568 | 568 | $sessname3 = 'subtotal_hideprices_propal'; |
569 | 569 | } |
570 | 570 | elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) { |
571 | - $sessname = 'subtotal_hideInnerLines_supplier_proposal'; |
|
572 | - $sessname2 = 'subtotal_hidedetails_supplier_proposal'; |
|
573 | - $sessname3 = 'subtotal_hideprices_supplier_proposal'; |
|
571 | + $sessname = 'subtotal_hideInnerLines_supplier_proposal'; |
|
572 | + $sessname2 = 'subtotal_hidedetails_supplier_proposal'; |
|
573 | + $sessname3 = 'subtotal_hideprices_supplier_proposal'; |
|
574 | 574 | } |
575 | 575 | elseif(in_array('ordercard',explode(':',$parameters['context']))) { |
576 | 576 | $sessname = 'subtotal_hideInnerLines_commande'; |
@@ -578,9 +578,9 @@ discard block |
||
578 | 578 | $sessname3 = 'subtotal_hideprices_commande'; |
579 | 579 | } |
580 | 580 | elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) { |
581 | - $sessname = 'subtotal_hideInnerLines_commande_fournisseur'; |
|
582 | - $sessname2 = 'subtotal_hidedetails_commande_fournisseur'; |
|
583 | - $sessname3 = 'subtotal_hideprices_commande_fournisseur'; |
|
581 | + $sessname = 'subtotal_hideInnerLines_commande_fournisseur'; |
|
582 | + $sessname2 = 'subtotal_hidedetails_commande_fournisseur'; |
|
583 | + $sessname3 = 'subtotal_hideprices_commande_fournisseur'; |
|
584 | 584 | } |
585 | 585 | else { |
586 | 586 | $sessname = 'subtotal_hideInnerLines_unknown'; |
@@ -602,17 +602,17 @@ discard block |
||
602 | 602 | foreach($object->lines as &$line) { |
603 | 603 | if ($line->product_type == 9 && $line->special_code == $this->module_number) { |
604 | 604 | |
605 | - if($line->qty>=90) { |
|
606 | - $line->modsubtotal_total = 1; |
|
607 | - } |
|
608 | - else{ |
|
609 | - $line->modsubtotal_title = 1; |
|
610 | - } |
|
605 | + if($line->qty>=90) { |
|
606 | + $line->modsubtotal_total = 1; |
|
607 | + } |
|
608 | + else{ |
|
609 | + $line->modsubtotal_title = 1; |
|
610 | + } |
|
611 | 611 | |
612 | 612 | $line->total_ht = $this->getTotalLineFromObject($object, $line, ''); |
613 | 613 | } |
614 | - } |
|
615 | - } |
|
614 | + } |
|
615 | + } |
|
616 | 616 | |
617 | 617 | } |
618 | 618 | else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') { |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | */ |
630 | 630 | else if($object->element=='invoice_supplier') |
631 | 631 | { |
632 | - $object->deleteline($idLine); |
|
632 | + $object->deleteline($idLine); |
|
633 | 633 | } |
634 | 634 | /** |
635 | 635 | * @var $object Propal |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | */ |
653 | 653 | else if($object->element=='order_supplier') |
654 | 654 | { |
655 | - $object->deleteline($idLine); |
|
655 | + $object->deleteline($idLine); |
|
656 | 656 | } |
657 | 657 | /** |
658 | 658 | * @var $object Facturerec |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | |
697 | 697 | foreach($object->lines as $l) { |
698 | 698 | |
699 | - $lid = (!empty($l->rowid) ? $l->rowid : $l->id); |
|
699 | + $lid = (!empty($l->rowid) ? $l->rowid : $l->id); |
|
700 | 700 | if($lid == $lineid) { |
701 | 701 | |
702 | 702 | $found = true; |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | |
706 | 706 | if($found) { |
707 | 707 | |
708 | - $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id); |
|
708 | + $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id); |
|
709 | 709 | |
710 | 710 | if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2)) ) { |
711 | 711 | break; // end of story |
@@ -784,17 +784,17 @@ discard block |
||
784 | 784 | if($l->rang>=$rang) { |
785 | 785 | return price($total); |
786 | 786 | } |
787 | - if (TSubtotal::isSubtotal($l)){ |
|
788 | - $total = 0; |
|
789 | - } else if ($l->situation_percent > 0 ){ |
|
787 | + if (TSubtotal::isSubtotal($l)){ |
|
788 | + $total = 0; |
|
789 | + } else if ($l->situation_percent > 0 ){ |
|
790 | 790 | |
791 | 791 | |
792 | 792 | $prev_progress = $l->get_prev_progress($object->id); |
793 | 793 | $progress = ($l->situation_percent - $prev_progress) /100; |
794 | - $total += ($l->total_ht/($l->situation_percent/100)) * $progress; |
|
794 | + $total += ($l->total_ht/($l->situation_percent/100)) * $progress; |
|
795 | 795 | |
796 | - } |
|
797 | - } |
|
796 | + } |
|
797 | + } |
|
798 | 798 | |
799 | 799 | return price($total); |
800 | 800 | } |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | if(method_exists('Closure','bind')) { |
827 | 827 | $pageBreakOriginalValue = $pdf->AcceptPageBreak(); |
828 | 828 | $sweetsThief = function ($pdf) { |
829 | - return $pdf->bMargin ; |
|
829 | + return $pdf->bMargin ; |
|
830 | 830 | }; |
831 | 831 | $sweetsThief = Closure::bind($sweetsThief, null, $pdf); |
832 | 832 | |
@@ -889,11 +889,11 @@ discard block |
||
889 | 889 | else |
890 | 890 | { |
891 | 891 | list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1); |
892 | - if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation |
|
893 | - $total_to_print = $this->getTotalToPrintSituation($object, $line); |
|
894 | - } else { |
|
895 | - $total_to_print = price($total); |
|
896 | - } |
|
892 | + if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation |
|
893 | + $total_to_print = $this->getTotalToPrintSituation($object, $line); |
|
894 | + } else { |
|
895 | + $total_to_print = price($total); |
|
896 | + } |
|
897 | 897 | |
898 | 898 | $line->total_ht = $total; |
899 | 899 | $line->total = $total; |
@@ -1044,7 +1044,7 @@ discard block |
||
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') { |
1047 | - global $conf, $hideprices, $hookmanager; |
|
1047 | + global $conf, $hideprices, $hookmanager; |
|
1048 | 1048 | |
1049 | 1049 | if($this->isModSubtotalLine($parameters,$object) ){ |
1050 | 1050 | |
@@ -1083,59 +1083,59 @@ discard block |
||
1083 | 1083 | } |
1084 | 1084 | } |
1085 | 1085 | if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){ |
1086 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1087 | - else $i = (int)$parameters; |
|
1088 | - $this->resprints = price($object->lines[$i]->total_ht); |
|
1086 | + if(is_array($parameters)) $i = & $parameters['i']; |
|
1087 | + else $i = (int)$parameters; |
|
1088 | + $this->resprints = price($object->lines[$i]->total_ht); |
|
1089 | 1089 | } |
1090 | 1090 | if (!empty($hideprices) |
1091 | - || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
|
1092 | - ) |
|
1091 | + || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
|
1092 | + ) |
|
1093 | 1093 | { |
1094 | - if (!empty($hideprices)) |
|
1095 | - { |
|
1094 | + if (!empty($hideprices)) |
|
1095 | + { |
|
1096 | 1096 | |
1097 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1098 | - else $i = (int)$parameters; |
|
1097 | + if(is_array($parameters)) $i = & $parameters['i']; |
|
1098 | + else $i = (int)$parameters; |
|
1099 | 1099 | |
1100 | - // Check if a title exist for this line && if the title have subtotal |
|
1101 | - $lineTitle = TSubtotal::getParentTitleOfLine($object, $i); |
|
1102 | - if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true)) |
|
1103 | - { |
|
1100 | + // Check if a title exist for this line && if the title have subtotal |
|
1101 | + $lineTitle = TSubtotal::getParentTitleOfLine($object, $i); |
|
1102 | + if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true)) |
|
1103 | + { |
|
1104 | 1104 | |
1105 | - $this->resprints = ' '; |
|
1105 | + $this->resprints = ' '; |
|
1106 | 1106 | |
1107 | - $reshook=$hookmanager->executeHooks('subtotalHidePrices',$parameters,$object,$action); |
|
1107 | + $reshook=$hookmanager->executeHooks('subtotalHidePrices',$parameters,$object,$action); |
|
1108 | 1108 | |
1109 | - if ($reshook < 0) |
|
1110 | - { |
|
1111 | - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
1112 | - return -1; |
|
1113 | - } |
|
1114 | - elseif (empty($reshook)) |
|
1115 | - { |
|
1116 | - $this->resprints .= $hookmanager->resprints; |
|
1117 | - } |
|
1118 | - else |
|
1119 | - { |
|
1120 | - $this->resprints = $hookmanager->resprints; |
|
1109 | + if ($reshook < 0) |
|
1110 | + { |
|
1111 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
1112 | + return -1; |
|
1113 | + } |
|
1114 | + elseif (empty($reshook)) |
|
1115 | + { |
|
1116 | + $this->resprints .= $hookmanager->resprints; |
|
1117 | + } |
|
1118 | + else |
|
1119 | + { |
|
1120 | + $this->resprints = $hookmanager->resprints; |
|
1121 | 1121 | |
1122 | - // override return (use $this->results['overrideReturn'] or $this->resArray['overrideReturn'] in other module action_xxxx.class.php ) |
|
1123 | - if(isset($hookmanager->resArray['overrideReturn'])) |
|
1124 | - { |
|
1125 | - return $hookmanager->resArray['overrideReturn']; |
|
1126 | - } |
|
1127 | - } |
|
1122 | + // override return (use $this->results['overrideReturn'] or $this->resArray['overrideReturn'] in other module action_xxxx.class.php ) |
|
1123 | + if(isset($hookmanager->resArray['overrideReturn'])) |
|
1124 | + { |
|
1125 | + return $hookmanager->resArray['overrideReturn']; |
|
1126 | + } |
|
1127 | + } |
|
1128 | 1128 | |
1129 | - return 1; |
|
1129 | + return 1; |
|
1130 | 1130 | |
1131 | 1131 | |
1132 | - } |
|
1133 | - } |
|
1134 | - elseif (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
|
1135 | - { |
|
1136 | - $this->resprints = ' '; |
|
1137 | - return 1; |
|
1138 | - } |
|
1132 | + } |
|
1133 | + } |
|
1134 | + elseif (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
|
1135 | + { |
|
1136 | + $this->resprints = ' '; |
|
1137 | + return 1; |
|
1138 | + } |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | return 0; |
@@ -1415,11 +1415,11 @@ discard block |
||
1415 | 1415 | $hidedetails = (int)GETPOST('hidedetails'); |
1416 | 1416 | |
1417 | 1417 | if ($hideInnerLines) { // si c une ligne de titre |
1418 | - $fk_parent_line=0; |
|
1418 | + $fk_parent_line=0; |
|
1419 | 1419 | $TLines =array(); |
1420 | 1420 | |
1421 | 1421 | $original_count=count($object->lines); |
1422 | - $TTvas = array(); // tableau de tva |
|
1422 | + $TTvas = array(); // tableau de tva |
|
1423 | 1423 | |
1424 | 1424 | foreach($object->lines as $k=>&$line) |
1425 | 1425 | { |
@@ -1449,48 +1449,48 @@ discard block |
||
1449 | 1449 | |
1450 | 1450 | if ($hideInnerLines) |
1451 | 1451 | { |
1452 | - if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) |
|
1453 | - { |
|
1454 | - if($line->tva_tx != '0.000' && $line->product_type!=9){ |
|
1452 | + if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) |
|
1453 | + { |
|
1454 | + if($line->tva_tx != '0.000' && $line->product_type!=9){ |
|
1455 | 1455 | |
1456 | - // on remplit le tableau de tva pour substituer les lignes cachées |
|
1457 | - $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva; |
|
1458 | - $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht; |
|
1459 | - $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; |
|
1460 | - } |
|
1461 | - if($line->product_type==9 && $line->rowid>0) |
|
1462 | - { |
|
1463 | - //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres |
|
1464 | - // génère des lignes d'affichage des montants HT soumis à tva |
|
1465 | - $nbtva = count($TTvas); |
|
1466 | - if(!empty($nbtva)){ |
|
1467 | - foreach ($TTvas as $tx =>$val){ |
|
1468 | - $l = clone $line; |
|
1469 | - $l->product_type = 1; |
|
1470 | - $l->special_code = ''; |
|
1471 | - $l->qty = 1; |
|
1472 | - $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx)); |
|
1473 | - $l->tva_tx = $tx; |
|
1474 | - $l->total_ht = $val['total_ht']; |
|
1475 | - $l->total_tva = $val['total_tva']; |
|
1476 | - $l->total = $line->total_ht; |
|
1477 | - $l->total_ttc = $val['total_ttc']; |
|
1478 | - $TLines[] = $l; |
|
1479 | - array_shift($TTvas); |
|
1480 | - } |
|
1481 | - } |
|
1456 | + // on remplit le tableau de tva pour substituer les lignes cachées |
|
1457 | + $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva; |
|
1458 | + $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht; |
|
1459 | + $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; |
|
1460 | + } |
|
1461 | + if($line->product_type==9 && $line->rowid>0) |
|
1462 | + { |
|
1463 | + //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres |
|
1464 | + // génère des lignes d'affichage des montants HT soumis à tva |
|
1465 | + $nbtva = count($TTvas); |
|
1466 | + if(!empty($nbtva)){ |
|
1467 | + foreach ($TTvas as $tx =>$val){ |
|
1468 | + $l = clone $line; |
|
1469 | + $l->product_type = 1; |
|
1470 | + $l->special_code = ''; |
|
1471 | + $l->qty = 1; |
|
1472 | + $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx)); |
|
1473 | + $l->tva_tx = $tx; |
|
1474 | + $l->total_ht = $val['total_ht']; |
|
1475 | + $l->total_tva = $val['total_tva']; |
|
1476 | + $l->total = $line->total_ht; |
|
1477 | + $l->total_ttc = $val['total_ttc']; |
|
1478 | + $TLines[] = $l; |
|
1479 | + array_shift($TTvas); |
|
1480 | + } |
|
1481 | + } |
|
1482 | 1482 | |
1483 | - // ajoute la ligne de sous-total |
|
1484 | - $TLines[] = $line; |
|
1485 | - } |
|
1486 | - } else { |
|
1483 | + // ajoute la ligne de sous-total |
|
1484 | + $TLines[] = $line; |
|
1485 | + } |
|
1486 | + } else { |
|
1487 | 1487 | |
1488 | - if($line->product_type==9 && $line->rowid>0) |
|
1489 | - { |
|
1490 | - // ajoute la ligne de sous-total |
|
1491 | - $TLines[] = $line; |
|
1492 | - } |
|
1493 | - } |
|
1488 | + if($line->product_type==9 && $line->rowid>0) |
|
1489 | + { |
|
1490 | + // ajoute la ligne de sous-total |
|
1491 | + $TLines[] = $line; |
|
1492 | + } |
|
1493 | + } |
|
1494 | 1494 | |
1495 | 1495 | |
1496 | 1496 | } |
@@ -1515,20 +1515,20 @@ discard block |
||
1515 | 1515 | $nbtva = count($TTvas); |
1516 | 1516 | if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) |
1517 | 1517 | { |
1518 | - foreach ($TTvas as $tx =>$val){ |
|
1519 | - $l = clone $line; |
|
1520 | - $l->product_type = 1; |
|
1521 | - $l->special_code = ''; |
|
1522 | - $l->qty = 1; |
|
1523 | - $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx)); |
|
1524 | - $l->tva_tx = $tx; |
|
1525 | - $l->total_ht = $val['total_ht']; |
|
1526 | - $l->total_tva = $val['total_tva']; |
|
1527 | - $l->total = $line->total_ht; |
|
1528 | - $l->total_ttc = $val['total_ttc']; |
|
1529 | - $TLines[] = $l; |
|
1530 | - array_shift($TTvas); |
|
1531 | - } |
|
1518 | + foreach ($TTvas as $tx =>$val){ |
|
1519 | + $l = clone $line; |
|
1520 | + $l->product_type = 1; |
|
1521 | + $l->special_code = ''; |
|
1522 | + $l->qty = 1; |
|
1523 | + $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx)); |
|
1524 | + $l->tva_tx = $tx; |
|
1525 | + $l->total_ht = $val['total_ht']; |
|
1526 | + $l->total_tva = $val['total_tva']; |
|
1527 | + $l->total = $line->total_ht; |
|
1528 | + $l->total_ttc = $val['total_ttc']; |
|
1529 | + $TLines[] = $l; |
|
1530 | + array_shift($TTvas); |
|
1531 | + } |
|
1532 | 1532 | } |
1533 | 1533 | |
1534 | 1534 | global $nblignes; |
@@ -1540,7 +1540,7 @@ discard block |
||
1540 | 1540 | $this->resprints = ''; |
1541 | 1541 | return 0; |
1542 | 1542 | } |
1543 | - } |
|
1543 | + } |
|
1544 | 1544 | |
1545 | 1545 | return 0; |
1546 | 1546 | } |
@@ -1703,18 +1703,18 @@ discard block |
||
1703 | 1703 | } |
1704 | 1704 | elseif($object->element == 'order_supplier' ) |
1705 | 1705 | { |
1706 | - $createRight = $user->rights->fournisseur->commande->creer; |
|
1706 | + $createRight = $user->rights->fournisseur->commande->creer; |
|
1707 | 1707 | } |
1708 | 1708 | elseif($object->element == 'invoice_supplier' ) |
1709 | 1709 | { |
1710 | - $createRight = $user->rights->fournisseur->facture->creer; |
|
1710 | + $createRight = $user->rights->fournisseur->facture->creer; |
|
1711 | 1711 | } |
1712 | 1712 | |
1713 | 1713 | if($line->special_code!=$this->module_number || $line->product_type!=9) { |
1714 | 1714 | null; |
1715 | 1715 | } |
1716 | 1716 | 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)) |
1717 | - { |
|
1717 | + { |
|
1718 | 1718 | if($object->element=='facture')$idvar = 'facid'; |
1719 | 1719 | else $idvar='id'; |
1720 | 1720 | |
@@ -1761,7 +1761,7 @@ discard block |
||
1761 | 1761 | //var_dump($line); |
1762 | 1762 | |
1763 | 1763 | // HTML 5 data for js |
1764 | - $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager); |
|
1764 | + $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager); |
|
1765 | 1765 | |
1766 | 1766 | |
1767 | 1767 | ?> |
@@ -1819,8 +1819,8 @@ discard block |
||
1819 | 1819 | } |
1820 | 1820 | |
1821 | 1821 | if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') { |
1822 | - $line->label = !empty($line->description) ? $line->description : $line->desc; |
|
1823 | - $line->description = ''; |
|
1822 | + $line->label = !empty($line->description) ? $line->description : $line->desc; |
|
1823 | + $line->description = ''; |
|
1824 | 1824 | } |
1825 | 1825 | $newlabel = $line->label; |
1826 | 1826 | if($line->label=='' && !$isFreeText) { |
@@ -2111,17 +2111,17 @@ discard block |
||
2111 | 2111 | if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline') |
2112 | 2112 | { |
2113 | 2113 | |
2114 | - if($object->element == 'invoice_supplier' || $object->element == 'order_supplier') |
|
2115 | - { |
|
2116 | - foreach ($object->lines as $line) |
|
2117 | - { |
|
2118 | - // fetch optionals attributes and labels |
|
2119 | - require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); |
|
2120 | - $extrafields=new ExtraFields($this->db); |
|
2121 | - $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true); |
|
2122 | - $line->fetch_optionals($line->id,$extralabels); |
|
2123 | - } |
|
2124 | - } |
|
2114 | + if($object->element == 'invoice_supplier' || $object->element == 'order_supplier') |
|
2115 | + { |
|
2116 | + foreach ($object->lines as $line) |
|
2117 | + { |
|
2118 | + // fetch optionals attributes and labels |
|
2119 | + require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); |
|
2120 | + $extrafields=new ExtraFields($this->db); |
|
2121 | + $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true); |
|
2122 | + $line->fetch_optionals($line->id,$extralabels); |
|
2123 | + } |
|
2124 | + } |
|
2125 | 2125 | |
2126 | 2126 | $TSubNc = array(); |
2127 | 2127 | foreach ($object->lines as &$l) |
@@ -2212,80 +2212,80 @@ discard block |
||
2212 | 2212 | { |
2213 | 2213 | dol_include_once('/subtotal/class/subtotal.class.php'); |
2214 | 2214 | |
2215 | - $line = &$parameters['line']; |
|
2215 | + $line = &$parameters['line']; |
|
2216 | 2216 | |
2217 | - $ThtmlData['data-id'] = $line->id; |
|
2218 | - $ThtmlData['data-product_type'] = $line->product_type; |
|
2219 | - $ThtmlData['data-qty'] = 0; //$line->qty; |
|
2220 | - $ThtmlData['data-level'] = TSubtotal::getNiveau($line); |
|
2217 | + $ThtmlData['data-id'] = $line->id; |
|
2218 | + $ThtmlData['data-product_type'] = $line->product_type; |
|
2219 | + $ThtmlData['data-qty'] = 0; //$line->qty; |
|
2220 | + $ThtmlData['data-level'] = TSubtotal::getNiveau($line); |
|
2221 | 2221 | |
2222 | - if(TSubtotal::isTitle($line)){ |
|
2223 | - $ThtmlData['data-issubtotal'] = 'title'; |
|
2224 | - }elseif(TSubtotal::isSubtotal($line)){ |
|
2225 | - $ThtmlData['data-issubtotal'] = 'subtotal'; |
|
2226 | - } |
|
2227 | - else{ |
|
2228 | - $ThtmlData['data-issubtotal'] = 'freetext'; |
|
2229 | - } |
|
2222 | + if(TSubtotal::isTitle($line)){ |
|
2223 | + $ThtmlData['data-issubtotal'] = 'title'; |
|
2224 | + }elseif(TSubtotal::isSubtotal($line)){ |
|
2225 | + $ThtmlData['data-issubtotal'] = 'subtotal'; |
|
2226 | + } |
|
2227 | + else{ |
|
2228 | + $ThtmlData['data-issubtotal'] = 'freetext'; |
|
2229 | + } |
|
2230 | 2230 | |
2231 | 2231 | |
2232 | - // Change or add data from hooks |
|
2233 | - $parameters = array_replace($parameters , array( 'ThtmlData' => $ThtmlData ) ); |
|
2232 | + // Change or add data from hooks |
|
2233 | + $parameters = array_replace($parameters , array( 'ThtmlData' => $ThtmlData ) ); |
|
2234 | 2234 | |
2235 | - // hook |
|
2236 | - $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
2237 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
2238 | - if ($reshook>0) |
|
2239 | - { |
|
2240 | - $ThtmlData = $hookmanager->resArray; |
|
2241 | - } |
|
2242 | - |
|
2243 | - return $this->implodeHtmlData($ThtmlData); |
|
2235 | + // hook |
|
2236 | + $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
2237 | + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
2238 | + if ($reshook>0) |
|
2239 | + { |
|
2240 | + $ThtmlData = $hookmanager->resArray; |
|
2241 | + } |
|
2242 | + |
|
2243 | + return $this->implodeHtmlData($ThtmlData); |
|
2244 | 2244 | |
2245 | 2245 | } |
2246 | 2246 | |
2247 | 2247 | |
2248 | 2248 | function implodeHtmlData($ThtmlData = array()) |
2249 | 2249 | { |
2250 | - $data = ''; |
|
2251 | - foreach($ThtmlData as $k => $h ) |
|
2252 | - { |
|
2253 | - if(is_array($h)) |
|
2254 | - { |
|
2255 | - $h = json_encode($h); |
|
2256 | - } |
|
2250 | + $data = ''; |
|
2251 | + foreach($ThtmlData as $k => $h ) |
|
2252 | + { |
|
2253 | + if(is_array($h)) |
|
2254 | + { |
|
2255 | + $h = json_encode($h); |
|
2256 | + } |
|
2257 | 2257 | |
2258 | - $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" '; |
|
2259 | - } |
|
2258 | + $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" '; |
|
2259 | + } |
|
2260 | 2260 | |
2261 | - return $data; |
|
2261 | + return $data; |
|
2262 | 2262 | } |
2263 | 2263 | |
2264 | 2264 | function _ajax_block_order_js($object) |
2265 | 2265 | { |
2266 | - global $conf,$tagidfortablednd,$filepath,$langs; |
|
2266 | + global $conf,$tagidfortablednd,$filepath,$langs; |
|
2267 | 2267 | |
2268 | - /* |
|
2268 | + /* |
|
2269 | 2269 | * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php |
2270 | 2270 | * for compatibility reasons we don't use tableDnD but jquery sortable |
2271 | 2271 | */ |
2272 | 2272 | |
2273 | - $id=$object->id; |
|
2274 | - $nboflines=(isset($object->lines)?count($object->lines):0); |
|
2275 | - $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1; |
|
2273 | + $id=$object->id; |
|
2274 | + $nboflines=(isset($object->lines)?count($object->lines):0); |
|
2275 | + $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1; |
|
2276 | 2276 | |
2277 | - $id=$object->id; |
|
2278 | - $fk_element=$object->fk_element; |
|
2279 | - $table_element_line=$object->table_element_line; |
|
2280 | - $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines)); |
|
2281 | - $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd); |
|
2282 | - $filepath=(empty($filepath)?'':$filepath); |
|
2277 | + $id=$object->id; |
|
2278 | + $fk_element=$object->fk_element; |
|
2279 | + $table_element_line=$object->table_element_line; |
|
2280 | + $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines)); |
|
2281 | + $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd); |
|
2282 | + $filepath=(empty($filepath)?'':$filepath); |
|
2283 | 2283 | |
2284 | 2284 | |
2285 | - if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1) |
|
2286 | - { |
|
2285 | + if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1) |
|
2286 | + { |
|
2287 | 2287 | |
2288 | - ?> |
|
2288 | + ?> |
|
2289 | 2289 | |
2290 | 2290 | |
2291 | 2291 | <script type="text/javascript"> |