Passed
Push — master ( a56e33...222e44 )
by Alxarafe
36:56
created
dolibarr/htdocs/core/tpl/ajax/objectlinked_lineimport.tpl.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@
 block discarded – undo
18 18
 // Protection to avoid direct call of template
19 19
 if (empty($conf) || ! is_object($conf))
20 20
 {
21
-	print "Error, template page can't be called as URL";
22
-	exit;
21
+    print "Error, template page can't be called as URL";
22
+    exit;
23 23
 }
24 24
 
25 25
 $objectUrl = $object->getNomUrl(0,'',0,1);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/tpl/ajaxrow.tpl.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@
 block discarded – undo
28 28
 // Protection to avoid direct call of template
29 29
 if (empty($object) || ! is_object($object))
30 30
 {
31
-	print "Error, template page can't be called as URL";
32
-	exit;
31
+    print "Error, template page can't be called as URL";
32
+    exit;
33 33
 }
34 34
 
35 35
 ?>
Please login to merge, or discard this patch.
dolibarr/htdocs/core/tpl/admin_extrafields_edit.tpl.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 // Protection to avoid direct call of template
30 30
 if (empty($conf) || ! is_object($conf))
31 31
 {
32
-	print "Error, template page can't be called as URL";
33
-	exit;
32
+    print "Error, template page can't be called as URL";
33
+    exit;
34 34
 }
35 35
 
36 36
 
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
     		var list = jQuery("#list");
55 55
             var totalizable = jQuery("#totalizable");
56 56
     		<?php
57
-    		if((GETPOST('type','alpha') != "select") &&  (GETPOST('type','alpha') != "sellist"))
58
-    		{
59
-    			print 'jQuery("#value_choice").hide();';
60
-    		}
57
+            if((GETPOST('type','alpha') != "select") &&  (GETPOST('type','alpha') != "sellist"))
58
+            {
59
+                print 'jQuery("#value_choice").hide();';
60
+            }
61 61
 
62
-    		if (GETPOST('type','alpha') == "separate")
63
-    		{
64
-				print "jQuery('#size, #default_value, #langfile').val('').prop('disabled', true);";
65
-    			print 'jQuery("#value_choice").hide();';
66
-    		}
67
-    		?>
62
+            if (GETPOST('type','alpha') == "separate")
63
+            {
64
+                print "jQuery('#size, #default_value, #langfile').val('').prop('disabled', true);";
65
+                print 'jQuery("#value_choice").hide();';
66
+            }
67
+            ?>
68 68
 
69 69
     		// Case of computed field
70 70
     		if (type == 'varchar' || type == 'int' || type == 'double' || type == 'price') {
@@ -164,19 +164,19 @@  discard block
 block discarded – undo
164 164
 
165 165
 if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param))
166 166
 {
167
-	$param_chain = '';
168
-	foreach ($param['options'] as $key => $value)
169
-	{
170
-		if(strlen($key))
171
-		{
172
-			$param_chain .= $key.','.$value."\n";
173
-		}
174
-	}
167
+    $param_chain = '';
168
+    foreach ($param['options'] as $key => $value)
169
+    {
170
+        if(strlen($key))
171
+        {
172
+            $param_chain .= $key.','.$value."\n";
173
+        }
174
+    }
175 175
 }
176 176
 elseif (($type== 'sellist') || ($type == 'chkbxlst') || ($type == 'link') || ($type == 'password'))
177 177
 {
178
-	$paramlist=array_keys($param['options']);
179
-	$param_chain = $paramlist[0];
178
+    $paramlist=array_keys($param['options']);
179
+    $param_chain = $paramlist[0];
180 180
 }
181 181
 ?>
182 182
 <!-- Label -->
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
 <?php
189 189
 // Define list of possible type transition
190 190
 $typewecanchangeinto=array(
191
-	'varchar'=>array('varchar', 'phone', 'mail', 'url', 'select', 'password', 'text', 'html'),
192
-	'text'=>array('text','html'),
193
-	'html'=>array('text','html'),
194
-	'password'=>array('password', 'varchar'),
195
-	'mail'=>array('varchar', 'phone', 'mail', 'url', 'select'),
191
+    'varchar'=>array('varchar', 'phone', 'mail', 'url', 'select', 'password', 'text', 'html'),
192
+    'text'=>array('text','html'),
193
+    'html'=>array('text','html'),
194
+    'password'=>array('password', 'varchar'),
195
+    'mail'=>array('varchar', 'phone', 'mail', 'url', 'select'),
196 196
     'url'=>array('varchar', 'phone', 'mail', 'url', 'select'),
197 197
     'phone'=>array('varchar', 'phone', 'mail', 'url', 'select'),
198 198
     'select'=>array('varchar', 'phone', 'mail', 'url', 'select')
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 }
213 213
 else
214 214
 {
215
-	print $type2label[$type];
215
+    print $type2label[$type];
216 216
     print '<input type="hidden" name="type" id="type" value="'.$type.'">';
217 217
 }
218 218
 ?>
Please login to merge, or discard this patch.
dolibarr/htdocs/core/tpl/document_actions_post_headers.tpl.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
 // Protection to avoid direct call of template
28 28
 if (empty($langs) || ! is_object($langs))
29 29
 {
30
-	print "Error, template page can't be called as URL";
31
-	exit;
30
+    print "Error, template page can't be called as URL";
31
+    exit;
32 32
 }
33 33
 
34 34
 
@@ -51,16 +51,16 @@  discard block
 block discarded – undo
51 51
 
52 52
 if ($action == 'delete')
53 53
 {
54
-	$langs->load("companies");	// Need for string DeleteFile+ConfirmDeleteFiles
55
-	print $form->formconfirm(
56
-			$_SERVER["PHP_SELF"] . '?id=' . $object->id . '&urlfile=' . urlencode(GETPOST("urlfile")) . '&linkid=' . GETPOST('linkid', 'int') . (empty($param)?'':$param),
57
-			$langs->trans('DeleteFile'),
58
-			$langs->trans('ConfirmDeleteFile'),
59
-			'confirm_deletefile',
60
-			'',
61
-			0,
62
-			1
63
-	);
54
+    $langs->load("companies");	// Need for string DeleteFile+ConfirmDeleteFiles
55
+    print $form->formconfirm(
56
+            $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&urlfile=' . urlencode(GETPOST("urlfile")) . '&linkid=' . GETPOST('linkid', 'int') . (empty($param)?'':$param),
57
+            $langs->trans('DeleteFile'),
58
+            $langs->trans('ConfirmDeleteFile'),
59
+            'confirm_deletefile',
60
+            '',
61
+            0,
62
+            1
63
+    );
64 64
 }
65 65
 
66 66
 $formfile=new FormFile($db);
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 $savingdocmask='';
70 70
 if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX))
71 71
 {
72
-	//var_dump($modulepart);
73
-	if (in_array($modulepart,array('facture_fournisseur','commande_fournisseur','facture','commande','propal','supplier_proposal','ficheinter','contract','expedition','project','project_task','expensereport','tax', 'produit', 'product_batch')))
74
-	{
75
-		$savingdocmask=dol_sanitizeFileName($object->ref).'-__file__';
76
-	}
77
-	/*if (in_array($modulepart,array('member')))
72
+    //var_dump($modulepart);
73
+    if (in_array($modulepart,array('facture_fournisseur','commande_fournisseur','facture','commande','propal','supplier_proposal','ficheinter','contract','expedition','project','project_task','expensereport','tax', 'produit', 'product_batch')))
74
+    {
75
+        $savingdocmask=dol_sanitizeFileName($object->ref).'-__file__';
76
+    }
77
+    /*if (in_array($modulepart,array('member')))
78 78
 	{
79 79
 		$savingdocmask=$object->login.'___file__';
80 80
 	}*/
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
     $permission,
90 90
     $conf->browser->layout == 'phone' ? 40 : 60,
91 91
     $object,
92
-	'',
93
-	1,
94
-	$savingdocmask
92
+    '',
93
+    1,
94
+    $savingdocmask
95 95
 );
96 96
 
97 97
 // List of document
Please login to merge, or discard this patch.
dolibarr/htdocs/core/tpl/objectline_create.tpl.php 1 patch
Indentation   +343 added lines, -343 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 // Protection to avoid direct call of template
36 36
 if (empty($object) || ! is_object($object))
37 37
 {
38
-	print "Error, template page can't be called as URL";
39
-	exit;
38
+    print "Error, template page can't be called as URL";
39
+    exit;
40 40
 }
41 41
 
42 42
 
@@ -65,30 +65,30 @@  discard block
 block discarded – undo
65 65
 $objectline = null;
66 66
 if (!empty($extrafieldsline))
