Passed
Branch develop (92bdcd)
by Laurent
32:39
created
htdocs/societe/canvas/individual/tpl/card_edit.tpl.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@
 block discarded – undo
114 114
 	<td colspan="3"><?php echo $this->control->tpl['select_suppliercategory']; ?></td>
115 115
 </tr>
116 116
 		<?php
117
-    }
117
+	}
118 118
 }
119 119
 ?>
120 120
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -173,7 +173,10 @@
 block discarded – undo
173 173
 	<td colspan="3"><?php echo $this->control->tpl['yn_assujtva']; ?></td>
174 174
 </tr>
175 175
 
176
-<?php if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?>
176
+<?php if (!empty($this->control->tpl['localtax'])) {
177
+	echo $this->control->tpl['localtax'];
178
+}
179
+?>
177 180
 
178 181
 </table>
179 182
 <br>
Please login to merge, or discard this patch.
htdocs/variants/admin/admin.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
 		setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
36 36
 	}
37 37
 
38
-    if (dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SEPARATOR', GETPOST('PRODUIT_ATTRIBUTES_SEPARATOR'), 'chaine', 0, '', $conf->entity)) {
39
-        setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
40
-    } else {
41
-        setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
42
-    }
38
+	if (dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SEPARATOR', GETPOST('PRODUIT_ATTRIBUTES_SEPARATOR'), 'chaine', 0, '', $conf->entity)) {
39
+		setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
40
+	} else {
41
+		setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
42
+	}
43 43
 }
44 44
 
45 45
 $title = $langs->trans('ModuleSetup').' '.$langs->trans('ProductAttributes');
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 print $form->selectyesno("PRODUIT_ATTRIBUTES_HIDECHILD", $conf->global->PRODUIT_ATTRIBUTES_HIDECHILD, 1).'</td></tr>';
61 61
 print '<tr class="oddeven"><td>'.$langs->trans('CombinationsSeparator').'</td>';
62 62
 if (isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) {
63
-    $separator = $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR;
63
+	$separator = $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR;
64 64
 } else {
65
-    $separator = "_";
65
+	$separator = "_";
66 66
 }
67 67
 print '<td class="right"><input size="3" type="text" class="flat" name="PRODUIT_ATTRIBUTES_SEPARATOR" value="'.$separator.'"></td></tr>';
68 68
 print '</table>';
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,8 +23,9 @@
 block discarded – undo
23 23
 $langs->loadLangs(array("admin", "products"));
24 24
 
25 25
 // Security check
26
-if (!$user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled)))
26
+if (!$user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled))) {
27 27
 	accessforbidden();
28
+}
28 29
 
29 30
 if ($_POST) {
30 31
 	$value = GETPOST('PRODUIT_ATTRIBUTES_HIDECHILD');
Please login to merge, or discard this patch.
htdocs/variants/ajax/getCombinations.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,18 +31,18 @@
 block discarded – undo
31 31
 $id = GETPOST('id', 'int');
32 32
 
33 33
 if (!$id) {
34
-    print json_encode(array(
35
-        'error' => 'ID not set'
36
-    ));
37
-    exit();
34
+	print json_encode(array(
35
+		'error' => 'ID not set'
36
+	));
37
+	exit();
38 38
 }
39 39
 
40 40
 $product = new Product($db);
41 41
 
42 42
 if ($product->fetch($id) < 0) {
43
-    print json_encode(array(
44
-        'error' => 'Product not found'
45
-    ));
43
+	print json_encode(array(
44
+		'error' => 'Product not found'
45
+	));
46 46
 }
47 47
 
48 48
 $prodcomb = new ProductCombination($db);
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,11 +16,21 @@
 block discarded – undo
16 16
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 17
  */
18 18
 
19
-if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
20
-if (!defined('NOREQUIREMENU'))  define('NOREQUIREMENU', '1');
21
-if (!defined('NOREQUIREHTML'))  define('NOREQUIREHTML', '1');
22
-if (!defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX', '1');
23
-if (!defined('NOREQUIRESOC'))   define('NOREQUIRESOC', '1');
19
+if (!defined('NOTOKENRENEWAL')) {
20
+	define('NOTOKENRENEWAL', '1');
21
+}
22
+if (!defined('NOREQUIREMENU')) {
23
+	define('NOREQUIREMENU', '1');
24
+}
25
+if (!defined('NOREQUIREHTML')) {
26
+	define('NOREQUIREHTML', '1');
27
+}
28
+if (!defined('NOREQUIREAJAX')) {
29
+	define('NOREQUIREAJAX', '1');
30
+}
31
+if (!defined('NOREQUIRESOC')) {
32
+	define('NOREQUIRESOC', '1');
33
+}
24 34
 
25 35
 require '../../main.inc.php';
26 36
 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
Please login to merge, or discard this patch.
htdocs/core/modules/modVariants.class.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@
 block discarded – undo
92 92
 
93 93
 		// Array to add new pages in new tabs
94 94
 		$this->tabs = array(
95
-        //	'product:+combinations:Combinaciones:products:1:/variants/combinations.php?id=__ID__'
95
+		//	'product:+combinations:Combinaciones:products:1:/variants/combinations.php?id=__ID__'
96 96
 		);
97 97
 
98 98
 		// Dictionaries
Please login to merge, or discard this patch.
htdocs/modulebuilder/template/core/modules/mymodule/modules_myobject.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -92,10 +92,18 @@
 block discarded – undo
92 92
 		global $langs;
93 93
 		$langs->load("admin");
94 94
 
95
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
96
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
97
-		if ($this->version == 'dolibarr') return DOL_VERSION;
98
-		if ($this->version) return $this->version;
95
+		if ($this->version == 'development') {
96
+			return $langs->trans("VersionDevelopment");
97
+		}
98
+		if ($this->version == 'experimental') {
99
+			return $langs->trans("VersionExperimental");
100
+		}
101
+		if ($this->version == 'dolibarr') {
102
+			return DOL_VERSION;
103
+		}
104
+		if ($this->version) {
105
+			return $this->version;
106
+		}
99 107
 		return $langs->trans("NotAvailable");
100 108
 	}
101 109
 }
Please login to merge, or discard this patch.
htdocs/core/class/comment.class.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -44,27 +44,27 @@
 block discarded – undo
44 44
 	public $description;
45 45
 
46 46
 	/**
47
-     * Date modification record (tms)
48
-     *
49
-     * @var integer
50
-     */
47
+	 * Date modification record (tms)
48
+	 *
49
+	 * @var integer
50
+	 */
51 51
 	public $tms;
52 52
 
53 53
 	/**
54
-     * Date creation record (datec)
55
-     *
56
-     * @var integer
57
-     */
58
-    public $datec;
54
+	 * Date creation record (datec)
55
+	 *
56
+	 * @var integer
57
+	 */
58
+	public $datec;
59 59
 
60 60
 	/**
61
-     * @var int ID
62
-     */
61
+	 * @var int ID
62
+	 */
63 63
 	public $fk_user_author;
64 64
 
65 65
 	/**
66
-     * @var int ID
67
-     */
66
+	 * @var int ID
67
+	 */
68 68
 	public $fk_user_modif;
69 69
 
