Completed
Branch develop (404fac)
by
unknown
20:18
created
htdocs/product/stock/stocktransfer/class/stocktransfer.class.php 1 patch
Braces   +71 added lines, -25 removed lines patch added patch discarded remove patch
@@ -183,8 +183,12 @@  discard block
 block discarded – undo
183 183
 		$this->db = $db;
184 184
 		$this->origin_type = 'StockTransfer@product/stock/stocktransfer';
185 185
 
186
-		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0;
187
-		if (!isModEnabled('multicompany') && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0;
186
+		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
187
+			$this->fields['rowid']['visible'] = 0;
188
+		}
189
+		if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
190
+			$this->fields['entity']['enabled'] = 0;
191
+		}
188 192
 
189 193
 		// Example to show how to set values of fields definition dynamically
190 194
 		/*if ($user->rights->stocktransfer->stocktransfer->read) {
@@ -221,10 +225,16 @@  discard block
 block discarded – undo
221 225
 	public function create(User $user, $notrigger = false)
222 226
 	{
223 227
 		$model_pdf = GETPOST('model');
224
-		if (!empty($model_pdf)) $this->model_pdf = $model_pdf;
228
+		if (!empty($model_pdf)) {
229
+			$this->model_pdf = $model_pdf;
230
+		}
225 231
 		$this->status = (int) $this->status;
226
-		if ($this->fk_warehouse_source <= 0) $this->fk_warehouse_source = 0;
227
-		if ($this->fk_warehouse_destination <= 0) $this->fk_warehouse_destination = 0;
232
+		if ($this->fk_warehouse_source <= 0) {
233
+			$this->fk_warehouse_source = 0;
234
+		}
235
+		if ($this->fk_warehouse_destination <= 0) {
236
+			$this->fk_warehouse_destination = 0;
237
+		}
228 238
 		return $this->createCommon($user, $notrigger);
229 239
 	}
230 240
 
@@ -248,7 +258,9 @@  discard block
 block discarded – undo
248 258
 
249 259
 		// Load source object
250 260
 		$result = $object->fetchCommon($fromid);
251
-		if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines();
261
+		if ($result > 0 && !empty($object->table_element_line)) {
262
+			$object->fetchLines();
263
+		}
252 264
 
253 265
 		// get lines so they will be clone
254 266
 		//foreach($this->lines as $line)
@@ -300,8 +312,9 @@  discard block
 block discarded – undo
300 312
 		if (!$error) {
301 313
 			// copy external contacts if same company
302 314
 			if (property_exists($this, 'socid') && $this->socid == $object->socid) {
303
-				if ($this->copy_linked_contact($object, 'external') < 0)
304
-					$error++;
315
+				if ($this->copy_linked_contact($object, 'external') < 0) {
316
+									$error++;
317
+				}
305 318
 			}
306 319
 		}
307 320
 
@@ -327,7 +340,9 @@  discard block
 block discarded – undo
327 340
 	public function fetch($id, $ref = null)
328 341
 	{
329 342
 		$result = $this->fetchCommon($id, $ref);
330
-		if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
343
+		if ($result > 0 && !empty($this->table_element_line)) {
344
+			$this->fetchLines();
345
+		}
331 346
 		return $result;
332 347
 	}
333 348
 
@@ -371,9 +386,13 @@  discard block
 block discarded – undo
371 386
 
372 387
 		$total_pmp = 0;
373 388
 
374
-		if (empty($this->lines)) $this->fetchLines();
389
+		if (empty($this->lines)) {
390
+			$this->fetchLines();
391
+		}
375 392
 		if (!empty($this->lines)) {
376
-			foreach ($this->lines as $l) $total_pmp+= ($l->pmp * $l->qty);
393
+			foreach ($this->lines as $l) {
394
+				$total_pmp+= ($l->pmp * $l->qty);
395
+			}
377 396
 		}
378 397
 
379 398
 		return $total_pmp;
@@ -401,8 +420,11 @@  discard block
 block discarded – undo
401 420
 		$sql = 'SELECT ';
402 421
 		$sql .= $this->getFieldList();
403 422
 		$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
404
-		if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')';
405
-		else $sql .= ' WHERE 1 = 1';
423
+		if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
424
+			$sql .= ' WHERE t.entity IN ('.getEntity($this->element).')';
425
+		} else {
426
+			$sql .= ' WHERE 1 = 1';
427
+		}
406 428
 		// Manage filter
407 429
 		$sqlwhere = array();
408 430
 		if (count($filter) > 0) {
@@ -465,8 +487,12 @@  discard block
 block discarded – undo
465 487
 	{
466 488
 		$this->tms = ''; // Will be done automatically because tms field is on update cascade
467 489
 		$res = $this->updateCommon($user, $notrigger);
468
-		if ($this->socid > 0 || $this->fk_soc > 0 && empty($this->thirdparty)) $this->fetch_thirdparty();
469
-		if (empty($this->socid) && empty($this->fk_soc)) unset($this->thirdparty);
490
+		if ($this->socid > 0 || $this->fk_soc > 0 && empty($this->thirdparty)) {
491
+			$this->fetch_thirdparty();
492
+		}
493
+		if (empty($this->socid) && empty($this->fk_soc)) {
494
+			unset($this->thirdparty);
495
+		}
470 496
 		return $res;
471 497
 	}
472 498
 
@@ -553,8 +579,12 @@  discard block
 block discarded – undo
553 579
 			$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
554 580
 			$sql .= " SET ref = '".$this->db->escape($num)."',";
555 581
 			$sql .= " status = ".self::STATUS_VALIDATED;
556
-			if (!empty($this->fields['date_validation'])) $sql .= ", date_validation = '".$this->db->idate($now)."',";
557
-			if (!empty($this->fields['fk_user_valid'])) $sql .= ", fk_user_valid = ".((int) $user->id);
582
+			if (!empty($this->fields['date_validation'])) {
583
+				$sql .= ", date_validation = '".$this->db->idate($now)."',";
584
+			}
585
+			if (!empty($this->fields['fk_user_valid'])) {
586
+				$sql .= ", fk_user_valid = ".((int) $user->id);
587
+			}
558 588
 			$sql .= " WHERE rowid = ".((int) $this->id);
559 589
 
560 590
 			dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
@@ -568,7 +598,9 @@  discard block
 block discarded – undo
568 598
 			if (!$error && !$notrigger) {
569 599
 				// Call trigger
570 600
 				$result = $this->call_trigger('STOCKTRANSFER_VALIDATE', $user);
571
-				if ($result < 0) $error++;
601
+				if ($result < 0) {
602
+					$error++;
603
+				}
572 604
 				// End call triggers
573 605
 			}
574 606
 		}
@@ -710,7 +742,10 @@  discard block
 block discarded – undo
710 742
 	{
711 743
 		global $conf, $langs, $hookmanager;
712 744
 
713
-		if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
745
+		if (!empty($conf->dol_no_mouse_hover)) {
746
+			$notooltip = 1;
747
+		}
748
+		// Force disable tooltips
714 749
 
715 750
 		$result = '';
716 751
 
@@ -742,7 +777,9 @@  discard block
 block discarded – undo
742 777
 			}
743 778
 			$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
744 779
 			$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
745
-		} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
780
+		} else {
781
+			$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
782
+		}
746 783
 
747 784
 		$linkstart = '<a href="'.$url.'"';
748 785
 		$linkstart .= $linkclose.'>';
@@ -751,7 +788,9 @@  discard block
 block discarded – undo
751 788
 		$result .= $linkstart;
752 789
 
753 790
 		if (empty($this->showphoto_on_popup)) {
754
-			if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
791
+			if ($withpicto) {
792
+				$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
793
+			}
755 794
 		} else {
756 795
 			if ($withpicto) {
757 796
 				require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@@ -777,7 +816,9 @@  discard block
 block discarded – undo
777 816
 			}
778 817
 		}
779 818
 
780
-		if ($withpicto != 2) $result .= $this->ref;
819
+		if ($withpicto != 2) {
820
+			$result .= $this->ref;
821
+		}
781 822
 
782 823
 		$result .= $linkend;
783 824
 		//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@@ -786,8 +827,11 @@  discard block
 block discarded – undo
786 827
 		$hookmanager->initHooks(array('stocktransferdao'));
787 828
 		$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
788 829
 		$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
789
-		if ($reshook > 0) $result = $hookmanager->resPrint;
790
-		else $result .= $hookmanager->resPrint;
830
+		if ($reshook > 0) {
831
+			$result = $hookmanager->resPrint;
832
+		} else {
833
+			$result .= $hookmanager->resPrint;
834
+		}
791 835
 
792 836
 		return $result;
793 837
 	}
@@ -829,7 +873,9 @@  discard block
 block discarded – undo
829 873
 
830 874
 		$statusType = 'status'.$status;
831 875
 		//if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
832
-		if ($status == self::STATUS_CLOSED) $statusType = 'status6';
876
+		if ($status == self::STATUS_CLOSED) {
877
+			$statusType = 'status6';
878
+		}
833 879
 
834 880
 		return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
835 881
 	}
Please login to merge, or discard this patch.
htdocs/product/stock/stocktransfer/class/stocktransferline.class.php 1 patch
Braces   +50 added lines, -18 removed lines patch added patch discarded remove patch
@@ -128,8 +128,12 @@  discard block
 block discarded – undo
128 128
 
129 129
 		$this->db = $db;
130 130
 
131
-		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0;
132
-		if (!isModEnabled('multicompany') && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0;
131
+		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
132
+			$this->fields['rowid']['visible'] = 0;
133
+		}
134
+		if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
135
+			$this->fields['entity']['enabled'] = 0;
136
+		}
133 137
 
134 138
 		// Example to show how to set values of fields definition dynamically
135 139
 		/*if ($user->rights->stocktransfer->stocktransferline->read) {
@@ -188,7 +192,9 @@  discard block
 block discarded – undo
188 192
 
189 193
 		// Load source object
190 194
 		$result = $object->fetchCommon($fromid);
191
-		if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines();
195
+		if ($result > 0 && !empty($object->table_element_line)) {
196
+			$object->fetchLines();
197
+		}
192 198
 
193 199
 		// get lines so they will be clone
194 200
 		//foreach($this->lines as $line)
@@ -235,8 +241,9 @@  discard block
 block discarded – undo
235 241
 		if (!$error) {
236 242
 			// copy external contacts if same company
237 243
 			if (property_exists($this, 'socid') && $this->socid == $object->socid) {
238
-				if ($this->copy_linked_contact($object, 'external') < 0)
239
-					$error++;
244
+				if ($this->copy_linked_contact($object, 'external') < 0) {
245
+									$error++;
246
+				}
240 247
 			}
241 248
 		}
242 249
 
@@ -262,7 +269,9 @@  discard block
 block discarded – undo
262 269
 	public function fetch($id, $ref = null)
263 270
 	{
264 271
 		$result = $this->fetchCommon($id, $ref);
265
-		if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
272
+		if ($result > 0 && !empty($this->table_element_line)) {
273
+			$this->fetchLines();
274
+		}
266 275
 		return $result;
267 276
 	}
268 277
 
@@ -300,8 +309,11 @@  discard block
 block discarded – undo
300 309
 		$sql = 'SELECT ';
301 310
 		$sql .= $this->getFieldList();
302 311
 		$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
303
-		if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')';
304
-		else $sql .= ' WHERE 1 = 1';
312
+		if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
313
+			$sql .= ' WHERE t.entity IN ('.getEntity($this->element).')';
314
+		} else {
315
+			$sql .= ' WHERE 1 = 1';
316
+		}
305 317
 		// Manage filter
306 318
 		$sqlwhere = array();
307 319
 		if (count($filter) > 0) {
@@ -548,8 +560,12 @@  discard block
 block discarded – undo
548 560
 			$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
549 561
 			$sql .= " SET ref = '".$this->db->escape($num)."',";
550 562
 			$sql .= " status = ".self::STATUS_VALIDATED;
551
-			if (!empty($this->fields['date_validation'])) $sql .= ", date_validation = '".$this->db->idate($now)."',";
552
-			if (!empty($this->fields['fk_user_valid'])) $sql .= ", fk_user_valid = ".((int) $user->id);
563
+			if (!empty($this->fields['date_validation'])) {
564
+				$sql .= ", date_validation = '".$this->db->idate($now)."',";
565
+			}
566
+			if (!empty($this->fields['fk_user_valid'])) {
567
+				$sql .= ", fk_user_valid = ".((int) $user->id);
568
+			}
553 569
 			$sql .= " WHERE rowid = ".((int) $this->id);
554 570
 
555 571
 			dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
@@ -563,7 +579,9 @@  discard block
 block discarded – undo
563 579
 			if (!$error && !$notrigger) {
564 580
 				// Call trigger
565 581
 				$result = $this->call_trigger('STOCKTRANSFERLINE_VALIDATE', $user);
566
-				if ($result < 0) $error++;
582
+				if ($result < 0) {
583
+					$error++;
584
+				}
567 585
 				// End call triggers
568 586
 			}
569 587
 		}
@@ -705,7 +723,10 @@  discard block
 block discarded – undo
705 723
 	{
706 724
 		global $conf, $langs, $hookmanager;
707 725
 
708
-		if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
726
+		if (!empty($conf->dol_no_mouse_hover)) {
727
+			$notooltip = 1;
728
+		}
729
+		// Force disable tooltips
709 730
 
710 731
 		$result = '';
711 732
 
@@ -737,7 +758,9 @@  discard block
 block discarded – undo
737 758
 			}
738 759
 			$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
739 760
 			$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
740
-		} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
761
+		} else {
762
+			$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
763
+		}
741 764
 
742 765
 		$linkstart = '<a href="'.$url.'"';
743 766
 		$linkstart .= $linkclose.'>';
@@ -746,7 +769,9 @@  discard block
 block discarded – undo
746 769
 		$result .= $linkstart;
747 770
 
748 771
 		if (empty($this->showphoto_on_popup)) {
749
-			if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
772
+			if ($withpicto) {
773
+				$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
774
+			}
750 775
 		} else {
751 776
 			if ($withpicto) {
752 777
 				require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@@ -772,7 +797,9 @@  discard block
 block discarded – undo
772 797
 			}
773 798
 		}
774 799
 
775
-		if ($withpicto != 2) $result .= $this->ref;
800
+		if ($withpicto != 2) {
801
+			$result .= $this->ref;
802
+		}
776 803
 
777 804
 		$result .= $linkend;
778 805
 		//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@@ -781,8 +808,11 @@  discard block
 block discarded – undo
781 808
 		$hookmanager->initHooks(array('stocktransferlinedao'));
782 809
 		$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
783 810
 		$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
784
-		if ($reshook > 0) $result = $hookmanager->resPrint;
785
-		else $result .= $hookmanager->resPrint;
811
+		if ($reshook > 0) {
812
+			$result = $hookmanager->resPrint;
813
+		} else {
814
+			$result .= $hookmanager->resPrint;
815
+		}
786 816
 
787 817
 		return $result;
788 818
 	}
@@ -822,7 +852,9 @@  discard block
 block discarded – undo
822 852
 
823 853
 		$statusType = 'status'.$status;
824 854
 		//if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
825
-		if ($status == self::STATUS_CANCELED) $statusType = 'status6';
855
+		if ($status == self::STATUS_CANCELED) {
856
+			$statusType = 'status6';
857
+		}
826 858
 
827 859
 		return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
828 860
 	}
Please login to merge, or discard this patch.
htdocs/takepos/ajax/ajax.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
44 44
 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
45 45
 
46
-$category = GETPOST('category', 'alphanohtml');	// Can be id of category or 'supplements'
46
+$category = GETPOST('category', 'alphanohtml'); // Can be id of category or 'supplements'
47 47
 $action = GETPOST('action', 'aZ09');
48 48
 $term = GETPOST('term', 'alpha');
49 49
 $id = GETPOST('id', 'int');
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
58 58
 $hookmanager->initHooks(array('takeposproductsearch')); // new context for product search hooks
59 59
 
60
-$pricelevel = 1;	// default price level if PRODUIT_MULTIPRICES. TODO Get price level from thirdparty.
60
+$pricelevel = 1; // default price level if PRODUIT_MULTIPRICES. TODO Get price level from thirdparty.
61 61
 
62 62
 
63 63
 
@@ -194,14 +194,14 @@  discard block
 block discarded – undo
194 194
 			if (isset($barcode_value_list['ref'])) {
195 195
 				// search product from reference
196 196
 				$sql  = "SELECT rowid, ref, label, tosell, tobuy, barcode, price, price_ttc";
197
-				$sql .= " FROM " . $db->prefix() . "product as p";
198
-				$sql .= " WHERE entity IN (" . getEntity('product') . ")";
199
-				$sql .= " AND ref = '" . $db->escape($barcode_value_list['ref']) . "'";
197
+				$sql .= " FROM ".$db->prefix()."product as p";
198
+				$sql .= " WHERE entity IN (".getEntity('product').")";
199
+				$sql .= " AND ref = '".$db->escape($barcode_value_list['ref'])."'";
200 200
 				if ($filteroncategids) {
201
-					$sql .= " AND EXISTS (SELECT cp.fk_product FROM " . $db->prefix() . "categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN (".$db->sanitize($filteroncategids)."))";
201
+					$sql .= " AND EXISTS (SELECT cp.fk_product FROM ".$db->prefix()."categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN (".$db->sanitize($filteroncategids)."))";
202 202
 				}
203 203
 				$sql .= " AND tosell = 1";
204
-				$sql .= " AND (barcode IS NULL OR barcode <> '" . $db->escape($term) . "')";
204
+				$sql .= " AND (barcode IS NULL OR barcode <> '".$db->escape($term)."')";
205 205
 
206 206
 				$resql = $db->query($sql);
207 207
 				if ($resql && $db->num_rows($resql) == 1) {
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 						if (isset($barcode_value_list['qu'])) {
211 211
 							$qty_str = $barcode_value_list['qu'];
212 212
 							if (isset($barcode_value_list['qd'])) {
213
-								$qty_str .= '.' . $barcode_value_list['qd'];
213
+								$qty_str .= '.'.$barcode_value_list['qd'];
214 214
 							}
215 215
 							$qty = floatval($qty_str);
216 216
 						}
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 		}
261 261
 	}
262 262
 
263
-	$sql = 'SELECT p.rowid, p.ref, p.label, p.tosell, p.tobuy, p.barcode, p.price, p.price_ttc' ;
263
+	$sql = 'SELECT p.rowid, p.ref, p.label, p.tosell, p.tobuy, p.barcode, p.price, p.price_ttc';
264 264
 	if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) {
265 265
 		$sql .= ', ps.reel';
266 266
 	}
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 	}
313 313
 
314 314
 	// load only one page of products
315
-	$sql.= $db->plimit($search_limit, $search_start);
315
+	$sql .= $db->plimit($search_limit, $search_start);
316 316
 
317 317
 	$resql = $db->query($sql);
318 318
 	if ($resql) {
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 				'price_ttc_formated' => price(price2num(empty($objProd->multiprices_ttc[$pricelevel]) ? $obj->price_ttc : $objProd->multiprices_ttc[$pricelevel], 'MT'), 1, $langs, 1, -1, -1, $conf->currency)
354 354
 			);
355 355
 			// Add entries to row from hooks
356
-			$parameters=array();
356
+			$parameters = array();
357 357
 			$parameters['row'] = $row;
358 358
 			$parameters['obj'] = $obj;
359 359
 			$reshook = $hookmanager->executeHooks('completeAjaxReturnArray', $parameters);
Please login to merge, or discard this patch.
htdocs/takepos/index.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 $arrayofcss = array('/takepos/css/pos.css.php', '/takepos/css/colorbox.css');
119 119
 
120 120
 if (getDolGlobalInt('TAKEPOS_COLOR_THEME') == 1) {
121
-	$arrayofcss[] =  '/takepos/css/colorful.css';
121
+	$arrayofcss[] = '/takepos/css/colorful.css';
122 122
 }
123 123
 
124 124
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 		limit = maxproduct-1;
332 332
 	}
333 333
 	// Only show products for sale (tosell=1)
334
-	$.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&category='+currentcat+'&tosell=1&limit='+limit+'&offset=0', function(data) {
334
+	$.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken(); ?>&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&category='+currentcat+'&tosell=1&limit='+limit+'&offset=0', function(data) {
335 335
 		console.log("Call ajax.php (in LoadProducts) to get Products of category "+currentcat+" then loop on result to fill image thumbs");
336 336
 		console.log(data);
337 337
 		while (ishow < maxproduct) {
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 
388 388
 				<?php
389 389
 				// Add js from hooks
390
-				$parameters=array();
390
+				$parameters = array();
391 391
 				$parameters['caller'] = 'loadProducts';
392 392
 				$hookmanager->executeHooks('completeJSProductDisplay', $parameters);
393 393
 				print $hookmanager->resPrint;
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 	}
432 432
 	var offset = <?php echo ($MAXPRODUCT - 2); ?> * pageproducts;
433 433
 	// Only show products for sale (tosell=1)
434
-	$.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&category='+currentcat+'&tosell=1&limit='+limit+'&offset='+offset, function(data) {
434
+	$.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken(); ?>&category='+currentcat+'&tosell=1&limit='+limit+'&offset='+offset, function(data) {
435 435
 		console.log("Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
436 436
 
437 437
 		if (typeof (data[0]) == "undefined" && moreorless=="more"){ // Return if no more pages
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 		if (idproduct=="") return;
493 493
 		// Call page invoice.php to generate the section with product lines
494 494
 		$("#poslines").load("invoice.php?action=addline&token=<?php echo newToken() ?>&place="+place+"&idproduct="+idproduct+"&selectedline="+selectedline+"&qty="+qty, function() {
495
-			<?php if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) echo "CustomerDisplay();";?>
495
+			<?php if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) echo "CustomerDisplay();"; ?>
496 496
 		});
497 497
 	}
498 498
 
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 function ChangeThirdparty(idcustomer) {
503 503
 	 console.log("ChangeThirdparty");
504 504
 		// Call page list.php to change customer
505
-		$("#poslines").load("../societe/list.php?action=change&token=<?php echo newToken();?>&type=t&contextpage=poslist&idcustomer="+idcustomer+"&place="+place+"", function() {
505
+		$("#poslines").load("../societe/list.php?action=change&token=<?php echo newToken(); ?>&type=t&contextpage=poslist&idcustomer="+idcustomer+"&place="+place+"", function() {
506 506
 		});
507 507
 
508 508
 	ClearSearch();
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 
575 575
 	console.log("New with place = <?php echo $place; ?>, js place="+place+", invoiceid="+invoiceid);
576 576
 
577
-	$.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid, function(data) {
577
+	$.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken(); ?>&id='+invoiceid, function(data) {
578 578
 		var r;
579 579
 
580 580
 		if (parseInt(data['paye']) === 1) {
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 			pageproducts = 0;
645 645
 			jQuery(".wrapper2 .catwatermark").hide();
646 646
 			var nbsearchresults = 0;
647
-			$.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&token=<?php echo newToken();?>&term=' + search_term + '&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) {
647
+			$.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&token=<?php echo newToken(); ?>&term=' + search_term + '&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) {
648 648
 				for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) {
649 649
 					if (typeof (data[i]) == "undefined") {
650 650
 						$("#prowatermark" + i).html("");
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 
689 689
 					<?php
690 690
 					// Add js from hooks
691
-					$parameters=array();
691
+					$parameters = array();
692 692
 					$parameters['caller'] = 'search2';
693 693
 					$hookmanager->executeHooks('completeJSProductDisplay', $parameters);
694 694
 					print $hookmanager->resPrint;
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 				}
727 727
 				else {
728 728
 					$("#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show();
729
-					var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>));
729
+					var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2; ?>));
730 730
 					$("#search_start_less").val(search_start_less);
731 731
 				}
732 732
 				if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) {
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 				}
735 735
 				else {
736 736
 					$("#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show();
737
-					var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>);
737
+					var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2; ?>);
738 738
 					$("#search_start_more").val(search_start_more);
739 739
 				}
740 740
 			});
@@ -831,14 +831,14 @@  discard block
 block discarded – undo
831 831
 
832 832
 function TakeposPrintingOrder(){
833 833
 	console.log("TakeposPrintingOrder");
834
-	$("#poslines").load("invoice.php?action=order&token=<?php echo newToken();?>&place="+place, function() {
834
+	$("#poslines").load("invoice.php?action=order&token=<?php echo newToken(); ?>&place="+place, function() {
835 835
 		//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
836 836
 	});
837 837
 }
838 838
 
839 839
 function TakeposPrintingTemp(){
840 840
 	console.log("TakeposPrintingTemp");
841
-	$("#poslines").load("invoice.php?action=temp&token=<?php echo newToken();?>&place="+place, function() {
841
+	$("#poslines").load("invoice.php?action=temp&token=<?php echo newToken(); ?>&place="+place, function() {
842 842
 		//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
843 843
 	});
844 844
 }
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 }
861 861
 
862 862
 function DolibarrOpenDrawer() {
863
-	console.log("DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&token=<?php echo newToken();?>&term=<?php print urlencode($_SESSION["takeposterminal"]); ?>");
863
+	console.log("DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&token=<?php echo newToken(); ?>&term=<?php print urlencode($_SESSION["takeposterminal"]); ?>");
864 864
 	$.ajax({
865 865
 		type: "GET",
866 866
 		data: { token: '<?php echo currentToken(); ?>' },
@@ -1200,15 +1200,15 @@  discard block
 block discarded – undo
1200 1200
 
1201 1201
 // TakePOS setup check
1202 1202
 if (isset($_SESSION["takeposterminal"]) && $_SESSION["takeposterminal"]) {
1203
-	$sql = "SELECT code, libelle FROM " . MAIN_DB_PREFIX . "c_paiement";
1204
-	$sql .= " WHERE entity IN (" . getEntity('c_paiement') . ")";
1203
+	$sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_paiement";
1204
+	$sql .= " WHERE entity IN (".getEntity('c_paiement').")";
1205 1205
 	$sql .= " AND active = 1";
1206 1206
 	$sql .= " ORDER BY libelle";
1207 1207
 
1208 1208
 	$resql          = $db->query($sql);
1209 1209
 	$paiementsModes = array();
1210 1210
 	if ($resql) {
1211
-		while ( $obj = $db->fetch_object($resql) ) {
1211
+		while ($obj = $db->fetch_object($resql)) {
1212 1212
 			$paycode = $obj->code;
1213 1213
 			if ($paycode == 'LIQ') {
1214 1214
 				$paycode = 'CASH';
@@ -1217,9 +1217,9 @@  discard block
 block discarded – undo
1217 1217
 				$paycode = 'CHEQUE';
1218 1218
 			}
1219 1219
 
1220
-			$constantforkey = "CASHDESK_ID_BANKACCOUNT_" . $paycode . $_SESSION["takeposterminal"];
1220
+			$constantforkey = "CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"];
1221 1221
 			//var_dump($constantforkey.' '.$conf->global->$constantforkey);
1222
-			if ( !empty($conf->global->$constantforkey) && $conf->global->$constantforkey > 0) {
1222
+			if (!empty($conf->global->$constantforkey) && $conf->global->$constantforkey > 0) {
1223 1223
 				array_push($paiementsModes, $obj);
1224 1224
 			}
1225 1225
 		}
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
 if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
1256 1256
 	$menus[$r++] = array('title'=>'<span class="far fa-building paddingrightonly"></span><div class="trunc">'.$langs->trans("Customer").'</div>', 'action'=>'Customer();');
1257 1257
 }
1258
-if ( ! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1258
+if (!getDolGlobalString('TAKEPOS_HIDE_HISTORY')) {
1259 1259
 	$menus[$r++] = array('title'=>'<span class="fa fa-history paddingrightonly"></span><div class="trunc">'.$langs->trans("History").'</div>', 'action'=>'History();');
1260 1260
 }
1261 1261
 $menus[$r++] = array('title'=>'<span class="fa fa-cube paddingrightonly"></span><div class="trunc">'.$langs->trans("FreeZone").'</div>', 'action'=>'FreeZone();');
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
 $parameters = array('menus'=>$menus);
1326 1326
 $reshook = $hookmanager->executeHooks('ActionButtons', $parameters);
1327 1327
 if ($reshook == 0) {  //add buttons
1328
-	if (is_array($hookmanager->resArray) ) {
1328
+	if (is_array($hookmanager->resArray)) {
1329 1329
 		foreach ($hookmanager->resArray as $resArray) {
1330 1330
 			foreach ($resArray as $butmenu) {
1331 1331
 				$menus[$r++] = $butmenu;
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
 		}
1334 1334
 	} elseif ($reshook == 1) {
1335 1335
 		$r = 0; //replace buttons
1336
-		if (is_array($hookmanager->resArray) ) {
1336
+		if (is_array($hookmanager->resArray)) {
1337 1337
 			foreach ($hookmanager->resArray as $resArray) {
1338 1338
 				foreach ($resArray as $butmenu) {
1339 1339
 					$menus[$r++] = $butmenu;
Please login to merge, or discard this patch.
htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php 1 patch
Braces   +139 added lines, -52 removed lines patch added patch discarded remove patch
@@ -105,7 +105,10 @@  discard block
 block discarded – undo
105 105
 
106 106
 		// Get source company
107 107
 		$this->emetteur = $mysoc;
108
-		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
108
+		if (!$this->emetteur->country_code) {
109
+			$this->emetteur->country_code = substr($langs->defaultlang, -2);
110
+		}
111
+		// By default if not defined
109 112
 
110 113
 		// Define position of columns
111 114
 		$this->posxdesc = $this->marge_gauche + 1;
@@ -124,7 +127,9 @@  discard block
 block discarded – undo
124 127
 			$this->posxtotalht = $this->page_largeur - $this->marge_droite - 20;
125 128
 		}*/
