| @@ -25,7 +25,9 @@ discard block | ||
| 25 | 25 | $value = ''; | 
| 26 | 26 |  				$sql = 'SELECT content FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text WHERE rowid = '.GETPOST('rowid'); | 
| 27 | 27 | $resql = $this->db->query($sql); | 
| 28 | - if ($resql && ($obj = $this->db->fetch_object($resql))) $value = $obj->content; | |
| 28 | +				if ($resql && ($obj = $this->db->fetch_object($resql))) { | |
| 29 | + $value = $obj->content; | |
| 30 | + } | |
| 29 | 31 | } | 
| 30 | 32 | |
| 31 | 33 | ?> | 
| @@ -109,8 +111,11 @@ discard block | ||
| 109 | 111 |  			if ($object->statut == 0  && $createRight) { | 
| 110 | 112 | |
| 111 | 113 | |
| 112 | - if($object->element=='facture')$idvar = 'facid'; | |
| 113 | - else $idvar='id'; | |
| 114 | +				if($object->element=='facture') { | |
| 115 | + $idvar = 'facid'; | |
| 116 | +				} else { | |
| 117 | + $idvar='id'; | |
| 118 | + } | |
| 114 | 119 | |
| 115 | 120 |  				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) ) | 
| 116 | 121 |  				{ | 
| @@ -118,10 +123,11 @@ discard block | ||
| 118 | 123 | |
| 119 | 124 |  					if($action=='add_title_line') { | 
| 120 | 125 |  						$title = GETPOST('title'); | 
| 121 | -						if(empty($title)) $title = $langs->trans('title'); | |
| 126 | +						if(empty($title)) { | |
| 127 | +							$title = $langs->trans('title'); | |
| 128 | + } | |
| 122 | 129 | $qty = $level<1 ? 1 : $level ; | 
| 123 | - } | |
| 124 | -					else if($action=='add_free_text') { | |
| 130 | +					} else if($action=='add_free_text') { | |
| 125 | 131 |  						$title = GETPOST('title'); | 
| 126 | 132 | |
| 127 | 133 |  						if (empty($title)) { | 
| @@ -133,29 +139,31 @@ discard block | ||
| 133 | 139 | } | 
| 134 | 140 | } | 
| 135 | 141 | } | 
| 136 | -						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription'); | |
| 142 | +						if(empty($title)) { | |
| 143 | +							$title = $langs->trans('subtotalAddLineDescription'); | |
| 144 | + } | |
| 137 | 145 | $qty = 50; | 
| 138 | - } | |
| 139 | -					else if($action=='add_subtitle_line') { | |
| 146 | +					} else if($action=='add_subtitle_line') { | |
| 140 | 147 |  						$title = GETPOST('title'); | 
| 141 | -						if(empty($title)) $title = $langs->trans('subtitle'); | |
| 148 | +						if(empty($title)) { | |
| 149 | +							$title = $langs->trans('subtitle'); | |
| 150 | + } | |
| 142 | 151 | $qty = 2; | 
| 143 | - } | |
| 144 | -					else if($action=='add_subtotal_line') { | |
| 152 | +					} else if($action=='add_subtotal_line') { | |
| 145 | 153 |  						$title = $langs->trans('SubSubTotal'); | 
| 146 | 154 | $qty = 98; | 
| 147 | - } | |
| 148 | -					else { | |
| 155 | +					} else { | |
| 149 | 156 |  						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal'); | 
| 150 | 157 | $qty = $level ? 100-$level : 99; | 
| 151 | 158 | } | 
| 152 | 159 |  					dol_include_once('/subtotal/class/subtotal.class.php'); | 
| 153 | 160 | |
| 154 | - if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty); | |
| 161 | +					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) { | |
| 162 | + TSubtotal::addSubtotalMissing($object, $qty); | |
| 163 | + } | |
| 155 | 164 | |
| 156 | 165 | TSubtotal::addSubTotalLine($object, $title, $qty); | 
| 157 | - } | |
| 158 | -				else if($action==='ask_deleteallline') { | |
| 166 | +				} else if($action==='ask_deleteallline') { | |
| 159 | 167 | $form=new Form($db); | 
| 160 | 168 | |
| 161 | 169 |  						$lineid = GETPOST('lineid','integer'); | 
| @@ -178,8 +186,7 @@ discard block | ||
| 178 | 186 | $this->printNewFormat($object, $conf, $langs, $idvar); | 
| 179 | 187 | } | 
| 180 | 188 | } | 
| 181 | - } | |
| 182 | -		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts)) | |
| 189 | +		} elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts)) | |
| 183 | 190 |  		{ | 
| 184 | 191 | ?> | 
| 185 | 192 | <script type="text/javascript"> | 
| @@ -197,8 +204,13 @@ discard block | ||
| 197 | 204 | |
| 198 | 205 | function printNewFormat(&$object, &$conf, &$langs, $idvar) | 
| 199 | 206 |  	{ | 
| 200 | - if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) return false; | |
| 201 | - if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) return false; // Si facture de situation | |
| 207 | +		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) { | |
| 208 | + return false; | |
| 209 | + } | |
| 210 | +		if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) { | |
| 211 | + return false; | |
| 212 | + } | |
| 213 | + // Si facture de situation | |
| 202 | 214 | ?> | 
| 203 | 215 | <script type="text/javascript"> | 
| 204 | 216 |  				$(document).ready(function() { | 
| @@ -484,8 +496,7 @@ discard block | ||
| 484 | 496 | } | 
| 485 | 497 | |
| 486 | 498 | |
| 487 | - } | |
| 488 | -			else{ | |
| 499 | +			} else{ | |
| 489 | 500 | $substitutionarray['line_not_modsubtotal'] = true; | 
| 490 | 501 | $substitutionarray['line_modsubtotal'] = 0; | 
| 491 | 502 | } | 
| @@ -543,8 +554,11 @@ discard block | ||
| 543 | 554 | |
| 544 | 555 |  		$showBlockExtrafields = GETPOST('showBlockExtrafields'); | 
| 545 | 556 | |
| 546 | - if($object->element=='facture') $idvar = 'facid'; | |
| 547 | - else $idvar = 'id'; | |
| 557 | +		if($object->element=='facture') { | |
| 558 | + $idvar = 'facid'; | |
| 559 | +		} else { | |
| 560 | + $idvar = 'id'; | |
| 561 | + } | |
| 548 | 562 | |
| 549 | 563 | if ($action == 'updateligne' || $action == 'updateline') | 
| 550 | 564 |  		{ | 
| @@ -574,8 +588,7 @@ discard block | ||
| 574 | 588 |  				header('Location: '.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id); | 
| 575 | 589 | exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne | 
| 576 | 590 | } | 
| 577 | - } | |
| 578 | -		else if($action === 'builddoc') { | |
| 591 | +		} else if($action === 'builddoc') { | |
| 579 | 592 | |
| 580 | 593 | if ( | 
| 581 | 594 |  				in_array('invoicecard',explode(':',$parameters['context'])) | 
| @@ -590,33 +603,27 @@ discard block | ||
| 590 | 603 | $sessname = 'subtotal_hideInnerLines_facture'; | 
| 591 | 604 | $sessname2 = 'subtotal_hidedetails_facture'; | 
| 592 | 605 | $sessname3 = 'subtotal_hideprices_facture'; | 
| 593 | - } | |
| 594 | -				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) { | |
| 606 | +				} elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) { | |
| 595 | 607 | $sessname = 'subtotal_hideInnerLines_facture_fournisseur'; | 
| 596 | 608 | $sessname2 = 'subtotal_hidedetails_facture_fournisseur'; | 
| 597 | 609 | $sessname3 = 'subtotal_hideprices_facture_fournisseur'; | 
| 598 | - } | |
| 599 | -				elseif(in_array('propalcard',explode(':',$parameters['context']))) { | |
| 610 | +				} elseif(in_array('propalcard',explode(':',$parameters['context']))) { | |
| 600 | 611 | $sessname = 'subtotal_hideInnerLines_propal'; | 
| 601 | 612 | $sessname2 = 'subtotal_hidedetails_propal'; | 
| 602 | 613 | $sessname3 = 'subtotal_hideprices_propal'; | 
| 603 | - } | |
| 604 | -				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) { | |
| 614 | +				} elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) { | |
| 605 | 615 | $sessname = 'subtotal_hideInnerLines_supplier_proposal'; | 
| 606 | 616 | $sessname2 = 'subtotal_hidedetails_supplier_proposal'; | 
| 607 | 617 | $sessname3 = 'subtotal_hideprices_supplier_proposal'; | 
| 608 | - } | |
| 609 | -				elseif(in_array('ordercard',explode(':',$parameters['context']))) { | |
| 618 | +				} elseif(in_array('ordercard',explode(':',$parameters['context']))) { | |
| 610 | 619 | $sessname = 'subtotal_hideInnerLines_commande'; | 
| 611 | 620 | $sessname2 = 'subtotal_hidedetails_commande'; | 
| 612 | 621 | $sessname3 = 'subtotal_hideprices_commande'; | 
| 613 | - } | |
| 614 | -				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) { | |
| 622 | +				} elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) { | |
| 615 | 623 | $sessname = 'subtotal_hideInnerLines_commande_fournisseur'; | 
| 616 | 624 | $sessname2 = 'subtotal_hidedetails_commande_fournisseur'; | 
| 617 | 625 | $sessname3 = 'subtotal_hideprices_commande_fournisseur'; | 
| 618 | - } | |
| 619 | -				else { | |
| 626 | +				} else { | |
| 620 | 627 | $sessname = 'subtotal_hideInnerLines_unknown'; | 
| 621 | 628 | $sessname2 = 'subtotal_hidedetails_unknown'; | 
| 622 | 629 | $sessname3 = 'subtotal_hideprices_unknown'; | 
| @@ -638,8 +645,7 @@ discard block | ||
| 638 | 645 | |
| 639 | 646 |                          if($line->qty>=90) { | 
| 640 | 647 | $line->modsubtotal_total = 1; | 
| 641 | - } | |
| 642 | -                        else{ | |
| 648 | +                        } else{ | |
| 643 | 649 | $line->modsubtotal_title = 1; | 
| 644 | 650 | } | 
| 645 | 651 | |
| @@ -648,8 +654,7 @@ discard block | ||
| 648 | 654 | } | 
| 649 | 655 | } | 
| 650 | 656 | |
| 651 | - } | |
| 652 | -		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') { | |
| 657 | +		} else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') { | |
| 653 | 658 | |
| 654 | 659 |  			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid')); | 
| 655 | 660 | |
| @@ -657,7 +662,9 @@ discard block | ||
| 657 | 662 | /** | 
| 658 | 663 | * @var $object Facture | 
| 659 | 664 | */ | 
| 660 | - if($object->element=='facture') $object->deleteline($idLine); | |
| 665 | +				if($object->element=='facture') { | |
| 666 | + $object->deleteline($idLine); | |
| 667 | + } | |
| 661 | 668 | /** | 
| 662 | 669 | * @var $object Facture fournisseur | 
| 663 | 670 | */ | 
| @@ -668,18 +675,25 @@ discard block | ||
| 668 | 675 | /** | 
| 669 | 676 | * @var $object Propal | 
| 670 | 677 | */ | 
| 671 | - else if($object->element=='propal') $object->deleteline($idLine); | |
| 678 | +				else if($object->element=='propal') { | |
| 679 | + $object->deleteline($idLine); | |
| 680 | + } | |
| 672 | 681 | /** | 
| 673 | 682 | * @var $object Propal Fournisseur | 
| 674 | 683 | */ | 
| 675 | - else if($object->element=='supplier_proposal') $object->deleteline($idLine); | |
| 684 | +				else if($object->element=='supplier_proposal') { | |
| 685 | + $object->deleteline($idLine); | |
| 686 | + } | |
| 676 | 687 | /** | 
| 677 | 688 | * @var $object Commande | 
| 678 | 689 | */ | 
| 679 | 690 | else if($object->element=='commande') | 
| 680 | 691 |  				{ | 
| 681 | - if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine); | |
| 682 | - else $object->deleteline($idLine); | |
| 692 | +					if ((float) DOL_VERSION >= 5.0) { | |
| 693 | + $object->deleteline($user, $idLine); | |
| 694 | +					} else { | |
| 695 | + $object->deleteline($idLine); | |
| 696 | + } | |
| 683 | 697 | } | 
| 684 | 698 | /** | 
| 685 | 699 | * @var $object Commande fournisseur | 
| @@ -691,21 +705,26 @@ discard block | ||
| 691 | 705 | /** | 
| 692 | 706 | * @var $object Facturerec | 
| 693 | 707 | */ | 
| 694 | - else if($object->element=='facturerec') $object->deleteline($idLine); | |
| 708 | +				else if($object->element=='facturerec') { | |
| 709 | + $object->deleteline($idLine); | |
| 710 | + } | |
| 695 | 711 | } | 
| 696 | 712 | |
| 697 | 713 |  			header('location:?id='.$object->id); | 
| 698 | 714 | exit; | 
| 699 | 715 | |
| 700 | - } | |
| 701 | - else if ($action == 'duplicate') | |
| 716 | + } else if ($action == 'duplicate') | |
| 702 | 717 |  		{ | 
| 703 | 718 |  			$lineid = GETPOST('lineid', 'int'); | 
| 704 | 719 | $nbDuplicate = TSubtotal::duplicateLines($object, $lineid, true); | 
| 705 | 720 | |
| 706 | -			if ($nbDuplicate > 0) setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate)); | |
| 707 | -			elseif ($nbDuplicate == 0) setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings'); | |
| 708 | -			else setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors'); | |
| 721 | +			if ($nbDuplicate > 0) { | |
| 722 | +				setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate)); | |
| 723 | +			} elseif ($nbDuplicate == 0) { | |
| 724 | +				setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings'); | |
| 725 | +			} else { | |
| 726 | +				setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors'); | |
| 727 | + } | |
| 709 | 728 | |
| 710 | 729 |  			header('Location: ?id='.$object->id); | 
| 711 | 730 | exit; | 
| @@ -785,17 +804,18 @@ discard block | ||
| 785 | 804 | //print $l->rang.'>='.$rang.' '.$total.'<br/>'; | 
| 786 | 805 |  			if($l->rang>=$rang) { | 
| 787 | 806 | //echo 'return!<br>'; | 
| 788 | - if (!$return_all) return $total; | |
| 789 | - else return array($total, $total_tva, $total_ttc, $TTotal_tva); | |
| 790 | - } | |
| 791 | - else if(TSubtotal::isTitle($l, 100 - $qty_line)) | |
| 807 | +				if (!$return_all) { | |
| 808 | + return $total; | |
| 809 | +				} else { | |
| 810 | + return array($total, $total_tva, $total_ttc, $TTotal_tva); | |
| 811 | + } | |
| 812 | + } else if(TSubtotal::isTitle($l, 100 - $qty_line)) | |
| 792 | 813 |  		  	{ | 
| 793 | 814 | $total = 0; | 
| 794 | 815 | $total_tva = 0; | 
| 795 | 816 | $total_ttc = 0; | 
| 796 | 817 | $TTotal_tva = array(); | 
| 797 | - } | |
| 798 | -			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) { | |
| 818 | +			} elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) { | |
| 799 | 819 | $total += $l->total_ht; | 
| 800 | 820 | $total_tva += $l->total_tva; | 
| 801 | 821 | $TTotal_tva[$l->tva_tx] += $l->total_tva; | 
| @@ -803,8 +823,11 @@ discard block | ||
| 803 | 823 | } | 
| 804 | 824 | |
| 805 | 825 | } | 
| 806 | - if (!$return_all) return $total; | |
| 807 | - else return array($total, $total_tva, $total_ttc, $TTotal_tva); | |
| 826 | +		if (!$return_all) { | |
| 827 | + return $total; | |
| 828 | +		} else { | |
| 829 | + return array($total, $total_tva, $total_ttc, $TTotal_tva); | |
| 830 | + } | |
| 808 | 831 | } | 
| 809 | 832 | |
| 810 | 833 | /* | 
| @@ -872,15 +895,18 @@ discard block | ||
| 872 | 895 | } | 
| 873 | 896 | |
| 874 | 897 | |
| 875 | - if($line->qty==99) | |
| 876 | - $pdf->SetFillColor(220,220,220); | |
| 877 | - elseif ($line->qty==98) | |
| 878 | - $pdf->SetFillColor(230,230,230); | |
| 879 | - else | |
| 880 | - $pdf->SetFillColor(240,240,240); | |
| 898 | +		if($line->qty==99) { | |
| 899 | + $pdf->SetFillColor(220,220,220); | |
| 900 | +		} elseif ($line->qty==98) { | |
| 901 | + $pdf->SetFillColor(230,230,230); | |
| 902 | +		} else { | |
| 903 | + $pdf->SetFillColor(240,240,240); | |
| 904 | + } | |
| 881 | 905 | |
| 882 | 906 | $style = 'B'; | 
| 883 | - if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE; | |
| 907 | +		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) { | |
| 908 | + $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE; | |
| 909 | + } | |
| 884 | 910 | |
| 885 | 911 |  		$pdf->SetFont('', $style, 9); | 
| 886 | 912 | |
| @@ -919,8 +945,7 @@ discard block | ||
| 919 | 945 | // $line->total_tva | 
| 920 | 946 | // $line->total | 
| 921 | 947 | // $line->total_ttc | 
| 922 | - } | |
| 923 | - else | |
| 948 | + } else | |
| 924 | 949 |  				{ | 
| 925 | 950 | list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1); | 
| 926 | 951 |                                          if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation | 
| @@ -937,11 +962,14 @@ discard block | ||
| 937 | 962 | } | 
| 938 | 963 | |
| 939 | 964 | $pdf->SetXY($pdf->postotalht, $posy); | 
| 940 | - if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); | |
| 965 | +			if($set_pagebreak_margin) { | |
| 966 | + $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); | |
| 967 | + } | |
| 941 | 968 | $pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0); | 
| 942 | - } | |
| 943 | -		else{ | |
| 944 | - if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); | |
| 969 | +		} else{ | |
| 970 | +			if($set_pagebreak_margin) { | |
| 971 | + $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); | |
| 972 | + } | |
| 945 | 973 | } | 
| 946 | 974 | |
| 947 | 975 | $posy = $posy + $cell_height; | 
| @@ -973,25 +1001,40 @@ discard block | ||
| 973 | 1001 | |
| 974 | 1002 | |
| 975 | 1003 | $style = ($line->qty==1) ? 'BU' : 'BUI'; | 
| 976 | - if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE; | |
| 1004 | +		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) { | |
| 1005 | + $style = $conf->global->SUBTOTAL_TITLE_STYLE; | |
| 1006 | + } | |
| 977 | 1007 | |
| 978 | 1008 |  		if($hideInnerLines) { | 
| 979 | -			if($line->qty==1)$pdf->SetFont('', $style, 9); | |
| 980 | - else | |
| 1009 | +			if($line->qty==1) { | |
| 1010 | +				$pdf->SetFont('', $style, 9); | |
| 1011 | + } else | |
| 981 | 1012 |  			{ | 
| 982 | - if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES; | |
| 1013 | +				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) { | |
| 1014 | + $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES; | |
| 1015 | + } | |
| 983 | 1016 |  				$pdf->SetFont('', $style, 9); | 
| 984 | 1017 | } | 
| 985 | - } | |
| 986 | -		else { | |
| 1018 | +		} else { | |
| 987 | 1019 | |
| 988 | -			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile | |
| 989 | -			else $pdf->SetFont('', $style, 9); | |
| 1020 | +			if($line->qty==1) { | |
| 1021 | +				$pdf->SetFont('', $style, 9); | |
| 1022 | + } | |
| 1023 | + //TODO if super utile | |
| 1024 | +			else { | |
| 1025 | +				$pdf->SetFont('', $style, 9); | |
| 1026 | + } | |
| 990 | 1027 | |
| 991 | 1028 | } | 
| 992 | 1029 | |
| 993 | - if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) $pdf->MultiCell($w, $h, $label, 0, 'L'); // Pas de HTML dans la chaine | |
| 994 | - else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML | |
| 1030 | +		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) { | |
| 1031 | + $pdf->MultiCell($w, $h, $label, 0, 'L'); | |
| 1032 | + } | |
| 1033 | + // Pas de HTML dans la chaine | |
| 1034 | +		else { | |
| 1035 | + $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); | |
| 1036 | + } | |
| 1037 | + // et maintenant avec du HTML | |
| 995 | 1038 | |
| 996 | 1039 |  		if($description && !$hidedesc) { | 
| 997 | 1040 | $posy = $pdf->GetY(); | 
| @@ -1015,8 +1058,7 @@ discard block | ||
| 1015 | 1058 | |
| 1016 | 1059 |  		if(is_array($parameters)) { | 
| 1017 | 1060 | $i = & $parameters['i']; | 
| 1018 | - } | |
| 1019 | -		else { | |
| 1061 | +		} else { | |
| 1020 | 1062 | $i = (int)$parameters; | 
| 1021 | 1063 | } | 
| 1022 | 1064 | |
| @@ -1038,17 +1080,14 @@ discard block | ||
| 1038 | 1080 | |
| 1039 | 1081 |  			if((float)DOL_VERSION<=3.6) { | 
| 1040 | 1082 | return ''; | 
| 1041 | - } | |
| 1042 | -			else if((float)DOL_VERSION>=3.8) { | |
| 1083 | +			} else if((float)DOL_VERSION>=3.8) { | |
| 1043 | 1084 | return 1; | 
| 1044 | 1085 | } | 
| 1045 | 1086 | |
| 1046 | - } | |
| 1047 | -		elseif(!empty($hideprices)) { | |
| 1087 | +		} elseif(!empty($hideprices)) { | |
| 1048 | 1088 | $this->resprints = $object->lines[$parameters['i']]->qty; | 
| 1049 | 1089 | return 1; | 
| 1050 | - } | |
| 1051 | - elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY)) | |
| 1090 | + } elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY)) | |
| 1052 | 1091 |  		{ | 
| 1053 | 1092 |  			$hideInnerLines = (int)GETPOST('hideInnerLines'); | 
| 1054 | 1093 |  			$hidedetails = (int)GETPOST('hidedetails'); | 
| @@ -1058,12 +1097,20 @@ discard block | ||
| 1058 | 1097 | } | 
| 1059 | 1098 | } | 
| 1060 | 1099 | |
| 1061 | - if(is_array($parameters)) $i = & $parameters['i']; | |
| 1062 | - else $i = (int)$parameters; | |
| 1100 | +		if(is_array($parameters)) { | |
| 1101 | + $i = & $parameters['i']; | |
| 1102 | +		} else { | |
| 1103 | + $i = (int)$parameters; | |
| 1104 | + } | |
| 1063 | 1105 | |
| 1064 | - if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) | |
| 1106 | +		if (empty($object->lines[$i])) { | |
| 1107 | + return 0; | |
| 1108 | + } | |
| 1109 | + // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) | |
| 1065 | 1110 | |
| 1066 | - if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals(); | |
| 1111 | +		if(empty($object->lines[$i]->array_options)) { | |
| 1112 | + $object->lines[$i]->fetch_optionals(); | |
| 1113 | + } | |
| 1067 | 1114 | |
| 1068 | 1115 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) | 
| 1069 | 1116 |  		{ | 
| @@ -1086,16 +1133,17 @@ discard block | ||
| 1086 | 1133 | |
| 1087 | 1134 |  			if((float)DOL_VERSION<=3.6) { | 
| 1088 | 1135 | return ''; | 
| 1089 | - } | |
| 1090 | -			else if((float)DOL_VERSION>=3.8) { | |
| 1136 | +			} else if((float)DOL_VERSION>=3.8) { | |
| 1091 | 1137 | return 1; | 
| 1092 | 1138 | } | 
| 1093 | 1139 | |
| 1094 | - } | |
| 1095 | - elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS)) | |
| 1140 | + } elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS)) | |
| 1096 | 1141 |  		{ | 
| 1097 | - if(is_array($parameters)) $i = & $parameters['i']; | |
| 1098 | - else $i = (int)$parameters; | |
| 1142 | +			if(is_array($parameters)) { | |
| 1143 | + $i = & $parameters['i']; | |
| 1144 | +			} else { | |
| 1145 | + $i = (int)$parameters; | |
| 1146 | + } | |
| 1099 | 1147 | |
| 1100 | 1148 |  			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) | 
| 1101 | 1149 |  			{ | 
| @@ -1117,8 +1165,11 @@ discard block | ||
| 1117 | 1165 | } | 
| 1118 | 1166 | } | 
| 1119 | 1167 |  		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){ | 
| 1120 | - if(is_array($parameters)) $i = & $parameters['i']; | |
| 1121 | - else $i = (int)$parameters; | |
| 1168 | +		    if(is_array($parameters)) { | |
| 1169 | + $i = & $parameters['i']; | |
| 1170 | +		    } else { | |
| 1171 | + $i = (int)$parameters; | |
| 1172 | + } | |
| 1122 | 1173 | $this->resprints = price($object->lines[$i]->total_ht); | 
| 1123 | 1174 | } | 
| 1124 | 1175 | if (!empty($hideprices) | 
| @@ -1128,8 +1179,11 @@ discard block | ||
| 1128 | 1179 | if (!empty($hideprices)) | 
| 1129 | 1180 |  		    { | 
| 1130 | 1181 | |
| 1131 | - if(is_array($parameters)) $i = & $parameters['i']; | |
| 1132 | - else $i = (int)$parameters; | |
| 1182 | +		        if(is_array($parameters)) { | |
| 1183 | + $i = & $parameters['i']; | |
| 1184 | +		        } else { | |
| 1185 | + $i = (int)$parameters; | |
| 1186 | + } | |
| 1133 | 1187 | |
| 1134 | 1188 | // Check if a title exist for this line && if the title have subtotal | 
| 1135 | 1189 | $lineTitle = TSubtotal::getParentTitleOfLine($object, $i); | 
| @@ -1144,12 +1198,10 @@ discard block | ||
| 1144 | 1198 |  		            { | 
| 1145 | 1199 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); | 
| 1146 | 1200 | return -1; | 
| 1147 | - } | |
| 1148 | - elseif (empty($reshook)) | |
| 1201 | + } elseif (empty($reshook)) | |
| 1149 | 1202 |  		            { | 
| 1150 | 1203 | $this->resprints .= $hookmanager->resprints; | 
| 1151 | - } | |
| 1152 | - else | |
| 1204 | + } else | |
| 1153 | 1205 |  		            { | 
| 1154 | 1206 | $this->resprints = $hookmanager->resprints; | 
| 1155 | 1207 | |
| @@ -1164,8 +1216,7 @@ discard block | ||
| 1164 | 1216 | |
| 1165 | 1217 | |
| 1166 | 1218 | } | 
| 1167 | - } | |
| 1168 | -		    elseif (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) | |
| 1219 | +		    } elseif (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) | |
| 1169 | 1220 |  		    { | 
| 1170 | 1221 | $this->resprints = ' '; | 
| 1171 | 1222 | return 1; | 
| @@ -1184,14 +1235,16 @@ discard block | ||
| 1184 | 1235 | |
| 1185 | 1236 |  			if((float)DOL_VERSION<=3.6) { | 
| 1186 | 1237 | return ''; | 
| 1187 | - } | |
| 1188 | -			else if((float)DOL_VERSION>=3.8) { | |
| 1238 | +			} else if((float)DOL_VERSION>=3.8) { | |
| 1189 | 1239 | return 1; | 
| 1190 | 1240 | } | 
| 1191 | 1241 | } | 
| 1192 | 1242 | |
| 1193 | - if(is_array($parameters)) $i = & $parameters['i']; | |
| 1194 | - else $i = (int)$parameters; | |
| 1243 | +		if(is_array($parameters)) { | |
| 1244 | + $i = & $parameters['i']; | |
| 1245 | +		} else { | |
| 1246 | + $i = (int)$parameters; | |
| 1247 | + } | |
| 1195 | 1248 | |
| 1196 | 1249 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) | 
| 1197 | 1250 |  		{ | 
| @@ -1213,14 +1266,16 @@ discard block | ||
| 1213 | 1266 | |
| 1214 | 1267 |  			if((float)DOL_VERSION<=3.6) { | 
| 1215 | 1268 | return ''; | 
| 1216 | - } | |
| 1217 | -			else if((float)DOL_VERSION>=3.8) { | |
| 1269 | +			} else if((float)DOL_VERSION>=3.8) { | |
| 1218 | 1270 | return 1; | 
| 1219 | 1271 | } | 
| 1220 | 1272 | } | 
| 1221 | 1273 | |
| 1222 | - if(is_array($parameters)) $i = & $parameters['i']; | |
| 1223 | - else $i = (int)$parameters; | |
| 1274 | +		if(is_array($parameters)) { | |
| 1275 | + $i = & $parameters['i']; | |
| 1276 | +		} else { | |
| 1277 | + $i = (int)$parameters; | |
| 1278 | + } | |
| 1224 | 1279 | |
| 1225 | 1280 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) | 
| 1226 | 1281 |  		{ | 
| @@ -1242,13 +1297,15 @@ discard block | ||
| 1242 | 1297 | |
| 1243 | 1298 |  			if((float)DOL_VERSION<=3.6) { | 
| 1244 | 1299 | return ''; | 
| 1245 | - } | |
| 1246 | -			else if((float)DOL_VERSION>=3.8) { | |
| 1300 | +			} else if((float)DOL_VERSION>=3.8) { | |
| 1247 | 1301 | return 1; | 
| 1248 | 1302 | } | 
| 1249 | 1303 | } | 
| 1250 | - if(is_array($parameters)) $i = & $parameters['i']; | |
| 1251 | - else $i = (int)$parameters; | |
| 1304 | +		if(is_array($parameters)) { | |
| 1305 | + $i = & $parameters['i']; | |
| 1306 | +		} else { | |
| 1307 | + $i = (int)$parameters; | |
| 1308 | + } | |
| 1252 | 1309 | |
| 1253 | 1310 | if (!empty($hideprices) | 
| 1254 | 1311 | || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) | 
| @@ -1271,14 +1328,16 @@ discard block | ||
| 1271 | 1328 | $this->resprints = ' '; | 
| 1272 | 1329 |  			if((float)DOL_VERSION<=3.6) { | 
| 1273 | 1330 | return ''; | 
| 1274 | - } | |
| 1275 | -			else if((float)DOL_VERSION>=3.8) { | |
| 1331 | +			} else if((float)DOL_VERSION>=3.8) { | |
| 1276 | 1332 | return 1; | 
| 1277 | 1333 | } | 
| 1278 | 1334 | } | 
| 1279 | 1335 | |
| 1280 | - if(is_array($parameters)) $i = & $parameters['i']; | |
| 1281 | - else $i = (int)$parameters; | |
| 1336 | +		if(is_array($parameters)) { | |
| 1337 | + $i = & $parameters['i']; | |
| 1338 | +		} else { | |
| 1339 | + $i = (int)$parameters; | |
| 1340 | + } | |
| 1282 | 1341 | |
| 1283 | 1342 | if (!empty($hideprices) | 
| 1284 | 1343 | || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) | 
| @@ -1302,16 +1361,21 @@ discard block | ||
| 1302 | 1361 | |
| 1303 | 1362 |  			if((float)DOL_VERSION<=3.6) { | 
| 1304 | 1363 | return ''; | 
| 1305 | - } | |
| 1306 | -			else if((float)DOL_VERSION>=3.8) { | |
| 1364 | +			} else if((float)DOL_VERSION>=3.8) { | |
| 1307 | 1365 | return 1; | 
| 1308 | 1366 | } | 
| 1309 | 1367 | } | 
| 1310 | 1368 | |
| 1311 | - if(is_array($parameters)) $i = & $parameters['i']; | |
| 1312 | - else $i = (int)$parameters; | |
| 1369 | +		if(is_array($parameters)) { | |
| 1370 | + $i = & $parameters['i']; | |
| 1371 | +		} else { | |
| 1372 | + $i = (int)$parameters; | |
| 1373 | + } | |
| 1313 | 1374 | |
| 1314 | - if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) | |
| 1375 | +		if (empty($object->lines[$i])) { | |
| 1376 | + return 0; | |
| 1377 | + } | |
| 1378 | + // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) | |
| 1315 | 1379 | |
| 1316 | 1380 | $object->lines[$i]->fetch_optionals(); | 
| 1317 | 1381 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) | 
| @@ -1333,14 +1397,16 @@ discard block | ||
| 1333 | 1397 | $this->resprints = ' '; | 
| 1334 | 1398 |  			if((float)DOL_VERSION<=3.6) { | 
| 1335 | 1399 | return ''; | 
| 1336 | - } | |
| 1337 | -			else if((float)DOL_VERSION>=3.8) { | |
| 1400 | +			} else if((float)DOL_VERSION>=3.8) { | |
| 1338 | 1401 | return 1; | 
| 1339 | 1402 | } | 
| 1340 | 1403 | } | 
| 1341 | 1404 | |
| 1342 | - if(is_array($parameters)) $i = & $parameters['i']; | |
| 1343 | - else $i = (int)$parameters; | |
| 1405 | +		if(is_array($parameters)) { | |
| 1406 | + $i = & $parameters['i']; | |
| 1407 | +		} else { | |
| 1408 | + $i = (int)$parameters; | |
| 1409 | + } | |
| 1344 | 1410 | |
| 1345 | 1411 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) | 
| 1346 | 1412 |  		{ | 
| @@ -1370,7 +1436,9 @@ discard block | ||
| 1370 | 1436 | } | 
| 1371 | 1437 | } | 
| 1372 | 1438 | |
| 1373 | - if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle); | |
| 1439 | +			if (!empty($TLineTitle)) { | |
| 1440 | + $TTitleNumeroted = $this->formatNumerotation($TLineTitle); | |
| 1441 | + } | |
| 1374 | 1442 | } | 
| 1375 | 1443 | |
| 1376 | 1444 | } | 
| @@ -1384,8 +1452,12 @@ discard block | ||
| 1384 | 1452 | $j=0; | 
| 1385 | 1453 | foreach ($TLineTitle as $k => &$line) | 
| 1386 | 1454 |  		{ | 
| 1387 | - if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue; | |
| 1388 | - if (!empty($line_reference) && $line->qty <= $line_reference->qty) break; | |
| 1455 | +			if (!empty($line_reference) && $line->rang <= $line_reference->rang) { | |
| 1456 | + continue; | |
| 1457 | + } | |
| 1458 | +			if (!empty($line_reference) && $line->qty <= $line_reference->qty) { | |
| 1459 | + break; | |
| 1460 | + } | |
| 1389 | 1461 | |
| 1390 | 1462 | if ($line->qty == $level) | 
| 1391 | 1463 |  			{ | 
| @@ -1419,7 +1491,9 @@ discard block | ||
| 1419 | 1491 | |
| 1420 | 1492 |  		$hidedetails = (int)GETPOST('hidedetails'); | 
| 1421 | 1493 | |
| 1422 | - if(empty($hidedetails)) return false; | |
| 1494 | +		if(empty($hidedetails)) { | |
| 1495 | + return false; | |
| 1496 | + } | |
| 1423 | 1497 | |
| 1424 | 1498 | // TODO can't add VAT to document without lines... :-/ | 
| 1425 | 1499 | |
| @@ -1472,7 +1546,9 @@ discard block | ||
| 1472 | 1546 | */ | 
| 1473 | 1547 | list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1); | 
| 1474 | 1548 | |
| 1475 | - if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TTotal_tva; | |
| 1549 | +						if (TSubtotal::getNiveau($line) == 1) { | |
| 1550 | + $line->TTotal_tva = $TTotal_tva; | |
| 1551 | + } | |
| 1476 | 1552 | $line->total_ht = $total; | 
| 1477 | 1553 | $line->total_tva = $total_tva; | 
| 1478 | 1554 | $line->total = $line->total_ht; | 
| @@ -1527,8 +1603,7 @@ discard block | ||
| 1527 | 1603 | } | 
| 1528 | 1604 | |
| 1529 | 1605 | |
| 1530 | - } | |
| 1531 | - elseif ($hidedetails) | |
| 1606 | + } elseif ($hidedetails) | |
| 1532 | 1607 |  				{ | 
| 1533 | 1608 | $TLines[] = $line; //Cas où je cache uniquement les prix des produits | 
| 1534 | 1609 | } | 
| @@ -1599,7 +1674,9 @@ discard block | ||
| 1599 | 1674 | |
| 1600 | 1675 |  				if(!empty($hideprices)) { | 
| 1601 | 1676 |  					foreach($object->lines as &$line) { | 
| 1602 | - if($line->fk_product_type!=9) $line->fk_parent_line = -1; | |
| 1677 | +						if($line->fk_product_type!=9) { | |
| 1678 | + $line->fk_parent_line = -1; | |
| 1679 | + } | |
| 1603 | 1680 | } | 
| 1604 | 1681 | } | 
| 1605 | 1682 | |
| @@ -1620,7 +1697,9 @@ discard block | ||
| 1620 | 1697 | |
| 1621 | 1698 |  				if($line->qty>90) { | 
| 1622 | 1699 | |
| 1623 | - if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) $label .= ' '.$this->getTitle($object, $line); | |
| 1700 | +					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) { | |
| 1701 | + $label .= ' '.$this->getTitle($object, $line); | |
| 1702 | + } | |
| 1624 | 1703 | |
| 1625 | 1704 | $pageBefore = $pdf->getPage(); | 
| 1626 | 1705 | $this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); | 
| @@ -1638,8 +1717,7 @@ discard block | ||
| 1638 | 1717 | |
| 1639 | 1718 | $posy = $pdf->GetY(); | 
| 1640 | 1719 | return 1; | 
| 1641 | - } | |
| 1642 | -				else if ($line->qty < 10) { | |
| 1720 | +				} else if ($line->qty < 10) { | |
| 1643 | 1721 | $pageBefore = $pdf->getPage(); | 
| 1644 | 1722 | |
| 1645 | 1723 | $this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); | 
| @@ -1663,8 +1741,7 @@ discard block | ||
| 1663 | 1741 | // if($line->rowid==47) exit; | 
| 1664 | 1742 | |
| 1665 | 1743 | return 0; | 
| 1666 | - } | |
| 1667 | - elseif (empty($object->lines[$parameters['i']])) | |
| 1744 | + } elseif (empty($object->lines[$parameters['i']])) | |
| 1668 | 1745 |  		{ | 
| 1669 | 1746 | $this->resprints = -1; | 
| 1670 | 1747 | } | 
| @@ -1697,7 +1774,9 @@ discard block | ||
| 1697 | 1774 | |
| 1698 | 1775 | foreach ($object->lines as $line) | 
| 1699 | 1776 |  		{ | 
| 1700 | - if ($line->id == $currentLine->id) break; | |
| 1777 | +			if ($line->id == $currentLine->id) { | |
| 1778 | + break; | |
| 1779 | + } | |
| 1701 | 1780 | |
| 1702 | 1781 | $qty_search = 100 - $currentLine->qty; | 
| 1703 | 1782 | |
| @@ -1734,23 +1813,23 @@ discard block | ||
| 1734 | 1813 |  		{ | 
| 1735 | 1814 | $object->statut = 0; // hack for facture rec | 
| 1736 | 1815 | $createRight = $user->rights->facture->creer; | 
| 1737 | - } | |
| 1738 | - elseif($object->element == 'order_supplier' ) | |
| 1816 | + } elseif($object->element == 'order_supplier' ) | |
| 1739 | 1817 |  		{ | 
| 1740 | 1818 | $createRight = $user->rights->fournisseur->commande->creer; | 
| 1741 | - } | |
| 1742 | - elseif($object->element == 'invoice_supplier' ) | |
| 1819 | + } elseif($object->element == 'invoice_supplier' ) | |
| 1743 | 1820 |  		{ | 
| 1744 | 1821 | $createRight = $user->rights->fournisseur->facture->creer; | 
| 1745 | 1822 | } | 
| 1746 | 1823 | |
| 1747 | 1824 |  		if($line->special_code!=$this->module_number || $line->product_type!=9) { | 
| 1748 | 1825 | null; | 
| 1749 | - } | |
| 1750 | -		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))  | |
| 1826 | +		} 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))  | |
| 1751 | 1827 |          { | 
| 1752 | - if($object->element=='facture')$idvar = 'facid'; | |
| 1753 | - else $idvar='id'; | |
| 1828 | +			if($object->element=='facture') { | |
| 1829 | + $idvar = 'facid'; | |
| 1830 | +			} else { | |
| 1831 | + $idvar='id'; | |
| 1832 | + } | |
| 1754 | 1833 | |
| 1755 | 1834 | if((float)DOL_VERSION <= 3.4) | 
| 1756 | 1835 |  			{ | 
| @@ -1776,20 +1855,44 @@ discard block | ||
| 1776 | 1855 | <?php | 
| 1777 | 1856 | } | 
| 1778 | 1857 | |
| 1779 | - if(empty($line->description)) $line->description = $line->desc; | |
| 1858 | +			if(empty($line->description)) { | |
| 1859 | + $line->description = $line->desc; | |
| 1860 | + } | |
| 1780 | 1861 | |
| 1781 | 1862 | $colspan = 5; | 
| 1782 | - if($object->element == 'facturerec' ) $colspan = 3; | |
| 1783 | - if($object->element == 'order_supplier') $colspan = 3; | |
| 1784 | - if($object->element == 'invoice_supplier') $colspan = 4; | |
| 1785 | - if($object->element == 'supplier_proposal') $colspan = 4; | |
| 1786 | - if(!empty($conf->multicurrency->enabled)) $colspan+=2; | |
| 1787 | - if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++; | |
| 1788 | - if(!empty($conf->margin->enabled)) $colspan++; | |
| 1789 | - if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; | |
| 1790 | - if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; | |
| 1791 | - if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++; | |
| 1792 | - if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++; | |
| 1863 | +			if($object->element == 'facturerec' ) { | |
| 1864 | + $colspan = 3; | |
| 1865 | + } | |
| 1866 | +			if($object->element == 'order_supplier') { | |
| 1867 | + $colspan = 3; | |
| 1868 | + } | |
| 1869 | +			if($object->element == 'invoice_supplier') { | |
| 1870 | + $colspan = 4; | |
| 1871 | + } | |
| 1872 | +			if($object->element == 'supplier_proposal') { | |
| 1873 | + $colspan = 4; | |
| 1874 | + } | |
| 1875 | +			if(!empty($conf->multicurrency->enabled)) { | |
| 1876 | + $colspan+=2; | |
| 1877 | + } | |
| 1878 | +			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) { | |
| 1879 | + $colspan++; | |
| 1880 | + } | |
| 1881 | +			if(!empty($conf->margin->enabled)) { | |
| 1882 | + $colspan++; | |
| 1883 | + } | |
| 1884 | +			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) { | |
| 1885 | + $colspan++; | |
| 1886 | + } | |
| 1887 | +			if(!empty($conf->global->DISPLAY_MARK_RATES)) { | |
| 1888 | + $colspan++; | |
| 1889 | + } | |
| 1890 | +			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) { | |
| 1891 | + $colspan++; | |
| 1892 | + } | |
| 1893 | +			if(!empty($conf->global->PRODUCT_USE_UNITS)) { | |
| 1894 | + $colspan++; | |
| 1895 | + } | |
| 1793 | 1896 | |
| 1794 | 1897 | /* Titre */ | 
| 1795 | 1898 | //var_dump($line); | 
| @@ -1802,23 +1905,36 @@ discard block | ||
| 1802 | 1905 | <tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php | 
| 1803 | 1906 | if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT)) | 
| 1804 | 1907 |  					{ | 
| 1805 | - if($line->qty==99) print 'background:#adadcf'; | |
| 1806 | - else if($line->qty==98) print 'background:#ddddff;'; | |
| 1807 | - else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;'; | |
| 1808 | - else if($line->qty==1) print 'background:#adadcf;'; | |
| 1809 | - else if($line->qty==2) print 'background:#ddddff;'; | |
| 1810 | - else if($line->qty==50) print ''; | |
| 1811 | - else print 'background:#eeeeff;'; | |
| 1908 | +						if($line->qty==99) { | |
| 1909 | + print 'background:#adadcf'; | |
| 1910 | +						} else if($line->qty==98) { | |
| 1911 | + print 'background:#ddddff;'; | |
| 1912 | +						} else if($line->qty<=97 && $line->qty>=91) { | |
| 1913 | + print 'background:#eeeeff;'; | |
| 1914 | +						} else if($line->qty==1) { | |
| 1915 | + print 'background:#adadcf;'; | |
| 1916 | +						} else if($line->qty==2) { | |
| 1917 | + print 'background:#ddddff;'; | |
| 1918 | +						} else if($line->qty==50) { | |
| 1919 | + print ''; | |
| 1920 | +						} else { | |
| 1921 | + print 'background:#eeeeff;'; | |
| 1922 | + } | |
| 1812 | 1923 | |
| 1813 | 1924 | //A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9 | 
| 1814 | - } | |
| 1815 | - else | |
| 1925 | + } else | |
| 1816 | 1926 |  					{ | 
| 1817 | - if($line->qty==99) print 'background:#ddffdd'; | |
| 1818 | - else if($line->qty==98) print 'background:#ddddff;'; | |
| 1819 | - else if($line->qty==2) print 'background:#eeeeff; '; | |
| 1820 | - else if($line->qty==50) print ''; | |
| 1821 | - else print 'background:#eeffee;' ; | |
| 1927 | +						if($line->qty==99) { | |
| 1928 | + print 'background:#ddffdd'; | |
| 1929 | +						} else if($line->qty==98) { | |
| 1930 | + print 'background:#ddddff;'; | |
| 1931 | +						} else if($line->qty==2) { | |
| 1932 | + print 'background:#eeeeff; '; | |
| 1933 | +						} else if($line->qty==50) { | |
| 1934 | + print ''; | |
| 1935 | +						} else { | |
| 1936 | + print 'background:#eeffee;' ; | |
| 1937 | + } | |
| 1822 | 1938 | } | 
| 1823 | 1939 | |
| 1824 | 1940 | ?>;"> | 
| @@ -1841,13 +1957,11 @@ discard block | ||
| 1841 | 1957 | $qty_displayed = $line->qty; | 
| 1842 | 1958 |  							print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span>  '; | 
| 1843 | 1959 | |
| 1844 | - } | |
| 1845 | - else if (TSubtotal::isSubtotal($line)) | |
| 1960 | + } else if (TSubtotal::isSubtotal($line)) | |
| 1846 | 1961 |  						{ | 
| 1847 | 1962 | $qty_displayed = 100 - $line->qty; | 
| 1848 | 1963 |  							print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span>  '; | 
| 1849 | - } | |
| 1850 | - else | |
| 1964 | + } else | |
| 1851 | 1965 |  						{ | 
| 1852 | 1966 | $isFreeText = true; | 
| 1853 | 1967 | } | 
| @@ -1868,9 +1982,13 @@ discard block | ||
| 1868 | 1982 | } | 
| 1869 | 1983 | |
| 1870 | 1984 | $readonlyForSituation = ''; | 
| 1871 | - if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) $readonlyForSituation = 'readonly'; | |
| 1985 | +						if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) { | |
| 1986 | + $readonlyForSituation = 'readonly'; | |
| 1987 | + } | |
| 1872 | 1988 | |
| 1873 | - if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/> '; | |
| 1989 | +						if (!$isFreeText) { | |
| 1990 | + echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/> '; | |
| 1991 | + } | |
| 1874 | 1992 | |
| 1875 | 1993 | if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) ) | 
| 1876 | 1994 |  						{ | 
| @@ -1878,8 +1996,12 @@ discard block | ||
| 1878 | 1996 | for ($j=1; $j<10; $j++) | 
| 1879 | 1997 |  							{ | 
| 1880 | 1998 |  								if (!empty($readonlyForSituation)) { | 
| 1881 | -									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; | |
| 1882 | -								} else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; | |
| 1999 | +									if ($qty_displayed == $j) { | |
| 2000 | +										$select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; | |
| 2001 | + } | |
| 2002 | +								} else { | |
| 2003 | +									$select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; | |
| 2004 | + } | |
| 1883 | 2005 | } | 
| 1884 | 2006 | $select .= '</select> '; | 
| 1885 | 2007 | |
| @@ -1895,15 +2017,18 @@ discard block | ||
| 1895 | 2017 | $form = new Form($db); | 
| 1896 | 2018 |  								echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>'; | 
| 1897 | 2019 | echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>'; | 
| 1898 | -								if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true)); | |
| 2020 | +								if (empty($readonlyForSituation)) { | |
| 2021 | +									echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true)); | |
| 2022 | + } | |
| 1899 | 2023 | echo '</select>  '; | 
| 1900 | 2024 | |
| 1901 | 2025 | if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION) | 
| 1902 | 2026 |  								{ | 
| 1903 | 2027 |  									echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%'; | 
| 1904 | 2028 | } | 
| 2029 | +							} else if ($isFreeText) { | |
| 2030 | + echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation); | |
| 1905 | 2031 | } | 
| 1906 | - else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation); | |
| 1907 | 2032 | echo '</div>'; | 
| 1908 | 2033 | |
| 1909 | 2034 |  						if($line->qty<10) { | 
| @@ -1923,8 +2048,7 @@ discard block | ||
| 1923 | 2048 | $doleditor->Create(); | 
| 1924 | 2049 | } | 
| 1925 | 2050 | |
| 1926 | - } | |
| 1927 | -					else { | |
| 2051 | +					} else { | |
| 1928 | 2052 | |
| 1929 | 2053 | if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) | 
| 1930 | 2054 |  						 { | 
| @@ -1932,14 +2056,19 @@ discard block | ||
| 1932 | 2056 |  							{ | 
| 1933 | 2057 |  								echo str_repeat('   ', $line->qty-1); | 
| 1934 | 2058 | |
| 1935 | -								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>  '; | |
| 1936 | -								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>  '; | |
| 2059 | +								if (TSubtotal::isTitle($line)) { | |
| 2060 | +									print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>  '; | |
| 2061 | +								} else { | |
| 2062 | +									print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>  '; | |
| 2063 | + } | |
| 1937 | 2064 | } | 
| 1938 | - } | |
| 1939 | - else | |
| 2065 | + } else | |
| 1940 | 2066 |  						 { | 
| 1941 | -							if($line->qty<=1) print img_picto('', 'subtotal@subtotal'); | |
| 1942 | -							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'     ';  | |
| 2067 | +							if($line->qty<=1) { | |
| 2068 | +								print img_picto('', 'subtotal@subtotal'); | |
| 2069 | +							} else if($line->qty==2) { | |
| 2070 | +								print img_picto('', 'subsubtotal@subtotal').'     '; | |
| 2071 | + } | |
| 1943 | 2072 | } | 
| 1944 | 2073 | |
| 1945 | 2074 | |
| @@ -1949,21 +2078,26 @@ discard block | ||
| 1949 | 2078 | $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;'; | 
| 1950 | 2079 | |
| 1951 | 2080 |  						 if (empty($line->label)) { | 
| 1952 | - if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print $line->description.' '.$this->getTitle($object, $line); | |
| 1953 | - else print $line->description; | |
| 1954 | - } | |
| 1955 | -						 else { | |
| 2081 | +							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) { | |
| 2082 | + print $line->description.' '.$this->getTitle($object, $line); | |
| 2083 | +							} else { | |
| 2084 | + print $line->description; | |
| 2085 | + } | |
| 2086 | +						 } else { | |
| 1956 | 2087 | |
| 1957 | 2088 |  							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) { | 
| 1958 | 2089 | print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>'; | 
| 1959 | - } | |
| 1960 | -							else{ | |
| 2090 | +							} else{ | |
| 1961 | 2091 | print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>'; | 
| 1962 | 2092 | } | 
| 1963 | 2093 | |
| 1964 | 2094 | } | 
| 1965 | - if($line->qty>90) print ' : '; | |
| 1966 | -						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal'); | |
| 2095 | +						if($line->qty>90) { | |
| 2096 | + print ' : '; | |
| 2097 | + } | |
| 2098 | +						if($line->info_bits > 0) { | |
| 2099 | +							echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal'); | |
| 2100 | + } | |
| 1967 | 2101 | |
| 1968 | 2102 | |
| 1969 | 2103 | |
| @@ -2000,11 +2134,12 @@ discard block | ||
| 2000 | 2134 | </script> | 
| 2001 | 2135 | <?php | 
| 2002 | 2136 | |
| 2003 | - } | |
| 2004 | -					else{ | |
| 2137 | +					} else{ | |
| 2005 | 2138 | if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier') | 
| 2006 | 2139 |  						{ | 
| 2007 | -							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>'; | |
| 2140 | +							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) { | |
| 2141 | +								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>'; | |
| 2142 | + } | |
| 2008 | 2143 | } | 
| 2009 | 2144 | |
| 2010 | 2145 | if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) | 
| @@ -2073,7 +2208,9 @@ discard block | ||
| 2073 | 2208 | $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); | 
| 2074 | 2209 | |
| 2075 | 2210 | $colspan+=3; $mode = 'view'; | 
| 2076 | -				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit'; | |
| 2211 | +				if($action === 'editline' && $line->rowid == GETPOST('lineid')) { | |
| 2212 | + $mode = 'edit'; | |
| 2213 | + } | |
| 2077 | 2214 | |
| 2078 | 2215 | $ex_element = $line->element; | 
| 2079 | 2216 | $line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr | 
| @@ -2255,10 +2392,9 @@ discard block | ||
| 2255 | 2392 | |
| 2256 | 2393 |  	    if(TSubtotal::isTitle($line)){ | 
| 2257 | 2394 | $ThtmlData['data-issubtotal'] = 'title'; | 
| 2258 | -	    }elseif(TSubtotal::isSubtotal($line)){ | |
| 2395 | +	    } elseif(TSubtotal::isSubtotal($line)){ | |
| 2259 | 2396 | $ThtmlData['data-issubtotal'] = 'subtotal'; | 
| 2260 | - } | |
| 2261 | -	    else{ | |
| 2397 | +	    } else{ | |
| 2262 | 2398 | $ThtmlData['data-issubtotal'] = 'freetext'; | 
| 2263 | 2399 | } | 
| 2264 | 2400 | |
| @@ -2268,7 +2404,9 @@ discard block | ||
| 2268 | 2404 | |
| 2269 | 2405 | // hook | 
| 2270 | 2406 |  	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook | 
| 2271 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); | |
| 2407 | +	    if ($reshook < 0) { | |
| 2408 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); | |
| 2409 | + } | |
| 2272 | 2410 | if ($reshook>0) | 
| 2273 | 2411 |  	    { | 
| 2274 | 2412 | $ThtmlData = $hookmanager->resArray; |