67 67
 {
68
-	if ($this->table_element_line=='commandedet') {
69
-		$objectline = new OrderLine($this->db);
70
-	}
71
-	elseif ($this->table_element_line=='propaldet') {
72
-		$objectline = new PropaleLigne($this->db);
73
-	}
74
-	elseif ($this->table_element_line=='supplier_proposaldet') {
75
-		$objectline = new SupplierProposalLine($this->db);
76
-	}
77
-	elseif ($this->table_element_line=='facturedet') {
78
-		$objectline = new FactureLigne($this->db);
79
-	}
80
-	elseif ($this->table_element_line=='contratdet') {
81
-		$objectline = new ContratLigne($this->db);
82
-	}
83
-	elseif ($this->table_element_line=='commande_fournisseurdet') {
84
-		$objectline = new CommandeFournisseurLigne($this->db);
85
-	}
86
-	elseif ($this->table_element_line=='facture_fourn_det') {
87
-		$objectline = new SupplierInvoiceLine($this->db);
88
-	}
89
-	elseif ($this->table_element_line=='facturedet_rec') {
90
-		$objectline = new FactureLigneRec($this->db);
91
-	}
68
+    if ($this->table_element_line=='commandedet') {
69
+        $objectline = new OrderLine($this->db);
70
+    }
71
+    elseif ($this->table_element_line=='propaldet') {
72
+        $objectline = new PropaleLigne($this->db);
73
+    }
74
+    elseif ($this->table_element_line=='supplier_proposaldet') {
75
+        $objectline = new SupplierProposalLine($this->db);
76
+    }
77
+    elseif ($this->table_element_line=='facturedet') {
78
+        $objectline = new FactureLigne($this->db);
79
+    }
80
+    elseif ($this->table_element_line=='contratdet') {
81
+        $objectline = new ContratLigne($this->db);
82
+    }
83
+    elseif ($this->table_element_line=='commande_fournisseurdet') {
84
+        $objectline = new CommandeFournisseurLigne($this->db);
85
+    }
86
+    elseif ($this->table_element_line=='facture_fourn_det') {
87
+        $objectline = new SupplierInvoiceLine($this->db);
88
+    }
89
+    elseif ($this->table_element_line=='facturedet_rec') {
90
+        $objectline = new FactureLigneRec($this->db);
91
+    }
92 92
 }
93 93
 
94 94
 ?>
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
 	<div id="add"></div><span class="hideonsmartphone"><?php echo $langs->trans('AddNewLine'); ?></span><?php // echo $langs->trans("FreeZone"); ?>
107 107
 	</td>
108 108
 	<?php
109
-	if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier')	// We must have same test in printObjectLines
110
-	{
111
-	?>
109
+    if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier')	// We must have same test in printObjectLines
110
+    {
111
+    ?>
112 112
 		<td class="linecolrefsupplier"><span id="title_fourn_ref"><?php echo $langs->trans('SupplierRef'); ?></span></td>
113 113
 	<?php } ?>
114 114
 	<td class="linecolvat" align="right"><span id="title_vat"><?php echo $langs->trans('VAT'); ?></span></td>
@@ -121,39 +121,39 @@  discard block
 block discarded – undo
121 121
 	<?php } ?>
122 122
 	<td class="linecolqty" align="right"><?php echo $langs->trans('Qty'); ?></td>
123 123
 	<?php
124
-	if($conf->global->PRODUCT_USE_UNITS)
125
-	{
126
-		print '<td class="linecoluseunit" align="left">';
127
-		print '<span id="title_units">';
128
-		print $langs->trans('Unit');
129
-		print '</span></td>';
130
-	}
131
-	?>
124
+    if($conf->global->PRODUCT_USE_UNITS)
125
+    {
126
+        print '<td class="linecoluseunit" align="left">';
127
+        print '<span id="title_units">';
128
+        print $langs->trans('Unit');
129
+        print '</span></td>';
130
+    }
131
+    ?>
132 132
 	<td class="linecoldiscount" align="right"><?php echo $langs->trans('ReductionShort'); ?></td>
133 133
 	<?php
134
-	if ($this->situation_cycle_ref) {
135
-		print '<td class="linecolcycleref" align="right">' . $langs->trans('Progress') . '</td>';
136
-	}
137
-	if (! empty($usemargins))
138
-	{
139
-		if (!empty($user->rights->margins->creer)) {
140
-		?>
134
+    if ($this->situation_cycle_ref) {
135
+        print '<td class="linecolcycleref" align="right">' . $langs->trans('Progress') . '</td>';
136
+    }
137
+    if (! empty($usemargins))
138
+    {
139
+        if (!empty($user->rights->margins->creer)) {
140
+        ?>
141 141
 		<td align="right" class="margininfos linecolmargin1">
142 142
 		<?php
143
-		}
144
-		else $colspan++;
143
+        }
144
+        else $colspan++;
145 145
 
146
-		if ($conf->global->MARGIN_TYPE == "1")
147
-			echo $langs->trans('BuyingPrice');
148
-		else
149
-			echo $langs->trans('CostPrice');
150
-		?>
146
+        if ($conf->global->MARGIN_TYPE == "1")
147
+            echo $langs->trans('BuyingPrice');
148
+        else
149
+            echo $langs->trans('CostPrice');
150
+        ?>
151 151
 		</td>
152 152
 		<?php
153
-		if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARGIN_RATES)) echo '<td align="right" class="margininfos linecolmargin2"><span class="np_marginRate">'.$langs->trans('MarginRate').'</span></td>';
154
-		if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARK_RATES)) 	echo '<td align="right" class="margininfos linecolmargin2"><span class="np_markRate">'.$langs->trans('MarkRate').'</span></td>';
155
-	}
156
-	?>
153
+        if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARGIN_RATES)) echo '<td align="right" class="margininfos linecolmargin2"><span class="np_marginRate">'.$langs->trans('MarginRate').'</span></td>';
154
+        if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARK_RATES)) 	echo '<td align="right" class="margininfos linecolmargin2"><span class="np_markRate">'.$langs->trans('MarkRate').'</span></td>';
155
+    }
156
+    ?>
157 157
 	<td class="linecoledit" colspan="<?php echo $colspan; ?>">&nbsp;</td>
158 158
 </tr>
159 159
 <?php
@@ -163,13 +163,13 @@  discard block
 block discarded – undo
163 163
 <?php
164 164
 // Adds a line numbering column
165 165
 if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
166
-	$coldisplay=2;
167
-	?>
166
+    $coldisplay=2;
167
+    ?>
168 168
 	<td class="nobottom linecolnum" align="center" width="5"></td>
169 169
 	<?php
170 170
 }
171 171
 else {
172
-	$coldisplay=0;
172
+    $coldisplay=0;
173 173
 }
174 174
 ?>
175 175
 
@@ -177,172 +177,172 @@  discard block
 block discarded – undo
177 177
 
178 178
 	<?php
179 179
 