126 129
 
127
-		if (!empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) $this->posxweightvol = $this->posxqty;
130
+		if (!empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) {
131
+			$this->posxweightvol = $this->posxqty;
132
+		}
128 133
 
129 134
 		$this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
130 135
 		//var_dump($this->posxpicture, $this->posxweightvol);exit;
@@ -165,9 +170,13 @@  discard block
 block discarded – undo
165 170
 
166 171
 		$this->atLeastOneBatch = $this->atLeastOneBatch($object);
167 172
 
168
-		if (!is_object($outputlangs)) $outputlangs = $langs;
173
+		if (!is_object($outputlangs)) {
174
+			$outputlangs = $langs;
175
+		}
169 176
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
170
-		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
177
+		if (!empty($conf->global->MAIN_USE_FPDF)) {
178
+			$outputlangs->charset_output = 'ISO-8859-1';
179
+		}
171 180
 
172 181
 		// Load traductions files required by page
173 182
 		$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch", "stocks", "stocktransfer@stocktransfer"));
@@ -180,7 +189,9 @@  discard block
 block discarded – undo
180 189
 			$objphoto = new Product($this->db);
181 190
 
182 191
 			for ($i = 0; $i < $nblines; $i++) {
183
-				if (empty($object->lines[$i]->fk_product)) continue;
192
+				if (empty($object->lines[$i]->fk_product)) {
193
+					continue;
194
+				}
184 195
 
185 196
 				$objphoto = new Product($this->db);
186 197
 				$objphoto->fetch($object->lines[$i]->fk_product);
@@ -210,16 +221,23 @@  discard block
 block discarded – undo
210 221
 					break;
211 222
 				}
212 223
 
213
-				if ($realpath) $realpatharray[$i] = $realpath;
224
+				if ($realpath) {
225
+					$realpatharray[$i] = $realpath;
226
+				}
214 227
 			}
215 228
 		}
216 229
 
217
-		if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
230
+		if (count($realpatharray) == 0) {
231
+			$this->posxpicture = $this->posxweightvol;
232
+		}
218 233
 
219 234
 
220 235
 		if (!empty($this->atLeastOneBatch)) {
221 236
 			$this->posxpicture = $this->posxlot;
222
-			if (!empty($conf->global->MAIN_GENERATE_STOCKTRANSFER_WITH_PICTURE)) $this->posxpicture -= (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
237
+			if (!empty($conf->global->MAIN_GENERATE_STOCKTRANSFER_WITH_PICTURE)) {
238
+				$this->posxpicture -= (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
239
+			}
240
+			// width of images
223 241
 		}
224 242
 
225 243
 		if ($conf->stocktransfer->dir_output) {
@@ -259,7 +277,9 @@  discard block
 block discarded – undo
259 277
 				$heightforinfotot = 8; // Height reserved to output the info and total part
260 278
 				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
261 279
 				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
262
-				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
280
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) {
281
+					$heightforfooter += 6;
282
+				}
263 283
 				$pdf->SetAutoPageBreak(1, 0);
264 284
 
265 285
 				if (class_exists('TCPDF')) {
@@ -277,7 +297,9 @@  discard block
 block discarded – undo
277 297
 				$pagenb = 0;
278 298
 				$pdf->SetDrawColor(128, 128, 128);
279 299
 
280
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
300
+				if (method_exists($pdf, 'AliasNbPages')) {
301
+					$pdf->AliasNbPages();
302
+				}
281 303
 
282 304
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
283 305
 				$pdf->SetSubject($outputlangs->transnoentities("Shipment"));
@@ -292,7 +314,9 @@  discard block
 block discarded – undo
292 314
 
293 315
 				// New page
294 316
 				$pdf->AddPage();
295
-				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
317
+				if (!empty($tplidx)) {
318
+					$pdf->useTemplate($tplidx);
319
+				}
296 320
 				$pagenb++;
297 321
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
298 322
 				$pdf->SetFont('', '', $default_font_size - 1);
@@ -344,7 +368,9 @@  discard block
 block discarded – undo
344 368
 								// Get code using getLabelFromKey
345 369
 								$code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
346 370
 								$label = '';
347
-								if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."<br>";
371
+								if ($object->tracking_url != $object->tracking_number) {
372
+									$label .= $outputlangs->trans("LinkToTrackYourPackage")."<br>";
373
+								}
348 374
 								$label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
349 375
 								//var_dump($object->tracking_url != $object->tracking_number);exit;
350 376
 								if ($object->tracking_url != $object->tracking_number) {
@@ -391,7 +417,9 @@  discard block
 block discarded – undo
391 417
 
392 418
 					// Define size of image if we need it
393 419
 					$imglinesize = array();
394
-					if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
420
+					if (!empty($realpatharray[$i])) {
421
+						$imglinesize = pdf_getSizeForImage($realpatharray[$i]);
422
+					}
395 423
 
396 424
 					$pdf->setTopMargin($tab_top_newpage);
397 425
 					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
@@ -404,16 +432,22 @@  discard block
 block discarded – undo
404 432
 					// We start with Photo of product line
405 433
 					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {	// If photo too high, we moved completely on new page
406 434
 						$pdf->AddPage('', '', true);
407
-						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
408
-						if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) $this->_pagehead($pdf, $object, 0, $outputlangs);
435
+						if (!empty($tplidx)) {
436
+							$pdf->useTemplate($tplidx);
437
+						}
438
+						if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
439
+							$this->_pagehead($pdf, $object, 0, $outputlangs);
440
+						}
409 441
 						$pdf->setPage($pageposbefore + 1);
410 442
 
411 443
 						$curY = $tab_top_newpage;
412 444
 
413 445
 						// Allows data in the first page if description is long enough to break in multiples pages
414
-						if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
415
-							$showpricebeforepagebreak = 1;
416
-						else $showpricebeforepagebreak = 0;
446
+						if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
447
+													$showpricebeforepagebreak = 1;
448
+						} else {
449
+							$showpricebeforepagebreak = 0;
450
+						}
417 451
 					}
418 452
 
419 453
 					if (isset($imglinesize['width']) && isset($imglinesize['height'])) {
@@ -460,17 +494,23 @@  discard block
 block discarded – undo
460 494
 						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {	// There is no space left for total+free text
461 495
 							if ($i == ($nblines - 1)) {	// No more lines, and no space left to show total, so we create a new page
462 496
 								$pdf->AddPage('', '', true);
463
-								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
464
-								if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) $this->_pagehead($pdf, $object, 0, $outputlangs);
497
+								if (!empty($tplidx)) {
498
+									$pdf->useTemplate($tplidx);
499
+								}
500
+								if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
501
+									$this->_pagehead($pdf, $object, 0, $outputlangs);
502
+								}
465 503
 								$pdf->setPage($pageposafter + 1);
466 504
 							}
467 505
 						} else {
468 506
 							// We found a page break
469 507
 
470 508
 							// Allows data in the first page if description is long enough to break in multiples pages
471
-							if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
472
-								$showpricebeforepagebreak = 1;
473
-							else $showpricebeforepagebreak = 0;
509
+							if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
510
+															$showpricebeforepagebreak = 1;
511
+							} else {
512
+								$showpricebeforepagebreak = 0;
513
+							}
474 514
 						}
475 515
 					} else // No pagebreak
476 516
 					{
@@ -527,8 +567,9 @@  discard block
 block discarded – undo
527 567
 
528 568
 					// Warehouse source
529 569
 					$wh_source = new Entrepot($db);
530
-					if (!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_source])) $wh_source = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_source];
531
-					else {
570
+					if (!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_source])) {
571
+						$wh_source = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_source];
572
+					} else {
532 573
 						$wh_source->fetch($object->lines[$i]->fk_warehouse_source);
533 574
 						$TCacheEntrepots[$object->lines[$i]->fk_warehouse_source] = $wh_source;
534 575
 					}
@@ -537,8 +578,9 @@  discard block
 block discarded – undo
537 578
 
538 579
 					// Warehouse destination
539 580
 					$wh_destination = new Entrepot($db);
540
-					if (!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination])) $wh_destination = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination];
541
-					else {
581
+					if (!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination])) {
582
+						$wh_destination = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination];
583
+					} else {
542 584
 						$wh_destination->fetch($object->lines[$i]->fk_warehouse_destination);
543 585
 						$TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination] = $wh_destination;
544 586
 					}
@@ -554,7 +596,9 @@  discard block
 block discarded – undo
554 596
 					}
555 597
 
556 598
 					$nexY += 3;
557
-					if ($weighttxt && $voltxt) $nexY += 2;
599
+					if ($weighttxt && $voltxt) {
600
+						$nexY += 2;
601
+					}
558 602
 
559 603
 					// Add line
560 604
 					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
@@ -577,7 +621,9 @@  discard block
 block discarded – undo
577 621
 						$pagenb++;
578 622
 						$pdf->setPage($pagenb);
579 623
 						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
580
-						if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) $this->_pagehead($pdf, $object, 0, $outputlangs);
624
+						if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
625
+							$this->_pagehead($pdf, $object, 0, $outputlangs);
626
+						}
581 627
 					}
582 628
 					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
583 629
 						if ($pagenb == 1) {
@@ -588,9 +634,13 @@  discard block
 block discarded – undo
588 634
 						$this->_pagefoot($pdf, $object, $outputlangs, 1);
589 635
 						// New page
590 636
 						$pdf->AddPage();
591
-						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
637
+						if (!empty($tplidx)) {
638
+							$pdf->useTemplate($tplidx);
639
+						}
592 640
 						$pagenb++;
593
-						if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) $this->_pagehead($pdf, $object, 0, $outputlangs);
641
+						if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
642
+							$this->_pagehead($pdf, $object, 0, $outputlangs);
643
+						}
594 644
 					}
595 645
 				}
596 646
 
@@ -608,7 +658,9 @@  discard block
 block discarded – undo
608 658
 
609 659
 				// Pied de page
610 660
 				$this->_pagefoot($pdf, $object, $outputlangs);
611
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
661
+				if (method_exists($pdf, 'AliasNbPages')) {
662
+					$pdf->AliasNbPages();
663
+				}
612 664
 
613 665
 				$pdf->Close();
614 666
 
@@ -670,8 +722,11 @@  discard block
 block discarded – undo
670 722
 		{
671 723
 			$col2x-=20;
672 724
 		}*/
673
-		if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxwarehousesource - $this->posxqty);
674
-		else $largcol2 = ($this->posxwarehousedestination - $this->posxqty);
725
+		if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_ORDERED)) {
726
+			$largcol2 = ($this->posxwarehousesource - $this->posxqty);
727
+		} else {
728
+			$largcol2 = ($this->posxwarehousedestination - $this->posxqty);
729
+		}
675 730
 
676 731
 		$useborder = 0;
677 732
 		$index = 0;
@@ -684,20 +739,29 @@  discard block
 block discarded – undo
684 739
 		$totalWeight = $tmparray['weight'];
685 740
 		$totalVolume = $tmparray['volume'];
686 741
 		$totalQty = 0;
687
-		if (!empty($object->lines))
688
-		foreach ($object->lines as $line) {
742
+		if (!empty($object->lines)) {
743
+				foreach ($object->lines as $line) {
689 744
 			$totalQty+=$line->qty;
690 745
 		}
746
+		}
691 747
 		// Set trueVolume and volume_units not currently stored into database
692 748
 		if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
693 749
 			$object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
694 750
 			$object->volume_units = $object->size_units * 3;
695 751
 		}
696 752
 
697
-		if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
698
-		if ($totalVolume != '') $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
699
-		if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
700
-		if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
753
+		if ($totalWeight != '') {
754
+			$totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
755
+		}
756
+		if ($totalVolume != '') {
757
+			$totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
758
+		}
759
+		if ($object->trueWeight) {
760
+			$totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
761
+		}
762
+		if ($object->trueVolume) {
763
+			$totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
764
+		}
701 765
 
702 766
 		$pdf->SetFillColor(255, 255, 255);
703 767
 		$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -730,7 +794,9 @@  discard block
 block discarded – undo
730 794
 
731 795
 				$index++;
732 796
 			}
733
-			if (!$totalWeighttoshow && !$totalVolumetoshow) $index++;
797
+			if (!$totalWeighttoshow && !$totalVolumetoshow) {
798
+				$index++;
799
+			}
734 800
 		}
735 801
 
736 802
 		$pdf->SetTextColor(0, 0, 0);
@@ -758,7 +824,9 @@  discard block
 block discarded – undo
758 824
 
759 825
 		// Force to disable hidetop and hidebottom
760 826
 		$hidebottom = 0;
761
-		if ($hidetop) $hidetop = -1;
827
+		if ($hidetop) {
828
+			$hidetop = -1;
829
+		}
762 830
 
763 831
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
764 832
 
@@ -1002,7 +1070,9 @@  discard block
 block discarded – undo
1002 1070
 
1003 1071
 				$pdf->SetFont('', '', $default_font_size - 2);
1004 1072
 				$text = $linkedobject->ref;
1005
-				if ($linkedobject->ref_client) $text .= ' ('.$linkedobject->ref_client.')';
1073
+				if ($linkedobject->ref_client) {
1074
+					$text .= ' ('.$linkedobject->ref_client.')';
1075
+				}
1006 1076
 				$Yoff = $Yoff + 8;
1007 1077
 				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1008 1078
 				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R');
@@ -1027,18 +1097,28 @@  discard block
 block discarded – undo
1027 1097
 				$result = $object->fetch_contact($arrayidcontact[0]);
1028 1098
 			}
1029 1099
 
1030
-			if ($usecontact) $thirdparty = $object->contact;
1031
-			else $thirdparty = $this->emetteur;
1100
+			if ($usecontact) {
1101
+				$thirdparty = $object->contact;
1102
+			} else {
1103
+				$thirdparty = $this->emetteur;
1104
+			}
1032 1105
 
1033
-			if (!empty($thirdparty)) $carac_emetteur_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1106
+			if (!empty($thirdparty)) {
1107
+				$carac_emetteur_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1108
+			}
1034 1109
 
1035
-			if ($usecontact) $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, 1, 'targetwithdetails', $object);
1036
-			else $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1110
+			if ($usecontact) {
1111
+				$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, 1, 'targetwithdetails', $object);
1112
+			} else {
1113
+				$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1114
+			}
1037 1115
 
1038 1116
 			// Show sender
1039 1117
 			$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1040 1118
 			$posx = $this->marge_gauche;
1041
-			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1119
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1120
+				$posx = $this->page_largeur - $this->marge_droite - 80;
1121
+			}
1042 1122
 
1043 1123
 			$hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1044 1124
 			$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
@@ -1082,16 +1162,23 @@  discard block
 block discarded – undo
1082 1162
 				$thirdparty = $object->thirdparty;
1083 1163
 			}
1084 1164
 
1085
-			if (!empty($thirdparty)) $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1165
+			if (!empty($thirdparty)) {
1166
+				$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1167
+			}
1086 1168
 
1087 1169
 			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
1088 1170
 
1089 1171
 			// Show recipient
1090 1172
 			$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1091
-			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1173
+			if ($this->page_largeur < 210) {
1174
+				$widthrecbox = 84;
1175
+			}
1176
+			// To work with US executive format
1092 1177
 			$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1093 1178
 			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1094
-			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1179
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1180
+				$posx = $this->marge_gauche;
1181
+			}
1095 1182
 
1096 1183
 			// Show recipient frame
1097 1184
 			$pdf->SetTextColor(0, 0, 0);
Please login to merge, or discard this patch.
htdocs/core/class/commoninvoice.class.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 	public $mode_reglement_id;
64 64
 	public $mode_reglement_code; // Code in llx_c_paiement
65 65
 
66
-	public $totalpaid;			// duplicate with sumpayed
67
-	public $totaldeposits;		// duplicate with sumdeposit
68
-	public $totalcreditnotes;	// duplicate with sumcreditnote
66
+	public $totalpaid; // duplicate with sumpayed
67
+	public $totaldeposits; // duplicate with sumdeposit
68
+	public $totalcreditnotes; // duplicate with sumcreditnote
69 69
 
70 70
 	public $sumpayed;
71 71
 	public $sumpayed_multicurrency;
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 			$sharedentity = 'facture_fourn';
392 392
 		}
393 393
 
394
-		$sql = "SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code".$field3 . $field4;
394
+		$sql = "SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code".$field3.$field4;
395 395
 		$sql .= " FROM ".$this->db->prefix().$table." as pf, ".$this->db->prefix().$table2." as p, ".$this->db->prefix()."c_paiement as t";
396 396
 		$sql .= " WHERE pf.".$field." = ".((int) $this->id);