70 70
 	/**
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -212,8 +212,11 @@  discard block
 block discarded – undo
212 212
 
213 213
 			$this->db->free($resql);
214 214
 
215
-			if ($num_rows) return 1;
216
-			else return 0;
215
+			if ($num_rows) {
216
+				return 1;
217
+			} else {
218
+				return 0;
219
+			}
217 220
 		} else {
218 221
 			$this->error = "Error ".$this->db->lasterror();
219 222
 			return -1;
@@ -234,8 +237,12 @@  discard block
 block discarded – undo
234 237
 		$error = 0;
235 238
 
236 239
 		// Clean parameters
237
-		if (isset($this->fk_element)) $this->fk_project = (int) trim($this->fk_element);
238
-		if (isset($this->description)) $this->description = trim($this->description);
240
+		if (isset($this->fk_element)) {
241
+			$this->fk_project = (int) trim($this->fk_element);
242
+		}
243
+		if (isset($this->description)) {
244
+			$this->description = trim($this->description);
245
+		}
239 246
 
240 247
 
241 248
 		// Update request
Please login to merge, or discard this patch.
htdocs/compta/paiement/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,8 +19,9 @@
 block discarded – undo
19 19
 require '../../main.inc.php';
20 20
 
21 21
 // Security check
22
-if (!$user->admin && $user->socid > 0)
22
+if (!$user->admin && $user->socid > 0) {
23 23
   accessforbidden();
24
+}
24 25
 
25 26
 
26 27
 /*
Please login to merge, or discard this patch.
htdocs/core/modules/mrp/modules_mo.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -92,10 +92,18 @@
 block discarded – undo
92 92
 		global $langs;
93 93
 		$langs->load("admin");
94 94
 
95
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
96
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
97
-		if ($this->version == 'dolibarr') return DOL_VERSION;
98
-		if ($this->version) return $this->version;
95
+		if ($this->version == 'development') {
96
+			return $langs->trans("VersionDevelopment");
97
+		}
98
+		if ($this->version == 'experimental') {
99
+			return $langs->trans("VersionExperimental");
100
+		}
101
+		if ($this->version == 'dolibarr') {
102
+			return DOL_VERSION;
103
+		}
104
+		if ($this->version) {
105
+			return $this->version;
106
+		}
99 107
 		return $langs->trans("NotAvailable");
100 108
 	}
101 109
 }
Please login to merge, or discard this patch.
htdocs/product/fournisseurs.php 4 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -687,7 +687,7 @@
 block discarded – undo
687 687
             });
688 688
         });
689 689
     </script>
690
-SCRIPT;
690
+script;
691 691
                 } else {
692 692
                     // Price qty min
693 693
                     print '<tr><td class="fieldrequired">'.$langs->trans("PriceQtyMin").'</td>';
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 
534 534
 					print '<td class="fieldrequired">'.$form->textwithpicto($langs->trans("PackagingForThisProduct"), $langs->trans("PackagingForThisProductDesc")).'</td>';
535 535
 					print '<td>';
536
-					$packaging = GETPOSTISSET('packaging') ? price2num(GETPOST('packaging', 'nohtml'), 'MS') : ((empty($rowid))?"1":price2num($object->packaging, 'MS'));
536
+					$packaging = GETPOSTISSET('packaging') ? price2num(GETPOST('packaging', 'nohtml'), 'MS') : ((empty($rowid)) ? "1" : price2num($object->packaging, 'MS'));
537 537
 					print '<input class="flat" name="packaging" size="5" value="'.$packaging.'">';
538 538
 
539 539
 					// Units
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 						// Show field if not hidden
900 900
 						if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
901 901
 							$extratitle = $langs->trans($value);
902
-							$arrayfields['ef.'.$key] = array('label'=>$extratitle, 'checked'=>0, 'position'=>(end($arrayfields)['position']+1), 'langfile'=>$extrafields->attributes["product_fournisseur_price"]['langfile'][$key], 'help'=>$extrafields->attributes["product_fournisseur_price"]['help'][$key]);
902
+							$arrayfields['ef.'.$key] = array('label'=>$extratitle, 'checked'=>0, 'position'=>(end($arrayfields)['position'] + 1), 'langfile'=>$extrafields->attributes["product_fournisseur_price"]['langfile'][$key], 'help'=>$extrafields->attributes["product_fournisseur_price"]['help'][$key]);
903 903
 						}
904 904
 					}
905 905
 				}
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
 				$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
912 912
 
913 913
 				print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post" name="formulaire">';
914
-				print '<input type="hidden" name="token" value="'. newToken() . '">';
914
+				print '<input type="hidden" name="token" value="'.newToken().'">';
915 915
 				print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
916 916
 				print '<input type="hidden" name="action" value="list">';
917 917
 				print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
 						if (!empty($arrayfields['pfp.multicurrency_unitprice']['checked'])) {
1043 1043
                             print '<td class="right">';
1044 1044
                             print price($productfourn->fourn_multicurrency_unitprice);
1045
-                            print '</td>';}
1045
+                            print '</td>'; }
1046 1046
 
1047 1047
 						// Currency
1048 1048
                         if ($conf->multicurrency->enabled) {
Please login to merge, or discard this patch.
Braces   +155 added lines, -53 removed lines patch added patch discarded remove patch
@@ -40,7 +40,9 @@  discard block
 block discarded – undo
40 40
 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
41 41
 require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_expression.class.php';
42 42
 require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php';
43
-if (!empty($conf->barcode->enabled)) dol_include_once('/core/class/html.formbarcode.class.php');
43
+if (!empty($conf->barcode->enabled)) {
44
+	dol_include_once('/core/class/html.formbarcode.class.php');
45
+}
44 46
 // Load translation files required by the page
45 47
 $langs->loadLangs(array('products', 'suppliers', 'bills', 'margins', 'stocks'));
46 48
 
@@ -69,10 +71,14 @@  discard block
 block discarded – undo
69 71
 // Security check
70 72
 $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
71 73
 $fieldtype = (!empty($ref) ? 'ref' : 'rowid');
72
-if ($user->socid) $socid = $user->socid;
74
+if ($user->socid) {
75
+	$socid = $user->socid;
76
+}
73 77
 $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
74 78
 
75
-if (empty($user->rights->fournisseur->lire)) accessforbidden();
79
+if (empty($user->rights->fournisseur->lire)) {
80
+	accessforbidden();
81
+}
76 82
 
77 83
 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
78 84
 $sortfield = GETPOST("sortfield", 'alpha');
@@ -82,8 +88,12 @@  discard block
 block discarded – undo
82 88
 $offset = $limit * $page;
83 89
 $pageprev = $page - 1;
84 90
 $pagenext = $page + 1;
85
-if (!$sortfield) $sortfield = "s.nom";
86
-if (!$sortorder) $sortorder = "ASC";
91
+if (!$sortfield) {
92
+	$sortfield = "s.nom";
93
+}
94
+if (!$sortorder) {
95
+	$sortorder = "ASC";
96
+}
87 97
 
88 98
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
89 99
 $hookmanager->initHooks(array('pricesuppliercard', 'globalcard'));
@@ -97,22 +107,30 @@  discard block
 block discarded – undo
97 107
 $sortfield = GETPOST("sortfield", 'alpha');
98 108
 $sortorder = GETPOST("sortorder", 'alpha');
99 109
 
100
-if (!$sortfield) $sortfield = "s.nom";
101
-if (!$sortorder) $sortorder = "ASC";
110
+if (!$sortfield) {
111
+	$sortfield = "s.nom";
112
+}
113
+if (!$sortorder) {
114
+	$sortorder = "ASC";
115
+}
102 116
 
103 117
 
104 118
 /*
105 119
  * Actions
106 120
  */
107 121
 
108
-if ($cancel) $action = '';
122
+if ($cancel) {
123
+	$action = '';
124
+}
109 125
 
110 126
 $usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire));
111 127
 $usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer));
112 128
 
113 129
 $parameters = array('socid'=>$socid, 'id_prod'=>$id);
114 130
 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
115
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
131
+if ($reshook < 0) {
132
+	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
133
+}
116 134
 
117 135
 if (empty($reshook))