180
-	$freelines = false;
181
-	if (empty($conf->global->MAIN_DISABLE_FREE_LINES))
182
-	{
183
-		$freelines = true;
184
-		$forceall=1;	// We always force all type for free lines (module product or service means we use predefined product or service)
185
-		if ($object->element == 'contrat')
186
-		{
187
-			if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=-1;	// With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set
188
-			else if (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=3;
189
-		}
180
+    $freelines = false;
181
+    if (empty($conf->global->MAIN_DISABLE_FREE_LINES))
182
+    {
183
+        $freelines = true;
184
+        $forceall=1;	// We always force all type for free lines (module product or service means we use predefined product or service)
185
+        if ($object->element == 'contrat')
186
+        {
187
+            if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=-1;	// With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set
188
+            else if (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=3;
189
+        }
190 190
 
191
-		// Free line
192
-		echo '<span class="prod_entry_mode_free">';
193
-		// Show radio free line
194
-		if ($forceall >= 0 && (! empty($conf->product->enabled) || ! empty($conf->service->enabled)))
195
-		{
196
-			echo '<label for="prod_entry_mode_free">';
197
-			echo '<input type="radio" class="prod_entry_mode_free" name="prod_entry_mode" id="prod_entry_mode_free" value="free"';
198
-			//echo (GETPOST('prod_entry_mode')=='free' ? ' checked' : ((empty($forceall) && (empty($conf->product->enabled) || empty($conf->service->enabled)))?' checked':'') );
199
-			echo (GETPOST('prod_entry_mode')=='free' ? ' checked' : '');
200
-			echo '> ';
201
-			// Show type selector
202
-			echo $langs->trans("FreeLineOfType");
203
-			echo '</label>';
204
-			echo ' ';
205
-		}
206
-		else
207
-		{
208
-			echo '<input type="hidden" id="prod_entry_mode_free" name="prod_entry_mode" value="free">';
209
-			// Show type selector
210
-			if ($forceall >= 0)
211
-			{
212
-			    if (empty($conf->product->enabled) || empty($conf->service->enabled)) echo $langs->trans("Type");
213
-				else echo $langs->trans("FreeLineOfType");
214
-				echo ' ';
215
-			}
216
-		}
191
+        // Free line
192
+        echo '<span class="prod_entry_mode_free">';
193
+        // Show radio free line
194
+        if ($forceall >= 0 && (! empty($conf->product->enabled) || ! empty($conf->service->enabled)))
195
+        {
196
+            echo '<label for="prod_entry_mode_free">';
197
+            echo '<input type="radio" class="prod_entry_mode_free" name="prod_entry_mode" id="prod_entry_mode_free" value="free"';
198
+            //echo (GETPOST('prod_entry_mode')=='free' ? ' checked' : ((empty($forceall) && (empty($conf->product->enabled) || empty($conf->service->enabled)))?' checked':'') );
199
+            echo (GETPOST('prod_entry_mode')=='free' ? ' checked' : '');
200
+            echo '> ';
201
+            // Show type selector
202
+            echo $langs->trans("FreeLineOfType");
203
+            echo '</label>';
204
+            echo ' ';
205
+        }
206
+        else
207
+        {
208
+            echo '<input type="hidden" id="prod_entry_mode_free" name="prod_entry_mode" value="free">';
209
+            // Show type selector
210
+            if ($forceall >= 0)
211
+            {
212
+                if (empty($conf->product->enabled) || empty($conf->service->enabled)) echo $langs->trans("Type");
213
+                else echo $langs->trans("FreeLineOfType");
214
+                echo ' ';
215
+            }
216
+        }
217 217
 
218
-		echo $form->select_type_of_lines(isset($_POST["type"])?GETPOST("type",'alpha',2):-1,'type',1,1,$forceall);
218
+        echo $form->select_type_of_lines(isset($_POST["type"])?GETPOST("type",'alpha',2):-1,'type',1,1,$forceall);
219 219
 
220
-		echo '</span>';
221
-	}
220
+        echo '</span>';
221
+    }
222 222
 
223
-	// Predefined product/service
224
-	if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
225
-	{
226
-		if ($forceall >= 0 && $freelines) echo '<br>';
227
-		echo '<span class="prod_entry_mode_predef">';
228
-		echo '<label for="prod_entry_mode_predef">';
229
-		echo '<input type="radio" class="prod_entry_mode_predef" name="prod_entry_mode" id="prod_entry_mode_predef" value="predef"'.(GETPOST('prod_entry_mode')=='predef'?' checked':'').'> ';
230
-		if (empty($senderissupplier))
231
-		{
232
-			if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('PredefinedProductsToSell');
233
-			else if ((empty($conf->product->enabled) && ! empty($conf->service->enabled)) || ($object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS))) echo $langs->trans('PredefinedServicesToSell');
234
-			else echo $langs->trans('PredefinedProductsAndServicesToSell');
235
-		}
236
-		else
237
-		{
238
-			if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('PredefinedProductsToPurchase');
239
-			else if (empty($conf->product->enabled) && ! empty($conf->service->enabled)) echo $langs->trans('PredefinedServicesToPurchase');
240
-			else echo $langs->trans('PredefinedProductsAndServicesToPurchase');
241
-		}
242
-		echo '</label>';
243
-		echo ' ';
223
+    // Predefined product/service
224
+    if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
225
+    {
226
+        if ($forceall >= 0 && $freelines) echo '<br>';
227
+        echo '<span class="prod_entry_mode_predef">';
228
+        echo '<label for="prod_entry_mode_predef">';
229
+        echo '<input type="radio" class="prod_entry_mode_predef" name="prod_entry_mode" id="prod_entry_mode_predef" value="predef"'.(GETPOST('prod_entry_mode')=='predef'?' checked':'').'> ';
230
+        if (empty($senderissupplier))
231
+        {
232
+            if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('PredefinedProductsToSell');
233
+            else if ((empty($conf->product->enabled) && ! empty($conf->service->enabled)) || ($object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS))) echo $langs->trans('PredefinedServicesToSell');
234
+            else echo $langs->trans('PredefinedProductsAndServicesToSell');
235
+        }
236
+        else
237
+        {
238
+            if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('PredefinedProductsToPurchase');
239
+            else if (empty($conf->product->enabled) && ! empty($conf->service->enabled)) echo $langs->trans('PredefinedServicesToPurchase');
240
+            else echo $langs->trans('PredefinedProductsAndServicesToPurchase');
241
+        }
242
+        echo '</label>';
243
+        echo ' ';
244 244
 
245
-		$filtertype='';
246
-		if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1';
245
+        $filtertype='';
246
+        if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1';
247 247
 
248
-		if (empty($senderissupplier))
249
-		{
250
-			if (! empty($conf->global->ENTREPOT_EXTRA_STATUS))
251
-			{
252
-				// hide products in closed warehouse, but show products for internal transfer
253
-				$form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array'));
254
-			}
255
-			else
256
-			{
257
-				$form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, '', GETPOST('combinations', 'array'));
258
-			}
259
-		}
260
-		else
261
-		{
262
-			// $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum
263
-		    if ($senderissupplier != 2)
264
-		    {
265
-    			$ajaxoptions=array(
266
-    					'update' => array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'),	// html id tags that will be edited with which ajax json response key
267
-    					'option_disabled' => 'idthatdoesnotexists',					// html id to disable once select is done
268
-    					'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for exemple shown we select a disabled option into combo)
269
-    			);
270
-    			$alsoproductwithnosupplierprice=0;
271
-		    }
272
-		    else
273
-		    {
274
-		        $ajaxoptions = array();
275
-		        $alsoproductwithnosupplierprice=1;
276
-		    }
277
-
278
-			$form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice);
279
-		}
280
-		echo '<input type="hidden" name="pbq" id="pbq" value="">';
281
-		echo '</span>';
282
-	}
248
+        if (empty($senderissupplier))
249
+        {
250
+            if (! empty($conf->global->ENTREPOT_EXTRA_STATUS))
251
+            {
252
+                // hide products in closed warehouse, but show products for internal transfer
253
+                $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array'));
254
+            }
255
+            else
256
+            {
257
+                $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, '', GETPOST('combinations', 'array'));
258
+            }
259
+        }
260
+        else
261
+        {
262
+            // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum
263
+            if ($senderissupplier != 2)
264
+            {
265
+                $ajaxoptions=array(
266
+                        'update' => array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'),	// html id tags that will be edited with which ajax json response key
267
+                        'option_disabled' => 'idthatdoesnotexists',					// html id to disable once select is done
268
+                        'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for exemple shown we select a disabled option into combo)
269
+                );
270
+                $alsoproductwithnosupplierprice=0;
271
+            }
272
+            else
273
+            {
274
+                $ajaxoptions = array();
275
+                $alsoproductwithnosupplierprice=1;
276
+            }
283 277
 
284
-	if (is_object($hookmanager) && empty($senderissupplier))
285
-	{
286
-        $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line','int'));
287
-		$reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action);
288
-		if (!empty($hookmanager->resPrint)) {
289
-			print $hookmanager->resPrint;
290
-		}
291
-	}
292
-	if (is_object($hookmanager) && ! empty($senderissupplier))
293
-	{
294
-		$parameters=array('htmlname'=>'addproduct');
295
-		$reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions',$parameters,$object,$action);
296
-		if (!empty($hookmanager->resPrint)) {
297
-			print $hookmanager->resPrint;
298
-		}
299
-	}
278
+            $form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice);
279
+        }
280
+        echo '<input type="hidden" name="pbq" id="pbq" value="">';
281
+        echo '</span>';
282
+    }
300 283
 
284
+    if (is_object($hookmanager) && empty($senderissupplier))
285
+    {
286
+        $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line','int'));
287
+        $reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action);
288
+        if (!empty($hookmanager->resPrint)) {
289
+            print $hookmanager->resPrint;
290
+        }
291
+    }
292
+    if (is_object($hookmanager) && ! empty($senderissupplier))
293
+    {
294
+        $parameters=array('htmlname'=>'addproduct');
295
+        $reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions',$parameters,$object,$action);
296
+        if (!empty($hookmanager->resPrint)) {
297
+            print $hookmanager->resPrint;
298
+        }
299
+    }
301 300
 
302
-	if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) {
303 301
 
304
-		if (!empty($conf->variants->enabled)) {
305
-			echo '<div id="attributes_box"></div>';
306
-		}
302
+    if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) {
307 303
 
308
-		echo '<br>';
309
-	}
304
+        if (!empty($conf->variants->enabled)) {
305
+            echo '<div id="attributes_box"></div>';
306
+        }
310 307
 
311
-	// Editor wysiwyg
312
-	require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
313
-	$nbrows=ROWS_2;
314
-	$enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
315
-	if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
316
-	$toolbarname='dolibarr_details';
317
-	if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes';
318
-	$doleditor=new DolEditor('dp_desc',GETPOST('dp_desc'),'',100,$toolbarname,'',false,true,$enabled,$nbrows,'98%');
319
-	$doleditor->Create();
320
-
321
-	// Show autofill date for recuring invoices
322
-	if (! empty($conf->service->enabled) && $object->element == 'facturerec')
323
-	{
324
-		echo '<div class="divlinefordates"><br>';
325
-		echo $langs->trans('AutoFillDateFrom').' ';
326
-		echo $form->selectyesno('date_start_fill', $line->date_start_fill, 1);
327
-		echo ' - ';
328
-		echo $langs->trans('AutoFillDateTo').' ';
329
-		echo $form->selectyesno('date_end_fill', $line->date_end_fill, 1);
330
-		echo '</div>';
331
-	}
332
-	?>
308
+        echo '<br>';
309
+    }
310
+
311
+    // Editor wysiwyg
312
+    require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
313
+    $nbrows=ROWS_2;
314
+    $enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
315
+    if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
316
+    $toolbarname='dolibarr_details';
317
+    if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes';
318
+    $doleditor=new DolEditor('dp_desc',GETPOST('dp_desc'),'',100,$toolbarname,'',false,true,$enabled,$nbrows,'98%');
319
+    $doleditor->Create();
320
+
321
+    // Show autofill date for recuring invoices
322
+    if (! empty($conf->service->enabled) && $object->element == 'facturerec')
323
+    {
324
+        echo '<div class="divlinefordates"><br>';
325
+        echo $langs->trans('AutoFillDateFrom').' ';
326
+        echo $form->selectyesno('date_start_fill', $line->date_start_fill, 1);
327
+        echo ' - ';
328
+        echo $langs->trans('AutoFillDateTo').' ';
329
+        echo $form->selectyesno('date_end_fill', $line->date_end_fill, 1);
330
+        echo '</div>';
331
+    }
332
+    ?>
333 333
 	</td>