397 397
 		$sql .= " AND pf.".$field2." = p.rowid";
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
 		if ($this->status > self::STATUS_DRAFT && $this->paye == 0) {
990 990
 			// Get the default payment mode for BAN payment of the third party
991 991
 			require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
992
-			$bac = new CompanyBankAccount($this->db);	// table societe_rib
992
+			$bac = new CompanyBankAccount($this->db); // table societe_rib
993 993
 			$result = $bac->fetch(0, $this->socid, 1, 'ban');
994 994
 			if ($result <= 0 || empty($bac->id)) {
995 995
 				$this->error = $langs->trans("ThirdpartyHasNoDefaultBanAccount");
@@ -1003,12 +1003,12 @@  discard block
 block discarded – undo
1003 1003
 			$sql .= " FROM ".$this->db->prefix()."prelevement_demande";
1004 1004
 			$sql .= " WHERE rowid = ".((int) $did);
1005 1005
 			if ($type != 'bank-transfer' && $type != 'credit-transfer') {
1006
-				$sql .= " AND fk_facture = ".((int) $this->id);		// Add a protection to not pay another invoice than current one
1006
+				$sql .= " AND fk_facture = ".((int) $this->id); // Add a protection to not pay another invoice than current one
1007 1007
 			}
1008 1008
 			if ($type != 'direct-debit') {
1009
-				$sql .= " AND fk_facture_fourn = ".((int) $this->id);		// Add a protection to not pay another invoice than current one
1009
+				$sql .= " AND fk_facture_fourn = ".((int) $this->id); // Add a protection to not pay another invoice than current one
1010 1010
 			}
1011
-			$sql .= " AND traite = 0";	// To not process payment request that were already converted into a direct debit or credit transfer order (Note: fk_prelevement_bons is also empty when traite = 0)
1011
+			$sql .= " AND traite = 0"; // To not process payment request that were already converted into a direct debit or credit transfer order (Note: fk_prelevement_bons is also empty when traite = 0)
1012 1012
 
1013 1013
 			dol_syslog(get_class($this)."::makeStripeSepaRequest load requests to process", LOG_DEBUG);
1014 1014
 			$resql = $this->db->query($sql);
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 
1025 1025
 				if (is_numeric($amount) && $amount != 0) {
1026 1026
 					require_once DOL_DOCUMENT_ROOT.'/societe/class/companypaymentmode.class.php';
1027
-					$companypaymentmode = new CompanyPaymentMode($this->db);	// table societe_rib
1027
+					$companypaymentmode = new CompanyPaymentMode($this->db); // table societe_rib
1028 1028
 					$companypaymentmode->fetch($bac->id);
1029 1029
 
1030 1030
 					$this->stripechargedone = 0;
@@ -1034,11 +1034,11 @@  discard block
 block discarded – undo
1034 1034
 
1035 1035
 					$currency = $conf->currency;
1036 1036
 
1037
-					$errorforinvoice = 0;     // We reset the $errorforinvoice at each invoice loop
1037
+					$errorforinvoice = 0; // We reset the $errorforinvoice at each invoice loop
1038 1038
 
1039 1039
 					$this->fetch_thirdparty();
1040 1040
 
1041
-					dol_syslog("--- Process payment request amount=".$amount." thirdparty_id=" . $this->thirdparty->id . ", thirdparty_name=" . $this->thirdparty->name . " ban id=" . $bac->id, LOG_DEBUG);
1041
+					dol_syslog("--- Process payment request amount=".$amount." thirdparty_id=".$this->thirdparty->id.", thirdparty_name=".$this->thirdparty->name." ban id=".$bac->id, LOG_DEBUG);
1042 1042
 
1043 1043
 					//$alreadypayed = $this->getSommePaiement();
1044 1044
 					//$amount_credit_notes_included = $this->getSumCreditNotesUsed();
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
 						$amountstripe = $amountstripe * 100;
1054 1054
 					}
1055 1055
 
1056
-					$fk_bank_account = getDolGlobalInt('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS');		// Bank account used for SEPA direct debit or credit transfer. Must be the Stripe account in Dolibarr.
1056
+					$fk_bank_account = getDolGlobalInt('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS'); // Bank account used for SEPA direct debit or credit transfer. Must be the Stripe account in Dolibarr.
1057 1057
 					if (!($fk_bank_account > 0)) {
1058 1058
 						$error++;
1059 1059
 						$errorforinvoice++;
@@ -1109,42 +1109,42 @@  discard block
 block discarded – undo
1109 1109
 								}
1110 1110
 
1111 1111
 								//var_dump($companypaymentmode);
1112
-								dol_syslog("We will try to pay with companypaymentmodeid=" . $companypaymentmode->id . " stripe_card_ref=" . $companypaymentmode->stripe_card_ref . " mode=" . $companypaymentmode->status, LOG_DEBUG);
1112
+								dol_syslog("We will try to pay with companypaymentmodeid=".$companypaymentmode->id." stripe_card_ref=".$companypaymentmode->stripe_card_ref." mode=".$companypaymentmode->status, LOG_DEBUG);
1113 1113
 
1114 1114
 								$thirdparty = new Societe($this->db);
1115 1115
 								$resultthirdparty = $thirdparty->fetch($this->socid);
1116 1116
 
1117
-								include_once DOL_DOCUMENT_ROOT . '/stripe/class/stripe.class.php';        // This include the include of htdocs/stripe/config.php
1117
+								include_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; // This include the include of htdocs/stripe/config.php
1118 1118
 								// So it inits or erases the $stripearrayofkeysbyenv
1119 1119
 								$stripe = new Stripe($this->db);
1120 1120
 
1121 1121
 								if (empty($savstripearrayofkeysbyenv)) $savstripearrayofkeysbyenv = $stripearrayofkeysbyenv;
1122
-								dol_syslog("makeStripeSepaRequest Current Stripe environment is " . $stripearrayofkeysbyenv[$servicestatus]['publishable_key']);
1122
+								dol_syslog("makeStripeSepaRequest Current Stripe environment is ".$stripearrayofkeysbyenv[$servicestatus]['publishable_key']);
1123 1123
 								dol_syslog("makeStripeSepaRequest Current Saved Stripe environment is ".$savstripearrayofkeysbyenv[$servicestatus]['publishable_key']);
1124 1124
 
1125 1125
 								$foundalternativestripeaccount = '';
1126 1126
 
1127 1127
 								// Force stripe to another value (by default this value is empty)
1128
-								if (! empty($forcestripe)) {
1128
+								if (!empty($forcestripe)) {
1129 1129
 									dol_syslog("makeStripeSepaRequest A dedicated stripe account was forced, so we switch to it.");
1130 1130
 
1131 1131
 									$tmparray = explode('@', $forcestripe);
1132
-									if (! empty($tmparray[1])) {
1132
+									if (!empty($tmparray[1])) {
1133 1133
 										$tmparray2 = explode(':', $tmparray[1]);
1134
-										if (! empty($tmparray2[1])) {
1134
+										if (!empty($tmparray2[1])) {
1135 1135
 											$stripearrayofkeysbyenv[$servicestatus]["publishable_key"] = $tmparray2[0];
1136 1136
 											$stripearrayofkeysbyenv[$servicestatus]["secret_key"] = $tmparray2[1];
1137 1137
 
1138 1138
 											$stripearrayofkeys = $stripearrayofkeysbyenv[$servicestatus];
1139 1139
 											\Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']);
1140 1140
 
1141
-											$foundalternativestripeaccount = $tmparray[0];    // Store the customer id
1141
+											$foundalternativestripeaccount = $tmparray[0]; // Store the customer id
1142 1142
 
1143 1143
 											dol_syslog("makeStripeSepaRequest We use now customer=".$foundalternativestripeaccount." publishable_key=".$stripearrayofkeys['publishable_key'], LOG_DEBUG);
1144 1144
 										}
1145 1145
 									}
1146 1146
 
1147
-									if (! $foundalternativestripeaccount) {
1147
+									if (!$foundalternativestripeaccount) {
1148 1148
 										$stripearrayofkeysbyenv = $savstripearrayofkeysbyenv;
1149 1149
 
1150 1150
 										$stripearrayofkeys = $savstripearrayofkeysbyenv[$servicestatus];
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
 									dol_syslog("makeStripeSepaRequest No dedicated Stripe Account requested, so we use global one, so ".$stripearrayofkeys['publishable_key'], LOG_DEBUG);
1160 1160
 								}
1161 1161
 
1162
-								$stripeacc = $stripe->getStripeAccount($service, $this->socid);								// Get Stripe OAuth connect account if it exists (no network access here)
1162
+								$stripeacc = $stripe->getStripeAccount($service, $this->socid); // Get Stripe OAuth connect account if it exists (no network access here)
1163 1163
 
1164 1164
 								if ($foundalternativestripeaccount) {
1165 1165
 									if (empty($stripeacc)) {				// If the Stripe connect account not set, we use common API usage
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 									}
1170 1170
 								} else {
1171 1171
 									$customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0);
1172
-									if (empty($customer) && ! empty($stripe->error)) {
1172
+									if (empty($customer) && !empty($stripe->error)) {
1173 1173
 										$this->errors[] = $stripe->error;
1174 1174
 									}
1175 1175
 									/*if (!empty($customer) && empty($customer->sources)) {
@@ -1196,15 +1196,15 @@  discard block
 block discarded – undo
1196 1196
 										}
1197 1197
 
1198 1198
 										if ($stripecard) {  // Can be src_... (for sepa) or pm_... (new card mode). Note that card_... (old card mode) should not happen here.
1199
-											$FULLTAG = 'DID='.$did.'-INV=' . $this->id . '-CUS=' . $thirdparty->id;
1200
-											$description = 'Stripe payment from makeStripeSepaRequest: ' . $FULLTAG . ' did='.$did.' ref=' . $this->ref;
1199
+											$FULLTAG = 'DID='.$did.'-INV='.$this->id.'-CUS='.$thirdparty->id;
1200
+											$description = 'Stripe payment from makeStripeSepaRequest: '.$FULLTAG.' did='.$did.' ref='.$this->ref;
1201 1201
 
1202 1202
 											$stripefailurecode = '';
1203 1203
 											$stripefailuremessage = '';
1204 1204
 											$stripefailuredeclinecode = '';
1205 1205
 
1206 1206
 											// Using new SCA method
1207
-											dol_syslog("* Create payment on SEPA " . $stripecard->id . ", amounttopay=" . $amounttopay . ", amountstripe=" . $amountstripe . ", FULLTAG=" . $FULLTAG, LOG_DEBUG);
1207
+											dol_syslog("* Create payment on SEPA ".$stripecard->id.", amounttopay=".$amounttopay.", amountstripe=".$amountstripe.", FULLTAG=".$FULLTAG, LOG_DEBUG);
1208 1208
 
1209 1209
 											// Create payment intent and charge payment (confirmnow = true)
1210 1210
 											$paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $this, $customer->id, $stripeacc, $servicestatus, 0, 'automatic', true, $stripecard->id, 1, 1, $did);
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
 												$charge->failure_message = $stripe->error;
1226 1226
 												$charge->failure_declinecode = $stripe->declinecode;
1227 1227
 												$stripefailurecode = $stripe->code;
1228
-												$stripefailuremessage = 'Action required. Contact the support at ';// . $conf->global->SELLYOURSAAS_MAIN_EMAIL;
1228
+												$stripefailuremessage = 'Action required. Contact the support at '; // . $conf->global->SELLYOURSAAS_MAIN_EMAIL;
1229 1229
 												$stripefailuredeclinecode = $stripe->declinecode;
1230 1230
 											} else {
1231 1231
 												dol_syslog(var_export($paymentintent, true), LOG_DEBUG);
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 
1247 1247
 											// Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...)
1248 1248
 											if (empty($charge) || $charge->status == 'failed') {
1249
-												dol_syslog('Failed to charge payment mode ' . $stripecard->id . ' stripefailurecode=' . $stripefailurecode . ' stripefailuremessage=' . $stripefailuremessage . ' stripefailuredeclinecode=' . $stripefailuredeclinecode, LOG_WARNING);
1249
+												dol_syslog('Failed to charge payment mode '.$stripecard->id.' stripefailurecode='.$stripefailurecode.' stripefailuremessage='.$stripefailuremessage.' stripefailuredeclinecode='.$stripefailuredeclinecode, LOG_WARNING);
1250 1250
 
1251 1251
 												// Save a stripe payment was in error
1252 1252
 												$this->stripechargeerror++;
@@ -1259,8 +1259,8 @@  discard block
 block discarded – undo
1259 1259
 														$errauthenticationmessage = $langs->trans("ErrSCAAuthentication");
1260 1260
 														$errmsg = $errauthenticationmessage;
1261 1261
 													} elseif (in_array($stripefailuredeclinecode, ['insufficient_funds', 'generic_decline'])) {
1262
-														$errmsg .= ': ' . $charge->failure_code;
1263
-														$errmsg .= ($charge->failure_message ? ' - ' : '') . ' ' . $charge->failure_message;
1262
+														$errmsg .= ': '.$charge->failure_code;
1263
+														$errmsg .= ($charge->failure_message ? ' - ' : '').' '.$charge->failure_message;
1264 1264
 														if (empty($stripefailurecode)) {
1265 1265
 															$stripefailurecode = $charge->failure_code;
1266 1266
 														}
@@ -1268,8 +1268,8 @@  discard block
 block discarded – undo
1268 1268
 															$stripefailuremessage = $charge->failure_message;
1269 1269
 														}
1270 1270
 													} else {
1271
-														$errmsg .= ': failure_code=' . $charge->failure_code;
1272
-														$errmsg .= ($charge->failure_message ? ' - ' : '') . ' failure_message=' . $charge->failure_message;
1271
+														$errmsg .= ': failure_code='.$charge->failure_code;
1272
+														$errmsg .= ($charge->failure_message ? ' - ' : '').' failure_message='.$charge->failure_message;
1273 1273
 														if (empty($stripefailurecode)) {
1274 1274
 															$stripefailurecode = $charge->failure_code;
1275 1275
 														}
@@ -1278,24 +1278,24 @@  discard block
 block discarded – undo
1278 1278
 														}
1279 1279
 													}
1280 1280
 												} else {
1281
-													$errmsg .= ': ' . $stripefailurecode . ' - ' . $stripefailuremessage;
1282
-													$errmsg .= ($stripefailuredeclinecode ? ' - ' . $stripefailuredeclinecode : '');
1281
+													$errmsg .= ': '.$stripefailurecode.' - '.$stripefailuremessage;
1282
+													$errmsg .= ($stripefailuredeclinecode ? ' - '.$stripefailuredeclinecode : '');
1283 1283
 												}
1284 1284
 
1285
-												$description = 'Stripe payment ERROR from makeStripeSepaRequest: ' . $FULLTAG;
1286
-												$postactionmessages[] = $errmsg . ' (' . $stripearrayofkeys['publishable_key'] . ')';
1285
+												$description = 'Stripe payment ERROR from makeStripeSepaRequest: '.$FULLTAG;
1286
+												$postactionmessages[] = $errmsg.' ('.$stripearrayofkeys['publishable_key'].')';
1287 1287
 												$this->errors[] = $errmsg;
1288 1288
 											} else {
1289 1289
 												dol_syslog('Successfuly request '.$type.' '.$stripecard->id);
1290 1290
 
1291
-												$postactionmessages[] = 'Success to request '.$type.' (' . $charge->id . ' with ' . $stripearrayofkeys['publishable_key'] . ')';
1291
+												$postactionmessages[] = 'Success to request '.$type.' ('.$charge->id.' with '.$stripearrayofkeys['publishable_key'].')';
1292 1292
 
1293 1293
 												// Save a stripe payment was done in realy life so later we will be able to force a commit on recorded payments
1294 1294
 												// even if in batch mode (method doTakePaymentStripe), we will always make all action in one transaction with a forced commit.
1295 1295
 												$this->stripechargedone++;
1296 1296
 
1297 1297
 												// Default description used for label of event. Will be overwrite by another value later.
1298
-												$description = 'Stripe payment request OK (' . $charge->id . ') from makeStripeSepaRequest: ' . $FULLTAG;
1298
+												$description = 'Stripe payment request OK ('.$charge->id.') from makeStripeSepaRequest: '.$FULLTAG;
1299 1299
 											}
1300 1300
 
1301 1301
 											$object = $this;
@@ -1304,8 +1304,8 @@  discard block
 block discarded – undo
1304 1304
 											if (empty($charge) || $charge->status == 'failed') {
1305 1305
 												$actioncode = 'PAYMENT_STRIPE_KO';
1306 1306
 												$extraparams = $stripefailurecode;
1307
-												$extraparams .= (($extraparams && $stripefailuremessage) ? ' - ' : '') . $stripefailuremessage;
1308
-												$extraparams .= (($extraparams && $stripefailuredeclinecode) ? ' - ' : '') . $stripefailuredeclinecode;
1307
+												$extraparams .= (($extraparams && $stripefailuremessage) ? ' - ' : '').$stripefailuremessage;
1308
+												$extraparams .= (($extraparams && $stripefailuredeclinecode) ? ' - ' : '').$stripefailuredeclinecode;
1309 1309
 											} else {
1310 1310
 												$actioncode = 'PAYMENT_STRIPE_OK';
1311 1311
 												$extraparams = '';
@@ -1313,13 +1313,13 @@  discard block
 block discarded – undo
1313 1313
 										} else {
1314 1314
 											$error++;
1315 1315
 											$errorforinvoice++;
1316
-											dol_syslog("No ban payment method found for this stripe customer " . $customer->id, LOG_WARNING);
1317
-											$this->errors[] = 'Failed to get direct debit payment method for stripe customer = ' . $customer->id;
1316
+											dol_syslog("No ban payment method found for this stripe customer ".$customer->id, LOG_WARNING);
1317
+											$this->errors[] = 'Failed to get direct debit payment method for stripe customer = '.$customer->id;
1318 1318
 
1319 1319
 											$description = 'Failed to find or use the payment mode - no ban defined for the thirdparty account';
1320 1320
 											$stripefailurecode = 'BADPAYMENTMODE';
1321 1321
 											$stripefailuremessage = 'Failed to find or use the payment mode - no ban defined for the thirdparty account';
1322
-											$postactionmessages[] = $description . ' (' . $stripearrayofkeys['publishable_key'] . ')';
1322
+											$postactionmessages[] = $description.' ('.$stripearrayofkeys['publishable_key'].')';
1323 1323
 
1324 1324
 											$object = $this;
1325 1325
 
@@ -1339,11 +1339,11 @@  discard block
 block discarded – undo
1339 1339
 									}
1340 1340
 								} else {	// Else of the   if ($resultthirdparty > 0 && ! empty($customer)) {
1341 1341
 									if ($resultthirdparty <= 0) {
1342
-										dol_syslog('SellYourSaasUtils Failed to load customer for thirdparty_id = ' . $thirdparty->id, LOG_WARNING);
1343
-										$this->errors[] = 'Failed to load Stripe account for thirdparty_id = ' . $thirdparty->id;
1342
+										dol_syslog('SellYourSaasUtils Failed to load customer for thirdparty_id = '.$thirdparty->id, LOG_WARNING);
1343
+										$this->errors[] = 'Failed to load Stripe account for thirdparty_id = '.$thirdparty->id;
1344 1344
 									} else { // $customer stripe not found
1345
-										dol_syslog('SellYourSaasUtils Failed to get Stripe customer id for thirdparty_id = ' . $thirdparty->id . " in mode " . $servicestatus . " in Stripe env " . $stripearrayofkeysbyenv[$servicestatus]['publishable_key'], LOG_WARNING);
1346
-										$this->errors[] = 'Failed to get Stripe account id for thirdparty_id = ' . $thirdparty->id . " in mode " . $servicestatus . " in Stripe env " . $stripearrayofkeysbyenv[$servicestatus]['publishable_key'];
1345
+										dol_syslog('SellYourSaasUtils Failed to get Stripe customer id for thirdparty_id = '.$thirdparty->id." in mode ".$servicestatus." in Stripe env ".$stripearrayofkeysbyenv[$servicestatus]['publishable_key'], LOG_WARNING);
1346
+										$this->errors[] = 'Failed to get Stripe account id for thirdparty_id = '.$thirdparty->id." in mode ".$servicestatus." in Stripe env ".$stripearrayofkeysbyenv[$servicestatus]['publishable_key'];
1347 1347
 									}
1348 1348
 									$error++;
1349 1349
 									$errorforinvoice++;
@@ -1360,24 +1360,24 @@  discard block
 block discarded – undo
1360 1360
 								}
1361 1361
 
1362 1362
 								if ($description) {
1363
-									dol_syslog("* Record event for credit transfer or direct debit request result - " . $description);
1363
+									dol_syslog("* Record event for credit transfer or direct debit request result - ".$description);
1364 1364
 									require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
1365 1365
 
1366 1366
 									// Insert record of payment (success or error)
1367 1367
 									$actioncomm = new ActionComm($this->db);
1368 1368
 
1369
-									$actioncomm->type_code = 'AC_OTH_AUTO';		// Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
1370
-									$actioncomm->code = 'AC_' . $actioncode;
1369
+									$actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
1370
+									$actioncomm->code = 'AC_'.$actioncode;
1371 1371
 									$actioncomm->label = $description;
1372 1372
 									$actioncomm->note_private = join(",\n", $postactionmessages);
1373 1373
 									$actioncomm->fk_project = $this->fk_project;
1374 1374
 									$actioncomm->datep = $now;
1375 1375
 									$actioncomm->datef = $now;
1376
-									$actioncomm->percentage = -1;   // Not applicable
1376
+									$actioncomm->percentage = -1; // Not applicable
1377 1377
 									$actioncomm->socid = $thirdparty->id;
1378 1378
 									$actioncomm->contactid = 0;
1379
-									$actioncomm->authorid = $user->id;   // User saving action
1380
-									$actioncomm->userownerid = $user->id;	// Owner of action
1379
+									$actioncomm->authorid = $user->id; // User saving action
1380
+									$actioncomm->userownerid = $user->id; // Owner of action
1381 1381
 									// Fields when action is a real email (content is already into note)
1382 1382
 									/*$actioncomm->email_msgid = $object->email_msgid;
1383 1383
 									 $actioncomm->email_from  = $object->email_from;
@@ -1399,14 +1399,14 @@  discard block
 block discarded – undo
1399 1399
 							} catch (Exception $e) {
1400 1400
 								$error++;
1401 1401
 								$errorforinvoice++;
1402
-								dol_syslog('Error ' . $e->getMessage(), LOG_ERR);
1403
-								$this->errors[] = 'Error ' . $e->getMessage();
1402
+								dol_syslog('Error '.$e->getMessage(), LOG_ERR);
1403
+								$this->errors[] = 'Error '.$e->getMessage();
1404 1404
 							}
1405 1405
 						} else {	// If remain to pay is null
1406 1406
 							$error++;
1407 1407
 							$errorforinvoice++;
1408
-							dol_syslog("Remain to pay is null for the invoice " . $this->id . " " . $this->ref . ". Why is the invoice not classified 'Paid' ?", LOG_WARNING);
1409
-							$this->errors[] = "Remain to pay is null for the invoice " . $this->id . " " . $this->ref . ". Why is the invoice not classified 'Paid' ?";
1408
+							dol_syslog("Remain to pay is null for the invoice ".$this->id." ".$this->ref.". Why is the invoice not classified 'Paid' ?", LOG_WARNING);
1409
+							$this->errors[] = "Remain to pay is null for the invoice ".$this->id." ".$this->ref.". Why is the invoice not classified 'Paid' ?";
1410 1410
 						}
1411 1411
 					}
1412 1412
 
@@ -1546,10 +1546,10 @@  discard block
 block discarded – undo
1546 1546
 		$s .= pack('C1', 3).pack('C1', strlen($datestring)).$datestring;
1547 1547
 		$s .= pack('C1', 4).pack('C1', strlen($pricewithtaxstring)).$pricewithtaxstring;
1548 1548
 		$s .= pack('C1', 5).pack('C1', strlen($pricetaxstring)).$pricetaxstring;
1549
-		$s .= '';					// Hash of xml invoice
1550
-		$s .= '';					// ecda signature
1551
-		$s .= '';					// ecda public key
1552
-		$s .= '';					// ecda signature of public key stamp
1549
+		$s .= ''; // Hash of xml invoice
1550
+		$s .= ''; // ecda signature
1551
+		$s .= ''; // ecda public key
1552
+		$s .= ''; // ecda signature of public key stamp
1553 1553
 
1554 1554
 		$s = base64_encode($s);
1555 1555
 
@@ -1617,8 +1617,8 @@  discard block
 block discarded – undo
1617 1617
 			$s .= "S\n";
1618 1618
 			$s .= dol_trunc($bankaccount->proprio, 70, 'right', 'UTF-8', 1)."\n";
1619 1619
 			$addresslinearray = explode("\n", $bankaccount->owner_address);
1620
-			$s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1)."\n";		// address line 1
1621
-			$s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1)."\n";		// address line 2
1620
+			$s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1)."\n"; // address line 1
1621
+			$s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1)."\n"; // address line 2
1622 1622
 			/*$s .= dol_trunc($mysoc->zip, 16, 'right', 'UTF-8', 1)."\n";
1623 1623
 			$s .= dol_trunc($mysoc->town, 35, 'right', 'UTF-8', 1)."\n";
1624 1624
 			$s .= dol_trunc($mysoc->country_code, 2, 'right', 'UTF-8', 1)."\n";*/
@@ -1626,8 +1626,8 @@  discard block
 block discarded – undo
1626 1626
 			$s .= "S\n";
1627 1627
 			$s .= dol_trunc($mysoc->name, 70, 'right', 'UTF-8', 1)."\n";
1628 1628
 			$addresslinearray = explode("\n", $mysoc->address);
1629
-			$s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1)."\n";		// address line 1
1630
-			$s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1)."\n";		// address line 2
1629
+			$s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1)."\n"; // address line 1
1630
+			$s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1)."\n"; // address line 2
1631 1631
 			$s .= dol_trunc($mysoc->zip, 16, 'right', 'UTF-8', 1)."\n";
1632 1632
 			$s .= dol_trunc($mysoc->town, 35, 'right', 'UTF-8', 1)."\n";
1633 1633
 			$s .= dol_trunc($mysoc->country_code, 2, 'right', 'UTF-8', 1)."\n";
@@ -1647,14 +1647,14 @@  discard block
 block discarded – undo
1647 1647
 		$s .= "S\n";
1648 1648
 		$s .= dol_trunc($this->thirdparty->name, 70, 'right', 'UTF-8', 1)."\n";
1649 1649
 		$addresslinearray = explode("\n", $this->thirdparty->address);
1650
-		$s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1)."\n";		// address line 1
1651
-		$s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1)."\n";		// address line 2
1650
+		$s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1)."\n"; // address line 1
1651
+		$s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1)."\n"; // address line 2
1652 1652
 		$s .= dol_trunc($this->thirdparty->zip, 16, 'right', 'UTF-8', 1)."\n";
1653 1653
 		$s .= dol_trunc($this->thirdparty->town, 35, 'right', 'UTF-8', 1)."\n";
1654 1654
 		$s .= dol_trunc($this->thirdparty->country_code, 2, 'right', 'UTF-8', 1)."\n";
1655 1655
 		// ID of payment
1656
-		$s .= "NON\n";			// NON or QRR
1657
-		$s .= "\n";				// QR Code reference if previous field is QRR
1656
+		$s .= "NON\n"; // NON or QRR
1657
+		$s .= "\n"; // QR Code reference if previous field is QRR
1658 1658
 		// Free text
