| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | class ActionsSubtotal | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | 	function __construct($db) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | 		global $langs; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | 		$this->db = $db; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | 		$langs->load('subtotal@subtotal'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | 		$this->allow_move_block_lines = true; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 	function createDictionaryFieldlist($parameters, &$object, &$action, $hookmanager) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 		global $conf; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 		if ($parameters['tabname'] == MAIN_DB_PREFIX.'c_subtotal_free_text') | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 			// Merci Dolibarr de remplacer les textarea par un input text | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 			if ((float) DOL_VERSION >= 6.0) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 				$value = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 				$sql = 'SELECT content FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text WHERE rowid = '.GETPOST('rowid'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 				$resql = $this->db->query($sql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 				if ($resql && ($obj = $this->db->fetch_object($resql))) $value = $obj->content; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 			?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 			<script type="text/javascript"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 				$(function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 					<?php if ((float) DOL_VERSION >= 6.0) { ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 							if ($('input[name=content]').length > 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 							{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 								$('input[name=content]').each(function(i,item) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 									var value = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 									// Le dernier item correspond à l'édition | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 									if (i == $('input[name=content]').length) value = <?php echo json_encode($value); ?>; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 									$(item).replaceWith($('<textarea name="content">'+value+'</textarea>')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 								}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 								 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 								<?php if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 								$('textarea[name=content]').each(function(i, item) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 									CKEDITOR.replace(item, { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 										toolbar: 'dolibarr_notes' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 										,customConfig : ckeditorConfig | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 									}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 								}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 								<?php } ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 					<?php } else { ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 						// <= 5.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 						// Le CKEditor est forcé sur la page dictionnaire, pas possible de mettre une valeur custom | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 						// petit js qui supprimer le wysiwyg et affiche le textarea car avant la version 6.0 le wysiwyg sur une page de dictionnaire est inexploitable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 						<?php if (!empty($conf->fckeditor->enabled)) { ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 							CKEDITOR.on('instanceReady', function(ev) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 								var editor = ev.editor; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 								if (editor.name == 'content') // Mon champ en bdd s'appel "content", pas le choix si je veux avoir un textarea sur une page de dictionnaire | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 								{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 									editor.element.show(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 									editor.destroy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 								} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 							}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 						<?php } ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 					<?php } ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 				}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 			</script> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 			<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 	/** Overloading the doActions function : replacing the parent's function with the one below | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 	 * @param      $parameters  array           meta datas of the hook (context, etc...) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 	 * @param      $object      CommonObject    the object you want to process (an invoice if you are in invoice module, a propale in propale's module, etc...) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 	 * @param      $action      string          current action (if set). Generally create or edit or null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 	 * @param      $hookmanager HookManager     current hook manager | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 	 * @return     void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     var $module_number = 104777; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     function formObjectOptions($parameters, &$object, &$action, $hookmanager)  | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |       	global $langs,$db,$user, $conf; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 		$langs->load('subtotal@subtotal'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 		$contexts = explode(':',$parameters['context']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 		if(in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('invoicereccard',$contexts)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 			$createRight = $user->rights->{$object->element}->creer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 			if($object->element == 'facturerec' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 				$object->statut = 0; // hack for facture rec | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 				$createRight = $user->rights->facture->creer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 			} elseif($object->element == 'order_supplier' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 			    $createRight = $user->rights->fournisseur->commande->creer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 			} elseif($object->element == 'invoice_supplier' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 			    $createRight = $user->rights->fournisseur->facture->creer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 			if ($object->statut == 0  && $createRight) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 				if($object->element=='facture')$idvar = 'facid'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 				else $idvar='id'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 					$level = GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 					if($action=='add_title_line') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 						$title = GETPOST('title'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 						if(empty($title)) $title = $langs->trans('title'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 						$qty = $level<1 ? 1 : $level ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 					else if($action=='add_free_text') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 						$title = GETPOST('title'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 						if (empty($title)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 							$free_text = GETPOST('free_text', 'int'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 							if (!empty($free_text)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 								$TFreeText = getTFreeText(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 								if (!empty($TFreeText[$free_text])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 									$title = $TFreeText[$free_text]->content; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 								} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 						$qty = 50; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 					else if($action=='add_subtitle_line') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 						$title = GETPOST('title'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 						if(empty($title)) $title = $langs->trans('subtitle'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 						$qty = 2; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 					else if($action=='add_subtotal_line') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 						$title = $langs->trans('SubSubTotal'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 						$qty = 98; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 					else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 						$qty = $level ? 100-$level : 99; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 					dol_include_once('/subtotal/class/subtotal.class.php'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 	    			TSubtotal::addSubTotalLine($object, $title, $qty); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 				else if($action==='ask_deleteallline') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 						$form=new Form($db); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 						 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 						$lineid = GETPOST('lineid','integer'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 						$TIdForGroup = $this->getArrayOfLineForAGroup($object, $lineid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | 						$nbLines = count($TIdForGroup); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 						$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines',$nbLines), 'confirm_delete_all_lines','',0,1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 						print $formconfirm; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 				if (!empty($conf->global->SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  | 					$this->showSelectTitleToAdd($object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 				if($action!='editline') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 					// New format is for 3.8 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 					$this->printNewFormat($object, $conf, $langs, $idvar); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  | 		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 			?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 			<script type="text/javascript"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 				$(function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  | 					var tr = $("<tr><td><?php echo $langs->trans('subtotal_add_title_bloc_from_orderstoinvoice'); ?></td><td><input type='checkbox' value='1' name='subtotal_add_title_bloc_from_orderstoinvoice' checked='checked' /></td></tr>") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 					$("textarea[name=note]").closest('tr').after(tr); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  | 				}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 			</script> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 			<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | 		return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |       | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | 	function printNewFormat(&$object, &$conf, &$langs, $idvar) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 		?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  | 		 	<script type="text/javascript"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 				$(document).ready(function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 					$('div.fiche div.tabsAction').append('<br />'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  | 					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_title_line" rel="add_title_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddTitle' )?></a></div>'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  | 					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_total_line" rel="add_total_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddSubTotal')?></a></div>'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_free_text" rel="add_free_text" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddFreeText')?></a></div>'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  | 					function updateAllMessageForms(){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  | 				         for (instance in CKEDITOR.instances) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  | 				             CKEDITOR.instances[instance].updateElement(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  | 				         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 				    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 					function promptSubTotal(action, titleDialog, label, url_to, url_ajax, params, use_textarea, show_free_text, show_under_title) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 					     $( "#dialog-prompt-subtotal" ).remove(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  | 						  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  | 						 var dialog_html = '<div id="dialog-prompt-subtotal" '+(action == 'addSubtotal' ? 'class="center"' : '')+' >'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  | 						  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  | 						 if (typeof show_under_title != 'undefined' && show_under_title) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 						 { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 							 var selectUnderTitle = <?php echo json_encode(getHtmlSelectTitle($object, true)); ?>; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  | 							 dialog_html += selectUnderTitle + '<br /><br />'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 						 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  | 						 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  | 						if (action == 'addTitle' || action == 'addFreeTxt') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  | 							if (typeof show_free_text != 'undefined' && show_free_text) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  | 							{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  | 							   var selectFreeText = <?php echo json_encode(getHtmlSelectFreeText()); ?>; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  | 							   dialog_html += selectFreeText + ' <?php echo $langs->transnoentities('subtotalFreeTextOrDesc'); ?><br />'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  | 						  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  | 							if (typeof use_textarea != 'undefined' && use_textarea) dialog_html += '<textarea id="sub-total-title" rows="<?php echo ROWS_8; ?>" cols="80" placeholder="'+label+'"></textarea>'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  | 							else dialog_html += '<input id="sub-total-title" size="30" value="" placeholder="'+label+'" />'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  | 						  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  | 						if (action == 'addTitle' || action == 'addSubtotal') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  | 							if (action == 'addSubtotal') dialog_html += '<input id="sub-total-title" size="30" value="" placeholder="'+label+'" />'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  | 							 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  | 							dialog_html += " <select name='subtotal_line_level'>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  | 							for (var i=1;i<10;i++) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  | 							{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  | 								dialog_html += "<option value="+i+"><?php echo $langs->trans('Level'); ?> "+i+"</option>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  | 							dialog_html += "</select>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 						  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  | 						 dialog_html += '</div>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  | 					     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  | 						$('body').append(dialog_html); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  | 						<?php  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME)?'ckeditor':$conf->global->FCKEDITOR_EDITORNAME; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  | 						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?false:$conf->global->FCKEDITOR_ENABLE_DETAILS; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 						if($editorConf && in_array($editorTool,array('textarea','ckeditor'))){  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | 						?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  | 						if (action == 'addTitle' || action == 'addFreeTxt') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  | 							if (typeof use_textarea != 'undefined' && use_textarea && typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined" ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 							{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | 								 CKEDITOR.replace( 'sub-total-title', {toolbar: 'dolibarr_details', toolbarStartupExpanded: false} ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 						<?php } ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  | 						 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 					     $( "#dialog-prompt-subtotal" ).dialog({ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  | 	                        resizable: false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | 							height: 'auto', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  | 							width: 'auto', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 	                        modal: true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | 	                        title: titleDialog, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  | 	                        buttons: { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 	                            "Ok": function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  | 	                            	if (typeof use_textarea != 'undefined' && use_textarea && typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined" ){ updateAllMessageForms(); } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  | 									params.title = params.title = (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined" && "sub-total-title" in CKEDITOR.instances ? CKEDITOR.instances["sub-total-title"].getData() : $(this).find('#sub-total-title').val()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 									params.under_title = $(this).find('select[name=under_title]').val(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  | 									params.free_text = $(this).find('select[name=free_text]').val(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  | 									params.level = $(this).find('select[name=subtotal_line_level]').val(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 									 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 									$.ajax({ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  | 										url: url_ajax | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 										,type: 'POST' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | 										,data: params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 									}).done(function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | 										document.location.href=url_to; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  | 									}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 									 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |                                     $( this ).dialog( "close" ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 	                            }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | 	                            "<?php echo $langs->trans('Cancel') ?>": function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  | 	                                $( this ).dialog( "close" ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 	                            } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 	                        } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | 	                     }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 					$('a[rel=add_title_line]').click(function()  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  | 					{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | 						promptSubTotal('addTitle' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 							 , "<?php echo $langs->trans('YourTitleLabel') ?>" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  | 							 , "<?php echo $langs->trans('title'); ?>" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | 							 , '?<?php echo $idvar ?>=<?php echo $object->id; ?>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | 							 , '<?php echo $_SERVER['PHP_SELF']; ?>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  | 							 , {<?php echo $idvar; ?>: <?php echo (int) $object->id; ?>, action:'add_title_line'} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  | 						); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  | 					}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  | 					$('a[rel=add_total_line]').click(function() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  | 					{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  | 						promptSubTotal('addSubtotal' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | 							, '<?php echo $langs->trans('YourSubtotalLabel') ?>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  | 							, '<?php echo $langs->trans('subtotal'); ?>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  | 							, '?<?php echo $idvar ?>=<?php echo $object->id; ?>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | 							, '<?php echo $_SERVER['PHP_SELF']; ?>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  | 							, {<?php echo $idvar; ?>: <?php echo (int) $object->id; ?>, action:'add_total_line'} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  | 							/*,false,false, <?php echo !empty($conf->global->SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE) ? 'true' : 'false'; ?>*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  | 						); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | 					}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  | 					$('a[rel=add_free_text]').click(function()  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 					{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | 						promptSubTotal('addFreeTxt' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  | 							, "<?php echo $langs->transnoentitiesnoconv('YourTextLabel') ?>" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | 							, "<?php echo $langs->trans('subtotalAddLineDescription'); ?>" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  | 							, '?<?php echo $idvar ?>=<?php echo $object->id; ?>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  | 							, '<?php echo $_SERVER['PHP_SELF']; ?>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 							, {<?php echo $idvar; ?>: <?php echo (int) $object->id; ?>, action:'add_free_text'} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  | 							, true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  | 							, true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  | 							, <?php echo !empty($conf->global->SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE) ? 'true' : 'false'; ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  | 						); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  | 					}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  | 				}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  | 		 	</script> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  | 		 <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  | 	}	  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  | 	  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  | 	function showSelectTitleToAdd(&$object) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  | 		global $langs; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  | 		dol_include_once('/subtotal/class/subtotal.class.php'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  | 		dol_include_once('/subtotal/lib/subtotal.lib.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  | 		$TTitle = TSubtotal::getAllTitleFromDocument($object); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  | 		?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  | 		<script type="text/javascript"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  | 			$(function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  | 				var add_button = $("#addline"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  | 				if (add_button.length > 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  | 					add_button.closest('tr').prev('tr.liste_titre').children('td:last').addClass('center').text("<?php echo $langs->trans('subtotal_title_to_add_under_title'); ?>"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  | 					var select_title = $(<?php echo json_encode(getHtmlSelectTitle($object)); ?>); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  | 					add_button.before(select_title); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  | 			}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  | 		</script> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  | 		<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  | 	function formBuilddocOptions($parameters) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  | 	/* Réponse besoin client */		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  | 		global $conf, $langs, $bc; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  | 		$action = GETPOST('action');	 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  | 		$TContext = explode(':',$parameters['context']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  | 		if ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  | 				in_array('invoicecard',$TContext) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  | 		        || in_array('invoicesuppliercard',$TContext) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  | 				|| in_array('propalcard',$TContext) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  | 				|| in_array('ordercard',$TContext) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  | 		        || in_array('ordersuppliercard',$TContext) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  | 				|| in_array('invoicereccard',$TContext) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  | 	        {	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  | 				$hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  | 				$hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  | 				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  | 				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : $hidepricesDefaultConf; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  | 				$var=false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  | 		     	$out.= '<tr '.$bc[$var].'> | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  | 		     			<td colspan="4" align="right"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  | 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  | 		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  | 		     			</td> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  | 		     			</tr>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  | 		     	$var=!$var; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | 		     	$out.= '<tr '.$bc[$var].'> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  | 		     			<td colspan="4" align="right"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  | 		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 		     			</td> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  | 		     			</tr>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  | 		     	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 		     	$var=!$var; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  | 		     	$out.= '<tr '.$bc[$var].'> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  | 		     			<td colspan="4" align="right"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidePrice').'</label> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | 		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  | 		     			</td> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 		     			</tr>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | 		     	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | 		     	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 				  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 				if (  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  | 					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  | 					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  | 				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | 					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  | 				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | 					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP )) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  | 				) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  | 					$var=!$var; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  | 					$out.= ' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  | 						<tr '.$bc[$var].'> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | 							<td colspan="4" align="right"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | 								<label for="subtotal_add_recap">'.$langs->trans('subtotal_add_recap').'</label> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  | 								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.( GETPOST('subtotal_add_recap') ? 'checked="checked"' : '' ).' /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | 							</td> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  | 						</tr>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  | 				$this->resprints = $out;	 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |         return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  | 	}  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  | 	  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |     function formEditProductOptions($parameters, &$object, &$action, $hookmanager)  | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |     	if (in_array('invoicecard',explode(':',$parameters['context']))) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |         	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |         return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  | 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  | 		global $conf; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  | 		if($action === 'builddoc') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  | 			$line = &$parameters['line']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  | 			$object = &$parameters['object']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  | 			$substitutionarray = &$parameters['substitutionarray']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  | 			if($line->product_type == 9 && $line->special_code == $this->module_number) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  | 				$substitutionarray['line_modsubtotal'] = 1;	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  | 				$substitutionarray['line_price_ht'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  | 					 = $substitutionarray['line_price_vat']  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  | 					 = $substitutionarray['line_price_ttc'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  | 					 = $substitutionarray['line_vatrate'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  | 					 = $substitutionarray['line_qty'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  | 					 = $substitutionarray['line_up']  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  | 					 = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  | 				if($line->qty>90) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  | 					$substitutionarray['line_modsubtotal_total'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  | 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  | 					$substitutionarray['line_price_ht'] = $total; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  | 					$substitutionarray['line_price_vat'] = $total_tva; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  | 					$substitutionarray['line_price_ttc'] = $total_ttc; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  | 					$substitutionarray['line_modsubtotal_title'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  | 			}	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  | 			else{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  | 				$substitutionarray['line_not_modsubtotal'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  | 				$substitutionarray['line_modsubtotal'] = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  | 	function createFrom($parameters, &$object, $action, $hookmanager) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  | 		if ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  | 				in_array('invoicecard',explode(':',$parameters['context'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  | 		        || in_array('invoicesuppliercard',explode(':',$parameters['context'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  | 				|| in_array('propalcard',explode(':',$parameters['context'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  | 		        || in_array('supplier_proposalcard',explode(':',$parameters['context'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  | 				|| in_array('ordercard',explode(':',$parameters['context'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  | 		        || in_array('ordersuppliercard',explode(':',$parameters['context'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  | 				|| in_array('invoicereccard',explode(':',$parameters['context'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  | 		) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  | 			global $db; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  | 			$objFrom = $parameters['objFrom']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  | 			foreach($objFrom->lines as $k=> &$lineOld) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  | 					if($lineOld->product_type == 9 && $lineOld->info_bits > 0 ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  | 							 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  | 							$line = & $object->lines[$k]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  | 							$idLine = (int) ($line->id ? $line->id : $line->rowid);  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  | 							$db->query("UPDATE ".MAIN_DB_PREFIX.$line->table_element." | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  | 							SET info_bits=".(int)$lineOld->info_bits." | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  | 							WHERE rowid = ".$idLine." | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  | 							"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  | 						 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  | 	function doActions($parameters, &$object, $action, $hookmanager) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  | 		global $db, $conf, $langs,$user; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  | 		dol_include_once('/subtotal/class/subtotal.class.php'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  | 		dol_include_once('/subtotal/lib/subtotal.lib.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  | 		require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  | 		$showBlockExtrafields = GETPOST('showBlockExtrafields'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  | 		if($object->element=='facture') $idvar = 'facid'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  | 		else $idvar = 'id'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  | 		if ($action == 'updateligne' || $action == 'updateline') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  | 			$found = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  | 			$lineid = GETPOST('lineid', 'int'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  | 			foreach ($object->lines as &$line) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  | 				if ($line->id == $lineid && TSubtotal::isModSubtotalLine($line)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  | 					$found = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  | 					if(TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  | 						$extrafieldsline = new ExtraFields($db); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  | 						$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  | 						$extrafieldsline->setOptionalsFromPost($extralabelsline, $line); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  | 					_updateSubtotalLine($object, $line); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  | 					_updateSubtotalBloc($object, $line); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  | 					TSubtotal::generateDoc($object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  | 					break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  | 			if ($found) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  | 				header('Location: '.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  | 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  | 		else if($action === 'builddoc') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  | 			if ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  | 				in_array('invoicecard',explode(':',$parameters['context'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  | 				|| in_array('propalcard',explode(':',$parameters['context'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  | 				|| in_array('ordercard',explode(':',$parameters['context'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  | 			    || in_array('ordersuppliercard',explode(':',$parameters['context'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  | 			    || in_array('invoicesuppliercard',explode(':',$parameters['context'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  | 			    || in_array('supplier_proposalcard',explode(':',$parameters['context'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  | 	        {								 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  | 				if(in_array('invoicecard',explode(':',$parameters['context']))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  | 					$sessname = 'subtotal_hideInnerLines_facture';	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  | 					$sessname2 = 'subtotal_hidedetails_facture'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  | 					$sessname3 = 'subtotal_hideprices_facture'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  | 				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  | 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  | 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  | 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  | 				elseif(in_array('propalcard',explode(':',$parameters['context']))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  | 					$sessname = 'subtotal_hideInnerLines_propal'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  | 					$sessname2 = 'subtotal_hidedetails_propal';	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  | 					$sessname3 = 'subtotal_hideprices_propal'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  | 				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  | 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  | 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  | 				    $sessname3 = 'subtotal_hideprices_supplier_proposal'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  | 				elseif(in_array('ordercard',explode(':',$parameters['context']))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  | 					$sessname = 'subtotal_hideInnerLines_commande'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  | 					$sessname2 = 'subtotal_hidedetails_commande';	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  | 					$sessname3 = 'subtotal_hideprices_commande'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  | 				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  | 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  | 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  | 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  | 				else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  | 					$sessname = 'subtotal_hideInnerLines_unknown'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  | 					$sessname2 = 'subtotal_hidedetails_unknown'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  | 					$sessname3 = 'subtotal_hideprices_unknown'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  | 				global $hideprices; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  | 				$hideInnerLines = (int)GETPOST('hideInnerLines'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  | 				$_SESSION[$sessname] = $hideInnerLines;		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  | 				$hidedetails= (int)GETPOST('hidedetails'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  | 				$_SESSION[$sessname2] = $hidedetails; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  | 				$hideprices= (int)GETPOST('hideprices'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  | 				$_SESSION[$sessname3] = $hideprices; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  | 				foreach($object->lines as &$line) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  | 					if ($line->product_type == 9 && $line->special_code == $this->module_number) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  | 					     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  |                         if($line->qty>=90) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  |                             $line->modsubtotal_total = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  |                         else{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  |                             $line->modsubtotal_title = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  |                          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  | 						$line->total_ht = $this->getTotalLineFromObject($object, $line, ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  | 	        	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  | 	        } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  | 		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  | 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  | 			foreach($Tab as $idLine) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  | 				/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  | 				 * @var $object Facture | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  | 				 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  | 				if($object->element=='facture') $object->deleteline($idLine); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  | 				/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  | 				 * @var $object Facture fournisseur | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  | 				 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  | 				else if($object->element=='invoice_supplier') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  | 				    $object->deleteline($idLine); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  | 				/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  | 				 * @var $object Propal | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  | 				 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  | 				else if($object->element=='propal') $object->deleteline($idLine); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  | 				/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  | 				 * @var $object Propal Fournisseur | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  | 				 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  | 				else if($object->element=='supplier_proposal') $object->deleteline($idLine); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 |  |  | 				/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  | 				 * @var $object Commande | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  | 				 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  | 				else if($object->element=='commande')  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  | 					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  | 					else $object->deleteline($idLine); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  | 				/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  | 				 * @var $object Commande fournisseur | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  | 				 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  | 				else if($object->element=='order_supplier') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  | 				    $object->deleteline($idLine); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  | 				/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  | 				 * @var $object Facturerec | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  | 				 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  | 				else if($object->element=='facturerec') $object->deleteline($idLine); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  | 			header('location:?id='.$object->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  | 			exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  | 		else if ($action == 'duplicate') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  | 			$lineid = GETPOST('lineid', 'int'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  | 			$nbDuplicate = TSubtotal::duplicateLines($object, $lineid, true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 709 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 710 |  |  | 			header('Location: ?id='.$object->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 711 |  |  | 			exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 712 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 713 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 714 |  |  | 		return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 715 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 716 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 717 |  |  | 	function formAddObjectLine ($parameters, &$object, &$action, $hookmanager) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 718 |  |  | 		return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 719 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 720 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 721 |  |  | 	function getArrayOfLineForAGroup(&$object, $lineid) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 722 |  |  | 		$rang = $line->rang; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 723 |  |  | 		$qty_line = $line->qty; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 724 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 725 |  |  | 		$qty_line = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 726 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 727 |  |  | 		$found = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 728 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 729 |  |  | 		$Tab= array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 730 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 731 |  |  | 		foreach($object->lines as $l) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 732 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 733 |  |  | 		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 734 |  |  | 			if($lid == $lineid) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 735 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 736 |  |  | 				$found = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 737 |  |  | 				$qty_line = $l->qty; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 738 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 739 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 740 |  |  | 			if($found) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 741 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 742 |  |  | 			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 743 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 744 |  |  | 				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 745 |  |  | 					break; // end of story | 
            
                                                                                                            
                            
            
                                    
            
            
                | 746 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 747 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 748 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 749 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 750 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 751 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 752 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 753 |  |  | 		return $Tab; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 754 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 755 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 756 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 757 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 758 |  |  | 	 *  TODO le calcul est faux dans certains cas,  exemple : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 759 |  |  | 	 *	T1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 760 |  |  | 	 *		|_ l1 => 50 € | 
            
                                                                                                            
                            
            
                                    
            
            
                | 761 |  |  | 	 *		|_ l2 => 40 € | 
            
                                                                                                            
                            
            
                                    
            
            
                | 762 |  |  | 	 *		|_ T2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 763 |  |  | 	 *			|_l3 => 100 € | 
            
                                                                                                            
                            
            
                                    
            
            
                | 764 |  |  | 	 *		|_ ST2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 765 |  |  | 	 *		|_ l4 => 23 € | 
            
                                                                                                            
                            
            
                                    
            
            
                | 766 |  |  | 	 *	|_ ST1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 767 |  |  | 	 *  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 768 |  |  | 	 * On obtiens ST2 = 100 ET ST1 = 123 € | 
            
                                                                                                            
                            
            
                                    
            
            
                | 769 |  |  | 	 * Alors qu'on devrais avoir ST2 = 100 ET ST1 = 213 € | 
            
                                                                                                            
                            
            
                                    
            
            
                | 770 |  |  | 	 *  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 771 |  |  | 	 * @param	$use_level		isn't used anymore | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 772 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 773 |  |  | 	function getTotalLineFromObject(&$object, &$line, $use_level=false, $return_all=0) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 774 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 775 |  |  | 		$rang = $line->rang; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 776 |  |  | 		$qty_line = $line->qty; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 777 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 778 |  |  | 		$total = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 779 |  |  | 		$total_tva = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 780 |  |  | 		$total_ttc = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 781 |  |  | 		$TTotal_tva = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 782 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 783 |  |  | 		dol_include_once('/subtotal/class/subtotal.class.php'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 784 |  |  | 		foreach($object->lines as $l) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 785 |  |  | 			//print $l->rang.'>='.$rang.' '.$total.'<br/>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 786 |  |  | 			if($l->rang>=$rang) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 787 |  |  | 				//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))  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 792 |  |  | 		  	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 793 |  |  | 				$total = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 794 |  |  | 				$total_tva = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 795 |  |  | 				$total_ttc = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 796 |  |  | 				$TTotal_tva = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 797 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 798 |  |  | 			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 799 |  |  | 				$total += $l->total_ht; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 800 |  |  | 				$total_tva += $l->total_tva; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 801 |  |  | 				$TTotal_tva[$l->tva_tx] += $l->total_tva; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 802 |  |  | 				$total_ttc += $l->total_ttc; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 803 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 804 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 805 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 806 |  |  | 		if (!$return_all) return $total; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 807 |  |  | 		else return array($total, $total_tva, $total_ttc, $TTotal_tva); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 808 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 809 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 810 |  |  | 	/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 811 |  |  | 	 * Get the sum of situation invoice for last column | 
            
                                                                                                            
                            
            
                                    
            
            
                | 812 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 813 |  |  | 	function getTotalToPrintSituation(&$object, &$line) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 814 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 815 |  |  | 		$rang = $line->rang; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 816 |  |  | 		$total = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 817 |  |  | 		foreach($object->lines as $l) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 818 |  |  | 			if($l->rang>=$rang) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 819 |  |  | 				return price($total); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 820 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 821 |  |  |                         if (TSubtotal::isSubtotal($l)){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 822 |  |  |                             $total = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 823 |  |  |                         } else  if ($l->situation_percent > 0 ){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 824 |  |  |                             | 
            
                                                                                                            
                            
            
                                    
            
            
                | 825 |  |  |         	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 826 |  |  | 		 	$prev_progress = $l->get_prev_progress($object->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 827 |  |  | 		 	$progress = ($l->situation_percent - $prev_progress) /100; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 828 |  |  |                         $total += ($l->total_ht/($l->situation_percent/100)) * $progress; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 829 |  |  |                          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 830 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 831 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 832 |  |  |                  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 833 |  |  | 		return price($total); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 834 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 835 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 836 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 837 |  |  | 	 * @param $pdf          TCPDF               PDF object | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 838 |  |  | 	 * @param $object       CommonObject        dolibarr object | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 839 |  |  | 	 * @param $line         CommonObjectLine    dolibarr object line | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 840 |  |  | 	 * @param $label        string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 841 |  |  | 	 * @param $description  string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 842 |  |  | 	 * @param $posx         float               horizontal position | 
            
                                                                                                            
                            
            
                                    
            
            
                | 843 |  |  | 	 * @param $posy         float               vertical position | 
            
                                                                                                            
                            
            
                                    
            
            
                | 844 |  |  | 	 * @param $w            float               width | 
            
                                                                                                            
                            
            
                                    
            
            
                | 845 |  |  | 	 * @param $h            float               height | 
            
                                                                                                            
                            
            
                                    
            
            
                | 846 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 847 |  |  | 	function pdf_add_total(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 848 |  |  | 		global $conf,$subtotal_last_title_posy; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 849 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 850 |  |  | 		$hideInnerLines = (int)GETPOST('hideInnerLines'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 851 |  |  | 		if (!empty($conf->global->SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES) && $hideInnerLines && !empty($subtotal_last_title_posy)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 852 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 853 |  |  | 			$posy = $subtotal_last_title_posy; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 854 |  |  | 			$subtotal_last_title_posy = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 855 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 856 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 857 |  |  | 		$hidePriceOnSubtotalLines = (int) GETPOST('hide_price_on_subtotal_lines'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 858 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 859 |  |  | 		$set_pagebreak_margin = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 860 |  |  | 		if(method_exists('Closure','bind')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 861 |  |  | 			$pageBreakOriginalValue = $pdf->AcceptPageBreak(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 862 |  |  | 			$sweetsThief = function ($pdf) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 863 |  |  | 		    		return $pdf->bMargin ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 864 |  |  | 			}; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 865 |  |  | 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 866 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 867 |  |  | 			$bMargin  = $sweetsThief($pdf); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 868 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 869 |  |  | 			$pdf->SetAutoPageBreak( false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 870 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 871 |  |  | 			$set_pagebreak_margin = true;			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 872 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 873 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 874 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 881 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 882 |  |  | 		$style = 'B'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 883 |  |  | 		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 884 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 885 |  |  | 		$pdf->SetFont('', $style, 9); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 886 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 887 |  |  | 		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R',true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 888 |  |  | //		var_dump($bMargin); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 889 |  |  | 		$pageAfter = $pdf->getPage(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 890 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 891 |  |  | 		//Print background | 
            
                                                                                                            
                            
            
                                    
            
            
                | 892 |  |  | 		$cell_height = $pdf->getStringHeight($w, $label); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 893 |  |  | 		$pdf->SetXY($posx, $posy); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 894 |  |  | 		$pdf->MultiCell($pdf->page_largeur - $pdf->marge_droite, $cell_height, '', 0, '', 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 895 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 896 |  |  | 		if (!$hidePriceOnSubtotalLines) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 897 |  |  | 			$total_to_print = price($line->total); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 898 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 899 |  |  | 			if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 900 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 901 |  |  | 				$TTitle = TSubtotal::getAllTitleFromLine($line); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 902 |  |  | 				foreach ($TTitle as &$line_title) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 903 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 904 |  |  | 					if (!empty($line_title->array_options['options_subtotal_nc'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 905 |  |  | 					{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 906 |  |  | 						$total_to_print = ''; // TODO Gestion "Compris/Non compris", voir si on affiche une annotation du genre "NC" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 907 |  |  | 						break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 908 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 909 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 910 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 911 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 912 |  |  | 			if($total_to_print) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 913 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 914 |  |  | 				if (GETPOST('hideInnerLines')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 915 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 916 |  |  | 					// Dans le cas des lignes cachés, le calcul est déjà fait dans la méthode beforePDFCreation et les lignes de sous-totaux sont déjà renseignés | 
            
                                                                                                            
                            
            
                                    
            
            
                | 917 |  |  | //					$line->TTotal_tva | 
            
                                                                                                            
                            
            
                                    
            
            
                | 918 |  |  | //					$line->total_ht | 
            
                                                                                                            
                            
            
                                    
            
            
                | 919 |  |  | //					$line->total_tva | 
            
                                                                                                            
                            
            
                                    
            
            
                | 920 |  |  | //					$line->total | 
            
                                                                                                            
                            
            
                                    
            
            
                | 921 |  |  | //					$line->total_ttc | 
            
                                                                                                            
                            
            
                                    
            
            
                | 922 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 923 |  |  | 				else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 924 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 925 |  |  | 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 926 |  |  |                                         if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 927 |  |  |                                                 $total_to_print = $this->getTotalToPrintSituation($object, $line); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 928 |  |  |                                         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 929 |  |  |                                             	$total_to_print = price($total); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 930 |  |  |                                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 931 |  |  |                                              | 
            
                                                                                                            
                            
            
                                    
            
            
                | 932 |  |  | 					$line->total_ht = $total; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 933 |  |  | 					$line->total = $total; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 934 |  |  | 					$line->total_tva = $total_tva; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 935 |  |  | 					$line->total_ttc = $total_ttc; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 936 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 937 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 938 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 939 |  |  | 			$pdf->SetXY($pdf->postotalht, $posy); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 940 |  |  | 			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 941 |  |  | 			$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); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 945 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 946 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 947 |  |  | 		$posy = $posy + $cell_height; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 948 |  |  | 		$pdf->SetXY($posx, $posy);  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 949 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 950 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 951 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 952 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 953 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 954 |  |  | 	 * @param $pdf          TCPDF               PDF object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 955 |  |  | 	 * @param $object       CommonObject        dolibarr object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 956 |  |  | 	 * @param $line         CommonObjectLine    dolibarr object line | 
            
                                                                                                            
                            
            
                                    
            
            
                | 957 |  |  | 	 * @param $label        string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 958 |  |  | 	 * @param $description  string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 959 |  |  | 	 * @param $posx         float               horizontal position | 
            
                                                                                                            
                            
            
                                    
            
            
                | 960 |  |  | 	 * @param $posy         float               vertical position | 
            
                                                                                                            
                            
            
                                    
            
            
                | 961 |  |  | 	 * @param $w            float               width | 
            
                                                                                                            
                            
            
                                    
            
            
                | 962 |  |  | 	 * @param $h            float               height | 
            
                                                                                                            
                            
            
                                    
            
            
                | 963 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 964 |  |  | 	function pdf_add_title(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 965 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 966 |  |  | 		global $db,$conf,$subtotal_last_title_posy; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 967 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 968 |  |  | 		$subtotal_last_title_posy = $posy; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 969 |  |  | 		$pdf->SetXY ($posx, $posy); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 970 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 971 |  |  | 		$hideInnerLines = (int)GETPOST('hideInnerLines'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 972 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 973 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 974 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 975 |  |  | 		$style = ($line->qty==1) ? 'BU' : 'BUI'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 976 |  |  | 		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 977 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 978 |  |  | 		if($hideInnerLines) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 979 |  |  | 			if($line->qty==1)$pdf->SetFont('', $style, 9); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 980 |  |  | 			else  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 981 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 982 |  |  | 				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 983 |  |  | 				$pdf->SetFont('', $style, 9); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 984 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 985 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 986 |  |  | 		else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 987 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 988 |  |  | 			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile | 
            
                                                                                                            
                            
            
                                    
            
            
                | 989 |  |  | 			else $pdf->SetFont('', $style, 9); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 990 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 991 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 992 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 995 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 996 |  |  | 		if($description && !$hidedesc) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 997 |  |  | 			$posy = $pdf->GetY(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 998 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 999 |  |  | 			$pdf->SetFont('', '', 8); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1000 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1001 |  |  | 			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J',true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1002 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1003 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1004 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1005 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1006 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1007 |  |  | 	function pdf_writelinedesc_ref($parameters=array(), &$object, &$action='') { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1008 |  |  | 	// ultimate PDF hook O_o | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1009 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1010 |  |  | 		return $this->pdf_writelinedesc($parameters,$object,$action); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1011 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1012 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1013 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1014 |  |  | 	function isModSubtotalLine(&$parameters, &$object) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1015 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1016 |  |  | 		if(is_array($parameters)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1017 |  |  | 			$i = & $parameters['i'];	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1018 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1019 |  |  | 		else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1020 |  |  | 			$i = (int)$parameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1021 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1022 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1023 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1024 |  |  | 		if($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1025 |  |  | 			return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1026 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1027 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1028 |  |  | 		return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1029 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1030 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1031 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1032 |  |  | 	function pdf_getlineqty($parameters=array(), &$object, &$action='') { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1033 |  |  | 		global $conf,$hideprices; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1034 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1035 |  |  | 		if($this->isModSubtotalLine($parameters,$object) ){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1036 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1037 |  |  | 			$this->resprints = ' '; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1038 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1039 |  |  | 			if((float)DOL_VERSION<=3.6) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1040 |  |  | 				return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1041 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1042 |  |  | 			else if((float)DOL_VERSION>=3.8) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1043 |  |  | 				return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1044 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1045 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1046 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1047 |  |  | 		elseif(!empty($hideprices)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1048 |  |  | 			$this->resprints = $object->lines[$parameters['i']]->qty; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1049 |  |  | 			return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1050 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1051 |  |  | 		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1052 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1053 |  |  | 			$hideInnerLines = (int)GETPOST('hideInnerLines'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1054 |  |  | 			$hidedetails = (int)GETPOST('hidedetails'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1055 |  |  | 			if (empty($hideInnerLines) && !empty($hidedetails)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1056 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1057 |  |  | 				$this->resprints = $object->lines[$parameters['i']]->qty; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1058 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1059 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1060 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1061 |  |  | 		if(is_array($parameters)) $i = & $parameters['i']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1062 |  |  | 		else $i = (int)$parameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1063 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1065 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1066 |  |  | 		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1067 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1068 |  |  | 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1069 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1070 |  |  | 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1071 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1072 |  |  | 				$this->resprints = ' '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1073 |  |  | 				return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1074 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1075 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1076 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1077 |  |  | 		return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1078 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 1079 |  |  | 	 | 
            
                                                                        
                            
            
                                    
            
            
                | 1080 |  |  | 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 1081 |  |  | 	    global $conf, $hideprices, $hookmanager; | 
            
                                                                        
                            
            
                                    
            
            
                | 1082 |  |  | 		 | 
            
                                                                        
                            
            
                                    
            
            
                | 1083 |  |  | 		if(is_array($parameters)) $i = & $parameters['i']; | 
            
                                                                        
                            
            
                                    
            
            
                | 1084 |  |  | 		else $i = (int)$parameters; | 
            
                                                                        
                            
            
                                    
            
            
                | 1085 |  |  | 			 | 
            
                                                                        
                            
            
                                    
            
            
                | 1086 |  |  | 		if($this->isModSubtotalLine($parameters,$object) ){ | 
            
                                                                        
                            
            
                                    
            
            
                | 1087 |  |  | 			 | 
            
                                                                        
                            
            
                                    
            
            
                | 1088 |  |  | 			$this->resprints = ' '; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 1089 |  |  | 			 | 
            
                                                                        
                            
            
                                    
            
            
                | 1090 |  |  | 			if((float)DOL_VERSION<=3.6) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 1091 |  |  | 				return ''; | 
            
                                                                        
                            
            
                                    
            
            
                | 1092 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 1093 |  |  | 			else if((float)DOL_VERSION>=3.8) { | 
            
                                                                        
                            
            
                                    
            
            
                | 1094 |  |  | 				return 1; | 
            
                                                                        
                            
            
                                    
            
            
                | 1095 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 1096 |  |  | 			 | 
            
                                                                        
                            
            
                                    
            
            
                | 1097 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 1098 |  |  | 		elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS)) | 
            
                                                                        
                            
            
                                    
            
            
                | 1099 |  |  | 		{ | 
            
                                                                        
                            
            
                                    
            
            
                | 1100 |  |  | 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) | 
            
                                                                        
                            
            
                                    
            
            
                | 1101 |  |  | 			{ | 
            
                                                                        
                            
            
                                    
            
            
                | 1102 |  |  | 				if (!empty($object->lines[$i]->array_options['options_subtotal_nc']))  | 
            
                                                                        
                            
            
                                    
            
            
                | 1103 |  |  | 				{ | 
            
                                                                        
                            
            
                                    
            
            
                | 1104 |  |  | 					$this->resprints = ' '; | 
            
                                                                        
                            
            
                                    
            
            
                | 1105 |  |  | 					return 1; | 
            
                                                                        
                            
            
                                    
            
            
                | 1106 |  |  | 				} | 
            
                                                                        
                            
            
                                    
            
            
                | 1107 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 1108 |  |  | 				$TTitle = TSubtotal::getAllTitleFromLine($object->lines[$i]); | 
            
                                                                        
                            
            
                                    
            
            
                | 1109 |  |  | 				foreach ($TTitle as &$line_title) | 
            
                                                                        
                            
            
                                    
            
            
                | 1110 |  |  | 				{ | 
            
                                                                        
                            
            
                                    
            
            
                | 1111 |  |  | 					if (!empty($line_title->array_options['options_subtotal_nc'])) | 
            
                                                                        
                            
            
                                    
            
            
                | 1112 |  |  | 					{ | 
            
                                                                        
                            
            
                                    
            
            
                | 1113 |  |  | 						$this->resprints = ' '; | 
            
                                                                        
                            
            
                                    
            
            
                | 1114 |  |  | 						return 1; | 
            
                                                                        
                            
            
                                    
            
            
                | 1115 |  |  | 					} | 
            
                                                                        
                            
            
                                    
            
            
                | 1116 |  |  | 				} | 
            
                                                                        
                            
            
                                    
            
            
                | 1117 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 1118 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 1119 |  |  | 		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 1120 |  |  | 		    $this->resprints = price($object->lines[$i]->total_ht); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 1121 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 1122 |  |  | 		 | 
            
                                                                        
                            
            
                                    
            
            
                | 1123 |  |  | 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché | 
            
                                                                        
                            
            
                                    
            
            
                | 1124 |  |  | 		if (  | 
            
                                                                        
                            
            
                                    
            
            
                | 1125 |  |  | 			!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) &&  | 
            
                                                                        
                            
            
                                    
            
            
                | 1126 |  |  | 			(!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))  | 
            
                                                                        
                            
            
                                    
            
            
                | 1127 |  |  | 		) | 
            
                                                                        
                            
            
                                    
            
            
                | 1128 |  |  | 		{ | 
            
                                                                        
                            
            
                                    
            
            
                | 1129 |  |  | 			// alors je dois vérifier si la méthode fait partie de la conf qui l'exclue | 
            
                                                                        
                            
            
                                    
            
            
                | 1130 |  |  | 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) | 
            
                                                                        
                            
            
                                    
            
            
                | 1131 |  |  | 			{ | 
            
                                                                        
                            
            
                                    
            
            
                | 1132 |  |  | 				$this->resprints = ' '; | 
            
                                                                        
                            
            
                                    
            
            
                | 1133 |  |  | 				 | 
            
                                                                        
                            
            
                                    
            
            
                | 1134 |  |  | 				// currentcontext à modifier celon l'appel | 
            
                                                                        
                            
            
                                    
            
            
                | 1135 |  |  | 				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinetotalexcltax', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i); | 
            
                                                                        
                            
            
                                    
            
            
                | 1136 |  |  | 				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1) | 
            
                                                                        
                            
            
                                    
            
            
                | 1137 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 1138 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 1139 |  |  | 		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble | 
            
                                                                        
                            
            
                                    
            
            
                | 1140 |  |  | 		else if (!empty($hideprices)) | 
            
                                                                        
                            
            
                                    
            
            
                | 1141 |  |  | 		{ | 
            
                                                                        
                            
            
                                    
            
            
                | 1142 |  |  | 			// Check if a title exist for this line && if the title have subtotal | 
            
                                                                        
                            
            
                                    
            
            
                | 1143 |  |  | 			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i); | 
            
                                                                        
                            
            
                                    
            
            
                | 1144 |  |  | 			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true)) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 1145 |  |  | 			{ | 
            
                                                                        
                            
            
                                    
            
            
                | 1146 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 1147 |  |  | 				$this->resprints = ' '; | 
            
                                                                        
                            
            
                                    
            
            
                | 1148 |  |  | 				 | 
            
                                                                        
                            
            
                                    
            
            
                | 1149 |  |  | 				// currentcontext à modifier celon l'appel | 
            
                                                                        
                            
            
                                    
            
            
                | 1150 |  |  | 				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinetotalexcltax', 'currentcontext'=>'subtotal_hideprices', 'i' => $i); | 
            
                                                                        
                            
            
                                    
            
            
                | 1151 |  |  | 				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1) | 
            
                                                                        
                            
            
                                    
            
            
                | 1152 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 1153 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 1154 |  |  |          | 
            
                                                                        
                            
            
                                    
            
            
                | 1155 |  |  | 		return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1156 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1157 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1158 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1159 |  |  | 	 * Remplace le retour de la méthode qui l'appelle par un standard 1 ou autre chose celon le hook | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1160 |  |  | 	 * @return int 1, 0, -1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1161 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1162 |  |  | 	private function callHook(&$object, &$hookmanager, $action, $params) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1163 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1164 |  |  | 		$reshook=$hookmanager->executeHooks('subtotalHidePrices',$params, $object, $action); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1165 |  |  | 		if ($reshook < 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1166 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1167 |  |  | 			$this->error = $hookmanager->error; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1168 |  |  | 			$this->errors = $hookmanager->errors; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1169 |  |  | 			return -1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1170 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1171 |  |  | 		elseif (empty($reshook)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1172 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1173 |  |  | 			$this->resprints .= $hookmanager->resprints; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1174 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1175 |  |  | 		else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1176 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1177 |  |  | 			$this->resprints = $hookmanager->resprints; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1178 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1179 |  |  | 			// override return (use  $this->results['overrideReturn'] or $this->resArray['overrideReturn'] in other module action_xxxx.class.php ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1180 |  |  | 			if(isset($hookmanager->resArray['overrideReturn'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1181 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1182 |  |  | 				return $hookmanager->resArray['overrideReturn']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1183 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1184 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1185 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1186 |  |  | 		return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1187 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1188 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1189 |  |  | 	function pdf_getlinetotalwithtax($parameters=array(), &$object, &$action='') { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1190 |  |  | 		global $conf; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1191 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1192 |  |  | 		if($this->isModSubtotalLine($parameters,$object) ){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1193 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1194 |  |  | 			$this->resprints = ' '; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1195 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1196 |  |  | 			if((float)DOL_VERSION<=3.6) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1197 |  |  | 				return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1198 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1199 |  |  | 			else if((float)DOL_VERSION>=3.8) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1200 |  |  | 				return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1201 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1202 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1203 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1204 |  |  | 		if(is_array($parameters)) $i = & $parameters['i']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1205 |  |  | 		else $i = (int)$parameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1206 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1207 |  |  | 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1208 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1209 |  |  | 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1210 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1211 |  |  | 				$this->resprints = ' '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1212 |  |  | 				return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1213 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1214 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1215 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1216 |  |  | 		return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1217 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1218 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1219 |  |  | 	function pdf_getlineunit($parameters=array(), &$object, &$action='') { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1220 |  |  | 		global $conf; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1221 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1222 |  |  | 		if($this->isModSubtotalLine($parameters,$object) ){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1223 |  |  | 			$this->resprints = ' '; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1224 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1225 |  |  | 			if((float)DOL_VERSION<=3.6) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1226 |  |  | 				return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1227 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1228 |  |  | 			else if((float)DOL_VERSION>=3.8) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1229 |  |  | 				return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1230 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1231 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1232 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1233 |  |  | 		if(is_array($parameters)) $i = & $parameters['i']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1234 |  |  | 		else $i = (int)$parameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1235 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1236 |  |  | 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1237 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1238 |  |  | 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1239 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1240 |  |  | 				$this->resprints = ' '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1241 |  |  | 				return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1242 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1243 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1244 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1245 |  |  | 		return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1246 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1247 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1248 |  |  | 	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1249 |  |  | 		global $conf,$hideprices; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1250 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1251 |  |  | 		if($this->isModSubtotalLine($parameters,$object) ){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1252 |  |  | 			$this->resprints = ' '; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1253 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1254 |  |  | 			if((float)DOL_VERSION<=3.6) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1255 |  |  | 				return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1256 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1257 |  |  | 			else if((float)DOL_VERSION>=3.8) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1258 |  |  | 				return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1259 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1260 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1261 |  |  | 		if(is_array($parameters)) $i = & $parameters['i']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1262 |  |  | 		else $i = (int)$parameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1263 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1264 |  |  | 		if (!empty($hideprices)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1265 |  |  | 				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1266 |  |  | 		) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1267 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1268 |  |  | 			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1269 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1270 |  |  | 				$this->resprints = ' '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1271 |  |  | 				return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1272 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1273 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1274 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1275 |  |  | 		return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1276 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1277 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1278 |  |  | 	function pdf_getlineupwithtax($parameters=array(), &$object, &$action='') { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1279 |  |  | 		global $conf,$hideprices; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1280 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1281 |  |  | 		if($this->isModSubtotalLine($parameters,$object) ){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1282 |  |  | 			$this->resprints = ' '; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1283 |  |  | 			if((float)DOL_VERSION<=3.6) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1284 |  |  | 				return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1285 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1286 |  |  | 			else if((float)DOL_VERSION>=3.8) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1287 |  |  | 				return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1288 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1289 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1290 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1291 |  |  | 		if(is_array($parameters)) $i = & $parameters['i']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1292 |  |  | 		else $i = (int)$parameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1293 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1294 |  |  | 		if (!empty($hideprices) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1295 |  |  | 				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1296 |  |  | 		) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1297 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1298 |  |  | 			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1299 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1300 |  |  | 				$this->resprints = ' '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1301 |  |  | 				return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1302 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1303 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1304 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1305 |  |  | 		return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1306 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1307 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1308 |  |  | 	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1309 |  |  | 		global $conf; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1310 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1311 |  |  | 		if($this->isModSubtotalLine($parameters,$object) ){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1312 |  |  | 			$this->resprints = ' '; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1313 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1314 |  |  | 			if((float)DOL_VERSION<=3.6) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1315 |  |  | 				return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1316 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1317 |  |  | 			else if((float)DOL_VERSION>=3.8) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1318 |  |  | 				return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1319 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1320 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1321 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1322 |  |  | 		if(is_array($parameters)) $i = & $parameters['i']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1323 |  |  | 		else $i = (int)$parameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1324 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1325 |  |  | 		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) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1326 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1327 |  |  | 		$object->lines[$i]->fetch_optionals(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1328 |  |  | 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1329 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1330 |  |  | 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1331 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1332 |  |  | 				$this->resprints = ' '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1333 |  |  | 				return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1334 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1335 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1336 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1337 |  |  | 		return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1338 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1339 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1340 |  |  | 	function pdf_getlineprogress($parameters=array(), &$object, &$action) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1341 |  |  | 		global $conf; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1342 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1343 |  |  | 		if($this->isModSubtotalLine($parameters,$object) ){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1344 |  |  | 			$this->resprints = ' '; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1345 |  |  | 			if((float)DOL_VERSION<=3.6) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1346 |  |  | 				return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1347 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1348 |  |  | 			else if((float)DOL_VERSION>=3.8) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1349 |  |  | 				return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1350 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1351 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1352 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1353 |  |  | 		if(is_array($parameters)) $i = & $parameters['i']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1354 |  |  | 		else $i = (int)$parameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1355 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1356 |  |  | 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1357 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1358 |  |  | 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1359 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1360 |  |  | 				$this->resprints = ' '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1361 |  |  | 				return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1362 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1363 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1364 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1365 |  |  | 		return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1366 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1367 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1368 |  |  | 	function add_numerotation(&$object) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1369 |  |  | 		global $conf; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1370 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1371 |  |  | 		if(!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1372 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1373 |  |  | 			$TLevelTitre = array(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1374 |  |  | 			$prevlevel = 0; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1375 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1376 |  |  | 			foreach($object->lines as $k=>&$line)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1377 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1378 |  |  | 				if ($line->id > 0 && $this->isModSubtotalLine($k, $object) && $line->qty <= 10) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1379 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1380 |  |  | 					$TLineTitle[] = &$line; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1381 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1382 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1383 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1384 |  |  | 			if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1385 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1386 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1387 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1388 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1389 |  |  | 	// TODO ne gère pas encore la numération des lignes "Totaux" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1390 |  |  | 	private function formatNumerotation(&$TLineTitle, $line_reference='', $level=1, $prefix_num=0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1391 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1392 |  |  | 		$TTitle = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1393 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1394 |  |  | 		$i=1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1395 |  |  | 		$j=0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1396 |  |  | 		foreach ($TLineTitle as $k => &$line) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1397 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1398 |  |  | 			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1399 |  |  | 			if (!empty($line_reference) && $line->qty <= $line_reference->qty) break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1400 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1401 |  |  | 			if ($line->qty == $level) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1402 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1403 |  |  | 				$TTitle[$j]['numerotation'] = ($prefix_num == 0) ? $i : $prefix_num.'.'.$i; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1404 |  |  | 				//var_dump('Prefix == '.$prefix_num.' // '.$line->desc.' ==> numerotation == '.$TTitle[$j]['numerotation'].'   ###    '.$line->qty .'=='. $level); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1405 |  |  | 				if (empty($line->label) && (float)DOL_VERSION < 6) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1406 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1407 |  |  | 					$line->label = !empty($line->desc) ? $line->desc : $line->description; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1408 |  |  | 					$line->desc = $line->description = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1409 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1410 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1411 |  |  | 				$line->label = $TTitle[$j]['numerotation'].' '.$line->label; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1412 |  |  | 				$TTitle[$j]['line'] = &$line; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1413 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1414 |  |  | 				$deep_level = $line->qty; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1415 |  |  | 				do { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1416 |  |  | 					$deep_level++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1417 |  |  | 					$TTitle[$j]['children'] = $this->formatNumerotation($TLineTitle, $line, $deep_level, $TTitle[$j]['numerotation']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1418 |  |  | 				} while (empty($TTitle[$j]['children']) && $deep_level <= 10); // Exemple si un bloc Titre lvl 1 contient pas de sous lvl 2 mais directement un sous lvl 5 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1419 |  |  | 				// Rappel on peux avoir jusqu'a 10 niveau de titre | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1420 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1421 |  |  | 				$i++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1422 |  |  | 				$j++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1423 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1424 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1425 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1426 |  |  | 		return $TTitle; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1427 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1428 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1429 |  |  | 	function setDocTVA(&$pdf, &$object) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1430 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1431 |  |  | 		$hidedetails = (int)GETPOST('hidedetails'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1432 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1433 |  |  | 		if(empty($hidedetails)) return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1434 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1435 |  |  | 		// TODO can't add VAT to document without lines... :-/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1436 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1437 |  |  | 		return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1438 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1439 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1440 |  |  | 	function beforePDFCreation($parameters=array(), &$object, &$action) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1441 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1442 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1443 |  |  | 		 * @var $pdf    TCPDF | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1444 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1445 |  |  | 		global $pdf,$conf, $langs; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1446 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1447 |  |  | 		// var_dump($object->lines); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1448 |  |  | 		dol_include_once('/subtotal/class/subtotal.class.php'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1449 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1450 |  |  | 		foreach($parameters as $key=>$value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1451 |  |  | 			${$key} = $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1452 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1453 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1454 |  |  | 		$this->setDocTVA($pdf, $object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1455 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1456 |  |  | 		$this->add_numerotation($object);	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1457 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1458 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1459 |  |  | 		$hideInnerLines = (int)GETPOST('hideInnerLines'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1460 |  |  | 		$hidedetails = (int)GETPOST('hidedetails'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1461 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1462 |  |  | 		if ($hideInnerLines) { // si c une ligne de titre | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1463 |  |  | 	    	$fk_parent_line=0; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1464 |  |  | 			$TLines =array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1465 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1466 |  |  | 			$original_count=count($object->lines); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1467 |  |  | 		    $TTvas = array(); // tableau de tva | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1468 |  |  | 		     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1469 |  |  | 			foreach($object->lines as $k=>&$line)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1470 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1471 |  |  | 			     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1472 |  |  | 				if($line->product_type==9 && $line->rowid>0)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1473 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1474 |  |  | 					$fk_parent_line = $line->rowid; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1475 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1476 |  |  | 					// Fix tk7201 - si on cache le détail, la TVA est renseigné au niveau du sous-total, l'erreur c'est s'il y a plusieurs sous-totaux pour les même lignes, ça va faire la somme | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1477 |  |  | 					if(TSubtotal::isSubtotal($line))  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1478 |  |  | 					{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1479 |  |  | 						/*$total = $this->getTotalLineFromObject($object, $line, ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1480 |  |  | 						 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1481 |  |  | 						$line->total_ht = $total; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1482 |  |  | 						$line->total = $total; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1483 |  |  | 						*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1484 |  |  | 						list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1485 |  |  | 						 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1486 |  |  | 						if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TTotal_tva; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1487 |  |  | 						$line->total_ht = $total; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1488 |  |  | 						$line->total_tva = $total_tva; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1489 |  |  | 						$line->total = $line->total_ht; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1490 |  |  | 						$line->total_ttc = $total_ttc; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1491 |  |  | 					}  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1492 |  |  | 						 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1493 |  |  | 				}  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1494 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1495 |  |  | 				if ($hideInnerLines) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1496 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1497 |  |  | 				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1498 |  |  | 				    { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1499 |  |  | 				        if($line->tva_tx != '0.000' && $line->product_type!=9){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1500 |  |  | 				             | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1501 |  |  |     				        // on remplit le tableau de tva pour substituer les lignes cachées | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1502 |  |  |     				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1503 |  |  |     				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1504 |  |  |     				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc;  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1505 |  |  |     				    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1506 |  |  |     					if($line->product_type==9 && $line->rowid>0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1507 |  |  |     					{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1508 |  |  |     					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1509 |  |  |     					    // génère des lignes d'affichage des montants HT soumis à tva | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1510 |  |  |     					    $nbtva = count($TTvas); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1511 |  |  |     					    if(!empty($nbtva)){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1512 |  |  |     					        foreach ($TTvas as $tx =>$val){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1513 |  |  |     					            $l = clone $line; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1514 |  |  |     					            $l->product_type = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1515 |  |  |     					            $l->special_code = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1516 |  |  |     					            $l->qty = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1517 |  |  |     					            $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx)); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1518 |  |  |     					            $l->tva_tx = $tx; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1519 |  |  |     					            $l->total_ht = $val['total_ht']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1520 |  |  |     					            $l->total_tva = $val['total_tva']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1521 |  |  |     					            $l->total = $line->total_ht; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1522 |  |  |     					            $l->total_ttc = $val['total_ttc']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1523 |  |  |     					            $TLines[] = $l; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1524 |  |  |     					            array_shift($TTvas); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1525 |  |  |     					       } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1526 |  |  |     					    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1527 |  |  |     					     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1528 |  |  |     					    // ajoute la ligne de sous-total | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1529 |  |  |     					    $TLines[] = $line;  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1530 |  |  |     					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1531 |  |  | 				    } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1532 |  |  | 				         | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1533 |  |  | 				        if($line->product_type==9 && $line->rowid>0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1534 |  |  | 				        { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1535 |  |  | 				            // ajoute la ligne de sous-total | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1536 |  |  | 				            $TLines[] = $line;  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1537 |  |  | 				        } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1538 |  |  | 				    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1539 |  |  | 				     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1540 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1541 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1542 |  |  | 				elseif ($hidedetails) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1543 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1544 |  |  | 					$TLines[] = $line; //Cas où je cache uniquement les prix des produits	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1545 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1546 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1547 |  |  | 				if ($line->product_type != 9) { // jusqu'au prochain titre ou total | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1548 |  |  | 					//$line->fk_parent_line = $fk_parent_line; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1549 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1550 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1551 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1552 |  |  | 				/*if($hideTotal) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1553 |  |  | 					$line->total = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1554 |  |  | 					$line->subprice= 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1555 |  |  | 				}*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1556 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1557 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1558 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1559 |  |  | 			// cas incongru où il y aurait des produits en dessous du dernier sous-total | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1560 |  |  | 			$nbtva = count($TTvas); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1561 |  |  | 			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1562 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1563 |  |  | 			    foreach ($TTvas as $tx =>$val){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1564 |  |  | 			        $l = clone $line; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1565 |  |  | 			        $l->product_type = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1566 |  |  | 			        $l->special_code = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1567 |  |  | 			        $l->qty = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1568 |  |  | 			        $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1569 |  |  | 			        $l->tva_tx = $tx; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1570 |  |  | 			        $l->total_ht = $val['total_ht']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1571 |  |  | 			        $l->total_tva = $val['total_tva']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1572 |  |  | 			        $l->total = $line->total_ht; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1573 |  |  | 			        $l->total_ttc = $val['total_ttc']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1574 |  |  | 			        $TLines[] = $l; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1575 |  |  | 			        array_shift($TTvas); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1576 |  |  | 			    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1577 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1578 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1579 |  |  | 			global $nblignes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1580 |  |  | 			$nblignes=count($TLines); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1581 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1582 |  |  | 			$object->lines = $TLines; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1583 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1584 |  |  | 			if($i>count($object->lines)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1585 |  |  | 				$this->resprints = ''; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1586 |  |  | 				return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1587 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1588 |  |  | 	    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1589 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1590 |  |  | 		return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1591 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1592 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1593 |  |  | 	function pdf_writelinedesc($parameters=array(), &$object, &$action) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1594 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1595 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1596 |  |  | 		 * @var $pdf    TCPDF | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1597 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1598 |  |  | 		global $pdf,$conf; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1599 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1600 |  |  | 		foreach($parameters as $key=>$value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1601 |  |  | 			${$key} = $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1602 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1603 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1604 |  |  | 		$hideInnerLines = (int)GETPOST('hideInnerLines'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1605 |  |  | 		$hidedetails = (int)GETPOST('hidedetails'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1606 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1607 |  |  | 		if($this->isModSubtotalLine($parameters,$object) ){			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1608 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1609 |  |  | 				global $hideprices; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1610 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1611 |  |  | 				if(!empty($hideprices)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1612 |  |  | 					foreach($object->lines as &$line) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1613 |  |  | 						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1614 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1615 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1616 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1617 |  |  | 				$line = &$object->lines[$i]; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1618 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1619 |  |  | 				if($line->info_bits>0) { // PAGE BREAK | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1620 |  |  | 					$pdf->addPage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1621 |  |  | 					$posy = $pdf->GetY(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1622 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1623 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1624 |  |  | 				$label = $line->label; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1625 |  |  | 				$description= !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1626 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1627 |  |  | 				if(empty($label)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1628 |  |  | 					$label = $description; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1629 |  |  | 					$description=''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1630 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1631 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1632 |  |  | 				if($line->qty>90) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1633 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1634 |  |  | 					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1635 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1636 |  |  | 					$pageBefore = $pdf->getPage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1637 |  |  | 					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1638 |  |  | 					$pageAfter = $pdf->getPage();	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1639 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1640 |  |  | 					if($pageAfter>$pageBefore) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1641 |  |  | 						//print "ST $pageAfter>$pageBefore<br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1642 |  |  | 						$pdf->rollbackTransaction(true);	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1643 |  |  | 						$pdf->addPage('','', true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1644 |  |  | 						$posy = $pdf->GetY(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1645 |  |  | 						$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1646 |  |  | 						$posy = $pdf->GetY(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1647 |  |  | 						//print 'add ST'.$pdf->getPage().'<br />'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1648 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1649 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1650 |  |  | 					$posy = $pdf->GetY(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1651 |  |  | 					return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1652 |  |  | 				}	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1653 |  |  | 				else if ($line->qty < 10) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1654 |  |  | 					$pageBefore = $pdf->getPage(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1655 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1656 |  |  | 					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1657 |  |  | 					$pageAfter = $pdf->getPage();	 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1658 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1659 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1660 |  |  | 					/*if($pageAfter>$pageBefore) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1661 |  |  | 						print "T $pageAfter>$pageBefore<br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1662 |  |  | 						$pdf->rollbackTransaction(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1663 |  |  | 						$pdf->addPage('','', true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1664 |  |  | 						print 'add T'.$pdf->getPage().' '.$line->rowid.' '.$pdf->GetY().' '.$posy.'<br />'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1665 |  |  | 						 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1666 |  |  | 						$posy = $pdf->GetY(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1667 |  |  | 						$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1668 |  |  | 						$posy = $pdf->GetY(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1669 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1670 |  |  | 				*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1671 |  |  | 					$posy = $pdf->GetY(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1672 |  |  | 					return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1673 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1674 |  |  | //	if($line->rowid==47) exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1675 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1676 |  |  | 			return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1677 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1678 |  |  | 		elseif (empty($object->lines[$parameters['i']])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1679 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1680 |  |  | 			$this->resprints = -1; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1681 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1682 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1683 |  |  | 		/* TODO je desactive parce que je comprends pas PH Style, mais à test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1684 |  |  | 		else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1685 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1686 |  |  | 			if($hideInnerLines) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1687 |  |  | 				$pdf->rollbackTransaction(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1688 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1689 |  |  | 			else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1690 |  |  | 				$labelproductservice=pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1691 |  |  | 				$pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1692 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1693 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1694 |  |  | 		}*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1695 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1696 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1697 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1698 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1699 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1700 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1701 |  |  | 	 * Permet de récupérer le titre lié au sous-total | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1702 |  |  | 	 *  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1703 |  |  | 	 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1704 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1705 |  |  | 	function getTitle(&$object, &$currentLine) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1706 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1707 |  |  | 		$res = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1708 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1709 |  |  | 		foreach ($object->lines as $line) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1710 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1711 |  |  | 			if ($line->id == $currentLine->id) break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1712 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1713 |  |  | 			$qty_search = 100 - $currentLine->qty; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1714 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1715 |  |  | 			if ($line->product_type == 9 && $line->special_code == $this->module_number && $line->qty == $qty_search)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1716 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1717 |  |  | 				$res = ($line->label) ? $line->label : (($line->description) ? $line->description : $line->desc); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1718 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1719 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1720 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1721 |  |  | 		return $res; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1722 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1723 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1724 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1725 |  |  | 	 * @param $parameters   array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1726 |  |  | 	 * @param $object       CommonObject | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1727 |  |  | 	 * @param $action       string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1728 |  |  | 	 * @param $hookmanager  HookManager | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1729 |  |  | 	 * @return int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1730 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1731 |  |  | 	function printObjectLine ($parameters, &$object, &$action, $hookmanager){ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1732 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1733 |  |  | 		global $conf,$langs,$user,$db,$bc; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1734 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1735 |  |  | 		$num = &$parameters['num']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1736 |  |  | 		$line = &$parameters['line']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1737 |  |  | 		$i = &$parameters['i']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1738 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1739 |  |  | 		$var = &$parameters['var']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1740 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1741 |  |  | 		$contexts = explode(':',$parameters['context']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1742 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1743 |  |  | 		$createRight = $user->rights->{$object->element}->creer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1744 |  |  | 		if($object->element == 'facturerec' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1745 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1746 |  |  | 			$object->statut = 0; // hack for facture rec | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1747 |  |  | 			$createRight = $user->rights->facture->creer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1748 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1749 |  |  | 		elseif($object->element == 'order_supplier' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1750 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1751 |  |  | 		    $createRight = $user->rights->fournisseur->commande->creer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1752 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1753 |  |  | 		elseif($object->element == 'invoice_supplier' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1754 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1755 |  |  | 		    $createRight = $user->rights->fournisseur->facture->creer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1756 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1757 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1758 |  |  | 		if($line->special_code!=$this->module_number || $line->product_type!=9) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1759 |  |  | 			null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1760 |  |  | 		}	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1761 |  |  | 		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))  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1762 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1763 |  |  | 			if($object->element=='facture')$idvar = 'facid'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1764 |  |  | 			else $idvar='id'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1765 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1766 |  |  | 			if((float)DOL_VERSION <= 3.4) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1767 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1768 |  |  | 				?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1769 |  |  | 				<script type="text/javascript"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1770 |  |  | 					$(document).ready(function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1771 |  |  | 						$('#tablelines tr[rel=subtotal]').mouseleave(function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1772 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1773 |  |  | 							id_line =$(this).attr('id'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1774 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1775 |  |  | 							$(this).find('td[rel=subtotal_total]').each(function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1776 |  |  | 								$.get(document.location.href, function(data) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1777 |  |  | 									var total = $(data).find('#tablelines tr#'+id_line+' td[rel=subtotal_total]').html(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1778 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1779 |  |  | 									$('#tablelines tr#'+id_line+' td[rel=subtotal_total]').html(total); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1780 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1781 |  |  | 								}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1782 |  |  | 							}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1783 |  |  | 						}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1784 |  |  | 					}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1785 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1786 |  |  | 				</script> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1787 |  |  | 				<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1788 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1789 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1790 |  |  | 			if(empty($line->description)) $line->description = $line->desc; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1791 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1792 |  |  | 			$colspan = 5; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1793 |  |  | 			if($object->element == 'facturerec' ) $colspan = 3; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1794 |  |  | 			if($object->element == 'order_supplier') $colspan = 3; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1795 |  |  | 			if($object->element == 'invoice_supplier') $colspan = 4; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1796 |  |  | 			if($object->element == 'supplier_proposal') $colspan = 4; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1797 |  |  | 			if(!empty($conf->multicurrency->enabled)) $colspan+=2; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1798 |  |  | 			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1799 |  |  | 			if(!empty($conf->margin->enabled)) $colspan++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1800 |  |  | 			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1801 |  |  | 			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1802 |  |  | 			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1803 |  |  | 			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1804 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1805 |  |  | 			/* Titre */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1806 |  |  | 			//var_dump($line); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1807 |  |  |              | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1808 |  |  | 			// HTML 5 data for js | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1809 |  |  |             $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1810 |  |  |              | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1811 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1812 |  |  | 			?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1813 |  |  | 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1814 |  |  | 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1815 |  |  | 					{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1816 |  |  | 						if($line->qty==99) print 'background:#adadcf'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1817 |  |  | 						else if($line->qty==98) print 'background:#ddddff;'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1818 |  |  | 						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1819 |  |  | 						else if($line->qty==1) print 'background:#adadcf;'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1820 |  |  | 						else if($line->qty==2) print 'background:#ddddff;'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1821 |  |  | 						else if($line->qty==50) print ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1822 |  |  | 						else print 'background:#eeeeff;'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1823 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1824 |  |  | 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1825 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1826 |  |  | 					else  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1827 |  |  | 					{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1828 |  |  | 						if($line->qty==99) print 'background:#ddffdd'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1829 |  |  | 						else if($line->qty==98) print 'background:#ddddff;'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1830 |  |  | 						else if($line->qty==2) print 'background:#eeeeff; '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1831 |  |  | 						else if($line->qty==50) print ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1832 |  |  | 						else print 'background:#eeffee;' ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1833 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1834 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1835 |  |  | 			?>;"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1836 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1837 |  |  | 				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1838 |  |  | 					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1839 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1840 |  |  | 						$params=array('line'=>$line); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1841 |  |  | 						$reshook=$hookmanager->executeHooks('formEditProductOptions',$params,$object,$action); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1842 |  |  | 						 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1843 |  |  | 						echo '<div id="line_'.$line->id.'"></div>'; // Imitation Dolibarr | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1844 |  |  | 						echo '<input type="hidden" value="'.$line->id.'" name="lineid">'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1845 |  |  | 						echo '<input id="product_type" type="hidden" value="'.$line->product_type.'" name="type">'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1846 |  |  | 						echo '<input id="product_id" type="hidden" value="'.$line->fk_product.'" name="type">'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1847 |  |  | 						echo '<input id="special_code" type="hidden" value="'.$line->special_code.'" name="type">'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1848 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1849 |  |  | 						$isFreeText=false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1850 |  |  | 						if (TSubtotal::isTitle($line)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1851 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1852 |  |  | 							$qty_displayed = $line->qty; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1853 |  |  | 							print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span>  '; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1854 |  |  | 							 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1855 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1856 |  |  | 						else if (TSubtotal::isSubtotal($line)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1857 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1858 |  |  | 							$qty_displayed = 100 - $line->qty; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1859 |  |  | 							print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span>  '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1860 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1861 |  |  | 						else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1862 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1863 |  |  | 							$isFreeText = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1864 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1865 |  |  | 						 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1866 |  |  | 						if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1867 |  |  | 						    $line->label = !empty($line->description) ? $line->description : $line->desc; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1868 |  |  | 						    $line->description = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1869 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1870 |  |  | 						$newlabel = $line->label; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1871 |  |  | 						if($line->label=='' && !$isFreeText) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1872 |  |  | 							if(TSubtotal::isSubtotal($line)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1873 |  |  | 								$newlabel = $line->description.' '.$this->getTitle($object, $line); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1874 |  |  | 								$line->description=''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1875 |  |  | 							} elseif( (float)DOL_VERSION < 6 ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1876 |  |  | 								$newlabel= $line->description; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1877 |  |  | 								$line->description=''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1878 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1879 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1880 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1881 |  |  | 						$readonlyForSituation = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1882 |  |  | 						if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) $readonlyForSituation = 'readonly'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1883 |  |  | 						 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1884 |  |  | 						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/> '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1885 |  |  | 						 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1886 |  |  | 						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1887 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1888 |  |  | 							$select = '<select name="subtotal_level">'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1889 |  |  | 							for ($j=1; $j<10; $j++) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1890 |  |  | 							{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1891 |  |  | 								if (!empty($readonlyForSituation)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1892 |  |  | 									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1893 |  |  | 								} else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1894 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1895 |  |  | 							$select .= '</select> '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1896 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1897 |  |  | 							echo $select; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1898 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1899 |  |  | 						 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1900 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1901 |  |  | 						echo '<div class="subtotal_underline" style="margin-left:24px;">'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1902 |  |  | 							echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label> <input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />  '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1903 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1904 |  |  | 							if (TSubtotal::isTitle($line)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1905 |  |  | 							{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1906 |  |  | 								$form = new Form($db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1907 |  |  | 								echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1908 |  |  | 								echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1909 |  |  | 								if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1910 |  |  | 								echo '</select>  '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1911 |  |  | 								 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1912 |  |  | 								if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1913 |  |  | 								{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1914 |  |  | 									echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1915 |  |  | 								} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1916 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1917 |  |  | 							else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1918 |  |  | 						echo '</div>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1919 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1920 |  |  | 						if($line->qty<10) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1921 |  |  | 							// WYSIWYG editor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1922 |  |  | 							require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1923 |  |  | 							$nbrows = ROWS_2; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1924 |  |  | 							$cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1925 |  |  | 							if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1926 |  |  | 								$nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1927 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1928 |  |  | 							$toolbarname = 'dolibarr_details'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1929 |  |  | 							if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1930 |  |  | 								$toolbarname = 'dolibarr_notes'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1931 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1932 |  |  | 							$doleditor = new DolEditor('line-description', $line->description, '', 100, $toolbarname, '', | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1933 |  |  | 								false, true, $cked_enabled, $nbrows, '98%', (bool) $readonlyForSituation); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1934 |  |  | 							$doleditor->Create(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1935 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1936 |  |  | 						 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1937 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1938 |  |  | 					else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1939 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1940 |  |  | 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1941 |  |  | 						 { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1942 |  |  | 							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1943 |  |  | 							{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1944 |  |  | 								echo str_repeat('   ', $line->qty-1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1945 |  |  | 								 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1946 |  |  | 								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>  '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1947 |  |  | 								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>  '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1948 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1949 |  |  | 						 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1950 |  |  | 						 else  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1951 |  |  | 						 { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1952 |  |  | 							if($line->qty<=1) print img_picto('', 'subtotal@subtotal'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1953 |  |  | 							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'     ';  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1954 |  |  | 						 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1955 |  |  | 						  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1956 |  |  | 						  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1957 |  |  | 						 // Get display styles and apply them | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1958 |  |  | 						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1959 |  |  | 						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1960 |  |  | 						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1961 |  |  | 						  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1962 |  |  | 						 if (empty($line->label)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1963 |  |  | 							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1964 |  |  | 							else print  $line->description; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1965 |  |  | 						 }  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1966 |  |  | 						 else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1967 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1968 |  |  | 							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1969 |  |  | 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1970 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1971 |  |  | 							else{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1972 |  |  | 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1973 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1974 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1975 |  |  | 						 }  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1976 |  |  | 						if($line->qty>90) print ' : '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1977 |  |  | 						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1978 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1979 |  |  | 						  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1980 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1981 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1982 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1983 |  |  | 			?></td> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1984 |  |  | 					  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1985 |  |  | 			<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1986 |  |  | 				if($line->qty>90) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1987 |  |  | 					/* Total */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1988 |  |  | 					$total_line = $this->getTotalLineFromObject($object, $line, ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1989 |  |  | 					echo '<td class="nowrap liencolht" align="right" style="font-weight:bold;" rel="subtotal_total">'.price($total_line).'</td>'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1990 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1991 |  |  | 					echo '<td class="liencolht movetitleblock" > </td>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1992 |  |  | 				}	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1993 |  |  | 			?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1994 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1995 |  |  | 			<td align="center" class="nowrap linecoledit"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1996 |  |  | 				<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1997 |  |  | 				if ($action != 'selectlines') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1998 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1999 |  |  | 					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2000 |  |  | 						?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2001 |  |  | 						<input id="savelinebutton" class="button" type="submit" name="save" value="<?php echo $langs->trans('Save') ?>" /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2002 |  |  | 						<br /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2003 |  |  | 						<input class="button" type="button" name="cancelEditlinetitle" value="<?php echo $langs->trans('Cancel') ?>" /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2004 |  |  | 						<script type="text/javascript"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2005 |  |  | 							$(document).ready(function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2006 |  |  | 								$('input[name=cancelEditlinetitle]').click(function () { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2007 |  |  | 									document.location.href="<?php echo '?'.$idvar.'='.$object->id ?>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2008 |  |  | 								}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2009 |  |  | 							}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2010 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2011 |  |  | 						</script> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2012 |  |  | 						<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2013 |  |  | 						 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2014 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2015 |  |  | 					else{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2016 |  |  | 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2017 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2018 |  |  | 							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>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2019 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2020 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2021 |  |  | 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK))  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2022 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2023 |  |  | 							echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=editline&lineid='.$line->id.'">'.img_edit().'</a>'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2024 |  |  | 						}								 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2025 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2026 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2027 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2028 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2029 |  |  | 				?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2030 |  |  | 			</td> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2031 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2032 |  |  | 			<td align="center" nowrap="nowrap" class="linecoldelete">	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2033 |  |  | 				<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2034 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2035 |  |  | 				if ($action != 'editline' && $action != 'selectlines') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2036 |  |  | 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2037 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2038 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2039 |  |  | 							if ($object->situation_counter == 1 || !$object->situation_cycle_ref) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2040 |  |  | 							{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2041 |  |  | 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteline&lineid='.$line->id.'">'.img_delete().'</a>'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2042 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2043 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2044 |  |  | 							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2045 |  |  | 							{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2046 |  |  | 								$img_delete = ((float) DOL_VERSION >= 3.8) ? img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal') : img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2047 |  |  | 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteallline&lineid='.$line->id.'">'.$img_delete.'</a>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2048 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2049 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2050 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2051 |  |  | 				?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2052 |  |  | 			</td> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2053 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2054 |  |  | 			<?php  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2055 |  |  | 			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2056 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2057 |  |  | 				echo '<td class="subtotal_nc">'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2058 |  |  | 				echo '<input id="subtotal_nc-'.$line->id.'" class="subtotal_nc_chkbx" data-lineid="'.$line->id.'" type="checkbox" name="subtotal_nc" value="1" '.(!empty($line->array_options['options_subtotal_nc']) ? 'checked="checked"' : '').' />'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2059 |  |  | 				echo '</td>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2060 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2061 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2062 |  |  | 			if ($num > 1 && empty($conf->browser->phone)) { ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2063 |  |  | 			<td align="center" class="tdlineupdown"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2064 |  |  | 			</td> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2065 |  |  | 			<?php } else { ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2066 |  |  | 			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0  && $createRight ))?' class="tdlineupdown"':''); ?>></td> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2067 |  |  | 			<?php } ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2068 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2069 |  |  | 			<?php  if($action == 'selectlines'){ // dolibarr 8 ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2070 |  |  | 			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2071 |  |  | 			<?php } ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2072 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2073 |  |  | 			</tr> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2074 |  |  | 			<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2075 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2076 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2077 |  |  | 			// Affichage des extrafields à la Dolibarr (car sinon non affiché sur les titres) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2078 |  |  | 			if(TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2079 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2080 |  |  | 				require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2081 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2082 |  |  | 				// Extrafields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2083 |  |  | 				$extrafieldsline = new ExtraFields($db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2084 |  |  | 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2085 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2086 |  |  | 				$colspan+=3; $mode = 'view'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2087 |  |  | 				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2088 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2089 |  |  | 				$ex_element = $line->element; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2090 |  |  | 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2091 |  |  | 				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ','colspan'=>$colspan)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2092 |  |  | 				$isExtraSelected = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2093 |  |  | 				foreach($line->array_options as $option) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2094 |  |  | 					if(!empty($option) && $option != "-1") { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2095 |  |  | 						$isExtraSelected = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2096 |  |  | 						break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2097 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2098 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2099 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2100 |  |  | 				if($mode === 'edit') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2101 |  |  | 					?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2102 |  |  | 					<script> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2103 |  |  | 						$(document).ready(function(){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2105 |  |  | 							var all_tr_extrafields = $("tr.tr_extrafield_title"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2106 |  |  | 							<?php  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2107 |  |  | 							// Si un extrafield est rempli alors on affiche directement les extrafields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2108 |  |  | 							if(!$isExtraSelected) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2109 |  |  | 								echo 'all_tr_extrafields.hide();'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2110 |  |  | 								echo 'var trad = "'.$langs->trans('showExtrafields').'";'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2111 |  |  | 								echo 'var extra = 0;'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2112 |  |  | 							} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2113 |  |  | 								echo 'all_tr_extrafields.show();'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2114 |  |  | 								echo 'var trad = "'.$langs->trans('hideExtrafields').'";'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2115 |  |  | 								echo 'var extra = 1;'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2116 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2117 |  |  | 							?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2118 |  |  | 							 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2119 |  |  | 							$("div .subtotal_underline").append( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2120 |  |  | 									'<a id="printBlocExtrafields" onclick="return false;" href="#">' + trad + '</a>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2121 |  |  | 									+ '<input type="hidden" name="showBlockExtrafields" id="showBlockExtrafields" value="'+ extra +'" />'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2123 |  |  | 							$(document).on('click', "#printBlocExtrafields", function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2124 |  |  | 								var btnShowBlock = $("#showBlockExtrafields"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2125 |  |  | 								var val = btnShowBlock.val(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2126 |  |  | 								if(val == '0') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2127 |  |  | 									btnShowBlock.val('1'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2128 |  |  | 									$("#printBlocExtrafields").html("<?php print $langs->trans('hideExtrafields'); ?>"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2129 |  |  | 									$(all_tr_extrafields).show(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2130 |  |  | 								} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2131 |  |  | 									btnShowBlock.val('0'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2132 |  |  | 									$("#printBlocExtrafields").html("<?php print $langs->trans('showExtrafields'); ?>"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2133 |  |  | 									$(all_tr_extrafields).hide(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2134 |  |  | 								} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2135 |  |  | 							}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2136 |  |  | 						}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2137 |  |  | 					</script> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2138 |  |  | 					<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2139 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2140 |  |  | 				$line->element = $ex_element; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2141 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2142 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2143 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2144 |  |  | 			return 1;	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2145 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2146 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2147 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2148 |  |  | 		return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2149 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2150 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2151 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2152 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2153 |  |  | 	function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2154 |  |  | 		global $conf,$langs; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2155 |  |  | 		  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2156 |  |  | 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2157 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2158 |  |  | 		     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2159 |  |  | 		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2160 |  |  | 		    { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2161 |  |  | 		        foreach ($object->lines as $line) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2162 |  |  | 		        { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2163 |  |  | 		            // fetch optionals attributes and labels | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2164 |  |  | 		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2165 |  |  | 		            $extrafields=new ExtraFields($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2166 |  |  | 		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2167 |  |  | 		            $line->fetch_optionals($line->id,$extralabels); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2168 |  |  | 		        } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2169 |  |  | 		    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2170 |  |  | 		     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2171 |  |  | 			$TSubNc = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2172 |  |  | 			foreach ($object->lines as &$l) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2173 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2174 |  |  | 				$TSubNc[$l->id] = (int) $l->array_options['options_subtotal_nc']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2175 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2176 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2177 |  |  | 			$form = new Form($db); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2178 |  |  | 			?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2179 |  |  | 			<script type="text/javascript"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2180 |  |  | 				$(function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2181 |  |  | 					var subtotal_TSubNc = <?php echo json_encode($TSubNc); ?>; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2182 |  |  | 					$("#tablelines tbody > tr").each(function(i, item) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2183 |  |  | 						if ($(item).children('.subtotal_nc').length == 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2184 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2185 |  |  | 							var id = $(item).attr('id'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2186 |  |  | 							 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2187 |  |  | 							if ((typeof id != 'undefined' && id.indexOf('row-') >= 0) || $(item).hasClass('liste_titre')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2188 |  |  | 							{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2189 |  |  | 								$(item).children('td:last-child').before('<td class="subtotal_nc"></td>'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2190 |  |  | 								 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2191 |  |  | 								if ($(item).attr('rel') != 'subtotal' && typeof $(item).attr('id') != 'undefined') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2192 |  |  | 								{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2193 |  |  | 									var idSplit = $(item).attr('id').split('-'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2194 |  |  | 									$(item).children('td.subtotal_nc').append($('<input type="checkbox" id="subtotal_nc-'+idSplit[1]+'" class="subtotal_nc_chkbx" data-lineid="'+idSplit[1]+'" value="1" '+(typeof subtotal_TSubNc[idSplit[1]] != 'undefined' && subtotal_TSubNc[idSplit[1]] == 1 ? 'checked="checked"' : '')+' />')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2195 |  |  | 								} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2196 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2197 |  |  | 							else  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2198 |  |  | 							{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2199 |  |  | 								$(item).append('<td class="subtotal_nc"></td>'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2200 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2201 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2202 |  |  | 					}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2203 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2204 |  |  | 					$('#tablelines tbody tr.liste_titre:first .subtotal_nc').html(<?php echo json_encode($form->textwithtooltip($langs->trans('subtotal_nc_title'), $langs->trans('subtotal_nc_title_help'))); ?>); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2205 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2206 |  |  | 					function callAjaxUpdateLineNC(set, lineid, subtotal_nc) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2207 |  |  | 					{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2208 |  |  | 						$.ajax({ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2209 |  |  | 							url: '<?php echo dol_buildpath('/subtotal/script/interface.php', 1); ?>' | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2210 |  |  | 							,type: 'POST' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2211 |  |  | 							,data: { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2212 |  |  | 								json:1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2213 |  |  | 								,set: set | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2214 |  |  | 								,element: '<?php echo $object->element; ?>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2215 |  |  | 								,elementid: <?php echo (int) $object->id; ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2216 |  |  | 								,lineid: lineid | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2217 |  |  | 								,subtotal_nc: subtotal_nc | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2218 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2219 |  |  | 						}).done(function(response) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2220 |  |  | 							window.location.href = window.location.pathname + '?id=<?php echo $object->id; ?>&page_y=' + window.pageYOffset; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2221 |  |  | 						}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2222 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2223 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2224 |  |  | 					$(".subtotal_nc_chkbx").change(function(event) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2225 |  |  | 						var lineid = $(this).data('lineid'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2226 |  |  | 						var subtotal_nc = 0 | $(this).is(':checked'); // Renvoi 0 ou 1  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2227 |  |  | 						 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2228 |  |  | 						callAjaxUpdateLineNC('updateLineNC', lineid, subtotal_nc); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2229 |  |  | 					}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2230 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2231 |  |  | 				}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2232 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2233 |  |  | 			</script> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2234 |  |  | 			<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2235 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2236 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2237 |  |  | 		$this->_ajax_block_order_js($object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2238 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2239 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2240 |  |  | 	function afterPDFCreation($parameters, &$pdf, &$action, $hookmanager) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2241 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2242 |  |  | 		global $conf; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2243 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2244 |  |  | 		$object = $parameters['object']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2245 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2246 |  |  | 		if ((!empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP) && $object->element == 'propal') || (!empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP) && $object->element == 'commande') || (!empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP) && $object->element == 'facture')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2247 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2248 |  |  | 			if (GETPOST('subtotal_add_recap')) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2249 |  |  | 				dol_include_once('/subtotal/class/subtotal.class.php'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2250 |  |  | 				TSubtotal::addRecapPage($parameters, $pdf); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2251 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2252 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2253 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2254 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2255 |  |  | 	// HTML 5 data for js | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2256 |  |  | 	private function _getHtmlData($parameters, &$object, &$action, $hookmanager) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2257 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2258 |  |  | 		dol_include_once('/subtotal/class/subtotal.class.php'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2259 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2260 |  |  | 	    $line = &$parameters['line']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2261 |  |  | 	     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2262 |  |  | 	    $ThtmlData['data-id']           = $line->id; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2263 |  |  | 	    $ThtmlData['data-product_type'] = $line->product_type; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2264 |  |  | 	    $ThtmlData['data-qty']          = 0; //$line->qty; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2265 |  |  | 	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2266 |  |  | 	     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2267 |  |  | 	    if(TSubtotal::isTitle($line)){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2268 |  |  | 	        $ThtmlData['data-issubtotal'] = 'title'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2269 |  |  | 	    }elseif(TSubtotal::isSubtotal($line)){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2270 |  |  | 	        $ThtmlData['data-issubtotal'] = 'subtotal'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2271 |  |  | 	    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2272 |  |  | 	    else{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2273 |  |  | 	        $ThtmlData['data-issubtotal'] = 'freetext'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2274 |  |  | 	    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2275 |  |  | 	     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2276 |  |  | 	     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2277 |  |  | 	    // Change or add data  from hooks | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2278 |  |  | 	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2279 |  |  | 	     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2280 |  |  | 	    // hook  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2281 |  |  | 	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2282 |  |  | 	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2283 |  |  | 	    if ($reshook>0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2284 |  |  | 	    { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2285 |  |  | 	        $ThtmlData = $hookmanager->resArray; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2286 |  |  | 	    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2287 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2288 |  |  | 	    return $this->implodeHtmlData($ThtmlData); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2289 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2290 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2291 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2292 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2293 |  |  | 	function implodeHtmlData($ThtmlData = array()) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2294 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2295 |  |  | 	    $data = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2296 |  |  | 	    foreach($ThtmlData as $k => $h ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2297 |  |  | 	    { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2298 |  |  | 	        if(is_array($h)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2299 |  |  | 	        { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2300 |  |  | 	            $h = json_encode($h); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2301 |  |  | 	        } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2302 |  |  | 	         | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2303 |  |  | 	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" '; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2304 |  |  | 	    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2305 |  |  | 	     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2306 |  |  | 	    return $data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2307 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2308 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2309 |  |  | 	function _ajax_block_order_js($object) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2310 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2311 |  |  | 	    global $conf,$tagidfortablednd,$filepath,$langs; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2312 |  |  | 	     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2313 |  |  | 	    /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2314 |  |  | 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2315 |  |  | 	     * for compatibility reasons we don't use tableDnD but jquery sortable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2316 |  |  | 	     */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2317 |  |  | 	     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2318 |  |  | 	    $id=$object->id; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2319 |  |  | 	    $nboflines=(isset($object->lines)?count($object->lines):0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2320 |  |  | 	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2321 |  |  | 	     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2322 |  |  | 	    $id=$object->id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2323 |  |  | 	    $fk_element=$object->fk_element; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2324 |  |  | 	    $table_element_line=$object->table_element_line; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2325 |  |  | 	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2326 |  |  | 	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2327 |  |  | 	    $filepath=(empty($filepath)?'':$filepath); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2328 |  |  | 	     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2329 |  |  | 	     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2330 |  |  | 	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2331 |  |  | 	    { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2332 |  |  | 	         | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2333 |  |  | 	        ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2334 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2335 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2336 |  |  | 			<script type="text/javascript"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2337 |  |  | 			$(document).ready(function(){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2338 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2339 |  |  | 				// target some elements | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2340 |  |  | 				var titleRow = $('tr[data-issubtotal="title"]'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2341 |  |  | 				var lastTitleCol = titleRow.find('td:last-child'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2342 |  |  | 				var moveBlockCol= titleRow.find('td.liencolht'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2343 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2344 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2345 |  |  | 				moveBlockCol.disableSelection(); // prevent selection | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2346 |  |  | <?php if ($object->statut == 0) { ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2347 |  |  | 				// apply some graphical stuff | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2348 |  |  | 				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png',2);  ?>)'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2349 |  |  | 				moveBlockCol.css("background-repeat","no-repeat"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2350 |  |  | 				moveBlockCol.css("background-position","center center"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2351 |  |  | 				moveBlockCol.css("cursor","move"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2352 |  |  | 				titleRow.attr('title', '<?php echo html_entity_decode($langs->trans('MoveTitleBlock')); ?>'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2353 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2354 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2355 |  |  |  				$( "#<?php echo $tagidfortablednd; ?>" ).sortable({ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2356 |  |  | 			    	  cursor: "move", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2357 |  |  | 			    	  handle: ".movetitleblock", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2358 |  |  | 			    	  items: 'tr:not(.nodrag,.nodrop,.noblockdrop)', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2359 |  |  | 			    	  delay: 150, //Needed to prevent accidental drag when trying to select | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2360 |  |  | 			    	  opacity: 0.8, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2361 |  |  | 			    	  axis: "y", // limit y axis | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2362 |  |  | 			    	  placeholder: "ui-state-highlight", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2363 |  |  | 			    	  start: function( event, ui ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2364 |  |  | 			    	      //console.log('X:' + e.screenX, 'Y:' + e.screenY); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2365 |  |  | 			    		  //console.log(ui.item); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2366 |  |  | 			    		  var colCount = ui.item.children().length; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2367 |  |  |    						  ui.placeholder.html('<td colspan="'+colCount+'"> </td>'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2368 |  |  |    		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2369 |  |  | 			    		  var TcurrentChilds = getSubtotalTitleChilds(ui.item); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2370 |  |  | 			    		  ui.item.data('childrens',TcurrentChilds); // store data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2371 |  |  | 				    		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2372 |  |  | 			    		  for (var key in TcurrentChilds) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2373 |  |  | 			    			  $('#'+ TcurrentChilds[key]).addClass('noblockdrop');//'#row-'+  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2374 |  |  | 			    			  $('#'+ TcurrentChilds[key]).fadeOut();//'#row-'+  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2375 |  |  | 			    		  } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2376 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2377 |  |  | 			    		  $(this).sortable("refresh");	// "refresh" of source sortable is required to make "disable" work! | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2378 |  |  | 			    	       | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2379 |  |  | 			    	    }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2380 |  |  | 				    	stop: function (event, ui) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2381 |  |  | 							// call we element is droped | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2382 |  |  | 				    	  	$('.noblockdrop').removeClass('noblockdrop'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2383 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2384 |  |  | 				    	  	var TcurrentChilds = ui.item.data('childrens'); // reload child list from data and not attr to prevent load error | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2385 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2386 |  |  | 							for (var i =TcurrentChilds.length ; i >= 0; i--) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2387 |  |  | 				    			  $('#'+ TcurrentChilds[i]).insertAfter(ui.item); //'#row-'+  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2388 |  |  | 				    			  $('#'+ TcurrentChilds[i]).fadeIn(); //'#row-'+  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2389 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2390 |  |  | 							console.log('onstop'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2391 |  |  | 							console.log(cleanSerialize($(this).sortable('serialize'))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2392 |  |  | 							 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2393 |  |  | 							$.ajax({ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2394 |  |  | 			    	            data: { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2395 |  |  | 									objet_id: <?php print $object->id; ?>, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2396 |  |  | 							    	roworder: cleanSerialize($(this).sortable('serialize')), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2397 |  |  | 									table_element_line: "<?php echo $table_element_line; ?>", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2398 |  |  | 									fk_element: "<?php echo $fk_element; ?>", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2399 |  |  | 									element_id: "<?php echo $id; ?>", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2400 |  |  | 									filepath: "<?php echo urlencode($filepath); ?>" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2401 |  |  | 								}, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2402 |  |  | 			    	            type: 'POST', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2403 |  |  | 			    	            url: '<?php echo DOL_URL_ROOT; ?>/core/ajax/row.php', | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2404 |  |  | 			    	            success: function(data) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2405 |  |  | 			    	                console.log(data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2406 |  |  | 			    	            }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2407 |  |  | 			    	        }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2408 |  |  | 			    	         | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2409 |  |  | 			    	  }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2410 |  |  | 			    	  update: function (event, ui) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2411 |  |  | 				    	   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2412 |  |  | 			    	        // POST to server using $.post or $.ajax | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2413 |  |  | 				    	  	$('.noblockdrop').removeClass('noblockdrop'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2414 |  |  | 							//console.log('onupdate'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2415 |  |  | 			    	        //console.log(cleanSerialize($(this).sortable('serialize'))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2416 |  |  | 			    	    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2417 |  |  | 			    }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2418 |  |  |  				<?php } ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2419 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2420 |  |  | 				function getSubtotalTitleChilds(item) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2421 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2422 |  |  | 		    		var TcurrentChilds = []; // = JSON.parse(item.attr('data-childrens')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2423 |  |  | 		    		var level = item.data('level'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2424 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2425 |  |  | 		    		var indexOfFirstSubtotal = -1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2426 |  |  | 		    		var indexOfFirstTitle = -1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2427 |  |  | 		    		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2428 |  |  | 		    		item.nextAll('[id^="row-"]').each(function(index){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2429 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2430 |  |  | 						var dataLevel = $(this).attr('data-level'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2431 |  |  | 						var dataIsSubtotal = $(this).attr('data-issubtotal'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2432 |  |  | 						 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2433 |  |  | 						if(dataIsSubtotal != 'undefined' && dataLevel != 'undefined' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2434 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2435 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2436 |  |  | 							if(dataLevel <=  level && indexOfFirstSubtotal < 0 && dataIsSubtotal == 'subtotal' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2437 |  |  | 							{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2438 |  |  | 								indexOfFirstSubtotal = index; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2439 |  |  | 								if(indexOfFirstTitle < 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2440 |  |  | 								{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2441 |  |  | 									TcurrentChilds.push($(this).attr('id')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2442 |  |  | 								} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2443 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2444 |  |  | 							 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2445 |  |  | 							if(dataLevel <=  level && indexOfFirstSubtotal < 0 && indexOfFirstTitle < 0 && dataIsSubtotal == 'title' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2446 |  |  | 							{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2447 |  |  | 								indexOfFirstTitle = index; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2448 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2449 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2450 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2451 |  |  | 						if(indexOfFirstTitle < 0 && indexOfFirstSubtotal < 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2452 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2453 |  |  | 							TcurrentChilds.push($(this).attr('id')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2454 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2455 |  |  | 							// Add extraffield support for dolibarr > 7 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2456 |  |  | 							var thisId = $(this).attr('data-id'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2457 |  |  | 							var thisElement = $(this).attr('data-element'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2458 |  |  | 							if(thisId != undefined && thisElement != undefined ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2459 |  |  | 							{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2460 |  |  | 								$('[data-targetid="' + thisId + '"][data-element="extrafield"][data-targetelement="'+ thisElement +'"]').each(function(index){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2461 |  |  | 									TcurrentChilds.push($(this).attr('id')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2462 |  |  | 								}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2463 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2464 |  |  | 							 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2465 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2466 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2467 |  |  | 		    		}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2468 |  |  | 		    		return TcurrentChilds; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2469 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2470 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2471 |  |  | 			}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2472 |  |  | 			</script> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2473 |  |  | 			<style type="text/css" > | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2474 |  |  |           | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2475 |  |  |             tr.ui-state-highlight td{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2476 |  |  |             	border: 1px solid #dad55e; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2477 |  |  |             	background: #fffa90; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2478 |  |  |             	color: #777620; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2479 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2480 |  |  |             </style> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2481 |  |  | 		<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2482 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2483 |  |  | 		}  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2484 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2485 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2486 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2487 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2488 |  |  | 	 | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 2489 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 2490 |  |  |  | 
            
                        
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.