334 334
 
335 335
 	<?php
336
-	if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier')	// We must have same test in printObjectLines
337
-	{
338
-	?>
336
+    if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier')	// We must have same test in printObjectLines
337
+    {
338
+    ?>
339 339
 		<td class="nobottom linecolresupplier"><input id="fourn_ref" name="fourn_ref" class="flat maxwidth75" value="<?php echo (isset($_POST["fourn_ref"])?GETPOST("fourn_ref",'alpha',2):''); ?>"></td>
340 340
 	<?php } ?>
341 341
 
342 342
 	<td class="nobottom linecolvat" align="right"><?php
343
-	if ($seller->tva_assuj == "0") echo '<input type="hidden" name="tva_tx" id="tva_tx" value="0">'.vatrate(0, true);
344
-	else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?GETPOST("tva_tx",'alpha',2):-1), $seller, $buyer, 0, 0, '', false, 1);
345
-	?>
343
+    if ($seller->tva_assuj == "0") echo '<input type="hidden" name="tva_tx" id="tva_tx" value="0">'.vatrate(0, true);
344
+    else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?GETPOST("tva_tx",'alpha',2):-1), $seller, $buyer, 0, 0, '', false, 1);
345
+    ?>
346 346
 	</td>
347 347
 	<td class="nobottom linecoluht" align="right">
348 348
 	<input type="text" size="5" name="price_ht" id="price_ht" class="flat right" value="<?php echo (isset($_POST["price_ht"])?GETPOST("price_ht",'alpha',2):''); ?>">
@@ -362,27 +362,27 @@  discard block
 block discarded – undo
362 362
 	<td class="nobottom linecolqty" align="right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="<?php echo (isset($_POST["qty"])?GETPOST("qty",'alpha',2):1); ?>">
363 363
 	</td>
364 364
 	<?php
365
-	if($conf->global->PRODUCT_USE_UNITS)
366
-	{
367
-		print '<td class="nobottom linecoluseunit" align="left">';
368
-		print $form->selectUnits($line->fk_unit, "units");
369
-		print '</td>';
370
-	}
371
-	$remise_percent = $buyer->remise_percent;
372
-	if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
373
-		$remise_percent = $seller->remise_supplier_percent;
374
-	}
375
-	?>
365
+    if($conf->global->PRODUCT_USE_UNITS)
366
+    {
367
+        print '<td class="nobottom linecoluseunit" align="left">';
368
+        print $form->selectUnits($line->fk_unit, "units");
369
+        print '</td>';
370
+    }
371
+    $remise_percent = $buyer->remise_percent;
372
+    if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
373
+        $remise_percent = $seller->remise_supplier_percent;
374
+    }
375
+    ?>
376 376
 	<td class="nobottom nowrap linecoldiscount" align="right"><input type="text" size="1" name="remise_percent" id="remise_percent" class="flat right" value="<?php echo (isset($_POST["remise_percent"])?GETPOST("remise_percent",'alpha',2):$remise_percent); ?>"><span class="hideonsmartphone">%</span></td>
377 377
 	<?php
378
-	if ($this->situation_cycle_ref) {
379
-		$coldisplay++;
380
-		print '<td class="nobottom nowrap" align="right"><input class="falt right" type="text" size="1" value="0" name="progress">%</td>';
381
-	}
382
-	if (! empty($usemargins))
383
-	{
384
-		if (!empty($user->rights->margins->creer)) {
385
-		?>
378
+    if ($this->situation_cycle_ref) {
379
+        $coldisplay++;
380
+        print '<td class="nobottom nowrap" align="right"><input class="falt right" type="text" size="1" value="0" name="progress">%</td>';
381
+    }
382
+    if (! empty($usemargins))
383
+    {
384
+        if (!empty($user->rights->margins->creer)) {
385
+        ?>
386 386
 		<td align="right" class="nobottom margininfos linecolmargin">
387 387
 			<!-- For predef product -->
388 388
 			<?php if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { ?>
@@ -392,29 +392,29 @@  discard block
 block discarded – undo
392 392
 			<input type="text" size="5" id="buying_price" name="buying_price" class="flat right" value="<?php echo (isset($_POST["buying_price"])?GETPOST("buying_price",'alpha',2):''); ?>">
393 393
 		</td>
394 394
 		<?php
395
-		$coldisplay++;
396
-		}
395
+        $coldisplay++;
396
+        }
397 397
 
398
-		if ($user->rights->margins->creer)
399
-		{
400
-			if (! empty($conf->global->DISPLAY_MARGIN_RATES))
401
-			{
402
-				echo '<td align="right" class="nobottom nowrap margininfos"><input class="flat right" type="text" size="2" id="np_marginRate" name="np_marginRate" value="'.(isset($_POST["np_marginRate"])?GETPOST("np_marginRate",'alpha',2):'').'"><span class="np_marginRate hideonsmartphone">%</span></td>';
403
-				$coldisplay++;
404
-			}
405
-			if (! empty($conf->global->DISPLAY_MARK_RATES))
406
-			{
407
-				echo '<td align="right" class="nobottom nowrap margininfos"><input class="flat right" type="text" size="2" id="np_markRate" name="np_markRate" value="'.(isset($_POST["np_markRate"])?GETPOST("np_markRate",'alpha',2):'').'"><span class="np_markRate hideonsmartphone">%</span></td>';
408
-				$coldisplay++;
409
-			}
410
-		}
411
-		else
412
-		{
413
-			if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $coldisplay++;
414
-			if (! empty($conf->global->DISPLAY_MARK_RATES))   $coldisplay++;
415
-		}
416
-	}
417
-	?>
398
+        if ($user->rights->margins->creer)
399
+        {
400
+            if (! empty($conf->global->DISPLAY_MARGIN_RATES))
401
+            {
402
+                echo '<td align="right" class="nobottom nowrap margininfos"><input class="flat right" type="text" size="2" id="np_marginRate" name="np_marginRate" value="'.(isset($_POST["np_marginRate"])?GETPOST("np_marginRate",'alpha',2):'').'"><span class="np_marginRate hideonsmartphone">%</span></td>';
403
+                $coldisplay++;
404
+            }
405
+            if (! empty($conf->global->DISPLAY_MARK_RATES))
406
+            {
407
+                echo '<td align="right" class="nobottom nowrap margininfos"><input class="flat right" type="text" size="2" id="np_markRate" name="np_markRate" value="'.(isset($_POST["np_markRate"])?GETPOST("np_markRate",'alpha',2):'').'"><span class="np_markRate hideonsmartphone">%</span></td>';
408
+                $coldisplay++;
409
+            }
410
+        }
411
+        else
412
+        {
413
+            if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $coldisplay++;
414
+            if (! empty($conf->global->DISPLAY_MARK_RATES))   $coldisplay++;
415
+        }
416
+    }
417
+    ?>
418 418
 	<td class="nobottom linecoledit" align="center" valign="middle" colspan="<?php echo $colspan; ?>">
419 419
 		<input type="submit" class="button" value="<?php echo $langs->trans('Add'); ?>" name="addline" id="addline">
420 420
 	</td>
@@ -422,98 +422,98 @@  discard block
 block discarded – undo
422 422
 
423 423
 <?php
424 424
 if (is_object($objectline)) {
425
-	print $objectline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay+8), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
425
+    print $objectline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay+8), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
426 426
 }
427 427
 ?>
428 428
 
429 429
 <?php
430 430
 if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0')	// We show date field if required
431 431
 {
432
-	$colspan = 6;
433
-
434
-	if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier')	// We must have same test in printObjectLines
435
-	{
436
-		$colspan++;
437
-	}
438
-	if ($this->situation_cycle_ref) {
439
-		$colspan++;
440
-	}
441
-	// We add 1 if col total ttc
442
-	if (!empty($inputalsopricewithtax)) {
443
-		$colspan++;
444
-	}
445
-	if ($conf->global->PRODUCT_USE_UNITS) {
446
-		$colspan++;
447
-	}
448
-	if (count($object->lines)) {
449
-		//There will be an edit and a delete button
450
-		$colspan += 2;
451
-
452
-		// With this, there is a column move button ONLY if lines > 1
453
-		if (in_array($object->element, array(
454
-			'propal',
455
-			'supplier_proposal',
456
-			'facture',
457
-		    'facturerec',
458
-			'invoice',
459
-			'commande',
460
-			'order',
461
-			'order_supplier',
462
-			'invoice_supplier'
463
-		))) {
464
-			$colspan++;
465
-		}
466
-	}
432
+    $colspan = 6;
433
+
434
+    if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier')	// We must have same test in printObjectLines
435
+    {
436
+        $colspan++;
437
+    }
438
+    if ($this->situation_cycle_ref) {
439
+        $colspan++;
440
+    }
441
+    // We add 1 if col total ttc
442
+    if (!empty($inputalsopricewithtax)) {
443
+        $colspan++;
444
+    }
445
+    if ($conf->global->PRODUCT_USE_UNITS) {
446
+        $colspan++;
447
+    }
448
+    if (count($object->lines)) {
449
+        //There will be an edit and a delete button
450
+        $colspan += 2;
451
+
452
+        // With this, there is a column move button ONLY if lines > 1
453
+        if (in_array($object->element, array(
454
+            'propal',
455
+            'supplier_proposal',
456
+            'facture',
457
+            'facturerec',
458
+            'invoice',
459
+            'commande',
460
+            'order',
461
+            'order_supplier',
462
+            'invoice_supplier'
463
+        ))) {
464
+            $colspan++;
465
+        }
466
+    }
467 467
 
468
-	if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan+=2;
468
+    if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan+=2;
469 469
 
470
-	if (! empty($usemargins))
471
-	{
472
-		if (!empty($user->rights->margins->creer)) $colspan++; // For the buying price
473
-		if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
474
-		if (! empty($conf->global->DISPLAY_MARK_RATES))   $colspan++;
475
-	}
476
-	?>
470
+    if (! empty($usemargins))
471
+    {
472
+        if (!empty($user->rights->margins->creer)) $colspan++; // For the buying price
473
+        if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
474
+        if (! empty($conf->global->DISPLAY_MARK_RATES))   $colspan++;
475
+    }
476
+    ?>
477 477
 
478 478
 	<tr id="trlinefordates" <?php echo $bcnd[$var]; ?>>
479 479
 	<?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print '<td></td>'; } ?>