118 136
 {
@@ -136,9 +154,11 @@  discard block
 block discarded – undo
136 154
 
137 155
 	if ($action == 'confirm_remove_pf')
138 156
 	{
139
-		if ($rowid)	// id of product supplier price to remove
157
+		if ($rowid) {
158
+			// id of product supplier price to remove
140 159
 		{
141 160
 			$action = '';
161
+		}
142 162
 			$result = $object->remove_product_fournisseur_price($rowid);
143 163
 			if ($result > 0) {
144 164
 				$db->query("DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields WHERE fk_object = $rowid");
@@ -153,11 +173,17 @@  discard block
 block discarded – undo
153 173
 	if ($action == 'save_price')
154 174
 	{
155 175
 		$id_fourn = GETPOST("id_fourn");
156
-		if (empty($id_fourn)) $id_fourn = GETPOST("search_id_fourn");
176
+		if (empty($id_fourn)) {
177
+			$id_fourn = GETPOST("search_id_fourn");
178
+		}
157 179
 		$ref_fourn = GETPOST("ref_fourn");
158
-		if (empty($ref_fourn)) $ref_fourn = GETPOST("search_ref_fourn");
180
+		if (empty($ref_fourn)) {
181
+			$ref_fourn = GETPOST("search_ref_fourn");
182
+		}
159 183
 		$ref_fourn_old = GETPOST("ref_fourn_old");
160
-		if (empty($ref_fourn_old)) $ref_fourn_old = $ref_fourn;
184
+		if (empty($ref_fourn_old)) {
185
+			$ref_fourn_old = $ref_fourn;
186
+		}
161 187
 		$quantity = price2num(GETPOST("qty", 'nohtml'), 'MS');
162 188
 		$remise_percent = price2num(GETPOST('remise_percent', 'alpha'));
163 189
 		$npr = preg_match('/\*/', $_POST['tva_tx']) ? 1 : 0;
@@ -203,9 +229,11 @@  discard block
 block discarded – undo
203 229
 		}
204 230
 		if (price2num($_POST["price"]) < 0 || $_POST["price"] == '')
205 231
 		{
206
-			if ($price_expression === '')	// Return error of missing price only if price_expression not set
232
+			if ($price_expression === '') {
233
+				// Return error of missing price only if price_expression not set
207 234
 			{
208 235
 				$error++;
236
+			}
209 237
 				$langs->load("errors");
210 238
 				setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Price")), null, 'errors');
211 239
 			} else {
@@ -290,8 +318,12 @@  discard block
 block discarded – undo
290 318
 
291 319
 				$newprice = price2num(GETPOST("price", "alpha"));
292 320
 
293
-				if (empty($packaging)) $packaging = 1;
294
-				if ($packaging < $quantity) $packaging = $quantity;
321
+				if (empty($packaging)) {
322
+					$packaging = 1;
323
+				}
324
+				if ($packaging < $quantity) {
325
+					$packaging = $quantity;
326
+				}
295 327
 				$object->packaging = $packaging;
296 328
 
297 329
                 if ($conf->multicurrency->enabled)
@@ -391,7 +423,9 @@  discard block
 block discarded – undo
391 423
 		    $object->next_prev_filter = " fk_product_type = ".$object->type;
392 424
 
393 425
             $shownav = 1;
394
-            if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
426
+            if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
427
+            	$shownav = 0;
428
+            }
395 429
 
396 430
 			dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
397 431
 
@@ -413,7 +447,9 @@  discard block
 block discarded – undo
413 447
             // PMP
414 448
             print '<tr><td class="titlefield">'.$form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")).'</td>';
415 449
             print '<td>';
416
-            if ($object->pmp > 0) print price($object->pmp).' '.$langs->trans("HT");
450
+            if ($object->pmp > 0) {
451
+            	print price($object->pmp).' '.$langs->trans("HT");
452
+            }
417 453
             print '</td>';
418 454
             print '</tr>';
419 455
 
@@ -423,8 +459,11 @@  discard block
 block discarded – undo
423 459
             $product_fourn = new ProductFournisseur($db);
424 460
             if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0)
425 461
             {
426
-            	if ($product_fourn->product_fourn_price_id > 0) print $product_fourn->display_price_product_fournisseur();
427
-            	else print $langs->trans("NotDefined");
462
+            	if ($product_fourn->product_fourn_price_id > 0) {
463
+            		print $product_fourn->display_price_product_fournisseur();
464
+            	} else {
465
+            		print $langs->trans("NotDefined");
466
+            	}
428 467
             }
429 468
             print '</td></tr>';
430 469
 
@@ -554,14 +593,18 @@  discard block
 block discarded – undo
554 593
 				$mysoc2->tva_assuj = 1;
555 594
 				$default_vat = get_default_tva($mysoc2, $mysoc, $object->id, 0);
556 595
 				$default_npr = get_default_npr($mysoc2, $mysoc, $object->id, 0);
557
-				if (empty($default_vat)) $default_npr = $default_vat;
596
+				if (empty($default_vat)) {
597
+					$default_npr = $default_vat;
598
+				}
558 599
 
559 600
 				print '<tr><td class="fieldrequired">'.$langs->trans("VATRateForSupplierProduct").'</td>';
560 601
 				print '<td>';
561 602
 				//print $form->load_tva('tva_tx',$object->tva_tx,$supplier,$mysoc);    // Do not use list here as it may be any vat rates for any country
562
-				if (!empty($rowid))	// If we have a supplier, it is an update, we must show the vat of current supplier price
603
+				if (!empty($rowid)) {
604
+					// If we have a supplier, it is an update, we must show the vat of current supplier price
563 605
 				{
564 606
 				    $tmpproductsupplier = new ProductFournisseur($db);
607
+				}
565 608
 				    $tmpproductsupplier->fetch_product_fournisseur_price($rowid, 1);
566 609
 					$default_vat = $tmpproductsupplier->fourn_tva_tx;
567 610
 					$default_npr = $tmpproductsupplier->fourn_tva_npr;
@@ -576,10 +619,12 @@  discard block
 block discarded – undo
576 619
 				print '<input type="text" class="flat" size="5" name="tva_tx" value="'.$vattosuggest.'">';
577 620
 				print '</td></tr>';
578 621
 
579
-				if (!empty($conf->dynamicprices->enabled)) //Only show price mode and expression selector if module is enabled
622
+				if (!empty($conf->dynamicprices->enabled)) {
623
+					//Only show price mode and expression selector if module is enabled
580 624
 				{
581 625
 					// Price mode selector
582 626
 					print '<tr><td class="fieldrequired">'.$langs->trans("PriceMode").'</td><td>';
627
+				}
583 628
 					$price_expression = new PriceExpression($db);
584 629
 					$price_expression_list = array(0 => $langs->trans("PriceNumeric")); //Put the numeric mode as first option
585 630
 					foreach ($price_expression->list_price_expression() as $entry) {
@@ -615,7 +660,9 @@  discard block
 block discarded – undo
615 660
                     print '<tr><td class="fieldrequired">'.$langs->trans("Currency").'</td>';
616 661
                     print '<td>';
617 662
                     $currencycodetouse = GETPOST('multicurrency_code') ?GETPOST('multicurrency_code') : (isset($object->fourn_multicurrency_code) ? $object->fourn_multicurrency_code : '');
618
-                    if (empty($currencycodetouse) && $object->fourn_multicurrency_tx == 1) $currencycodetouse = $conf->currency;
663
+                    if (empty($currencycodetouse) && $object->fourn_multicurrency_tx == 1) {
664
+                    	$currencycodetouse = $conf->currency;
665
+                    }
619 666
                     print $form->selectMultiCurrency($currencycodetouse, "multicurrency_code", 1);
620 667
                     print '</td>';
621 668
                     print '</tr>';
@@ -780,11 +827,16 @@  discard block
 block discarded – undo
780 827
                     if (empty($rowid)) {
781 828
                         foreach ($extralabels as $key => $value) {
782 829
                             if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) {
783
-                                if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
830
+                                if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) {
831
+                                	$langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
832
+                                }
784 833
 
785 834
                                 print '<tr><td'.($extrafields->attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>';
786
-                                if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
787
-                                else print $langs->trans($value);
835
+                                if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) {
836
+                                	print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
837
+                                } else {
838
+                                	print $langs->trans($value);
839
+                                }
788 840
                                 print '</td><td>'.$extrafields->showInputField($key, GETPOSTISSET('options_'.$key) ? $extrafield_values['options_'.$key] : '', '', '', '', '', 0, 'product_fournisseur_price').'</td></tr>';
789 841
                             }
790 842
                         }
@@ -801,11 +853,16 @@  discard block
 block discarded – undo
801 853
                             $obj = $db->fetch_object($resql);
802 854
                             foreach ($extralabels as $key => $value) {
803 855
                                 if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) {
804
-                                    if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
856
+                                    if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) {
857
+                                    	$langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
858
+                                    }
805 859
 
806 860
                                     print '<tr><td'.($extrafields->attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>';
807
-                                    if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
808
-                                    else print $langs->trans($value);
861
+                                    if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) {
862
+                                    	print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
863
+                                    } else {
864
+                                    	print $langs->trans($value);
865
+                                    }
809 866
                                     print '</td><td>'.$extrafields->showInputField($key, GETPOSTISSET('options_'.$key) ? $extrafield_values['options_'.$key] : $obj->{$key}, '', '', '', '', 0, 'product_fournisseur_price');
810 867
 
811 868
                                     print '</td></tr>';
@@ -857,11 +914,17 @@  discard block
 block discarded – undo
857 914
 			print "\n</div>\n";
858 915
 			print '<br>';
859 916
 
860
-			if ($user->rights->fournisseur->lire) // Duplicate ? this check is already in the head of this file
917
+			if ($user->rights->fournisseur->lire) {
918
+				// Duplicate ? this check is already in the head of this file
861 919
 			{
862 920
 				$param = '';
863
-				if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
864
-				if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
921
+			}
922
+				if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
923
+					$param .= '&contextpage='.urlencode($contextpage);
924
+				}
925
+				if ($limit > 0 && $limit != $conf->liste_limit) {
926
+					$param .= '&limit='.urlencode($limit);
927
+				}
865 928
 				$param .= '&ref='.urlencode($object->ref);
866 929
 
867 930
 				$product_fourn = new ProductFournisseur($db);
@@ -869,7 +932,9 @@  discard block
 block discarded – undo
869 932
 				$product_fourn_list_all = $product_fourn->list_product_fournisseur_price($object->id, $sortfield, $sortorder, 0, 0);
870 933
 				$nbtotalofrecords = count($product_fourn_list_all);
871 934
 				$num = count($product_fourn_list);
872
-				if (($num + ($offset * $limit)) < $nbtotalofrecords) $num++;
935
+				if (($num + ($offset * $limit)) < $nbtotalofrecords) {
936
+					$num++;
937
+				}
873 938
 
874 939
 				print_barre_liste($langs->trans('SupplierPrices'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit, 1);
875 940
 
@@ -924,24 +989,52 @@  discard block
 block discarded – undo
924 989
 				$param = "&id=".$object->id;
925 990
 
926 991
 				print '<tr class="liste_titre">';
927
-				if (!empty($arrayfields['pfp.datec']['checked']))					print_liste_field_titre("AppliedPricesFrom", $_SERVER["PHP_SELF"], "pfp.datec", "", $param, "", $sortfield, $sortorder);
928
-				if (!empty($arrayfields['s.nom']['checked']))						print_liste_field_titre("Suppliers", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
992
+				if (!empty($arrayfields['pfp.datec']['checked'])) {
993
+					print_liste_field_titre("AppliedPricesFrom", $_SERVER["PHP_SELF"], "pfp.datec", "", $param, "", $sortfield, $sortorder);
994
+				}
995
+				if (!empty($arrayfields['s.nom']['checked'])) {
996
+					print_liste_field_titre("Suppliers", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
997
+				}
929 998
 				print_liste_field_titre("SupplierRef", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder);
930
-				if (!empty($arrayfields['pfp.fk_availability']['checked']))			print_liste_field_titre("Availability", $_SERVER["PHP_SELF"], "pfp.fk_availability", "", $param, "", $sortfield, $sortorder);
931
-				if (!empty($arrayfields['pfp.quantity']['checked']))				print_liste_field_titre("QtyMin", $_SERVER["PHP_SELF"], "pfp.quantity", "", $param, '', $sortfield, $sortorder, 'right ');
999
+				if (!empty($arrayfields['pfp.fk_availability']['checked'])) {
1000
+					print_liste_field_titre("Availability", $_SERVER["PHP_SELF"], "pfp.fk_availability", "", $param, "", $sortfield, $sortorder);
1001
+				}
1002
+				if (!empty($arrayfields['pfp.quantity']['checked'])) {
1003
+					print_liste_field_titre("QtyMin", $_SERVER["PHP_SELF"], "pfp.quantity", "", $param, '', $sortfield, $sortorder, 'right ');
1004
+				}
932 1005
 				print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
933 1006
 				print_liste_field_titre("PriceQtyMinHT", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
934
-                if ($conf->multicurrency->enabled)									print_liste_field_titre("PriceQtyMinHTCurrency", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
935
-                if (!empty($arrayfields['pfp.unitprice']['checked']))				print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "pfp.unitprice", "", $param, '', $sortfield, $sortorder, 'right ');
936
-				if (!empty($arrayfields['pfp.multicurrency_unitprice']['checked']))	print_liste_field_titre("UnitPriceHTCurrency", $_SERVER["PHP_SELF"], "pfp.multicurrency_unitprice", "", $param, '', $sortfield, $sortorder, 'right ');
937
-				if ($conf->multicurrency->enabled)									print_liste_field_titre("Currency", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
1007
+                if ($conf->multicurrency->enabled) {
1008
+                	print_liste_field_titre("PriceQtyMinHTCurrency", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
1009
+                }
1010
+                if (!empty($arrayfields['pfp.unitprice']['checked'])) {
1011
+                	print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "pfp.unitprice", "", $param, '', $sortfield, $sortorder, 'right ');
1012
+                }
1013
+				if (!empty($arrayfields['pfp.multicurrency_unitprice']['checked'])) {
1014
+					print_liste_field_titre("UnitPriceHTCurrency", $_SERVER["PHP_SELF"], "pfp.multicurrency_unitprice", "", $param, '', $sortfield, $sortorder, 'right ');
1015
+				}
1016
+				if ($conf->multicurrency->enabled) {
1017
+					print_liste_field_titre("Currency", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
1018
+				}
938 1019
 				print_liste_field_titre("DiscountQtyMin", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
939
-				if (!empty($arrayfields['pfp.delivery_time_days']['checked']))		print_liste_field_titre("NbDaysToDelivery", $_SERVER["PHP_SELF"], "pfp.delivery_time_days", "", $param, '', $sortfield, $sortorder, 'right ');
940
-				if (!empty($arrayfields['pfp.supplier_reputation']['checked']))		print_liste_field_titre("ReputationForThisProduct", $_SERVER["PHP_SELF"], "pfp.supplier_reputation", "", $param, '', $sortfield, $sortorder, 'center ');
941
-				if (!empty($arrayfields['pfp.barcode']['checked']))					print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, '', $sortfield, $sortorder, 'center ');
942
-				if (!empty($arrayfields['pfp.fk_barcode_type']['checked']))			print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, '', $sortfield, $sortorder, 'center ');
943
-				if (!empty($arrayfields['pfp.packaging']['checked']))				print_liste_field_titre("PackagingForThisProduct", $_SERVER["PHP_SELF"], "pfp.packaging", "", $param, 'align="center"', $sortfield, $sortorder);
944
-				if (!empty($arrayfields['pfp.tms']['checked']))						print_liste_field_titre("DateModification", $_SERVER["PHP_SELF"], "pfp.tms", "", $param, '', $sortfield, $sortorder, 'right ');
1020
+				if (!empty($arrayfields['pfp.delivery_time_days']['checked'])) {
1021
+					print_liste_field_titre("NbDaysToDelivery", $_SERVER["PHP_SELF"], "pfp.delivery_time_days", "", $param, '', $sortfield, $sortorder, 'right ');
1022
+				}
1023
+				if (!empty($arrayfields['pfp.supplier_reputation']['checked'])) {
1024
+					print_liste_field_titre("ReputationForThisProduct", $_SERVER["PHP_SELF"], "pfp.supplier_reputation", "", $param, '', $sortfield, $sortorder, 'center ');
1025
+				}
1026
+				if (!empty($arrayfields['pfp.barcode']['checked'])) {
1027
+					print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, '', $sortfield, $sortorder, 'center ');
1028
+				}
1029
+				if (!empty($arrayfields['pfp.fk_barcode_type']['checked'])) {
1030
+					print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, '', $sortfield, $sortorder, 'center ');
1031
+				}
1032
+				if (!empty($arrayfields['pfp.packaging']['checked'])) {
1033
+					print_liste_field_titre("PackagingForThisProduct", $_SERVER["PHP_SELF"], "pfp.packaging", "", $param, 'align="center"', $sortfield, $sortorder);
1034
+				}
1035
+				if (!empty($arrayfields['pfp.tms']['checked'])) {
1036
+					print_liste_field_titre("DateModification", $_SERVER["PHP_SELF"], "pfp.tms", "", $param, '', $sortfield, $sortorder, 'right ');
1037
+				}
945 1038
 
946 1039
 				// fetch optionals attributes and labels
947 1040
 				$extrafields->fetch_name_optionals_label("product_fournisseur_price");
@@ -951,10 +1044,17 @@  discard block
 block discarded – undo
951 1044
 					foreach ($extralabels as $key => $value) {
952 1045
 						// Show field if not hidden
953 1046
 						if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
954
-                            if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
955
-                            if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
956
-							else $extratitle = $langs->trans($value);
957
-							if (!empty($arrayfields['ef.'.$key]['checked'])) print_liste_field_titre($extratitle, $_SERVER["PHP_SELF"], 'ef.'.$key, '', $param, '', $sortfield, $sortorder, 'right ');
1047
+                            if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) {
1048
+                            	$langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
1049
+                            }
1050
+                            if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) {
1051
+                            	$extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
1052
+                            } else {
1053
+								$extratitle = $langs->trans($value);
1054
+							}
1055
+							if (!empty($arrayfields['ef.'.$key]['checked'])) {
1056
+								print_liste_field_titre($extratitle, $_SERVER["PHP_SELF"], 'ef.'.$key, '', $param, '', $sortfield, $sortorder, 'right ');
1057
+							}
958 1058
 						}
959 1059
 					}
960 1060
 				}
@@ -984,9 +1084,11 @@  discard block
 block discarded – undo
984 1084
 						}
985 1085
 
986 1086
 						// Supplier ref
987
-						if ($usercancreate) // change required right here
1087
+						if ($usercancreate) {
1088
+							// change required right here
988 1089
 						{
989 1090
 							print '<td class="left">'.$productfourn->getNomUrl().'</td>';
1091
+						}
990 1092
 						} else {
991 1093
 							print '<td class="left">'.$productfourn->fourn_ref.'</td>';
992 1094
 						}
Please login to merge, or discard this patch.
Indentation   +283 added lines, -283 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 $object = new ProductFournisseur($db);
92 92
 if ($id > 0 || $ref)
93 93
 {
94
-    $object->fetch($id, $ref);
94
+	$object->fetch($id, $ref);
95 95
 }
96 96
 
97 97
 $sortfield = GETPOST("sortfield", 'alpha');
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 			if ($result > 0)
127 127
 			{
128 128
 				setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
129
-		        $action = '';
129
+				$action = '';
130 130
 			} else {
131 131
 				$error++;
132 132
 				setEventMessages($object->error, $object->errors, 'errors');
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 		$delivery_time_days = GETPOST('delivery_time_days', 'int') ? GETPOST('delivery_time_days', 'int') : '';
168 168
 		$supplier_reputation = GETPOST('supplier_reputation');
169 169
 		$supplier_description = GETPOST('supplier_description', 'restricthtml');
170
-        $barcode = GETPOST('barcode', 'alpha');
171
-        $fk_barcode_type = GETPOST('fk_barcode_type', 'int');
170
+		$barcode = GETPOST('barcode', 'alpha');
171
+		$fk_barcode_type = GETPOST('fk_barcode_type', 'int');
172 172
 		$packaging = price2num(GETPOST("packaging", 'alphanohtml'), 'MS');
173 173
 
174 174
 		if ($tva_tx == '')
@@ -212,23 +212,23 @@  discard block
 block discarded – undo
212 212
 				$_POST["price"] = 0;
213 213
 			}
214 214
 		}
215
-        if ($conf->multicurrency->enabled) {
216
-            if (empty($_POST["multicurrency_code"])) {
217
-                $error++;
218
-                $langs->load("errors");
219
-                setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Currency")), null, 'errors');
220
-            }
221
-            if (price2num($_POST["multicurrency_tx"]) <= 0 || $_POST["multicurrency_tx"] == '') {
222
-                $error++;
223
-                $langs->load("errors");
224
-                setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("CurrencyRate")), null, 'errors');
225
-            }
226
-            if (price2num($_POST["multicurrency_price"]) < 0 || $_POST["multicurrency_price"] == '') {
227
-                $error++;
228
-                $langs->load("errors");
229
-                setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PriceCurrency")), null, 'errors');
230
-            }
231
-        }
215
+		if ($conf->multicurrency->enabled) {
216
+			if (empty($_POST["multicurrency_code"])) {
217
+				$error++;
218
+				$langs->load("errors");
219
+				setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Currency")), null, 'errors');
220
+			}
221
+			if (price2num($_POST["multicurrency_tx"]) <= 0 || $_POST["multicurrency_tx"] == '') {
222
+				$error++;
223
+				$langs->load("errors");
224
+				setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("CurrencyRate")), null, 'errors');
225
+			}
226
+			if (price2num($_POST["multicurrency_price"]) < 0 || $_POST["multicurrency_price"] == '') {
227
+				$error++;
228
+				$langs->load("errors");
229
+				setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PriceCurrency")), null, 'errors');
230
+			}
231
+		}
232 232
 