1659 1659
 		if ($complementaryinfo) {
1660 1660
 			$s .= $complementaryinfo."\n";
Please login to merge, or discard this patch.
test/phpunit/FunctionsLibTest.php 1 patch
Spacing   +427 added lines, -427 removed lines patch added patch discarded remove patch
@@ -25,42 +25,42 @@  discard block
 block discarded – undo
25 25
  *		\remarks	To run this script as CLI:  phpunit filename.php
26 26
  */
27 27
 
28
-global $conf,$user,$langs,$db;
28
+global $conf, $user, $langs, $db;
29 29
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
30 30
 //require_once 'PHPUnit/Autoload.php';
31 31
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
32 32
 require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php';
33 33
 require_once dirname(__FILE__).'/../../htdocs/product/class/product.class.php';
34 34
 
35
-if (! defined('NOREQUIREUSER')) {
35
+if (!defined('NOREQUIREUSER')) {
36 36
 	define('NOREQUIREUSER', '1');
37 37
 }
38
-if (! defined('NOREQUIREDB')) {
38
+if (!defined('NOREQUIREDB')) {
39 39
 	define('NOREQUIREDB', '1');
40 40
 }
41
-if (! defined('NOREQUIRESOC')) {
41
+if (!defined('NOREQUIRESOC')) {
42 42
 	define('NOREQUIRESOC', '1');
43 43
 }
44
-if (! defined('NOREQUIRETRAN')) {
44
+if (!defined('NOREQUIRETRAN')) {
45 45
 	define('NOREQUIRETRAN', '1');
46 46
 }
47
-if (! defined('NOCSRFCHECK')) {
47
+if (!defined('NOCSRFCHECK')) {
48 48
 	define('NOCSRFCHECK', '1');
49 49
 }
50
-if (! defined('NOTOKENRENEWAL')) {
50
+if (!defined('NOTOKENRENEWAL')) {
51 51
 	define('NOTOKENRENEWAL', '1');
52 52
 }
53
-if (! defined('NOREQUIREMENU')) {
53
+if (!defined('NOREQUIREMENU')) {
54 54
 	define('NOREQUIREMENU', '1'); // If there is no menu to show
55 55
 }
56
-if (! defined('NOREQUIREHTML')) {
56
+if (!defined('NOREQUIREHTML')) {
57 57
 	define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
58 58
 }
59
-if (! defined('NOREQUIREAJAX')) {
59
+if (!defined('NOREQUIREAJAX')) {
60 60
 	define('NOREQUIREAJAX', '1');
61 61
 }
62
-if (! defined("NOLOGIN")) {
63
-	define("NOLOGIN", '1');       // If this page is public (can be called outside logged session)
62
+if (!defined("NOLOGIN")) {
63
+	define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
64 64
 }
65 65
 
66 66
 print "\n".$langs->trans("CurrentTimeZone").' : '.getServerTimeZoneString();
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 		parent::__construct($name);
96 96
 
97 97
 		//$this->sharedFixture
98
-		global $conf,$user,$langs,$db,$mysoc;
99
-		$this->savconf=$conf;
100
-		$this->savuser=$user;
101
-		$this->savlangs=$langs;
102
-		$this->savdb=$db;
103
-		$this->savmysoc=$mysoc;
98
+		global $conf, $user, $langs, $db, $mysoc;
99
+		$this->savconf = $conf;
100
+		$this->savuser = $user;
101
+		$this->savlangs = $langs;
102
+		$this->savdb = $db;
103
+		$this->savmysoc = $mysoc;
104 104
 
105 105
 		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
106 106
 		//print " - db ".$db->db;
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	public static function setUpBeforeClass(): void
116 116
 	{
117
-		global $conf,$user,$langs,$db;
117
+		global $conf, $user, $langs, $db;
118 118
 		//$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
119 119
 
120
-		if (! function_exists('mb_substr')) {
120
+		if (!function_exists('mb_substr')) {
121 121
 			print "\n".__METHOD__." function mb_substr must be enabled.\n"; die(1);
122 122
 		}
123 123
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	public static function tearDownAfterClass(): void
141 141
 	{
142
-		global $conf,$user,$langs,$db;
142
+		global $conf, $user, $langs, $db;
143 143
 		//$db->rollback();
144 144
 
145 145
 		print __METHOD__."\n";
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	protected function setUp(): void
154 154
 	{
155
-		global $conf,$user,$langs,$db,$mysoc;
156
-		$conf=$this->savconf;
157
-		$user=$this->savuser;
158
-		$langs=$this->savlangs;
159
-		$db=$this->savdb;
160
-		$mysoc=$this->savmysoc;
155
+		global $conf, $user, $langs, $db, $mysoc;
156
+		$conf = $this->savconf;
157
+		$user = $this->savuser;
158
+		$langs = $this->savlangs;
159
+		$db = $this->savdb;
160
+		$mysoc = $this->savmysoc;
161 161
 
162 162
 		print __METHOD__."\n";
163 163
 	}
@@ -183,16 +183,16 @@  discard block
 block discarded – undo
183 183
 		global $conf, $langs;
184 184
 
185 185
 		// An attempt for SQL injection
186
-		$filter='if(now()=sysdate()%2Csleep(6)%2C0)';
186
+		$filter = 'if(now()=sysdate()%2Csleep(6)%2C0)';
187 187
 		$sql = forgeSQLFromUniversalSearchCriteria($filter);
188 188
 		$this->assertEquals($sql, 'Filter syntax error - Bad syntax of the search string');
189 189
 
190 190
 		// A real search string
191
-		$filter='(((statut:=:1) or (entity:in:__AAA__)) and (abc:<:2.0) and (abc:!=:1.23))';
191
+		$filter = '(((statut:=:1) or (entity:in:__AAA__)) and (abc:<:2.0) and (abc:!=:1.23))';
192 192
 		$sql = forgeSQLFromUniversalSearchCriteria($filter);
193 193
 		$this->assertEquals($sql, ' AND ((((statut = 1) or (entity IN (__AAA__))) and (abc < 2) and (abc <> 1.23)))');
194 194
 
195
-		$filter="(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.date_creation:<:'2016-01-01 12:30:00') or (t.nature:is:NULL)";
195
+		$filter = "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.date_creation:<:'2016-01-01 12:30:00') or (t.nature:is:NULL)";
196 196
 		$sql = forgeSQLFromUniversalSearchCriteria($filter);
197 197
 		$this->assertEquals($sql, " AND ((t.ref LIKE 'SO-%') or (t.date_creation < '20160101') or (t.date_creation < 0) or (t.nature IS NULL))");
198 198
 
@@ -258,23 +258,23 @@  discard block
 block discarded – undo
258 258
 	{
259 259
 		// Nb of line is same than entry text
260 260
 
261
-		$input="bidon@bademail";
262
-		$result=isValidEmail($input);
261
+		$input = "bidon@bademail";
262
+		$result = isValidEmail($input);
263 263
 		print __METHOD__." result=".$result."\n";
264 264
 		$this->assertFalse($result, 'Check isValidEmail '.$input);
265 265
 
266
-		$input="[email protected]";
267
-		$result=isValidEmail($input);
266
+		$input = "[email protected]";
267
+		$result = isValidEmail($input);
268 268
 		print __METHOD__." result=".$result."\n";
269 269
 		$this->assertTrue($result, 'Check isValidEmail '.$input);
270 270
 
271
-		$input="The name of sender <[email protected]>";
272
-		$result=isValidEmail($input);
271
+		$input = "The name of sender <[email protected]>";
272
+		$result = isValidEmail($input);
273 273
 		print __METHOD__." result=".$result."\n";
274 274
 		$this->assertFalse($result, 'Check isValidEmail '.$input);
275 275
 
276
-		$input="[email protected]";
277
-		$result=isValidEmail($input);
276
+		$input = "[email protected]";
277
+		$result = isValidEmail($input);
278 278
 		print __METHOD__." result=".$result."\n";
279 279
 		$this->assertTrue($result, 'Check isValidEmail '.$input);
280 280
 	}
@@ -288,18 +288,18 @@  discard block
 block discarded – undo
288 288
 	{
289 289
 		// Nb of line is same than entry text
290 290
 
291
-		$input="yahoo.com";
292
-		$result=isValidMXRecord($input);
291
+		$input = "yahoo.com";
292
+		$result = isValidMXRecord($input);
293 293
 		print __METHOD__." result=".$result."\n";
294 294
 		$this->assertEquals(1, $result);
295 295
 
296
-		$input="yhaoo.com";
297
-		$result=isValidMXRecord($input);
296
+		$input = "yhaoo.com";
297
+		$result = isValidMXRecord($input);
298 298
 		print __METHOD__." result=".$result."\n";
299 299
 		$this->assertEquals(0, $result);
300 300
 
301
-		$input="dolibarr.fr";
302
-		$result=isValidMXRecord($input);
301
+		$input = "dolibarr.fr";
302
+		$result = isValidMXRecord($input);
303 303
 		print __METHOD__." result=".$result."\n";
304 304
 		$this->assertEquals(0, $result);
305 305
 	}
@@ -313,57 +313,57 @@  discard block
 block discarded – undo
313 313
 	{
314 314
 		// Nb of line is same than entry text
315 315
 
316
-		$input="aaaa";
317
-		$result=dolGetFirstLineOfText($input);
316
+		$input = "aaaa";
317
+		$result = dolGetFirstLineOfText($input);
318 318
 		print __METHOD__." result=".$result."\n";
319 319
 		$this->assertEquals("aaaa", $result);
320 320
 
321
-		$input="aaaa\nbbbbbbbbbbbb\n";
322
-		$result=dolGetFirstLineOfText($input, 2);
321
+		$input = "aaaa\nbbbbbbbbbbbb\n";
322
+		$result = dolGetFirstLineOfText($input, 2);
323 323
 		print __METHOD__." result=".$result."\n";
324 324
 		$this->assertEquals("aaaa\nbbbbbbbbbbbb", $result);
325 325
 
326
-		$input="aaaa<br>bbbbbbbbbbbb<br>";
327
-		$result=dolGetFirstLineOfText($input, 2);
326
+		$input = "aaaa<br>bbbbbbbbbbbb<br>";
327
+		$result = dolGetFirstLineOfText($input, 2);
328 328
 		print __METHOD__." result=".$result."\n";
329 329
 		$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb", $result);
330 330
 
331 331
 		// Nb of line is lower
332 332
 
333
-		$input="aaaa\nbbbbbbbbbbbb\ncccccc\n";
334
-		$result=dolGetFirstLineOfText($input);
333
+		$input = "aaaa\nbbbbbbbbbbbb\ncccccc\n";
334
+		$result = dolGetFirstLineOfText($input);
335 335
 		print __METHOD__." result=".$result."\n";
336 336
 		$this->assertEquals("aaaa...", $result);
337 337
 
338
-		$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
339
-		$result=dolGetFirstLineOfText($input);
338
+		$input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
339
+		$result = dolGetFirstLineOfText($input);
340 340
 		print __METHOD__." result=".$result."\n";
341 341
 		$this->assertEquals("aaaa...", $result);
342 342
 
343
-		$input="aaaa\nbbbbbbbbbbbb\ncccccc\n";
344
-		$result=dolGetFirstLineOfText($input, 2);
343
+		$input = "aaaa\nbbbbbbbbbbbb\ncccccc\n";
344
+		$result = dolGetFirstLineOfText($input, 2);
345 345
 		print __METHOD__." result=".$result."\n";
346 346
 		$this->assertEquals("aaaa\nbbbbbbbbbbbb...", $result);
347 347
 
348
-		$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
349
-		$result=dolGetFirstLineOfText($input, 2);
348
+		$input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
349
+		$result = dolGetFirstLineOfText($input, 2);
350 350
 		print __METHOD__." result=".$result."\n";
351 351
 		$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb...", $result);
352 352
 
353 353
 		// Nb of line is higher
354 354
 
355
-		$input="aaaa<br>bbbbbbbbbbbb<br>cccccc";
356
-		$result=dolGetFirstLineOfText($input, 100);
355
+		$input = "aaaa<br>bbbbbbbbbbbb<br>cccccc";
356
+		$result = dolGetFirstLineOfText($input, 100);
357 357
 		print __METHOD__." result=".$result."\n";
358 358
 		$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 a');
359 359
 
360
-		$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
361
-		$result=dolGetFirstLineOfText($input, 100);
360
+		$input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
361
+		$result = dolGetFirstLineOfText($input, 100);
362 362
 		print __METHOD__." result=".$result."\n";
363 363
 		$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 b');
364 364
 
365
-		$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>\n";
366
-		$result=dolGetFirstLineOfText($input, 100);
365
+		$input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>\n";
366
+		$result = dolGetFirstLineOfText($input, 100);
367 367
 		print __METHOD__." result=".$result."\n";
368 368
 		$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 c');
369 369
 	}
@@ -384,11 +384,11 @@  discard block
 block discarded – undo
384 384
 		var_dump($tmp);
385 385
 		*/
386 386
 
387
-		$result=dol_buildpath('/google/oauth2callback.php', 2);
387
+		$result = dol_buildpath('/google/oauth2callback.php', 2);
388 388
 		print __METHOD__." result=".$result."\n";
389 389
 		$this->assertStringStartsWith('http', $result);
390 390
 
391
-		$result=dol_buildpath('/google/oauth2callback.php', 3);
391
+		$result = dol_buildpath('/google/oauth2callback.php', 3);
392 392
 		print __METHOD__." result=".$result."\n";
393 393
 		$this->assertStringStartsWith('http', $result);
394 394
 	}
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
 	public function testGetBrowserInfo()
403 403
 	{
404 404
 		// MSIE 5.0
405
-		$user_agent ='Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; KITV4 Wanadoo; KITV5 Wanadoo)';
406
-		$tmp=getBrowserInfo($user_agent);
405
+		$user_agent = 'Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; KITV4 Wanadoo; KITV5 Wanadoo)';
406
+		$tmp = getBrowserInfo($user_agent);
407 407
 		$this->assertEquals('ie', $tmp['browsername']);
408 408
 		$this->assertEquals('5.0', $tmp['browserversion']);
409 409
 		$this->assertEmpty($tmp['phone']);
@@ -411,40 +411,40 @@  discard block
 block discarded – undo
411 411
 		$this->assertEquals('classic', $tmp['layout']);
412 412
 
413 413
 		// Firefox 0.9.1
414
-		$user_agent ='Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firefox/0.9.1';
415
-		$tmp=getBrowserInfo($user_agent);
414
+		$user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firefox/0.9.1';
415
+		$tmp = getBrowserInfo($user_agent);
416 416
 		$this->assertEquals('firefox', $tmp['browsername']);
417 417
 		$this->assertEquals('0.9.1', $tmp['browserversion']);
418 418
 		$this->assertEmpty($tmp['phone']);
419 419
 		$this->assertFalse($tmp['tablet']);
420 420
 		$this->assertEquals('classic', $tmp['layout']);
421 421
 
422
-		$user_agent ='Mozilla/3.0 (Windows 98; U) Opera 6.03  [en]';
423
-		$tmp=getBrowserInfo($user_agent);
422
+		$user_agent = 'Mozilla/3.0 (Windows 98; U) Opera 6.03  [en]';
423
+		$tmp = getBrowserInfo($user_agent);
424 424
 		$this->assertEquals('opera', $tmp['browsername']);
425 425
 		$this->assertEquals('6.03', $tmp['browserversion']);
426 426
 		$this->assertEmpty($tmp['phone']);
427 427
 		$this->assertFalse($tmp['tablet']);
428 428
 		$this->assertEquals('classic', $tmp['layout']);
429 429
 
430
-		$user_agent ='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21';
431
-		$tmp=getBrowserInfo($user_agent);
430
+		$user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21';
431
+		$tmp = getBrowserInfo($user_agent);
432 432
 		$this->assertEquals('chrome', $tmp['browsername']);
433 433
 		$this->assertEquals('19.0.1042.0', $tmp['browserversion']);
434 434
 		$this->assertEmpty($tmp['phone']);
435 435
 		$this->assertFalse($tmp['tablet']);
436 436
 		$this->assertEquals('classic', $tmp['layout']);
437 437
 
438
-		$user_agent ='chrome (Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11)';
439
-		$tmp=getBrowserInfo($user_agent);
438
+		$user_agent = 'chrome (Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11)';
439
+		$tmp = getBrowserInfo($user_agent);
440 440
 		$this->assertEquals('chrome', $tmp['browsername']);
441 441
 		$this->assertEquals('17.0.963.56', $tmp['browserversion']);
442 442
 		$this->assertEmpty($tmp['phone']);
443 443
 		$this->assertFalse($tmp['tablet']);
444 444
 		$this->assertEquals('classic', $tmp['layout']);
445 445
 
446
-		$user_agent ='Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1';
447
-		$tmp=getBrowserInfo($user_agent);
446
+		$user_agent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1';
447
+		$tmp = getBrowserInfo($user_agent);
448 448
 		$this->assertEquals('safari', $tmp['browsername']);
449 449
 		$this->assertEquals('533.21.1', $tmp['browserversion']);
450 450
 		$this->assertEmpty($tmp['phone']);
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 
454 454
 		//Internet Explorer 11
455 455
 		$user_agent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';
456
-		$tmp=getBrowserInfo($user_agent);
456
+		$tmp = getBrowserInfo($user_agent);
457 457
 		$this->assertEquals('ie', $tmp['browsername']);
458 458
 		$this->assertEquals('11.0', $tmp['browserversion']);
459 459
 		$this->assertEmpty($tmp['phone']);
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 
463 463
 		//Internet Explorer 11 bis
464 464
 		$user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; NP06; rv:11.0) like Gecko';
465
-		$tmp=getBrowserInfo($user_agent);
465
+		$tmp = getBrowserInfo($user_agent);
466 466
 		$this->assertEquals('ie', $tmp['browsername']);
467 467
 		$this->assertEquals('11.0', $tmp['browserversion']);
468 468
 		$this->assertEmpty($tmp['phone']);
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 
472 472
 		//iPad
473 473
 		$user_agent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25';
474
-		$tmp=getBrowserInfo($user_agent);
474
+		$tmp = getBrowserInfo($user_agent);
475 475
 		$this->assertEquals('safari', $tmp['browsername']);
476 476
 		$this->assertEquals('8536.25', $tmp['browserversion']);
477 477
 		$this->assertEquals('ios', $tmp['browseros']);
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 
481 481
 		//Lynx
482 482
 		$user_agent = 'Lynx/2.8.8dev.3 libwww‑FM/2.14 SSL‑MM/1.4.1';
483
-		$tmp=getBrowserInfo($user_agent);
483
+		$tmp = getBrowserInfo($user_agent);
484 484
 		$this->assertEquals('lynxlinks', $tmp['browsername']);
485 485
 		$this->assertEquals('2.8.8', $tmp['browserversion']);
486 486
 		$this->assertEquals('unknown', $tmp['browseros']);
@@ -547,71 +547,71 @@  discard block
 block discarded – undo
547 547
 	public function testDolTextIsHtml()
548 548
 	{
549 549
 		// True
550
-		$input='<html>xxx</html>';
551
-		$after=dol_textishtml($input);
550
+		$input = '<html>xxx</html>';
551
+		$after = dol_textishtml($input);
552 552
 		$this->assertTrue($after, 'Test with html tag');
553
-		$input='<body>xxx</body>';
554
-		$after=dol_textishtml($input);
553
+		$input = '<body>xxx</body>';
554
+		$after = dol_textishtml($input);
555 555
 		$this->assertTrue($after, 'Test with body tag');
556
-		$input='xxx <b>yyy</b> zzz';
557
-		$after=dol_textishtml($input);
556
+		$input = 'xxx <b>yyy</b> zzz';
557
+		$after = dol_textishtml($input);
558 558
 		$this->assertTrue($after, 'Test with b tag');
559
-		$input='xxx <u>yyy</u> zzz';
560
-		$after=dol_textishtml($input);
559
+		$input = 'xxx <u>yyy</u> zzz';
560
+		$after = dol_textishtml($input);
561 561
 		$this->assertTrue($after, 'Test with u tag');
562
-		$input='text with <div>some div</div>';
563
-		$after=dol_textishtml($input);
562
+		$input = 'text with <div>some div</div>';
563
+		$after = dol_textishtml($input);
564 564
 		$this->assertTrue($after, 'Test with div tag');
565
-		$input='text with HTML &nbsp; entities';
566
-		$after=dol_textishtml($input);
565
+		$input = 'text with HTML &nbsp; entities';
566
+		$after = dol_textishtml($input);
567 567
 		$this->assertTrue($after, 'Test with entities tag');
568
-		$input='xxx<br>';
569
-		$after=dol_textishtml($input);
568
+		$input = 'xxx<br>';
569
+		$after = dol_textishtml($input);
570 570
 		$this->assertTrue($after, 'Test with entities br');
571
-		$input='xxx<br >';
572
-		$after=dol_textishtml($input);
571
+		$input = 'xxx<br >';
572
+		$after = dol_textishtml($input);
573 573
 		$this->assertTrue($after, 'Test with entities br');
574
-		$input='xxx<br style="eee">';
575
-		$after=dol_textishtml($input);
574
+		$input = 'xxx<br style="eee">';
575
+		$after = dol_textishtml($input);
576 576
 		$this->assertTrue($after, 'Test with entities br and attributes');
577
-		$input='xxx<br style="eee" >';
578
-		$after=dol_textishtml($input);
577
+		$input = 'xxx<br style="eee" >';
578
+		$after = dol_textishtml($input);
579 579
 		$this->assertTrue($after, 'Test with entities br and attributes bis');
580
-		$input='<h2>abc</h2>';
581
-		$after=dol_textishtml($input);
580
+		$input = '<h2>abc</h2>';
581
+		$after = dol_textishtml($input);
582 582
 		$this->assertTrue($after, 'Test with entities h2');
583
-		$input='<img id="abc" src="https://xxx.com/aaa/image.png" />';
584
-		$after=dol_textishtml($input);
583
+		$input = '<img id="abc" src="https://xxx.com/aaa/image.png" />';
584
+		$after = dol_textishtml($input);
585 585
 		$this->assertTrue($after, 'Test with img tag');
586
-		$input='<a class="azerty" href="https://xxx.com/aaa/image.png" />';
587
-		$after=dol_textishtml($input);
586
+		$input = '<a class="azerty" href="https://xxx.com/aaa/image.png" />';
587
+		$after = dol_textishtml($input);
588 588
 		$this->assertTrue($after, 'Test with a tag');
589
-		$input='This is a text with&nbsp;html spaces';
590
-		$after=dol_textishtml($input);
589
+		$input = 'This is a text with&nbsp;html spaces';
590
+		$after = dol_textishtml($input);
591 591
 		$this->assertTrue($after, 'Test with a &nbsp;');
592
-		$input='This is a text with accent &eacute;';
593
-		$after=dol_textishtml($input);
592
+		$input = 'This is a text with accent &eacute;';
593
+		$after = dol_textishtml($input);
594 594
 		$this->assertTrue($after, 'Test with a &eacute;');
595
-		$input='<i class="abc">xxx</i>';
596
-		$after=dol_textishtml($input);
595
+		$input = '<i class="abc">xxx</i>';
596
+		$after = dol_textishtml($input);
597 597
 		$this->assertTrue($after, 'Test with i tag and class;');
598 598
 
599 599
 		// False
600
-		$input='xxx < br>';
601
-		$after=dol_textishtml($input);
600
+		$input = 'xxx < br>';
601
+		$after = dol_textishtml($input);
602 602
 		$this->assertFalse($after);
603
-		$input='xxx <[email protected]>';	// <em> is html, <em... is not
604
-		$after=dol_textishtml($input);
603
+		$input = 'xxx <[email protected]>'; // <em> is html, <em... is not
604
+		$after = dol_textishtml($input);
605 605
 		$this->assertFalse($after);
606
-		$input='xxx <brstyle="ee">';
607
-		$after=dol_textishtml($input);
606
+		$input = 'xxx <brstyle="ee">';
607
+		$after = dol_textishtml($input);
608 608
 		$this->assertFalse($after);
609
-		$input='This is a text with html comments <!-- comment -->';	// we suppose this is not enough to be html content
610
-		$after=dol_textishtml($input);
609
+		$input = 'This is a text with html comments <!-- comment -->'; // we suppose this is not enough to be html content
610
+		$after = dol_textishtml($input);
611 611
 		$this->assertFalse($after);
612 612
 
613
-		$input="A text\nwith a link https://aaa?param=abc&amp;param2=def";
614
-		$after=dol_textishtml($input);
613
+		$input = "A text\nwith a link https://aaa?param=abc&amp;param2=def";
614
+		$after = dol_textishtml($input);
615 615
 		$this->assertFalse($after);
616 616
 	}
617 617
 
@@ -623,32 +623,32 @@  discard block
 block discarded – undo
623 623
 	 */
624 624
 	public function testDolHtmlCleanLastBr()
625 625
 	{
626
-		$input="A string\n";
627
-		$after=dol_htmlcleanlastbr($input);
626
+		$input = "A string\n";
627
+		$after = dol_htmlcleanlastbr($input);
628 628
 		$this->assertEquals("A string", $after);
629 629
 
630
-		$input="A string first\nA string second\n";
631
-		$after=dol_htmlcleanlastbr($input);
630
+		$input = "A string first\nA string second\n";
631
+		$after = dol_htmlcleanlastbr($input);
632 632
 		$this->assertEquals("A string first\nA string second", $after);
633 633
 
634
-		$input="A string\n\n\n";
635
-		$after=dol_htmlcleanlastbr($input);
634
+		$input = "A string\n\n\n";
635
+		$after = dol_htmlcleanlastbr($input);
636 636
 		$this->assertEquals("A string", $after);
637 637
 
638
-		$input="A string<br>";
639
-		$after=dol_htmlcleanlastbr($input);
638
+		$input = "A string<br>";
639
+		$after = dol_htmlcleanlastbr($input);
640 640
 		$this->assertEquals("A string", $after);
641 641
 
642
-		$input="A string first<br>\nA string second<br>";
643
-		$after=dol_htmlcleanlastbr($input);
642
+		$input = "A string first<br>\nA string second<br>";
643
+		$after = dol_htmlcleanlastbr($input);
644 644
 		$this->assertEquals("A string first<br>\nA string second", $after);
645 645
 
646
-		$input="A string\n<br type=\"_moz\" />\n";
647
-		$after=dol_htmlcleanlastbr($input);
646
+		$input = "A string\n<br type=\"_moz\" />\n";
647
+		$after = dol_htmlcleanlastbr($input);
648 648
 		$this->assertEquals("A string", $after);
649 649
 
650
-		$input="A string\n<br><br />\n\n";
651
-		$after=dol_htmlcleanlastbr($input);
650
+		$input = "A string\n<br><br />\n\n";
651
+		$after = dol_htmlcleanlastbr($input);
652 652
 		$this->assertEquals("A string", $after);
653 653
 
654 654
 		return true;
@@ -661,16 +661,16 @@  discard block
 block discarded – undo
661 661
 	 */
662 662
 	public function testDolConcat()
663 663
 	{
664
-		$text1="A string 1"; $text2="A string 2";	// text 1 and 2 are text, concat need only \n
665
-		$after=dol_concatdesc($text1, $text2);
664
+		$text1 = "A string 1"; $text2 = "A string 2"; // text 1 and 2 are text, concat need only \n
665
+		$after = dol_concatdesc($text1, $text2);
666 666
 		$this->assertEquals("A string 1\nA string 2", $after);
667 667
 
668
-		$text1="A<br>string 1"; $text2="A string 2";	// text 1 is html, concat need <br>\n
669
-		$after=dol_concatdesc($text1, $text2);
668
+		$text1 = "A<br>string 1"; $text2 = "A string 2"; // text 1 is html, concat need <br>\n
669
+		$after = dol_concatdesc($text1, $text2);
670 670
 		$this->assertEquals("A<br>string 1<br>\nA string 2", $after);
671 671
 
672
-		$text1="A string 1"; $text2="A <b>string</b> 2";	// text 2 is html, concat need <br>\n
673
-		$after=dol_concatdesc($text1, $text2);
672
+		$text1 = "A string 1"; $text2 = "A <b>string</b> 2"; // text 2 is html, concat need <br>\n
673
+		$after = dol_concatdesc($text1, $text2);
674 674
 		$this->assertEquals("A string 1<br>\nA <b>string</b> 2", $after);
675 675
 
676 676
 		return true;
@@ -684,12 +684,12 @@  discard block
 block discarded – undo
684 684
 	 */
685 685
 	public function testDolStringNoSpecial()
686 686
 	{
687
-		$text="A string with space and special char like ' or ° and more...\n";
688
-		$after=dol_string_nospecial($text, '_', '', '', 0);
687
+		$text = "A string with space and special char like ' or ° and more...\n";
688
+		$after = dol_string_nospecial($text, '_', '', '', 0);
689 689
 		$this->assertEquals("A_string_with_space_and_special_char_like___or___and_more...\n", $after, "testDolStringNoSpecial 1");
690 690
 
691
-		$text="A string with space and special char like ' or ° and more...\n";
692
-		$after=dol_string_nospecial($text, '_', '', '', 1);
691
+		$text = "A string with space and special char like ' or ° and more...\n";
692
+		$after = dol_string_nospecial($text, '_', '', '', 1);
693 693
 		$this->assertEquals("A string with space and special char like _ or _ and more...\n", $after, "testDolStringNoSpecial 2");
694 694
 
695 695
 		return true;
@@ -702,52 +702,52 @@  discard block
 block discarded – undo
702 702
 	 */
703 703
 	public function testDolStringNohtmltag()
704 704
 	{
705
-		$text="A\nstring\n\nand more\n";
706
-		$after=dol_string_nohtmltag($text, 0);
705
+		$text = "A\nstring\n\nand more\n";
706
+		$after = dol_string_nohtmltag($text, 0);
707 707
 		$this->assertEquals("A\nstring\n\nand more", $after, "test1a");
708 708
 
709
-		$text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
710
-		$after=dol_string_nohtmltag($text, 0);
709
+		$text = "A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
710
+		$after = dol_string_nohtmltag($text, 0);
711 711
 		$this->assertEquals("A string\n\n\n\n\nwith html tag", $after, 'test2a 2 br and 3 \n give 5 \n');
712 712
 
713
-		$text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
714
-		$after=dol_string_nohtmltag($text, 1);
713
+		$text = "A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
714
+		$after = dol_string_nohtmltag($text, 1);
715 715
 		$this->assertEquals("A string with html tag", $after, 'test2b 2 br and 3 \n give 1 space');
716 716
 
717
-		$text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
718
-		$after=dol_string_nohtmltag($text, 2);
717
+		$text = "A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
718
+		$after = dol_string_nohtmltag($text, 2);
719 719
 		$this->assertEquals("A string\n\nwith html tag", $after, 'test2c 2 br and 3 \n give 2 \n');
720 720
 
721
-		$text="A <b>string<b><br>\r\n<br>\r\n\r\nwith html tag<br>\n";
722
-		$after=dol_string_nohtmltag($text, 2);
721
+		$text = "A <b>string<b><br>\r\n<br>\r\n\r\nwith html tag<br>\n";
722
+		$after = dol_string_nohtmltag($text, 2);
723 723
 		$this->assertEquals("A string\n\nwith html tag", $after, 'test2c 2 br and 3 \r\n give 2 \n');
724 724
 
725
-		$text="A string<br>Another string";
726
-		$after=dol_string_nohtmltag($text, 0);
725
+		$text = "A string<br>Another string";
726
+		$after = dol_string_nohtmltag($text, 0);
727 727
 		$this->assertEquals("A string\nAnother string", $after, "test4");
728 728
 
729
-		$text="A string<br>Another string";
730
-		$after=dol_string_nohtmltag($text, 1);
729
+		$text = "A string<br>Another string";
730
+		$after = dol_string_nohtmltag($text, 1);
731 731
 		$this->assertEquals("A string Another string", $after, "test5");
732 732
 
733
-		$text='<a href="/myurl" title="<u>Afficher projet</u>">ABC</a>';
734
-		$after=dol_string_nohtmltag($text, 1);
733
+		$text = '<a href="/myurl" title="<u>Afficher projet</u>">ABC</a>';
734
+		$after = dol_string_nohtmltag($text, 1);
735 735
 		$this->assertEquals("ABC", $after, "test6");
736 736
 
737
-		$text='<a href="/myurl" title="&lt;u&gt;Afficher projet&lt;/u&gt;">DEF</a>';
738
-		$after=dol_string_nohtmltag($text, 1);
737
+		$text = '<a href="/myurl" title="&lt;u&gt;Afficher projet&lt;/u&gt;">DEF</a>';
738
+		$after = dol_string_nohtmltag($text, 1);
739 739
 		$this->assertEquals("DEF", $after, "test7");
740 740
 
741
-		$text='<a href="/myurl" title="<u>A title</u>">HIJ</a>';
742
-		$after=dol_string_nohtmltag($text, 0);
741
+		$text = '<a href="/myurl" title="<u>A title</u>">HIJ</a>';
742
+		$after = dol_string_nohtmltag($text, 0);
743 743
 		$this->assertEquals("HIJ", $after, "test8");
744 744
 
745
-		$text="A <b>string<b>\n\nwith html tag and '<' chars<br>\n";
746
-		$after=dol_string_nohtmltag($text, 0);
745
+		$text = "A <b>string<b>\n\nwith html tag and '<' chars<br>\n";
746
+		$after = dol_string_nohtmltag($text, 0);
747 747
 		$this->assertEquals("A string\n\nwith html tag and '<' chars", $after, "test9");
748 748
 
749
-		$text="A <b>string<b>\n\nwith tag with < chars<br>\n";
750
-		$after=dol_string_nohtmltag($text, 1);
749
+		$text = "A <b>string<b>\n\nwith tag with < chars<br>\n";
750
+		$after = dol_string_nohtmltag($text, 1);
751 751
 		$this->assertEquals("A string with tag with < chars", $after, "test10");
752 752
 
753 753
 		return true;
@@ -764,38 +764,38 @@  discard block
 block discarded – undo
764 764
 	{
765 765
 		// Text not already HTML
766 766
 
767
-		$input="A string\nwith a é, &, < and >.";
768
-		$after=dol_htmlentitiesbr($input, 0);    // Add <br> before \n
767
+		$input = "A string\nwith a é, &, < and >.";
768
+		$after = dol_htmlentitiesbr($input, 0); // Add <br> before \n
769 769
 		$this->assertEquals("A string<br>\nwith a &eacute;, &amp;, &lt; and &gt;.", $after);
770 770
 
771
-		$input="A string\nwith a é, &, < and >.";
772
-		$after=dol_htmlentitiesbr($input, 1);    // Replace \n with <br>
771
+		$input = "A string\nwith a é, &, < and >.";
772
+		$after = dol_htmlentitiesbr($input, 1); // Replace \n with <br>
773 773
 		$this->assertEquals("A string<br>with a &eacute;, &amp;, &lt; and &gt;.", $after);
774 774
 
775
-		$input="A string\nwith a é, &, < and >.\n\n";	// With some \n at end that should be cleaned
776
-		$after=dol_htmlentitiesbr($input, 0);    // Add <br> before \n
775
+		$input = "A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned
776
+		$after = dol_htmlentitiesbr($input, 0); // Add <br> before \n
777 777
 		$this->assertEquals("A string<br>\nwith a &eacute;, &amp;, &lt; and &gt;.", $after);
778 778
 
779
-		$input="A string\nwith a é, &, < and >.\n\n";	// With some \n at end that should be cleaned
780
-		$after=dol_htmlentitiesbr($input, 1);    // Replace \n with <br>
779
+		$input = "A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned
780
+		$after = dol_htmlentitiesbr($input, 1); // Replace \n with <br>
781 781
 		$this->assertEquals("A string<br>with a &eacute;, &amp;, &lt; and &gt;.", $after);
782 782
 
783 783
 		// Text already HTML, so &,<,> should not be converted
784 784
 
785
-		$input="A string<br>\nwith a é, &, < and >.";
786
-		$after=dol_htmlentitiesbr($input);
785
+		$input = "A string<br>\nwith a é, &, < and >.";
786
+		$after = dol_htmlentitiesbr($input);
787 787
 		$this->assertEquals("A string<br>\nwith a &eacute;, &, < and >.", $after);
788 788
 
789
-		$input="<li>\nA string with a é, &, < and >.</li>\nAnother string";
790
-		$after=dol_htmlentitiesbr($input);
789
+		$input = "<li>\nA string with a é, &, < and >.</li>\nAnother string";
790
+		$after = dol_htmlentitiesbr($input);
791 791
 		$this->assertEquals("<li>\nA string with a &eacute;, &, < and >.</li>\nAnother string", $after);
792 792
 
793
-		$input="A string<br>\nwith a é, &, < and >.<br>";	// With some <br> at end that should be cleaned
794
-		$after=dol_htmlentitiesbr($input);
793
+		$input = "A string<br>\nwith a é, &, < and >.<br>"; // With some <br> at end that should be cleaned
794
+		$after = dol_htmlentitiesbr($input);
795 795
 		$this->assertEquals("A string<br>\nwith a &eacute;, &, < and >.", $after);
796 796
 
797
-		$input="<li>\nA string with a é, &, < and >.</li>\nAnother string<br>";	// With some <br> at end that should be cleaned
798
-		$after=dol_htmlentitiesbr($input);
797
+		$input = "<li>\nA string with a é, &, < and >.</li>\nAnother string<br>"; // With some <br> at end that should be cleaned
798
+		$after = dol_htmlentitiesbr($input);
799 799
 		$this->assertEquals("<li>\nA string with a &eacute;, &, < and >.</li>\nAnother string", $after);
800 800
 
801 801
 		// TODO Add test with param $removelasteolbr = 0
@@ -812,18 +812,18 @@  discard block
 block discarded – undo
812 812
 	public function testDolNbOfLinesBis()
813 813
 	{
814 814
 		// This is not a html string so nb of lines depends on \n
815
-		$input="A string\nwith a é, &, < and > and bold tag.\nThird line";
816
-		$after=dol_nboflines_bis($input, 0);
815
+		$input = "A string\nwith a é, &, < and > and bold tag.\nThird line";
816
+		$after = dol_nboflines_bis($input, 0);
817 817
 		$this->assertEquals($after, 3);
818 818
 
819 819
 		// This is a html string so nb of lines depends on <br>
820
-		$input="A string\nwith a é, &, < and > and <b>bold</b> tag.\nThird line";
821
-		$after=dol_nboflines_bis($input, 0);
820
+		$input = "A string\nwith a é, &, < and > and <b>bold</b> tag.\nThird line";
821
+		$after = dol_nboflines_bis($input, 0);
822 822
 		$this->assertEquals($after, 1);
823 823
 
824 824
 		// This is a html string so nb of lines depends on <br>
825
-		$input="A string<br>with a é, &, < and > and <b>bold</b> tag.<br>Third line";
826
-		$after=dol_nboflines_bis($input, 0);
825
+		$input = "A string<br>with a é, &, < and > and <b>bold</b> tag.<br>Third line";
826
+		$after = dol_nboflines_bis($input, 0);
827 827
 		$this->assertEquals($after, 3);
828 828
 
829 829
 		return true;
@@ -839,8 +839,8 @@  discard block
 block discarded – undo
839 839
 	{
840 840
 		// Text not already HTML
841 841
 
842
-		$input="A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >.";
843
-		$after=dol_string_unaccent($input);
842
+		$input = "A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >.";
843
+		$after = dol_string_unaccent($input);
844 844
 		$this->assertEquals("A string\nwith a a a e e e i u o y, &, < and >.", $after);
845 845
 	}
846 846
 
@@ -853,17 +853,17 @@  discard block
 block discarded – undo
853 853
 	public function testDolUtf8Check()
854 854
 	{
855 855
 		// True
856
-		$result=utf8_check('azerty');
856
+		$result = utf8_check('azerty');
857 857
 		$this->assertTrue($result);
858 858
 
859
-		$file=dirname(__FILE__).'/textutf8.txt';
860
-		$filecontent=file_get_contents($file);
861
-		$result=utf8_check($filecontent);
859
+		$file = dirname(__FILE__).'/textutf8.txt';
860
+		$filecontent = file_get_contents($file);
861
+		$result = utf8_check($filecontent);
862 862
 		$this->assertTrue($result);
863 863
 
864
-		$file=dirname(__FILE__).'/textiso.txt';
865
-		$filecontent=file_get_contents($file);
866
-		$result=utf8_check($filecontent);
864
+		$file = dirname(__FILE__).'/textiso.txt';
865
+		$filecontent = file_get_contents($file);
866
+		$result = utf8_check($filecontent);
867 867
 		$this->assertFalse($result);
868 868
 	}
869 869
 
@@ -875,15 +875,15 @@  discard block
 block discarded – undo
875 875
 	public function testDolAsciiCheck()
876 876
 	{
877 877
 		// True
878
-		$result=ascii_check('azerty');
878
+		$result = ascii_check('azerty');
879 879
 		$this->assertTrue($result);
880 880
 
881
-		$result=ascii_check('é');
881
+		$result = ascii_check('é');
882 882
 		$this->assertFalse($result);
883 883
 
884
-		$file=dirname(__FILE__).'/textutf8.txt';
885
-		$filecontent=file_get_contents($file);
886
-		$result=ascii_check($filecontent);
884
+		$file = dirname(__FILE__).'/textutf8.txt';
885
+		$filecontent = file_get_contents($file);
886
+		$result = ascii_check($filecontent);
887 887
 		$this->assertFalse($result);
888 888
 	}
889 889
 
@@ -895,49 +895,49 @@  discard block
 block discarded – undo
895 895
 	public function testDolTrunc()
896 896
 	{
897 897
 		// Default trunc (will add … if truncation truncation or keep last char if only one char)
898
-		$input="éeéeéeàa";
899
-		$after=dol_trunc($input, 3);
898
+		$input = "éeéeéeàa";
899
+		$after = dol_trunc($input, 3);
900 900
 		$this->assertEquals("éeé…", $after, 'Test A1');
901
-		$after=dol_trunc($input, 2);
901
+		$after = dol_trunc($input, 2);
902 902
 		$this->assertEquals("ée…", $after, 'Test A2');
903
-		$after=dol_trunc($input, 1);
903
+		$after = dol_trunc($input, 1);
904 904
 		$this->assertEquals("é…", $after, 'Test A3');
905
-		$input="éeée";
906
-		$after=dol_trunc($input, 3);
905
+		$input = "éeée";
906
+		$after = dol_trunc($input, 3);
907 907
 		$this->assertEquals("éeée", $after, 'Test B1');
908
-		$after=dol_trunc($input, 2);
908
+		$after = dol_trunc($input, 2);
909 909
 		$this->assertEquals("ée…", $after, 'Test B2');
910
-		$after=dol_trunc($input, 1);
910
+		$after = dol_trunc($input, 1);
911 911
 		$this->assertEquals("é…", $after, 'Test B3');
912
-		$input="éeée";
913
-		$after=dol_trunc($input, 3);
912
+		$input = "éeée";
913
+		$after = dol_trunc($input, 3);
914 914
 		$this->assertEquals("éeée", $after, 'Test C1');
915
-		$after=dol_trunc($input, 2);
915
+		$after = dol_trunc($input, 2);
916 916
 		$this->assertEquals("ée…", $after, 'Test C2');
917
-		$after=dol_trunc($input, 1);
917
+		$after = dol_trunc($input, 1);
918 918
 		$this->assertEquals("é…", $after, 'Test C3');
919
-		$input="éeé";
920
-		$after=dol_trunc($input, 3);
919
+		$input = "éeé";
920
+		$after = dol_trunc($input, 3);
921 921
 		$this->assertEquals("éeé", $after, 'Test C');
922
-		$after=dol_trunc($input, 2);
922
+		$after = dol_trunc($input, 2);
923 923
 		$this->assertEquals("éeé", $after, 'Test D');
924
-		$after=dol_trunc($input, 1);
924
+		$after = dol_trunc($input, 1);
925 925
 		$this->assertEquals("é…", $after, 'Test E');
926 926
 		// Trunc with no …
927
-		$input="éeéeéeàa";
928
-		$after=dol_trunc($input, 3, 'right', 'UTF-8', 1);
927
+		$input = "éeéeéeàa";
928
+		$after = dol_trunc($input, 3, 'right', 'UTF-8', 1);
929 929
 		$this->assertEquals("éeé", $after, 'Test F');
930
-		$after=dol_trunc($input, 2, 'right', 'UTF-8', 1);
930
+		$after = dol_trunc($input, 2, 'right', 'UTF-8', 1);
931 931
 		$this->assertEquals("ée", $after, 'Test G');
932
-		$input="éeé";
933
-		$after=dol_trunc($input, 3, 'right', 'UTF-8', 1);
932
+		$input = "éeé";
933
+		$after = dol_trunc($input, 3, 'right', 'UTF-8', 1);
934 934
 		$this->assertEquals("éeé", $after, 'Test H');
935
-		$after=dol_trunc($input, 2, 'right', 'UTF-8', 1);
935
+		$after = dol_trunc($input, 2, 'right', 'UTF-8', 1);
936 936
 		$this->assertEquals("ée", $after, 'Test I');
937
-		$after=dol_trunc($input, 1, 'right', 'UTF-8', 1);
937
+		$after = dol_trunc($input, 1, 'right', 'UTF-8', 1);
938 938
 		$this->assertEquals("é", $after, 'Test J');
939
-		$input="éeéeéeàa";
940
-		$after=dol_trunc($input, 4, 'middle');
939
+		$input = "éeéeéeàa";
940
+		$after = dol_trunc($input, 4, 'middle');
941 941
 		$this->assertEquals("ée…àa", $after, 'Test K');
942 942
 
943 943
 		return true;
@@ -952,49 +952,49 @@  discard block
 block discarded – undo
952 952
 	{
953 953
 		global $conf;
954 954
 
955
-		$savtz=date_default_timezone_get();
955
+		$savtz = date_default_timezone_get();
956 956
 
957 957
 		// Some test for UTC TZ
958 958
 		date_default_timezone_set('UTC');
959 959
 
960 960
 		// Check bad hours
961
-		$result=dol_mktime(25, 0, 0, 1, 1, 1970, 1, 1);    // Error (25 hours)
961
+		$result = dol_mktime(25, 0, 0, 1, 1, 1970, 1, 1); // Error (25 hours)
962 962
 		print __METHOD__." result=".$result."\n";
963 963
 		$this->assertEquals('', $result);
964
-		$result=dol_mktime(2, 61, 0, 1, 1, 1970, 1, 1);    // Error (61 minutes)
964
+		$result = dol_mktime(2, 61, 0, 1, 1, 1970, 1, 1); // Error (61 minutes)
965 965
 		print __METHOD__." result=".$result."\n";
966 966
 		$this->assertEquals('', $result);
967
-		$result=dol_mktime(2, 1, 61, 1, 1, 1970, 1, 1);    // Error (61 seconds)
967
+		$result = dol_mktime(2, 1, 61, 1, 1, 1970, 1, 1); // Error (61 seconds)
968 968
 		print __METHOD__." result=".$result."\n";
969 969
 		$this->assertEquals('', $result);
970
-		$result=dol_mktime(2, 1, 1, 1, 32, 1970, 1, 1);    // Error (day 32)
970
+		$result = dol_mktime(2, 1, 1, 1, 32, 1970, 1, 1); // Error (day 32)
971 971
 		print __METHOD__." result=".$result."\n";
972 972
 		$this->assertEquals('', $result);
973
-		$result=dol_mktime(2, 1, 1, 13, 1, 1970, 1, 1);    // Error (month 13)
973
+		$result = dol_mktime(2, 1, 1, 13, 1, 1970, 1, 1); // Error (month 13)
974 974
 		print __METHOD__." result=".$result."\n";
975 975
 		$this->assertEquals('', $result);
976 976
 
977
-		$result=dol_mktime(2, 1, 1, 1, 1, 1970, 1);    // 1970-01-01 02:01:01 in GMT area -> 7261
977
+		$result = dol_mktime(2, 1, 1, 1, 1, 1970, 1); // 1970-01-01 02:01:01 in GMT area -> 7261
978 978
 		print __METHOD__." result=".$result."\n";
979 979
 		$this->assertEquals(7261, $result);
980 980
 
981
-		$result=dol_mktime(2, 0, 0, 1, 1, 1970, 0);                // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT
981
+		$result = dol_mktime(2, 0, 0, 1, 1, 1970, 0); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT
982 982
 		print __METHOD__." result=".$result."\n";
983
-		$tz=getServerTimeZoneInt('winter');                  // +1 in Europe/Paris at this time (this time is winter)
984
-		$this->assertEquals(7200-($tz*3600), $result);        // 7200 if we are at greenwich winter, 7200-($tz*3600) at local winter
983
+		$tz = getServerTimeZoneInt('winter'); // +1 in Europe/Paris at this time (this time is winter)
984
+		$this->assertEquals(7200 - ($tz * 3600), $result); // 7200 if we are at greenwich winter, 7200-($tz*3600) at local winter
985 985
 
986 986
 		// Some test for local TZ Europe/Paris
987 987
 		date_default_timezone_set('Europe/Paris');
988 988
 
989 989
 		// Check that tz for paris in winter is used
990
-		$result=dol_mktime(2, 0, 0, 1, 1, 1970, 'server');         // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT
990
+		$result = dol_mktime(2, 0, 0, 1, 1, 1970, 'server'); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT
991 991
 		print __METHOD__." result=".$result."\n";
992
-		$this->assertEquals(3600, $result);        			 // 7200 if we are at greenwich winter, 3600 at Europe/Paris
992
+		$this->assertEquals(3600, $result); // 7200 if we are at greenwich winter, 3600 at Europe/Paris
993 993
 
994 994
 		// Check that daylight saving time is used
995
-		$result=dol_mktime(2, 0, 0, 6, 1, 2014, 0);         		// 2014-06-01 02:00:00 = 1401588000-3600(location)-3600(daylight) in local area Europe/Paris = 1401588000 GMT
995
+		$result = dol_mktime(2, 0, 0, 6, 1, 2014, 0); // 2014-06-01 02:00:00 = 1401588000-3600(location)-3600(daylight) in local area Europe/Paris = 1401588000 GMT
996 996
 		print __METHOD__." result=".$result."\n";
997
-		$this->assertEquals(1401588000-3600-3600, $result);  // 1401588000 are at greenwich summer, 1401588000-3600(location)-3600(daylight) at Europe/Paris summer
997
+		$this->assertEquals(1401588000 - 3600 - 3600, $result); // 1401588000 are at greenwich summer, 1401588000-3600(location)-3600(daylight) at Europe/Paris summer
998 998
 
999 999
 		date_default_timezone_set($savtz);
1000 1000
 	}
@@ -1007,14 +1007,14 @@  discard block
 block discarded – undo
1007 1007
 	 */
1008 1008
 	public function testDolEscapeJs()
1009 1009
 	{
1010
-		$input="x&<b>#</b>,\"'";    // " will be converted into '
1011
-		$result=dol_escape_js($input);
1010
+		$input = "x&<b>#</b>,\"'"; // " will be converted into '
1011
+		$result = dol_escape_js($input);
1012 1012
 		$this->assertEquals("x&<b>#</b>,\'\'", $result, "Test mode=0");
1013 1013
 
1014
-		$result=dol_escape_js($input, 1);
1014
+		$result = dol_escape_js($input, 1);
1015 1015
 		$this->assertEquals("x&<b>#</b>,\"\'", $result, "Test mode=1");
1016 1016
 
1017
-		$result=dol_escape_js($input, 2);
1017
+		$result = dol_escape_js($input, 2);
1018 1018
 		$this->assertEquals("x&<b>#</b>,\\\"'", $result, "Test mode=2");
1019 1019
 	}
1020 1020
 
@@ -1026,12 +1026,12 @@  discard block
 block discarded – undo
1026 1026
 	*/
1027 1027
 	public function testDolEscapeHtmlTag()
1028 1028
 	{
1029
-		$input='x&<b>#</b>,"';    // & and " are converted into html entities, <b> are removed
1030
-		$result=dol_escape_htmltag($input);
1029
+		$input = 'x&<b>#</b>,"'; // & and " are converted into html entities, <b> are removed
1030
+		$result = dol_escape_htmltag($input);
1031 1031
 		$this->assertEquals('x&amp;#,&quot;', $result);
1032 1032
 
1033
-		$input='x&<b>#</b>,"';    // & and " are converted into html entities, <b> are not removed
1034
-		$result=dol_escape_htmltag($input, 1);
1033
+		$input = 'x&<b>#</b>,"'; // & and " are converted into html entities, <b> are not removed
1034
+		$result = dol_escape_htmltag($input, 1);
1035 1035
 		$this->assertEquals('x&amp;&lt;b&gt;#&lt;/b&gt;,&quot;', $result);
1036 1036
 	}
1037 1037
 
@@ -1043,33 +1043,33 @@  discard block
 block discarded – undo
1043 1043
 	 */
1044 1044
 	public function testDolFormatAddress()
1045 1045
 	{
1046
-		global $conf,$user,$langs,$db;
1047
-		$conf=$this->savconf;
1048
-		$user=$this->savuser;
1049
-		$langs=$this->savlangs;
1050
-		$db=$this->savdb;
1046
+		global $conf, $user, $langs, $db;
1047
+		$conf = $this->savconf;
1048
+		$user = $this->savuser;
1049
+		$langs = $this->savlangs;
1050
+		$db = $this->savdb;
1051 1051
 
1052
-		$object=new Societe($db);
1052
+		$object = new Societe($db);
1053 1053
 		$object->initAsSpecimen();
1054 1054
 
1055
-		$object->country_code='FR';
1056
-		$address=dol_format_address($object);
1055
+		$object->country_code = 'FR';
1056
+		$address = dol_format_address($object);
1057 1057
 		$this->assertEquals("21 jump street\n99999 MyTown", $address);
1058 1058
 
1059
-		$object->country_code='GB';
1060
-		$address=dol_format_address($object);
1059
+		$object->country_code = 'GB';
1060
+		$address = dol_format_address($object);
1061 1061
 		$this->assertEquals("21 jump street\nMyTown, MyState\n99999", $address);
1062 1062
 
1063
-		$object->country_code='US';
1064
-		$address=dol_format_address($object);
1063
+		$object->country_code = 'US';
1064
+		$address = dol_format_address($object);
1065 1065
 		$this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address);
1066 1066
 
1067
-		$object->country_code='AU';
1068
-		$address=dol_format_address($object);
1067
+		$object->country_code = 'AU';
1068
+		$address = dol_format_address($object);
1069 1069
 		$this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address);
1070 1070
 
1071
-		$object->country_code='JP';
1072
-		$address=dol_format_address($object);
1071
+		$object->country_code = 'JP';
1072
+		$address = dol_format_address($object);
1073 1073
 		$this->assertEquals("21 jump street\nMyState, MyTown 99999", $address);
1074 1074
 	}
1075 1075
 
@@ -1081,29 +1081,29 @@  discard block
 block discarded – undo
1081 1081
 	 */
1082 1082
 	public function testDolPrintPhone()
1083 1083
 	{
1084
-		global $conf,$user,$langs,$db;
1085
-		$conf=$this->savconf;
1086
-		$user=$this->savuser;
1087
-		$langs=$this->savlangs;
1088
-		$db=$this->savdb;
1084
+		global $conf, $user, $langs, $db;
1085
+		$conf = $this->savconf;
1086
+		$user = $this->savuser;
1087
+		$langs = $this->savlangs;
1088
+		$db = $this->savdb;
1089 1089
 
1090
-		$object=new Societe($db);
1090
+		$object = new Societe($db);
1091 1091
 		$object->initAsSpecimen();
1092 1092
 
1093
-		$object->country_code='FR';
1094
-		$phone=dol_print_phone('1234567890', $object->country_code);
1093
+		$object->country_code = 'FR';
1094
+		$phone = dol_print_phone('1234567890', $object->country_code);
1095 1095
 		$this->assertEquals('<span style="margin-right: 10px;">12&nbsp;34&nbsp;56&nbsp;78&nbsp;90</span>', $phone, 'Phone for FR 1');
1096 1096
 
1097
-		$object->country_code='FR';
1098
-		$phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, '');
1097
+		$object->country_code = 'FR';
1098
+		$phone = dol_print_phone('1234567890', $object->country_code, 0, 0, 0, '');
1099 1099
 		$this->assertEquals('<span style="margin-right: 10px;">1234567890</span>', $phone, 'Phone for FR 2');
1100 1100
 
1101
-		$object->country_code='FR';
1102
-		$phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' ');
1101
+		$object->country_code = 'FR';
1102
+		$phone = dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' ');
1103 1103
 		$this->assertEquals('<span style="margin-right: 10px;">12 34 56 78 90</span>', $phone, 'Phone for FR 3');
1104 1104
 
1105
-		$object->country_code='CA';
1106
-		$phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' ');
1105
+		$object->country_code = 'CA';
1106
+		$phone = dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' ');
1107 1107
 		$this->assertEquals('<span style="margin-right: 10px;">(123) 456-7890</span>', $phone, 'Phone for CA 1');
1108 1108
 	}
1109 1109
 
@@ -1115,24 +1115,24 @@  discard block
 block discarded – undo
1115 1115
 	 */
1116 1116
 	public function testImgPicto()
1117 1117
 	{
1118
-		$s=img_picto('title', 'user');
1118
+		$s = img_picto('title', 'user');
1119 1119
 		print __METHOD__." s=".$s."\n";
1120 1120
 		$this->assertStringContainsStringIgnoringCase('fa-user', $s, 'testImgPicto1');
1121 1121
 
1122
-		$s=img_picto('title', 'img.png', 'style="float: right"', 0);
1122
+		$s = img_picto('title', 'img.png', 'style="float: right"', 0);
1123 1123
 		print __METHOD__." s=".$s."\n";
1124 1124
 		$this->assertStringContainsStringIgnoringCase('theme', $s, 'testImgPicto2');
1125 1125
 		$this->assertStringContainsStringIgnoringCase('style="float: right"', $s, 'testImgPicto2');
1126 1126
 
1127
-		$s=img_picto('title', '/fullpath/img.png', '', 1);
1127
+		$s = img_picto('title', '/fullpath/img.png', '', 1);
1128 1128
 		print __METHOD__." s=".$s."\n";
1129 1129
 		$this->assertEquals('<img src="/fullpath/img.png" alt="" title="title" class="inline-block">', $s, 'testImgPicto3');
1130 1130
 
1131
-		$s=img_picto('title', '/fullpath/img.png', '', true);
1131
+		$s = img_picto('title', '/fullpath/img.png', '', true);
1132 1132
 		print __METHOD__." s=".$s."\n";
1133 1133
 		$this->assertEquals('<img src="/fullpath/img.png" alt="" title="title" class="inline-block">', $s, 'testImgPicto4');
1134 1134
 
1135
-		$s=img_picto('title', 'delete', '', 0, 1);
1135
+		$s = img_picto('title', 'delete', '', 0, 1);
1136 1136
 		print __METHOD__." s=".$s."\n";
1137 1137
 		$this->assertEquals(DOL_URL_ROOT.'/theme/eldy/img/delete.png', $s, 'testImgPicto5');
1138 1138
 	}
@@ -1144,10 +1144,10 @@  discard block
 block discarded – undo
1144 1144
 	 */
1145 1145
 	public function testDolNow()
1146 1146
 	{
1147
-		$now=dol_now('gmt');
1148
-		$nowtzserver=dol_now('tzserver');
1149
-		print __METHOD__." getServerTimeZoneInt=".(getServerTimeZoneInt('now')*3600)."\n";
1150
-		$this->assertEquals(getServerTimeZoneInt('now')*3600, ($nowtzserver-$now));
1147
+		$now = dol_now('gmt');
1148
+		$nowtzserver = dol_now('tzserver');
1149
+		print __METHOD__." getServerTimeZoneInt=".(getServerTimeZoneInt('now') * 3600)."\n";
1150
+		$this->assertEquals(getServerTimeZoneInt('now') * 3600, ($nowtzserver - $now));
1151 1151
 	}
1152 1152
 
1153 1153
 	/**
@@ -1157,25 +1157,25 @@  discard block
 block discarded – undo
1157 1157
 	 */
1158 1158
 	public function testVerifCond()
1159 1159
 	{
1160
-		$verifcond=verifCond('1==1');
1160
+		$verifcond = verifCond('1==1');
1161 1161
 		$this->assertTrue($verifcond, 'Test a true comparison');
1162 1162
 
1163
-		$verifcond=verifCond('1==2');
1163
+		$verifcond = verifCond('1==2');
1164 1164
 		$this->assertFalse($verifcond, 'Test a false comparison');
1165 1165
 
1166
-		$verifcond=verifCond('isModEnabled("facture")');
1166
+		$verifcond = verifCond('isModEnabled("facture")');
1167 1167
 		$this->assertTrue($verifcond, 'Test that the conf property of a module reports true when enabled');
1168 1168
 
1169
-		$verifcond=verifCond('isModEnabled("moduledummy")');
1169
+		$verifcond = verifCond('isModEnabled("moduledummy")');
1170 1170
 		$this->assertFalse($verifcond, 'Test that the conf property of a module reports false when disabled');
1171 1171
 
1172
-		$verifcond=verifCond(0);
1172
+		$verifcond = verifCond(0);
1173 1173
 		$this->assertFalse($verifcond, 'Test that verifConf(0) return False');
1174 1174
 
1175
-		$verifcond=verifCond("0");
1175
+		$verifcond = verifCond("0");
1176 1176
 		$this->assertFalse($verifcond, 'Test that verifConf("0") return False');
1177 1177
 
1178
-		$verifcond=verifCond('');
1178
+		$verifcond = verifCond('');
1179 1179
 		$this->assertTrue($verifcond, 'Test that verifConf("") return False (special case)');
1180 1180
 	}
1181 1181
 
@@ -1186,75 +1186,75 @@  discard block
 block discarded – undo
1186 1186
 	 */
1187 1187
 	public function testGetDefaultTva()
1188 1188
 	{
1189
-		global $conf,$user,$langs,$db;
1190
-		$this->savconf=$conf;
1191
-		$this->savuser=$user;
1192
-		$this->savlangs=$langs;
1193
-		$this->savdb=$db;
1189
+		global $conf, $user, $langs, $db;
1190
+		$this->savconf = $conf;
1191
+		$this->savuser = $user;
1192
+		$this->savlangs = $langs;
1193
+		$this->savdb = $db;
1194 1194
 
1195 1195
 		// Sellers
1196
-		$companyfrnovat=new Societe($db);
1197
-		$companyfrnovat->country_code='FR';
1198
-		$companyfrnovat->tva_assuj=0;
1196
+		$companyfrnovat = new Societe($db);
1197
+		$companyfrnovat->country_code = 'FR';
1198
+		$companyfrnovat->tva_assuj = 0;
1199 1199
 
1200
-		$companyfr=new Societe($db);
1201
-		$companyfr->country_code='FR';
1202
-		$companyfr->tva_assuj=1;
1203
-		$companyfr->tva_intra='FR9999';
1200
+		$companyfr = new Societe($db);
1201
+		$companyfr->country_code = 'FR';
1202
+		$companyfr->tva_assuj = 1;
1203
+		$companyfr->tva_intra = 'FR9999';
1204 1204
 
1205 1205
 		// Buyers
1206
-		$companymc=new Societe($db);
1207
-		$companymc->country_code='MC';
1208
-		$companymc->tva_assuj=1;
1209
-		$companyfr->tva_intra='MC9999';
1206
+		$companymc = new Societe($db);
1207
+		$companymc->country_code = 'MC';
1208
+		$companymc->tva_assuj = 1;
1209
+		$companyfr->tva_intra = 'MC9999';
1210 1210
 
1211
-		$companyit=new Societe($db);
1212
-		$companyit->country_code='IT';
1213
-		$companyit->tva_assuj=1;
1214
-		$companyit->tva_intra='IT99999';
1211
+		$companyit = new Societe($db);
1212
+		$companyit->country_code = 'IT';
1213
+		$companyit->tva_assuj = 1;
1214
+		$companyit->tva_intra = 'IT99999';
1215 1215
 
1216
-		$companyde=new Societe($db);
1217
-		$companyde->country_code='DE';
1218
-		$companyde->tva_assuj=1;
1219
-		$companyde->tva_intra='DE99999';
1216
+		$companyde = new Societe($db);
1217
+		$companyde->country_code = 'DE';
1218
+		$companyde->tva_assuj = 1;
1219
+		$companyde->tva_intra = 'DE99999';
1220 1220
 
1221
-		$notcompanyde=new Societe($db);
1222
-		$notcompanyde->country_code='DE';
1223
-		$notcompanyde->tva_assuj=0;
1224
-		$notcompanyde->tva_intra='';
1225
-		$notcompanyde->typent_code='TE_PRIVATE';
1221
+		$notcompanyde = new Societe($db);
1222
+		$notcompanyde->country_code = 'DE';
1223
+		$notcompanyde->tva_assuj = 0;
1224
+		$notcompanyde->tva_intra = '';
1225
+		$notcompanyde->typent_code = 'TE_PRIVATE';
1226 1226
 
1227
-		$companyus=new Societe($db);
1228
-		$companyus->country_code='US';
1229
-		$companyus->tva_assuj=1;
1230
-		$companyus->tva_intra='';
1227
+		$companyus = new Societe($db);
1228
+		$companyus->country_code = 'US';
1229
+		$companyus->tva_assuj = 1;
1230
+		$companyus->tva_intra = '';
1231 1231
 
1232 1232
 
1233 1233
 		// Test RULE 0 (FR-DE)
1234 1234
 		// Not tested
1235 1235
 
1236 1236
 		// Test RULE 1
1237
-		$vat=get_default_tva($companyfrnovat, $companymc, 0);
1237
+		$vat = get_default_tva($companyfrnovat, $companymc, 0);
1238 1238
 		$this->assertEquals(0, $vat, 'RULE 1');
1239 1239
 
1240 1240
 		// Test RULE 2 (FR-FR)
1241
-		$vat=get_default_tva($companyfr, $companyfr, 0);
1241
+		$vat = get_default_tva($companyfr, $companyfr, 0);
1242 1242
 		$this->assertEquals(20, $vat, 'RULE 2');
1243 1243
 
1244 1244
 		// Test RULE 2 (FR-MC)
1245
-		$vat=get_default_tva($companyfr, $companymc, 0);
1245
+		$vat = get_default_tva($companyfr, $companymc, 0);
1246 1246
 		$this->assertEquals(20, $vat, 'RULE 2');
1247 1247
 
1248 1248
 		// Test RULE 3 (FR-DE company)
1249
-		$vat=get_default_tva($companyfr, $companyit, 0);
1249
+		$vat = get_default_tva($companyfr, $companyit, 0);
1250 1250
 		$this->assertEquals(0, $vat, 'RULE 3');
1251 1251
 
1252 1252
 		// Test RULE 4 (FR-DE not a company)
1253
-		$vat=get_default_tva($companyfr, $notcompanyde, 0);
1253
+		$vat = get_default_tva($companyfr, $notcompanyde, 0);
1254 1254
 		$this->assertEquals(20, $vat, 'RULE 4');
1255 1255
 
1256 1256
 		// Test RULE 5 (FR-US)
1257
-		$vat=get_default_tva($companyfr, $companyus, 0);
1257
+		$vat = get_default_tva($companyfr, $companyus, 0);
1258 1258
 		$this->assertEquals(0, $vat, 'RULE 5');
1259 1259
 
1260 1260
 
@@ -1262,23 +1262,23 @@  discard block
 block discarded – undo
1262 1262
 		$conf->global->SERVICE_ARE_ECOMMERCE_200238EC = 1;
1263 1263
 
1264 1264
 		// Test RULE 1 (FR-US)
1265
-		$vat=get_default_tva($companyfr, $companyus, 0);
1265
+		$vat = get_default_tva($companyfr, $companyus, 0);
1266 1266
 		$this->assertEquals(0, $vat, 'RULE 1 ECOMMERCE_200238EC');
1267 1267
 
1268 1268
 		// Test RULE 2 (FR-FR)
1269
-		$vat=get_default_tva($companyfr, $companyfr, 0);
1269
+		$vat = get_default_tva($companyfr, $companyfr, 0);
1270 1270
 		$this->assertEquals(20, $vat, 'RULE 2 ECOMMERCE_200238EC');
1271 1271
 
1272 1272
 		// Test RULE 3 (FR-DE company)
1273
-		$vat=get_default_tva($companyfr, $companyde, 0);
1273
+		$vat = get_default_tva($companyfr, $companyde, 0);
1274 1274
 		$this->assertEquals(0, $vat, 'RULE 3 ECOMMERCE_200238EC');
1275 1275
 
1276 1276
 		// Test RULE 4 (FR-DE not a company)
1277
-		$vat=get_default_tva($companyfr, $notcompanyde, 0);
1277
+		$vat = get_default_tva($companyfr, $notcompanyde, 0);
1278 1278
 		$this->assertEquals(19, $vat, 'RULE 4 ECOMMERCE_200238EC');
1279 1279
 
1280 1280
 		// Test RULE 5 (FR-US)
1281
-		$vat=get_default_tva($companyfr, $companyus, 0);
1281
+		$vat = get_default_tva($companyfr, $companyus, 0);
1282 1282
 		$this->assertEquals(0, $vat, 'RULE 5 ECOMMERCE_200238EC');
1283 1283
 	}
1284 1284
 
@@ -1289,73 +1289,73 @@  discard block
 block discarded – undo
1289 1289
 	 */
1290 1290
 	public function testGetDefaultLocalTax()
1291 1291
 	{
1292
-		global $conf,$user,$langs,$db;
1293
-		$this->savconf=$conf;
1294
-		$this->savuser=$user;
1295
-		$this->savlangs=$langs;
1296
-		$this->savdb=$db;
1297
-
1298
-		$companyfrnovat=new Societe($db);
1299
-		$companyfrnovat->country_code='FR';
1300
-		$companyfrnovat->tva_assuj=0;
1301
-		$companyfrnovat->localtax1_assuj=0;
1302
-		$companyfrnovat->localtax2_assuj=0;
1303
-
1304
-		$companyes=new Societe($db);
1305
-		$companyes->country_code='ES';
1306
-		$companyes->tva_assuj=1;
1307
-		$companyes->localtax1_assuj=1;
1308
-		$companyes->localtax2_assuj=1;
1309
-
1310
-		$companymc=new Societe($db);
1311
-		$companymc->country_code='MC';
1312
-		$companymc->tva_assuj=1;
1313
-		$companymc->localtax1_assuj=0;
1314
-		$companymc->localtax2_assuj=0;
1315
-
1316
-		$companyit=new Societe($db);
1317
-		$companyit->country_code='IT';
1318
-		$companyit->tva_assuj=1;
1319
-		$companyit->tva_intra='IT99999';
1320
-		$companyit->localtax1_assuj=0;
1321
-		$companyit->localtax2_assuj=0;
1322
-
1323
-		$notcompanyit=new Societe($db);
1324
-		$notcompanyit->country_code='IT';
1325
-		$notcompanyit->tva_assuj=1;
1326
-		$notcompanyit->tva_intra='';
1327
-		$notcompanyit->typent_code='TE_PRIVATE';
1328
-		$notcompanyit->localtax1_assuj=0;
1329
-		$notcompanyit->localtax2_assuj=0;
1330
-
1331
-		$companyus=new Societe($db);
1332
-		$companyus->country_code='US';
1333
-		$companyus->tva_assuj=1;
1334
-		$companyus->tva_intra='';
1335
-		$companyus->localtax1_assuj=0;
1336
-		$companyus->localtax2_assuj=0;
1292
+		global $conf, $user, $langs, $db;
1293
+		$this->savconf = $conf;
1294
+		$this->savuser = $user;
1295
+		$this->savlangs = $langs;
1296
+		$this->savdb = $db;
1297
+
1298
+		$companyfrnovat = new Societe($db);
1299
+		$companyfrnovat->country_code = 'FR';
1300
+		$companyfrnovat->tva_assuj = 0;
1301
+		$companyfrnovat->localtax1_assuj = 0;
1302
+		$companyfrnovat->localtax2_assuj = 0;
1303
+
1304
+		$companyes = new Societe($db);
1305
+		$companyes->country_code = 'ES';
1306
+		$companyes->tva_assuj = 1;
1307
+		$companyes->localtax1_assuj = 1;
1308
+		$companyes->localtax2_assuj = 1;
1309
+
1310
+		$companymc = new Societe($db);
1311
+		$companymc->country_code = 'MC';
1312
+		$companymc->tva_assuj = 1;
1313
+		$companymc->localtax1_assuj = 0;
1314
+		$companymc->localtax2_assuj = 0;
1315
+
1316
+		$companyit = new Societe($db);
1317
+		$companyit->country_code = 'IT';
1318
+		$companyit->tva_assuj = 1;
1319
+		$companyit->tva_intra = 'IT99999';
1320
+		$companyit->localtax1_assuj = 0;
1321
+		$companyit->localtax2_assuj = 0;
1322
+
1323
+		$notcompanyit = new Societe($db);
1324
+		$notcompanyit->country_code = 'IT';
1325
+		$notcompanyit->tva_assuj = 1;
1326
+		$notcompanyit->tva_intra = '';
1327
+		$notcompanyit->typent_code = 'TE_PRIVATE';
1328
+		$notcompanyit->localtax1_assuj = 0;
1329
+		$notcompanyit->localtax2_assuj = 0;
1330
+
1331
+		$companyus = new Societe($db);
1332
+		$companyus->country_code = 'US';
1333
+		$companyus->tva_assuj = 1;
1334
+		$companyus->tva_intra = '';
1335
+		$companyus->localtax1_assuj = 0;
1336
+		$companyus->localtax2_assuj = 0;
1337 1337
 
1338 1338
 		// Test RULE FR-MC
1339
-		$vat1=get_default_localtax($companyfrnovat, $companymc, 1, 0);
1340
-		$vat2=get_default_localtax($companyfrnovat, $companymc, 2, 0);
1339
+		$vat1 = get_default_localtax($companyfrnovat, $companymc, 1, 0);
1340
+		$vat2 = get_default_localtax($companyfrnovat, $companymc, 2, 0);
1341 1341
 		$this->assertEquals(0, $vat1);
1342 1342
 		$this->assertEquals(0, $vat2);
1343 1343
 
1344 1344
 		// Test RULE ES-ES
1345
-		$vat1=get_default_localtax($companyes, $companyes, 1, 0);
1346
-		$vat2=get_default_localtax($companyes, $companyes, 2, 0);
1345
+		$vat1 = get_default_localtax($companyes, $companyes, 1, 0);
1346
+		$vat2 = get_default_localtax($companyes, $companyes, 2, 0);
1347 1347
 		$this->assertEquals($vat1, 5.2);
1348
-		$this->assertStringStartsWith((string) $vat2, '-19:-15:-9');       // Can be -19 (old version) or '-19:-15:-9' (new setup)
1348
+		$this->assertStringStartsWith((string) $vat2, '-19:-15:-9'); // Can be -19 (old version) or '-19:-15:-9' (new setup)
1349 1349
 
1350 1350
 		// Test RULE ES-IT
1351
-		$vat1=get_default_localtax($companyes, $companyit, 1, 0);
1352
-		$vat2=get_default_localtax($companyes, $companyit, 2, 0);
1351
+		$vat1 = get_default_localtax($companyes, $companyit, 1, 0);
1352
+		$vat2 = get_default_localtax($companyes, $companyit, 2, 0);
1353 1353
 		$this->assertEquals(0, $vat1);
1354 1354
 		$this->assertEquals(0, $vat2);
1355 1355
 
1356 1356
 		// Test RULE ES-IT
1357
-		$vat1=get_default_localtax($companyes, $notcompanyit, 1, 0);
1358
-		$vat2=get_default_localtax($companyes, $notcompanyit, 2, 0);
1357
+		$vat1 = get_default_localtax($companyes, $notcompanyit, 1, 0);
1358
+		$vat2 = get_default_localtax($companyes, $notcompanyit, 2, 0);
1359 1359
 		$this->assertEquals(0, $vat1);
1360 1360
 		$this->assertEquals(0, $vat2);
1361 1361
 
@@ -1363,8 +1363,8 @@  discard block
 block discarded – undo
1363 1363
 		// Not tested
1364 1364
 
1365 1365
 		// Test RULE ES-US
1366
-		$vat1=get_default_localtax($companyes, $companyus, 1, 0);
1367
-		$vat2=get_default_localtax($companyes, $companyus, 2, 0);
1366
+		$vat1 = get_default_localtax($companyes, $companyus, 1, 0);
1367
+		$vat2 = get_default_localtax($companyes, $companyus, 2, 0);
1368 1368
 		$this->assertEquals(0, $vat1);
1369 1369
 		$this->assertEquals(0, $vat2);
1370 1370
 	}
@@ -1398,14 +1398,14 @@  discard block
 block discarded – undo
1398 1398
 	 */
1399 1399
 	public function testDolExplodeIntoArray()
1400 1400
 	{
1401
-		$stringtoexplode='AA=B/B.CC=.EE=FF.HH=GG;.';
1402
-		$tmp=dolExplodeIntoArray($stringtoexplode, '.', '=');
1401
+		$stringtoexplode = 'AA=B/B.CC=.EE=FF.HH=GG;.';
1402
+		$tmp = dolExplodeIntoArray($stringtoexplode, '.', '=');
1403 1403
 
1404 1404
 		print __METHOD__." tmp=".json_encode($tmp)."\n";
1405 1405
 		$this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG;"}', json_encode($tmp));
1406 1406
 
1407
-		$stringtoexplode="AA=B/B;CC=\n\rEE=FF\nHH=GG;;;\nII=JJ\n";
1408
-		$tmp=dolExplodeIntoArray($stringtoexplode, "(\r\n|\n|\r|;)", '=');
1407
+		$stringtoexplode = "AA=B/B;CC=\n\rEE=FF\nHH=GG;;;\nII=JJ\n";
1408
+		$tmp = dolExplodeIntoArray($stringtoexplode, "(\r\n|\n|\r|;)", '=');
1409 1409
 
1410 1410
 		print __METHOD__." tmp=".json_encode($tmp)."\n";
1411 1411
 		$this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG","II":"JJ"}', json_encode($tmp));
@@ -1533,48 +1533,48 @@  discard block
 block discarded – undo
1533 1533
 
1534 1534
 		$conf->global->MAIN_START_WEEK = 0;
1535 1535
 
1536
-		$tmp=dol_getdate(24*60*60+1, false, 'UTC');		// 2/1/1970 and 1 second = friday
1536
+		$tmp = dol_getdate(24 * 60 * 60 + 1, false, 'UTC'); // 2/1/1970 and 1 second = friday
1537 1537
 		$this->assertEquals(5, $tmp['wday'], 'Bad value of day in week');
1538 1538
 
1539 1539
 		$conf->global->MAIN_START_WEEK = 1;
1540 1540
 
1541
-		$tmp=dol_getdate(1, false, 'UTC');				// 1/1/1970 and 1 second = thirday
1541
+		$tmp = dol_getdate(1, false, 'UTC'); // 1/1/1970 and 1 second = thirday
1542 1542
 		$this->assertEquals(4, $tmp['wday'], 'Bad value of day in week');
1543 1543
 
1544
-		$tmp=dol_getdate(24*60*60+1, false, 'UTC');		// 2/1/1970 and 1 second = friday
1544
+		$tmp = dol_getdate(24 * 60 * 60 + 1, false, 'UTC'); // 2/1/1970 and 1 second = friday
1545 1545
 		$this->assertEquals(5, $tmp['wday'], 'Bad value of day in week');
1546 1546
 
1547
-		$tmp=dol_getdate(1, false, "Europe/Paris");						// 1/1/1970 and 1 second = thirday
1547
+		$tmp = dol_getdate(1, false, "Europe/Paris"); // 1/1/1970 and 1 second = thirday
1548 1548
 		$this->assertEquals(1970, $tmp['year']);
1549 1549
 		$this->assertEquals(1, $tmp['mon']);
1550 1550
 		$this->assertEquals(1, $tmp['mday']);
1551 1551
 		$this->assertEquals(4, $tmp['wday']);
1552 1552
 		$this->assertEquals(0, $tmp['yday']);
1553
-		$this->assertEquals(1, $tmp['hours']);		// We are winter, so we are GMT+1 even during summer
1553
+		$this->assertEquals(1, $tmp['hours']); // We are winter, so we are GMT+1 even during summer
1554 1554
 		$this->assertEquals(0, $tmp['minutes']);
1555 1555
 		$this->assertEquals(1, $tmp['seconds']);
1556 1556
 
1557
-		$tmp=dol_getdate(15638401, false, "Europe/Paris");					// 1/7/1970 and 1 second = wednesday
1557
+		$tmp = dol_getdate(15638401, false, "Europe/Paris"); // 1/7/1970 and 1 second = wednesday
1558 1558
 		$this->assertEquals(1970, $tmp['year']);
1559 1559
 		$this->assertEquals(7, $tmp['mon']);
1560 1560
 		$this->assertEquals(1, $tmp['mday']);
1561 1561
 		$this->assertEquals(3, $tmp['wday']);
1562 1562
 		$this->assertEquals(181, $tmp['yday']);
1563
-		$this->assertEquals(1, $tmp['hours']);		// There is no daylight in 1970, so we are GMT+1 even during summer
1563
+		$this->assertEquals(1, $tmp['hours']); // There is no daylight in 1970, so we are GMT+1 even during summer
1564 1564
 		$this->assertEquals(0, $tmp['minutes']);
1565 1565
 		$this->assertEquals(1, $tmp['seconds']);
1566 1566
 
1567
-		$tmp=dol_getdate(1593561601, false, "Europe/Paris");				// 1/7/2020 and 1 second = wednesday
1567
+		$tmp = dol_getdate(1593561601, false, "Europe/Paris"); // 1/7/2020 and 1 second = wednesday
1568 1568
 		$this->assertEquals(2020, $tmp['year']);
1569 1569
 		$this->assertEquals(7, $tmp['mon']);
1570 1570
 		$this->assertEquals(1, $tmp['mday']);
1571 1571
 		$this->assertEquals(3, $tmp['wday']);
1572
-		$this->assertEquals(182, $tmp['yday']);		// 182 and not 181, due to the 29th february
1573
-		$this->assertEquals(2, $tmp['hours']);		// There is a daylight, so we are GMT+2
1572
+		$this->assertEquals(182, $tmp['yday']); // 182 and not 181, due to the 29th february
1573
+		$this->assertEquals(2, $tmp['hours']); // There is a daylight, so we are GMT+2
1574 1574
 		$this->assertEquals(0, $tmp['minutes']);
1575 1575
 		$this->assertEquals(1, $tmp['seconds']);
1576 1576
 
1577
-		$tmp=dol_getdate(1, false, 'UTC');						// 1/1/1970 and 1 second = thirday
1577
+		$tmp = dol_getdate(1, false, 'UTC'); // 1/1/1970 and 1 second = thirday
1578 1578
 		$this->assertEquals(1970, $tmp['year']);
1579 1579
 		$this->assertEquals(1, $tmp['mon']);
1580 1580
 		$this->assertEquals(1, $tmp['mday']);
@@ -1585,7 +1585,7 @@  discard block
 block discarded – undo
1585 1585
 		$this->assertEquals(0, $tmp['minutes']);
1586 1586
 		$this->assertEquals(1, $tmp['seconds']);
1587 1587
 
1588
-		$tmp=dol_getdate(15638401, false, 'UTC');				// 1/7/1970 and 1 second = wednesday
1588
+		$tmp = dol_getdate(15638401, false, 'UTC'); // 1/7/1970 and 1 second = wednesday
1589 1589
 		$this->assertEquals(1970, $tmp['year']);
1590 1590
 		$this->assertEquals(7, $tmp['mon']);
1591 1591
 		$this->assertEquals(1, $tmp['mday']);
@@ -1596,12 +1596,12 @@  discard block
 block discarded – undo
1596 1596
 		$this->assertEquals(0, $tmp['minutes']);
1597 1597
 		$this->assertEquals(1, $tmp['seconds']);
1598 1598
 
1599
-		$tmp=dol_getdate(1593561601, false, 'UTC');				// 1/7/2020 and 1 second = wednesday
1599
+		$tmp = dol_getdate(1593561601, false, 'UTC'); // 1/7/2020 and 1 second = wednesday
1600 1600
 		$this->assertEquals(2020, $tmp['year']);
1601 1601
 		$this->assertEquals(7, $tmp['mon']);
1602 1602
 		$this->assertEquals(1, $tmp['mday']);
1603 1603
 		$this->assertEquals(3, $tmp['wday']);
1604
-		$this->assertEquals(182, $tmp['yday']);		// 182 and not 181, due to the 29th february
1604
+		$this->assertEquals(182, $tmp['yday']); // 182 and not 181, due to the 29th february
1605 1605
 		// We must disable this because on CI, timezone is may be UTC or something else
1606 1606
 		//$this->assertEquals(2, $tmp['hours']);	// There is a daylight, so we are GMT+2
1607 1607
 		$this->assertEquals(0, $tmp['minutes']);
@@ -1658,11 +1658,11 @@  discard block
 block discarded – undo
1658 1658
 	{
1659 1659
 		global $conf, $langs;
1660 1660
 
1661
-		$chaine='This is an ISO string';
1661
+		$chaine = 'This is an ISO string';
1662 1662
 		$result = dol_string_is_good_iso($chaine);
1663 1663
 		$this->assertEquals($result, 1);
1664 1664
 
1665
-		$chaine='This is a not ISO string '.chr(0);
1665
+		$chaine = 'This is a not ISO string '.chr(0);
1666 1666
 		$result = dol_string_is_good_iso($chaine);
1667 1667
 		$this->assertEquals($result, 0);
1668 1668
 
@@ -1679,18 +1679,18 @@  discard block
 block discarded – undo
1679 1679
 	{
1680 1680
 		global $conf, $langs;
1681 1681
 
1682
-		$_SERVER['HTTP_X_FORWARDED_FOR']='1.2.3.4';
1683
-		$_SERVER['HTTP_CLIENT_IP']='5.6.7.8';
1682
+		$_SERVER['HTTP_X_FORWARDED_FOR'] = '1.2.3.4';
1683
+		$_SERVER['HTTP_CLIENT_IP'] = '5.6.7.8';
1684 1684
 		$result = getUserRemoteIP();
1685 1685
 		$this->assertEquals($result, '1.2.3.4');
1686 1686
 
1687
-		$_SERVER['HTTP_X_FORWARDED_FOR']='1.2.3.4<corrupted>';
1688
-		$_SERVER['HTTP_CLIENT_IP']='5.6.7.8';
1687
+		$_SERVER['HTTP_X_FORWARDED_FOR'] = '1.2.3.4<corrupted>';
1688
+		$_SERVER['HTTP_CLIENT_IP'] = '5.6.7.8';
1689 1689
 		$result = getUserRemoteIP();
1690 1690
 		$this->assertEquals($result, '5.6.7.8');
1691 1691
 
1692
-		$_SERVER['HTTP_X_FORWARDED_FOR']='[1:2:3:4]';
1693
-		$_SERVER['HTTP_CLIENT_IP']='5.6.7.8';
1692
+		$_SERVER['HTTP_X_FORWARDED_FOR'] = '[1:2:3:4]';
1693
+		$_SERVER['HTTP_CLIENT_IP'] = '5.6.7.8';
1694 1694
 		$result = getUserRemoteIP();
1695 1695
 		$this->assertEquals($result, '[1:2:3:4]');
1696 1696
 
Please login to merge, or discard this patch.
test/phpunit/BankAccountTest.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *      \remarks    To run this script as CLI:  phpunit filename.php
25 25
  */
26 26
 
27
-global $conf,$user,$langs,$db;
27
+global $conf, $user, $langs, $db;
28 28
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
29 29
 //require_once 'PHPUnit/Autoload.php';
30 30
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	$user->fetch(1);
37 37
 	$user->getrights();
38 38
 }
39
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
39
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
40 40
 
41 41
 $langs->load("main");
42 42
 
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
 		parent::__construct($name);
68 68
 
69 69
 		//$this->sharedFixture
70
-		global $conf,$user,$langs,$db;
71
-		$this->savconf=$conf;
72
-		$this->savuser=$user;
73
-		$this->savlangs=$langs;
74
-		$this->savdb=$db;
70
+		global $conf, $user, $langs, $db;
71
+		$this->savconf = $conf;
72
+		$this->savuser = $user;
73
+		$this->savlangs = $langs;
74
+		$this->savdb = $db;
75 75
 
76 76
 		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
77 77
 		//print " - db ".$db->db;
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public static function setUpBeforeClass(): void
87 87
 	{
88
-		global $conf,$user,$langs,$db;
88
+		global $conf, $user, $langs, $db;
89 89
 		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
90 90
 
91 91
 		print __METHOD__."\n";
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	public static function tearDownAfterClass(): void
100 100
 	{
101
-		global $conf,$user,$langs,$db;
101
+		global $conf, $user, $langs, $db;
102 102
 		$db->rollback();
103 103
 
104 104
 		print __METHOD__."\n";
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	protected function setUp(): void
113 113
 	{
114
-		global $conf,$user,$langs,$db;
115
-		$conf=$this->savconf;
116
-		$user=$this->savuser;
117
-		$langs=$this->savlangs;
118
-		$db=$this->savdb;
114
+		global $conf, $user, $langs, $db;
115
+		$conf = $this->savconf;
116
+		$user = $this->savuser;
117
+		$langs = $this->savlangs;
118
+		$db = $this->savdb;
119 119
 
120 120
 		print __METHOD__."\n";
121 121
 	}
@@ -137,16 +137,16 @@  discard block
 block discarded – undo
137 137
 	 */
138 138
 	public function testBankAccountCreate()
139 139
 	{
140
-		global $conf,$user,$langs,$db;
141
-		$conf=$this->savconf;
142
-		$user=$this->savuser;
143
-		$langs=$this->savlangs;
144
-		$db=$this->savdb;
140
+		global $conf, $user, $langs, $db;
141
+		$conf = $this->savconf;
142
+		$user = $this->savuser;
143
+		$langs = $this->savlangs;
144
+		$db = $this->savdb;
145 145
 
146 146
 		$localobject = new Account($db);
147 147
 		$localobject->initAsSpecimen();
148 148
 		$localobject->date_solde = dol_now();
149
-		$result=$localobject->create($user);
149
+		$result = $localobject->create($user);
150 150
 
151 151
 		print __METHOD__." result=".$result."\n";
152 152
 		$this->assertLessThan($result, 0);
@@ -165,14 +165,14 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	public function testBankAccountFetch($id)
167 167
 	{
168
-		global $conf,$user,$langs,$db;
169
-		$conf=$this->savconf;
170
-		$user=$this->savuser;
171
-		$langs=$this->savlangs;
172
-		$db=$this->savdb;
168
+		global $conf, $user, $langs, $db;
169
+		$conf = $this->savconf;
170
+		$user = $this->savuser;
171
+		$langs = $this->savlangs;
172
+		$db = $this->savdb;
173 173
 
174
-		$localobject=new Account($db);
175
-		$result=$localobject->fetch($id);
174
+		$localobject = new Account($db);
175
+		$result = $localobject->fetch($id);
176 176
 
177 177
 		print __METHOD__." id=".$id." result=".$result."\n";
178 178
 		$this->assertLessThan($result, 0);
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
 	 */
192 192
 	public function testBankAccountOther($localobject)
193 193
 	{
194
-		global $conf,$user,$langs,$db;
195
-		$conf=$this->savconf;
196
-		$user=$this->savuser;
197
-		$langs=$this->savlangs;
198
-		$db=$this->savdb;
194
+		global $conf, $user, $langs, $db;
195
+		$conf = $this->savconf;
196
+		$user = $this->savuser;
197
+		$langs = $this->savlangs;
198
+		$db = $this->savdb;
199 199
 
200 200
 		/*$result=$localobject->setstatus(0);
201 201
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		$this->assertTrue($result);
215 215
 
216 216
 		// Test checkIbanForAccount for CI account
217
-		$localobject2=new Account($db);
217
+		$localobject2 = new Account($db);
218 218
 		$localobject2->country = 'CI';
219 219
 		$localobject2->iban = 'CI77A12312341234123412341234';
220 220
 		$result = checkIbanForAccount($localobject2);
@@ -235,15 +235,15 @@  discard block
 block discarded – undo
235 235
 	 */
236 236
 	public function testBankAccountDelete($id)
237 237
 	{
238
-		global $conf,$user,$langs,$db;
239
-		$conf=$this->savconf;
240
-		$user=$this->savuser;
241
-		$langs=$this->savlangs;
242
-		$db=$this->savdb;
243
-
244
-		$localobject=new Account($db);
245
-		$result=$localobject->fetch($id);
246
-		$result=$localobject->delete($user);
238
+		global $conf, $user, $langs, $db;
239
+		$conf = $this->savconf;
240
+		$user = $this->savuser;
241
+		$langs = $this->savlangs;
242
+		$db = $this->savdb;
243
+
244
+		$localobject = new Account($db);
245
+		$result = $localobject->fetch($id);
246
+		$result = $localobject->delete($user);
247 247
 
248 248
 		print __METHOD__." id=".$id." result=".$result."\n";
249 249
 		$this->assertLessThan($result, 0);
Please login to merge, or discard this patch.
test/phpunit/SecurityTest.php 1 patch
Spacing   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -24,32 +24,32 @@  discard block
 block discarded – undo
24 24
  *		\remarks	To run this script as CLI:  phpunit filename.php
25 25
  */
26 26
 
27
-global $conf,$user,$langs,$db;
27
+global $conf, $user, $langs, $db;
28 28
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
29 29
 //require_once 'PHPUnit/Autoload.php';
30 30
 
31
-if (! defined('NOREQUIRESOC')) {
31
+if (!defined('NOREQUIRESOC')) {
32 32
 	define('NOREQUIRESOC', '1');
33 33
 }
34
-if (! defined('NOCSRFCHECK')) {
34
+if (!defined('NOCSRFCHECK')) {
35 35
 	define('NOCSRFCHECK', '1');
36 36
 }
37
-if (! defined('NOTOKENRENEWAL')) {
37
+if (!defined('NOTOKENRENEWAL')) {
38 38
 	define('NOTOKENRENEWAL', '1');
39 39
 }
40
-if (! defined('NOREQUIREMENU')) {
40
+if (!defined('NOREQUIREMENU')) {
41 41
 	define('NOREQUIREMENU', '1'); // If there is no menu to show
42 42
 }
43
-if (! defined('NOREQUIREHTML')) {
43
+if (!defined('NOREQUIREHTML')) {
44 44
 	define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
45 45
 }
46
-if (! defined('NOREQUIREAJAX')) {
46
+if (!defined('NOREQUIREAJAX')) {
47 47
 	define('NOREQUIREAJAX', '1');
48 48
 }
49
-if (! defined("NOLOGIN")) {
50
-	define("NOLOGIN", '1');       // If this page is public (can be called outside logged session)
49
+if (!defined("NOLOGIN")) {
50
+	define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
51 51
 }
52
-if (! defined("NOSESSION")) {
52
+if (!defined("NOSESSION")) {
53 53
 	define("NOSESSION", '1');
54 54
 }
55 55
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	$user->fetch(1);
64 64
 	$user->getrights();
65 65
 }
66
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
66
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
67 67
 
68 68
 
69 69
 /**
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 		parent::__construct($name);
93 93
 
94 94
 		//$this->sharedFixture
95
-		global $conf,$user,$langs,$db;
96
-		$this->savconf=$conf;
97
-		$this->savuser=$user;
98
-		$this->savlangs=$langs;
99
-		$this->savdb=$db;
95
+		global $conf, $user, $langs, $db;
96
+		$this->savconf = $conf;
97
+		$this->savuser = $user;
98
+		$this->savlangs = $langs;
99
+		$this->savdb = $db;
100 100
 
101 101
 		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
102 102
 		//print " - db ".$db->db;
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	public static function setUpBeforeClass(): void
112 112
 	{
113
-		global $conf,$user,$langs,$db;
114
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
113
+		global $conf, $user, $langs, $db;
114
+		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
115 115
 
116 116
 		print __METHOD__."\n";
117 117
 	}
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 */
124 124
 	public static function tearDownAfterClass(): void
125 125
 	{
126
-		global $conf,$user,$langs,$db;
126
+		global $conf, $user, $langs, $db;
127 127
 		$db->rollback();
128 128
 
129 129
 		// Restore value to a neutral value (it was set to a test value by some tests)
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	protected function setUp(): void
141 141
 	{
142
-		global $conf,$user,$langs,$db;
143
-		$conf=$this->savconf;
144
-		$user=$this->savuser;
145
-		$langs=$this->savlangs;
146
-		$db=$this->savdb;
142
+		global $conf, $user, $langs, $db;
143
+		$conf = $this->savconf;
144
+		$user = $this->savuser;
145
+		$langs = $this->savlangs;
146
+		$db = $this->savdb;
147 147
 
148 148
 		print __METHOD__."\n";
149 149
 	}
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	public function testSetLang()
167 167
 	{
168 168
 		global $conf;
169
-		$conf=$this->savconf;
169
+		$conf = $this->savconf;
170 170
 
171 171
 		$tmplangs = new Translate('', $conf);
172 172
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 		// More on https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
188 188
 
189 189
 		// Should be OK
190
-		$expectedresult=0;
190
+		$expectedresult = 0;
191 191
 
192 192
 		/*
193 193
 		$test = '';
@@ -195,107 +195,107 @@  discard block
 block discarded – undo
195 195
 		$this->assertGreaterThanOrEqual(0, $result, 'Error on testSqlAndScriptInject kkk');
196 196
 		*/
197 197
 
198
-		$_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php';
199
-		$result=testSqlAndScriptInject($_SERVER["PHP_SELF"], 2);
198
+		$_SERVER["PHP_SELF"] = '/DIR WITH SPACE/htdocs/admin/index.php';
199
+		$result = testSqlAndScriptInject($_SERVER["PHP_SELF"], 2);
200 200
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for PHP_SELF that should be ok');
201 201
 
202 202
 		$test = 'This is a < inside string with < and > also and tag like <a> before the >';
203
-		$result=testSqlAndScriptInject($test, 0);
203
+		$result = testSqlAndScriptInject($test, 0);
204 204
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject expected 0b');
205 205
 
206 206
 		$test = 'This is the union of all for the selection of the best';
207
-		$result=testSqlAndScriptInject($test, 0);
207
+		$result = testSqlAndScriptInject($test, 0);
208 208
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject expected 0c');
209 209
 
210
-		$test='/user/perms.php?id=1&action=addrights&entity=1&rights=123&confirm=yes&token=123456789&updatedmodulename=lmscoursetracking';
211
-		$result=testSqlAndScriptInject($test, 1);
210
+		$test = '/user/perms.php?id=1&action=addrights&entity=1&rights=123&confirm=yes&token=123456789&updatedmodulename=lmscoursetracking';
211
+		$result = testSqlAndScriptInject($test, 1);
212 212
 		print "test=".$test." result=".$result."\n";
213 213
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject with a valid url');
214 214
 
215 215
 		// Should detect attack
216
-		$expectedresult=1;
216
+		$expectedresult = 1;
217 217
 
218
-		$_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php/<svg>';
219
-		$result=testSqlAndScriptInject($_SERVER["PHP_SELF"], 2);
218
+		$_SERVER["PHP_SELF"] = '/DIR WITH SPACE/htdocs/admin/index.php/<svg>';
219
+		$result = testSqlAndScriptInject($_SERVER["PHP_SELF"], 2);
220 220
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject for PHP_SELF that should detect XSS');
221 221
 
222 222
 		$test = 'select @@version';
223
-		$result=testSqlAndScriptInject($test, 0);
223
+		$result = testSqlAndScriptInject($test, 0);
224 224
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL1a. Should find an attack on POST param and did not.');
225 225
 
226 226
 		$test = 'select @@version';
227
-		$result=testSqlAndScriptInject($test, 1);
227
+		$result = testSqlAndScriptInject($test, 1);
228 228
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL1b. Should find an attack on GET param and did not.');
229 229
 
230 230
 		$test = '... update ... set ... =';
231
-		$result=testSqlAndScriptInject($test, 1);
231
+		$result = testSqlAndScriptInject($test, 1);
232 232
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL2a. Should find an attack on GET param and did not.');
233 233
 
234 234
 		$test = "delete\nfrom";
235
-		$result=testSqlAndScriptInject($test, 1);
235
+		$result = testSqlAndScriptInject($test, 1);
236 236
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL2b. Should find an attack on GET param and did not.');
237 237
 
238 238
 		$test = 'action=update& ... set ... =';
239
-		$result=testSqlAndScriptInject($test, 1);
239
+		$result = testSqlAndScriptInject($test, 1);
240 240
 		$this->assertEquals(0, $result, 'Error on testSqlAndScriptInject for SQL2b. Should not find an attack on GET param and did.');
241 241
 
242 242
 		$test = '... union ... selection ';
243
-		$result=testSqlAndScriptInject($test, 1);
243
+		$result = testSqlAndScriptInject($test, 1);
244 244
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL2c. Should find an attack on GET param and did not.');
245 245
 
246 246
 		$test = 'j&#x61;vascript:';
247
-		$result=testSqlAndScriptInject($test, 0);
247
+		$result = testSqlAndScriptInject($test, 0);
248 248
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for javascript1. Should find an attack and did not.');
249 249
 
250 250
 		$test = 'j&#x61vascript:';
251
-		$result=testSqlAndScriptInject($test, 0);
251
+		$result = testSqlAndScriptInject($test, 0);
252 252
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for javascript2. Should find an attack and did not.');
253 253
 
254 254
 		$test = 'javascript&colon&#x3B;alert(1)';
255
-		$result=testSqlAndScriptInject($test, 0);
255
+		$result = testSqlAndScriptInject($test, 0);
256 256
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for javascript2');
257 257
 
258
-		$test="<img src='1.jpg' onerror =javascript:alert('XSS')>";
259
-		$result=testSqlAndScriptInject($test, 0);
258
+		$test = "<img src='1.jpg' onerror =javascript:alert('XSS')>";
259
+		$result = testSqlAndScriptInject($test, 0);
260 260
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa1');
261 261
 
262
-		$test="<img src='1.jpg' onerror =javascript:alert('XSS')>";
263
-		$result=testSqlAndScriptInject($test, 2);
262
+		$test = "<img src='1.jpg' onerror =javascript:alert('XSS')>";
263
+		$result = testSqlAndScriptInject($test, 2);
264 264
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa2');
265 265
 
266
-		$test='<IMG SRC=# onmouseover="alert(1)">';
267
-		$result=testSqlAndScriptInject($test, 0);
266
+		$test = '<IMG SRC=# onmouseover="alert(1)">';
267
+		$result = testSqlAndScriptInject($test, 0);
268 268
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa3');
269
-		$test='<IMG SRC onmouseover="alert(1)">';
270
-		$result=testSqlAndScriptInject($test, 0);
269
+		$test = '<IMG SRC onmouseover="alert(1)">';
270
+		$result = testSqlAndScriptInject($test, 0);
271 271
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa4');
272
-		$test='<IMG onmouseover="alert(1)">';
273
-		$result=testSqlAndScriptInject($test, 0);
272
+		$test = '<IMG onmouseover="alert(1)">';
273
+		$result = testSqlAndScriptInject($test, 0);
274 274
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa5');
275
-		$test='<IMG SRC=/ onerror="alert(1)">';
276
-		$result=testSqlAndScriptInject($test, 0);
275
+		$test = '<IMG SRC=/ onerror="alert(1)">';
276
+		$result = testSqlAndScriptInject($test, 0);
277 277
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa6');
278
-		$test='<IMG SRC=" &#14;  javascript:alert(1);">';
279
-		$result=testSqlAndScriptInject($test, 0);
278
+		$test = '<IMG SRC=" &#14;  javascript:alert(1);">';
279
+		$result = testSqlAndScriptInject($test, 0);
280 280
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa7');
281 281
 
282
-		$test='<IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;>';
283
-		$result=testSqlAndScriptInject($test, 0);
282
+		$test = '<IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;>';
283
+		$result = testSqlAndScriptInject($test, 0);
284 284
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject bbb');
285 285
 
286
-		$test='<SCRIPT SRC=http://xss.rocks/xss.js></SCRIPT>';
287
-		$result=testSqlAndScriptInject($test, 0);
286
+		$test = '<SCRIPT SRC=http://xss.rocks/xss.js></SCRIPT>';
287
+		$result = testSqlAndScriptInject($test, 0);
288 288
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ccc');
289 289
 
290
-		$test='<IMG SRC="javascript:alert(\'XSS\');">';
291
-		$result=testSqlAndScriptInject($test, 1);
290
+		$test = '<IMG SRC="javascript:alert(\'XSS\');">';
291
+		$result = testSqlAndScriptInject($test, 1);
292 292
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ddd');
293 293
 
294
-		$test='<IMG """><SCRIPT>alert("XSS")</SCRIPT>">';
295
-		$result=testSqlAndScriptInject($test, 0);
294
+		$test = '<IMG """><SCRIPT>alert("XSS")</SCRIPT>">';
295
+		$result = testSqlAndScriptInject($test, 0);
296 296
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject eee');
297 297
 
298
-		$test='<!-- Google analytics -->
298
+		$test = '<!-- Google analytics -->
299 299
 			<script>
300 300
 			  (function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){
301 301
 			  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
@@ -306,60 +306,60 @@  discard block
 block discarded – undo
306 306
 			  ga(\'send\', \'pageview\');
307 307
 
308 308
 			</script>';
309
-		$result=testSqlAndScriptInject($test, 0);
309
+		$result = testSqlAndScriptInject($test, 0);
310 310
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject eee');
311 311
 
312
-		$test="<IMG SRC=\"jav\tascript:alert('XSS');\">";		// Is locked by some browser like chrome because the default directive no-referrer-when-downgrade is sent when requesting the SRC and then refused because of browser protection on img src load without referrer.
313
-		$test="<IMG SRC=\"jav&#x0D;ascript:alert('XSS');\">";	// Same
312
+		$test = "<IMG SRC=\"jav\tascript:alert('XSS');\">"; // Is locked by some browser like chrome because the default directive no-referrer-when-downgrade is sent when requesting the SRC and then refused because of browser protection on img src load without referrer.
313
+		$test = "<IMG SRC=\"jav&#x0D;ascript:alert('XSS');\">"; // Same
314 314
 
315
-		$test='<SCRIPT/XSS SRC="http://xss.rocks/xss.js"></SCRIPT>';
316
-		$result=testSqlAndScriptInject($test, 0);
315
+		$test = '<SCRIPT/XSS SRC="http://xss.rocks/xss.js"></SCRIPT>';
316
+		$result = testSqlAndScriptInject($test, 0);
317 317
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject fff1');
318
-		$test='<SCRIPT/SRC="http://xss.rocks/xss.js"></SCRIPT>';
319
-		$result=testSqlAndScriptInject($test, 0);
318
+		$test = '<SCRIPT/SRC="http://xss.rocks/xss.js"></SCRIPT>';
319
+		$result = testSqlAndScriptInject($test, 0);
320 320
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject fff2');
321 321
 
322 322
 		// This case seems to be filtered by browsers now.
323
-		$test='<BODY onload!#$%&()*~+-_.,:;?@[/|\]^`=alert(1)>';
323
+		$test = '<BODY onload!#$%&()*~+-_.,:;?@[/|\]^`=alert(1)>';
324 324
 		//$result=testSqlAndScriptInject($test, 0);
325 325
 		//$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ggg');
326 326
 
327
-		$test='<iframe src=http://xss.rocks/scriptlet.html <';
328
-		$result=testSqlAndScriptInject($test, 0);
327
+		$test = '<iframe src=http://xss.rocks/scriptlet.html <';
328
+		$result = testSqlAndScriptInject($test, 0);
329 329
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject hhh');
330 330
 
331
-		$test='Set.constructor`alert\x281\x29```';
332
-		$result=testSqlAndScriptInject($test, 0);
331
+		$test = 'Set.constructor`alert\x281\x29```';
332
+		$result = testSqlAndScriptInject($test, 0);
333 333
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject iii');
334 334
 
335
-		$test="on<!-- ab\nc -->error=alert(1)";
336
-		$result=testSqlAndScriptInject($test, 0);
335
+		$test = "on<!-- ab\nc -->error=alert(1)";
336
+		$result = testSqlAndScriptInject($test, 0);
337 337
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject jjj');
338 338
 
339
-		$test="<img src=x one<a>rror=alert(document.location)";
340
-		$result=testSqlAndScriptInject($test, 0);
339
+		$test = "<img src=x one<a>rror=alert(document.location)";
340
+		$result = testSqlAndScriptInject($test, 0);
341 341
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject kkk');
342 342
 
343
-		$test="<a onpointerdown=alert(document.domain)>XSS</a>";
344
-		$result=testSqlAndScriptInject($test, 0);
343
+		$test = "<a onpointerdown=alert(document.domain)>XSS</a>";
344
+		$result = testSqlAndScriptInject($test, 0);
345 345
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject lll');
346 346
 
347
-		$test='<a onscrollend=alert(1) style="display:block;overflow:auto;border:1px+dashed;width:500px;height:100px;"><br><br><br><br><br><span+id=x>test</span></a>';	// Add the char %F6 into the variable
348
-		$result=testSqlAndScriptInject($test, 0);
347
+		$test = '<a onscrollend=alert(1) style="display:block;overflow:auto;border:1px+dashed;width:500px;height:100px;"><br><br><br><br><br><span+id=x>test</span></a>'; // Add the char %F6 into the variable
348
+		$result = testSqlAndScriptInject($test, 0);
349 349
 		//print "test=".$test." result=".$result."\n";
350 350
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject mmm');
351 351
 
352 352
 
353
-		$test="Text with ' encoded with the numeric html entity converted into text entity &#39; (like when submited by CKEditor)";
354
-		$result=testSqlAndScriptInject($test, 0);	// result must be 0
353
+		$test = "Text with ' encoded with the numeric html entity converted into text entity &#39; (like when submited by CKEditor)";
354
+		$result = testSqlAndScriptInject($test, 0); // result must be 0
355 355
 		$this->assertEquals(0, $result, 'Error on testSqlAndScriptInject mmm, result should be 0 and is not');
356 356
 
357
-		$test ='<a href="j&Tab;a&Tab;v&Tab;asc&NewLine;ri&Tab;pt:&lpar;a&Tab;l&Tab;e&Tab;r&Tab;t&Tab;(document.cookie)&rpar;">XSS</a>';
358
-		$result=testSqlAndScriptInject($test, 0);
357
+		$test = '<a href="j&Tab;a&Tab;v&Tab;asc&NewLine;ri&Tab;pt:&lpar;a&Tab;l&Tab;e&Tab;r&Tab;t&Tab;(document.cookie)&rpar;">XSS</a>';
358
+		$result = testSqlAndScriptInject($test, 0);
359 359
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject nnn, result should be >= 1 and is not');
360 360
 
361
-		$test="/dolibarr/htdocs/index.php/".chr('246')."abc";	// Add the char %F6 into the variable
362
-		$result=testSqlAndScriptInject($test, 2);
361
+		$test = "/dolibarr/htdocs/index.php/".chr('246')."abc"; // Add the char %F6 into the variable
362
+		$result = testSqlAndScriptInject($test, 2);
363 363
 		//print "test=".$test." result=".$result."\n";
364 364
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject with a non valid UTF8 char');
365 365
 	}
@@ -371,201 +371,201 @@  discard block
 block discarded – undo
371 371
 	 */
372 372
 	public function testGETPOST()
373 373
 	{
374
-		global $conf,$user,$langs,$db;
375
-		$conf=$this->savconf;
376
-		$user=$this->savuser;
377
-		$langs=$this->savlangs;
378
-		$db=$this->savdb;
374
+		global $conf, $user, $langs, $db;
375
+		$conf = $this->savconf;
376
+		$user = $this->savuser;
377
+		$langs = $this->savlangs;
378
+		$db = $this->savdb;
379 379
 
380 380
 		// Force default mode
381 381
 		$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0;
382 382
 		$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0;
383 383
 
384
-		$_COOKIE["id"]=111;
385
-		$_GET["param1"]="222";
386
-		$_POST["param1"]="333";
387
-		$_GET["param2"]='a/b#e(pr)qq-rr\cc';
388
-		$_GET["param3"]='"&#110;a/b#e(pr)qq-rr\cc';    // Same than param2 + " and &#110;
389
-		$_GET["param4a"]='..&#47;../dir';
390
-		$_GET["param4b"]='..&#92;..\dirwindows';
391
-		$_GET["param5"]="a_1-b";
392
-		$_POST["param6"]="&quot;&gt;<svg o&#110;load='console.log(&quot;123&quot;)'&gt;";
393
-		$_POST["param6b"]='<<<../>../>../svg><<<../>../>../animate =alert(1)>abc';
394
-		$_GET["param7"]='"c:\this is a path~1\aaa&#110; &#x&#x31;&#x31;&#x30;;" abc<bad>def</bad>';
395
-		$_POST["param8a"]="Hacker<svg o&#110;load='console.log(&quot;123&quot;)'";	// html tag is not closed so it is not detected as html tag but is still harmfull
396
-		$_POST['param8b']='<img src=x onerror=alert(document.location) t=';		// this is html obfuscated by non closing tag
397
-		$_POST['param8c']='< with space after is ok';
398
-		$_POST['param8d']='<abc123 is html to clean';
399
-		$_POST['param8e']='<123abc is not html to clean';	// other similar case: '<2021-12-12'
400
-		$_POST['param8f']='abc<<svg <><<animate onbegin=alert(document.domain) a';
401
-		$_POST["param9"]='is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'objnotdefined\'';
402
-		$_POST["param10"]='is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'<abc>objnotdefined\'';
403
-		$_POST["param11"]=' Name <[email protected]> ';
404
-		$_POST["param12"]='<!DOCTYPE html><html>aaa</html>';
405
-		$_POST["param13"]='&#110; &#x6E; &gt; &lt; &quot; <a href=\"j&#x61;vascript:alert(document.domain)\">XSS</a>';
406
-		$_POST["param13b"]='&#110; &#x6E; &gt; &lt; &quot; <a href=\"j&#x61vascript:alert(document.domain)\">XSS</a>';
407
-		$_POST["param14"]="Text with ' encoded with the numeric html entity converted into text entity &#39; (like when submited by CKEditor)";
408
-		$_POST["param15"]="<img onerror<=alert(document.domain)> src=>0xbeefed";
384
+		$_COOKIE["id"] = 111;
385
+		$_GET["param1"] = "222";
386
+		$_POST["param1"] = "333";
387
+		$_GET["param2"] = 'a/b#e(pr)qq-rr\cc';
388
+		$_GET["param3"] = '"&#110;a/b#e(pr)qq-rr\cc'; // Same than param2 + " and &#110;
389
+		$_GET["param4a"] = '..&#47;../dir';
390
+		$_GET["param4b"] = '..&#92;..\dirwindows';
391
+		$_GET["param5"] = "a_1-b";
392
+		$_POST["param6"] = "&quot;&gt;<svg o&#110;load='console.log(&quot;123&quot;)'&gt;";
393
+		$_POST["param6b"] = '<<<../>../>../svg><<<../>../>../animate =alert(1)>abc';
394
+		$_GET["param7"] = '"c:\this is a path~1\aaa&#110; &#x&#x31;&#x31;&#x30;;" abc<bad>def</bad>';
395
+		$_POST["param8a"] = "Hacker<svg o&#110;load='console.log(&quot;123&quot;)'"; // html tag is not closed so it is not detected as html tag but is still harmfull
396
+		$_POST['param8b'] = '<img src=x onerror=alert(document.location) t='; // this is html obfuscated by non closing tag
397
+		$_POST['param8c'] = '< with space after is ok';
398
+		$_POST['param8d'] = '<abc123 is html to clean';
399
+		$_POST['param8e'] = '<123abc is not html to clean'; // other similar case: '<2021-12-12'
400
+		$_POST['param8f'] = 'abc<<svg <><<animate onbegin=alert(document.domain) a';
401
+		$_POST["param9"] = 'is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'objnotdefined\'';
402
+		$_POST["param10"] = 'is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'<abc>objnotdefined\'';
403
+		$_POST["param11"] = ' Name <[email protected]> ';
404
+		$_POST["param12"] = '<!DOCTYPE html><html>aaa</html>';
405
+		$_POST["param13"] = '&#110; &#x6E; &gt; &lt; &quot; <a href=\"j&#x61;vascript:alert(document.domain)\">XSS</a>';
406
+		$_POST["param13b"] = '&#110; &#x6E; &gt; &lt; &quot; <a href=\"j&#x61vascript:alert(document.domain)\">XSS</a>';
407
+		$_POST["param14"] = "Text with ' encoded with the numeric html entity converted into text entity &#39; (like when submited by CKEditor)";
408
+		$_POST["param15"] = "<img onerror<=alert(document.domain)> src=>0xbeefed";
409 409
 		//$_POST["param15b"]="<html><head><title>Example HTML</title></head><body><div><p>This is a paragraph.</div><ul><li>Item 1</li><li>Item 2</li></ol></body><html>";
410
-		$_POST["param16"]='<a style="z-index: 1000">abc</a>';
411
-		$_POST["param17"]='<span style="background-image: url(logout.php)">abc</span>';
412
-		$_POST["param18"]='<span style="background-image: url(...?...action=aaa)">abc</span>';
413
-		$_POST["param19"]='<a href="j&Tab;a&Tab;v&Tab;asc&NewLine;ri&Tab;pt:&lpar;alert(document.cookie)&rpar;">XSS</a>';
410
+		$_POST["param16"] = '<a style="z-index: 1000">abc</a>';
411
+		$_POST["param17"] = '<span style="background-image: url(logout.php)">abc</span>';
412
+		$_POST["param18"] = '<span style="background-image: url(...?...action=aaa)">abc</span>';
413
+		$_POST["param19"] = '<a href="j&Tab;a&Tab;v&Tab;asc&NewLine;ri&Tab;pt:&lpar;alert(document.cookie)&rpar;">XSS</a>';
414 414
 		//$_POST["param19"]='<a href="javascript:alert(document.cookie)">XSS</a>';
415 415
 
416
-		$result=GETPOST('id', 'int');              // Must return nothing
416
+		$result = GETPOST('id', 'int'); // Must return nothing
417 417
 		print __METHOD__." result=".$result."\n";
418 418
 		$this->assertEquals($result, '');
419 419
 
420
-		$result=GETPOST("param1", 'int');
420
+		$result = GETPOST("param1", 'int');
421 421
 		print __METHOD__." result=".$result."\n";
422 422
 		$this->assertEquals($result, 222, 'Test on param1 with no 3rd param');
423 423
 
424
-		$result=GETPOST("param1", 'int', 2);
424
+		$result = GETPOST("param1", 'int', 2);
425 425
 		print __METHOD__." result=".$result."\n";
426 426
 		$this->assertEquals($result, 333, 'Test on param1 with 3rd param = 2');
427 427
 
428 428
 		// Test with alpha
429 429
 
430
-		$result=GETPOST("param2", 'alpha');
430
+		$result = GETPOST("param2", 'alpha');
431 431
 		print __METHOD__." result=".$result."\n";
432 432
 		$this->assertEquals($result, $_GET["param2"], 'Test on param2');
433 433
 
434
-		$result=GETPOST("param3", 'alpha');  // Must return string sanitized from char "
434
+		$result = GETPOST("param3", 'alpha'); // Must return string sanitized from char "
435 435
 		print __METHOD__." result=".$result."\n";
436 436
 		$this->assertEquals($result, 'na/b#e(pr)qq-rr\cc', 'Test on param3');
437 437
 
438
-		$result=GETPOST("param4a", 'alpha');  // Must return string sanitized from ../
438
+		$result = GETPOST("param4a", 'alpha'); // Must return string sanitized from ../
439 439
 		print __METHOD__." result=".$result."\n";
440 440
 		$this->assertEquals($result, 'dir');
441 441
 
442
-		$result=GETPOST("param4b", 'alpha');  // Must return string sanitized from ../
442
+		$result = GETPOST("param4b", 'alpha'); // Must return string sanitized from ../
443 443
 		print __METHOD__." result=".$result."\n";
444 444
 		$this->assertEquals($result, 'dirwindows');
445 445
 
446 446
 		// Test with aZ09
447 447
 
448
-		$result=GETPOST("param1", 'aZ09');
448
+		$result = GETPOST("param1", 'aZ09');
449 449
 		print __METHOD__." result=".$result."\n";
450 450
 		$this->assertEquals($result, $_GET["param1"]);
451 451
 
452
-		$result=GETPOST("param2", 'aZ09');  // Must return '' as string contains car not in aZ09 definition
452
+		$result = GETPOST("param2", 'aZ09'); // Must return '' as string contains car not in aZ09 definition
453 453
 		print __METHOD__." result=".$result."\n";
454 454
 		$this->assertEquals($result, '');
455 455
 
456
-		$result=GETPOST("param3", 'aZ09');  // Must return '' as string contains car not in aZ09 definition
456
+		$result = GETPOST("param3", 'aZ09'); // Must return '' as string contains car not in aZ09 definition
457 457
 		print __METHOD__." result=".$result."\n";
458 458
 		$this->assertEquals($result, '');
459 459
 
460
-		$result=GETPOST("param4a", 'aZ09');  // Must return '' as string contains car not in aZ09 definition
460
+		$result = GETPOST("param4a", 'aZ09'); // Must return '' as string contains car not in aZ09 definition
461 461
 		print __METHOD__." result=".$result."\n";
462 462
 		$this->assertEquals('', $result);
463 463
 
464
-		$result=GETPOST("param4b", 'aZ09');  // Must return '' as string contains car not in aZ09 definition
464
+		$result = GETPOST("param4b", 'aZ09'); // Must return '' as string contains car not in aZ09 definition
465 465
 		print __METHOD__." result=".$result."\n";
466 466
 		$this->assertEquals('', $result);
467 467
 
468
-		$result=GETPOST("param5", 'aZ09');
468
+		$result = GETPOST("param5", 'aZ09');
469 469
 		print __METHOD__." result=".$result."\n";
470 470
 		$this->assertEquals($_GET["param5"], $result);
471 471
 
472 472
 		// Test with nohtml
473 473
 
474
-		$result=GETPOST("param6", 'nohtml');
474
+		$result = GETPOST("param6", 'nohtml');
475 475
 		print __METHOD__." result=".$result."\n";
476 476
 		$this->assertEquals('">', $result);
477 477
 
478 478
 		// Test with alpha = alphanohtml. We must convert the html entities like &#110; and disable all entities
479 479
 
480
-		$result=GETPOST("param6", 'alphanohtml');
480
+		$result = GETPOST("param6", 'alphanohtml');
481 481
 		print __METHOD__." result=".$result."\n";
482 482
 		$this->assertEquals('>', $result);
483 483
 
484
-		$result=GETPOST("param6b", 'alphanohtml');
484
+		$result = GETPOST("param6b", 'alphanohtml');
485 485
 		print __METHOD__." result=".$result."\n";
486 486
 		$this->assertEquals('abc', $result);
487 487
 
488
-		$result=GETPOST("param8a", 'alphanohtml');
488
+		$result = GETPOST("param8a", 'alphanohtml');
489 489
 		print __METHOD__." result=".$result."\n";
490 490
 		$this->assertEquals("Hackersvg onload='console.log(123)'", $result);
491 491
 
492
-		$result=GETPOST("param8b", 'alphanohtml');
492
+		$result = GETPOST("param8b", 'alphanohtml');
493 493
 		print __METHOD__." result=".$result."\n";
494 494
 		$this->assertEquals('img src=x onerror=alert(document.location) t=', $result, 'Test a string with non closing html tag with alphanohtml');
495 495
 
496
-		$result=GETPOST("param8c", 'alphanohtml');
496
+		$result = GETPOST("param8c", 'alphanohtml');
497 497
 		print __METHOD__." result=".$result."\n";
498 498
 		$this->assertEquals($_POST['param8c'], $result, 'Test a string with non closing html tag with alphanohtml');
499 499
 
500
-		$result=GETPOST("param8d", 'alphanohtml');
500
+		$result = GETPOST("param8d", 'alphanohtml');
501 501
 		print __METHOD__." result=".$result."\n";
502 502
 		$this->assertEquals('abc123 is html to clean', $result, 'Test a string with non closing html tag with alphanohtml');
503 503
 
504
-		$result=GETPOST("param8e", 'alphanohtml');
504
+		$result = GETPOST("param8e", 'alphanohtml');
505 505
 		print __METHOD__." result=".$result."\n";
506 506
 		$this->assertEquals($_POST['param8e'], $result, 'Test a string with non closing html tag with alphanohtml');
507 507
 
508
-		$result=GETPOST("param8f", 'alphanohtml');
508
+		$result = GETPOST("param8f", 'alphanohtml');
509 509
 		print __METHOD__." result=".$result."\n";
510 510
 		$this->assertEquals('abcsvg animate onbegin=alert(document.domain) a', $result, 'Test a string with html tag open with several <');
511 511
 
512
-		$result=GETPOST("param9", 'alphanohtml');
512
+		$result = GETPOST("param9", 'alphanohtml');
513 513
 		print __METHOD__." result=".$result."\n";
514 514
 		$this->assertEquals($_POST["param9"], $result);
515 515
 
516
-		$result=GETPOST("param10", 'alphanohtml');
516
+		$result = GETPOST("param10", 'alphanohtml');
517 517
 		print __METHOD__." result=".$result."\n";
518 518
 		$this->assertEquals($_POST["param9"], $result, 'We should get param9 after processing param10');
519 519
 
520
-		$result=GETPOST("param11", 'alphanohtml');
520
+		$result = GETPOST("param11", 'alphanohtml');
521 521
 		print __METHOD__." result=".$result."\n";
522 522
 		$this->assertEquals("Name", $result, 'Test an email string with alphanohtml');
523 523
 
524
-		$result=GETPOST("param13", 'alphanohtml');
524
+		$result = GETPOST("param13", 'alphanohtml');
525 525
 		print __METHOD__." result=".$result."\n";
526 526
 		$this->assertEquals('n n > <  XSS', $result, 'Test that html entities are decoded with alpha');
527 527
 
528 528
 		// Test with alphawithlgt
529 529
 
530
-		$result=GETPOST("param11", 'alphawithlgt');
530
+		$result = GETPOST("param11", 'alphawithlgt');
531 531
 		print __METHOD__." result=".$result."\n";
532 532
 		$this->assertEquals(trim($_POST["param11"]), $result, 'Test an email string with alphawithlgt');
533 533
 
534 534
 		// Test with restricthtml: we must remove html open/close tag and content but not htmlentities (we can decode html entities for ascii chars like &#110;)
535 535
 
536
-		$result=GETPOST("param6", 'restricthtml');
536
+		$result = GETPOST("param6", 'restricthtml');
537 537
 		print __METHOD__." result param6=".$result."\n";
538 538
 		$this->assertEquals('&quot;&gt;', $result);
539 539
 
540
-		$result=GETPOST("param7", 'restricthtml');
540
+		$result = GETPOST("param7", 'restricthtml');
541 541
 		print __METHOD__." result param7 = ".$result."\n";
542 542
 		$this->assertEquals('"c:\this is a path~1\aaan &#x;;;;" abcdef', $result);
543 543
 
544
-		$result=GETPOST("param8e", 'restricthtml');
544
+		$result = GETPOST("param8e", 'restricthtml');
545 545
 		print __METHOD__." result param8e = ".$result."\n";
546 546
 		$this->assertEquals('', $result);
547 547
 
548
-		$result=GETPOST("param12", 'restricthtml');
548
+		$result = GETPOST("param12", 'restricthtml');
549 549
 		print __METHOD__." result=".$result."\n";
550 550
 		$this->assertEquals(trim($_POST["param12"]), $result, 'Test a string with DOCTYPE and restricthtml');
551 551
 
552
-		$result=GETPOST("param13", 'restricthtml');
552
+		$result = GETPOST("param13", 'restricthtml');
553 553
 		print __METHOD__." result=".$result."\n";
554 554
 		$this->assertEquals('n n &gt; &lt; &quot; <a href=\"alert(document.domain)\">XSS</a>', $result, 'Test 13 that HTML entities are decoded with restricthtml, but only for common alpha chars');
555 555
 
556
-		$result=GETPOST("param13b", 'restricthtml');
556
+		$result = GETPOST("param13b", 'restricthtml');
557 557
 		print __METHOD__." result=".$result."\n";
558 558
 		$this->assertEquals('n n &gt; &lt; &quot; <a href=\"alert(document.domain)\">XSS</a>', $result, 'Test 13b that HTML entities are decoded with restricthtml, but only for common alpha chars');
559 559
 
560
-		$result=GETPOST("param14", 'restricthtml');
560
+		$result = GETPOST("param14", 'restricthtml');
561 561
 		print __METHOD__." result=".$result."\n";
562 562
 		$this->assertEquals("Text with ' encoded with the numeric html entity converted into text entity &#39; (like when submited by CKEditor)", $result, 'Test 14');
563 563
 
564
-		$result=GETPOST("param15", 'restricthtml');		// param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
564
+		$result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
565 565
 		print __METHOD__." result=".$result."\n";
566
-		$this->assertEquals("<img onerror=alert(document.domain) src=>0xbeefed", $result, 'Test 15');	// The GETPOST return a harmull string
566
+		$this->assertEquals("<img onerror=alert(document.domain) src=>0xbeefed", $result, 'Test 15'); // The GETPOST return a harmull string
567 567
 
568
-		$result=GETPOST("param19", 'restricthtml');
568
+		$result = GETPOST("param19", 'restricthtml');
569 569
 		print __METHOD__." result=".$result."\n";
570 570
 		$this->assertEquals('<a href="&lpar;alert(document.cookie)&rpar;">XSS</a>', $result, 'Test 19');
571 571
 
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
 		$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1;
575 575
 
576 576
 
577
-		$result=GETPOST("param15", 'restricthtml');		// param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
577
+		$result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
578 578
 		print __METHOD__." result=".$result."\n";
579
-		$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b');					// With some PHP and libxml version, we got this result when parsing invalid HTML, but ...
579
+		$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b'); // With some PHP and libxml version, we got this result when parsing invalid HTML, but ...
580 580
 		//$this->assertEquals('<img onerror> src=&gt;0xbeefed', $result, 'Test 15b');	// ... on other PHP and libxml versions, we got a HTML that has been cleaned
581 581
 
582 582
 
@@ -585,19 +585,19 @@  discard block
 block discarded – undo
585 585
 		// Test with restricthtml + MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES to test disabling of bad atrributes
586 586
 		$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 1;
587 587
 
588
-		$result=GETPOST("param15", 'restricthtml');
588
+		$result = GETPOST("param15", 'restricthtml');
589 589
 		print __METHOD__." result=".$result."\n";
590 590
 		$this->assertEquals('<img src="">0xbeefed', $result, 'Test 15c');
591 591
 
592
-		$result=GETPOST('param16', 'restricthtml');
592
+		$result = GETPOST('param16', 'restricthtml');
593 593
 		print __METHOD__." result=".$result."\n";
594 594
 		$this->assertEquals('<a style=" 1000">abc</a>', $result, 'Test tag a with forbidden attribute z-index');
595 595
 
596
-		$result=GETPOST('param17', 'restricthtml');
596
+		$result = GETPOST('param17', 'restricthtml');
597 597
 		print __METHOD__." result=".$result."\n";
598 598
 		$this->assertEquals('<span style="background-image: url()">abc</span>', $result, 'Test anytag with a forbidden value for attribute');
599 599
 
600
-		$result=GETPOST('param18', 'restricthtml');
600
+		$result = GETPOST('param18', 'restricthtml');
601 601
 		print __METHOD__." result=".$result."\n";
602 602
 		$this->assertEquals('<span style="background-image: url(...?...aaa)">abc</span>', $result, 'Test anytag with a forbidden value for attribute');
603 603
 
@@ -606,40 +606,40 @@  discard block
 block discarded – undo
606 606
 
607 607
 		// Special test for GETPOST of backtopage, backtolist or backtourl parameter
608 608
 
609
-		$_POST["backtopage"]='//www.google.com';
610
-		$result=GETPOST("backtopage");
609
+		$_POST["backtopage"] = '//www.google.com';
610
+		$result = GETPOST("backtopage");
611 611
 		print __METHOD__." result=".$result."\n";
612 612
 		$this->assertEquals('www.google.com', $result, 'Test for backtopage param');
613 613
 
614
-		$_POST["backtopage"]='https:https://www.google.com';
615
-		$result=GETPOST("backtopage");
614
+		$_POST["backtopage"] = 'https:https://www.google.com';
615
+		$result = GETPOST("backtopage");
616 616
 		print __METHOD__." result=".$result."\n";
617 617
 		$this->assertEquals('www.google.com', $result, 'Test for backtopage param');
618 618
 
619
-		$_POST["backtolist"]='::HTTPS://www.google.com';
620
-		$result=GETPOST("backtolist");
619
+		$_POST["backtolist"] = '::HTTPS://www.google.com';
620
+		$result = GETPOST("backtolist");
621 621
 		print __METHOD__." result=".$result."\n";
622 622
 		$this->assertEquals('www.google.com', $result, 'Test for backtopage param');
623 623
 
624
-		$_POST["backtopage"]='http:www.google.com';
625
-		$result=GETPOST("backtopage");
624
+		$_POST["backtopage"] = 'http:www.google.com';
625
+		$result = GETPOST("backtopage");
626 626
 		print __METHOD__." result=".$result."\n";
627 627
 		$this->assertEquals('httpwww.google.com', $result, 'Test for backtopage param');
628 628
 
629
-		$_POST["backtopage"]='/mydir/mypage.php?aa=a%10a';
630
-		$result=GETPOST("backtopage");
629
+		$_POST["backtopage"] = '/mydir/mypage.php?aa=a%10a';
630
+		$result = GETPOST("backtopage");
631 631
 		print __METHOD__." result=".$result."\n";
632 632
 		$this->assertEquals('/mydir/mypage.php?aa=a%10a', $result, 'Test for backtopage param');
633 633
 
634
-		$_POST["backtopage"]='javascripT&javascript#javascriptxjavascript3a alert(1)';
635
-		$result=GETPOST("backtopage");
634
+		$_POST["backtopage"] = 'javascripT&javascript#javascriptxjavascript3a alert(1)';
635
+		$result = GETPOST("backtopage");
636 636
 		print __METHOD__." result=".$result."\n";
637 637
 		$this->assertEquals('x3aalert(1)', $result, 'Test for backtopage param');
638 638
 
639 639
 
640 640
 		$conf->global->MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT = 3;
641
-		$_POST["pagecontentwithlinks"]='<img src="aaa"><img src="bbb"><img src="ccc"><span style="background: url(/ddd)"></span>';
642
-		$result=GETPOST("pagecontentwithlinks", 'restricthtml');
641
+		$_POST["pagecontentwithlinks"] = '<img src="aaa"><img src="bbb"><img src="ccc"><span style="background: url(/ddd)"></span>';
642
+		$result = GETPOST("pagecontentwithlinks", 'restricthtml');
643 643
 		print __METHOD__." result=".$result."\n";
644 644
 		$this->assertEquals('TooManyLinksIntoHTMLString', $result, 'Test on limit on GETPOST fails');
645 645
 
@@ -653,15 +653,15 @@  discard block
 block discarded – undo
653 653
 	 */
654 654
 	public function testEncodeDecode()
655 655
 	{
656
-		$stringtotest="This is a string to test encode/decode. This is a string to test encode/decode. This is a string to test encode/decode.";
656
+		$stringtotest = "This is a string to test encode/decode. This is a string to test encode/decode. This is a string to test encode/decode.";
657 657
 
658
-		$encodedstring=dol_encode($stringtotest);
659
-		$decodedstring=dol_decode($encodedstring);
658
+		$encodedstring = dol_encode($stringtotest);
659
+		$decodedstring = dol_decode($encodedstring);
660 660
 		print __METHOD__." encodedstring=".$encodedstring." ".base64_encode($stringtotest)."\n";
661 661
 		$this->assertEquals($stringtotest, $decodedstring, 'Use dol_encode/decode with no parameter');
662 662
 
663
-		$encodedstring=dol_encode($stringtotest, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
664
-		$decodedstring=dol_decode($encodedstring, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
663
+		$encodedstring = dol_encode($stringtotest, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
664
+		$decodedstring = dol_decode($encodedstring, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
665 665
 		print __METHOD__." encodedstring=".$encodedstring." ".base64_encode($stringtotest)."\n";
666 666
 		$this->assertEquals($stringtotest, $decodedstring, 'Use dol_encode/decode with a key parameter');
667 667
 
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 		$this->assertEquals('a &colon; b " c \' d &apos; e é', $decodedstring, 'Function did not sanitize correclty');
681 681
 
682 682
 		$stringtotest = 'a &colon; b &quot; c &#039; d &apos; e &eacute;';
683
-		$decodedstring = dol_html_entity_decode($stringtotest, ENT_QUOTES|ENT_HTML5);
683
+		$decodedstring = dol_html_entity_decode($stringtotest, ENT_QUOTES | ENT_HTML5);
684 684
 		$this->assertEquals('a : b " c \' d \' e é', $decodedstring, 'Function did not sanitize correclty');
685 685
 
686 686
 		return 0;
@@ -744,21 +744,21 @@  discard block
 block discarded – undo
744 744
 	{
745 745
 		global $conf;
746 746
 
747
-		$genpass1=getRandomPassword(true);				// Should be a string return by dol_hash (if no option set, will be md5)
747
+		$genpass1 = getRandomPassword(true); // Should be a string return by dol_hash (if no option set, will be md5)
748 748
 		print __METHOD__." genpass1=".$genpass1."\n";
749 749
 		$this->assertEquals(strlen($genpass1), 32);
750 750
 
751
-		$genpass1=getRandomPassword(true, array('I'));	// Should be a string return by dol_hash (if no option set, will be md5)
751
+		$genpass1 = getRandomPassword(true, array('I')); // Should be a string return by dol_hash (if no option set, will be md5)
752 752
 		print __METHOD__." genpass1=".$genpass1."\n";
753 753
 		$this->assertEquals(strlen($genpass1), 32);
754 754
 
755
-		$conf->global->USER_PASSWORD_GENERATED='None';
756
-		$genpass2=getRandomPassword(false);				// Should return an empty string
755
+		$conf->global->USER_PASSWORD_GENERATED = 'None';
756
+		$genpass2 = getRandomPassword(false); // Should return an empty string
757 757
 		print __METHOD__." genpass2=".$genpass2."\n";
758 758
 		$this->assertEquals($genpass2, '');
759 759
 
760
-		$conf->global->USER_PASSWORD_GENERATED='Standard';
761
-		$genpass3=getRandomPassword(false);				// Should return a password of 12 chars
760
+		$conf->global->USER_PASSWORD_GENERATED = 'Standard';
761
+		$genpass3 = getRandomPassword(false); // Should return a password of 12 chars
762 762
 		print __METHOD__." genpass3=".$genpass3."\n";
763 763
 		$this->assertEquals(strlen($genpass3), 12);
764 764
 
@@ -772,16 +772,16 @@  discard block
 block discarded – undo
772 772
 	 */
773 773
 	public function testRestrictedArea()
774 774
 	{
775
-		global $conf,$user,$langs,$db;
776
-		$conf=$this->savconf;
777
-		$user=$this->savuser;
778
-		$langs=$this->savlangs;
779
-		$db=$this->savdb;
775
+		global $conf, $user, $langs, $db;
776
+		$conf = $this->savconf;
777
+		$user = $this->savuser;
778
+		$langs = $this->savlangs;
779
+		$db = $this->savdb;
780 780
 
781 781
 		//$dummyuser=new User($db);
782 782
 		//$result=restrictedArea($dummyuser,'societe');
783 783
 
784
-		$result=restrictedArea($user, 'societe');
784
+		$result = restrictedArea($user, 'societe');
785 785
 		$this->assertEquals(1, $result);
786 786
 	}
787 787
 
@@ -799,42 +799,42 @@  discard block
 block discarded – undo
799 799
 		$url = 'ftp://mydomain.com';
800 800
 		$tmp = getURLContent($url);
801 801
 		print __METHOD__." url=".$url."\n";
802
-		$this->assertGreaterThan(0, strpos($tmp['curl_error_msg'], 'not supported'));	// Test error if return does not contains 'not supported'
802
+		$this->assertGreaterThan(0, strpos($tmp['curl_error_msg'], 'not supported')); // Test error if return does not contains 'not supported'
803 803
 
804
-		$url = 'https://www.dolibarr.fr';	// This is a redirect 301 page
805
-		$tmp = getURLContent($url, 'GET', '', 0);	// We do NOT follow
804
+		$url = 'https://www.dolibarr.fr'; // This is a redirect 301 page
805
+		$tmp = getURLContent($url, 'GET', '', 0); // We do NOT follow
806 806
 		print __METHOD__." url=".$url."\n";
807 807
 		$this->assertEquals(301, $tmp['http_code'], 'Should GET url 301 response and stop here');
808 808
 
809
-		$url = 'https://www.dolibarr.fr';	// This is a redirect 301 page
810
-		$tmp = getURLContent($url);		// We DO follow a page with return 300 so result should be 200
809
+		$url = 'https://www.dolibarr.fr'; // This is a redirect 301 page
810
+		$tmp = getURLContent($url); // We DO follow a page with return 300 so result should be 200
811 811
 		print __METHOD__." url=".$url."\n";
812 812
 		$this->assertEquals(200, $tmp['http_code'], 'Should GET url 301 with a follow -> 200 but we get '.$tmp['http_code']);
813 813
 
814 814
 		$url = 'http://localhost';
815
-		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL
815
+		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL
816 816
 		print __METHOD__." url=".$url."\n";
817
-		$this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that resolves to a local URL');	// Test we receive an error because localtest.me is not an external URL
817
+		$this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL
818 818
 
819 819
 		$url = 'http://127.0.0.1';
820
-		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL
820
+		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL
821 821
 		print __METHOD__." url=".$url."\n";
822
-		$this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL');	// Test we receive an error because 127.0.0.1 is not an external URL
822
+		$this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.0.1 is not an external URL
823 823
 
824 824
 		$url = 'http://127.0.2.1';
825
-		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL
825
+		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL
826 826
 		print __METHOD__." url=".$url."\n";
827
-		$this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL');	// Test we receive an error because 127.0.2.1 is not an external URL
827
+		$this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.2.1 is not an external URL
828 828
 
829 829
 		$url = 'https://169.254.0.1';
830
-		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL
830
+		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL
831 831
 		print __METHOD__." url=".$url."\n";
832
-		$this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL');	// Test we receive an error because 169.254.0.1 is not an external URL
832
+		$this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 169.254.0.1 is not an external URL
833 833
 
834 834
 		$url = 'http://[::1]';
835
-		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL
835
+		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL
836 836
 		print __METHOD__." url=".$url."\n";
837
-		$this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL');	// Test we receive an error because [::1] is not an external URL
837
+		$this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because [::1] is not an external URL
838 838
 
839 839
 		/*$url = 'localtest.me';
840 840
 		 $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL
@@ -843,9 +843,9 @@  discard block
 block discarded – undo
843 843
 		 */
844 844
 
845 845
 		$url = 'http://192.0.0.192';
846
-		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL but on an IP in blacklist
846
+		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL but on an IP in blacklist
847 847
 		print __METHOD__." url=".$url." tmp['http_code'] = ".$tmp['http_code']."\n";
848
-		$this->assertEquals(400, $tmp['http_code'], 'Access should be refused and was not');	// Test we receive an error because ip is in blacklist
848
+		$this->assertEquals(400, $tmp['http_code'], 'Access should be refused and was not'); // Test we receive an error because ip is in blacklist
849 849
 
850 850
 		return 0;
851 851
 	}
@@ -857,22 +857,22 @@  discard block
 block discarded – undo
857 857
 	 */
858 858
 	public function testDolSanitizeUrl()
859 859
 	{
860
-		global $conf,$user,$langs,$db;
861
-		$conf=$this->savconf;
862
-		$user=$this->savuser;
863
-		$langs=$this->savlangs;
864
-		$db=$this->savdb;
860
+		global $conf, $user, $langs, $db;
861
+		$conf = $this->savconf;
862
+		$user = $this->savuser;
863
+		$langs = $this->savlangs;
864
+		$db = $this->savdb;
865 865
 
866 866
 		$test = 'javascripT&javascript#x3a alert(1)';
867
-		$result=dol_sanitizeUrl($test);
867
+		$result = dol_sanitizeUrl($test);
868 868
 		$this->assertEquals('x3a alert(1)', $result, 'Test on dol_sanitizeUrl A');
869 869
 
870 870
 		$test = 'javajavascriptscript&cjavascriptolon;alert(1)';
871
-		$result=dol_sanitizeUrl($test);
871
+		$result = dol_sanitizeUrl($test);
872 872
 		$this->assertEquals('alert(1)', $result, 'Test on dol_sanitizeUrl B');
873 873
 
874 874
 		$test = '/javas:cript/google.com';
875
-		$result=dol_sanitizeUrl($test);
875
+		$result = dol_sanitizeUrl($test);
876 876
 		$this->assertEquals('google.com', $result, 'Test on dol_sanitizeUrl C');
877 877
 	}
878 878
 
@@ -883,26 +883,26 @@  discard block
 block discarded – undo
883 883
 	 */
884 884
 	public function testDolSanitizeEmail()
885 885
 	{
886
-		global $conf,$user,$langs,$db;
887
-		$conf=$this->savconf;
888
-		$user=$this->savuser;
889
-		$langs=$this->savlangs;
890
-		$db=$this->savdb;
886
+		global $conf, $user, $langs, $db;
887
+		$conf = $this->savconf;
888
+		$user = $this->savuser;
889
+		$langs = $this->savlangs;
890
+		$db = $this->savdb;
891 891
 
892 892
 		$test = '[email protected] <My name>, [email protected] <Another name>';
893
-		$result=dol_sanitizeEmail($test);
893
+		$result = dol_sanitizeEmail($test);
894 894
 		$this->assertEquals($test, $result, 'Test on dol_sanitizeEmail A');
895 895
 
896 896
 		$test = "[email protected] <My name>,\[email protected] <Another name>";
897
-		$result=dol_sanitizeEmail($test);
897
+		$result = dol_sanitizeEmail($test);
898 898
 		$this->assertEquals('[email protected] <My name>,[email protected] <Another name>', $result, 'Test on dol_sanitizeEmail B');
899 899
 
900 900
 		$test = '[email protected] <My name>,\[email protected] <Another name>';
901
-		$result=dol_sanitizeEmail($test);
901
+		$result = dol_sanitizeEmail($test);
902 902
 		$this->assertEquals('[email protected] <My name>,[email protected] <Another name>', $result, 'Test on dol_sanitizeEmail C');
903 903
 
904 904
 		$test = '[email protected] <My name>, "bcc:bbb"@mycompany.com <Another name>';
905
-		$result=dol_sanitizeEmail($test);
905
+		$result = dol_sanitizeEmail($test);
906 906
 		$this->assertEquals('[email protected] <My name>, [email protected] <Another name>', $result, 'Test on dol_sanitizeEmail D');
907 907
 	}
908 908
 
@@ -913,19 +913,19 @@  discard block
 block discarded – undo
913 913
 	 */
914 914
 	public function testDolSanitizeFileName()
915 915
 	{
916
-		global $conf,$user,$langs,$db;
917
-		$conf=$this->savconf;
918
-		$user=$this->savuser;
919
-		$langs=$this->savlangs;
920
-		$db=$this->savdb;
916
+		global $conf, $user, $langs, $db;
917
+		$conf = $this->savconf;
918
+		$user = $this->savuser;
919
+		$langs = $this->savlangs;
920
+		$db = $this->savdb;
921 921
 
922 922
 		//$dummyuser=new User($db);
923 923
 		//$result=restrictedArea($dummyuser,'societe');
924 924
 
925
-		$result=dol_sanitizeFileName('bad file | evilaction');
925
+		$result = dol_sanitizeFileName('bad file | evilaction');
926 926
 		$this->assertEquals('bad file _ evilaction', $result);
927 927
 
928
-		$result=dol_sanitizeFileName('bad file -evilparam --evilparam ---evilparam ----evilparam');
928
+		$result = dol_sanitizeFileName('bad file -evilparam --evilparam ---evilparam ----evilparam');
929 929
 		$this->assertEquals('bad file _evilparam _evilparam _evilparam _evilparam', $result);
930 930
 	}
931 931
 
@@ -936,17 +936,17 @@  discard block
 block discarded – undo
936 936
 	 */
937 937
 	public function testDolEval()
938 938
 	{
939
-		global $conf,$user,$langs,$db;
940
-		$conf=$this->savconf;
941
-		$user=$this->savuser;
942
-		$langs=$this->savlangs;
943
-		$db=$this->savdb;
939
+		global $conf, $user, $langs, $db;
940
+		$conf = $this->savconf;
941
+		$user = $this->savuser;
942
+		$langs = $this->savlangs;
943
+		$db = $this->savdb;
944 944
 
945
-		$result=dol_eval('1==1', 1, 0);
945
+		$result = dol_eval('1==1', 1, 0);
946 946
 		print "result1 = ".$result."\n";
947 947
 		$this->assertTrue($result);
948 948
 
949
-		$result=dol_eval('1==2', 1, 0);
949
+		$result = dol_eval('1==2', 1, 0);
950 950
 		print "result2 = ".$result."\n";
951 951
 		$this->assertFalse($result);
952 952
 
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
 		include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
955 955
 
956 956
 		$s = '(($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : "Parent project not found"';
957
-		$result=dol_eval($s, 1, 1, '2');
957
+		$result = dol_eval($s, 1, 1, '2');
958 958
 		print "result3 = ".$result."\n";
959 959
 		$this->assertEquals('Parent project not found', $result);
960 960
 
@@ -995,48 +995,48 @@  discard block
 block discarded – undo
995 995
 		print "result12 = ".$result."\n";
996 996
 		$this->assertStringContainsString('Bad string syntax to evaluate', $result);
997 997
 
998
-		$result=dol_eval("90402.38+267678+0", 1, 1, 1);
998
+		$result = dol_eval("90402.38+267678+0", 1, 1, 1);
999 999
 		print "result13 = ".$result."\n";
1000 1000
 		$this->assertEquals('358080.38', $result);
1001 1001
 
1002
-		global $leftmenu;	// Used into strings to eval
1002
+		global $leftmenu; // Used into strings to eval
1003 1003
 
1004 1004
 		$leftmenu = 'AAA';
1005
-		$result=dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1');
1005
+		$result = dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1');
1006 1006
 		print "result = ".$result."\n";
1007 1007
 		$this->assertTrue($result);
1008 1008
 
1009 1009
 		// Same with a value that does not match
1010 1010
 		$leftmenu = 'XXX';
1011
-		$result=dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1');
1011
+		$result = dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1');
1012 1012
 		print "result14 = ".$result."\n";
1013 1013
 		$this->assertFalse($result);
1014 1014
 
1015 1015
 		$leftmenu = 'AAA';
1016
-		$result=dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1');
1016
+		$result = dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1');
1017 1017
 		print "result15 = ".$result."\n";
1018 1018
 		$this->assertTrue($result);
1019 1019
 
1020 1020
 		$leftmenu = 'XXX';
1021
-		$result=dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1');
1021
+		$result = dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1');
1022 1022
 		print "result16 = ".$result."\n";
1023 1023
 		$this->assertFalse($result);
1024 1024
 
1025 1025
 		$string = '(isModEnabled("agenda") || isModEnabled("resource")) && getDolGlobalInt("MAIN_FEATURES_LEVEL") >= 0 && preg_match(\'/^(admintools|all|XXX)/\', $leftmenu)';
1026
-		$result=dol_eval($string, 1, 1, '1');
1026
+		$result = dol_eval($string, 1, 1, '1');
1027 1027
 		print "result17 = ".$result."\n";
1028 1028
 		$this->assertTrue($result);
1029 1029
 
1030
-		$result=dol_eval('1 && getDolGlobalInt("doesnotexist1") && $conf->global->MAIN_FEATURES_LEVEL', 1, 0);	// Should return false and not a 'Bad string syntax to evaluate ...'
1030
+		$result = dol_eval('1 && getDolGlobalInt("doesnotexist1") && $conf->global->MAIN_FEATURES_LEVEL', 1, 0); // Should return false and not a 'Bad string syntax to evaluate ...'
1031 1031
 		print "result18 = ".$result."\n";
1032 1032
 		$this->assertFalse($result);
1033 1033
 
1034
-		$a='ab';
1034
+		$a = 'ab';
1035 1035
 		$result = (string) dol_eval("(\$a.'s')", 1, 0);
1036 1036
 		print "result19 = ".$result."\n";
1037 1037
 		$this->assertStringContainsString('Bad string syntax to evaluate', $result);
1038 1038
 
1039
-		$leftmenu='abs';
1039
+		$leftmenu = 'abs';
1040 1040
 		$result = (string) dol_eval('$leftmenu(-5)', 1, 0);
1041 1041
 		print "result20 = ".$result."\n";
1042 1042
 		$this->assertStringContainsString('Bad string syntax to evaluate', $result);
@@ -1050,24 +1050,24 @@  discard block
 block discarded – undo
1050 1050
 	 */
1051 1051
 	public function testCheckLoginPassEntity()
1052 1052
 	{
1053
-		$login=checkLoginPassEntity('loginbidon', 'passwordbidon', 1, array('dolibarr'));
1053
+		$login = checkLoginPassEntity('loginbidon', 'passwordbidon', 1, array('dolibarr'));
1054 1054
 		print __METHOD__." login=".$login."\n";
1055 1055
 		$this->assertEquals($login, '');
1056 1056
 
1057
-		$login=checkLoginPassEntity('admin', 'passwordbidon', 1, array('dolibarr'));
1057
+		$login = checkLoginPassEntity('admin', 'passwordbidon', 1, array('dolibarr'));
1058 1058
 		print __METHOD__." login=".$login."\n";
1059 1059
 		$this->assertEquals($login, '');
1060 1060
 
1061
-		$login=checkLoginPassEntity('admin', 'admin', 1, array('dolibarr'));            // Should works because admin/admin exists
1061
+		$login = checkLoginPassEntity('admin', 'admin', 1, array('dolibarr')); // Should works because admin/admin exists
1062 1062
 		print __METHOD__." login=".$login."\n";
1063 1063
 		$this->assertEquals($login, 'admin', 'The test to check if pass of user "admin" is "admin" has failed');
1064 1064
 
1065
-		$login=checkLoginPassEntity('admin', 'admin', 1, array('http','dolibarr'));    // Should work because of second authentication method
1065
+		$login = checkLoginPassEntity('admin', 'admin', 1, array('http', 'dolibarr')); // Should work because of second authentication method
1066 1066
 		print __METHOD__." login=".$login."\n";
1067 1067
 		$this->assertEquals($login, 'admin');
1068 1068
 
1069
-		$login=checkLoginPassEntity('admin', 'admin', 1, array('forceuser'));
1069
+		$login = checkLoginPassEntity('admin', 'admin', 1, array('forceuser'));
1070 1070
 		print __METHOD__." login=".$login."\n";
1071
-		$this->assertEquals('', $login, 'Error');    // Expected '' because should failed because login 'auto' does not exists
1071
+		$this->assertEquals('', $login, 'Error'); // Expected '' because should failed because login 'auto' does not exists
1072 1072
 	}
1073 1073
 }
Please login to merge, or discard this patch.