480 480
 	<td colspan="<?php echo $colspan; ?>">
481 481
 	<?php
482
-	$date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
483
-	$date_end=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
484
-	if (! empty($object->element) && $object->element == 'contrat')
485
-	{
486
-		print $langs->trans("DateStartPlanned").' ';
487
-		print $form->selectDate($date_start,"date_start",$usehm,$usehm,1,"addproduct");
488
-		print ' &nbsp; '.$langs->trans("DateEndPlanned").' ';
489
-		print $form->selectDate($date_end,"date_end",$usehm,$usehm,1,"addproduct");
490
-	}
491
-	else
492
-	{
493
-		echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
494
-		print $form->selectDate($date_start, 'date_start', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, 1, "addproduct", 1, 0);
495
-		echo ' '.$langs->trans('to').' ';
496
-		print $form->selectDate($date_end, 'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, 1, "addproduct", 1, 0);
497
-	};
498
-	print '<script type="text/javascript">';
499
-	if (!$date_start) {
500
-		if (isset($conf->global->MAIN_DEFAULT_DATE_START_HOUR)) {
501
-			print 'jQuery("#date_starthour").val("'.$conf->global->MAIN_DEFAULT_DATE_START_HOUR.'");';
502
-		}
503
-		if (isset($conf->global->MAIN_DEFAULT_DATE_START_MIN)) {
504
-			print 'jQuery("#date_startmin").val("'.$conf->global->MAIN_DEFAULT_DATE_START_MIN.'");';
505
-		}
506
-	}
507
-	if (!$date_end) {
508
-		if (isset($conf->global->MAIN_DEFAULT_DATE_END_HOUR)) {
509
-			print 'jQuery("#date_endhour").val("'.$conf->global->MAIN_DEFAULT_DATE_END_HOUR.'");';
510
-		}
511
-		if (isset($conf->global->MAIN_DEFAULT_DATE_END_MIN)) {
512
-			print 'jQuery("#date_endmin").val("'.$conf->global->MAIN_DEFAULT_DATE_END_MIN.'");';
513
-		}
514
-	}
515
-	print '</script>'
516
-	?>
482
+    $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
483
+    $date_end=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
484
+    if (! empty($object->element) && $object->element == 'contrat')
485
+    {
486
+        print $langs->trans("DateStartPlanned").' ';
487
+        print $form->selectDate($date_start,"date_start",$usehm,$usehm,1,"addproduct");
488
+        print ' &nbsp; '.$langs->trans("DateEndPlanned").' ';
489
+        print $form->selectDate($date_end,"date_end",$usehm,$usehm,1,"addproduct");
490
+    }
491
+    else
492
+    {
493
+        echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
494
+        print $form->selectDate($date_start, 'date_start', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, 1, "addproduct", 1, 0);
495
+        echo ' '.$langs->trans('to').' ';
496
+        print $form->selectDate($date_end, 'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, 1, "addproduct", 1, 0);
497
+    };
498
+    print '<script type="text/javascript">';
499
+    if (!$date_start) {
500
+        if (isset($conf->global->MAIN_DEFAULT_DATE_START_HOUR)) {
501
+            print 'jQuery("#date_starthour").val("'.$conf->global->MAIN_DEFAULT_DATE_START_HOUR.'");';
502
+        }
503
+        if (isset($conf->global->MAIN_DEFAULT_DATE_START_MIN)) {
504
+            print 'jQuery("#date_startmin").val("'.$conf->global->MAIN_DEFAULT_DATE_START_MIN.'");';
505
+        }
506
+    }
507
+    if (!$date_end) {
508
+        if (isset($conf->global->MAIN_DEFAULT_DATE_END_HOUR)) {
509
+            print 'jQuery("#date_endhour").val("'.$conf->global->MAIN_DEFAULT_DATE_END_HOUR.'");';
510
+        }
511
+        if (isset($conf->global->MAIN_DEFAULT_DATE_END_MIN)) {
512
+            print 'jQuery("#date_endmin").val("'.$conf->global->MAIN_DEFAULT_DATE_END_MIN.'");';
513
+        }
514
+    }
515
+    print '</script>'
516
+    ?>
517 517
 	</td>
518 518
 	</tr>
519 519
 <?php
@@ -530,19 +530,19 @@  discard block
 block discarded – undo
530 530
 	/* Some js test when we click on button "Add" */
531 531
 	jQuery(document).ready(function() {
532 532
 		<?php
533
-		if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { ?>
533
+        if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { ?>
534 534
 			$("input[name='np_marginRate']:first").blur(function(e) {
535 535
 				return checkFreeLine(e, "np_marginRate");
536 536
 			});
537 537
 		<?php
538
-		}
539
-		if (! empty($conf->global->DISPLAY_MARK_RATES)) { ?>
538
+        }
539
+        if (! empty($conf->global->DISPLAY_MARK_RATES)) { ?>
540 540
 			$("input[name='np_markRate']:first").blur(function(e) {
541 541
 				return checkFreeLine(e, "np_markRate");
542 542
 			});
543 543
 		<?php
544
-		}
545
-		?>
544
+        }
545
+        ?>
546 546
 	});
547 547
 
548 548
 	/* TODO This does not work for number with thousand separator that is , */
@@ -633,11 +633,11 @@  discard block
 block discarded – undo
633 633
 	});
634 634
 
635 635
 	<?php
636
-	if(!$freelines) { ?>
636
+    if(!$freelines) { ?>
637 637
 		$("#prod_entry_mode_predef").click();
638 638
 	<?php
639
-	}
640
-	?>
639
+    }
640
+    ?>
641 641
 
642 642
 	/* When changing predefined product, we reload list of supplier prices required for margin combo */