233 233
 		if (!$error)
234 234
 		{
@@ -263,30 +263,30 @@  discard block
 block discarded – undo
263 263
 				$extralabels = $extrafields->fetch_name_optionals_label("product_fournisseur_price");
264 264
 				$extrafield_values = $extrafields->getOptionalsFromPost("product_fournisseur_price");
265 265
 				if (!empty($extrafield_values)) {
266
-                    $resql = $db->query("SELECT fk_object FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields WHERE fk_object = ".$object->product_fourn_price_id);
267
-                    // Insert a new extrafields row, if none exists
268
-                    if ($db->num_rows($resql) != 1) {
269
-                        $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields (fk_object, ";
270
-                        foreach ($extrafield_values as $key => $value) {
271
-                            $sql .= str_replace('options_', '', $key).', ';
272
-                        }
273
-                        $sql = substr($sql, 0, strlen($sql) - 2).") VALUES (".$object->product_fourn_price_id.", ";
274
-                        foreach ($extrafield_values as $key => $value) {
275
-                            $sql .= '"'.$value.'", ';
276
-                        }
277
-                        $sql = substr($sql, 0, strlen($sql) - 2).')';
278
-                    } else {
279
-                        // update the existing one
280
-                        $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields SET ";
281
-                        foreach ($extrafield_values as $key => $value) {
282
-                            $sql .= str_replace('options_', '', $key).' = "'.$value.'", ';
283
-                        }
284
-                        $sql = substr($sql, 0, strlen($sql) - 2).' WHERE fk_object = '.$object->product_fourn_price_id;
285
-                    }
286
-
287
-                    // Execute the sql command from above
288
-                    $db->query($sql);
289
-                }
266
+					$resql = $db->query("SELECT fk_object FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields WHERE fk_object = ".$object->product_fourn_price_id);
267
+					// Insert a new extrafields row, if none exists
268
+					if ($db->num_rows($resql) != 1) {
269
+						$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields (fk_object, ";
270
+						foreach ($extrafield_values as $key => $value) {
271
+							$sql .= str_replace('options_', '', $key).', ';
272
+						}
273
+						$sql = substr($sql, 0, strlen($sql) - 2).") VALUES (".$object->product_fourn_price_id.", ";
274
+						foreach ($extrafield_values as $key => $value) {
275
+							$sql .= '"'.$value.'", ';
276
+						}
277
+						$sql = substr($sql, 0, strlen($sql) - 2).')';
278
+					} else {
279
+						// update the existing one
280
+						$sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields SET ";
281
+						foreach ($extrafield_values as $key => $value) {
282
+							$sql .= str_replace('options_', '', $key).' = "'.$value.'", ';
283
+						}
284
+						$sql = substr($sql, 0, strlen($sql) - 2).' WHERE fk_object = '.$object->product_fourn_price_id;
285
+					}
286
+
287
+					// Execute the sql command from above
288
+					$db->query($sql);
289
+				}
290 290
 
291 291
 				$newprice = price2num(GETPOST("price", "alpha"));
292 292
 
@@ -294,16 +294,16 @@  discard block
 block discarded – undo
294 294
 				if ($packaging < $quantity) $packaging = $quantity;
295 295
 				$object->packaging = $packaging;
296 296
 
297
-                if ($conf->multicurrency->enabled)
298
-                {
299
-                	$multicurrency_tx = price2num(GETPOST("multicurrency_tx", 'alpha'));
300
-                	$multicurrency_price = price2num(GETPOST("multicurrency_price", 'alpha'));
301
-                	$multicurrency_code = GETPOST("multicurrency_code", 'alpha');
297
+				if ($conf->multicurrency->enabled)
298
+				{
299
+					$multicurrency_tx = price2num(GETPOST("multicurrency_tx", 'alpha'));
300
+					$multicurrency_price = price2num(GETPOST("multicurrency_price", 'alpha'));
301
+					$multicurrency_code = GETPOST("multicurrency_code", 'alpha');
302 302
 
303
-                    $ret = $object->update_buyprice($quantity, $newprice, $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', $multicurrency_price, $_POST["multicurrency_price_base_type"], $multicurrency_tx, $multicurrency_code, $supplier_description, $barcode, $fk_barcode_type);
304
-                } else {
305
-                    $ret = $object->update_buyprice($quantity, $newprice, $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', 0, 'HT', 1, '', $supplier_description, $barcode, $fk_barcode_type);
306
-                }
303
+					$ret = $object->update_buyprice($quantity, $newprice, $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', $multicurrency_price, $_POST["multicurrency_price_base_type"], $multicurrency_tx, $multicurrency_code, $supplier_description, $barcode, $fk_barcode_type);
304
+				} else {
305
+					$ret = $object->update_buyprice($quantity, $newprice, $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', 0, 'HT', 1, '', $supplier_description, $barcode, $fk_barcode_type);
306
+				}
307 307
 				if ($ret < 0)
308 308
 				{
309 309
 					$error++;
@@ -312,9 +312,9 @@  discard block
 block discarded – undo
312 312
 					if (!empty($conf->dynamicprices->enabled) && $price_expression !== '')
313 313
 					{
314 314
 						//Check the expression validity by parsing it
315
-                        $priceparser = new PriceParser($db);
316
-                        $object->fk_supplier_price_expression = $price_expression;
317
-                        $price_result = $priceparser->parseProductSupplier($object);
315
+						$priceparser = new PriceParser($db);
316
+						$object->fk_supplier_price_expression = $price_expression;
317
+						$price_result = $priceparser->parseProductSupplier($object);
318 318
 						if ($price_result < 0) { //Expression is not valid
319 319
 							$error++;
320 320
 							setEventMessages($priceparser->translatedError(), null, 'errors');
@@ -388,50 +388,50 @@  discard block
 block discarded – undo
388 388
 			print dol_get_fiche_head($head, 'suppliers', $titre, -1, $picto);
389 389
 
390 390
 			$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
391
-		    $object->next_prev_filter = " fk_product_type = ".$object->type;
391
+			$object->next_prev_filter = " fk_product_type = ".$object->type;
392 392
 
393
-            $shownav = 1;
394
-            if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
393
+			$shownav = 1;
394
+			if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
395 395
 
396 396
 			dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
397 397
 
398
-            print '<div class="fichecenter">';
398
+			print '<div class="fichecenter">';
399 399
 
400
-            print '<div class="underbanner clearboth"></div>';
401
-            print '<table class="border tableforfield" width="100%">';
400
+			print '<div class="underbanner clearboth"></div>';
401
+			print '<table class="border tableforfield" width="100%">';
402 402
 
403 403
 			// Cost price. Can be used for margin module for option "calculate margin on explicit cost price
404
-            print '<tr><td>';
404
+			print '<tr><td>';
405 405
 			$textdesc = $langs->trans("CostPriceDescription");
406 406
 			$textdesc .= "<br>".$langs->trans("CostPriceUsage");
407 407
 			$text = $form->textwithpicto($langs->trans("CostPrice"), $textdesc, 1, 'help', '');
408 408
 			print $form->editfieldkey($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6');
409
-            print '</td><td colspan="2">';
410
-            print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6');
411
-            print '</td></tr>';
412
-
413
-            // PMP
414
-            print '<tr><td class="titlefield">'.$form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")).'</td>';
415
-            print '<td>';
416
-            if ($object->pmp > 0) print price($object->pmp).' '.$langs->trans("HT");
417
-            print '</td>';
418
-            print '</tr>';
419
-
420
-            // Best buying Price
421
-            print '<tr><td class="titlefield">'.$langs->trans("BuyingPriceMin").'</td>';
422
-            print '<td colspan="2">';
423
-            $product_fourn = new ProductFournisseur($db);
424
-            if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0)
425
-            {
426
-            	if ($product_fourn->product_fourn_price_id > 0) print $product_fourn->display_price_product_fournisseur();
427
-            	else print $langs->trans("NotDefined");
428
-            }
429
-            print '</td></tr>';
430
-
431
-            print '</table>';
432
-
433
-            print '</div>';
434
-            print '<div style="clear:both"></div>';
409
+			print '</td><td colspan="2">';
410
+			print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6');
411
+			print '</td></tr>';
412
+
413
+			// PMP
414
+			print '<tr><td class="titlefield">'.$form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")).'</td>';
415
+			print '<td>';
416
+			if ($object->pmp > 0) print price($object->pmp).' '.$langs->trans("HT");
417
+			print '</td>';
418
+			print '</tr>';
419
+
420
+			// Best buying Price
421
+			print '<tr><td class="titlefield">'.$langs->trans("BuyingPriceMin").'</td>';
422
+			print '<td colspan="2">';
423
+			$product_fourn = new ProductFournisseur($db);
424
+			if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0)
425
+			{
426
+				if ($product_fourn->product_fourn_price_id > 0) print $product_fourn->display_price_product_fournisseur();
427
+				else print $langs->trans("NotDefined");
428
+			}
429
+			print '</td></tr>';
430
+
431
+			print '</table>';
432
+
433
+			print '</div>';
434
+			print '<div style="clear:both"></div>';
435 435
 
436 436
 			print dol_get_fiche_end();
437 437
 
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 					print $form->select_company(GETPOST("id_fourn", 'alpha'), 'id_fourn', 'fournisseur=1', 'SelectThirdParty', 0, 0, $events);
475 475
 
476 476
 					$parameters = array('filtre'=>"fournisseur=1", 'html_name'=>'id_fourn', 'selected'=>GETPOST("id_fourn"), 'showempty'=>1, 'prod_id'=>$object->id);
477
-				    $reshook = $hookmanager->executeHooks('formCreateThirdpartyOptions', $parameters, $object, $action);
477
+					$reshook = $hookmanager->executeHooks('formCreateThirdpartyOptions', $parameters, $object, $action);
478 478
 					if (empty($reshook))
479 479
 					{
480 480
 						if (empty($form->result))
@@ -489,8 +489,8 @@  discard block
 block discarded – undo
489 489
 				print '<tr><td class="fieldrequired">'.$langs->trans("SupplierRef").'</td><td>';
490 490
 				if ($rowid)
491 491
 				{
492
-                    print '<input type="hidden" name="ref_fourn_old" value="'.$object->ref_supplier.'">';
493
-                    print '<input class="flat" name="ref_fourn" size="12" value="'.$object->ref_supplier.'">';
492
+					print '<input type="hidden" name="ref_fourn_old" value="'.$object->ref_supplier.'">';
493
+					print '<input class="flat" name="ref_fourn" size="12" value="'.$object->ref_supplier.'">';
494 494
 				} else {
495 495
 					print '<input class="flat" name="ref_fourn" size="12" value="'.(GETPOST("ref_fourn") ?GETPOST("ref_fourn") : '').'">';
496 496
 				}
@@ -518,13 +518,13 @@  discard block
 block discarded – undo
518 518
 				} else {
519 519
 					print '<input class="flat" name="qty" size="5" value="'.$quantity.'">';
520 520
 				}
521
-                // Units
522
-                if ($conf->global->PRODUCT_USE_UNITS) {
523
-                    $unit = $object->getLabelOfUnit();
524
-                    if ($unit !== '') {
525
-                        print '&nbsp;&nbsp;'.$langs->trans($unit);
526
-                    }
527
-                }
521
+				// Units
522
+				if ($conf->global->PRODUCT_USE_UNITS) {
523
+					$unit = $object->getLabelOfUnit();
524
+					if ($unit !== '') {
525
+						print '&nbsp;&nbsp;'.$langs->trans($unit);
526
+					}
527
+				}
528 528
 				print '</td></tr>';
529 529
 
530 530
 				if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) {
@@ -561,15 +561,15 @@  discard block
 block discarded – undo
561 561
 				//print $form->load_tva('tva_tx',$object->tva_tx,$supplier,$mysoc);    // Do not use list here as it may be any vat rates for any country
562 562
 				if (!empty($rowid))	// If we have a supplier, it is an update, we must show the vat of current supplier price
563 563
 				{
564
-				    $tmpproductsupplier = new ProductFournisseur($db);
565
-				    $tmpproductsupplier->fetch_product_fournisseur_price($rowid, 1);
564
+					$tmpproductsupplier = new ProductFournisseur($db);
565
+					$tmpproductsupplier->fetch_product_fournisseur_price($rowid, 1);
566 566
 					$default_vat = $tmpproductsupplier->fourn_tva_tx;
567 567
 					$default_npr = $tmpproductsupplier->fourn_tva_npr;
568 568
 				} else {
569
-                    if (empty($default_vat))
570
-                    {
571
-                        $default_vat = $object->tva_tx;
572
-                    }
569
+					if (empty($default_vat))
570
+					{
571
+						$default_vat = $object->tva_tx;
572
+					}
573 573
 				}
574 574
 				$vattosuggest = (GETPOST("tva_tx") ?vatrate(GETPOST("tva_tx")) : ($default_vat != '' ?vatrate($default_vat) : ''));
575 575
 				$vattosuggest = preg_replace('/\s*\(.*\)$/', '', $vattosuggest);
@@ -610,52 +610,52 @@  discard block
 block discarded – undo
610 610
 					</script>';
611 611
 				}
612 612
 
613
-                if ($conf->multicurrency->enabled) {
614
-                    // Currency
615
-                    print '<tr><td class="fieldrequired">'.$langs->trans("Currency").'</td>';
616
-                    print '<td>';
617
-                    $currencycodetouse = GETPOST('multicurrency_code') ?GETPOST('multicurrency_code') : (isset($object->fourn_multicurrency_code) ? $object->fourn_multicurrency_code : '');
618
-                    if (empty($currencycodetouse) && $object->fourn_multicurrency_tx == 1) $currencycodetouse = $conf->currency;
619
-                    print $form->selectMultiCurrency($currencycodetouse, "multicurrency_code", 1);
620
-                    print '</td>';
621
-                    print '</tr>';
622
-
623
-                    // Currency tx
624
-                    print '<tr><td class="fieldrequired">'.$langs->trans("CurrencyRate").'</td>';
625
-                    print '<td><input class="flat" name="multicurrency_tx" size="4" value="'.vatrate(GETPOST('multicurrency_tx') ?GETPOST('multicurrency_tx') : (isset($object->fourn_multicurrency_tx) ? $object->fourn_multicurrency_tx : '')).'">';
626
-                    print '</td>';
627
-                    print '</tr>';
628
-
629
-                    // Currency price qty min
630
-                    print '<tr><td class="fieldrequired">'.$langs->trans("PriceQtyMinCurrency").'</td>';
631
-                    $pricesupplierincurrencytouse = (GETPOST('multicurrency_price') ?GETPOST('multicurrency_price') : (isset($object->fourn_multicurrency_price) ? $object->fourn_multicurrency_price : ''));
632
-                    print '<td><input class="flat" name="multicurrency_price" size="8" value="'.price($pricesupplierincurrencytouse).'">';
633
-                    print '&nbsp;';
634
-                    print $form->selectPriceBaseType((GETPOST('multicurrency_price_base_type') ?GETPOST('multicurrency_price_base_type') : 'HT'), "multicurrency_price_base_type"); // We keep 'HT' here, multicurrency_price_base_type is not yet supported for supplier prices
635
-                    print '</td></tr>';
636
-
637
-                    // Price qty min
638
-                    print '<tr><td class="fieldrequired">'.$langs->trans("PriceQtyMin").'</td>';
639
-                    print '<td><input class="flat" name="disabled_price" size="8" value="">';
640
-                    print '<input type="hidden" name="price" value="">';
641
-                    print '<input type="hidden" name="price_base_type" value="">';
642
-                    print '&nbsp;';
643
-                    print $form->selectPriceBaseType('', "disabled_price_base_type");
644
-                    print '</td></tr>';
645
-
646
-                    $currencies = array();
647
-                    $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE entity = '.$conf->entity;
648
-                    $resql = $db->query($sql);
649
-                    if ($resql) {
650
-                        $currency = new MultiCurrency($db);
651
-                        while ($obj = $db->fetch_object($resql)) {
652
-                            $currency->fetch($obj->rowid);
653
-                            $currencies[$currency->code] = $currency->rate->rate;
654
-                        }
655
-                    }
656
-                    $currencies = json_encode($currencies);
657
-
658
-                    print <<<SCRIPT
613
+				if ($conf->multicurrency->enabled) {
614
+					// Currency
615
+					print '<tr><td class="fieldrequired">'.$langs->trans("Currency").'</td>';
616
+					print '<td>';
617
+					$currencycodetouse = GETPOST('multicurrency_code') ?GETPOST('multicurrency_code') : (isset($object->fourn_multicurrency_code) ? $object->fourn_multicurrency_code : '');
618
+					if (empty($currencycodetouse) && $object->fourn_multicurrency_tx == 1) $currencycodetouse = $conf->currency;
619
+					print $form->selectMultiCurrency($currencycodetouse, "multicurrency_code", 1);
620
+					print '</td>';
621
+					print '</tr>';
622
+
623
+					// Currency tx
624
+					print '<tr><td class="fieldrequired">'.$langs->trans("CurrencyRate").'</td>';
625
+					print '<td><input class="flat" name="multicurrency_tx" size="4" value="'.vatrate(GETPOST('multicurrency_tx') ?GETPOST('multicurrency_tx') : (isset($object->fourn_multicurrency_tx) ? $object->fourn_multicurrency_tx : '')).'">';
626
+					print '</td>';
627
+					print '</tr>';
628
+
629
+					// Currency price qty min
630
+					print '<tr><td class="fieldrequired">'.$langs->trans("PriceQtyMinCurrency").'</td>';
631
+					$pricesupplierincurrencytouse = (GETPOST('multicurrency_price') ?GETPOST('multicurrency_price') : (isset($object->fourn_multicurrency_price) ? $object->fourn_multicurrency_price : ''));
632
+					print '<td><input class="flat" name="multicurrency_price" size="8" value="'.price($pricesupplierincurrencytouse).'">';
633
+					print '&nbsp;';
634
+					print $form->selectPriceBaseType((GETPOST('multicurrency_price_base_type') ?GETPOST('multicurrency_price_base_type') : 'HT'), "multicurrency_price_base_type"); // We keep 'HT' here, multicurrency_price_base_type is not yet supported for supplier prices
635
+					print '</td></tr>';
636
+
637
+					// Price qty min
638
+					print '<tr><td class="fieldrequired">'.$langs->trans("PriceQtyMin").'</td>';
639
+					print '<td><input class="flat" name="disabled_price" size="8" value="">';
640
+					print '<input type="hidden" name="price" value="">';
641
+					print '<input type="hidden" name="price_base_type" value="">';
642
+					print '&nbsp;';
643
+					print $form->selectPriceBaseType('', "disabled_price_base_type");
644
+					print '</td></tr>';
645
+
646
+					$currencies = array();
647
+					$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE entity = '.$conf->entity;
648
+					$resql = $db->query($sql);
649
+					if ($resql) {
650
+						$currency = new MultiCurrency($db);
651
+						while ($obj = $db->fetch_object($resql)) {
652
+							$currency->fetch($obj->rowid);
653
+							$currencies[$currency->code] = $currency->rate->rate;
654
+						}
655
+					}
656
+					$currencies = json_encode($currencies);
657
+
658
+					print <<<SCRIPT
659 659
     <script type="text/javascript">
660 660
         function update_price_from_multicurrency() {
661 661
             var multicurrency_price = $('input[name="multicurrency_price"]').val();
@@ -696,14 +696,14 @@  discard block
 block discarded – undo
696 696
         });
697 697
     </script>
698 698
 SCRIPT;
699
-                } else {
700
-                    // Price qty min
701
-                    print '<tr><td class="fieldrequired">'.$langs->trans("PriceQtyMin").'</td>';
702
-                    print '<td><input class="flat" name="price" size="8" value="'.(GETPOST('price') ? price(GETPOST('price')) : (isset($object->fourn_price) ? price($object->fourn_price) : '')).'">';
703
-                    print '&nbsp;';
704
-                    print $form->selectPriceBaseType((GETPOST('price_base_type') ? GETPOST('price_base_type') : 'HT'), "price_base_type"); // We keep 'HT' here, price_base_type is not yet supported for supplier prices
705
-                    print '</td></tr>';
706
-                }
699
+				} else {
700
+					// Price qty min
701
+					print '<tr><td class="fieldrequired">'.$langs->trans("PriceQtyMin").'</td>';
702
+					print '<td><input class="flat" name="price" size="8" value="'.(GETPOST('price') ? price(GETPOST('price')) : (isset($object->fourn_price) ? price($object->fourn_price) : '')).'">';
703
+					print '&nbsp;';
704
+					print $form->selectPriceBaseType((GETPOST('price_base_type') ? GETPOST('price_base_type') : 'HT'), "price_base_type"); // We keep 'HT' here, price_base_type is not yet supported for supplier prices
705
+					print '</td></tr>';
706
+				}
707 707
 
708 708
 
709 709
 				// Discount qty min
@@ -724,23 +724,23 @@  discard block
 block discarded – undo
724 724
 				print '</td></tr>';
725 725
 
726 726
 				// Barcode
727
-                if (!empty($conf->barcode->enabled))
728
-                {
729
-				    // Option to define a transport cost on supplier price
730
-                    print '<tr>';
731
-                    print '<td>'.$langs->trans('BarcodeValue').'</td>';
732
-                    print '<td><input class="flat" name="barcode"  value="'.($rowid ? $object->fourn_barcode : '').'"></td>';
733
-                    print '</tr>';
734
-                    $formbarcode = new FormBarCode($db);
735
-
736
-                    // Barcode type
737
-                    print '<tr>';
738
-                    print '<td>'.$langs->trans('BarcodeType').'</td>';
739
-                    print '<td>';
740
-                    print $formbarcode->selectBarcodeType(($rowid ? $object->fourn_fk_barcode_type : $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE), 'fk_barcode_type', 1);
741
-                    print '</td>';
742
-                    print '</tr>';
743
-                }
727
+				if (!empty($conf->barcode->enabled))
728
+				{
729
+					// Option to define a transport cost on supplier price
730
+					print '<tr>';
731
+					print '<td>'.$langs->trans('BarcodeValue').'</td>';
732
+					print '<td><input class="flat" name="barcode"  value="'.($rowid ? $object->fourn_barcode : '').'"></td>';
733
+					print '</tr>';
734
+					$formbarcode = new FormBarCode($db);
735
+
736
+					// Barcode type
737
+					print '<tr>';
738
+					print '<td>'.$langs->trans('BarcodeType').'</td>';
739
+					print '<td>';
740
+					print $formbarcode->selectBarcodeType(($rowid ? $object->fourn_fk_barcode_type : $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE), 'fk_barcode_type', 1);
741
+					print '</td>';
742
+					print '</tr>';
743
+				}
744 744
 
745 745
 				// Option to define a transport cost on supplier price
746 746
 				if ($conf->global->PRODUCT_CHARGES)
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
 						print '<tr>';
751 751
 						print '<td>'.$langs->trans("Charges").'</td>';
752 752
 						print '<td><input class="flat" name="charges" size="8" value="'.(GETPOST('charges') ?price(GETPOST('charges')) : (isset($object->fourn_charges) ?price($object->fourn_charges) : '')).'">';
753
-		        		print '</td>';
753
+						print '</td>';
754 754
 						print '</tr>';
755 755
 					}
756 756
 				}
@@ -758,69 +758,69 @@  discard block
 block discarded – undo
758 758
 				// Product description of the supplier
759 759
 				if (!empty($conf->global->PRODUIT_FOURN_TEXTS))
760 760
 				{
761
-				    //WYSIWYG Editor
762
-				    require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
761
+					//WYSIWYG Editor
762
+					require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
763 763
 
764
-    				print '<tr>';
765
-    				print '<td>'.$langs->trans('ProductSupplierDescription').'</td>';
766
-    				print '<td>';
764
+					print '<tr>';
765
+					print '<td>'.$langs->trans('ProductSupplierDescription').'</td>';
766
+					print '<td>';
767 767
 
768
-    				$doleditor = new DolEditor('supplier_description', $object->desc_supplier, '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%');
769
-    				$doleditor->Create();
768
+					$doleditor = new DolEditor('supplier_description', $object->desc_supplier, '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%');
769
+					$doleditor->Create();
770 770
 
771
-    				print '</td>';
772
-    				print '</tr>';
771
+					print '</td>';
772
+					print '</tr>';
773 773
 				}
774 774
 
775
-                // Extrafields
775
+				// Extrafields
776 776
 				$extrafields->fetch_name_optionals_label("product_fournisseur_price");
777 777
 				$extralabels = $extrafields->attributes["product_fournisseur_price"]['label'];
778
-                $extrafield_values = $extrafields->getOptionalsFromPost("product_fournisseur_price");
778
+				$extrafield_values = $extrafields->getOptionalsFromPost("product_fournisseur_price");
779 779
 				if (!empty($extralabels)) {
780
-                    if (empty($rowid)) {
781
-                        foreach ($extralabels as $key => $value) {
782
-                            if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) {
783
-                                if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
784
-
785
-                                print '<tr><td'.($extrafields->attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>';
786
-                                if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
787
-                                else print $langs->trans($value);
788
-                                print '</td><td>'.$extrafields->showInputField($key, GETPOSTISSET('options_'.$key) ? $extrafield_values['options_'.$key] : '', '', '', '', '', 0, 'product_fournisseur_price').'</td></tr>';
789
-                            }
790
-                        }
791
-                    } else {
792
-                        $sql  = "SELECT";
793
-                        $sql .= " fk_object";
794
-                        foreach ($extralabels as $key => $value) {
795
-                            $sql .= ", ".$key;
796
-                        }
797
-                        $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields";
798
-                        $sql .= " WHERE fk_object = ".$rowid;
799
-                        $resql = $db->query($sql);
800
-                        if ($resql) {
801
-                            $obj = $db->fetch_object($resql);
802
-                            foreach ($extralabels as $key => $value) {
803
-                                if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) {
804
-                                    if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
805
-
806
-                                    print '<tr><td'.($extrafields->attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>';
807
-                                    if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
808
-                                    else print $langs->trans($value);
809
-                                    print '</td><td>'.$extrafields->showInputField($key, GETPOSTISSET('options_'.$key) ? $extrafield_values['options_'.$key] : $obj->{$key}, '', '', '', '', 0, 'product_fournisseur_price');
810
-
811
-                                    print '</td></tr>';
812
-                                }
813
-                            }
814
-                            $db->free($resql);
815
-                        }
816
-                    }
780
+					if (empty($rowid)) {
781
+						foreach ($extralabels as $key => $value) {
782
+							if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) {
783
+								if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
784
+
785
+								print '<tr><td'.($extrafields->attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>';
786
+								if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
787
+								else print $langs->trans($value);
788
+								print '</td><td>'.$extrafields->showInputField($key, GETPOSTISSET('options_'.$key) ? $extrafield_values['options_'.$key] : '', '', '', '', '', 0, 'product_fournisseur_price').'</td></tr>';
789
+							}
790
+						}
791
+					} else {
792
+						$sql  = "SELECT";
793
+						$sql .= " fk_object";
794
+						foreach ($extralabels as $key => $value) {
795
+							$sql .= ", ".$key;
796
+						}
797
+						$sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields";
798
+						$sql .= " WHERE fk_object = ".$rowid;
799
+						$resql = $db->query($sql);
800
+						if ($resql) {
801
+							$obj = $db->fetch_object($resql);
802
+							foreach ($extralabels as $key => $value) {
803
+								if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) {
804
+									if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
805
+
806
+									print '<tr><td'.($extrafields->attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>';
807
+									if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
808
+									else print $langs->trans($value);
809
+									print '</td><td>'.$extrafields->showInputField($key, GETPOSTISSET('options_'.$key) ? $extrafield_values['options_'.$key] : $obj->{$key}, '', '', '', '', 0, 'product_fournisseur_price');
810
+
811
+									print '</td></tr>';
812
+								}
813
+							}
814
+							$db->free($resql);
815
+						}
816
+					}
817 817
 				}
818 818
 
819 819
 				if (is_object($hookmanager))
820 820
 				{
821 821
 					$parameters = array('id_fourn'=>$id_fourn, 'prod_id'=>$object->id);
822
-				    $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action);
823
-                    print $hookmanager->resPrint;
822
+					$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action);
823
+					print $hookmanager->resPrint;
824 824
 				}
825 825
 
826 826
 				print '</table>';
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
 				if (!empty($arrayfields['pfp.quantity']['checked']))				print_liste_field_titre("QtyMin", $_SERVER["PHP_SELF"], "pfp.quantity", "", $param, '', $sortfield, $sortorder, 'right ');
932 932
 				print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
933 933
 				print_liste_field_titre("PriceQtyMinHT", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
934
-                if ($conf->multicurrency->enabled)									print_liste_field_titre("PriceQtyMinHTCurrency", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
935
-                if (!empty($arrayfields['pfp.unitprice']['checked']))				print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "pfp.unitprice", "", $param, '', $sortfield, $sortorder, 'right ');
934
+				if ($conf->multicurrency->enabled)									print_liste_field_titre("PriceQtyMinHTCurrency", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
935
+				if (!empty($arrayfields['pfp.unitprice']['checked']))				print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "pfp.unitprice", "", $param, '', $sortfield, $sortorder, 'right ');
936 936
 				if (!empty($arrayfields['pfp.multicurrency_unitprice']['checked']))	print_liste_field_titre("UnitPriceHTCurrency", $_SERVER["PHP_SELF"], "pfp.multicurrency_unitprice", "", $param, '', $sortfield, $sortorder, 'right ');
937 937
 				if ($conf->multicurrency->enabled)									print_liste_field_titre("Currency", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
938 938
 				print_liste_field_titre("DiscountQtyMin", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
@@ -951,8 +951,8 @@  discard block
 block discarded – undo
951 951
 					foreach ($extralabels as $key => $value) {
952 952
 						// Show field if not hidden
953 953
 						if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
954
-                            if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
955
-                            if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
954
+							if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
955
+							if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
956 956
 							else $extratitle = $langs->trans($value);
957 957
 							if (!empty($arrayfields['ef.'.$key]['checked'])) print_liste_field_titre($extratitle, $_SERVER["PHP_SELF"], 'ef.'.$key, '', $param, '', $sortfield, $sortorder, 'right ');
958 958
 						}
@@ -961,8 +961,8 @@  discard block
 block discarded – undo
961 961
 
962 962
 				if (is_object($hookmanager))
963 963
 				{
964
-				    $parameters = array('id_fourn'=>$id_fourn, 'prod_id'=>$object->id);
965
-				    $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action);
964
+					$parameters = array('id_fourn'=>$id_fourn, 'prod_id'=>$object->id);
965
+					$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action);
966 966
 				}
967 967
 				print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
968 968
 				print "</tr>\n";
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 						if (!empty($arrayfields['pfp.fk_availability']['checked']))
996 996
 						{
997 997
 							$form->load_cache_availability();
998
-                			$availability = $form->cache_availability[$productfourn->fk_availability]['label'];
998
+							$availability = $form->cache_availability[$productfourn->fk_availability]['label'];
999 999
 							print '<td class="left">'.$availability.'</td>';
1000 1000
 						}
1001 1001
 
@@ -1023,12 +1023,12 @@  discard block
 block discarded – undo
1023 1023
 						print $productfourn->fourn_price ?price($productfourn->fourn_price) : "";
1024 1024
 						print '</td>';
1025 1025
 
1026
-                        if ($conf->multicurrency->enabled) {
1027
-                            // Price for the quantity in currency
1028
-                            print '<td class="right">';
1029
-                            print $productfourn->fourn_multicurrency_price ? price($productfourn->fourn_multicurrency_price) : "";
1030
-                            print '</td>';
1031
-                        }
1026
+						if ($conf->multicurrency->enabled) {
1027
+							// Price for the quantity in currency
1028
+							print '<td class="right">';
1029
+							print $productfourn->fourn_multicurrency_price ? price($productfourn->fourn_multicurrency_price) : "";
1030
+							print '</td>';
1031
+						}
1032 1032
 
1033 1033
 						// Unit price
1034 1034
 						if (!empty($arrayfields['pfp.unitprice']['checked'])) {
@@ -1040,16 +1040,16 @@  discard block
 block discarded – undo
1040 1040
 
1041 1041
 						// Unit price in currency
1042 1042
 						if (!empty($arrayfields['pfp.multicurrency_unitprice']['checked'])) {
1043
-                            print '<td class="right">';
1044
-                            print price($productfourn->fourn_multicurrency_unitprice);
1045
-                            print '</td>';}
1043
+							print '<td class="right">';
1044
+							print price($productfourn->fourn_multicurrency_unitprice);
1045
+							print '</td>';}
1046 1046
 
1047 1047
 						// Currency
1048
-                        if ($conf->multicurrency->enabled) {
1049
-                            print '<td class="right">';
1050
-                            print $productfourn->fourn_multicurrency_code ? currency_name($productfourn->fourn_multicurrency_code) : '';
1051
-                            print '</td>';
1052
-                        }
1048
+						if ($conf->multicurrency->enabled) {
1049
+							print '<td class="right">';
1050
+							print $productfourn->fourn_multicurrency_code ? currency_name($productfourn->fourn_multicurrency_code) : '';
1051
+							print '</td>';
1052
+						}
1053 1053
 
1054 1054
 						// Discount
1055 1055
 						print '<td class="right">';
@@ -1074,18 +1074,18 @@  discard block
 block discarded – undo
1074 1074
 
1075 1075
 						// Barcode
1076 1076
 						if (!empty($arrayfields['pfp.barcode']['checked'])) {
1077
-                            print '<td align="right">';
1078
-                            print $productfourn->barcode;
1077
+							print '<td align="right">';
1078
+							print $productfourn->barcode;
1079 1079
 							print '</td>';
1080 1080
 						}
1081 1081
 
1082 1082
 						// Barcode type
1083 1083
 						if (!empty($arrayfields['pfp.fk_barcode_type']['checked'])) {
1084
-                            print '<td class="center">';
1085
-                            $productfourn->barcode_type = !empty($productfourn->fk_barcode_type) ? $productfourn->fk_barcode_type : 0;
1086
-                            $productfourn->fetch_barcode();
1087
-                            print $productfourn->barcode_type_label ? $productfourn->barcode_type_label : ($productfourn->barcode ? '<div class="warning">'.$langs->trans("SetDefaultBarcodeType").'<div>' : '');
1088
-                            print '</td>';
1084
+							print '<td class="center">';
1085
+							$productfourn->barcode_type = !empty($productfourn->fk_barcode_type) ? $productfourn->fk_barcode_type : 0;
1086
+							$productfourn->fetch_barcode();
1087
+							print $productfourn->barcode_type_label ? $productfourn->barcode_type_label : ($productfourn->barcode ? '<div class="warning">'.$langs->trans("SetDefaultBarcodeType").'<div>' : '');
1088
+							print '</td>';
1089 1089
 						}
1090 1090
 
1091 1091
 						// Packaging
@@ -1104,37 +1104,37 @@  discard block
 block discarded – undo
1104 1104
 
1105 1105
 						// Extrafields
1106 1106
 						if (!empty($extralabels)) {
1107
-                            $sql  = "SELECT";
1108
-                            $sql .= " fk_object";
1109
-                            foreach ($extralabels as $key => $value) {
1110
-                                $sql .= ", ".$key;
1111
-                            }
1112
-                            $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields";
1113
-                            $sql .= " WHERE fk_object = ".$productfourn->product_fourn_price_id;
1114
-                            $resql = $db->query($sql);
1115
-                            if ($resql) {
1116
-                                if ($db->num_rows($resql) != 1) {
1117
-                                    foreach ($extralabels as $key => $value) {
1118
-                                        if (!empty($arrayfields['ef.'.$key]['checked']) && !empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
1119
-                                            print "<td></td>";
1120
-                                        }
1121
-                                    }
1122
-                                } else {
1123
-                                    $obj = $db->fetch_object($resql);
1124
-                                    foreach ($extralabels as $key => $value) {
1125
-                                        if (!empty($arrayfields['ef.'.$key]['checked']) && !empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
1126
-                                            print '<td align="right">'.$extrafields->showOutputField($key, $obj->{$key})."</td>";
1127
-                                        }
1128
-                                    }
1129
-                                }
1130
-                                $db->free($resql);
1131
-                            }
1107
+							$sql  = "SELECT";
1108
+							$sql .= " fk_object";
1109
+							foreach ($extralabels as $key => $value) {
1110
+								$sql .= ", ".$key;
1111
+							}
1112
+							$sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields";
1113
+							$sql .= " WHERE fk_object = ".$productfourn->product_fourn_price_id;
1114
+							$resql = $db->query($sql);
1115
+							if ($resql) {
1116
+								if ($db->num_rows($resql) != 1) {
1117
+									foreach ($extralabels as $key => $value) {
1118
+										if (!empty($arrayfields['ef.'.$key]['checked']) && !empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
1119
+											print "<td></td>";
1120
+										}
1121
+									}
1122
+								} else {
1123
+									$obj = $db->fetch_object($resql);
1124
+									foreach ($extralabels as $key => $value) {
1125
+										if (!empty($arrayfields['ef.'.$key]['checked']) && !empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
1126
+											print '<td align="right">'.$extrafields->showOutputField($key, $obj->{$key})."</td>";
1127
+										}
1128
+									}
1129
+								}
1130
+								$db->free($resql);
1131
+							}
1132 1132
 						}
1133 1133
 
1134 1134
 						if (is_object($hookmanager))
1135 1135
 						{
1136 1136
 							$parameters = array('id_pfp'=>$productfourn->product_fourn_price_id, 'id_fourn'=>$id_fourn, 'prod_id'=>$object->id);
1137
-						    $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action);
1137
+							$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action);
1138 1138
 						}
1139 1139
 
1140 1140
 						// Modify-Remove
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 						print '</tr>';
1153 1153
 					}
1154 1154
 				} else {
1155
-				    dol_print_error($db);
1155
+					dol_print_error($db);
1156 1156
 				}
1157 1157
 
1158 1158
 				print '</table>';
Please login to merge, or discard this patch.