@@ -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, $ThidepricesExceptionList; |
|
| 1047 | + global $conf, $hideprices, $ThidepricesExceptionList; |
|
| 1048 | 1048 | |
| 1049 | 1049 | if($this->isModSubtotalLine($parameters,$object) ){ |
| 1050 | 1050 | |
@@ -1083,28 +1083,28 @@ 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) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
|
| 1095 | - { |
|
| 1096 | - // Check if a title exist for this line |
|
| 1097 | - $lineTitle = TSubtotal::getParentTitleOfLine($object, $i); |
|
| 1098 | - if(TSubtotal::getParentTitleOfLine($object, $i)) |
|
| 1099 | - { |
|
| 1100 | - // check if the title have subtotal |
|
| 1101 | - if(TSubtotal::titleHasTotalLine($object, $lineTitle, true)) |
|
| 1102 | - { |
|
| 1103 | - $this->resprints = ' '; |
|
| 1104 | - return 1; |
|
| 1105 | - } |
|
| 1106 | - } |
|
| 1107 | - } |
|
| 1094 | + if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
|
| 1095 | + { |
|
| 1096 | + // Check if a title exist for this line |
|
| 1097 | + $lineTitle = TSubtotal::getParentTitleOfLine($object, $i); |
|
| 1098 | + if(TSubtotal::getParentTitleOfLine($object, $i)) |
|
| 1099 | + { |
|
| 1100 | + // check if the title have subtotal |
|
| 1101 | + if(TSubtotal::titleHasTotalLine($object, $lineTitle, true)) |
|
| 1102 | + { |
|
| 1103 | + $this->resprints = ' '; |
|
| 1104 | + return 1; |
|
| 1105 | + } |
|
| 1106 | + } |
|
| 1107 | + } |
|
| 1108 | 1108 | } |
| 1109 | 1109 | |
| 1110 | 1110 | return 0; |
@@ -1384,11 +1384,11 @@ discard block |
||
| 1384 | 1384 | $hidedetails = (int)GETPOST('hidedetails'); |
| 1385 | 1385 | |
| 1386 | 1386 | if ($hideInnerLines) { // si c une ligne de titre |
| 1387 | - $fk_parent_line=0; |
|
| 1387 | + $fk_parent_line=0; |
|
| 1388 | 1388 | $TLines =array(); |
| 1389 | 1389 | |
| 1390 | 1390 | $original_count=count($object->lines); |
| 1391 | - $TTvas = array(); // tableau de tva |
|
| 1391 | + $TTvas = array(); // tableau de tva |
|
| 1392 | 1392 | |
| 1393 | 1393 | foreach($object->lines as $k=>&$line) |
| 1394 | 1394 | { |
@@ -1418,48 +1418,48 @@ discard block |
||
| 1418 | 1418 | |
| 1419 | 1419 | if ($hideInnerLines) |
| 1420 | 1420 | { |
| 1421 | - if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) |
|
| 1422 | - { |
|
| 1423 | - if($line->tva_tx != '0.000' && $line->product_type!=9){ |
|
| 1421 | + if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) |
|
| 1422 | + { |
|
| 1423 | + if($line->tva_tx != '0.000' && $line->product_type!=9){ |
|
| 1424 | 1424 | |
| 1425 | - // on remplit le tableau de tva pour substituer les lignes cachées |
|
| 1426 | - $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva; |
|
| 1427 | - $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht; |
|
| 1428 | - $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; |
|
| 1429 | - } |
|
| 1430 | - if($line->product_type==9 && $line->rowid>0) |
|
| 1431 | - { |
|
| 1432 | - //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres |
|
| 1433 | - // génère des lignes d'affichage des montants HT soumis à tva |
|
| 1434 | - $nbtva = count($TTvas); |
|
| 1435 | - if(!empty($nbtva)){ |
|
| 1436 | - foreach ($TTvas as $tx =>$val){ |
|
| 1437 | - $l = clone $line; |
|
| 1438 | - $l->product_type = 1; |
|
| 1439 | - $l->special_code = ''; |
|
| 1440 | - $l->qty = 1; |
|
| 1441 | - $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx)); |
|
| 1442 | - $l->tva_tx = $tx; |
|
| 1443 | - $l->total_ht = $val['total_ht']; |
|
| 1444 | - $l->total_tva = $val['total_tva']; |
|
| 1445 | - $l->total = $line->total_ht; |
|
| 1446 | - $l->total_ttc = $val['total_ttc']; |
|
| 1447 | - $TLines[] = $l; |
|
| 1448 | - array_shift($TTvas); |
|
| 1449 | - } |
|
| 1450 | - } |
|
| 1425 | + // on remplit le tableau de tva pour substituer les lignes cachées |
|
| 1426 | + $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva; |
|
| 1427 | + $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht; |
|
| 1428 | + $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; |
|
| 1429 | + } |
|
| 1430 | + if($line->product_type==9 && $line->rowid>0) |
|
| 1431 | + { |
|
| 1432 | + //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres |
|
| 1433 | + // génère des lignes d'affichage des montants HT soumis à tva |
|
| 1434 | + $nbtva = count($TTvas); |
|
| 1435 | + if(!empty($nbtva)){ |
|
| 1436 | + foreach ($TTvas as $tx =>$val){ |
|
| 1437 | + $l = clone $line; |
|
| 1438 | + $l->product_type = 1; |
|
| 1439 | + $l->special_code = ''; |
|
| 1440 | + $l->qty = 1; |
|
| 1441 | + $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx)); |
|
| 1442 | + $l->tva_tx = $tx; |
|
| 1443 | + $l->total_ht = $val['total_ht']; |
|
| 1444 | + $l->total_tva = $val['total_tva']; |
|
| 1445 | + $l->total = $line->total_ht; |
|
| 1446 | + $l->total_ttc = $val['total_ttc']; |
|
| 1447 | + $TLines[] = $l; |
|
| 1448 | + array_shift($TTvas); |
|
| 1449 | + } |
|
| 1450 | + } |
|
| 1451 | 1451 | |
| 1452 | - // ajoute la ligne de sous-total |
|
| 1453 | - $TLines[] = $line; |
|
| 1454 | - } |
|
| 1455 | - } else { |
|
| 1452 | + // ajoute la ligne de sous-total |
|
| 1453 | + $TLines[] = $line; |
|
| 1454 | + } |
|
| 1455 | + } else { |
|
| 1456 | 1456 | |
| 1457 | - if($line->product_type==9 && $line->rowid>0) |
|
| 1458 | - { |
|
| 1459 | - // ajoute la ligne de sous-total |
|
| 1460 | - $TLines[] = $line; |
|
| 1461 | - } |
|
| 1462 | - } |
|
| 1457 | + if($line->product_type==9 && $line->rowid>0) |
|
| 1458 | + { |
|
| 1459 | + // ajoute la ligne de sous-total |
|
| 1460 | + $TLines[] = $line; |
|
| 1461 | + } |
|
| 1462 | + } |
|
| 1463 | 1463 | |
| 1464 | 1464 | |
| 1465 | 1465 | } |
@@ -1484,20 +1484,20 @@ discard block |
||
| 1484 | 1484 | $nbtva = count($TTvas); |
| 1485 | 1485 | if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) |
| 1486 | 1486 | { |
| 1487 | - foreach ($TTvas as $tx =>$val){ |
|
| 1488 | - $l = clone $line; |
|
| 1489 | - $l->product_type = 1; |
|
| 1490 | - $l->special_code = ''; |
|
| 1491 | - $l->qty = 1; |
|
| 1492 | - $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx)); |
|
| 1493 | - $l->tva_tx = $tx; |
|
| 1494 | - $l->total_ht = $val['total_ht']; |
|
| 1495 | - $l->total_tva = $val['total_tva']; |
|
| 1496 | - $l->total = $line->total_ht; |
|
| 1497 | - $l->total_ttc = $val['total_ttc']; |
|
| 1498 | - $TLines[] = $l; |
|
| 1499 | - array_shift($TTvas); |
|
| 1500 | - } |
|
| 1487 | + foreach ($TTvas as $tx =>$val){ |
|
| 1488 | + $l = clone $line; |
|
| 1489 | + $l->product_type = 1; |
|
| 1490 | + $l->special_code = ''; |
|
| 1491 | + $l->qty = 1; |
|
| 1492 | + $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx)); |
|
| 1493 | + $l->tva_tx = $tx; |
|
| 1494 | + $l->total_ht = $val['total_ht']; |
|
| 1495 | + $l->total_tva = $val['total_tva']; |
|
| 1496 | + $l->total = $line->total_ht; |
|
| 1497 | + $l->total_ttc = $val['total_ttc']; |
|
| 1498 | + $TLines[] = $l; |
|
| 1499 | + array_shift($TTvas); |
|
| 1500 | + } |
|
| 1501 | 1501 | } |
| 1502 | 1502 | |
| 1503 | 1503 | global $nblignes; |
@@ -1509,7 +1509,7 @@ discard block |
||
| 1509 | 1509 | $this->resprints = ''; |
| 1510 | 1510 | return 0; |
| 1511 | 1511 | } |
| 1512 | - } |
|
| 1512 | + } |
|
| 1513 | 1513 | |
| 1514 | 1514 | return 0; |
| 1515 | 1515 | } |
@@ -1672,18 +1672,18 @@ discard block |
||
| 1672 | 1672 | } |
| 1673 | 1673 | elseif($object->element == 'order_supplier' ) |
| 1674 | 1674 | { |
| 1675 | - $createRight = $user->rights->fournisseur->commande->creer; |
|
| 1675 | + $createRight = $user->rights->fournisseur->commande->creer; |
|
| 1676 | 1676 | } |
| 1677 | 1677 | elseif($object->element == 'invoice_supplier' ) |
| 1678 | 1678 | { |
| 1679 | - $createRight = $user->rights->fournisseur->facture->creer; |
|
| 1679 | + $createRight = $user->rights->fournisseur->facture->creer; |
|
| 1680 | 1680 | } |
| 1681 | 1681 | |
| 1682 | 1682 | if($line->special_code!=$this->module_number || $line->product_type!=9) { |
| 1683 | 1683 | null; |
| 1684 | 1684 | } |
| 1685 | 1685 | 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)) |
| 1686 | - { |
|
| 1686 | + { |
|
| 1687 | 1687 | if($object->element=='facture')$idvar = 'facid'; |
| 1688 | 1688 | else $idvar='id'; |
| 1689 | 1689 | |
@@ -1730,7 +1730,7 @@ discard block |
||
| 1730 | 1730 | //var_dump($line); |
| 1731 | 1731 | |
| 1732 | 1732 | // HTML 5 data for js |
| 1733 | - $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager); |
|
| 1733 | + $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager); |
|
| 1734 | 1734 | |
| 1735 | 1735 | |
| 1736 | 1736 | ?> |
@@ -1788,8 +1788,8 @@ discard block |
||
| 1788 | 1788 | } |
| 1789 | 1789 | |
| 1790 | 1790 | if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') { |
| 1791 | - $line->label = !empty($line->description) ? $line->description : $line->desc; |
|
| 1792 | - $line->description = ''; |
|
| 1791 | + $line->label = !empty($line->description) ? $line->description : $line->desc; |
|
| 1792 | + $line->description = ''; |
|
| 1793 | 1793 | } |
| 1794 | 1794 | $newlabel = $line->label; |
| 1795 | 1795 | if($line->label=='' && !$isFreeText) { |
@@ -2080,17 +2080,17 @@ discard block |
||
| 2080 | 2080 | if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline') |
| 2081 | 2081 | { |
| 2082 | 2082 | |
| 2083 | - if($object->element == 'invoice_supplier' || $object->element == 'order_supplier') |
|
| 2084 | - { |
|
| 2085 | - foreach ($object->lines as $line) |
|
| 2086 | - { |
|
| 2087 | - // fetch optionals attributes and labels |
|
| 2088 | - require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); |
|
| 2089 | - $extrafields=new ExtraFields($this->db); |
|
| 2090 | - $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true); |
|
| 2091 | - $line->fetch_optionals($line->id,$extralabels); |
|
| 2092 | - } |
|
| 2093 | - } |
|
| 2083 | + if($object->element == 'invoice_supplier' || $object->element == 'order_supplier') |
|
| 2084 | + { |
|
| 2085 | + foreach ($object->lines as $line) |
|
| 2086 | + { |
|
| 2087 | + // fetch optionals attributes and labels |
|
| 2088 | + require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); |
|
| 2089 | + $extrafields=new ExtraFields($this->db); |
|
| 2090 | + $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true); |
|
| 2091 | + $line->fetch_optionals($line->id,$extralabels); |
|
| 2092 | + } |
|
| 2093 | + } |
|
| 2094 | 2094 | |
| 2095 | 2095 | $TSubNc = array(); |
| 2096 | 2096 | foreach ($object->lines as &$l) |
@@ -2181,80 +2181,80 @@ discard block |
||
| 2181 | 2181 | { |
| 2182 | 2182 | dol_include_once('/subtotal/class/subtotal.class.php'); |
| 2183 | 2183 | |
| 2184 | - $line = &$parameters['line']; |
|
| 2184 | + $line = &$parameters['line']; |
|
| 2185 | 2185 | |
| 2186 | - $ThtmlData['data-id'] = $line->id; |
|
| 2187 | - $ThtmlData['data-product_type'] = $line->product_type; |
|
| 2188 | - $ThtmlData['data-qty'] = 0; //$line->qty; |
|
| 2189 | - $ThtmlData['data-level'] = TSubtotal::getNiveau($line); |
|
| 2186 | + $ThtmlData['data-id'] = $line->id; |
|
| 2187 | + $ThtmlData['data-product_type'] = $line->product_type; |
|
| 2188 | + $ThtmlData['data-qty'] = 0; //$line->qty; |
|
| 2189 | + $ThtmlData['data-level'] = TSubtotal::getNiveau($line); |
|
| 2190 | 2190 | |
| 2191 | - if(TSubtotal::isTitle($line)){ |
|
| 2192 | - $ThtmlData['data-issubtotal'] = 'title'; |
|
| 2193 | - }elseif(TSubtotal::isSubtotal($line)){ |
|
| 2194 | - $ThtmlData['data-issubtotal'] = 'subtotal'; |
|
| 2195 | - } |
|
| 2196 | - else{ |
|
| 2197 | - $ThtmlData['data-issubtotal'] = 'freetext'; |
|
| 2198 | - } |
|
| 2191 | + if(TSubtotal::isTitle($line)){ |
|
| 2192 | + $ThtmlData['data-issubtotal'] = 'title'; |
|
| 2193 | + }elseif(TSubtotal::isSubtotal($line)){ |
|
| 2194 | + $ThtmlData['data-issubtotal'] = 'subtotal'; |
|
| 2195 | + } |
|
| 2196 | + else{ |
|
| 2197 | + $ThtmlData['data-issubtotal'] = 'freetext'; |
|
| 2198 | + } |
|
| 2199 | 2199 | |
| 2200 | 2200 | |
| 2201 | - // Change or add data from hooks |
|
| 2202 | - $parameters = array_replace($parameters , array( 'ThtmlData' => $ThtmlData ) ); |
|
| 2201 | + // Change or add data from hooks |
|
| 2202 | + $parameters = array_replace($parameters , array( 'ThtmlData' => $ThtmlData ) ); |
|
| 2203 | 2203 | |
| 2204 | - // hook |
|
| 2205 | - $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
| 2206 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 2207 | - if ($reshook>0) |
|
| 2208 | - { |
|
| 2209 | - $ThtmlData = $hookmanager->resArray; |
|
| 2210 | - } |
|
| 2211 | - |
|
| 2212 | - return $this->implodeHtmlData($ThtmlData); |
|
| 2204 | + // hook |
|
| 2205 | + $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
| 2206 | + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 2207 | + if ($reshook>0) |
|
| 2208 | + { |
|
| 2209 | + $ThtmlData = $hookmanager->resArray; |
|
| 2210 | + } |
|
| 2211 | + |
|
| 2212 | + return $this->implodeHtmlData($ThtmlData); |
|
| 2213 | 2213 | |
| 2214 | 2214 | } |
| 2215 | 2215 | |
| 2216 | 2216 | |
| 2217 | 2217 | function implodeHtmlData($ThtmlData = array()) |
| 2218 | 2218 | { |
| 2219 | - $data = ''; |
|
| 2220 | - foreach($ThtmlData as $k => $h ) |
|
| 2221 | - { |
|
| 2222 | - if(is_array($h)) |
|
| 2223 | - { |
|
| 2224 | - $h = json_encode($h); |
|
| 2225 | - } |
|
| 2219 | + $data = ''; |
|
| 2220 | + foreach($ThtmlData as $k => $h ) |
|
| 2221 | + { |
|
| 2222 | + if(is_array($h)) |
|
| 2223 | + { |
|
| 2224 | + $h = json_encode($h); |
|
| 2225 | + } |
|
| 2226 | 2226 | |
| 2227 | - $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" '; |
|
| 2228 | - } |
|
| 2227 | + $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" '; |
|
| 2228 | + } |
|
| 2229 | 2229 | |
| 2230 | - return $data; |
|
| 2230 | + return $data; |
|
| 2231 | 2231 | } |
| 2232 | 2232 | |
| 2233 | 2233 | function _ajax_block_order_js($object) |
| 2234 | 2234 | { |
| 2235 | - global $conf,$tagidfortablednd,$filepath,$langs; |
|
| 2235 | + global $conf,$tagidfortablednd,$filepath,$langs; |
|
| 2236 | 2236 | |
| 2237 | - /* |
|
| 2237 | + /* |
|
| 2238 | 2238 | * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php |
| 2239 | 2239 | * for compatibility reasons we don't use tableDnD but jquery sortable |
| 2240 | 2240 | */ |
| 2241 | 2241 | |
| 2242 | - $id=$object->id; |
|
| 2243 | - $nboflines=(isset($object->lines)?count($object->lines):0); |
|
| 2244 | - $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1; |
|
| 2242 | + $id=$object->id; |
|
| 2243 | + $nboflines=(isset($object->lines)?count($object->lines):0); |
|
| 2244 | + $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1; |
|
| 2245 | 2245 | |
| 2246 | - $id=$object->id; |
|
| 2247 | - $fk_element=$object->fk_element; |
|
| 2248 | - $table_element_line=$object->table_element_line; |
|
| 2249 | - $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines)); |
|
| 2250 | - $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd); |
|
| 2251 | - $filepath=(empty($filepath)?'':$filepath); |
|
| 2246 | + $id=$object->id; |
|
| 2247 | + $fk_element=$object->fk_element; |
|
| 2248 | + $table_element_line=$object->table_element_line; |
|
| 2249 | + $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines)); |
|
| 2250 | + $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd); |
|
| 2251 | + $filepath=(empty($filepath)?'':$filepath); |
|
| 2252 | 2252 | |
| 2253 | 2253 | |
| 2254 | - if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1) |
|
| 2255 | - { |
|
| 2254 | + if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1) |
|
| 2255 | + { |
|
| 2256 | 2256 | |
| 2257 | - ?> |
|
| 2257 | + ?> |
|
| 2258 | 2258 | |
| 2259 | 2259 | |
| 2260 | 2260 | <script type="text/javascript"> |