643 643
 	$("#idprod, #idprodfournprice").change(function()
@@ -649,10 +649,10 @@  discard block
 block discarded – undo
649 649
 		jQuery('#trlinefordates').show();
650 650
 
651 651
 		<?php
652
-		if (! empty($usemargins) && $user->rights->margins->creer)
653
-		{
654
-			$langs->load('stocks');
655
-			?>
652
+        if (! empty($usemargins) && $user->rights->margins->creer)
653
+        {
654
+            $langs->load('stocks');
655
+            ?>
656 656
 
657 657
     		/* Code for margin */
658 658
       		$("#fournprice_predef").find("option").remove();
@@ -673,12 +673,12 @@  discard block
 block discarded – undo
673 673
 
674 674
     				/* setup of margin calculation */
675 675
     	      		var defaultbuyprice = '<?php
676
-    	      		if (isset($conf->global->MARGIN_TYPE))
677
-    	      		{
678
-    	      		    if ($conf->global->MARGIN_TYPE == '1')   print 'bestsupplierprice';
679
-    	      		    if ($conf->global->MARGIN_TYPE == 'pmp') print 'pmp';
680
-    	      		    if ($conf->global->MARGIN_TYPE == 'costprice') print 'costprice';
681
-    	      		} ?>';
676
+                        if (isset($conf->global->MARGIN_TYPE))
677
+                        {
678
+                            if ($conf->global->MARGIN_TYPE == '1')   print 'bestsupplierprice';
679
+                            if ($conf->global->MARGIN_TYPE == 'pmp') print 'pmp';
680
+                            if ($conf->global->MARGIN_TYPE == 'costprice') print 'costprice';
681
+                        } ?>';
682 682
     	      		console.log("we will set the field for margin. defaultbuyprice="+defaultbuyprice);
683 683
 
684 684
     	      		var i = 0;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/tpl/bloc_showhide.tpl.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@
 block discarded – undo
20 20
 // Protection to avoid direct call of template
21 21
 if (empty($blocname))
22 22
 {
23
-	print "Error, template page can't be called as URL";
24
-	exit;
23
+    print "Error, template page can't be called as URL";
24
+    exit;
25 25
 }
26 26
 
27 27
 $hide = true;	// Hide by default
Please login to merge, or discard this patch.
dolibarr/htdocs/core/tpl/extrafields_list_print_fields.tpl.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 // Protection to avoid direct call of template
4 4
 if (empty($conf) || ! is_object($conf))
5 5
 {
6
-	print "Error, template page can't be called as URL";
7
-	exit;
6
+    print "Error, template page can't be called as URL";
7
+    exit;
8 8
 }
9 9
 
10 10
 if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey=$object->table_element;
@@ -12,34 +12,34 @@  discard block
 block discarded – undo
12 12
 // Loop to show all columns of extrafields from $obj, $extrafields and $db
13 13
 if (! empty($extrafieldsobjectkey))	// $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ...
14 14
 {
15
-	if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
16
-	{
17
-		foreach($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val)
18
-		{
19
-			if (! empty($arrayfields["ef.".$key]['checked']))
20
-			{
21
-				$align=$extrafields->getAlignFlag($key, $extrafieldsobjectkey);
22
-				print '<td';
23
-				if ($align) print ' align="'.$align.'"';
24
-				print '>';
25
-				$tmpkey='options_'.$key;
26
-				if (in_array($extrafields->attributes[$extrafieldsobjectkey]['type'][$key], array('date', 'datetime', 'timestamp')) && !is_numeric($obj->$tmpkey))
27
-				{
28
-					$datenotinstring = $obj->$tmpkey;
29
-					if (! is_numeric($obj->$tmpkey))	// For backward compatibility
30
-					{
31
-						$datenotinstring = $db->jdate($datenotinstring);
32
-					}
33
-					$value = $datenotinstring;
34
-				}
35
-				else
36
-				{
37
-					$value = $obj->$tmpkey;
38
-				}
15
+    if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
16
+    {
17
+        foreach($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val)
18
+        {
19
+            if (! empty($arrayfields["ef.".$key]['checked']))
20
+            {
21
+                $align=$extrafields->getAlignFlag($key, $extrafieldsobjectkey);
22
+                print '<td';
23
+                if ($align) print ' align="'.$align.'"';
24
+                print '>';
25
+                $tmpkey='options_'.$key;
26
+                if (in_array($extrafields->attributes[$extrafieldsobjectkey]['type'][$key], array('date', 'datetime', 'timestamp')) && !is_numeric($obj->$tmpkey))
27
+                {
28
+                    $datenotinstring = $obj->$tmpkey;
29
+                    if (! is_numeric($obj->$tmpkey))	// For backward compatibility
30
+                    {
31
+                        $datenotinstring = $db->jdate($datenotinstring);
32
+                    }
33
+                    $value = $datenotinstring;
34
+                }
35
+                else
36
+                {
37
+                    $value = $obj->$tmpkey;
38
+                }
39 39
 
40
-				print $extrafields->showOutputField($key, $value, '', $extrafieldsobjectkey);
41
-				print '</td>';
42
-				if (! $i) $totalarray['nbfield']++;
40
+                print $extrafields->showOutputField($key, $value, '', $extrafieldsobjectkey);
41
+                print '</td>';
42
+                if (! $i) $totalarray['nbfield']++;
43 43
 
44 44
                 if ($extrafields->attributes[$extrafieldsobjectkey]['totalizable'][$key]) {
45 45
                     if (! $i) {
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
                     }
49 49
                     $totalarray['totalizable'][$key]['total'] += $obj->$tmpkey;
50 50
                 }
51
-				if (! empty($val['isameasure']))
52
-				{
53
-					if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey;
54
-					$totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey;
55
-				}
56
-			}
57
-		}
58
-	}
51
+                if (! empty($val['isameasure']))
52
+                {
53
+                    if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey;
54
+                    $totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey;
55
+                }
56
+            }
57
+        }
58
+    }
59 59
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/tpl/contacts.tpl.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
 // Protection to avoid direct call of template
25 25
 if (empty($object) || ! is_object($object))
26 26
 {
27
-	print "Error, template page can't be called as URL";
28
-	exit;
27
+    print "Error, template page can't be called as URL";
28
+    exit;
29 29
 }
30 30
 
31 31
 
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
 elseif ($module == 'project_task')	{ $permission=$user->rights->projet->creer; }
47 47
 elseif (! isset($permission) && isset($user->rights->$module->creer))
48 48
 {
49
-	$permission=$user->rights->$module->creer;
49
+    $permission=$user->rights->$module->creer;
50 50
 }
51 51
 elseif (! isset($permission)  && isset($user->rights->$module->write))
52 52
 {
53
-	$permission=$user->rights->$module->write;
53
+    $permission=$user->rights->$module->write;
54 54
 }
55 55
 
56 56
 $formcompany= new FormCompany($db);
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
 
80 80
 	<?php
81 81
 
82
-	if (empty($hideaddcontactforuser))
83
-	{
82
+    if (empty($hideaddcontactforuser))
83
+    {
84 84
 
85
-	?>
85
+    ?>
86 86
 	<form class="tagtr impair" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id; ?>" method="POST">
87 87
 	<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
88 88
 	<input type="hidden" name="id" value="<?php echo $object->id; ?>" />
@@ -94,21 +94,21 @@  discard block
 block discarded – undo
94 94
 		<div class="tagtd maxwidthonsmartphone"><?php echo $form->select_dolusers($user->id, 'userid', 0, (! empty($userAlreadySelected)?$userAlreadySelected:null), 0, null, null, 0, 56, '', 0, '', 'minwidth200imp'); ?></div>
95 95
 		<div class="tagtd maxwidthonsmartphone">
96 96
 		<?php
97
-		$tmpobject=$object;
98
-		if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc;
99
-		echo $formcompany->selectTypeContact($tmpobject, '', 'type','internal');
100
-		?></div>
97
+        $tmpobject=$object;
98
+        if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc;
99
+        echo $formcompany->selectTypeContact($tmpobject, '', 'type','internal');
100
+        ?></div>
101 101
 		<div class="tagtd">&nbsp;</div>
102 102
 		<div class="tagtd center"><input type="submit" class="button" value="<?php echo $langs->trans("Add"); ?>"></div>
103 103
 	</form>
104 104
 
105 105
 	<?php
106
-	}
106
+    }
107 107
 
108
-	if (empty($hideaddcontactforthirdparty))
109
-	{
108
+    if (empty($hideaddcontactforthirdparty))
109
+    {
110 110
 
111
-	?>
111
+    ?>
112 112
 
113 113
 	<form class="tagtr pair" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id; ?>" method="POST">
114 114
 	<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
@@ -120,12 +120,12 @@  discard block
 block discarded – undo
120 120
 		<div class="tagtd nowrap maxwidthonsmartphone noborderbottom">
121 121
 			<?php $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$object->socid; ?>
122 122
 			<?php
123
-			// add company icon before select list
124
-			if ($selectedCompany)
125
-			{
126
-			    echo img_object('', 'company', 'class="hideonsmartphone"');
127
-			}
128
-			?>
123
+            // add company icon before select list
124
+            if ($selectedCompany)
125
+            {
126
+                echo img_object('', 'company', 'class="hideonsmartphone"');
127
+            }
128
+            ?>
129 129
 			<?php $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', '', 0, '', 'minwidth300imp'); ?>
130 130
 		</div>
131 131
 		<div class="tagtd maxwidthonsmartphone noborderbottom">
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 		</div>
134 134
 		<div class="tagtd maxwidthonsmartphone noborderbottom">
135 135
 			<?php
136
-			$tmpobject=$object;
137
-			if (($object->element == 'shipping'|| $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc;
138
-			$formcompany->selectTypeContact($tmpobject, '', 'type','external', 'position', 0, 'minwidth100imp'); ?>
136
+            $tmpobject=$object;
137
+            if (($object->element == 'shipping'|| $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc;
138
+            $formcompany->selectTypeContact($tmpobject, '', 'type','external', 'position', 0, 'minwidth100imp'); ?>
139 139
 		</div>
140 140
 		<div class="tagtd noborderbottom">&nbsp;</div>
141 141
 		<div class="tagtd center noborderbottom">
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	</form>
145 145
 
146 146
 <?php
147
-	}
147
+    }
148 148
 }
149 149
 ?>
150 150
 
@@ -158,18 +158,18 @@  discard block
 block discarded – undo
158 158
 	</form>
159 159
 
160 160
 	<?php
161
-	$arrayofsource=array('internal','external');	// Show both link to user and thirdparties contacts
162
-	foreach($arrayofsource as $source) {
161
+    $arrayofsource=array('internal','external');	// Show both link to user and thirdparties contacts
162
+    foreach($arrayofsource as $source) {
163 163
 
164
-		$tmpobject=$object;
165
-		if (($object->element == 'shipping'|| $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc;
164
+        $tmpobject=$object;
165
+        if (($object->element == 'shipping'|| $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc;
166 166
 
167
-		$tab = $tmpobject->liste_contact(-1,$source);
168
-		$num=count($tab);
167
+        $tab = $tmpobject->liste_contact(-1,$source);
168
+        $num=count($tab);
169 169
 
170
-		$i = 0;
171
-		while ($i < $num) {
172
-	?>
170
+        $i = 0;
171
+        while ($i < $num) {
172
+    ?>
173 173
 
174 174
 	<form class="tagtr oddeven">
175 175
 		<div class="tagtd" align="left">
@@ -178,50 +178,50 @@  discard block
 block discarded – undo
178 178
 		</div>
179 179
 		<div class="tagtd" align="left">
180 180
 			<?php
181
-			if ($tab[$i]['socid'] > 0)
182
-			{
183
-				$companystatic->fetch($tab[$i]['socid']);
184
-				echo $companystatic->getNomUrl(1);
185
-			}
186
-			if ($tab[$i]['socid'] < 0)
187
-			{
188
-				echo $conf->global->MAIN_INFO_SOCIETE_NOM;
189
-			}
190
-			if (! $tab[$i]['socid'])
191
-			{
192
-				echo '&nbsp;';
193
-			}
194
-			?>
181
+            if ($tab[$i]['socid'] > 0)
182
+            {
183
+                $companystatic->fetch($tab[$i]['socid']);
184
+                echo $companystatic->getNomUrl(1);
185
+            }
186
+            if ($tab[$i]['socid'] < 0)
187
+            {
188
+                echo $conf->global->MAIN_INFO_SOCIETE_NOM;
189
+            }
190
+            if (! $tab[$i]['socid'])
191
+            {
192
+                echo '&nbsp;';
193
+            }
194
+            ?>
195 195
 		</div>
196 196
 		<div class="tagtd">
197 197
 			<?php
198
-			$statusofcontact = $tab[$i]['status'];
199
-
200
-			if ($tab[$i]['source']=='internal')
201
-			{
202
-				$userstatic->fetch($tab[$i]['id']);
203
-				echo $userstatic->getNomUrl(-1, '', 0, 0, 0, 0, '', 'valignmiddle');
204
-			}
205
-			if ($tab[$i]['source']=='external')
206
-			{
207
-				$contactstatic->fetch($tab[$i]['id']);
208
-				echo $contactstatic->getNomUrl(1, '', 0, 0, 0, 0, '', 'valignmiddle');
209
-			}
210
-			?>
198
+            $statusofcontact = $tab[$i]['status'];
199
+
200
+            if ($tab[$i]['source']=='internal')
201
+            {
202
+                $userstatic->fetch($tab[$i]['id']);
203
+                echo $userstatic->getNomUrl(-1, '', 0, 0, 0, 0, '', 'valignmiddle');
204
+            }
205
+            if ($tab[$i]['source']=='external')
206
+            {
207
+                $contactstatic->fetch($tab[$i]['id']);
208
+                echo $contactstatic->getNomUrl(1, '', 0, 0, 0, 0, '', 'valignmiddle');
209
+            }
210
+            ?>
211 211
 		</div>
212 212
 		<div class="tagtd"><?php echo $tab[$i]['libelle']; ?></div>
213 213
 		<div class="tagtd center">
214 214
 			<?php //if ($object->statut >= 0) echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">'; ?>
215 215
 			<?php
216
-			if ($tab[$i]['source']=='internal')
217
-			{
218
-				echo $userstatic->LibStatut($tab[$i]['statuscontact'],3);
219
-			}
220
-			if ($tab[$i]['source']=='external')
221
-			{
222
-				echo $contactstatic->LibStatut($tab[$i]['statuscontact'],3);
223
-			}
224
-			?>
216
+            if ($tab[$i]['source']=='internal')
217
+            {
218
+                echo $userstatic->LibStatut($tab[$i]['statuscontact'],3);
219
+            }
220
+            if ($tab[$i]['source']=='external')
221
+            {
222
+                echo $contactstatic->LibStatut($tab[$i]['statuscontact'],3);
223
+            }
224
+            ?>
225 225
 			<?php //if ($object->statut >= 0) echo '</a>'; ?>
226 226
 		</div>
227 227
 		<div class="tagtd nowrap right">
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
 </div>
239 239
 <!-- TEMPLATE CONTACTS HOOK BEGIN HERE -->
240 240
 <?php
241
-	if (is_object($hookmanager))
242
-	{
243
-		$hookmanager->initHooks(array('contacttpl'));
244
-		$parameters=array();
245
-		$reshook=$hookmanager->executeHooks('formContactTpl',$parameters,$object,$action);
246
-	}
241
+    if (is_object($hookmanager))
242
+    {
243
+        $hookmanager->initHooks(array('contacttpl'));
244
+        $parameters=array();
245
+        $reshook=$hookmanager->executeHooks('formContactTpl',$parameters,$object,$action);
246
+    }
247 247
 ?>
248 248
 <!-- END PHP TEMPLATE CONTACTS -->
Please login to merge, or discard this patch.
dolibarr/htdocs/core/tpl/card_presend.tpl.php 1 patch
Indentation   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -29,203 +29,203 @@
 block discarded – undo
29 29
 // Protection to avoid direct call of template
30 30
 if (empty($conf) || ! is_object($conf))
31 31
 {
32
-	print "Error, template page can't be called as URL";
33
-	exit;
32
+    print "Error, template page can't be called as URL";
33
+    exit;
34 34
 }
35 35
 
36 36
 
37 37
 if ($action == 'presend')
38 38
 {
39
-	$langs->load("mails");
40
-
41
-	$titreform='SendMail';
42
-
43
-	$object->fetch_projet();
44
-
45
-	if (! in_array($object->element, array('societe', 'user', 'member')))
46
-	{
47
-		// TODO get also the main_lastdoc field of $object. If not found, try to guess with following code
48
-
49
-		$ref = dol_sanitizeFileName($object->ref);
50
-		include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
51
-		$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
52
-		//
53
-		if ($object->element == 'invoice_supplier')
54
-		{
55
-			$fileparams = dol_most_recent_file($diroutput . '/' . get_exdir($object->id,2,0,0,$object,$object->element).$ref, preg_quote($ref,'/').'([^\-])+');
56
-		}
57
-
58
-		$file = $fileparams['fullname'];
59
-	}
60
-
61
-	// Define output language
62
-	$outputlangs = $langs;
63
-	$newlang = '';
64
-	if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
65
-	{
66
-		$newlang = $_REQUEST['lang_id'];
67
-	}
68
-	if ($conf->global->MAIN_MULTILANGS && empty($newlang))
69
-	{
70
-		$newlang = $object->thirdparty->default_lang;
71
-	}
72
-
73
-	if (!empty($newlang))
74
-	{
75
-		$outputlangs = new Translate('', $conf);
76
-		$outputlangs->setDefaultLang($newlang);
77
-		// Load traductions files requiredby by page
78
-		$outputlangs->loadLangs(array('commercial','bills','orders','contracts','members','propal','products','supplier_proposal','interventions'));
79
-	}
80
-
81
-	$topicmail='';
82
-	if (empty($object->ref_client)) {
83
-		$topicmail = $outputlangs->trans($defaulttopic, '__REF__');
84
-	} else if (! empty($object->ref_client)) {
85
-		$topicmail = $outputlangs->trans($defaulttopic, '__REF__ (__REFCLIENT__)');
86
-	}
87
-
88
-	// Build document if it not exists
89
-	if (! in_array($object->element, array('societe', 'user', 'member')))
90
-	{
91
-		if ((! $file || ! is_readable($file)) && method_exists($object, 'generateDocument'))
92
-		{
93
-			$result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
94
-			if ($result <= 0) {
95
-				dol_print_error($db, $object->error, $object->errors);
96
-				exit();
97
-			}
98
-			$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
99
-			$file = $fileparams['fullname'];
100
-		}
101
-	}
102
-
103
-	print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
104
-	print '<div class="clearboth"></div>';
105
-	print '<br>';
106
-	print load_fiche_titre($langs->trans($titreform));
107
-
108
-	dol_fiche_head('');
109
-
110
-	// Create form for email
111
-	include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
112
-	$formmail = new FormMail($db);
113
-
114
-	$formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang);
115
-	$formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user'));
116
-
117
-	if ($formmail->fromtype === 'user')
118
-	{
119
-		$formmail->fromid = $user->id;
120
-	}
121
-	$formmail->trackid=$trackid;
122
-	if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2))	// If bit 2 is set
123
-	{
124
-		include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
125
-		$formmail->frommail=dolAddEmailTrackId($formmail->frommail, $trackid);
126
-	}
127
-	$formmail->withfrom = 1;
128
-
129
-	// Fill list of recipient with email inside <>.
130
-	$liste = array();
131
-	if ($object->element == 'expensereport')
132
-	{
133
-		$fuser = new User($db);
134
-		$fuser->fetch($object->fk_user_author);
135
-		$liste['thirdparty'] = $fuser->getFullName($langs)." <".$fuser->email.">";
136
-	}
137
-	elseif ($object->element == 'societe')
138
-	{
139
-		foreach ($object->thirdparty_and_contact_email_array(1) as $key => $value) {
140
-			$liste[$key] = $value;
141
-		}
142
-	}
143
-	elseif ($object->element == 'contact')
144
-	{
145
-		$liste['contact'] = $object->getFullName($langs)." <".$object->email.">";
146
-	}
147
-	elseif ($object->element == 'user' || $object->element == 'member')
148
-	{
149
-		$liste['thirdparty'] = $object->getFullName($langs)." <".$object->email.">";
150
-	}
151
-	else
152
-	{
153
-		if (is_object($object->thirdparty))
154
-		{
155
-			foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) {
156
-				$liste[$key] = $value;
157
-			}
158
-		}
159
-	}
160
-	if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
161
-		$listeuser=array();
162
-		$fuserdest = new User($db);
163
-
164
-		$result= $fuserdest->fetchAll('ASC', 't.lastname', 0, 0, array('customsql'=>'t.statut=1 AND t.employee=1 AND t.email IS NOT NULL AND t.email<>\'\''));
165
-		if ($result>0 && is_array($fuserdest->users) && count($fuserdest->users)>0) {
166
-			foreach($fuserdest->users as $uuserdest) {
167
-				$listeuser[$uuserdest->id] = $uuserdest->user_get_property($uuserdest->id,'email');
168
-			}
169
-		} elseif ($result<0) {
170
-			setEventMessages(null, $fuserdest->errors,'errors');
171
-		}
172
-		if (count($listeuser)>0) {
173
-			$formmail->withtouser = $listeuser;
174
-			$formmail->withtoccuser = $listeuser;
175
-		}
176
-	}
177
-
178
-	$formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste;
179
-	$formmail->withtocc = $liste;
180
-	$formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
181
-	$formmail->withtopic = $topicmail;
182
-	$formmail->withfile = 2;
183
-	$formmail->withbody = 1;
184
-	$formmail->withdeliveryreceipt = 1;
185
-	$formmail->withcancel = 1;
186
-
187
-	//$arrayoffamiliestoexclude=array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...);
188
-	if (! isset($arrayoffamiliestoexclude)) $arrayoffamiliestoexclude=null;
189
-
190
-	// Make substitution in email content
191
-	$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object);
192
-	$substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . $object->thirdparty->tag . '&securitykey=' . urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) . '" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '';
193
-	$substitutionarray['__PERSONALIZED__'] = '';	// deprecated
194
-	$substitutionarray['__CONTACTCIVNAME__'] = '';
195
-	$parameters = array(
196
-		'mode' => 'formemail'
197
-	);
198
-	complete_substitutions_array($substitutionarray, $outputlangs, $object, $parameters);
199
-
200
-	// Find the good contact adress
201
-	$custcontact = '';
202
-	$contactarr = array();
203
-	$contactarr = $object->liste_contact(- 1, 'external');
204
-
205
-	if (is_array($contactarr) && count($contactarr) > 0) {
206
-		require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
39
+    $langs->load("mails");
40
+
41
+    $titreform='SendMail';
42
+
43
+    $object->fetch_projet();
44
+
45
+    if (! in_array($object->element, array('societe', 'user', 'member')))
46
+    {
47
+        // TODO get also the main_lastdoc field of $object. If not found, try to guess with following code
48
+
49
+        $ref = dol_sanitizeFileName($object->ref);
50
+        include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
51
+        $fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
52
+        //
53
+        if ($object->element == 'invoice_supplier')
54
+        {
55
+            $fileparams = dol_most_recent_file($diroutput . '/' . get_exdir($object->id,2,0,0,$object,$object->element).$ref, preg_quote($ref,'/').'([^\-])+');
56
+        }
57
+
58
+        $file = $fileparams['fullname'];
59
+    }
60
+
61
+    // Define output language
62
+    $outputlangs = $langs;
63
+    $newlang = '';
64
+    if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
65
+    {
66
+        $newlang = $_REQUEST['lang_id'];
67
+    }
68
+    if ($conf->global->MAIN_MULTILANGS && empty($newlang))
69
+    {
70
+        $newlang = $object->thirdparty->default_lang;
71
+    }
72
+
73
+    if (!empty($newlang))
74
+    {
75
+        $outputlangs = new Translate('', $conf);
76
+        $outputlangs->setDefaultLang($newlang);
77
+        // Load traductions files requiredby by page
78
+        $outputlangs->loadLangs(array('commercial','bills','orders','contracts','members','propal','products','supplier_proposal','interventions'));
79
+    }
80
+
81
+    $topicmail='';
82
+    if (empty($object->ref_client)) {
83
+        $topicmail = $outputlangs->trans($defaulttopic, '__REF__');
84
+    } else if (! empty($object->ref_client)) {
85
+        $topicmail = $outputlangs->trans($defaulttopic, '__REF__ (__REFCLIENT__)');
86
+    }
87
+
88
+    // Build document if it not exists
89
+    if (! in_array($object->element, array('societe', 'user', 'member')))
90
+    {
91
+        if ((! $file || ! is_readable($file)) && method_exists($object, 'generateDocument'))
92
+        {
93
+            $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
94
+            if ($result <= 0) {
95
+                dol_print_error($db, $object->error, $object->errors);
96
+                exit();
97
+            }
98
+            $fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
99
+            $file = $fileparams['fullname'];
100
+        }
101
+    }
102
+
103
+    print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
104
+    print '<div class="clearboth"></div>';
105
+    print '<br>';
106
+    print load_fiche_titre($langs->trans($titreform));
107
+
108
+    dol_fiche_head('');
109
+
110
+    // Create form for email
111
+    include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
112
+    $formmail = new FormMail($db);
113
+
114
+    $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang);
115
+    $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user'));
116
+
117
+    if ($formmail->fromtype === 'user')
118
+    {
119
+        $formmail->fromid = $user->id;
120
+    }
121
+    $formmail->trackid=$trackid;
122
+    if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2))	// If bit 2 is set
123
+    {
124
+        include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
125
+        $formmail->frommail=dolAddEmailTrackId($formmail->frommail, $trackid);
126
+    }
127
+    $formmail->withfrom = 1;
128
+
129
+    // Fill list of recipient with email inside <>.
130
+    $liste = array();
131
+    if ($object->element == 'expensereport')
132
+    {
133
+        $fuser = new User($db);
134
+        $fuser->fetch($object->fk_user_author);
135
+        $liste['thirdparty'] = $fuser->getFullName($langs)." <".$fuser->email.">";
136
+    }
137
+    elseif ($object->element == 'societe')
138
+    {
139
+        foreach ($object->thirdparty_and_contact_email_array(1) as $key => $value) {
140
+            $liste[$key] = $value;
141
+        }
142
+    }
143
+    elseif ($object->element == 'contact')
144
+    {
145
+        $liste['contact'] = $object->getFullName($langs)." <".$object->email.">";
146
+    }
147
+    elseif ($object->element == 'user' || $object->element == 'member')
148
+    {
149
+        $liste['thirdparty'] = $object->getFullName($langs)." <".$object->email.">";
150
+    }
151
+    else
152
+    {
153
+        if (is_object($object->thirdparty))
154
+        {
155
+            foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) {
156
+                $liste[$key] = $value;
157
+            }
158
+        }
159
+    }
160
+    if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
161
+        $listeuser=array();
162
+        $fuserdest = new User($db);
163
+
164
+        $result= $fuserdest->fetchAll('ASC', 't.lastname', 0, 0, array('customsql'=>'t.statut=1 AND t.employee=1 AND t.email IS NOT NULL AND t.email<>\'\''));
165
+        if ($result>0 && is_array($fuserdest->users) && count($fuserdest->users)>0) {
166
+            foreach($fuserdest->users as $uuserdest) {
167
+                $listeuser[$uuserdest->id] = $uuserdest->user_get_property($uuserdest->id,'email');
168
+            }
169
+        } elseif ($result<0) {
170
+            setEventMessages(null, $fuserdest->errors,'errors');
171
+        }
172
+        if (count($listeuser)>0) {
173
+            $formmail->withtouser = $listeuser;
174
+            $formmail->withtoccuser = $listeuser;
175
+        }
176
+    }
177
+
178
+    $formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste;
179
+    $formmail->withtocc = $liste;
180
+    $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
181
+    $formmail->withtopic = $topicmail;
182
+    $formmail->withfile = 2;
183
+    $formmail->withbody = 1;
184
+    $formmail->withdeliveryreceipt = 1;
185
+    $formmail->withcancel = 1;
186
+
187
+    //$arrayoffamiliestoexclude=array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...);
188
+    if (! isset($arrayoffamiliestoexclude)) $arrayoffamiliestoexclude=null;
189
+
190
+    // Make substitution in email content
191
+    $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object);
192
+    $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . $object->thirdparty->tag . '&securitykey=' . urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) . '" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '';
193
+    $substitutionarray['__PERSONALIZED__'] = '';	// deprecated
194
+    $substitutionarray['__CONTACTCIVNAME__'] = '';
195
+    $parameters = array(
196
+        'mode' => 'formemail'
197
+    );
198
+    complete_substitutions_array($substitutionarray, $outputlangs, $object, $parameters);
199
+
200
+    // Find the good contact adress
201
+    $custcontact = '';
202
+    $contactarr = array();
203
+    $contactarr = $object->liste_contact(- 1, 'external');
204
+
205
+    if (is_array($contactarr) && count($contactarr) > 0) {
206
+        require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
207 207
         $contactstatic = new Contact($db);
208 208
 
209
-		foreach ($contactarr as $contact) {
209
+        foreach ($contactarr as $contact) {
210 210
             $contactstatic->fetch($contact['id']);
211 211
             $substitutionarray['__CONTACT_NAME_'.$contact['code'].'__'] = $contactstatic->getFullName($langs, 1);
212
-		}
213
-	}
212
+        }
213
+    }
214 214
 
215
-	// Tableau des substitutions
216
-	$formmail->substit = $substitutionarray;
215
+    // Tableau des substitutions
216
+    $formmail->substit = $substitutionarray;
217 217
 
218
-	// Tableau des parametres complementaires
219
-	$formmail->param['action'] = 'send';
220
-	$formmail->param['models'] = $modelmail;
221
-	$formmail->param['models_id']=GETPOST('modelmailselected','int');
222
-	$formmail->param['id'] = $object->id;
223
-	$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
224
-	$formmail->param['fileinit'] = array($file);
218
+    // Tableau des parametres complementaires
219
+    $formmail->param['action'] = 'send';
220
+    $formmail->param['models'] = $modelmail;
221
+    $formmail->param['models_id']=GETPOST('modelmailselected','int');
222
+    $formmail->param['id'] = $object->id;
223
+    $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
224
+    $formmail->param['fileinit'] = array($file);
225 225
 
226
-	// Show form
227
-	print $formmail->get_form();
226
+    // Show form
227
+    print $formmail->get_form();
228 228
 
229
-	dol_fiche_end();
229
+    dol_fiche_end();
230 230
 }
231 231
 
Please login to merge, or discard this patch.