Completed
Branch develop (f8a444)
by
unknown
32:44
created
htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	/**
103 103
 	 *  Return next value
104 104
 	 *
105
-	 *  @param	Societe		$objsoc     Object third party
105
+	 *  @param	integer		$objsoc     Object third party
106 106
 	 *  @param  Object	    $object		Object
107 107
      *  @return string      			Value if OK, 0 if KO
108 108
 	*/
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     /**
131 131
      *  Renvoie la reference de commande suivante non utilisee
132 132
      *
133
-	 *  @param	Societe		$objsoc     Object third party
133
+	 *  @param	integer		$objsoc     Object third party
134 134
 	 *  @param  Object	    $object		Object
135 135
      *  @return string      			Texte descripif
136 136
      */
Please login to merge, or discard this patch.
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
 	var $nom = 'Orchidee';
38 38
 
39 39
 
40
-    /**
41
-     *  Renvoi la description du modele de numerotation
42
-     *
43
-     * 	@return     string      Texte descripif
44
-     */
40
+	/**
41
+	 *  Renvoi la description du modele de numerotation
42
+	 *
43
+	 * 	@return     string      Texte descripif
44
+	 */
45 45
 	function info()
46
-    {
47
-    	global $conf,$langs;
46
+	{
47
+		global $conf,$langs;
48 48
 
49 49
 		$langs->load("bills");
50 50
 		$langs->load("admin");
@@ -76,20 +76,20 @@  discard block
 block discarded – undo
76 76
 		$texte.= '</form>';
77 77
 
78 78
 		return $texte;
79
-    }
80
-
81
-    /**
82
-     *  Renvoi un exemple de numerotation
83
-     *
84
-     *  @return     string      Example
85
-     */
86
-    function getExample()
87
-    {
88
-    	global $conf,$langs,$mysoc;
89
-
90
-    	$old_code_client=$mysoc->code_client;
91
-    	$mysoc->code_client='CCCCCCCCCC';
92
-    	$numExample = $this->getNextValue($mysoc,'');
79
+	}
80
+
81
+	/**
82
+	 *  Renvoi un exemple de numerotation
83
+	 *
84
+	 *  @return     string      Example
85
+	 */
86
+	function getExample()
87
+	{
88
+		global $conf,$langs,$mysoc;
89
+
90
+		$old_code_client=$mysoc->code_client;
91
+		$mysoc->code_client='CCCCCCCCCC';
92
+		$numExample = $this->getNextValue($mysoc,'');
93 93
 		$mysoc->code_client=$old_code_client;
94 94
 
95 95
 		if (! $numExample)
@@ -97,17 +97,17 @@  discard block
 block discarded – undo
97 97
 			$numExample = $langs->trans('NotConfigured');
98 98
 		}
99 99
 		return $numExample;
100
-    }
100
+	}
101 101
 
102 102
 	/**
103 103
 	 *  Return next value
104 104
 	 *
105 105
 	 *  @param	Societe		$objsoc     Object third party
106 106
 	 *  @param  Object	    $object		Object
107
-     *  @return string      			Value if OK, 0 if KO
108
-	*/
109
-    function getNextValue($objsoc=0,$object='')
110
-    {
107
+	 *  @return string      			Value if OK, 0 if KO
108
+	 */
109
+	function getNextValue($objsoc=0,$object='')
110
+	{
111 111
 		global $db,$conf;
112 112
 
113 113
 		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
@@ -127,16 +127,16 @@  discard block
 block discarded – undo
127 127
 	}
128 128
 
129 129
 
130
-    /**
131
-     *  Renvoie la reference de commande suivante non utilisee
132
-     *
130
+	/**
131
+	 *  Renvoie la reference de commande suivante non utilisee
132
+	 *
133 133
 	 *  @param	Societe		$objsoc     Object third party
134 134
 	 *  @param  Object	    $object		Object
135
-     *  @return string      			Texte descripif
136
-     */
137
-    function commande_get_num($objsoc=0,$object='')
138
-    {
139
-        return $this->getNextValue($objsoc,$object);
140
-    }
135
+	 *  @return string      			Texte descripif
136
+	 */
137
+	function commande_get_num($objsoc=0,$object='')
138
+	{
139
+		return $this->getNextValue($objsoc,$object);
140
+	}
141 141
 }
142 142
 
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *	\brief      Fichier contenant la classe du modele de numerotation de reference de commande fournisseur Orchidee
25 25
  */
26 26
 
27
-require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_order/modules_commandefournisseur.php';
27
+require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_order/modules_commandefournisseur.php';
28 28
 
29 29
 
30 30
 /**
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders
34 34
 {
35
-	var $version='dolibarr';		// 'development', 'experimental', 'dolibarr'
35
+	var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
36 36
 	var $error = '';
37 37
 	var $nom = 'Orchidee';
38 38
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      */
45 45
 	function info()
46 46
     {
47
-    	global $conf,$langs;
47
+    	global $conf, $langs;
48 48
 
49 49
 		$langs->load("bills");
50 50
 		$langs->load("admin");
@@ -52,28 +52,28 @@  discard block
 block discarded – undo
52 52
 		$form = new Form($this->db);
53 53
 
54 54
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
55
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
56
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
57
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
58
-		$texte.= '<input type="hidden" name="maskconstorder" value="COMMANDE_FOURNISSEUR_ORCHIDEE_MASK">';
59
-		$texte.= '<table class="nobordernopadding" width="100%">';
60
-
61
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
62
-		$tooltip.=$langs->trans("GenericMaskCodes2");
63
-		$tooltip.=$langs->trans("GenericMaskCodes3");
64
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
65
-		$tooltip.=$langs->trans("GenericMaskCodes5");
55
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
56
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
57
+		$texte .= '<input type="hidden" name="action" value="updateMask">';
58
+		$texte .= '<input type="hidden" name="maskconstorder" value="COMMANDE_FOURNISSEUR_ORCHIDEE_MASK">';
59
+		$texte .= '<table class="nobordernopadding" width="100%">';
60
+
61
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Order"), $langs->transnoentities("Order"));
62
+		$tooltip .= $langs->trans("GenericMaskCodes2");
63
+		$tooltip .= $langs->trans("GenericMaskCodes3");
64
+		$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Order"), $langs->transnoentities("Order"));
65
+		$tooltip .= $langs->trans("GenericMaskCodes5");
66 66
 
67 67
 		// Parametrage du prefix
68
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
69
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK.'">',$tooltip,1,1).'</td>';
68
+		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
69
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK.'">', $tooltip, 1, 1).'</td>';
70 70
 
71
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
71
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
72 72
 
73
-		$texte.= '</tr>';
73
+		$texte .= '</tr>';
74 74
 
75
-		$texte.= '</table>';
76
-		$texte.= '</form>';
75
+		$texte .= '</table>';
76
+		$texte .= '</form>';
77 77
 
78 78
 		return $texte;
79 79
     }
@@ -85,14 +85,14 @@  discard block
 block discarded – undo
85 85
      */
86 86
     function getExample()
87 87
     {
88
-    	global $conf,$langs,$mysoc;
88
+    	global $conf, $langs, $mysoc;
89 89
 
90
-    	$old_code_client=$mysoc->code_client;
91
-    	$mysoc->code_client='CCCCCCCCCC';
92
-    	$numExample = $this->getNextValue($mysoc,'');
93
-		$mysoc->code_client=$old_code_client;
90
+    	$old_code_client = $mysoc->code_client;
91
+    	$mysoc->code_client = 'CCCCCCCCCC';
92
+    	$numExample = $this->getNextValue($mysoc, '');
93
+		$mysoc->code_client = $old_code_client;
94 94
 
95
-		if (! $numExample)
95
+		if (!$numExample)
96 96
 		{
97 97
 			$numExample = $langs->trans('NotConfigured');
98 98
 		}
@@ -106,22 +106,22 @@  discard block
 block discarded – undo
106 106
 	 *  @param  Object	    $object		Object
107 107
      *  @return string      			Value if OK, 0 if KO
108 108
 	*/
109
-    function getNextValue($objsoc=0,$object='')
109
+    function getNextValue($objsoc = 0, $object = '')
110 110
     {
111
-		global $db,$conf;
111
+		global $db, $conf;
112 112
 
113
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
113
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
114 114
 
115 115
 		// On defini critere recherche compteur
116
-		$mask=$conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK;
116
+		$mask = $conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK;
117 117
 
118
-		if (! $mask)
118
+		if (!$mask)
119 119
 		{
120
-			$this->error='NotConfigured';
120
+			$this->error = 'NotConfigured';
121 121
 			return 0;
122 122
 		}
123 123
 
124
-		$numFinal=get_next_value($db,$mask,'commande_fournisseur','ref','',$objsoc,$object->date_commande);
124
+		$numFinal = get_next_value($db, $mask, 'commande_fournisseur', 'ref', '', $objsoc, $object->date_commande);
125 125
 
126 126
 		return  $numFinal;
127 127
 	}
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 	 *  @param  Object	    $object		Object
135 135
      *  @return string      			Texte descripif
136 136
      */
137
-    function commande_get_num($objsoc=0,$object='')
137
+    function commande_get_num($objsoc = 0, $object = '')
138 138
     {
139
-        return $this->getNextValue($objsoc,$object);
139
+        return $this->getNextValue($objsoc, $object);
140 140
     }
141 141
 }
142 142
 
Please login to merge, or discard this patch.
htdocs/loan/class/paymentloan.class.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -226,7 +226,7 @@
 block discarded – undo
226 226
 	/**
227 227
 	 *  Update database
228 228
 	 *
229
-	 *  @param	User	$user        	User that modify
229
+	 *  @param	integer	$user        	User that modify
230 230
 	 *  @param  int		$notrigger	    0=launch triggers after, 1=disable triggers
231 231
 	 *  @return int         			<0 if KO, >0 if OK
232 232
 	 */
Please login to merge, or discard this patch.
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 	var $datec='';
38 38
 	var $tms='';
39 39
 	var $datep='';
40
-    var $amounts=array();   // Array of amounts
41
-    var $amount_capital;    // Total amount of payment
40
+	var $amounts=array();   // Array of amounts
41
+	var $amount_capital;    // Total amount of payment
42 42
 	var $amount_insurance;
43 43
 	var $amount_interest;
44 44
 	var $fk_typepayment;
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 
66 66
 	/**
67 67
 	 *  Create payment of loan into database.
68
-     *  Use this->amounts to have list of lines for the payment
69
-     *
68
+	 *  Use this->amounts to have list of lines for the payment
69
+	 *
70 70
 	 *  @param      User		$user   User making payment
71 71
 	 *  @return     int     			<0 if KO, id of payment if OK
72 72
 	 */
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 
77 77
 		$error=0;
78 78
 
79
-        $now=dol_now();
79
+		$now=dol_now();
80 80
 
81
-        // Validate parameters
81
+		// Validate parameters
82 82
 		if (! $this->datepaid)
83 83
 		{
84 84
 			$this->error='ErrorBadValueForParameter';
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 		if (isset($this->fk_user_creat))	$this->fk_user_creat = trim($this->fk_user_creat);
99 99
 		if (isset($this->fk_user_modif))	$this->fk_user_modif = trim($this->fk_user_modif);
100 100
 
101
-        $totalamount = $this->amount_capital + $this->amount_insurance + $this->amount_interest;
102
-        $totalamount = price2num($totalamount);
101
+		$totalamount = $this->amount_capital + $this->amount_insurance + $this->amount_interest;
102
+		$totalamount = price2num($totalamount);
103 103
 
104
-        // Check parameters
105
-        if ($totalamount == 0) return -1; // Negative amounts are accepted for reject prelevement but not null
104
+		// Check parameters
105
+		if ($totalamount == 0) return -1; // Negative amounts are accepted for reject prelevement but not null
106 106
 
107 107
 
108 108
 		$this->db->begin();
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 			}
128 128
 			else
129 129
 			{
130
-                $this->error=$this->db->lasterror();
130
+				$this->error=$this->db->lasterror();
131 131
 				$error++;
132 132
 			}
133 133
 
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
 
136 136
 		if ($totalamount != 0 && ! $error)
137 137
 		{
138
-		    $this->amount_capital=$totalamount;
139
-            $this->total=$totalamount;    // deprecated
140
-		    $this->db->commit();
138
+			$this->amount_capital=$totalamount;
139
+			$this->total=$totalamount;    // deprecated
140
+			$this->db->commit();
141 141
 			return $this->id;
142 142
 		}
143 143
 		else
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 		$sql.= " t.amount_interest,";
169 169
 		$sql.= " t.fk_typepayment,";
170 170
 		$sql.= " t.num_payment,";
171
-        $sql.= " t.note_private,";
172
-        $sql.= " t.note_public,";
171
+		$sql.= " t.note_private,";
172
+		$sql.= " t.note_public,";
173 173
 		$sql.= " t.fk_bank,";
174 174
 		$sql.= " t.fk_user_creat,";
175 175
 		$sql.= " t.fk_user_modif,";
@@ -326,15 +326,15 @@  discard block
 block discarded – undo
326 326
 
327 327
 		$this->db->begin();
328 328
 
329
-	    if (! $error)
330
-        {
331
-            $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url";
332
-            $sql.= " WHERE type='payment_loan' AND url_id=".$this->id;
329
+		if (! $error)
330
+		{
331
+			$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url";
332
+			$sql.= " WHERE type='payment_loan' AND url_id=".$this->id;
333 333
 
334
-            dol_syslog(get_class($this)."::delete", LOG_DEBUG);
335
-            $resql = $this->db->query($sql);
336
-            if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
337
-        }
334
+			dol_syslog(get_class($this)."::delete", LOG_DEBUG);
335
+			$resql = $this->db->query($sql);
336
+			if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
337
+		}
338 338
 
339 339
 		if (! $error)
340 340
 		{
@@ -380,95 +380,95 @@  discard block
 block discarded – undo
380 380
 		}
381 381
 	}
382 382
 
383
-    /**
384
-     *      Add record into bank for payment with links between this bank record and invoices of payment.
385
-     *      All payment properties must have been set first like after a call to create().
386
-     *
387
-     *      @param	User	$user               Object of user making payment
388
-     *      @param  int		$fk_loan            Id of fk_loan to do link with this payment
389
-     *      @param  string	$mode               'payment_loan'
390
-     *      @param  string	$label              Label to use in bank record
391
-     *      @param  int		$accountid          Id of bank account to do link with
392
-     *      @param  string	$emetteur_nom       Name of transmitter
393
-     *      @param  string	$emetteur_banque    Name of bank
394
-     *      @return int                 		<0 if KO, >0 if OK
395
-     */
396
-    function addPaymentToBank($user, $fk_loan, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
397
-    {
398
-        global $conf;
399
-
400
-        $error=0;
401
-
402
-        if (! empty($conf->banque->enabled))
403
-        {
404
-            require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
405
-
406
-            $acc = new Account($this->db);
407
-            $acc->fetch($accountid);
408
-
409
-            $total=$this->total;
410
-            if ($mode == 'payment_loan') $total=-$total;
411
-
412
-            // Insert payment into llx_bank
413
-            $bank_line_id = $acc->addline(
414
-                $this->datepaid,
415
-                $this->paymenttype,  // Payment mode id or code ("CHQ or VIR for example")
416
-                $label,
417
-                $total,
418
-                $this->num_payment,
419
-                '',
420
-                $user,
421
-                $emetteur_nom,
422
-                $emetteur_banque
423
-            );
424
-
425
-            // Update fk_bank into llx_paiement.
426
-            // We know the payment who generated the account write
427
-            if ($bank_line_id > 0)
428
-            {
429
-                $result=$this->update_fk_bank($bank_line_id);
430
-                if ($result <= 0)
431
-                {
432
-                    $error++;
433
-                    dol_print_error($this->db);
434
-                }
435
-
436
-                // Add link 'payment_loan' in bank_url between payment and bank transaction
437
-                $url='';
438
-                if ($mode == 'payment_loan') $url=DOL_URL_ROOT.'/loan/payment/card.php?id=';
439
-                if ($url)
440
-                {
441
-                    $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(payment)', $mode);
442
-                    if ($result <= 0)
443
-                    {
444
-                        $error++;
445
-                        dol_print_error($this->db);
446
-                    }
447
-                }
448
-
449
-                // Add link 'loan' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
450
-                if ($mode == 'payment_loan')
451
-                {
452
-                    $result=$acc->add_url_line($bank_line_id, $fk_loan, DOL_URL_ROOT.'/loan/card.php?id=', ($this->label?$this->label:''),'loan');
453
-                    if ($result <= 0) dol_print_error($this->db);
454
-                }
455
-            }
456
-            else
457
-            {
458
-                $this->error=$acc->error;
459
-                $error++;
460
-            }
461
-        }
462
-
463
-        if (! $error)
464
-        {
465
-            return 1;
466
-        }
467
-        else
468
-        {
469
-            return -1;
470
-        }
471
-    }
383
+	/**
384
+	 *      Add record into bank for payment with links between this bank record and invoices of payment.
385
+	 *      All payment properties must have been set first like after a call to create().
386
+	 *
387
+	 *      @param	User	$user               Object of user making payment
388
+	 *      @param  int		$fk_loan            Id of fk_loan to do link with this payment
389
+	 *      @param  string	$mode               'payment_loan'
390
+	 *      @param  string	$label              Label to use in bank record
391
+	 *      @param  int		$accountid          Id of bank account to do link with
392
+	 *      @param  string	$emetteur_nom       Name of transmitter
393
+	 *      @param  string	$emetteur_banque    Name of bank
394
+	 *      @return int                 		<0 if KO, >0 if OK
395
+	 */
396
+	function addPaymentToBank($user, $fk_loan, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
397
+	{
398
+		global $conf;
399
+
400
+		$error=0;
401
+
402
+		if (! empty($conf->banque->enabled))
403
+		{
404
+			require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
405
+
406
+			$acc = new Account($this->db);
407
+			$acc->fetch($accountid);
408
+
409
+			$total=$this->total;
410
+			if ($mode == 'payment_loan') $total=-$total;
411
+
412
+			// Insert payment into llx_bank
413
+			$bank_line_id = $acc->addline(
414
+				$this->datepaid,
415
+				$this->paymenttype,  // Payment mode id or code ("CHQ or VIR for example")
416
+				$label,
417
+				$total,
418
+				$this->num_payment,
419
+				'',
420
+				$user,
421
+				$emetteur_nom,
422
+				$emetteur_banque
423
+			);
424
+
425
+			// Update fk_bank into llx_paiement.
426
+			// We know the payment who generated the account write
427
+			if ($bank_line_id > 0)
428
+			{
429
+				$result=$this->update_fk_bank($bank_line_id);
430
+				if ($result <= 0)
431
+				{
432
+					$error++;
433
+					dol_print_error($this->db);
434
+				}
435
+
436
+				// Add link 'payment_loan' in bank_url between payment and bank transaction
437
+				$url='';
438
+				if ($mode == 'payment_loan') $url=DOL_URL_ROOT.'/loan/payment/card.php?id=';
439
+				if ($url)
440
+				{
441
+					$result=$acc->add_url_line($bank_line_id, $this->id, $url, '(payment)', $mode);
442
+					if ($result <= 0)
443
+					{
444
+						$error++;
445
+						dol_print_error($this->db);
446
+					}
447
+				}
448
+
449
+				// Add link 'loan' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
450
+				if ($mode == 'payment_loan')
451
+				{
452
+					$result=$acc->add_url_line($bank_line_id, $fk_loan, DOL_URL_ROOT.'/loan/card.php?id=', ($this->label?$this->label:''),'loan');
453
+					if ($result <= 0) dol_print_error($this->db);
454
+				}
455
+			}
456
+			else
457
+			{
458
+				$this->error=$acc->error;
459
+				$error++;
460
+			}
461
+		}
462
+
463
+		if (! $error)
464
+		{
465
+			return 1;
466
+		}
467
+		else
468
+		{
469
+			return -1;
470
+		}
471
+	}
472 472
 
473 473
 
474 474
 	/**
Please login to merge, or discard this patch.
Braces   +99 added lines, -46 removed lines patch added patch discarded remove patch
@@ -86,23 +86,48 @@  discard block
 block discarded – undo
86 86
 		}
87 87
 
88 88
 		// Clean parameters
89
-		if (isset($this->fk_loan)) 			$this->fk_loan = trim($this->fk_loan);
90
-		if (isset($this->amount_capital))	$this->amount_capital = price2num($this->amount_capital?$this->amount_capital:0);
91
-		if (isset($this->amount_insurance))	$this->amount_insurance = price2num($this->amount_insurance?$this->amount_insurance:0);
92
-		if (isset($this->amount_interest))	$this->amount_interest = price2num($this->amount_interest?$this->amount_interest:0);
93
-		if (isset($this->fk_typepayment))	$this->fk_typepayment = trim($this->fk_typepayment);
94
-		if (isset($this->num_payment))		$this->num_payment = trim($this->num_payment);
95
-		if (isset($this->note_private))     $this->note_private = trim($this->note_private);
96
-		if (isset($this->note_public))      $this->note_public = trim($this->note_public);
97
-		if (isset($this->fk_bank))			$this->fk_bank = trim($this->fk_bank);
98
-		if (isset($this->fk_user_creat))	$this->fk_user_creat = trim($this->fk_user_creat);
99
-		if (isset($this->fk_user_modif))	$this->fk_user_modif = trim($this->fk_user_modif);
89
+		if (isset($this->fk_loan)) {
90
+			$this->fk_loan = trim($this->fk_loan);
91
+		}
92
+		if (isset($this->amount_capital)) {
93
+			$this->amount_capital = price2num($this->amount_capital?$this->amount_capital:0);
94
+		}
95
+		if (isset($this->amount_insurance)) {
96
+			$this->amount_insurance = price2num($this->amount_insurance?$this->amount_insurance:0);
97
+		}
98
+		if (isset($this->amount_interest)) {
99
+			$this->amount_interest = price2num($this->amount_interest?$this->amount_interest:0);
100
+		}
101
+		if (isset($this->fk_typepayment)) {
102
+			$this->fk_typepayment = trim($this->fk_typepayment);
103
+		}
104
+		if (isset($this->num_payment)) {
105
+			$this->num_payment = trim($this->num_payment);
106
+		}
107
+		if (isset($this->note_private)) {
108
+			$this->note_private = trim($this->note_private);
109
+		}
110
+		if (isset($this->note_public)) {
111
+			$this->note_public = trim($this->note_public);
112
+		}
113
+		if (isset($this->fk_bank)) {
114
+			$this->fk_bank = trim($this->fk_bank);
115
+		}
116
+		if (isset($this->fk_user_creat)) {
117
+			$this->fk_user_creat = trim($this->fk_user_creat);
118
+		}
119
+		if (isset($this->fk_user_modif)) {
120
+			$this->fk_user_modif = trim($this->fk_user_modif);
121
+		}
100 122
 
101 123
         $totalamount = $this->amount_capital + $this->amount_insurance + $this->amount_interest;
102 124
         $totalamount = price2num($totalamount);
103 125
 
104 126
         // Check parameters
105
-        if ($totalamount == 0) return -1; // Negative amounts are accepted for reject prelevement but not null
127
+        if ($totalamount == 0) {
128
+        	return -1;
129
+        }
130
+        // Negative amounts are accepted for reject prelevement but not null
106 131
 
107 132
 
108 133
 		$this->db->begin();
@@ -124,8 +149,7 @@  discard block
 block discarded – undo
124 149
 			if ($resql)
125 150
 			{
126 151
 				$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_loan");
127
-			}
128
-			else
152
+			} else
129 153
 			{
130 154
                 $this->error=$this->db->lasterror();
131 155
 				$error++;
@@ -139,8 +163,7 @@  discard block
 block discarded – undo
139 163
             $this->total=$totalamount;    // deprecated
140 164
 		    $this->db->commit();
141 165
 			return $this->id;
142
-		}
143
-		else
166
+		} else
144 167
 		{
145 168
 			$this->error=$this->db->lasterror();
146 169
 			$this->db->rollback();
@@ -214,8 +237,7 @@  discard block
 block discarded – undo
214 237
 			$this->db->free($resql);
215 238
 
216 239
 			return 1;
217
-		}
218
-		else
240
+		} else
219 241
 		{
220 242
 			$this->error="Error ".$this->db->lasterror();
221 243
 			return -1;
@@ -236,17 +258,39 @@  discard block
 block discarded – undo
236 258
 		$error=0;
237 259
 
238 260
 		// Clean parameters
239
-		if (isset($this->fk_loan)) $this->fk_loan=trim($this->fk_loan);
240
-		if (isset($this->amount_capital)) $this->amount_capital=trim($this->amount_capital);
241
-		if (isset($this->amount_insurance)) $this->amount_insurance=trim($this->amount_insurance);
242
-		if (isset($this->amount_interest)) $this->amount_interest=trim($this->amount_interest);
243
-		if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment);
244
-		if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment);
245
-		if (isset($this->note_private)) $this->note=trim($this->note_private);
246
-		if (isset($this->note_public)) $this->note=trim($this->note_public);
247
-		if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank);
248
-		if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat);
249
-		if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif);
261
+		if (isset($this->fk_loan)) {
262
+			$this->fk_loan=trim($this->fk_loan);
263
+		}
264
+		if (isset($this->amount_capital)) {
265
+			$this->amount_capital=trim($this->amount_capital);
266
+		}
267
+		if (isset($this->amount_insurance)) {
268
+			$this->amount_insurance=trim($this->amount_insurance);
269
+		}
270
+		if (isset($this->amount_interest)) {
271
+			$this->amount_interest=trim($this->amount_interest);
272
+		}
273
+		if (isset($this->fk_typepayment)) {
274
+			$this->fk_typepayment=trim($this->fk_typepayment);
275
+		}
276
+		if (isset($this->num_payment)) {
277
+			$this->num_payment=trim($this->num_payment);
278
+		}
279
+		if (isset($this->note_private)) {
280
+			$this->note=trim($this->note_private);
281
+		}
282
+		if (isset($this->note_public)) {
283
+			$this->note=trim($this->note_public);
284
+		}
285
+		if (isset($this->fk_bank)) {
286
+			$this->fk_bank=trim($this->fk_bank);
287
+		}
288
+		if (isset($this->fk_user_creat)) {
289
+			$this->fk_user_creat=trim($this->fk_user_creat);
290
+		}
291
+		if (isset($this->fk_user_modif)) {
292
+			$this->fk_user_modif=trim($this->fk_user_modif);
293
+		}
250 294
 
251 295
 		// Check parameters
252 296
 		// Put here code to add control on parameters values
@@ -303,8 +347,7 @@  discard block
 block discarded – undo
303 347
 			}
304 348
 			$this->db->rollback();
305 349
 			return -1*$error;
306
-		}
307
-		else
350
+		} else
308 351
 		{
309 352
 			$this->db->commit();
310 353
 			return 1;
@@ -372,8 +415,7 @@  discard block
 block discarded – undo
372 415
 			}
373 416
 			$this->db->rollback();
374 417
 			return -1*$error;
375
-		}
376
-		else
418
+		} else
377 419
 		{
378 420
 			$this->db->commit();
379 421
 			return 1;
@@ -407,7 +449,9 @@  discard block
 block discarded – undo
407 449
             $acc->fetch($accountid);
408 450
 
409 451
             $total=$this->total;
410
-            if ($mode == 'payment_loan') $total=-$total;
452
+            if ($mode == 'payment_loan') {
453
+            	$total=-$total;
454
+            }
411 455
 
412 456
             // Insert payment into llx_bank
413 457
             $bank_line_id = $acc->addline(
@@ -435,7 +479,9 @@  discard block
 block discarded – undo
435 479
 
436 480
                 // Add link 'payment_loan' in bank_url between payment and bank transaction
437 481
                 $url='';
438
-                if ($mode == 'payment_loan') $url=DOL_URL_ROOT.'/loan/payment/card.php?id=';
482
+                if ($mode == 'payment_loan') {
483
+                	$url=DOL_URL_ROOT.'/loan/payment/card.php?id=';
484
+                }
439 485
                 if ($url)
440 486
                 {
441 487
                     $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(payment)', $mode);
@@ -450,10 +496,11 @@  discard block
 block discarded – undo
450 496
                 if ($mode == 'payment_loan')
451 497
                 {
452 498
                     $result=$acc->add_url_line($bank_line_id, $fk_loan, DOL_URL_ROOT.'/loan/card.php?id=', ($this->label?$this->label:''),'loan');
453
-                    if ($result <= 0) dol_print_error($this->db);
499
+                    if ($result <= 0) {
500
+                    	dol_print_error($this->db);
501
+                    }
454 502
                 }
455
-            }
456
-            else
503
+            } else
457 504
             {
458 505
                 $this->error=$acc->error;
459 506
                 $error++;
@@ -463,8 +510,7 @@  discard block
 block discarded – undo
463 510
         if (! $error)
464 511
         {
465 512
             return 1;
466
-        }
467
-        else
513
+        } else
468 514
         {
469 515
             return -1;
470 516
         }
@@ -486,8 +532,7 @@  discard block
 block discarded – undo
486 532
 		if ($result)
487 533
 		{
488 534
 			return 1;
489
-		}
490
-		else
535
+		} else
491 536
 		{
492 537
 			$this->error=$this->db->error();
493 538
 			return 0;
@@ -507,16 +552,24 @@  discard block
 block discarded – undo
507 552
 
508 553
 		$result='';
509 554
 
510
-		if (empty($this->ref)) $this->ref=$this->lib;
555
+		if (empty($this->ref)) {
556
+			$this->ref=$this->lib;
557
+		}
511 558
 
512 559
 		if (!empty($this->id))
513 560
 		{
514 561
 			$link = '<a href="'.DOL_URL_ROOT.'/compta/payment/card.php?id='.$this->id.'">';
515 562
 			$linkend='</a>';
516 563
 
517
-			if ($withpicto) $result.=($link.img_object($langs->trans("ShowPayment").': '.$this->ref,'payment').$linkend.' ');
518
-			if ($withpicto && $withpicto != 2) $result.=' ';
519
-			if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$linkend;
564
+			if ($withpicto) {
565
+				$result.=($link.img_object($langs->trans("ShowPayment").': '.$this->ref,'payment').$linkend.' ');
566
+			}
567
+			if ($withpicto && $withpicto != 2) {
568
+				$result.=' ';
569
+			}
570
+			if ($withpicto != 2) {
571
+				$result.=$link.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$linkend;
572
+			}
520 573
 		}
521 574
 
522 575
 		return $result;
Please login to merge, or discard this patch.
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -30,15 +30,15 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class PaymentLoan extends CommonObject
32 32
 {
33
-	public $element='payment_loan';			//!< Id that identify managed objects
34
-	public $table_element='payment_loan';	//!< Name of table without prefix where object is stored
33
+	public $element = 'payment_loan'; //!< Id that identify managed objects
34
+	public $table_element = 'payment_loan'; //!< Name of table without prefix where object is stored
35 35
 
36 36
 	var $fk_loan;
37
-	var $datec='';
38
-	var $tms='';
39
-	var $datep='';
40
-    var $amounts=array();   // Array of amounts
41
-    var $amount_capital;    // Total amount of payment
37
+	var $datec = '';
38
+	var $tms = '';
39
+	var $datep = '';
40
+    var $amounts = array(); // Array of amounts
41
+    var $amount_capital; // Total amount of payment
42 42
 	var $amount_insurance;
43 43
 	var $amount_interest;
44 44
 	var $fk_typepayment;
@@ -74,22 +74,22 @@  discard block
 block discarded – undo
74 74
 	{
75 75
 		global $conf, $langs;
76 76
 
77
-		$error=0;
77
+		$error = 0;
78 78
 
79
-        $now=dol_now();
79
+        $now = dol_now();
80 80
 
81 81
         // Validate parameters
82
-		if (! $this->datepaid)
82
+		if (!$this->datepaid)
83 83
 		{
84
-			$this->error='ErrorBadValueForParameter';
84
+			$this->error = 'ErrorBadValueForParameter';
85 85
 			return -1;
86 86
 		}
87 87
 
88 88
 		// Clean parameters
89 89
 		if (isset($this->fk_loan)) 			$this->fk_loan = trim($this->fk_loan);
90
-		if (isset($this->amount_capital))	$this->amount_capital = price2num($this->amount_capital?$this->amount_capital:0);
91
-		if (isset($this->amount_insurance))	$this->amount_insurance = price2num($this->amount_insurance?$this->amount_insurance:0);
92
-		if (isset($this->amount_interest))	$this->amount_interest = price2num($this->amount_interest?$this->amount_interest:0);
90
+		if (isset($this->amount_capital))	$this->amount_capital = price2num($this->amount_capital ? $this->amount_capital : 0);
91
+		if (isset($this->amount_insurance))	$this->amount_insurance = price2num($this->amount_insurance ? $this->amount_insurance : 0);
92
+		if (isset($this->amount_interest))	$this->amount_interest = price2num($this->amount_interest ? $this->amount_interest : 0);
93 93
 		if (isset($this->fk_typepayment))	$this->fk_typepayment = trim($this->fk_typepayment);
94 94
 		if (isset($this->num_payment))		$this->num_payment = trim($this->num_payment);
95 95
 		if (isset($this->note_private))     $this->note_private = trim($this->note_private);
@@ -110,39 +110,39 @@  discard block
 block discarded – undo
110 110
 		if ($totalamount != 0)
111 111
 		{
112 112
 			$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_loan (fk_loan, datec, datep, amount_capital, amount_insurance, amount_interest,";
113
-			$sql.= " fk_typepayment, num_payment, note_private, note_public, fk_user_creat, fk_bank)";
114
-			$sql.= " VALUES (".$this->chid.", '".$this->db->idate($now)."',";
115
-			$sql.= " '".$this->db->idate($this->datepaid)."',";
116
-			$sql.= " ".$this->amount_capital.",";
117
-			$sql.= " ".$this->amount_insurance.",";
118
-			$sql.= " ".$this->amount_interest.",";
119
-			$sql.= " ".$this->paymenttype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_private)."', '".$this->db->escape($this->note_public)."', ".$user->id.",";
120
-			$sql.= " 0)";
113
+			$sql .= " fk_typepayment, num_payment, note_private, note_public, fk_user_creat, fk_bank)";
114
+			$sql .= " VALUES (".$this->chid.", '".$this->db->idate($now)."',";
115
+			$sql .= " '".$this->db->idate($this->datepaid)."',";
116
+			$sql .= " ".$this->amount_capital.",";
117
+			$sql .= " ".$this->amount_insurance.",";
118
+			$sql .= " ".$this->amount_interest.",";
119
+			$sql .= " ".$this->paymenttype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_private)."', '".$this->db->escape($this->note_public)."', ".$user->id.",";
120
+			$sql .= " 0)";
121 121
 
122 122
 			dol_syslog(get_class($this)."::create", LOG_DEBUG);
123
-			$resql=$this->db->query($sql);
123
+			$resql = $this->db->query($sql);
124 124
 			if ($resql)
125 125
 			{
126 126
 				$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_loan");
127 127
 			}
128 128
 			else
129 129
 			{
130
-                $this->error=$this->db->lasterror();
130
+                $this->error = $this->db->lasterror();
131 131
 				$error++;
132 132
 			}
133 133
 
134 134
 		}
135 135
 
136
-		if ($totalamount != 0 && ! $error)
136
+		if ($totalamount != 0 && !$error)
137 137
 		{
138
-		    $this->amount_capital=$totalamount;
139
-            $this->total=$totalamount;    // deprecated
138
+		    $this->amount_capital = $totalamount;
139
+            $this->total = $totalamount; // deprecated
140 140
 		    $this->db->commit();
141 141
 			return $this->id;
142 142
 		}
143 143
 		else
144 144
 		{
145
-			$this->error=$this->db->lasterror();
145
+			$this->error = $this->db->lasterror();
146 146
 			$this->db->rollback();
147 147
 			return -1;
148 148
 		}
@@ -158,30 +158,30 @@  discard block
 block discarded – undo
158 158
 	{
159 159
 		global $langs;
160 160
 		$sql = "SELECT";
161
-		$sql.= " t.rowid,";
162
-		$sql.= " t.fk_loan,";
163
-		$sql.= " t.datec,";
164
-		$sql.= " t.tms,";
165
-		$sql.= " t.datep,";
166
-		$sql.= " t.amount_capital,";
167
-		$sql.= " t.amount_insurance,";
168
-		$sql.= " t.amount_interest,";
169
-		$sql.= " t.fk_typepayment,";
170
-		$sql.= " t.num_payment,";
171
-        $sql.= " t.note_private,";
172
-        $sql.= " t.note_public,";
173
-		$sql.= " t.fk_bank,";
174
-		$sql.= " t.fk_user_creat,";
175
-		$sql.= " t.fk_user_modif,";
176
-		$sql.= " pt.code as type_code, pt.libelle as type_libelle,";
177
-		$sql.= ' b.fk_account';
178
-		$sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX."payment_loan as t)";
179
-		$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid';
180
-		$sql.= " WHERE t.rowid = ".$id." AND t.fk_typepayment = pt.id";
181
-		$sql.= " AND pt.entity = " . getEntity('c_paiement');
161
+		$sql .= " t.rowid,";
162
+		$sql .= " t.fk_loan,";
163
+		$sql .= " t.datec,";
164
+		$sql .= " t.tms,";
165
+		$sql .= " t.datep,";
166
+		$sql .= " t.amount_capital,";
167
+		$sql .= " t.amount_insurance,";
168
+		$sql .= " t.amount_interest,";
169
+		$sql .= " t.fk_typepayment,";
170
+		$sql .= " t.num_payment,";
171
+        $sql .= " t.note_private,";
172
+        $sql .= " t.note_public,";
173
+		$sql .= " t.fk_bank,";
174
+		$sql .= " t.fk_user_creat,";
175
+		$sql .= " t.fk_user_modif,";
176
+		$sql .= " pt.code as type_code, pt.libelle as type_libelle,";
177
+		$sql .= ' b.fk_account';
178
+		$sql .= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX."payment_loan as t)";
179
+		$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid';
180
+		$sql .= " WHERE t.rowid = ".$id." AND t.fk_typepayment = pt.id";
181
+		$sql .= " AND pt.entity = ".getEntity('c_paiement');
182 182
 
183 183
 		dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
184
-		$resql=$this->db->query($sql);
184
+		$resql = $this->db->query($sql);
185 185
 		if ($resql)
186 186
 		{
187 187
 			if ($this->db->num_rows($resql))
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 		}
219 219
 		else
220 220
 		{
221
-			$this->error="Error ".$this->db->lasterror();
221
+			$this->error = "Error ".$this->db->lasterror();
222 222
 			return -1;
223 223
 		}
224 224
 	}
@@ -231,23 +231,23 @@  discard block
 block discarded – undo
231 231
 	 *  @param  int		$notrigger	    0=launch triggers after, 1=disable triggers
232 232
 	 *  @return int         			<0 if KO, >0 if OK
233 233
 	 */
234
-	function update($user=0, $notrigger=0)
234
+	function update($user = 0, $notrigger = 0)
235 235
 	{
236 236
 		global $conf, $langs;
237
-		$error=0;
237
+		$error = 0;
238 238
 
239 239
 		// Clean parameters
240
-		if (isset($this->fk_loan)) $this->fk_loan=trim($this->fk_loan);
241
-		if (isset($this->amount_capital)) $this->amount_capital=trim($this->amount_capital);
242
-		if (isset($this->amount_insurance)) $this->amount_insurance=trim($this->amount_insurance);
243
-		if (isset($this->amount_interest)) $this->amount_interest=trim($this->amount_interest);
244
-		if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment);
245
-		if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment);
246
-		if (isset($this->note_private)) $this->note=trim($this->note_private);
247
-		if (isset($this->note_public)) $this->note=trim($this->note_public);
248
-		if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank);
249
-		if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat);
250
-		if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif);
240
+		if (isset($this->fk_loan)) $this->fk_loan = trim($this->fk_loan);
241
+		if (isset($this->amount_capital)) $this->amount_capital = trim($this->amount_capital);
242
+		if (isset($this->amount_insurance)) $this->amount_insurance = trim($this->amount_insurance);
243
+		if (isset($this->amount_interest)) $this->amount_interest = trim($this->amount_interest);
244
+		if (isset($this->fk_typepayment)) $this->fk_typepayment = trim($this->fk_typepayment);
245
+		if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
246
+		if (isset($this->note_private)) $this->note = trim($this->note_private);
247
+		if (isset($this->note_public)) $this->note = trim($this->note_public);
248
+		if (isset($this->fk_bank)) $this->fk_bank = trim($this->fk_bank);
249
+		if (isset($this->fk_user_creat)) $this->fk_user_creat = trim($this->fk_user_creat);
250
+		if (isset($this->fk_user_modif)) $this->fk_user_modif = trim($this->fk_user_modif);
251 251
 
252 252
 		// Check parameters
253 253
 		// Put here code to add control on parameters values
@@ -255,32 +255,32 @@  discard block
 block discarded – undo
255 255
 		// Update request
256 256
 		$sql = "UPDATE ".MAIN_DB_PREFIX."payment_loan SET";
257 257
 
258
-		$sql.= " fk_loan=".(isset($this->fk_loan)?$this->fk_loan:"null").",";
259
-		$sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
260
-		$sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
261
-		$sql.= " datep=".(dol_strlen($this->datep)!=0 ? "'".$this->db->idate($this->datep)."'" : 'null').",";
262
-		$sql.= " amount_capital=".(isset($this->amount_capital)?$this->amount_capital:"null").",";
263
-		$sql.= " amount_insurance=".(isset($this->amount_insurance)?$this->amount_insurance:"null").",";
264
-		$sql.= " amount_interest=".(isset($this->amount_interest)?$this->amount_interest:"null").",";
265
-		$sql.= " fk_typepayment=".(isset($this->fk_typepayment)?$this->fk_typepayment:"null").",";
266
-		$sql.= " num_payment=".(isset($this->num_payment)?"'".$this->db->escape($this->num_payment)."'":"null").",";
267
-		$sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").",";
268
-		$sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").",";
269
-		$sql.= " fk_bank=".(isset($this->fk_bank)?$this->fk_bank:"null").",";
270
-		$sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").",";
271
-		$sql.= " fk_user_modif=".(isset($this->fk_user_modif)?$this->fk_user_modif:"null")."";
272
-
273
-		$sql.= " WHERE rowid=".$this->id;
258
+		$sql .= " fk_loan=".(isset($this->fk_loan) ? $this->fk_loan : "null").",";
259
+		$sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
260
+		$sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
261
+		$sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').",";
262
+		$sql .= " amount_capital=".(isset($this->amount_capital) ? $this->amount_capital : "null").",";
263
+		$sql .= " amount_insurance=".(isset($this->amount_insurance) ? $this->amount_insurance : "null").",";
264
+		$sql .= " amount_interest=".(isset($this->amount_interest) ? $this->amount_interest : "null").",";
265
+		$sql .= " fk_typepayment=".(isset($this->fk_typepayment) ? $this->fk_typepayment : "null").",";
266
+		$sql .= " num_payment=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").",";
267
+		$sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").",";
268
+		$sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").",";
269
+		$sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").",";
270
+		$sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").",";
271
+		$sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null")."";
272
+
273
+		$sql .= " WHERE rowid=".$this->id;
274 274
 
275 275
 		$this->db->begin();
276 276
 
277 277
 		dol_syslog(get_class($this)."::update", LOG_DEBUG);
278 278
 		$resql = $this->db->query($sql);
279
-		if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
279
+		if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
280 280
 
281
-		if (! $error)
281
+		if (!$error)
282 282
 		{
283
-			if (! $notrigger)
283
+			if (!$notrigger)
284 284
 			{
285 285
 				// Uncomment this and change MYOBJECT to your own tag if you
286 286
 				// want this action call a trigger.
@@ -297,13 +297,13 @@  discard block
 block discarded – undo
297 297
 		// Commit or rollback
298 298
 		if ($error)
299 299
 		{
300
-			foreach($this->errors as $errmsg)
300
+			foreach ($this->errors as $errmsg)
301 301
 			{
302 302
 				dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
303
-				$this->error.=($this->error?', '.$errmsg:$errmsg);
303
+				$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
304 304
 			}
305 305
 			$this->db->rollback();
306
-			return -1*$error;
306
+			return -1 * $error;
307 307
 		}
308 308
 		else
309 309
 		{
@@ -320,36 +320,36 @@  discard block
 block discarded – undo
320 320
 	 *  @param  int		$notrigger		0=launch triggers after, 1=disable triggers
321 321
 	 *  @return int						<0 if KO, >0 if OK
322 322
 	 */
323
-	function delete($user, $notrigger=0)
323
+	function delete($user, $notrigger = 0)
324 324
 	{
325 325
 		global $conf, $langs;
326
-		$error=0;
326
+		$error = 0;
327 327
 
328 328
 		$this->db->begin();
329 329
 
330
-	    if (! $error)
330
+	    if (!$error)
331 331
         {
332 332
             $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url";
333
-            $sql.= " WHERE type='payment_loan' AND url_id=".$this->id;
333
+            $sql .= " WHERE type='payment_loan' AND url_id=".$this->id;
334 334
 
335 335
             dol_syslog(get_class($this)."::delete", LOG_DEBUG);
336 336
             $resql = $this->db->query($sql);
337
-            if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
337
+            if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
338 338
         }
339 339
 
340
-		if (! $error)
340
+		if (!$error)
341 341
 		{
342 342
 			$sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_loan";
343
-			$sql.= " WHERE rowid=".$this->id;
343
+			$sql .= " WHERE rowid=".$this->id;
344 344
 
345 345
 			dol_syslog(get_class($this)."::delete", LOG_DEBUG);
346 346
 			$resql = $this->db->query($sql);
347
-			if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
347
+			if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
348 348
 		}
349 349
 
350
-		if (! $error)
350
+		if (!$error)
351 351
 		{
352
-			if (! $notrigger)
352
+			if (!$notrigger)
353 353
 			{
354 354
 				// Uncomment this and change MYOBJECT to your own tag if you
355 355
 				// want this action call a trigger.
@@ -366,13 +366,13 @@  discard block
 block discarded – undo
366 366
 		// Commit or rollback
367 367
 		if ($error)
368 368
 		{
369
-			foreach($this->errors as $errmsg)
369
+			foreach ($this->errors as $errmsg)
370 370
 			{
371 371
 				dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
372
-				$this->error.=($this->error?', '.$errmsg:$errmsg);
372
+				$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
373 373
 			}
374 374
 			$this->db->rollback();
375
-			return -1*$error;
375
+			return -1 * $error;
376 376
 		}
377 377
 		else
378 378
 		{
@@ -398,22 +398,22 @@  discard block
 block discarded – undo
398 398
     {
399 399
         global $conf;
400 400
 
401
-        $error=0;
401
+        $error = 0;
402 402
 
403
-        if (! empty($conf->banque->enabled))
403
+        if (!empty($conf->banque->enabled))
404 404
         {
405 405
             require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
406 406
 
407 407
             $acc = new Account($this->db);
408 408
             $acc->fetch($accountid);
409 409
 
410
-            $total=$this->total;
411
-            if ($mode == 'payment_loan') $total=-$total;
410
+            $total = $this->total;
411
+            if ($mode == 'payment_loan') $total = -$total;
412 412
 
413 413
             // Insert payment into llx_bank
414 414
             $bank_line_id = $acc->addline(
415 415
                 $this->datepaid,
416
-                $this->paymenttype,  // Payment mode id or code ("CHQ or VIR for example")
416
+                $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example")
417 417
                 $label,
418 418
                 $total,
419 419
                 $this->num_payment,
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
             // We know the payment who generated the account write
428 428
             if ($bank_line_id > 0)
429 429
             {
430
-                $result=$this->update_fk_bank($bank_line_id);
430
+                $result = $this->update_fk_bank($bank_line_id);
431 431
                 if ($result <= 0)
432 432
                 {
433 433
                     $error++;
@@ -435,11 +435,11 @@  discard block
 block discarded – undo
435 435
                 }
436 436
 
437 437
                 // Add link 'payment_loan' in bank_url between payment and bank transaction
438
-                $url='';
439
-                if ($mode == 'payment_loan') $url=DOL_URL_ROOT.'/loan/payment/card.php?id=';
438
+                $url = '';
439
+                if ($mode == 'payment_loan') $url = DOL_URL_ROOT.'/loan/payment/card.php?id=';
440 440
                 if ($url)
441 441
                 {
442
-                    $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(payment)', $mode);
442
+                    $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(payment)', $mode);
443 443
                     if ($result <= 0)
444 444
                     {
445 445
                         $error++;
@@ -450,18 +450,18 @@  discard block
 block discarded – undo
450 450
                 // Add link 'loan' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
451 451
                 if ($mode == 'payment_loan')
452 452
                 {
453
-                    $result=$acc->add_url_line($bank_line_id, $fk_loan, DOL_URL_ROOT.'/loan/card.php?id=', ($this->label?$this->label:''),'loan');
453
+                    $result = $acc->add_url_line($bank_line_id, $fk_loan, DOL_URL_ROOT.'/loan/card.php?id=', ($this->label ? $this->label : ''), 'loan');
454 454
                     if ($result <= 0) dol_print_error($this->db);
455 455
                 }
456 456
             }
457 457
             else
458 458
             {
459
-                $this->error=$acc->error;
459
+                $this->error = $acc->error;
460 460
                 $error++;
461 461
             }
462 462
         }
463 463
 
464
-        if (! $error)
464
+        if (!$error)
465 465
         {
466 466
             return 1;
467 467
         }
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 		}
491 491
 		else
492 492
 		{
493
-			$this->error=$this->db->error();
493
+			$this->error = $this->db->error();
494 494
 			return 0;
495 495
 		}
496 496
 	}
@@ -502,22 +502,22 @@  discard block
 block discarded – undo
502 502
 	 * 	@param	int		$maxlen			Max length label
503 503
 	 *	@return	string					Chaine with URL
504 504
 	 */
505
-	function getNomUrl($withpicto=0,$maxlen=0)
505
+	function getNomUrl($withpicto = 0, $maxlen = 0)
506 506
 	{
507 507
 		global $langs;
508 508
 
509
-		$result='';
509
+		$result = '';
510 510
 
511
-		if (empty($this->ref)) $this->ref=$this->lib;
511
+		if (empty($this->ref)) $this->ref = $this->lib;
512 512
 
513 513
 		if (!empty($this->id))
514 514
 		{
515 515
 			$link = '<a href="'.DOL_URL_ROOT.'/compta/payment/card.php?id='.$this->id.'">';
516
-			$linkend='</a>';
516
+			$linkend = '</a>';
517 517
 
518
-			if ($withpicto) $result.=($link.img_object($langs->trans("ShowPayment").': '.$this->ref,'payment').$linkend.' ');
519
-			if ($withpicto && $withpicto != 2) $result.=' ';
520
-			if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$linkend;
518
+			if ($withpicto) $result .= ($link.img_object($langs->trans("ShowPayment").': '.$this->ref, 'payment').$linkend.' ');
519
+			if ($withpicto && $withpicto != 2) $result .= ' ';
520
+			if ($withpicto != 2) $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend;
521 521
 		}
522 522
 
523 523
 		return $result;
Please login to merge, or discard this patch.
htdocs/main.inc.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1590,7 +1590,7 @@  discard block
 block discarded – undo
1590 1590
 /**
1591 1591
  *  Show left menu bar
1592 1592
  *
1593
- *  @param  array	$menu_array_before 	       	Table of menu entries to show before entries of menu handler. This param is deprectaed and must be provided to ''.
1593
+ *  @param  string	$menu_array_before 	       	Table of menu entries to show before entries of menu handler. This param is deprectaed and must be provided to ''.
1594 1594
  *  @param  string	$helppagename    	       	Name of wiki page for help ('' by default).
1595 1595
  * 				     		                   	Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage
1596 1596
  * 									         		       For other external page: http://server/url
@@ -1598,7 +1598,7 @@  discard block
 block discarded – undo
1598 1598
  *  @param  array	$menu_array_after           Table of menu entries to show after entries of menu handler
1599 1599
  *  @param  int		$leftmenuwithoutmainarea    Must be set to 1. 0 by default for backward compatibility with old modules.
1600 1600
  *  @param  string	$title                      Title of web page
1601
- *  @param  string  $acceptdelayedhtml          1 if caller request to have html delayed content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect)
1601
+ *  @param  integer  $acceptdelayedhtml          1 if caller request to have html delayed content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect)
1602 1602
  *  @return	void
1603 1603
  */
1604 1604
 function left_menu($menu_array_before, $helppagename='', $notused='', $menu_array_after='', $leftmenuwithoutmainarea=0, $title='', $acceptdelayedhtml=0)
Please login to merge, or discard this patch.
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -1279,97 +1279,97 @@
 block discarded – undo
1279 1279
                 print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1280 1280
                 print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jszip/jszip.min.js"></script>'."\n";
1281 1281
             }*/
1282
-            // jQuery Timepicker
1283
-            if (! empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER'))
1284
-            {
1285
-            	print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1286
-            	print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/timepicker.js.php?lang='.$langs->defaultlang.($ext?'&amp;'.$ext:'').'"></script>'."\n";
1287
-            }
1288
-            if (! defined('DISABLE_SELECT2') && (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')))     // jQuery plugin "mutiselect", "multiple-select", "select2", ...
1289
-            {
1290
-            	$tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT;
1291
-            	print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/'.$tmpplugin.'/dist/js/'.$tmpplugin.'.full.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";	// We include full because we need the support of containerCssClass
1292
-            }
1293
-        }
1294
-
1295
-        if (! $disablejs && ! empty($conf->use_javascript_ajax))
1296
-        {
1297
-            // CKEditor
1298
-            if (! empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') && ! defined('DISABLE_CKEDITOR'))
1299
-            {
1300
-                print '<!-- Includes JS for CKEditor -->'."\n";
1301
-                $pathckeditor = DOL_URL_ROOT . '/includes/ckeditor/ckeditor/';
1302
-                $jsckeditor='ckeditor.js';
1303
-                if (constant('JS_CKEDITOR'))	// To use external ckeditor 4 js lib
1304
-                {
1305
-                	$pathckeditor=constant('JS_CKEDITOR');
1306
-                }
1307
-                print '<script type="text/javascript">';
1308
-                print 'var CKEDITOR_BASEPATH = \''.$pathckeditor.'\';'."\n";
1309
-                print 'var ckeditorConfig = \''.dol_buildpath($themesubdir.'/theme/'.$conf->theme.'/ckeditor/config.js'.($ext?'?'.$ext:''),1).'\';'."\n";		// $themesubdir='' in standard usage
1310
-                print 'var ckeditorFilebrowserBrowseUrl = \''.DOL_URL_ROOT.'/core/filemanagerdol/browser/default/browser.php?Connector='.DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php\';'."\n";
1311
-                print 'var ckeditorFilebrowserImageBrowseUrl = \''.DOL_URL_ROOT.'/core/filemanagerdol/browser/default/browser.php?Type=Image&Connector='.DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php\';'."\n";
1312
-                print '</script>'."\n";
1313
-                print '<script type="text/javascript" src="'.$pathckeditor.$jsckeditor.($ext?'?'.$ext:'').'"></script>'."\n";
1314
-            }
1315
-
1316
-            // Browser notifications
1317
-            if (! defined('DISABLE_BROWSER_NOTIF'))
1318
-            {
1319
-                $enablebrowsernotif=false;
1320
-                if (! empty($conf->agenda->enabled) && ! empty($conf->global->AGENDA_REMINDER_BROWSER)) $enablebrowsernotif=true;
1321
-                if ($conf->browser->layout == 'phone') $enablebrowsernotif=false;
1322
-                if ($enablebrowsernotif)
1323
-                {
1324
-                    print '<!-- Includes JS of Dolibarr (brwoser layout = '.$conf->browser->layout.')-->'."\n";
1325
-                    print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/lib_notification.js.php'.($ext?'?'.$ext:'').'"></script>'."\n";
1326
-                }
1327
-            }
1328
-
1329
-            // Global js function
1330
-            print '<!-- Includes JS of Dolibarr -->'."\n";
1331
-            print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/lib_head.js.php?lang='.$langs->defaultlang.($ext?'&amp;'.$ext:'').'"></script>'."\n";
1332
-
1333
-            // JS forced by modules (relative url starting with /)
1334
-            if (! empty($conf->modules_parts['js']))		// $conf->modules_parts['js'] is array('module'=>array('file1','file2'))
1335
-        	{
1336
-        		$arrayjs=(array) $conf->modules_parts['js'];
1337
-	            foreach($arrayjs as $modjs => $filesjs)
1338
-	            {
1339
-        			$filesjs=(array) $filesjs;	// To be sure filejs is an array
1340
-		            foreach($filesjs as $jsfile)
1341
-		            {
1342
-	    	    		// jsfile is a relative path
1343
-	        	    	print '<!-- Include JS added by module '.$modjs. '-->'."\n".'<script type="text/javascript" src="'.dol_buildpath($jsfile,1).'"></script>'."\n";
1344
-		            }
1345
-	            }
1346
-        	}
1347
-            // JS forced by page in top_htmlhead (relative url starting with /)
1348
-            if (is_array($arrayofjs))
1349
-            {
1350
-                print '<!-- Includes JS added by page -->'."\n";
1351
-                foreach($arrayofjs as $jsfile)
1352
-                {
1353
-                    if (preg_match('/^http/i',$jsfile))
1354
-                    {
1355
-                        print '<script type="text/javascript" src="'.$jsfile.'"></script>'."\n";
1356
-                    }
1357
-                    else
1358
-                    {
1359
-                        if (! preg_match('/^\//',$jsfile)) $jsfile='/'.$jsfile;	// For backward compatibility
1360
-                        print '<script type="text/javascript" src="'.dol_buildpath($jsfile,1).'"></script>'."\n";
1361
-                    }
1362
-                }
1363
-            }
1364
-        }
1365
-
1366
-        if (! empty($head)) print $head."\n";
1367
-        if (! empty($conf->global->MAIN_HTML_HEADER)) print $conf->global->MAIN_HTML_HEADER."\n";
1368
-
1369
-        print "</head>\n\n";
1370
-    }
1371
-
1372
-    $conf->headerdone=1;	// To tell header was output
1282
+			// jQuery Timepicker
1283
+			if (! empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER'))
1284
+			{
1285
+				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1286
+				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/timepicker.js.php?lang='.$langs->defaultlang.($ext?'&amp;'.$ext:'').'"></script>'."\n";
1287
+			}
1288
+			if (! defined('DISABLE_SELECT2') && (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')))     // jQuery plugin "mutiselect", "multiple-select", "select2", ...
1289
+			{
1290
+				$tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT;
1291
+				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/'.$tmpplugin.'/dist/js/'.$tmpplugin.'.full.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";	// We include full because we need the support of containerCssClass
1292
+			}
1293
+		}
1294
+
1295
+		if (! $disablejs && ! empty($conf->use_javascript_ajax))
1296
+		{
1297
+			// CKEditor
1298
+			if (! empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') && ! defined('DISABLE_CKEDITOR'))
1299
+			{
1300
+				print '<!-- Includes JS for CKEditor -->'."\n";
1301
+				$pathckeditor = DOL_URL_ROOT . '/includes/ckeditor/ckeditor/';
1302
+				$jsckeditor='ckeditor.js';
1303
+				if (constant('JS_CKEDITOR'))	// To use external ckeditor 4 js lib
1304
+				{
1305
+					$pathckeditor=constant('JS_CKEDITOR');
1306
+				}
1307
+				print '<script type="text/javascript">';
1308
+				print 'var CKEDITOR_BASEPATH = \''.$pathckeditor.'\';'."\n";
1309
+				print 'var ckeditorConfig = \''.dol_buildpath($themesubdir.'/theme/'.$conf->theme.'/ckeditor/config.js'.($ext?'?'.$ext:''),1).'\';'."\n";		// $themesubdir='' in standard usage
1310
+				print 'var ckeditorFilebrowserBrowseUrl = \''.DOL_URL_ROOT.'/core/filemanagerdol/browser/default/browser.php?Connector='.DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php\';'."\n";
1311
+				print 'var ckeditorFilebrowserImageBrowseUrl = \''.DOL_URL_ROOT.'/core/filemanagerdol/browser/default/browser.php?Type=Image&Connector='.DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php\';'."\n";
1312
+				print '</script>'."\n";
1313
+				print '<script type="text/javascript" src="'.$pathckeditor.$jsckeditor.($ext?'?'.$ext:'').'"></script>'."\n";
1314
+			}
1315
+
1316
+			// Browser notifications
1317
+			if (! defined('DISABLE_BROWSER_NOTIF'))
1318
+			{
1319
+				$enablebrowsernotif=false;
1320
+				if (! empty($conf->agenda->enabled) && ! empty($conf->global->AGENDA_REMINDER_BROWSER)) $enablebrowsernotif=true;
1321
+				if ($conf->browser->layout == 'phone') $enablebrowsernotif=false;
1322
+				if ($enablebrowsernotif)
1323
+				{
1324
+					print '<!-- Includes JS of Dolibarr (brwoser layout = '.$conf->browser->layout.')-->'."\n";
1325
+					print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/lib_notification.js.php'.($ext?'?'.$ext:'').'"></script>'."\n";
1326
+				}
1327
+			}
1328
+
1329
+			// Global js function
1330
+			print '<!-- Includes JS of Dolibarr -->'."\n";
1331
+			print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/lib_head.js.php?lang='.$langs->defaultlang.($ext?'&amp;'.$ext:'').'"></script>'."\n";
1332
+
1333
+			// JS forced by modules (relative url starting with /)
1334
+			if (! empty($conf->modules_parts['js']))		// $conf->modules_parts['js'] is array('module'=>array('file1','file2'))
1335
+			{
1336
+				$arrayjs=(array) $conf->modules_parts['js'];
1337
+				foreach($arrayjs as $modjs => $filesjs)
1338
+				{
1339
+					$filesjs=(array) $filesjs;	// To be sure filejs is an array
1340
+					foreach($filesjs as $jsfile)
1341
+					{
1342
+						// jsfile is a relative path
1343
+						print '<!-- Include JS added by module '.$modjs. '-->'."\n".'<script type="text/javascript" src="'.dol_buildpath($jsfile,1).'"></script>'."\n";
1344
+					}
1345
+				}
1346
+			}
1347
+			// JS forced by page in top_htmlhead (relative url starting with /)
1348
+			if (is_array($arrayofjs))
1349
+			{
1350
+				print '<!-- Includes JS added by page -->'."\n";
1351
+				foreach($arrayofjs as $jsfile)
1352
+				{
1353
+					if (preg_match('/^http/i',$jsfile))
1354
+					{
1355
+						print '<script type="text/javascript" src="'.$jsfile.'"></script>'."\n";
1356
+					}
1357
+					else
1358
+					{
1359
+						if (! preg_match('/^\//',$jsfile)) $jsfile='/'.$jsfile;	// For backward compatibility
1360
+						print '<script type="text/javascript" src="'.dol_buildpath($jsfile,1).'"></script>'."\n";
1361
+					}
1362
+				}
1363
+			}
1364
+		}
1365
+
1366
+		if (! empty($head)) print $head."\n";
1367
+		if (! empty($conf->global->MAIN_HTML_HEADER)) print $conf->global->MAIN_HTML_HEADER."\n";
1368
+
1369
+		print "</head>\n\n";
1370
+	}
1371
+
1372
+	$conf->headerdone=1;	// To tell header was output
1373 1373
 }
1374 1374
 
1375 1375
 
Please login to merge, or discard this patch.
Spacing   +605 added lines, -605 removed lines patch added patch discarded remove patch
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
 //@ini_set('memory_limit', '128M');	// This may be useless if memory is hard limited by your PHP
36 36
 
37 37
 // For optional tuning. Enabled if environment variable MAIN_SHOW_TUNING_INFO is defined.
38
-$micro_start_time=0;
39
-if (! empty($_SERVER['MAIN_SHOW_TUNING_INFO']))
38
+$micro_start_time = 0;
39
+if (!empty($_SERVER['MAIN_SHOW_TUNING_INFO']))
40 40
 {
41 41
 	list($usec, $sec) = explode(" ", microtime());
42
-	$micro_start_time=((float) $usec + (float) $sec);
42
+	$micro_start_time = ((float) $usec + (float) $sec);
43 43
 	// Add Xdebug code coverage
44 44
 	//define('XDEBUGCOVERAGE',1);
45 45
 	if (defined('XDEBUGCOVERAGE')) {
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
 	// For SQL Injection (only GET and POST are used to be included into bad escaped SQL requests)
82 82
 	if ($type != 2)
83 83
 	{
84
-		$inj += preg_match('/delete\s+from/i',	 $val);
85
-		$inj += preg_match('/create\s+table/i',	 $val);
86
-		$inj += preg_match('/update.+set.+=/i',  $val);
87
-		$inj += preg_match('/insert\s+into/i', 	 $val);
88
-		$inj += preg_match('/select.+from/i', 	 $val);
89
-		$inj += preg_match('/union.+select/i', 	 $val);
90
-		$inj += preg_match('/into\s+(outfile|dumpfile)/i',  $val);
91
-		$inj += preg_match('/(\.\.%2f)+/i',		 $val);
84
+		$inj += preg_match('/delete\s+from/i', $val);
85
+		$inj += preg_match('/create\s+table/i', $val);
86
+		$inj += preg_match('/update.+set.+=/i', $val);
87
+		$inj += preg_match('/insert\s+into/i', $val);
88
+		$inj += preg_match('/select.+from/i', $val);
89
+		$inj += preg_match('/union.+select/i', $val);
90
+		$inj += preg_match('/into\s+(outfile|dumpfile)/i', $val);
91
+		$inj += preg_match('/(\.\.%2f)+/i', $val);
92 92
 	}
93 93
 	// For XSS Injection done by adding javascript with script
94 94
 	// This is all cases a browser consider text is javascript:
@@ -97,23 +97,23 @@  discard block
 block discarded – undo
97 97
 	// More on https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
98 98
 	$inj += preg_match('/<script/i', $val);
99 99
 	$inj += preg_match('/<iframe/i', $val);
100
-	$inj += preg_match('/Set\.constructor/i', $val);	// ECMA script 6
101
-	if (! defined('NOSTYLECHECK')) $inj += preg_match('/<style/i', $val);
100
+	$inj += preg_match('/Set\.constructor/i', $val); // ECMA script 6
101
+	if (!defined('NOSTYLECHECK')) $inj += preg_match('/<style/i', $val);
102 102
 	$inj += preg_match('/base[\s]+href/si', $val);
103
-	$inj += preg_match('/<.*onmouse/si', $val);       // onmousexxx can be set on img or any html tag like <img title='...' onmouseover=alert(1)>
104
-	$inj += preg_match('/onerror\s*=/i', $val);       // onerror can be set on img or any html tag like <img title='...' onerror = alert(1)>
105
-	$inj += preg_match('/onfocus\s*=/i', $val);       // onfocus can be set on input text html tag like <input type='text' value='...' onfocus = alert(1)>
106
-	$inj += preg_match('/onload\s*=/i', $val);        // onload can be set on svg tag <svg/onload=alert(1)> or other tag like body <body onload=alert(1)>
103
+	$inj += preg_match('/<.*onmouse/si', $val); // onmousexxx can be set on img or any html tag like <img title='...' onmouseover=alert(1)>
104
+	$inj += preg_match('/onerror\s*=/i', $val); // onerror can be set on img or any html tag like <img title='...' onerror = alert(1)>
105
+	$inj += preg_match('/onfocus\s*=/i', $val); // onfocus can be set on input text html tag like <input type='text' value='...' onfocus = alert(1)>
106
+	$inj += preg_match('/onload\s*=/i', $val); // onload can be set on svg tag <svg/onload=alert(1)> or other tag like body <body onload=alert(1)>
107 107
 	//$inj += preg_match('/on[A-Z][a-z]+\*=/', $val);   // To lock event handlers onAbort(), ...
108
-	$inj += preg_match('/&#58;|&#0000058|&#x3A/i', $val);		// refused string ':' encoded (no reason to have it encoded) to lock 'javascript:...'
108
+	$inj += preg_match('/&#58;|&#0000058|&#x3A/i', $val); // refused string ':' encoded (no reason to have it encoded) to lock 'javascript:...'
109 109
 	//if ($type == 1)
110 110
 	//{
111 111
 		$inj += preg_match('/javascript:/i', $val);
112 112
 		$inj += preg_match('/vbscript:/i', $val);
113 113
 	//}
114 114
 	// For XSS Injection done by adding javascript closing html tags like with onmousemove, etc... (closing a src or href tag with not cleaned param)
115
-	if ($type == 1) $inj += preg_match('/"/i', $val);		// We refused " in GET parameters value
116
-	if ($type == 2) $inj += preg_match('/[;"]/', $val);		// PHP_SELF is a file system path. It can contains spaces.
115
+	if ($type == 1) $inj += preg_match('/"/i', $val); // We refused " in GET parameters value
116
+	if ($type == 2) $inj += preg_match('/[;"]/', $val); // PHP_SELF is a file system path. It can contains spaces.
117 117
 	return $inj;
118 118
 }
119 119
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	{
131 131
 		foreach ($var as $key => $value)
132 132
 		{
133
-			if (analyseVarsForSqlAndScriptsInjection($value,$type))
133
+			if (analyseVarsForSqlAndScriptsInjection($value, $type))
134 134
 			{
135 135
 				$var[$key] = $value;
136 136
 			}
@@ -144,36 +144,36 @@  discard block
 block discarded – undo
144 144
 	}
145 145
 	else
146 146
 	{
147
-		return (test_sql_and_script_inject($var,$type) <= 0);
147
+		return (test_sql_and_script_inject($var, $type) <= 0);
148 148
 	}
149 149
 }
150 150
 
151 151
 
152 152
 // Check consistency of NOREQUIREXXX DEFINES
153
-if ((defined('NOREQUIREDB') || defined('NOREQUIRETRAN')) && ! defined('NOREQUIREMENU')) dol_print_error('','If define NOREQUIREDB or NOREQUIRETRAN are set, you must also set NOREQUIREMENU or not use them');
153
+if ((defined('NOREQUIREDB') || defined('NOREQUIRETRAN')) && !defined('NOREQUIREMENU')) dol_print_error('', 'If define NOREQUIREDB or NOREQUIRETRAN are set, you must also set NOREQUIREMENU or not use them');
154 154
 
155 155
 // Sanity check on URL
156
-if (! empty($_SERVER["PHP_SELF"]))
156
+if (!empty($_SERVER["PHP_SELF"]))
157 157
 {
158
-	$morevaltochecklikepost=array($_SERVER["PHP_SELF"]);
159
-	analyseVarsForSqlAndScriptsInjection($morevaltochecklikepost,2);
158
+	$morevaltochecklikepost = array($_SERVER["PHP_SELF"]);
159
+	analyseVarsForSqlAndScriptsInjection($morevaltochecklikepost, 2);
160 160
 }
161 161
 // Sanity check on GET parameters
162
-if (! defined('NOSCANGETFORINJECTION') && ! empty($_SERVER["QUERY_STRING"]))
162
+if (!defined('NOSCANGETFORINJECTION') && !empty($_SERVER["QUERY_STRING"]))
163 163
 {
164
-	$morevaltochecklikeget=array($_SERVER["QUERY_STRING"]);
165
-	analyseVarsForSqlAndScriptsInjection($morevaltochecklikeget,1);
164
+	$morevaltochecklikeget = array($_SERVER["QUERY_STRING"]);
165
+	analyseVarsForSqlAndScriptsInjection($morevaltochecklikeget, 1);
166 166
 }
167 167
 // Sanity check on POST
168
-if (! defined('NOSCANPOSTFORINJECTION'))
168
+if (!defined('NOSCANPOSTFORINJECTION'))
169 169
 {
170
-	analyseVarsForSqlAndScriptsInjection($_POST,0);
170
+	analyseVarsForSqlAndScriptsInjection($_POST, 0);
171 171
 }
172 172
 
173 173
 // This is to make Dolibarr working with Plesk
174
-if (! empty($_SERVER['DOCUMENT_ROOT']) && substr($_SERVER['DOCUMENT_ROOT'], -6) !== 'htdocs')
174
+if (!empty($_SERVER['DOCUMENT_ROOT']) && substr($_SERVER['DOCUMENT_ROOT'], -6) !== 'htdocs')
175 175
 {
176
-	set_include_path($_SERVER['DOCUMENT_ROOT'] . '/htdocs');
176
+	set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs');
177 177
 }
178 178
 
179 179
 // Include the conf.php and functions.lib.php
@@ -182,34 +182,34 @@  discard block
 block discarded – undo
182 182
 // If there is a POST parameter to tell to save automatically some POST parameters into cookies, we do it.
183 183
 // This is used for example by form of boxes to save personalization of some options.
184 184
 // DOL_AUTOSET_COOKIE=cookiename:val1,val2 and  cookiename_val1=aaa cookiename_val2=bbb will set cookie_name with value json_encode(array('val1'=> , ))
185
-if (! empty($_POST["DOL_AUTOSET_COOKIE"]))
185
+if (!empty($_POST["DOL_AUTOSET_COOKIE"]))
186 186
 {
187
-	$tmpautoset=explode(':',$_POST["DOL_AUTOSET_COOKIE"],2);
188
-	$tmplist=explode(',',$tmpautoset[1]);
189
-	$cookiearrayvalue='';
187
+	$tmpautoset = explode(':', $_POST["DOL_AUTOSET_COOKIE"], 2);
188
+	$tmplist = explode(',', $tmpautoset[1]);
189
+	$cookiearrayvalue = '';
190 190
 	foreach ($tmplist as $tmpkey)
191 191
 	{
192
-		$postkey=$tmpautoset[0].'_'.$tmpkey;
192
+		$postkey = $tmpautoset[0].'_'.$tmpkey;
193 193
 		//var_dump('tmpkey='.$tmpkey.' postkey='.$postkey.' value='.$_POST[$postkey]);
194
-		if (! empty($_POST[$postkey])) $cookiearrayvalue[$tmpkey]=$_POST[$postkey];
194
+		if (!empty($_POST[$postkey])) $cookiearrayvalue[$tmpkey] = $_POST[$postkey];
195 195
 	}
196
-	$cookiename=$tmpautoset[0];
197
-	$cookievalue=json_encode($cookiearrayvalue);
196
+	$cookiename = $tmpautoset[0];
197
+	$cookievalue = json_encode($cookiearrayvalue);
198 198
 	//var_dump('setcookie cookiename='.$cookiename.' cookievalue='.$cookievalue);
199
-	setcookie($cookiename, empty($cookievalue)?'':$cookievalue, empty($cookievalue)?0:(time()+(86400*354)), '/', null, false, true);	// keep cookie 1 year and add tag httponly
199
+	setcookie($cookiename, empty($cookievalue) ? '' : $cookievalue, empty($cookievalue) ? 0 : (time() + (86400 * 354)), '/', null, false, true); // keep cookie 1 year and add tag httponly
200 200
 	if (empty($cookievalue)) unset($_COOKIE[$cookiename]);
201 201
 }
202 202
 
203 203
 // Init session. Name of session is specific to Dolibarr instance.
204
-$prefix=dol_getprefix();
205
-$sessionname='DOLSESSID_'.$prefix;
206
-$sessiontimeout='DOLSESSTIMEOUT_'.$prefix;
207
-if (! empty($_COOKIE[$sessiontimeout])) ini_set('session.gc_maxlifetime',$_COOKIE[$sessiontimeout]);
204
+$prefix = dol_getprefix();
205
+$sessionname = 'DOLSESSID_'.$prefix;
206
+$sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix;
207
+if (!empty($_COOKIE[$sessiontimeout])) ini_set('session.gc_maxlifetime', $_COOKIE[$sessiontimeout]);
208 208
 session_name($sessionname);
209
-session_set_cookie_params(0, '/', null, false, true);   // Add tag httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start.
209
+session_set_cookie_params(0, '/', null, false, true); // Add tag httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start.
210 210
 // This create lock released until session_write_close() or end of page.
211 211
 // We need this lock as long as we read/write $_SESSION ['vars']. We can close released when finished.
212
-if (! defined('NOSESSION'))
212
+if (!defined('NOSESSION'))
213 213
 {
214 214
 	session_start();
215 215
 	if (ini_get('register_globals'))    // Deprecated in 5.3 and removed in 5.4. To solve bug in using $_SESSION
@@ -230,42 +230,42 @@  discard block
 block discarded – undo
230 230
 // Detection browser
231 231
 if (isset($_SERVER["HTTP_USER_AGENT"]))
232 232
 {
233
-	$tmp=getBrowserInfo($_SERVER["HTTP_USER_AGENT"]);
234
-	$conf->browser->name=$tmp['browsername'];
235
-	$conf->browser->os=$tmp['browseros'];
236
-	$conf->browser->version=$tmp['browserversion'];
237
-	$conf->browser->layout=$tmp['layout'];     // 'classic', 'phone', 'tablet'
238
-	$conf->browser->phone=$tmp['phone'];	   // TODO deprecated, use ->layout
239
-	$conf->browser->tablet=$tmp['tablet'];	   // TODO deprecated, use ->layout
233
+	$tmp = getBrowserInfo($_SERVER["HTTP_USER_AGENT"]);
234
+	$conf->browser->name = $tmp['browsername'];
235
+	$conf->browser->os = $tmp['browseros'];
236
+	$conf->browser->version = $tmp['browserversion'];
237
+	$conf->browser->layout = $tmp['layout']; // 'classic', 'phone', 'tablet'
238
+	$conf->browser->phone = $tmp['phone']; // TODO deprecated, use ->layout
239
+	$conf->browser->tablet = $tmp['tablet']; // TODO deprecated, use ->layout
240 240
 	//var_dump($conf->browser);
241 241
 
242
-	if ($conf->browser->layout == 'phone') $conf->dol_no_mouse_hover=1;
243
-	if ($conf->browser->layout == 'phone') $conf->global->MAIN_TESTMENUHIDER=1;
242
+	if ($conf->browser->layout == 'phone') $conf->dol_no_mouse_hover = 1;
243
+	if ($conf->browser->layout == 'phone') $conf->global->MAIN_TESTMENUHIDER = 1;
244 244
 }
245 245
 
246 246
 // Force HTTPS if required ($conf->file->main_force_https is 0/1 or https dolibarr root url)
247 247
 // $_SERVER["HTTPS"] is 'on' when link is https, otherwise $_SERVER["HTTPS"] is empty or 'off'
248
-if (! empty($conf->file->main_force_https) && (empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on'))
248
+if (!empty($conf->file->main_force_https) && (empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on'))
249 249
 {
250
-	$newurl='';
250
+	$newurl = '';
251 251
 	if (is_numeric($conf->file->main_force_https))
252 252
 	{
253
-		if ($conf->file->main_force_https == '1' && ! empty($_SERVER["SCRIPT_URI"]))	// If SCRIPT_URI supported by server
253
+		if ($conf->file->main_force_https == '1' && !empty($_SERVER["SCRIPT_URI"]))	// If SCRIPT_URI supported by server
254 254
 		{
255
-			if (preg_match('/^http:/i',$_SERVER["SCRIPT_URI"]) && ! preg_match('/^https:/i',$_SERVER["SCRIPT_URI"]))	// If link is http
255
+			if (preg_match('/^http:/i', $_SERVER["SCRIPT_URI"]) && !preg_match('/^https:/i', $_SERVER["SCRIPT_URI"]))	// If link is http
256 256
 			{
257
-				$newurl=preg_replace('/^http:/i','https:',$_SERVER["SCRIPT_URI"]);
257
+				$newurl = preg_replace('/^http:/i', 'https:', $_SERVER["SCRIPT_URI"]);
258 258
 			}
259 259
 		}
260 260
 		else	// Check HTTPS environment variable (Apache/mod_ssl only)
261 261
 		{
262
-			$newurl=preg_replace('/^http:/i','https:',DOL_MAIN_URL_ROOT).$_SERVER["REQUEST_URI"];
262
+			$newurl = preg_replace('/^http:/i', 'https:', DOL_MAIN_URL_ROOT).$_SERVER["REQUEST_URI"];
263 263
 		}
264 264
 	}
265 265
 	else
266 266
 	{
267 267
 		// Check HTTPS environment variable (Apache/mod_ssl only)
268
-		$newurl=$conf->file->main_force_https.$_SERVER["REQUEST_URI"];
268
+		$newurl = $conf->file->main_force_https.$_SERVER["REQUEST_URI"];
269 269
 	}
270 270
 	// Start redirect
271 271
 	if ($newurl)
@@ -282,25 +282,25 @@  discard block
 block discarded – undo
282 282
 
283 283
 
284 284
 // Loading of additional presentation includes
285
-if (! defined('NOREQUIREHTML')) require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php';	    // Need 660ko memory (800ko in 2.2)
286
-if (! defined('NOREQUIREAJAX') && $conf->use_javascript_ajax) require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';	// Need 22ko memory
285
+if (!defined('NOREQUIREHTML')) require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; // Need 660ko memory (800ko in 2.2)
286
+if (!defined('NOREQUIREAJAX') && $conf->use_javascript_ajax) require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; // Need 22ko memory
287 287
 
288 288
 // If install or upgrade process not done or not completely finished, we call the install page.
289
-if (! empty($conf->global->MAIN_NOT_INSTALLED) || ! empty($conf->global->MAIN_NOT_UPGRADED))
289
+if (!empty($conf->global->MAIN_NOT_INSTALLED) || !empty($conf->global->MAIN_NOT_UPGRADED))
290 290
 {
291 291
 	dol_syslog("main.inc: A previous install or upgrade was not complete. Redirect to install page.", LOG_WARNING);
292 292
 	header("Location: ".DOL_URL_ROOT."/install/index.php");
293 293
 	exit;
294 294
 }
295 295
 // If an upgrade process is required, we call the install page.
296
-if ((! empty($conf->global->MAIN_VERSION_LAST_UPGRADE) && ($conf->global->MAIN_VERSION_LAST_UPGRADE != DOL_VERSION))
297
-|| (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) && ! empty($conf->global->MAIN_VERSION_LAST_INSTALL) && ($conf->global->MAIN_VERSION_LAST_INSTALL != DOL_VERSION)))
296
+if ((!empty($conf->global->MAIN_VERSION_LAST_UPGRADE) && ($conf->global->MAIN_VERSION_LAST_UPGRADE != DOL_VERSION))
297
+|| (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) && !empty($conf->global->MAIN_VERSION_LAST_INSTALL) && ($conf->global->MAIN_VERSION_LAST_INSTALL != DOL_VERSION)))
298 298
 {
299
-	$versiontocompare=empty($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_INSTALL:$conf->global->MAIN_VERSION_LAST_UPGRADE;
300
-	require_once DOL_DOCUMENT_ROOT .'/core/lib/admin.lib.php';
301
-	$dolibarrversionlastupgrade=preg_split('/[.-]/',$versiontocompare);
302
-	$dolibarrversionprogram=preg_split('/[.-]/',DOL_VERSION);
303
-	$rescomp=versioncompare($dolibarrversionprogram,$dolibarrversionlastupgrade);
299
+	$versiontocompare = empty($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_INSTALL : $conf->global->MAIN_VERSION_LAST_UPGRADE;
300
+	require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
301
+	$dolibarrversionlastupgrade = preg_split('/[.-]/', $versiontocompare);
302
+	$dolibarrversionprogram = preg_split('/[.-]/', DOL_VERSION);
303
+	$rescomp = versioncompare($dolibarrversionprogram, $dolibarrversionlastupgrade);
304 304
 	if ($rescomp > 0)   // Programs have a version higher than database. We did not add "&& $rescomp < 3" because we want upgrade process for build upgrades
305 305
 	{
306 306
 		dol_syslog("main.inc: database version ".$versiontocompare." is lower than programs version ".DOL_VERSION.". Redirect to install page.", LOG_WARNING);
@@ -310,18 +310,18 @@  discard block
 block discarded – undo
310 310
 }
311 311
 
312 312
 // Creation of a token against CSRF vulnerabilities
313
-if (! defined('NOTOKENRENEWAL'))
313
+if (!defined('NOTOKENRENEWAL'))
314 314
 {
315 315
 	// roulement des jetons car cree a chaque appel
316 316
 	if (isset($_SESSION['newtoken'])) $_SESSION['token'] = $_SESSION['newtoken'];
317 317
 
318 318
 	// Save in $_SESSION['newtoken'] what will be next token. Into forms, we will add param token = $_SESSION['newtoken']
319
-	$token = dol_hash(uniqid(mt_rand(),TRUE)); // Generates a hash of a random number
319
+	$token = dol_hash(uniqid(mt_rand(), TRUE)); // Generates a hash of a random number
320 320
 	$_SESSION['newtoken'] = $token;
321 321
 }
322
-if (! defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && ! empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN))	// Check validity of token, only if option enabled (this option breaks some features sometimes)
322
+if (!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN))	// Check validity of token, only if option enabled (this option breaks some features sometimes)
323 323
 {
324
-	if ($_SERVER['REQUEST_METHOD'] == 'POST' && ! GETPOST('token','alpha')) // Note, offender can still send request by GET
324
+	if ($_SERVER['REQUEST_METHOD'] == 'POST' && !GETPOST('token', 'alpha')) // Note, offender can still send request by GET
325 325
 	{
326 326
 		print "Access refused by CSRF protection in main.inc.php. Token not provided.\n";
327 327
 		print "If you access your server behind a proxy using url rewriting, you might check that all HTTP header is propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file).\n";
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 	{
332 332
 		if (GETPOST('token', 'alpha') != $_SESSION['token'])
333 333
 		{
334
-			dol_syslog("Invalid token in ".$_SERVER['HTTP_REFERER'].", action=".GETPOST('action','aZ09').", _POST['token']=".GETPOST('token','alpha').", _SESSION['token']=".$_SESSION['token'], LOG_WARNING);
334
+			dol_syslog("Invalid token in ".$_SERVER['HTTP_REFERER'].", action=".GETPOST('action', 'aZ09').", _POST['token']=".GETPOST('token', 'alpha').", _SESSION['token']=".$_SESSION['token'], LOG_WARNING);
335 335
 			//print 'Unset POST by CSRF protection in main.inc.php.';	// Do not output anything because this create problems when using the BACK button on browsers.
336 336
 			unset($_POST);
337 337
 		}
@@ -339,20 +339,20 @@  discard block
 block discarded – undo
339 339
 }
340 340
 
341 341
 // Disable modules (this must be after session_start and after conf has been loaded)
342
-if (GETPOST('disablemodules','alpha'))  $_SESSION["disablemodules"]=GETPOST('disablemodules','alpha');
343
-if (! empty($_SESSION["disablemodules"]))
342
+if (GETPOST('disablemodules', 'alpha'))  $_SESSION["disablemodules"] = GETPOST('disablemodules', 'alpha');
343
+if (!empty($_SESSION["disablemodules"]))
344 344
 {
345
-	$disabled_modules=explode(',',$_SESSION["disablemodules"]);
346
-	foreach($disabled_modules as $module)
345
+	$disabled_modules = explode(',', $_SESSION["disablemodules"]);
346
+	foreach ($disabled_modules as $module)
347 347
 	{
348 348
 		if ($module)
349 349
 		{
350
-			if (empty($conf->$module)) $conf->$module=new stdClass();
351
-			$conf->$module->enabled=false;
350
+			if (empty($conf->$module)) $conf->$module = new stdClass();
351
+			$conf->$module->enabled = false;
352 352
 			if ($module == 'fournisseur')		// Special case
353 353
 			{
354
-				$conf->supplier_order->enabled=0;
355
-				$conf->supplier_invoice->enabled=0;
354
+				$conf->supplier_order->enabled = 0;
355
+				$conf->supplier_invoice->enabled = 0;
356 356
 			}
357 357
 		}
358 358
 	}
@@ -362,120 +362,120 @@  discard block
 block discarded – undo
362 362
 /*
363 363
  * Phase authentication / login
364 364
  */
365
-$login='';
366
-if (! defined('NOLOGIN'))
365
+$login = '';
366
+if (!defined('NOLOGIN'))
367 367
 {
368 368
 	// $authmode lists the different means of identification to be tested in order of preference.
369 369
 	// Example: 'http', 'dolibarr', 'ldap', 'http,forceuser'
370 370
 
371 371
 	// Authentication mode
372
-	if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='http,dolibarr';
372
+	if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'http,dolibarr';
373 373
 	// Authentication mode: forceuser
374
-	if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user='auto';
374
+	if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user = 'auto';
375 375
 	// Set authmode
376
-	$authmode=explode(',',$dolibarr_main_authentication);
376
+	$authmode = explode(',', $dolibarr_main_authentication);
377 377
 
378 378
 	// No authentication mode
379
-	if (! count($authmode))
379
+	if (!count($authmode))
380 380
 	{
381 381
 		$langs->load('main');
382
-		dol_print_error('',$langs->trans("ErrorConfigParameterNotDefined",'dolibarr_main_authentication'));
382
+		dol_print_error('', $langs->trans("ErrorConfigParameterNotDefined", 'dolibarr_main_authentication'));
383 383
 		exit;
384 384
 	}
385 385
 
386 386
 	// If login request was already post, we retrieve login from the session
387 387
 	// Call module if not realized that his request.
388 388
 	// At the end of this phase, the variable $login is defined.
389
-	$resultFetchUser='';
390
-	$test=true;
391
-	if (! isset($_SESSION["dol_login"]))
389
+	$resultFetchUser = '';
390
+	$test = true;
391
+	if (!isset($_SESSION["dol_login"]))
392 392
 	{
393 393
 		// It is not already authenticated and it requests the login / password
394 394
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
395 395
 
396
-		$dol_dst_observed=GETPOST("dst_observed",'int',3);
397
-		$dol_dst_first=GETPOST("dst_first",'int',3);
398
-		$dol_dst_second=GETPOST("dst_second",'int',3);
399
-		$dol_screenwidth=GETPOST("screenwidth",'int',3);
400
-		$dol_screenheight=GETPOST("screenheight",'int',3);
401
-		$dol_hide_topmenu=GETPOST('dol_hide_topmenu','int',3);
402
-		$dol_hide_leftmenu=GETPOST('dol_hide_leftmenu','int',3);
403
-		$dol_optimize_smallscreen=GETPOST('dol_optimize_smallscreen','int',3);
404
-		$dol_no_mouse_hover=GETPOST('dol_no_mouse_hover','int',3);
405
-		$dol_use_jmobile=GETPOST('dol_use_jmobile','int',3);
396
+		$dol_dst_observed = GETPOST("dst_observed", 'int', 3);
397
+		$dol_dst_first = GETPOST("dst_first", 'int', 3);
398
+		$dol_dst_second = GETPOST("dst_second", 'int', 3);
399
+		$dol_screenwidth = GETPOST("screenwidth", 'int', 3);
400
+		$dol_screenheight = GETPOST("screenheight", 'int', 3);
401
+		$dol_hide_topmenu = GETPOST('dol_hide_topmenu', 'int', 3);
402
+		$dol_hide_leftmenu = GETPOST('dol_hide_leftmenu', 'int', 3);
403
+		$dol_optimize_smallscreen = GETPOST('dol_optimize_smallscreen', 'int', 3);
404
+		$dol_no_mouse_hover = GETPOST('dol_no_mouse_hover', 'int', 3);
405
+		$dol_use_jmobile = GETPOST('dol_use_jmobile', 'int', 3);
406 406
 		//dol_syslog("POST key=".join(array_keys($_POST),',').' value='.join($_POST,','));
407 407
 
408 408
 		// If in demo mode, we check we go to home page through the public/demo/index.php page
409
-		if (! empty($dolibarr_main_demo) && $_SERVER['PHP_SELF'] == DOL_URL_ROOT.'/index.php')  // We ask index page
409
+		if (!empty($dolibarr_main_demo) && $_SERVER['PHP_SELF'] == DOL_URL_ROOT.'/index.php')  // We ask index page
410 410
 		{
411
-			if (empty($_SERVER['HTTP_REFERER']) || ! preg_match('/public/',$_SERVER['HTTP_REFERER']))
411
+			if (empty($_SERVER['HTTP_REFERER']) || !preg_match('/public/', $_SERVER['HTTP_REFERER']))
412 412
 			{
413 413
 				dol_syslog("Call index page from another url than demo page (call is done from page ".$_SERVER['HTTP_REFERER'].")");
414
-				$url='';
415
-				$url.=($url?'&':'').($dol_hide_topmenu?'dol_hide_topmenu='.$dol_hide_topmenu:'');
416
-				$url.=($url?'&':'').($dol_hide_leftmenu?'dol_hide_leftmenu='.$dol_hide_leftmenu:'');
417
-				$url.=($url?'&':'').($dol_optimize_smallscreen?'dol_optimize_smallscreen='.$dol_optimize_smallscreen:'');
418
-				$url.=($url?'&':'').($dol_no_mouse_hover?'dol_no_mouse_hover='.$dol_no_mouse_hover:'');
419
-				$url.=($url?'&':'').($dol_use_jmobile?'dol_use_jmobile='.$dol_use_jmobile:'');
420
-				$url=DOL_URL_ROOT.'/public/demo/index.php'.($url?'?'.$url:'');
414
+				$url = '';
415
+				$url .= ($url ? '&' : '').($dol_hide_topmenu ? 'dol_hide_topmenu='.$dol_hide_topmenu : '');
416
+				$url .= ($url ? '&' : '').($dol_hide_leftmenu ? 'dol_hide_leftmenu='.$dol_hide_leftmenu : '');
417
+				$url .= ($url ? '&' : '').($dol_optimize_smallscreen ? 'dol_optimize_smallscreen='.$dol_optimize_smallscreen : '');
418
+				$url .= ($url ? '&' : '').($dol_no_mouse_hover ? 'dol_no_mouse_hover='.$dol_no_mouse_hover : '');
419
+				$url .= ($url ? '&' : '').($dol_use_jmobile ? 'dol_use_jmobile='.$dol_use_jmobile : '');
420
+				$url = DOL_URL_ROOT.'/public/demo/index.php'.($url ? '?'.$url : '');
421 421
 				header("Location: ".$url);
422 422
 				exit;
423 423
 			}
424 424
 		}
425 425
 
426 426
 		// Verification security graphic code
427
-		if (GETPOST("username","alpha",2) && ! empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA))
427
+		if (GETPOST("username", "alpha", 2) && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA))
428 428
 		{
429 429
 			$sessionkey = 'dol_antispam_value';
430
-			$ok=(array_key_exists($sessionkey, $_SESSION) === TRUE && (strtolower($_SESSION[$sessionkey]) == strtolower($_POST['code'])));
430
+			$ok = (array_key_exists($sessionkey, $_SESSION) === TRUE && (strtolower($_SESSION[$sessionkey]) == strtolower($_POST['code'])));
431 431
 
432 432
 			// Check code
433
-			if (! $ok)
433
+			if (!$ok)
434 434
 			{
435 435
 				dol_syslog('Bad value for code, connexion refused');
436 436
 				$langs->load('main');
437 437
 				$langs->load('errors');
438 438
 
439
-				$_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadValueForCode");
440
-				$test=false;
439
+				$_SESSION["dol_loginmesg"] = $langs->trans("ErrorBadValueForCode");
440
+				$test = false;
441 441
 
442 442
 				// TODO @deprecated Remove this. Hook must be used, not this trigger.
443
-				$user->trigger_mesg='ErrorBadValueForCode - login='.GETPOST("username","alpha",2);
443
+				$user->trigger_mesg = 'ErrorBadValueForCode - login='.GETPOST("username", "alpha", 2);
444 444
 				// Call of triggers
445
-				include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
446
-				$interface=new Interfaces($db);
447
-				$result=$interface->run_triggers('USER_LOGIN_FAILED',$user,$user,$langs,$conf);
445
+				include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
446
+				$interface = new Interfaces($db);
447
+				$result = $interface->run_triggers('USER_LOGIN_FAILED', $user, $user, $langs, $conf);
448 448
 				if ($result < 0) {
449 449
 					$error++;
450 450
 				}
451 451
 				// End Call of triggers
452 452
 
453 453
 				// Hooks on failed login
454
-				$action='';
454
+				$action = '';
455 455
 				$hookmanager->initHooks(array('login'));
456
-				$parameters=array('dol_authmode'=>$dol_authmode, 'dol_loginmesg'=>$_SESSION["dol_loginmesg"]);
457
-				$reshook=$hookmanager->executeHooks('afterLoginFailed',$parameters,$user,$action);    // Note that $action and $object may have been modified by some hooks
456
+				$parameters = array('dol_authmode'=>$dol_authmode, 'dol_loginmesg'=>$_SESSION["dol_loginmesg"]);
457
+				$reshook = $hookmanager->executeHooks('afterLoginFailed', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks
458 458
 				if ($reshook < 0) $error++;
459 459
 
460 460
 				// Note: exit is done later
461 461
 			}
462 462
 		}
463 463
 
464
-		$usertotest		= (! empty($_COOKIE['login_dolibarr']) ? $_COOKIE['login_dolibarr'] : GETPOST("username","alpha",2));
465
-		$passwordtotest	= GETPOST('password','none',2);
466
-		$entitytotest	= (GETPOST('entity','int') ? GETPOST('entity','int') : (!empty($conf->entity) ? $conf->entity : 1));
464
+		$usertotest = (!empty($_COOKIE['login_dolibarr']) ? $_COOKIE['login_dolibarr'] : GETPOST("username", "alpha", 2));
465
+		$passwordtotest = GETPOST('password', 'none', 2);
466
+		$entitytotest = (GETPOST('entity', 'int') ? GETPOST('entity', 'int') : (!empty($conf->entity) ? $conf->entity : 1));
467 467
 
468 468
 		// Define if we received data to test the login.
469
-		$goontestloop=false;
470
-		if (isset($_SERVER["REMOTE_USER"]) && in_array('http',$authmode)) $goontestloop=true;
471
-		if ($dolibarr_main_authentication == 'forceuser' && ! empty($dolibarr_auto_user)) $goontestloop=true;
472
-		if (GETPOST("username","alpha",2) || ! empty($_COOKIE['login_dolibarr']) || GETPOST('openid_mode','alpha',1)) $goontestloop=true;
469
+		$goontestloop = false;
470
+		if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) $goontestloop = true;
471
+		if ($dolibarr_main_authentication == 'forceuser' && !empty($dolibarr_auto_user)) $goontestloop = true;
472
+		if (GETPOST("username", "alpha", 2) || !empty($_COOKIE['login_dolibarr']) || GETPOST('openid_mode', 'alpha', 1)) $goontestloop = true;
473 473
 
474
-		if (! is_object($langs)) // This can occurs when calling page with NOREQUIRETRAN defined, however we need langs for error messages.
474
+		if (!is_object($langs)) // This can occurs when calling page with NOREQUIRETRAN defined, however we need langs for error messages.
475 475
 		{
476 476
 			include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
477
-			$langs=new Translate("",$conf);
478
-			$langcode=(GETPOST('lang','aZ09',1)?GETPOST('lang','aZ09',1):(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT));
477
+			$langs = new Translate("", $conf);
478
+			$langcode = (GETPOST('lang', 'aZ09', 1) ?GETPOST('lang', 'aZ09', 1) : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT));
479 479
 			$langs->setDefaultLang($langcode);
480 480
 		}
481 481
 
@@ -484,53 +484,53 @@  discard block
 block discarded – undo
484 484
 		// If error, we will put error message in session under the name dol_loginmesg
485 485
 		if ($test && $goontestloop)
486 486
 		{
487
-			$login = checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmode);
487
+			$login = checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode);
488 488
 			if ($login)
489 489
 			{
490
-				$dol_authmode=$conf->authmode;	// This properties is defined only when logged, to say what mode was successfully used
491
-				$dol_tz=$_POST["tz"];
492
-				$dol_tz_string=$_POST["tz_string"];
493
-				$dol_tz_string=preg_replace('/\s*\(.+\)$/','',$dol_tz_string);
494
-				$dol_tz_string=preg_replace('/,/','/',$dol_tz_string);
495
-				$dol_tz_string=preg_replace('/\s/','_',$dol_tz_string);
496
-				$dol_dst=0;
490
+				$dol_authmode = $conf->authmode; // This properties is defined only when logged, to say what mode was successfully used
491
+				$dol_tz = $_POST["tz"];
492
+				$dol_tz_string = $_POST["tz_string"];
493
+				$dol_tz_string = preg_replace('/\s*\(.+\)$/', '', $dol_tz_string);
494
+				$dol_tz_string = preg_replace('/,/', '/', $dol_tz_string);
495
+				$dol_tz_string = preg_replace('/\s/', '_', $dol_tz_string);
496
+				$dol_dst = 0;
497 497
 				if (isset($_POST["dst_first"]) && isset($_POST["dst_second"]))
498 498
 				{
499 499
 					include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
500
-					$datenow=dol_now();
501
-					$datefirst=dol_stringtotime($_POST["dst_first"]);
502
-					$datesecond=dol_stringtotime($_POST["dst_second"]);
503
-					if ($datenow >= $datefirst && $datenow < $datesecond) $dol_dst=1;
500
+					$datenow = dol_now();
501
+					$datefirst = dol_stringtotime($_POST["dst_first"]);
502
+					$datesecond = dol_stringtotime($_POST["dst_second"]);
503
+					if ($datenow >= $datefirst && $datenow < $datesecond) $dol_dst = 1;
504 504
 				}
505 505
 				//print $datefirst.'-'.$datesecond.'-'.$datenow.'-'.$dol_tz.'-'.$dol_tzstring.'-'.$dol_dst; exit;
506 506
 			}
507 507
 
508
-			if (! $login)
508
+			if (!$login)
509 509
 			{
510
-				dol_syslog('Bad password, connexion refused',LOG_DEBUG);
510
+				dol_syslog('Bad password, connexion refused', LOG_DEBUG);
511 511
 				$langs->load('main');
512 512
 				$langs->load('errors');
513 513
 
514 514
 				// Bad password. No authmode has found a good password.
515 515
 				// We set a generic message if not defined inside function checkLoginPassEntity or subfunctions
516
-				if (empty($_SESSION["dol_loginmesg"])) $_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword");
516
+				if (empty($_SESSION["dol_loginmesg"])) $_SESSION["dol_loginmesg"] = $langs->trans("ErrorBadLoginPassword");
517 517
 
518 518
 				// TODO @deprecated Remove this. Hook must be used, not this trigger.
519
-				$user->trigger_mesg=$langs->trans("ErrorBadLoginPassword").' - login='.GETPOST("username","alpha",2);
519
+				$user->trigger_mesg = $langs->trans("ErrorBadLoginPassword").' - login='.GETPOST("username", "alpha", 2);
520 520
 				// Call of triggers
521 521
 				include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
522
-				$interface=new Interfaces($db);
523
-				$result=$interface->run_triggers('USER_LOGIN_FAILED',$user,$user,$langs,$conf,GETPOST("username","alpha",2));
522
+				$interface = new Interfaces($db);
523
+				$result = $interface->run_triggers('USER_LOGIN_FAILED', $user, $user, $langs, $conf, GETPOST("username", "alpha", 2));
524 524
 				if ($result < 0) {
525 525
 					$error++;
526 526
 				}
527 527
 				// End Call of triggers
528 528
 
529 529
 				// Hooks on failed login
530
-				$action='';
530
+				$action = '';
531 531
 				$hookmanager->initHooks(array('login'));
532
-				$parameters=array('dol_authmode'=>$dol_authmode, 'dol_loginmesg'=>$_SESSION["dol_loginmesg"]);
533
-				$reshook=$hookmanager->executeHooks('afterLoginFailed',$parameters,$user,$action);    // Note that $action and $object may have been modified by some hooks
532
+				$parameters = array('dol_authmode'=>$dol_authmode, 'dol_loginmesg'=>$_SESSION["dol_loginmesg"]);
533
+				$reshook = $hookmanager->executeHooks('afterLoginFailed', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks
534 534
 				if ($reshook < 0) $error++;
535 535
 
536 536
 				// Note: exit is done in next chapter
@@ -538,123 +538,123 @@  discard block
 block discarded – undo
538 538
 		}
539 539
 
540 540
 		// End test login / passwords
541
-		if (! $login || (in_array('ldap',$authmode) && empty($passwordtotest)))	// With LDAP we refused empty password because some LDAP are "opened" for anonymous access so connexion is a success.
541
+		if (!$login || (in_array('ldap', $authmode) && empty($passwordtotest)))	// With LDAP we refused empty password because some LDAP are "opened" for anonymous access so connexion is a success.
542 542
 		{
543 543
 			// No data to test login, so we show the login page
544 544
 			dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." showing the login form and exit");
545 545
 			if (defined('NOREDIRECTBYMAINTOLOGIN')) return 'ERROR_NOT_LOGGED';
546
-			else dol_loginfunction($langs,$conf,(! empty($mysoc)?$mysoc:''));
546
+			else dol_loginfunction($langs, $conf, (!empty($mysoc) ? $mysoc : ''));
547 547
 			exit;
548 548
 		}
549 549
 
550
-		$resultFetchUser=$user->fetch('', $login, '', 1, ($entitytotest > 0 ? $entitytotest : -1));
550
+		$resultFetchUser = $user->fetch('', $login, '', 1, ($entitytotest > 0 ? $entitytotest : -1));
551 551
 		if ($resultFetchUser <= 0)
552 552
 		{
553 553
 			dol_syslog('User not found, connexion refused');
554 554
 			session_destroy();
555 555
 			session_name($sessionname);
556
-			session_set_cookie_params(0, '/', null, false, true);   // Add tag httponly on session cookie
557
-			session_start();    // Fixing the bug of register_globals here is useless since session is empty
556
+			session_set_cookie_params(0, '/', null, false, true); // Add tag httponly on session cookie
557
+			session_start(); // Fixing the bug of register_globals here is useless since session is empty
558 558
 
559 559
 			if ($resultFetchUser == 0)
560 560
 			{
561 561
 				$langs->load('main');
562 562
 				$langs->load('errors');
563 563
 
564
-				$_SESSION["dol_loginmesg"]=$langs->trans("ErrorCantLoadUserFromDolibarrDatabase",$login);
564
+				$_SESSION["dol_loginmesg"] = $langs->trans("ErrorCantLoadUserFromDolibarrDatabase", $login);
565 565
 
566 566
 				// TODO @deprecated Remove this. Hook must be used, not this trigger.
567
-				$user->trigger_mesg='ErrorCantLoadUserFromDolibarrDatabase - login='.$login;
567
+				$user->trigger_mesg = 'ErrorCantLoadUserFromDolibarrDatabase - login='.$login;
568 568
 			}
569 569
 			if ($resultFetchUser < 0)
570 570
 			{
571
-				$_SESSION["dol_loginmesg"]=$user->error;
571
+				$_SESSION["dol_loginmesg"] = $user->error;
572 572
 
573 573
 				// TODO @deprecated Remove this. Hook must be used, not this trigger.
574
-				$user->trigger_mesg=$user->error;
574
+				$user->trigger_mesg = $user->error;
575 575
 			}
576 576
 
577 577
 			// Call triggers
578
-			include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
579
-			$interface=new Interfaces($db);
580
-			$result=$interface->run_triggers('USER_LOGIN_FAILED',$user,$user,$langs,$conf);
578
+			include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
579
+			$interface = new Interfaces($db);
580
+			$result = $interface->run_triggers('USER_LOGIN_FAILED', $user, $user, $langs, $conf);
581 581
 			if ($result < 0) {
582 582
 				$error++;
583 583
 			}
584 584
 			// End call triggers
585 585
 
586 586
 			// Hooks on failed login
587
-			$action='';
587
+			$action = '';
588 588
 			$hookmanager->initHooks(array('login'));
589
-			$parameters=array('dol_authmode'=>$dol_authmode, 'dol_loginmesg'=>$_SESSION["dol_loginmesg"]);
590
-			$reshook=$hookmanager->executeHooks('afterLoginFailed',$parameters,$user,$action);    // Note that $action and $object may have been modified by some hooks
589
+			$parameters = array('dol_authmode'=>$dol_authmode, 'dol_loginmesg'=>$_SESSION["dol_loginmesg"]);
590
+			$reshook = $hookmanager->executeHooks('afterLoginFailed', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks
591 591
 			if ($reshook < 0) $error++;
592 592
 
593
-			$paramsurl=array();
594
-			if (GETPOST('textbrowser','int')) $paramsurl[]='textbrowser='.GETPOST('textbrowser','int');
595
-			if (GETPOST('nojs','int'))        $paramsurl[]='nojs='.GETPOST('nojs','int');
596
-			if (GETPOST('lang','aZ09'))       $paramsurl[]='lang='.GETPOST('lang','aZ09');
597
-			header('Location: '.DOL_URL_ROOT.'/index.php'.(count($paramsurl)?'?'.implode('&',$paramsurl):''));
593
+			$paramsurl = array();
594
+			if (GETPOST('textbrowser', 'int')) $paramsurl[] = 'textbrowser='.GETPOST('textbrowser', 'int');
595
+			if (GETPOST('nojs', 'int'))        $paramsurl[] = 'nojs='.GETPOST('nojs', 'int');
596
+			if (GETPOST('lang', 'aZ09'))       $paramsurl[] = 'lang='.GETPOST('lang', 'aZ09');
597
+			header('Location: '.DOL_URL_ROOT.'/index.php'.(count($paramsurl) ? '?'.implode('&', $paramsurl) : ''));
598 598
 			exit;
599 599
 		}
600 600
 	}
601 601
 	else
602 602
 	{
603 603
 		// We are already into an authenticated session
604
-		$login=$_SESSION["dol_login"];
605
-		$entity=$_SESSION["dol_entity"];
604
+		$login = $_SESSION["dol_login"];
605
+		$entity = $_SESSION["dol_entity"];
606 606
 		dol_syslog("- This is an already logged session. _SESSION['dol_login']=".$login." _SESSION['dol_entity']=".$entity, LOG_DEBUG);
607 607
 
608
-		$resultFetchUser=$user->fetch('', $login, '', 1, ($entity > 0 ? $entity : -1));
608
+		$resultFetchUser = $user->fetch('', $login, '', 1, ($entity > 0 ? $entity : -1));
609 609
 		if ($resultFetchUser <= 0)
610 610
 		{
611 611
 			// Account has been removed after login
612 612
 			dol_syslog("Can't load user even if session logged. _SESSION['dol_login']=".$login, LOG_WARNING);
613 613
 			session_destroy();
614 614
 			session_name($sessionname);
615
-			session_set_cookie_params(0, '/', null, false, true);   // Add tag httponly on session cookie
616
-			session_start();    // Fixing the bug of register_globals here is useless since session is empty
615
+			session_set_cookie_params(0, '/', null, false, true); // Add tag httponly on session cookie
616
+			session_start(); // Fixing the bug of register_globals here is useless since session is empty
617 617
 
618 618
 			if ($resultFetchUser == 0)
619 619
 			{
620 620
 				$langs->load('main');
621 621
 				$langs->load('errors');
622 622
 
623
-				$_SESSION["dol_loginmesg"]=$langs->trans("ErrorCantLoadUserFromDolibarrDatabase",$login);
623
+				$_SESSION["dol_loginmesg"] = $langs->trans("ErrorCantLoadUserFromDolibarrDatabase", $login);
624 624
 
625 625
 				// TODO @deprecated Remove this. Hook must be used, not this trigger.
626
-				$user->trigger_mesg='ErrorCantLoadUserFromDolibarrDatabase - login='.$login;
626
+				$user->trigger_mesg = 'ErrorCantLoadUserFromDolibarrDatabase - login='.$login;
627 627
 			}
628 628
 			if ($resultFetchUser < 0)
629 629
 			{
630
-				$_SESSION["dol_loginmesg"]=$user->error;
630
+				$_SESSION["dol_loginmesg"] = $user->error;
631 631
 
632 632
 				// TODO @deprecated Remove this. Hook must be used, not this trigger.
633
-				$user->trigger_mesg=$user->error;
633
+				$user->trigger_mesg = $user->error;
634 634
 			}
635 635
 
636 636
 			// TODO @deprecated Remove this. Hook must be used, not this trigger.
637 637
 			// Call triggers
638
-			include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
639
-			$interface=new Interfaces($db);
640
-			$result=$interface->run_triggers('USER_LOGIN_FAILED',$user,$user,$langs,$conf);
638
+			include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
639
+			$interface = new Interfaces($db);
640
+			$result = $interface->run_triggers('USER_LOGIN_FAILED', $user, $user, $langs, $conf);
641 641
 			if ($result < 0) {
642 642
 				$error++;
643 643
 			}
644 644
 			// End call triggers
645 645
 
646 646
 			// Hooks on failed login
647
-			$action='';
647
+			$action = '';
648 648
 			$hookmanager->initHooks(array('login'));
649
-			$parameters=array('dol_authmode'=>$dol_authmode, 'dol_loginmesg'=>$_SESSION["dol_loginmesg"]);
650
-			$reshook=$hookmanager->executeHooks('afterLoginFailed',$parameters,$user,$action);    // Note that $action and $object may have been modified by some hooks
649
+			$parameters = array('dol_authmode'=>$dol_authmode, 'dol_loginmesg'=>$_SESSION["dol_loginmesg"]);
650
+			$reshook = $hookmanager->executeHooks('afterLoginFailed', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks
651 651
 			if ($reshook < 0) $error++;
652 652
 
653
-			$paramsurl=array();
654
-			if (GETPOST('textbrowser','int')) $paramsurl[]='textbrowser='.GETPOST('textbrowser','int');
655
-			if (GETPOST('nojs','int'))        $paramsurl[]='nojs='.GETPOST('nojs','int');
656
-			if (GETPOST('lang','aZ09'))       $paramsurl[]='lang='.GETPOST('lang','aZ09');
657
-			header('Location: '.DOL_URL_ROOT.'/index.php'.(count($paramsurl)?'?'.implode('&',$paramsurl):''));
653
+			$paramsurl = array();
654
+			if (GETPOST('textbrowser', 'int')) $paramsurl[] = 'textbrowser='.GETPOST('textbrowser', 'int');
655
+			if (GETPOST('nojs', 'int'))        $paramsurl[] = 'nojs='.GETPOST('nojs', 'int');
656
+			if (GETPOST('lang', 'aZ09'))       $paramsurl[] = 'lang='.GETPOST('lang', 'aZ09');
657
+			header('Location: '.DOL_URL_ROOT.'/index.php'.(count($paramsurl) ? '?'.implode('&', $paramsurl) : ''));
658 658
 			exit;
659 659
 		}
660 660
 		else
@@ -663,19 +663,19 @@  discard block
 block discarded – undo
663 663
 		   $hookmanager->initHooks(array('main'));
664 664
 
665 665
 		   // Code for search criteria persistence.
666
-		   if (! empty($_GET['save_lastsearch_values']))    // Keep $_GET here
666
+		   if (!empty($_GET['save_lastsearch_values']))    // Keep $_GET here
667 667
 		   {
668
-			   $relativepathstring = preg_replace('/\?.*$/','',$_SERVER["HTTP_REFERER"]);
669
-			   $relativepathstring = preg_replace('/^https?:\/\/[^\/]*/','',$relativepathstring);     // Get full path except host server
668
+			   $relativepathstring = preg_replace('/\?.*$/', '', $_SERVER["HTTP_REFERER"]);
669
+			   $relativepathstring = preg_replace('/^https?:\/\/[^\/]*/', '', $relativepathstring); // Get full path except host server
670 670
 			   // Clean $relativepathstring
671
-   			   if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring);
671
+   			   if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'), '/').'/', '', $relativepathstring);
672 672
 			   $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
673 673
 			   $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
674 674
 			   //var_dump($relativepathstring);
675 675
 
676
-			   if (! empty($_SESSION['lastsearch_values_tmp_'.$relativepathstring]))
676
+			   if (!empty($_SESSION['lastsearch_values_tmp_'.$relativepathstring]))
677 677
 			   {
678
-				   $_SESSION['lastsearch_values_'.$relativepathstring]=$_SESSION['lastsearch_values_tmp_'.$relativepathstring];
678
+				   $_SESSION['lastsearch_values_'.$relativepathstring] = $_SESSION['lastsearch_values_tmp_'.$relativepathstring];
679 679
 				   unset($_SESSION['lastsearch_values_tmp_'.$relativepathstring]);
680 680
 			   }
681 681
 		   }
@@ -690,30 +690,30 @@  discard block
 block discarded – undo
690 690
 
691 691
 	// Is it a new session that has started ?
692 692
 	// If we are here, this means authentication was successfull.
693
-	if (! isset($_SESSION["dol_login"]))
693
+	if (!isset($_SESSION["dol_login"]))
694 694
 	{
695 695
 		// New session for this login has started.
696
-		$error=0;
696
+		$error = 0;
697 697
 
698 698
 		// Store value into session (values always stored)
699
-		$_SESSION["dol_login"]=$user->login;
700
-		$_SESSION["dol_authmode"]=isset($dol_authmode)?$dol_authmode:'';
701
-		$_SESSION["dol_tz"]=isset($dol_tz)?$dol_tz:'';
702
-		$_SESSION["dol_tz_string"]=isset($dol_tz_string)?$dol_tz_string:'';
703
-		$_SESSION["dol_dst"]=isset($dol_dst)?$dol_dst:'';
704
-		$_SESSION["dol_dst_observed"]=isset($dol_dst_observed)?$dol_dst_observed:'';
705
-		$_SESSION["dol_dst_first"]=isset($dol_dst_first)?$dol_dst_first:'';
706
-		$_SESSION["dol_dst_second"]=isset($dol_dst_second)?$dol_dst_second:'';
707
-		$_SESSION["dol_screenwidth"]=isset($dol_screenwidth)?$dol_screenwidth:'';
708
-		$_SESSION["dol_screenheight"]=isset($dol_screenheight)?$dol_screenheight:'';
709
-		$_SESSION["dol_company"]=$conf->global->MAIN_INFO_SOCIETE_NOM;
710
-		$_SESSION["dol_entity"]=$conf->entity;
699
+		$_SESSION["dol_login"] = $user->login;
700
+		$_SESSION["dol_authmode"] = isset($dol_authmode) ? $dol_authmode : '';
701
+		$_SESSION["dol_tz"] = isset($dol_tz) ? $dol_tz : '';
702
+		$_SESSION["dol_tz_string"] = isset($dol_tz_string) ? $dol_tz_string : '';
703
+		$_SESSION["dol_dst"] = isset($dol_dst) ? $dol_dst : '';
704
+		$_SESSION["dol_dst_observed"] = isset($dol_dst_observed) ? $dol_dst_observed : '';
705
+		$_SESSION["dol_dst_first"] = isset($dol_dst_first) ? $dol_dst_first : '';
706
+		$_SESSION["dol_dst_second"] = isset($dol_dst_second) ? $dol_dst_second : '';
707
+		$_SESSION["dol_screenwidth"] = isset($dol_screenwidth) ? $dol_screenwidth : '';
708
+		$_SESSION["dol_screenheight"] = isset($dol_screenheight) ? $dol_screenheight : '';
709
+		$_SESSION["dol_company"] = $conf->global->MAIN_INFO_SOCIETE_NOM;
710
+		$_SESSION["dol_entity"] = $conf->entity;
711 711
 		// Store value into session (values stored only if defined)
712
-		if (! empty($dol_hide_topmenu))         $_SESSION['dol_hide_topmenu']=$dol_hide_topmenu;
713
-		if (! empty($dol_hide_leftmenu))        $_SESSION['dol_hide_leftmenu']=$dol_hide_leftmenu;
714
-		if (! empty($dol_optimize_smallscreen)) $_SESSION['dol_optimize_smallscreen']=$dol_optimize_smallscreen;
715
-		if (! empty($dol_no_mouse_hover))       $_SESSION['dol_no_mouse_hover']=$dol_no_mouse_hover;
716
-		if (! empty($dol_use_jmobile))          $_SESSION['dol_use_jmobile']=$dol_use_jmobile;
712
+		if (!empty($dol_hide_topmenu))         $_SESSION['dol_hide_topmenu'] = $dol_hide_topmenu;
713
+		if (!empty($dol_hide_leftmenu))        $_SESSION['dol_hide_leftmenu'] = $dol_hide_leftmenu;
714
+		if (!empty($dol_optimize_smallscreen)) $_SESSION['dol_optimize_smallscreen'] = $dol_optimize_smallscreen;
715
+		if (!empty($dol_no_mouse_hover))       $_SESSION['dol_no_mouse_hover'] = $dol_no_mouse_hover;
716
+		if (!empty($dol_use_jmobile))          $_SESSION['dol_use_jmobile'] = $dol_use_jmobile;
717 717
 
718 718
 		dol_syslog("This is a new started user session. _SESSION['dol_login']=".$_SESSION["dol_login"]." Session id=".session_id());
719 719
 
@@ -726,26 +726,26 @@  discard block
 block discarded – undo
726 726
 		// TODO @deprecated Remove this. Hook must be used, not this trigger.
727 727
 		$user->trigger_mesg = $loginfo;
728 728
 		// Call triggers
729
-		include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
730
-		$interface=new Interfaces($db);
731
-		$result=$interface->run_triggers('USER_LOGIN',$user,$user,$langs,$conf);
729
+		include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
730
+		$interface = new Interfaces($db);
731
+		$result = $interface->run_triggers('USER_LOGIN', $user, $user, $langs, $conf);
732 732
 		if ($result < 0) {
733 733
 			$error++;
734 734
 		}
735 735
 		// End call triggers
736 736
 
737 737
 		// Hooks on successfull login
738
-		$action='';
738
+		$action = '';
739 739
 		$hookmanager->initHooks(array('login'));
740
-		$parameters=array('dol_authmode'=>$dol_authmode, 'dol_loginfo'=>$loginfo);
741
-		$reshook=$hookmanager->executeHooks('afterLogin',$parameters,$user,$action);    // Note that $action and $object may have been modified by some hooks
740
+		$parameters = array('dol_authmode'=>$dol_authmode, 'dol_loginfo'=>$loginfo);
741
+		$reshook = $hookmanager->executeHooks('afterLogin', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks
742 742
 		if ($reshook < 0) $error++;
743 743
 
744 744
 		if ($error)
745 745
 		{
746 746
 			$db->rollback();
747 747
 			session_destroy();
748
-			dol_print_error($db,'Error in some hooks afterLogin (or old trigger USER_LOGIN)');
748
+			dol_print_error($db, 'Error in some hooks afterLogin (or old trigger USER_LOGIN)');
749 749
 			exit;
750 750
 		}
751 751
 		else
@@ -754,10 +754,10 @@  discard block
 block discarded – undo
754 754
 		}
755 755
 
756 756
 		// Change landing page if defined.
757
-		$landingpage=(empty($user->conf->MAIN_LANDING_PAGE)?(empty($conf->global->MAIN_LANDING_PAGE)?'':$conf->global->MAIN_LANDING_PAGE):$user->conf->MAIN_LANDING_PAGE);
758
-		if (! empty($landingpage))    // Example: /index.php
757
+		$landingpage = (empty($user->conf->MAIN_LANDING_PAGE) ? (empty($conf->global->MAIN_LANDING_PAGE) ? '' : $conf->global->MAIN_LANDING_PAGE) : $user->conf->MAIN_LANDING_PAGE);
758
+		if (!empty($landingpage))    // Example: /index.php
759 759
 		{
760
-			$newpath=dol_buildpath($landingpage, 1);
760
+			$newpath = dol_buildpath($landingpage, 1);
761 761
 			if ($_SERVER["PHP_SELF"] != $newpath)   // not already on landing page (avoid infinite loop)
762 762
 			{
763 763
 				header('Location: '.$newpath);
@@ -770,12 +770,12 @@  discard block
 block discarded – undo
770 770
 	// If user admin, we force the rights-based modules
771 771
 	if ($user->admin)
772 772
 	{
773
-		$user->rights->user->user->lire=1;
774
-		$user->rights->user->user->creer=1;
775
-		$user->rights->user->user->password=1;
776
-		$user->rights->user->user->supprimer=1;
777
-		$user->rights->user->self->creer=1;
778
-		$user->rights->user->self->password=1;
773
+		$user->rights->user->user->lire = 1;
774
+		$user->rights->user->user->creer = 1;
775
+		$user->rights->user->user->password = 1;
776
+		$user->rights->user->user->supprimer = 1;
777
+		$user->rights->user->self->creer = 1;
778
+		$user->rights->user->self->password = 1;
779 779
 	}
780 780
 
781 781
 	/*
@@ -783,74 +783,74 @@  discard block
 block discarded – undo
783 783
      */
784 784
 
785 785
 	// Set liste_limit
786
-	if (isset($user->conf->MAIN_SIZE_LISTE_LIMIT))	$conf->liste_limit = $user->conf->MAIN_SIZE_LISTE_LIMIT;	// Can be 0
787
-	if (isset($user->conf->PRODUIT_LIMIT_SIZE))	$conf->product->limit_size = $user->conf->PRODUIT_LIMIT_SIZE;	// Can be 0
786
+	if (isset($user->conf->MAIN_SIZE_LISTE_LIMIT))	$conf->liste_limit = $user->conf->MAIN_SIZE_LISTE_LIMIT; // Can be 0
787
+	if (isset($user->conf->PRODUIT_LIMIT_SIZE))	$conf->product->limit_size = $user->conf->PRODUIT_LIMIT_SIZE; // Can be 0
788 788
 
789 789
 	// Replace conf->css by personalized value if theme not forced
790
-	if (empty($conf->global->MAIN_FORCETHEME) && ! empty($user->conf->MAIN_THEME))
790
+	if (empty($conf->global->MAIN_FORCETHEME) && !empty($user->conf->MAIN_THEME))
791 791
 	{
792
-		$conf->theme=$user->conf->MAIN_THEME;
792
+		$conf->theme = $user->conf->MAIN_THEME;
793 793
 		$conf->css  = "/theme/".$conf->theme."/style.css.php";
794 794
 	}
795 795
 }
796 796
 
797 797
 // Case forcing style from url
798
-if (GETPOST('theme','alpha'))
798
+if (GETPOST('theme', 'alpha'))
799 799
 {
800
-	$conf->theme=GETPOST('theme','alpha',1);
800
+	$conf->theme = GETPOST('theme', 'alpha', 1);
801 801
 	$conf->css  = "/theme/".$conf->theme."/style.css.php";
802 802
 }
803 803
 
804 804
 
805 805
 // Set javascript option
806
-if (! GETPOST('nojs','int'))   // If javascript was not disabled on URL
806
+if (!GETPOST('nojs', 'int'))   // If javascript was not disabled on URL
807 807
 {
808
-	if (! empty($user->conf->MAIN_DISABLE_JAVASCRIPT))
808
+	if (!empty($user->conf->MAIN_DISABLE_JAVASCRIPT))
809 809
 	{
810
-		$conf->use_javascript_ajax=! $user->conf->MAIN_DISABLE_JAVASCRIPT;
810
+		$conf->use_javascript_ajax = !$user->conf->MAIN_DISABLE_JAVASCRIPT;
811 811
 	}
812 812
 }
813
-else $conf->use_javascript_ajax=0;
813
+else $conf->use_javascript_ajax = 0;
814 814
 // Set MAIN_OPTIMIZEFORTEXTBROWSER
815
-if (GETPOST('textbrowser','int') || (! empty($conf->browser->name) && $conf->browser->name == 'lynxlinks') || ! empty($user->conf->MAIN_OPTIMIZEFORTEXTBROWSER))   // If we must enable text browser
815
+if (GETPOST('textbrowser', 'int') || (!empty($conf->browser->name) && $conf->browser->name == 'lynxlinks') || !empty($user->conf->MAIN_OPTIMIZEFORTEXTBROWSER))   // If we must enable text browser
816 816
 {
817
-	$conf->global->MAIN_OPTIMIZEFORTEXTBROWSER=1;
817
+	$conf->global->MAIN_OPTIMIZEFORTEXTBROWSER = 1;
818 818
 }
819
-elseif (! empty($user->conf->MAIN_OPTIMIZEFORTEXTBROWSER))
819
+elseif (!empty($user->conf->MAIN_OPTIMIZEFORTEXTBROWSER))
820 820
 {
821
-	$conf->global->MAIN_OPTIMIZEFORTEXTBROWSER=$user->conf->MAIN_OPTIMIZEFORTEXTBROWSER;
821
+	$conf->global->MAIN_OPTIMIZEFORTEXTBROWSER = $user->conf->MAIN_OPTIMIZEFORTEXTBROWSER;
822 822
 }
823 823
 
824 824
 // Set terminal output option according to conf->browser.
825
-if (GETPOST('dol_hide_leftmenu','int') || ! empty($_SESSION['dol_hide_leftmenu']))               $conf->dol_hide_leftmenu=1;
826
-if (GETPOST('dol_hide_topmenu','int') || ! empty($_SESSION['dol_hide_topmenu']))                 $conf->dol_hide_topmenu=1;
827
-if (GETPOST('dol_optimize_smallscreen','int') || ! empty($_SESSION['dol_optimize_smallscreen'])) $conf->dol_optimize_smallscreen=1;
828
-if (GETPOST('dol_no_mouse_hover','int') || ! empty($_SESSION['dol_no_mouse_hover']))             $conf->dol_no_mouse_hover=1;
829
-if (GETPOST('dol_use_jmobile','int') || ! empty($_SESSION['dol_use_jmobile']))                   $conf->dol_use_jmobile=1;
830
-if (! empty($conf->browser->layout) && $conf->browser->layout != 'classic') $conf->dol_no_mouse_hover=1;
831
-if ((! empty($conf->browser->layout) && $conf->browser->layout == 'phone')
832
-	|| (! empty($_SESSION['dol_screenwidth']) && $_SESSION['dol_screenwidth'] < 400)
833
-	|| (! empty($_SESSION['dol_screenheight']) && $_SESSION['dol_screenheight'] < 400)
825
+if (GETPOST('dol_hide_leftmenu', 'int') || !empty($_SESSION['dol_hide_leftmenu']))               $conf->dol_hide_leftmenu = 1;
826
+if (GETPOST('dol_hide_topmenu', 'int') || !empty($_SESSION['dol_hide_topmenu']))                 $conf->dol_hide_topmenu = 1;
827
+if (GETPOST('dol_optimize_smallscreen', 'int') || !empty($_SESSION['dol_optimize_smallscreen'])) $conf->dol_optimize_smallscreen = 1;
828
+if (GETPOST('dol_no_mouse_hover', 'int') || !empty($_SESSION['dol_no_mouse_hover']))             $conf->dol_no_mouse_hover = 1;
829
+if (GETPOST('dol_use_jmobile', 'int') || !empty($_SESSION['dol_use_jmobile']))                   $conf->dol_use_jmobile = 1;
830
+if (!empty($conf->browser->layout) && $conf->browser->layout != 'classic') $conf->dol_no_mouse_hover = 1;
831
+if ((!empty($conf->browser->layout) && $conf->browser->layout == 'phone')
832
+	|| (!empty($_SESSION['dol_screenwidth']) && $_SESSION['dol_screenwidth'] < 400)
833
+	|| (!empty($_SESSION['dol_screenheight']) && $_SESSION['dol_screenheight'] < 400)
834 834
 )
835 835
 {
836
-	$conf->dol_optimize_smallscreen=1;
836
+	$conf->dol_optimize_smallscreen = 1;
837 837
 }
838 838
 // If we force to use jmobile, then we reenable javascript
839
-if (! empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax=1;
839
+if (!empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax = 1;
840 840
 // Replace themes bugged with jmobile with eldy
841
-if (! empty($conf->dol_use_jmobile) && in_array($conf->theme,array('bureau2crea','cameleo','amarok')))
841
+if (!empty($conf->dol_use_jmobile) && in_array($conf->theme, array('bureau2crea', 'cameleo', 'amarok')))
842 842
 {
843
-	$conf->theme='eldy';
844
-	$conf->css  =  "/theme/".$conf->theme."/style.css.php";
843
+	$conf->theme = 'eldy';
844
+	$conf->css  = "/theme/".$conf->theme."/style.css.php";
845 845
 }
846 846
 //var_dump($conf->browser->phone);
847 847
 
848
-if (! defined('NOREQUIRETRAN'))
848
+if (!defined('NOREQUIRETRAN'))
849 849
 {
850
-	if (! GETPOST('lang','aZ09'))	// If language was not forced on URL
850
+	if (!GETPOST('lang', 'aZ09'))	// If language was not forced on URL
851 851
 	{
852 852
 		// If user has chosen its own language
853
-		if (! empty($user->conf->MAIN_LANG_DEFAULT))
853
+		if (!empty($user->conf->MAIN_LANG_DEFAULT))
854 854
 		{
855 855
 			// If different than current language
856 856
 			//print ">>>".$langs->getDefaultLang()."-".$user->conf->MAIN_LANG_DEFAULT;
@@ -862,11 +862,11 @@  discard block
 block discarded – undo
862 862
 	}
863 863
 }
864 864
 
865
-if (! defined('NOLOGIN'))
865
+if (!defined('NOLOGIN'))
866 866
 {
867 867
 	// If the login is not recovered, it is identified with an account that does not exist.
868 868
 	// Hacking attempt?
869
-	if (! $user->login) accessforbidden();
869
+	if (!$user->login) accessforbidden();
870 870
 
871 871
 	// Check if user is active
872 872
 	if ($user->statut < 1)
@@ -883,88 +883,88 @@  discard block
 block discarded – undo
883 883
 }
884 884
 
885 885
 
886
-dol_syslog("--- Access to ".$_SERVER["PHP_SELF"].' - action='.GETPOST('action','az09').', massaction='.GETPOST('massaction','az09'));
886
+dol_syslog("--- Access to ".$_SERVER["PHP_SELF"].' - action='.GETPOST('action', 'az09').', massaction='.GETPOST('massaction', 'az09'));
887 887
 //Another call for easy debugg
888 888
 //dol_syslog("Access to ".$_SERVER["PHP_SELF"].' GET='.join(',',array_keys($_GET)).'->'.join(',',$_GET).' POST:'.join(',',array_keys($_POST)).'->'.join(',',$_POST));
889 889
 
890 890
 // Load main languages files
891
-if (! defined('NOREQUIRETRAN'))
891
+if (!defined('NOREQUIRETRAN'))
892 892
 {
893 893
 	$langs->load("main");
894 894
 	$langs->load("dict");
895 895
 }
896 896
 
897 897
 // Define some constants used for style of arrays
898
-$bc=array(0=>'class="impair"',1=>'class="pair"');
899
-$bcdd=array(0=>'class="drag drop oddeven"',1=>'class="drag drop oddeven"');
900
-$bcnd=array(0=>'class="nodrag nodrop nohover"',1=>'class="nodrag nodrop nohoverpair"');		// Used for tr to add new lines
901
-$bctag=array(0=>'class="impair tagtr"',1=>'class="pair tagtr"');
898
+$bc = array(0=>'class="impair"', 1=>'class="pair"');
899
+$bcdd = array(0=>'class="drag drop oddeven"', 1=>'class="drag drop oddeven"');
900
+$bcnd = array(0=>'class="nodrag nodrop nohover"', 1=>'class="nodrag nodrop nohoverpair"'); // Used for tr to add new lines
901
+$bctag = array(0=>'class="impair tagtr"', 1=>'class="pair tagtr"');
902 902
 
903 903
 // Define messages variables
904
-$mesg=''; $warning=''; $error=0;
904
+$mesg = ''; $warning = ''; $error = 0;
905 905
 // deprecated, see setEventMessages() and dol_htmloutput_events()
906
-$mesgs=array(); $warnings=array(); $errors=array();
906
+$mesgs = array(); $warnings = array(); $errors = array();
907 907
 
908 908
 // Constants used to defined number of lines in textarea
909 909
 if (empty($conf->browser->firefox))
910 910
 {
911
-	define('ROWS_1',1);
912
-	define('ROWS_2',2);
913
-	define('ROWS_3',3);
914
-	define('ROWS_4',4);
915
-	define('ROWS_5',5);
916
-	define('ROWS_6',6);
917
-	define('ROWS_7',7);
918
-	define('ROWS_8',8);
919
-	define('ROWS_9',9);
911
+	define('ROWS_1', 1);
912
+	define('ROWS_2', 2);
913
+	define('ROWS_3', 3);
914
+	define('ROWS_4', 4);
915
+	define('ROWS_5', 5);
916
+	define('ROWS_6', 6);
917
+	define('ROWS_7', 7);
918
+	define('ROWS_8', 8);
919
+	define('ROWS_9', 9);
920 920
 }
921 921
 else
922 922
 {
923
-	define('ROWS_1',0);
924
-	define('ROWS_2',1);
925
-	define('ROWS_3',2);
926
-	define('ROWS_4',3);
927
-	define('ROWS_5',4);
928
-	define('ROWS_6',5);
929
-	define('ROWS_7',6);
930
-	define('ROWS_8',7);
931
-	define('ROWS_9',8);
923
+	define('ROWS_1', 0);
924
+	define('ROWS_2', 1);
925
+	define('ROWS_3', 2);
926
+	define('ROWS_4', 3);
927
+	define('ROWS_5', 4);
928
+	define('ROWS_6', 5);
929
+	define('ROWS_7', 6);
930
+	define('ROWS_8', 7);
931
+	define('ROWS_9', 8);
932 932
 }
933 933
 
934
-$heightforframes=48;
934
+$heightforframes = 48;
935 935
 
936 936
 // Init menu manager
937
-if (! defined('NOREQUIREMENU'))
937
+if (!defined('NOREQUIREMENU'))
938 938
 {
939 939
 	if (empty($user->societe_id))    // If internal user or not defined
940 940
 	{
941
-		$conf->standard_menu=(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?(empty($conf->global->MAIN_MENU_STANDARD)?'eldy_menu.php':$conf->global->MAIN_MENU_STANDARD):$conf->global->MAIN_MENU_STANDARD_FORCED);
941
+		$conf->standard_menu = (empty($conf->global->MAIN_MENU_STANDARD_FORCED) ? (empty($conf->global->MAIN_MENU_STANDARD) ? 'eldy_menu.php' : $conf->global->MAIN_MENU_STANDARD) : $conf->global->MAIN_MENU_STANDARD_FORCED);
942 942
 	}
943 943
 	else                        // If external user
944 944
 	{
945
-		$conf->standard_menu=(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?(empty($conf->global->MAIN_MENUFRONT_STANDARD)?'eldy_menu.php':$conf->global->MAIN_MENUFRONT_STANDARD):$conf->global->MAIN_MENUFRONT_STANDARD_FORCED);
945
+		$conf->standard_menu = (empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED) ? (empty($conf->global->MAIN_MENUFRONT_STANDARD) ? 'eldy_menu.php' : $conf->global->MAIN_MENUFRONT_STANDARD) : $conf->global->MAIN_MENUFRONT_STANDARD_FORCED);
946 946
 	}
947 947
 
948 948
 	// Load the menu manager (only if not already done)
949
-	$file_menu=$conf->standard_menu;
950
-	if (GETPOST('menu','alpha')) $file_menu=GETPOST('menu','alpha');     // example: menu=eldy_menu.php
951
-	if (! class_exists('MenuManager'))
949
+	$file_menu = $conf->standard_menu;
950
+	if (GETPOST('menu', 'alpha')) $file_menu = GETPOST('menu', 'alpha'); // example: menu=eldy_menu.php
951
+	if (!class_exists('MenuManager'))
952 952
 	{
953
-		$menufound=0;
954
-		$dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']);
955
-		foreach($dirmenus as $dirmenu)
953
+		$menufound = 0;
954
+		$dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
955
+		foreach ($dirmenus as $dirmenu)
956 956
 		{
957
-			$menufound=dol_include_once($dirmenu."standard/".$file_menu);
957
+			$menufound = dol_include_once($dirmenu."standard/".$file_menu);
958 958
 			if (class_exists('MenuManager')) break;
959 959
 		}
960
-		if (! class_exists('MenuManager'))	// If failed to include, we try with standard eldy_menu.php
960
+		if (!class_exists('MenuManager'))	// If failed to include, we try with standard eldy_menu.php
961 961
 		{
962 962
 			dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING);
963
-			$file_menu='eldy_menu.php';
963
+			$file_menu = 'eldy_menu.php';
964 964
 			include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu;
965 965
 		}
966 966
 	}
967
-	$menumanager = new MenuManager($db, empty($user->societe_id)?0:1);
967
+	$menumanager = new MenuManager($db, empty($user->societe_id) ? 0 : 1);
968 968
 	$menumanager->loadMenu();
969 969
 }
970 970
 
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
 
973 973
 // Functions
974 974
 
975
-if (! function_exists("llxHeader"))
975
+if (!function_exists("llxHeader"))
976 976
 {
977 977
 	/**
978 978
 	 *	Show HTML header HTML + BODY + Top menu + left menu + DIV
@@ -992,14 +992,14 @@  discard block
 block discarded – undo
992 992
 	 * @param	string	$replacemainareaby	Replace call to main_area() by a print of this string
993 993
 	 * @return	void
994 994
 	 */
995
-	function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='')
995
+	function llxHeader($head = '', $title = '', $help_url = '', $target = '', $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '', $morequerystring = '', $morecssonbody = '', $replacemainareaby = '')
996 996
 	{
997 997
 		global $conf;
998 998
 
999 999
 		// html header
1000 1000
 		top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
1001 1001
 
1002
-		print '<body id="mainbody"'.($morecssonbody?' class="'.$morecssonbody.'"':'').'>' . "\n";
1002
+		print '<body id="mainbody"'.($morecssonbody ? ' class="'.$morecssonbody.'"' : '').'>'."\n";
1003 1003
 
1004 1004
 		// top menu and left menu area
1005 1005
 		if (empty($conf->dol_hide_topmenu))
@@ -1029,16 +1029,16 @@  discard block
 block discarded – undo
1029 1029
  *  @param  string  $contenttype    Content type. For example, 'text/html'
1030 1030
  *  @return	void
1031 1031
  */
1032
-function top_httphead($contenttype='text/html')
1032
+function top_httphead($contenttype = 'text/html')
1033 1033
 {
1034 1034
 	global $conf;
1035 1035
 
1036
-	if ($contenttype == 'text/html' ) header("Content-Type: text/html; charset=".$conf->file->character_set_client);
1036
+	if ($contenttype == 'text/html') header("Content-Type: text/html; charset=".$conf->file->character_set_client);
1037 1037
 	else header("Content-Type: ".$contenttype);
1038 1038
 	// Security options
1039
-	header("X-Content-Type-Options: nosniff");  // With the nosniff option, if the server says the content is text/html, the browser will render it as text/html (note that most browsers now force this option to on)
1040
-	header("X-Frame-Options: SAMEORIGIN");      // Frames allowed only if on same domain (stop some XSS attacks)
1041
-	if (! empty($conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY))
1039
+	header("X-Content-Type-Options: nosniff"); // With the nosniff option, if the server says the content is text/html, the browser will render it as text/html (note that most browsers now force this option to on)
1040
+	header("X-Frame-Options: SAMEORIGIN"); // Frames allowed only if on same domain (stop some XSS attacks)
1041
+	if (!empty($conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY))
1042 1042
 	{
1043 1043
 		// For example, to restrict script, object, frames or img to some domains
1044 1044
 		// script-src https://api.google.com https://anotherhost.com; object-src https://youtube.com; child-src https://youtube.com; img-src: https://static.example.com
@@ -1068,72 +1068,72 @@  discard block
 block discarded – undo
1068 1068
  * @param   int     $disablenofollow Disable no follow tag
1069 1069
  * @return	void
1070 1070
  */
1071
-function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disablejmobile=0, $disablenofollow=0)
1071
+function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '', $disablejmobile = 0, $disablenofollow = 0)
1072 1072
 {
1073 1073
 	global $user, $conf, $langs, $db;
1074 1074
 
1075 1075
 	top_httphead();
1076 1076
 
1077
-	if (empty($conf->css)) $conf->css = '/theme/eldy/style.css.php';	// If not defined, eldy by default
1077
+	if (empty($conf->css)) $conf->css = '/theme/eldy/style.css.php'; // If not defined, eldy by default
1078 1078
 
1079
-	if (! empty($conf->global->MAIN_ACTIVATE_HTML4)) {
1079
+	if (!empty($conf->global->MAIN_ACTIVATE_HTML4)) {
1080 1080
 		$doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
1081
-	}else {
1081
+	} else {
1082 1082
 		$doctype = '<!doctype html>';
1083 1083
 	}
1084 1084
 	print $doctype."\n";
1085
-	if (! empty($conf->global->MAIN_USE_CACHE_MANIFEST)) print '<html lang="'.substr($langs->defaultlang,0,2).'" manifest="'.DOL_URL_ROOT.'/cache.manifest">'."\n";
1086
-	else print '<html lang="'.substr($langs->defaultlang,0,2).'">'."\n";
1085
+	if (!empty($conf->global->MAIN_USE_CACHE_MANIFEST)) print '<html lang="'.substr($langs->defaultlang, 0, 2).'" manifest="'.DOL_URL_ROOT.'/cache.manifest">'."\n";
1086
+	else print '<html lang="'.substr($langs->defaultlang, 0, 2).'">'."\n";
1087 1087
 	//print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">'."\n";
1088 1088
 	if (empty($disablehead))
1089 1089
 	{
1090 1090
 		print "<head>\n";
1091
-		if (GETPOST('dol_basehref','alpha')) print '<base href="'.dol_escape_htmltag(GETPOST('dol_basehref','alpha')).'">'."\n";
1091
+		if (GETPOST('dol_basehref', 'alpha')) print '<base href="'.dol_escape_htmltag(GETPOST('dol_basehref', 'alpha')).'">'."\n";
1092 1092
 		// Displays meta
1093
-		print '<meta name="robots" content="noindex'.($disablenofollow?'':',nofollow').'">'."\n";	// Do not index
1094
-		print '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n";		// Scale for mobile device
1093
+		print '<meta name="robots" content="noindex'.($disablenofollow ? '' : ',nofollow').'">'."\n"; // Do not index
1094
+		print '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n"; // Scale for mobile device
1095 1095
 		print '<meta name="author" content="Dolibarr Development Team">'."\n";
1096 1096
 		// Favicon
1097
-		$favicon=dol_buildpath('/theme/'.$conf->theme.'/img/favicon.ico',1);
1098
-		if (! empty($conf->global->MAIN_FAVICON_URL)) $favicon=$conf->global->MAIN_FAVICON_URL;
1099
-		if (empty($conf->dol_use_jmobile)) print '<link rel="shortcut icon" type="image/x-icon" href="'.$favicon.'"/>'."\n";	// Not required into an Android webview
1097
+		$favicon = dol_buildpath('/theme/'.$conf->theme.'/img/favicon.ico', 1);
1098
+		if (!empty($conf->global->MAIN_FAVICON_URL)) $favicon = $conf->global->MAIN_FAVICON_URL;
1099
+		if (empty($conf->dol_use_jmobile)) print '<link rel="shortcut icon" type="image/x-icon" href="'.$favicon.'"/>'."\n"; // Not required into an Android webview
1100 1100
 		//if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<link rel="top" title="'.$langs->trans("Home").'" href="'.(DOL_URL_ROOT?DOL_URL_ROOT:'/').'">'."\n";
1101 1101
 		//if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<link rel="copyright" title="GNU General Public License" href="http://www.gnu.org/copyleft/gpl.html#SEC1">'."\n";
1102 1102
 		//if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<link rel="author" title="Dolibarr Development Team" href="https://www.dolibarr.org">'."\n";
1103 1103
 
1104 1104
 		// Displays title
1105
-		$appli=constant('DOL_APPLICATION_TITLE');
1106
-		if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE;
1105
+		$appli = constant('DOL_APPLICATION_TITLE');
1106
+		if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli = $conf->global->MAIN_APPLICATION_TITLE;
1107 1107
 
1108
-		if ($title && ! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/noapp/',$conf->global->MAIN_HTML_TITLE)) print '<title>'.dol_htmlentities($title).'</title>';
1108
+		if ($title && !empty($conf->global->MAIN_HTML_TITLE) && preg_match('/noapp/', $conf->global->MAIN_HTML_TITLE)) print '<title>'.dol_htmlentities($title).'</title>';
1109 1109
 		else if ($title) print '<title>'.dol_htmlentities($appli.' - '.$title).'</title>';
1110 1110
 		else print "<title>".dol_htmlentities($appli)."</title>";
1111 1111
 		print "\n";
1112 1112
 
1113 1113
 		//$ext='';
1114 1114
 		//if (! empty($conf->dol_use_jmobile)) $ext='version='.urlencode(DOL_VERSION);
1115
-		$ext='version='.urlencode(DOL_VERSION);
1115
+		$ext = 'version='.urlencode(DOL_VERSION);
1116 1116
 
1117
-		if (GETPOST('version','int')) $ext='version='.GETPOST('version','int');	// usefull to force no cache on css/js
1118
-		if (GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)) $ext.='&testmenuhider='.(GETPOST('testmenuhider','int')?GETPOST('testmenuhider','int'):$conf->global->MAIN_TESTMENUHIDER);
1117
+		if (GETPOST('version', 'int')) $ext = 'version='.GETPOST('version', 'int'); // usefull to force no cache on css/js
1118
+		if (GETPOST('testmenuhider', 'int') || !empty($conf->global->MAIN_TESTMENUHIDER)) $ext .= '&testmenuhider='.(GETPOST('testmenuhider', 'int') ?GETPOST('testmenuhider', 'int') : $conf->global->MAIN_TESTMENUHIDER);
1119 1119
 
1120
-		$themeparam='?lang='.$langs->defaultlang.'&amp;theme='.$conf->theme.(GETPOST('optioncss','aZ09')?'&amp;optioncss='.GETPOST('optioncss','aZ09',1):'').'&amp;userid='.$user->id.'&amp;entity='.$conf->entity;
1121
-		$themeparam.=($ext?'&amp;'.$ext:'');
1122
-		if (! empty($_SESSION['dol_resetcache'])) $themeparam.='&amp;dol_resetcache='.$_SESSION['dol_resetcache'];
1123
-		if (GETPOST('dol_hide_topmenu','int'))           { $themeparam.='&amp;dol_hide_topmenu='.GETPOST('dol_hide_topmenu','int'); }
1124
-		if (GETPOST('dol_hide_leftmenu','int'))          { $themeparam.='&amp;dol_hide_leftmenu='.GETPOST('dol_hide_leftmenu','int'); }
1125
-		if (GETPOST('dol_optimize_smallscreen','int'))   { $themeparam.='&amp;dol_optimize_smallscreen='.GETPOST('dol_optimize_smallscreen','int'); }
1126
-		if (GETPOST('dol_no_mouse_hover','int'))         { $themeparam.='&amp;dol_no_mouse_hover='.GETPOST('dol_no_mouse_hover','int'); }
1127
-		if (GETPOST('dol_use_jmobile','int'))            { $themeparam.='&amp;dol_use_jmobile='.GETPOST('dol_use_jmobile','int'); $conf->dol_use_jmobile=GETPOST('dol_use_jmobile','int'); }
1120
+		$themeparam = '?lang='.$langs->defaultlang.'&amp;theme='.$conf->theme.(GETPOST('optioncss', 'aZ09') ? '&amp;optioncss='.GETPOST('optioncss', 'aZ09', 1) : '').'&amp;userid='.$user->id.'&amp;entity='.$conf->entity;
1121
+		$themeparam .= ($ext ? '&amp;'.$ext : '');
1122
+		if (!empty($_SESSION['dol_resetcache'])) $themeparam .= '&amp;dol_resetcache='.$_SESSION['dol_resetcache'];
1123
+		if (GETPOST('dol_hide_topmenu', 'int')) { $themeparam .= '&amp;dol_hide_topmenu='.GETPOST('dol_hide_topmenu', 'int'); }
1124
+		if (GETPOST('dol_hide_leftmenu', 'int')) { $themeparam .= '&amp;dol_hide_leftmenu='.GETPOST('dol_hide_leftmenu', 'int'); }
1125
+		if (GETPOST('dol_optimize_smallscreen', 'int')) { $themeparam .= '&amp;dol_optimize_smallscreen='.GETPOST('dol_optimize_smallscreen', 'int'); }
1126
+		if (GETPOST('dol_no_mouse_hover', 'int')) { $themeparam .= '&amp;dol_no_mouse_hover='.GETPOST('dol_no_mouse_hover', 'int'); }
1127
+		if (GETPOST('dol_use_jmobile', 'int')) { $themeparam .= '&amp;dol_use_jmobile='.GETPOST('dol_use_jmobile', 'int'); $conf->dol_use_jmobile = GETPOST('dol_use_jmobile', 'int'); }
1128 1128
 
1129
-		if (! defined('DISABLE_JQUERY') && ! $disablejs && $conf->use_javascript_ajax)
1129
+		if (!defined('DISABLE_JQUERY') && !$disablejs && $conf->use_javascript_ajax)
1130 1130
 		{
1131 1131
 			print '<!-- Includes CSS for JQuery (Ajax library) -->'."\n";
1132 1132
 			$jquerytheme = 'smoothness';
1133 1133
 			if (!empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME;
1134
-			if (constant('JS_JQUERY_UI')) print '<link rel="stylesheet" type="text/css" href="'.JS_JQUERY_UI.'css/'.$jquerytheme.'/jquery-ui.min.css'.($ext?'?'.$ext:'').'">'."\n";  // JQuery
1135
-			else print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/css/'.$jquerytheme.'/jquery-ui.css'.($ext?'?'.$ext:'').'">'."\n";    // JQuery
1136
-			if (! defined('DISABLE_JQUERY_JNOTIFY')) print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify-alt.min.css'.($ext?'?'.$ext:'').'">'."\n";          // JNotify
1134
+			if (constant('JS_JQUERY_UI')) print '<link rel="stylesheet" type="text/css" href="'.JS_JQUERY_UI.'css/'.$jquerytheme.'/jquery-ui.min.css'.($ext ? '?'.$ext : '').'">'."\n"; // JQuery
1135
+			else print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/css/'.$jquerytheme.'/jquery-ui.css'.($ext ? '?'.$ext : '').'">'."\n"; // JQuery
1136
+			if (!defined('DISABLE_JQUERY_JNOTIFY')) print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify-alt.min.css'.($ext ? '?'.$ext : '').'">'."\n"; // JNotify
1137 1137
 			/* Removed a old hidden problematic feature never used in Dolibarr. If an external module need datatable, the module must provide all lib it needs and manage version problems with other dolibarr components
1138 1138
             if (! empty($conf->global->MAIN_USE_JQUERY_DATATABLES) || (defined('REQUIRE_JQUERY_DATATABLES') && constant('REQUIRE_JQUERY_DATATABLES')))     // jQuery datatables
1139 1139
             {
@@ -1141,58 +1141,58 @@  discard block
 block discarded – undo
1141 1141
                 print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extensions/Buttons/css/buttons.dataTables.min.css'.($ext?'?'.$ext:'').'">'."\n";
1142 1142
                 print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extensions/ColReorder/css/colReorder.dataTables.min.css'.($ext?'?'.$ext:'').'"></script>'."\n";
1143 1143
             }*/
1144
-			if (! defined('DISABLE_SELECT2') && (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')))     // jQuery plugin "mutiselect", "multiple-select", "select2"...
1144
+			if (!defined('DISABLE_SELECT2') && (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')))     // jQuery plugin "mutiselect", "multiple-select", "select2"...
1145 1145
 			{
1146
-				$tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT;
1147
-				print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/'.$tmpplugin.'/dist/css/'.$tmpplugin.'.css'.($ext?'?'.$ext:'').'">'."\n";
1146
+				$tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
1147
+				print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/'.$tmpplugin.'/dist/css/'.$tmpplugin.'.css'.($ext ? '?'.$ext : '').'">'."\n";
1148 1148
 			}
1149 1149
 			// jQuery Timepicker
1150
-			if (! empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER'))
1150
+			if (!empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER'))
1151 1151
 			{
1152
-				print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.css'.($ext?'?'.$ext:'').'">'."\n";
1152
+				print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.css'.($ext ? '?'.$ext : '').'">'."\n";
1153 1153
 			}
1154 1154
 		}
1155 1155
 
1156
-		if (! defined('DISABLE_FONT_AWSOME'))
1156
+		if (!defined('DISABLE_FONT_AWSOME'))
1157 1157
 		{
1158 1158
 			print '<!-- Includes CSS for font awesome -->'."\n";
1159
-			print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/common/fontawesome/css/font-awesome.min.css'.($ext?'?'.$ext:'').'">'."\n";
1159
+			print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/common/fontawesome/css/font-awesome.min.css'.($ext ? '?'.$ext : '').'">'."\n";
1160 1160
 		}
1161 1161
 
1162 1162
 		print '<!-- Includes CSS for Dolibarr theme -->'."\n";
1163 1163
 		// Output style sheets (optioncss='print' or ''). Note: $conf->css looks like '/theme/eldy/style.css.php'
1164
-		$themepath=dol_buildpath($conf->css,1);
1165
-		$themesubdir='';
1166
-		if (! empty($conf->modules_parts['theme']))	// This slow down
1164
+		$themepath = dol_buildpath($conf->css, 1);
1165
+		$themesubdir = '';
1166
+		if (!empty($conf->modules_parts['theme']))	// This slow down
1167 1167
 		{
1168
-			foreach($conf->modules_parts['theme'] as $reldir)
1168
+			foreach ($conf->modules_parts['theme'] as $reldir)
1169 1169
 			{
1170 1170
 				if (file_exists(dol_buildpath($reldir.$conf->css, 0)))
1171 1171
 				{
1172
-					$themepath=dol_buildpath($reldir.$conf->css, 1);
1173
-					$themesubdir=$reldir;
1172
+					$themepath = dol_buildpath($reldir.$conf->css, 1);
1173
+					$themesubdir = $reldir;
1174 1174
 					break;
1175 1175
 				}
1176 1176
 			}
1177 1177
 		}
1178 1178
 		//print 'themepath='.$themepath.' themeparam='.$themeparam;exit;
1179 1179
 		print '<link rel="stylesheet" type="text/css" href="'.$themepath.$themeparam.'">'."\n";
1180
-		if (! empty($conf->global->MAIN_FIX_FLASH_ON_CHROME)) print '<!-- Includes CSS that does not exists as a workaround of flash bug of chrome -->'."\n".'<link rel="stylesheet" type="text/css" href="filethatdoesnotexiststosolvechromeflashbug">'."\n";
1180
+		if (!empty($conf->global->MAIN_FIX_FLASH_ON_CHROME)) print '<!-- Includes CSS that does not exists as a workaround of flash bug of chrome -->'."\n".'<link rel="stylesheet" type="text/css" href="filethatdoesnotexiststosolvechromeflashbug">'."\n";
1181 1181
 
1182 1182
 		// CSS forced by modules (relative url starting with /)
1183
-		if (! empty($conf->modules_parts['css']))
1183
+		if (!empty($conf->modules_parts['css']))
1184 1184
 		{
1185
-			$arraycss=(array) $conf->modules_parts['css'];
1186
-			foreach($arraycss as $modcss => $filescss)
1185
+			$arraycss = (array) $conf->modules_parts['css'];
1186
+			foreach ($arraycss as $modcss => $filescss)
1187 1187
 			{
1188
-				$filescss=(array) $filescss;	// To be sure filecss is an array
1189
-				foreach($filescss as $cssfile)
1188
+				$filescss = (array) $filescss; // To be sure filecss is an array
1189
+				foreach ($filescss as $cssfile)
1190 1190
 				{
1191 1191
 					if (empty($cssfile)) dol_syslog("Warning: module ".$modcss." declared a css path file into its descriptor that is empty.", LOG_WARNING);
1192 1192
 					// cssfile is a relative path
1193
-					print '<!-- Includes CSS added by module '.$modcss. ' -->'."\n".'<link rel="stylesheet" type="text/css" href="'.dol_buildpath($cssfile,1);
1193
+					print '<!-- Includes CSS added by module '.$modcss.' -->'."\n".'<link rel="stylesheet" type="text/css" href="'.dol_buildpath($cssfile, 1);
1194 1194
 					// We add params only if page is not static, because some web server setup does not return content type text/css if url has parameters, so browser cache is not used.
1195
-					if (!preg_match('/\.css$/i',$cssfile)) print $themeparam;
1195
+					if (!preg_match('/\.css$/i', $cssfile)) print $themeparam;
1196 1196
 					print '">'."\n";
1197 1197
 				}
1198 1198
 			}
@@ -1200,71 +1200,71 @@  discard block
 block discarded – undo
1200 1200
 		// CSS forced by page in top_htmlhead call (relative url starting with /)
1201 1201
 		if (is_array($arrayofcss))
1202 1202
 		{
1203
-			foreach($arrayofcss as $cssfile)
1203
+			foreach ($arrayofcss as $cssfile)
1204 1204
 			{
1205
-				print '<!-- Includes CSS added by page -->'."\n".'<link rel="stylesheet" type="text/css" title="default" href="'.dol_buildpath($cssfile,1);
1205
+				print '<!-- Includes CSS added by page -->'."\n".'<link rel="stylesheet" type="text/css" title="default" href="'.dol_buildpath($cssfile, 1);
1206 1206
 				// We add params only if page is not static, because some web server setup does not return content type text/css if url has parameters and browser cache is not used.
1207
-				if (!preg_match('/\.css$/i',$cssfile)) print $themeparam;
1207
+				if (!preg_match('/\.css$/i', $cssfile)) print $themeparam;
1208 1208
 				print '">'."\n";
1209 1209
 			}
1210 1210
 		}
1211 1211
 
1212 1212
 		// Output standard javascript links
1213
-		if (! defined('DISABLE_JQUERY') && ! $disablejs && ! empty($conf->use_javascript_ajax))
1213
+		if (!defined('DISABLE_JQUERY') && !$disablejs && !empty($conf->use_javascript_ajax))
1214 1214
 		{
1215 1215
 			// JQuery. Must be before other includes
1216 1216
 			print '<!-- Includes JS for JQuery -->'."\n";
1217
-			if (defined('JS_JQUERY') && constant('JS_JQUERY')) print '<script type="text/javascript" src="'.JS_JQUERY.'jquery.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1218
-			else print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1219
-			if (! empty($conf->global->MAIN_FEATURES_LEVEL) && ! defined('JS_JQUERY_MIGRATE_DISABLED'))
1217
+			if (defined('JS_JQUERY') && constant('JS_JQUERY')) print '<script type="text/javascript" src="'.JS_JQUERY.'jquery.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1218
+			else print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1219
+			if (!empty($conf->global->MAIN_FEATURES_LEVEL) && !defined('JS_JQUERY_MIGRATE_DISABLED'))
1220 1220
 			{
1221
-				if (defined('JS_JQUERY_MIGRATE') && constant('JS_JQUERY_MIGRATE')) print '<script type="text/javascript" src="'.JS_JQUERY_MIGRATE.'jquery-migrate.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1222
-				else print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-migrate.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1221
+				if (defined('JS_JQUERY_MIGRATE') && constant('JS_JQUERY_MIGRATE')) print '<script type="text/javascript" src="'.JS_JQUERY_MIGRATE.'jquery-migrate.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1222
+				else print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-migrate.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1223 1223
 			}
1224
-			if (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI')) print '<script type="text/javascript" src="'.JS_JQUERY_UI.'jquery-ui.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1225
-			else print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-ui.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1226
-			if (! defined('DISABLE_JQUERY_TABLEDND')) print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/tablednd/jquery.tablednd.0.6.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1224
+			if (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI')) print '<script type="text/javascript" src="'.JS_JQUERY_UI.'jquery-ui.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1225
+			else print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-ui.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1226
+			if (!defined('DISABLE_JQUERY_TABLEDND')) print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/tablednd/jquery.tablednd.0.6.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1227 1227
 			// jQuery jnotify
1228
-			if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! defined('DISABLE_JQUERY_JNOTIFY'))
1228
+			if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && !defined('DISABLE_JQUERY_JNOTIFY'))
1229 1229
 			{
1230
-				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1231
-				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/jnotify.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1230
+				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1231
+				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/jnotify.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1232 1232
 			}
1233 1233
 			// Flot
1234
-			if (empty($conf->global->MAIN_DISABLE_JQUERY_FLOT) && ! defined('DISABLE_JQUERY_FLOT'))
1234
+			if (empty($conf->global->MAIN_DISABLE_JQUERY_FLOT) && !defined('DISABLE_JQUERY_FLOT'))
1235 1235
 			{
1236 1236
 				if (constant('JS_JQUERY_FLOT'))
1237 1237
 				{
1238
-					print '<script type="text/javascript" src="'.JS_JQUERY_FLOT.'jquery.flot.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1239
-					print '<script type="text/javascript" src="'.JS_JQUERY_FLOT.'jquery.flot.pie.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1240
-					print '<script type="text/javascript" src="'.JS_JQUERY_FLOT.'jquery.flot.stack.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1238
+					print '<script type="text/javascript" src="'.JS_JQUERY_FLOT.'jquery.flot.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1239
+					print '<script type="text/javascript" src="'.JS_JQUERY_FLOT.'jquery.flot.pie.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1240
+					print '<script type="text/javascript" src="'.JS_JQUERY_FLOT.'jquery.flot.stack.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1241 1241
 				}
1242 1242
 				else
1243 1243
 				{
1244
-					print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1245
-					print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.pie.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1246
-					print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.stack.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1244
+					print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1245
+					print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.pie.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1246
+					print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.stack.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1247 1247
 				}
1248 1248
 			}
1249 1249
 			// jQuery jeditable
1250
-			if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && ! defined('DISABLE_JQUERY_JEDITABLE'))
1250
+			if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !defined('DISABLE_JQUERY_JEDITABLE'))
1251 1251
 			{
1252 1252
 				print '<!-- JS to manage editInPlace feature -->'."\n";
1253
-				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1254
-				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.ui-datepicker.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1255
-				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.ui-autocomplete.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1253
+				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1254
+				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.ui-datepicker.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1255
+				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.ui-autocomplete.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1256 1256
 				print '<script type="text/javascript">'."\n";
1257 1257
 				print 'var urlSaveInPlace = \''.DOL_URL_ROOT.'/core/ajax/saveinplace.php\';'."\n";
1258 1258
 				print 'var urlLoadInPlace = \''.DOL_URL_ROOT.'/core/ajax/loadinplace.php\';'."\n";
1259
-				print 'var tooltipInPlace = \''.$langs->transnoentities('ClickToEdit').'\';'."\n";	// Added in title attribute of span
1260
-				print 'var placeholderInPlace = \'&nbsp;\';'."\n";	// If we put another string than $langs->trans("ClickToEdit") here, nothing is shown. If we put empty string, there is error, Why ?
1259
+				print 'var tooltipInPlace = \''.$langs->transnoentities('ClickToEdit').'\';'."\n"; // Added in title attribute of span
1260
+				print 'var placeholderInPlace = \'&nbsp;\';'."\n"; // If we put another string than $langs->trans("ClickToEdit") here, nothing is shown. If we put empty string, there is error, Why ?
1261 1261
 				print 'var cancelInPlace = \''.$langs->trans('Cancel').'\';'."\n";
1262 1262
 				print 'var submitInPlace = \''.$langs->trans('Ok').'\';'."\n";
1263 1263
 				print 'var indicatorInPlace = \'<img src="'.DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif".'">\';'."\n";
1264
-				print 'var withInPlace = 300;';		// width in pixel for default string edit
1264
+				print 'var withInPlace = 300;'; // width in pixel for default string edit
1265 1265
 				print '</script>'."\n";
1266
-				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/editinplace.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1267
-				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.ckeditor.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1266
+				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/editinplace.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1267
+				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.ckeditor.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1268 1268
 			}
1269 1269
 			// jQuery DataTables
1270 1270
 			/* Removed a old hidden problematic feature never used in Dolibarr. If an external module need datatable, the module must provide all lib it needs and manage version problems with other dolibarr components
@@ -1280,67 +1280,67 @@  discard block
 block discarded – undo
1280 1280
                 print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jszip/jszip.min.js"></script>'."\n";
1281 1281
             }*/
1282 1282
             // jQuery Timepicker
1283
-            if (! empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER'))
1283
+            if (!empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER'))
1284 1284
             {
1285
-            	print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1286
-            	print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/timepicker.js.php?lang='.$langs->defaultlang.($ext?'&amp;'.$ext:'').'"></script>'."\n";
1285
+            	print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
1286
+            	print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/timepicker.js.php?lang='.$langs->defaultlang.($ext ? '&amp;'.$ext : '').'"></script>'."\n";
1287 1287
             }
1288
-            if (! defined('DISABLE_SELECT2') && (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')))     // jQuery plugin "mutiselect", "multiple-select", "select2", ...
1288
+            if (!defined('DISABLE_SELECT2') && (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')))     // jQuery plugin "mutiselect", "multiple-select", "select2", ...
1289 1289
             {
1290
-            	$tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT;
1291
-            	print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/'.$tmpplugin.'/dist/js/'.$tmpplugin.'.full.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";	// We include full because we need the support of containerCssClass
1290
+            	$tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
1291
+            	print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/'.$tmpplugin.'/dist/js/'.$tmpplugin.'.full.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n"; // We include full because we need the support of containerCssClass
1292 1292
             }
1293 1293
         }
1294 1294
 
1295
-        if (! $disablejs && ! empty($conf->use_javascript_ajax))
1295
+        if (!$disablejs && !empty($conf->use_javascript_ajax))
1296 1296
         {
1297 1297
             // CKEditor
1298
-            if (! empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') && ! defined('DISABLE_CKEDITOR'))
1298
+            if (!empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') && !defined('DISABLE_CKEDITOR'))
1299 1299
             {
1300 1300
                 print '<!-- Includes JS for CKEditor -->'."\n";
1301
-                $pathckeditor = DOL_URL_ROOT . '/includes/ckeditor/ckeditor/';
1302
-                $jsckeditor='ckeditor.js';
1301
+                $pathckeditor = DOL_URL_ROOT.'/includes/ckeditor/ckeditor/';
1302
+                $jsckeditor = 'ckeditor.js';
1303 1303
                 if (constant('JS_CKEDITOR'))	// To use external ckeditor 4 js lib
1304 1304
                 {
1305
-                	$pathckeditor=constant('JS_CKEDITOR');
1305
+                	$pathckeditor = constant('JS_CKEDITOR');
1306 1306
                 }
1307 1307
                 print '<script type="text/javascript">';
1308 1308
                 print 'var CKEDITOR_BASEPATH = \''.$pathckeditor.'\';'."\n";
1309
-                print 'var ckeditorConfig = \''.dol_buildpath($themesubdir.'/theme/'.$conf->theme.'/ckeditor/config.js'.($ext?'?'.$ext:''),1).'\';'."\n";		// $themesubdir='' in standard usage
1309
+                print 'var ckeditorConfig = \''.dol_buildpath($themesubdir.'/theme/'.$conf->theme.'/ckeditor/config.js'.($ext ? '?'.$ext : ''), 1).'\';'."\n"; // $themesubdir='' in standard usage
1310 1310
                 print 'var ckeditorFilebrowserBrowseUrl = \''.DOL_URL_ROOT.'/core/filemanagerdol/browser/default/browser.php?Connector='.DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php\';'."\n";
1311 1311
                 print 'var ckeditorFilebrowserImageBrowseUrl = \''.DOL_URL_ROOT.'/core/filemanagerdol/browser/default/browser.php?Type=Image&Connector='.DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php\';'."\n";
1312 1312
                 print '</script>'."\n";
1313
-                print '<script type="text/javascript" src="'.$pathckeditor.$jsckeditor.($ext?'?'.$ext:'').'"></script>'."\n";
1313
+                print '<script type="text/javascript" src="'.$pathckeditor.$jsckeditor.($ext ? '?'.$ext : '').'"></script>'."\n";
1314 1314
             }
1315 1315
 
1316 1316
             // Browser notifications
1317
-            if (! defined('DISABLE_BROWSER_NOTIF'))
1317
+            if (!defined('DISABLE_BROWSER_NOTIF'))
1318 1318
             {
1319
-                $enablebrowsernotif=false;
1320
-                if (! empty($conf->agenda->enabled) && ! empty($conf->global->AGENDA_REMINDER_BROWSER)) $enablebrowsernotif=true;
1321
-                if ($conf->browser->layout == 'phone') $enablebrowsernotif=false;
1319
+                $enablebrowsernotif = false;
1320
+                if (!empty($conf->agenda->enabled) && !empty($conf->global->AGENDA_REMINDER_BROWSER)) $enablebrowsernotif = true;
1321
+                if ($conf->browser->layout == 'phone') $enablebrowsernotif = false;
1322 1322
                 if ($enablebrowsernotif)
1323 1323
                 {
1324 1324
                     print '<!-- Includes JS of Dolibarr (brwoser layout = '.$conf->browser->layout.')-->'."\n";
1325
-                    print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/lib_notification.js.php'.($ext?'?'.$ext:'').'"></script>'."\n";
1325
+                    print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/lib_notification.js.php'.($ext ? '?'.$ext : '').'"></script>'."\n";
1326 1326
                 }
1327 1327
             }
1328 1328
 
1329 1329
             // Global js function
1330 1330
             print '<!-- Includes JS of Dolibarr -->'."\n";
1331
-            print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/lib_head.js.php?lang='.$langs->defaultlang.($ext?'&amp;'.$ext:'').'"></script>'."\n";
1331
+            print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/lib_head.js.php?lang='.$langs->defaultlang.($ext ? '&amp;'.$ext : '').'"></script>'."\n";
1332 1332
 
1333 1333
             // JS forced by modules (relative url starting with /)
1334
-            if (! empty($conf->modules_parts['js']))		// $conf->modules_parts['js'] is array('module'=>array('file1','file2'))
1334
+            if (!empty($conf->modules_parts['js']))		// $conf->modules_parts['js'] is array('module'=>array('file1','file2'))
1335 1335
         	{
1336
-        		$arrayjs=(array) $conf->modules_parts['js'];
1337
-	            foreach($arrayjs as $modjs => $filesjs)
1336
+        		$arrayjs = (array) $conf->modules_parts['js'];
1337
+	            foreach ($arrayjs as $modjs => $filesjs)
1338 1338
 	            {
1339
-        			$filesjs=(array) $filesjs;	// To be sure filejs is an array
1340
-		            foreach($filesjs as $jsfile)
1339
+        			$filesjs = (array) $filesjs; // To be sure filejs is an array
1340
+		            foreach ($filesjs as $jsfile)
1341 1341
 		            {
1342 1342
 	    	    		// jsfile is a relative path
1343
-	        	    	print '<!-- Include JS added by module '.$modjs. '-->'."\n".'<script type="text/javascript" src="'.dol_buildpath($jsfile,1).'"></script>'."\n";
1343
+	        	    	print '<!-- Include JS added by module '.$modjs.'-->'."\n".'<script type="text/javascript" src="'.dol_buildpath($jsfile, 1).'"></script>'."\n";
1344 1344
 		            }
1345 1345
 	            }
1346 1346
         	}
@@ -1348,28 +1348,28 @@  discard block
 block discarded – undo
1348 1348
             if (is_array($arrayofjs))
1349 1349
             {
1350 1350
                 print '<!-- Includes JS added by page -->'."\n";
1351
-                foreach($arrayofjs as $jsfile)
1351
+                foreach ($arrayofjs as $jsfile)
1352 1352
                 {
1353
-                    if (preg_match('/^http/i',$jsfile))
1353
+                    if (preg_match('/^http/i', $jsfile))
1354 1354
                     {
1355 1355
                         print '<script type="text/javascript" src="'.$jsfile.'"></script>'."\n";
1356 1356
                     }
1357 1357
                     else
1358 1358
                     {
1359
-                        if (! preg_match('/^\//',$jsfile)) $jsfile='/'.$jsfile;	// For backward compatibility
1360
-                        print '<script type="text/javascript" src="'.dol_buildpath($jsfile,1).'"></script>'."\n";
1359
+                        if (!preg_match('/^\//', $jsfile)) $jsfile = '/'.$jsfile; // For backward compatibility
1360
+                        print '<script type="text/javascript" src="'.dol_buildpath($jsfile, 1).'"></script>'."\n";
1361 1361
                     }
1362 1362
                 }
1363 1363
             }
1364 1364
         }
1365 1365
 
1366
-        if (! empty($head)) print $head."\n";
1367
-        if (! empty($conf->global->MAIN_HTML_HEADER)) print $conf->global->MAIN_HTML_HEADER."\n";
1366
+        if (!empty($head)) print $head."\n";
1367
+        if (!empty($conf->global->MAIN_HTML_HEADER)) print $conf->global->MAIN_HTML_HEADER."\n";
1368 1368
 
1369 1369
         print "</head>\n\n";
1370 1370
     }
1371 1371
 
1372
-    $conf->headerdone=1;	// To tell header was output
1372
+    $conf->headerdone = 1; // To tell header was output
1373 1373
 }
1374 1374
 
1375 1375
 
@@ -1389,19 +1389,19 @@  discard block
 block discarded – undo
1389 1389
  * 									                   For other external page: http://server/url
1390 1390
  *  @return		void
1391 1391
  */
1392
-function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $helppagename='')
1392
+function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '', $morequerystring = '', $helppagename = '')
1393 1393
 {
1394 1394
 	global $user, $conf, $langs, $db;
1395 1395
 	global $dolibarr_main_authentication, $dolibarr_main_demo;
1396
-	global $hookmanager,$menumanager;
1396
+	global $hookmanager, $menumanager;
1397 1397
 
1398
-	$searchform='';
1399
-	$bookmarks='';
1398
+	$searchform = '';
1399
+	$bookmarks = '';
1400 1400
 
1401 1401
 	// Instantiate hooks of thirdparty module
1402 1402
 	$hookmanager->initHooks(array('toprightmenu'));
1403 1403
 
1404
-	$toprightmenu='';
1404
+	$toprightmenu = '';
1405 1405
 
1406 1406
 	// For backward compatibility with old modules
1407 1407
 	if (empty($conf->headerdone))
@@ -1413,49 +1413,49 @@  discard block
 block discarded – undo
1413 1413
 	/*
1414 1414
      * Top menu
1415 1415
      */
1416
-	if (empty($conf->dol_hide_topmenu) && (! defined('NOREQUIREMENU') || ! constant('NOREQUIREMENU')))
1416
+	if (empty($conf->dol_hide_topmenu) && (!defined('NOREQUIREMENU') || !constant('NOREQUIREMENU')))
1417 1417
 	{
1418 1418
 		print "\n".'<!-- Start top horizontal -->'."\n";
1419 1419
 
1420 1420
 		print '<div class="side-nav-vert"><div id="id-top">';
1421 1421
 
1422 1422
 		// Show menu entries
1423
-		print '<div id="tmenu_tooltip'.(empty($conf->global->MAIN_MENU_INVERT)?'':'invert').'" class="tmenu">'."\n";
1424
-		$menumanager->atarget=$target;
1425
-		$menumanager->showmenu('top', array('searchform'=>$searchform, 'bookmarks'=>$bookmarks));      // This contains a \n
1423
+		print '<div id="tmenu_tooltip'.(empty($conf->global->MAIN_MENU_INVERT) ? '' : 'invert').'" class="tmenu">'."\n";
1424
+		$menumanager->atarget = $target;
1425
+		$menumanager->showmenu('top', array('searchform'=>$searchform, 'bookmarks'=>$bookmarks)); // This contains a \n
1426 1426
 		print "</div>\n";
1427 1427
 
1428 1428
 		// Define link to login card
1429
-		$appli=constant('DOL_APPLICATION_TITLE');
1430
-		if (! empty($conf->global->MAIN_APPLICATION_TITLE))
1429
+		$appli = constant('DOL_APPLICATION_TITLE');
1430
+		if (!empty($conf->global->MAIN_APPLICATION_TITLE))
1431 1431
 		{
1432
-			$appli=$conf->global->MAIN_APPLICATION_TITLE;
1432
+			$appli = $conf->global->MAIN_APPLICATION_TITLE;
1433 1433
 			if (preg_match('/\d\.\d/', $appli))
1434 1434
 			{
1435
-				if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")";	// If new title contains a version that is different than core
1435
+				if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
1436 1436
 			}
1437
-			else $appli.=" ".DOL_VERSION;
1437
+			else $appli .= " ".DOL_VERSION;
1438 1438
 		}
1439
-		else $appli.=" ".DOL_VERSION;
1439
+		else $appli .= " ".DOL_VERSION;
1440 1440
 
1441
-		if (! empty($conf->global->MAIN_FEATURES_LEVEL)) $appli.="<br>".$langs->trans("LevelOfFeature").': '.$conf->global->MAIN_FEATURES_LEVEL;
1441
+		if (!empty($conf->global->MAIN_FEATURES_LEVEL)) $appli .= "<br>".$langs->trans("LevelOfFeature").': '.$conf->global->MAIN_FEATURES_LEVEL;
1442 1442
 
1443
-		$logouttext='';
1443
+		$logouttext = '';
1444 1444
 		if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
1445 1445
 		{
1446 1446
 			//$logouthtmltext=$appli.'<br>';
1447 1447
 			if ($_SESSION["dol_authmode"] != 'forceuser' && $_SESSION["dol_authmode"] != 'http')
1448 1448
 			{
1449
-				$logouthtmltext.=$langs->trans("Logout").'<br>';
1449
+				$logouthtmltext .= $langs->trans("Logout").'<br>';
1450 1450
 
1451
-				$logouttext .='<a href="'.DOL_URL_ROOT.'/user/logout.php">';
1451
+				$logouttext .= '<a href="'.DOL_URL_ROOT.'/user/logout.php">';
1452 1452
 				//$logouttext .= img_picto($langs->trans('Logout').":".$langs->trans('Logout'), 'logout_top.png', 'class="login"', 0, 0, 1);
1453
-				$logouttext .='<span class="fa fa-sign-out atoplogin"></span>';
1454
-				$logouttext .='</a>';
1453
+				$logouttext .= '<span class="fa fa-sign-out atoplogin"></span>';
1454
+				$logouttext .= '</a>';
1455 1455
 			}
1456 1456
 			else
1457 1457
 			{
1458
-				$logouthtmltext.=$langs->trans("NoLogoutProcessWithAuthMode",$_SESSION["dol_authmode"]);
1458
+				$logouthtmltext .= $langs->trans("NoLogoutProcessWithAuthMode", $_SESSION["dol_authmode"]);
1459 1459
 				$logouttext .= img_picto($langs->trans('Logout').":".$langs->trans('Logout'), 'logout_top.png', 'class="login"', 0, 0, 1);
1460 1460
 			}
1461 1461
 		}
@@ -1463,55 +1463,55 @@  discard block
 block discarded – undo
1463 1463
 		print '<div class="login_block">'."\n";
1464 1464
 
1465 1465
 		// Add login user link
1466
-		$toprightmenu.='<div class="login_block_user">';
1466
+		$toprightmenu .= '<div class="login_block_user">';
1467 1467
 
1468 1468
 		// Login name with photo and tooltip
1469
-		$mode=-1;
1470
-		$toprightmenu.='<div class="inline-block nowrap"><div class="inline-block login_block_elem login_block_elem_name" style="padding: 0px;">';
1471
-		$toprightmenu.=$user->getNomUrl($mode, '', 1, 0, 11, 0, ($user->firstname ? 'firstname' : -1),'atoplogin');
1472
-		$toprightmenu.='</div></div>';
1469
+		$mode = -1;
1470
+		$toprightmenu .= '<div class="inline-block nowrap"><div class="inline-block login_block_elem login_block_elem_name" style="padding: 0px;">';
1471
+		$toprightmenu .= $user->getNomUrl($mode, '', 1, 0, 11, 0, ($user->firstname ? 'firstname' : -1), 'atoplogin');
1472
+		$toprightmenu .= '</div></div>';
1473 1473
 
1474
-		$toprightmenu.='</div>'."\n";
1474
+		$toprightmenu .= '</div>'."\n";
1475 1475
 
1476
-		$toprightmenu.='<div class="login_block_other">';
1476
+		$toprightmenu .= '<div class="login_block_other">';
1477 1477
 
1478 1478
 		// Execute hook printTopRightMenu (hooks should output string like '<div class="login"><a href="">mylink</a></div>')
1479
-		$parameters=array();
1480
-		$result=$hookmanager->executeHooks('printTopRightMenu',$parameters);    // Note that $action and $object may have been modified by some hooks
1479
+		$parameters = array();
1480
+		$result = $hookmanager->executeHooks('printTopRightMenu', $parameters); // Note that $action and $object may have been modified by some hooks
1481 1481
 		if (is_numeric($result))
1482 1482
 		{
1483
-			if (empty($result)) $toprightmenu.=$hookmanager->resPrint;		// add
1484
-			else  $toprightmenu=$hookmanager->resPrint;						// replace
1483
+			if (empty($result)) $toprightmenu .= $hookmanager->resPrint; // add
1484
+			else  $toprightmenu = $hookmanager->resPrint; // replace
1485 1485
 		}
1486
-		else $toprightmenu.=$result;	// For backward compatibility
1486
+		else $toprightmenu .= $result; // For backward compatibility
1487 1487
 
1488 1488
 		// Link to module builder
1489
-		if (! empty($conf->modulebuilder->enabled))
1489
+		if (!empty($conf->modulebuilder->enabled))
1490 1490
 		{
1491
-			$text ='<a href="'.DOL_URL_ROOT.'/modulebuilder/index.php?mainmenu=home&leftmenu=admintools" target="_modulebuilder">';
1491
+			$text = '<a href="'.DOL_URL_ROOT.'/modulebuilder/index.php?mainmenu=home&leftmenu=admintools" target="_modulebuilder">';
1492 1492
 			//$text.= img_picto(":".$langs->trans("ModuleBuilder"), 'printer_top.png', 'class="printer"');
1493
-			$text.='<span class="fa fa-bug atoplogin"></span>';
1494
-			$text.='</a>';
1495
-			$toprightmenu.=@Form::textwithtooltip('',$langs->trans("ModuleBuilder"),2,1,$text,'login_block_elem',2);
1493
+			$text .= '<span class="fa fa-bug atoplogin"></span>';
1494
+			$text .= '</a>';
1495
+			$toprightmenu .= @Form::textwithtooltip('', $langs->trans("ModuleBuilder"), 2, 1, $text, 'login_block_elem', 2);
1496 1496
 		}
1497 1497
 
1498 1498
 		// Link to print main content area
1499 1499
 		if (empty($conf->global->MAIN_PRINT_DISABLELINK) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && empty($conf->browser->phone))
1500 1500
 		{
1501
-			$qs=dol_escape_htmltag($_SERVER["QUERY_STRING"]);
1501
+			$qs = dol_escape_htmltag($_SERVER["QUERY_STRING"]);
1502 1502
 
1503 1503
 			if (is_array($_POST))
1504 1504
 			{
1505
-				foreach($_POST as $key=>$value) {
1506
-					if ($key!=='action' && !is_array($value)) $qs.='&'.$key.'='.urlencode($value);
1505
+				foreach ($_POST as $key=>$value) {
1506
+					if ($key !== 'action' && !is_array($value)) $qs .= '&'.$key.'='.urlencode($value);
1507 1507
 				}
1508 1508
 			}
1509
-			$qs.=(($qs && $morequerystring)?'&':'').$morequerystring;
1510
-			$text ='<a href="'.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.$qs.($qs?'&':'').'optioncss=print" target="_blank">';
1509
+			$qs .= (($qs && $morequerystring) ? '&' : '').$morequerystring;
1510
+			$text = '<a href="'.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.$qs.($qs ? '&' : '').'optioncss=print" target="_blank">';
1511 1511
 			//$text.= img_picto(":".$langs->trans("PrintContentArea"), 'printer_top.png', 'class="printer"');
1512
-			$text.='<span class="fa fa-print atoplogin"></span>';
1513
-			$text.='</a>';
1514
-			$toprightmenu.=@Form::textwithtooltip('',$langs->trans("PrintContentArea"),2,1,$text,'login_block_elem',2);
1512
+			$text .= '<span class="fa fa-print atoplogin"></span>';
1513
+			$text .= '</a>';
1514
+			$toprightmenu .= @Form::textwithtooltip('', $langs->trans("PrintContentArea"), 2, 1, $text, 'login_block_elem', 2);
1515 1515
 		}
1516 1516
 
1517 1517
 		// Link to Dolibarr wiki pages
@@ -1519,43 +1519,43 @@  discard block
 block discarded – undo
1519 1519
 		{
1520 1520
 			$langs->load("help");
1521 1521
 
1522
-			$helpbaseurl='';
1523
-			$helppage='';
1524
-			$mode='';
1522
+			$helpbaseurl = '';
1523
+			$helppage = '';
1524
+			$mode = '';
1525 1525
 
1526
-			if (empty($helppagename)) $helppagename='EN:User_documentation|FR:Documentation_utilisateur|ES:Documentación_usuarios';
1526
+			if (empty($helppagename)) $helppagename = 'EN:User_documentation|FR:Documentation_utilisateur|ES:Documentación_usuarios';
1527 1527
 
1528 1528
 			// Get helpbaseurl, helppage and mode from helppagename and langs
1529
-			$arrayres=getHelpParamFor($helppagename,$langs);
1530
-			$helpbaseurl=$arrayres['helpbaseurl'];
1531
-			$helppage=$arrayres['helppage'];
1532
-			$mode=$arrayres['mode'];
1529
+			$arrayres = getHelpParamFor($helppagename, $langs);
1530
+			$helpbaseurl = $arrayres['helpbaseurl'];
1531
+			$helppage = $arrayres['helppage'];
1532
+			$mode = $arrayres['mode'];
1533 1533
 
1534 1534
 			// Link to help pages
1535 1535
 			if ($helpbaseurl && $helppage)
1536 1536
 			{
1537
-				$text='';
1538
-				$title=$appli.'<br>';
1539
-				$title.=$langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage': 'GoToHelpPage');
1540
-				if ($mode == 'wiki') $title.=' - '.$langs->trans("PageWiki").' &quot;'.dol_escape_htmltag(strtr($helppage,'_',' ')).'&quot;';
1541
-				$text.='<a class="help" target="_blank" href="';
1542
-				if ($mode == 'wiki') $text.=sprintf($helpbaseurl,urlencode(html_entity_decode($helppage)));
1543
-				else $text.=sprintf($helpbaseurl,$helppage);
1544
-				$text.='">';
1537
+				$text = '';
1538
+				$title = $appli.'<br>';
1539
+				$title .= $langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage' : 'GoToHelpPage');
1540
+				if ($mode == 'wiki') $title .= ' - '.$langs->trans("PageWiki").' &quot;'.dol_escape_htmltag(strtr($helppage, '_', ' ')).'&quot;';
1541
+				$text .= '<a class="help" target="_blank" href="';
1542
+				if ($mode == 'wiki') $text .= sprintf($helpbaseurl, urlencode(html_entity_decode($helppage)));
1543
+				else $text .= sprintf($helpbaseurl, $helppage);
1544
+				$text .= '">';
1545 1545
 				//$text.=img_picto('', 'helpdoc_top').' ';
1546
-				$text.='<span class="fa fa-question-circle atoplogin"></span>';
1546
+				$text .= '<span class="fa fa-question-circle atoplogin"></span>';
1547 1547
 				//$toprightmenu.=$langs->trans($mode == 'wiki' ? 'OnlineHelp': 'Help');
1548 1548
 				//if ($mode == 'wiki') $text.=' ('.dol_trunc(strtr($helppage,'_',' '),8).')';
1549
-				$text.='</a>';
1549
+				$text .= '</a>';
1550 1550
 				//$toprightmenu.='</div>'."\n";
1551
-				$toprightmenu.=@Form::textwithtooltip('',$title,2,1,$text,'login_block_elem',2);
1551
+				$toprightmenu .= @Form::textwithtooltip('', $title, 2, 1, $text, 'login_block_elem', 2);
1552 1552
 			}
1553 1553
 		}
1554 1554
 
1555 1555
 		// Logout link
1556
-		$toprightmenu.=@Form::textwithtooltip('',$logouthtmltext,2,1,$logouttext,'login_block_elem',2);
1556
+		$toprightmenu .= @Form::textwithtooltip('', $logouthtmltext, 2, 1, $logouttext, 'login_block_elem', 2);
1557 1557
 
1558
-		$toprightmenu.='</div>';
1558
+		$toprightmenu .= '</div>';
1559 1559
 
1560 1560
 		print $toprightmenu;
1561 1561
 
@@ -1568,7 +1568,7 @@  discard block
 block discarded – undo
1568 1568
 		print "<!-- End top horizontal menu -->\n\n";
1569 1569
 	}
1570 1570
 
1571
-	if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '<!-- Begin div id-container --><div id="id-container" class="id-container'.($morecss?' '.$morecss:'').'">';
1571
+	if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '<!-- Begin div id-container --><div id="id-container" class="id-container'.($morecss ? ' '.$morecss : '').'">';
1572 1572
 }
1573 1573
 
1574 1574
 
@@ -1586,81 +1586,81 @@  discard block
 block discarded – undo
1586 1586
  *  @param  string  $acceptdelayedhtml          1 if caller request to have html delayed content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect)
1587 1587
  *  @return	void
1588 1588
  */
1589
-function left_menu($menu_array_before, $helppagename='', $notused='', $menu_array_after='', $leftmenuwithoutmainarea=0, $title='', $acceptdelayedhtml=0)
1589
+function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_array_after = '', $leftmenuwithoutmainarea = 0, $title = '', $acceptdelayedhtml = 0)
1590 1590
 {
1591 1591
 	global $user, $conf, $langs, $db, $form;
1592 1592
 	global $hookmanager, $menumanager;
1593 1593
 
1594
-	$searchform='';
1595
-	$bookmarks='';
1594
+	$searchform = '';
1595
+	$bookmarks = '';
1596 1596
 
1597
-	if (! empty($menu_array_before)) dol_syslog("Deprecated parameter menu_array_before was used when calling main::left_menu function. Menu entries of module should now be defined into module descriptor and not provided when calling left_menu.", LOG_WARNING);
1597
+	if (!empty($menu_array_before)) dol_syslog("Deprecated parameter menu_array_before was used when calling main::left_menu function. Menu entries of module should now be defined into module descriptor and not provided when calling left_menu.", LOG_WARNING);
1598 1598
 
1599
-	if (empty($conf->dol_hide_leftmenu) && (! defined('NOREQUIREMENU') || ! constant('NOREQUIREMENU')))
1599
+	if (empty($conf->dol_hide_leftmenu) && (!defined('NOREQUIREMENU') || !constant('NOREQUIREMENU')))
1600 1600
 	{
1601 1601
 		// Instantiate hooks of thirdparty module
1602
-		$hookmanager->initHooks(array('searchform','leftblock'));
1602
+		$hookmanager->initHooks(array('searchform', 'leftblock'));
1603 1603
 
1604 1604
 		print "\n".'<!-- Begin side-nav id-left -->'."\n".'<div class="side-nav"><div id="id-left">'."\n";
1605 1605
 
1606 1606
 		print "\n";
1607 1607
 
1608
-		if ($conf->browser->layout == 'phone') $conf->global->MAIN_USE_OLD_SEARCH_FORM=1;	// Select into select2 is awfull on smartphone
1608
+		if ($conf->browser->layout == 'phone') $conf->global->MAIN_USE_OLD_SEARCH_FORM = 1; // Select into select2 is awfull on smartphone
1609 1609
 		if ($conf->use_javascript_ajax && empty($conf->global->MAIN_USE_OLD_SEARCH_FORM))
1610 1610
 		{
1611
-			if (! is_object($form)) $form=new Form($db);
1612
-			$selected=-1;
1613
-			$searchform.=$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'vmenusearchselectcombo', 1, $langs->trans("Search"), 1);
1611
+			if (!is_object($form)) $form = new Form($db);
1612
+			$selected = -1;
1613
+			$searchform .= $form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'vmenusearchselectcombo', 1, $langs->trans("Search"), 1);
1614 1614
 		}
1615 1615
 		else
1616 1616
 		{
1617
-			if (! is_object($form)) $form=new Form($db);
1618
-			$selected=-1;
1619
-			$usedbyinclude=1;
1617
+			if (!is_object($form)) $form = new Form($db);
1618
+			$selected = -1;
1619
+			$usedbyinclude = 1;
1620 1620
 			include_once DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php';
1621 1621
 
1622
-			foreach($arrayresult as $key => $val)
1622
+			foreach ($arrayresult as $key => $val)
1623 1623
 			{
1624 1624
 				//$searchform.=printSearchForm($val['url'], $val['url'], $val['label'], 'maxwidth100', 'sall', $val['shortcut'], 'searchleftt', img_picto('',$val['img']));
1625
-				$searchform.=printSearchForm($val['url'], $val['url'], $val['label'], 'maxwidth125', 'sall', $val['shortcut'], 'searchleftt', img_picto('', $val['img'], '', false, 1, 1));
1625
+				$searchform .= printSearchForm($val['url'], $val['url'], $val['label'], 'maxwidth125', 'sall', $val['shortcut'], 'searchleftt', img_picto('', $val['img'], '', false, 1, 1));
1626 1626
 			}
1627 1627
 		}
1628 1628
 
1629 1629
 		// Execute hook printSearchForm
1630
-		$parameters=array('searchform'=>$searchform);
1631
-		$reshook=$hookmanager->executeHooks('printSearchForm',$parameters);    // Note that $action and $object may have been modified by some hooks
1630
+		$parameters = array('searchform'=>$searchform);
1631
+		$reshook = $hookmanager->executeHooks('printSearchForm', $parameters); // Note that $action and $object may have been modified by some hooks
1632 1632
 		if (empty($reshook))
1633 1633
 		{
1634
-			$searchform.=$hookmanager->resPrint;
1634
+			$searchform .= $hookmanager->resPrint;
1635 1635
 		}
1636
-		else $searchform=$hookmanager->resPrint;
1636
+		else $searchform = $hookmanager->resPrint;
1637 1637
 
1638
-		if ($conf->use_javascript_ajax && ! empty($conf->global->MAIN_USE_OLD_SEARCH_FORM))
1638
+		if ($conf->use_javascript_ajax && !empty($conf->global->MAIN_USE_OLD_SEARCH_FORM))
1639 1639
 		{
1640
-			$searchform='<div class="blockvmenuimpair blockvmenusearchphone"><div id="divsearchforms1"><a href="#" alt="'.dol_escape_htmltag($langs->trans("ShowSearchFields")).'">'.$langs->trans("Search").'...</a></div><div id="divsearchforms2" style="display: none">'.$searchform.'</div>';
1641
-			$searchform.='<script type="text/javascript">
1640
+			$searchform = '<div class="blockvmenuimpair blockvmenusearchphone"><div id="divsearchforms1"><a href="#" alt="'.dol_escape_htmltag($langs->trans("ShowSearchFields")).'">'.$langs->trans("Search").'...</a></div><div id="divsearchforms2" style="display: none">'.$searchform.'</div>';
1641
+			$searchform .= '<script type="text/javascript">
1642 1642
             	jQuery(document).ready(function () {
1643 1643
             		jQuery("#divsearchforms1").click(function(){
1644 1644
 	                   jQuery("#divsearchforms2").toggle();
1645 1645
 	               });
1646 1646
             	});
1647 1647
                 </script>' . "\n";
1648
-			$searchform.='</div>';
1648
+			$searchform .= '</div>';
1649 1649
 		}
1650 1650
 
1651 1651
 		// Define $bookmarks
1652
-		if (! empty($conf->bookmark->enabled) && $user->rights->bookmark->lire)
1652
+		if (!empty($conf->bookmark->enabled) && $user->rights->bookmark->lire)
1653 1653
 		{
1654 1654
 			include_once (DOL_DOCUMENT_ROOT.'/bookmarks/bookmarks.lib.php');
1655 1655
 			$langs->load("bookmarks");
1656 1656
 
1657
-			$bookmarks=printBookmarksList($db, $langs);
1657
+			$bookmarks = printBookmarksList($db, $langs);
1658 1658
 		}
1659 1659
 
1660 1660
 		// Left column
1661 1661
 		print '<!-- Begin left menu -->'."\n";
1662 1662
 
1663
-		print '<div class="vmenu"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?'':' title="Left menu"').'>'."\n\n";
1663
+		print '<div class="vmenu"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' title="Left menu"').'>'."\n\n";
1664 1664
 
1665 1665
 		// Show left menu with other forms
1666 1666
 		$menumanager->menu_array = $menu_array_before;
@@ -1675,25 +1675,25 @@  discard block
 block discarded – undo
1675 1675
 		// Version
1676 1676
 		if (empty($conf->global->MAIN_HIDE_VERSION))    // Version is already on help picto and on login page.
1677 1677
 		{
1678
-			$doliurl='https://www.dolibarr.org';
1678
+			$doliurl = 'https://www.dolibarr.org';
1679 1679
 			//local communities
1680
-			if (preg_match('/fr/i',$langs->defaultlang)) $doliurl='https://www.dolibarr.fr';
1681
-			if (preg_match('/es/i',$langs->defaultlang)) $doliurl='https://www.dolibarr.es';
1682
-			if (preg_match('/de/i',$langs->defaultlang)) $doliurl='https://www.dolibarr.de';
1683
-			if (preg_match('/it/i',$langs->defaultlang)) $doliurl='https://www.dolibarr.it';
1684
-			if (preg_match('/gr/i',$langs->defaultlang)) $doliurl='https://www.dolibarr.gr';
1685
-
1686
-			$appli=constant('DOL_APPLICATION_TITLE');
1687
-			if (! empty($conf->global->MAIN_APPLICATION_TITLE))
1680
+			if (preg_match('/fr/i', $langs->defaultlang)) $doliurl = 'https://www.dolibarr.fr';
1681
+			if (preg_match('/es/i', $langs->defaultlang)) $doliurl = 'https://www.dolibarr.es';
1682
+			if (preg_match('/de/i', $langs->defaultlang)) $doliurl = 'https://www.dolibarr.de';
1683
+			if (preg_match('/it/i', $langs->defaultlang)) $doliurl = 'https://www.dolibarr.it';
1684
+			if (preg_match('/gr/i', $langs->defaultlang)) $doliurl = 'https://www.dolibarr.gr';
1685
+
1686
+			$appli = constant('DOL_APPLICATION_TITLE');
1687
+			if (!empty($conf->global->MAIN_APPLICATION_TITLE))
1688 1688
 			{
1689
-				$appli=$conf->global->MAIN_APPLICATION_TITLE; $doliurl='';
1689
+				$appli = $conf->global->MAIN_APPLICATION_TITLE; $doliurl = '';
1690 1690
 				if (preg_match('/\d\.\d/', $appli))
1691 1691
 				{
1692
-					if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")";	// If new title contains a version that is different than core
1692
+					if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
1693 1693
 				}
1694
-				else $appli.=" ".DOL_VERSION;
1694
+				else $appli .= " ".DOL_VERSION;
1695 1695
 			}
1696
-			else $appli.=" ".DOL_VERSION;
1696
+			else $appli .= " ".DOL_VERSION;
1697 1697
 			print '<div id="blockvmenuhelpapp" class="blockvmenuhelp">';
1698 1698
 			if ($doliurl) print '<a class="help" target="_blank" href="'.$doliurl.'">';
1699 1699
 			else print '<span class="help">';
@@ -1704,26 +1704,26 @@  discard block
 block discarded – undo
1704 1704
 		}
1705 1705
 
1706 1706
 		// Link to bugtrack
1707
-		if (! empty($conf->global->MAIN_BUGTRACK_ENABLELINK))
1707
+		if (!empty($conf->global->MAIN_BUGTRACK_ENABLELINK))
1708 1708
 		{
1709 1709
 			require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
1710 1710
 
1711 1711
 			$bugbaseurl = 'https://github.com/Dolibarr/dolibarr/issues/new';
1712
-			$bugbaseurl.= '?title=';
1713
-			$bugbaseurl.= urlencode("Bug: ");
1714
-			$bugbaseurl.= '&body=';
1712
+			$bugbaseurl .= '?title=';
1713
+			$bugbaseurl .= urlencode("Bug: ");
1714
+			$bugbaseurl .= '&body=';
1715 1715
 			// TODO use .github/ISSUE_TEMPLATE.md to generate?
1716 1716
 			$bugbaseurl .= urlencode("# Bug\n");
1717 1717
 			$bugbaseurl .= urlencode("\n");
1718
-			$bugbaseurl.= urlencode("## Environment\n");
1719
-			$bugbaseurl.= urlencode("- **Version**: " . DOL_VERSION . "\n");
1720
-			$bugbaseurl.= urlencode("- **OS**: " . php_uname('s') . "\n");
1721
-			$bugbaseurl.= urlencode("- **Web server**: " . $_SERVER["SERVER_SOFTWARE"] . "\n");
1722
-			$bugbaseurl.= urlencode("- **PHP**: " . php_sapi_name() . ' ' . phpversion() . "\n");
1723
-			$bugbaseurl.= urlencode("- **Database**: " . $db::LABEL . ' ' . $db->getVersion() . "\n");
1724
-			$bugbaseurl.= urlencode("- **URL**: " . $_SERVER["REQUEST_URI"] . "\n");
1725
-			$bugbaseurl.= urlencode("\n");
1726
-			$bugbaseurl.= urlencode("## Report\n");
1718
+			$bugbaseurl .= urlencode("## Environment\n");
1719
+			$bugbaseurl .= urlencode("- **Version**: ".DOL_VERSION."\n");
1720
+			$bugbaseurl .= urlencode("- **OS**: ".php_uname('s')."\n");
1721
+			$bugbaseurl .= urlencode("- **Web server**: ".$_SERVER["SERVER_SOFTWARE"]."\n");
1722
+			$bugbaseurl .= urlencode("- **PHP**: ".php_sapi_name().' '.phpversion()."\n");
1723
+			$bugbaseurl .= urlencode("- **Database**: ".$db::LABEL.' '.$db->getVersion()."\n");
1724
+			$bugbaseurl .= urlencode("- **URL**: ".$_SERVER["REQUEST_URI"]."\n");
1725
+			$bugbaseurl .= urlencode("\n");
1726
+			$bugbaseurl .= urlencode("## Report\n");
1727 1727
 			print '<div id="blockvmenuhelpbugreport" class="blockvmenuhelp">';
1728 1728
 			print '<a class="help" target="_blank" href="'.$bugbaseurl.'">'.$langs->trans("FindBug").'</a>';
1729 1729
 			print '</div>';
@@ -1738,11 +1738,11 @@  discard block
 block discarded – undo
1738 1738
 		print "\n";
1739 1739
 
1740 1740
 		// Execute hook printLeftBlock
1741
-		$parameters=array();
1742
-		$reshook=$hookmanager->executeHooks('printLeftBlock',$parameters);    // Note that $action and $object may have been modified by some hooks
1741
+		$parameters = array();
1742
+		$reshook = $hookmanager->executeHooks('printLeftBlock', $parameters); // Note that $action and $object may have been modified by some hooks
1743 1743
 		print $hookmanager->resPrint;
1744 1744
 
1745
-		print '</div></div> <!-- End side-nav id-left -->';	// End div id="side-nav" div id="id-left"
1745
+		print '</div></div> <!-- End side-nav id-left -->'; // End div id="side-nav" div id="id-left"
1746 1746
 	}
1747 1747
 
1748 1748
 	print "\n";
@@ -1758,7 +1758,7 @@  discard block
 block discarded – undo
1758 1758
  *  @param	string	$title		Title
1759 1759
  *  @return	void
1760 1760
  */
1761
-function main_area($title='')
1761
+function main_area($title = '')
1762 1762
 {
1763 1763
 	global $conf, $langs;
1764 1764
 
@@ -1768,7 +1768,7 @@  discard block
 block discarded – undo
1768 1768
 
1769 1769
 	print '<!-- Begin div class="fiche" -->'."\n".'<div class="fiche">'."\n";
1770 1770
 
1771
-	if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) print info_admin($langs->trans("WarningYouAreInMaintenanceMode",$conf->global->MAIN_ONLY_LOGIN_ALLOWED));
1771
+	if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) print info_admin($langs->trans("WarningYouAreInMaintenanceMode", $conf->global->MAIN_ONLY_LOGIN_ALLOWED));
1772 1772
 }
1773 1773
 
1774 1774
 
@@ -1779,40 +1779,40 @@  discard block
 block discarded – undo
1779 1779
  *  @param  Translate	$langs				Language
1780 1780
  *  @return	array		Array of help urls
1781 1781
  */
1782
-function getHelpParamFor($helppagename,$langs)
1782
+function getHelpParamFor($helppagename, $langs)
1783 1783
 {
1784
-	$helpbaseurl='';
1785
-	$helppage='';
1786
-	$mode='';
1784
+	$helpbaseurl = '';
1785
+	$helppage = '';
1786
+	$mode = '';
1787 1787
 
1788
-	if (preg_match('/^http/i',$helppagename))
1788
+	if (preg_match('/^http/i', $helppagename))
1789 1789
 	{
1790 1790
 		// If complete URL
1791
-		$helpbaseurl='%s';
1792
-		$helppage=$helppagename;
1793
-		$mode='local';
1791
+		$helpbaseurl = '%s';
1792
+		$helppage = $helppagename;
1793
+		$mode = 'local';
1794 1794
 	}
1795 1795
 	else
1796 1796
 	{
1797 1797
 		// If WIKI URL
1798
-		if (preg_match('/^es/i',$langs->defaultlang))
1798
+		if (preg_match('/^es/i', $langs->defaultlang))
1799 1799
 		{
1800
-			$helpbaseurl='http://wiki.dolibarr.org/index.php/%s';
1801
-			if (preg_match('/ES:([^|]+)/i',$helppagename,$reg)) $helppage=$reg[1];
1800
+			$helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s';
1801
+			if (preg_match('/ES:([^|]+)/i', $helppagename, $reg)) $helppage = $reg[1];
1802 1802
 		}
1803
-		if (preg_match('/^fr/i',$langs->defaultlang))
1803
+		if (preg_match('/^fr/i', $langs->defaultlang))
1804 1804
 		{
1805
-			$helpbaseurl='http://wiki.dolibarr.org/index.php/%s';
1806
-			if (preg_match('/FR:([^|]+)/i',$helppagename,$reg)) $helppage=$reg[1];
1805
+			$helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s';
1806
+			if (preg_match('/FR:([^|]+)/i', $helppagename, $reg)) $helppage = $reg[1];
1807 1807
 		}
1808 1808
 		if (empty($helppage))	// If help page not already found
1809 1809
 		{
1810
-			$helpbaseurl='http://wiki.dolibarr.org/index.php/%s';
1811
-			if (preg_match('/EN:([^|]+)/i',$helppagename,$reg)) $helppage=$reg[1];
1810
+			$helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s';
1811
+			if (preg_match('/EN:([^|]+)/i', $helppagename, $reg)) $helppage = $reg[1];
1812 1812
 		}
1813
-		$mode='wiki';
1813
+		$mode = 'wiki';
1814 1814
 	}
1815
-	return array('helpbaseurl'=>$helpbaseurl,'helppage'=>$helppage,'mode'=>$mode);
1815
+	return array('helpbaseurl'=>$helpbaseurl, 'helppage'=>$helppage, 'mode'=>$mode);
1816 1816
 }
1817 1817
 
1818 1818
 
@@ -1830,31 +1830,31 @@  discard block
 block discarded – undo
1830 1830
  *  @param	string	$img				Image to use
1831 1831
  *  @return	string
1832 1832
  */
1833
-function printSearchForm($urlaction, $urlobject, $title, $htmlmorecss, $htmlinputname, $accesskey='', $prefhtmlinputname='',$img='')
1833
+function printSearchForm($urlaction, $urlobject, $title, $htmlmorecss, $htmlinputname, $accesskey = '', $prefhtmlinputname = '', $img = '')
1834 1834
 {
1835
-	global $conf,$langs,$user;
1835
+	global $conf, $langs, $user;
1836 1836
 
1837 1837
 	if (empty($htmlinputid)) {
1838 1838
 		$htmlinputid = $htmlinputname;
1839 1839
 	}
1840 1840
 
1841
-	$ret='';
1842
-	$ret.='<form action="'.$urlaction.'" method="post" class="searchform">';
1843
-	$ret.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
1844
-	$ret.='<input type="hidden" name="mode" value="search">';
1845
-	$ret.='<input type="hidden" name="savelogin" value="'.dol_escape_htmltag($user->login).'">';
1846
-	$ret.='<input type="text" class="flat '.$htmlmorecss.'"';
1847
-	$ret.=' style="text-indent: 22px; background-image: url(\''.$img.'\'); background-repeat: no-repeat; background-position: 3px;"';
1848
-	$ret.=($accesskey?' accesskey="'.$accesskey.'"':'');
1849
-	$ret.=' placeholder="'.strip_tags($title).'"';
1850
-	$ret.=' name="'.$htmlinputname.'" id="'.$prefhtmlinputname.$htmlinputname.'" />';
1851
-	$ret.='<input type="submit" class="button" style="padding-top: 4px; padding-bottom: 4px; padding-left: 6px; padding-right: 6px" value="'.$langs->trans("Go").'">';
1852
-	$ret.="</form>\n";
1841
+	$ret = '';
1842
+	$ret .= '<form action="'.$urlaction.'" method="post" class="searchform">';
1843
+	$ret .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
1844
+	$ret .= '<input type="hidden" name="mode" value="search">';
1845
+	$ret .= '<input type="hidden" name="savelogin" value="'.dol_escape_htmltag($user->login).'">';
1846
+	$ret .= '<input type="text" class="flat '.$htmlmorecss.'"';
1847
+	$ret .= ' style="text-indent: 22px; background-image: url(\''.$img.'\'); background-repeat: no-repeat; background-position: 3px;"';
1848
+	$ret .= ($accesskey ? ' accesskey="'.$accesskey.'"' : '');
1849
+	$ret .= ' placeholder="'.strip_tags($title).'"';
1850
+	$ret .= ' name="'.$htmlinputname.'" id="'.$prefhtmlinputname.$htmlinputname.'" />';
1851
+	$ret .= '<input type="submit" class="button" style="padding-top: 4px; padding-bottom: 4px; padding-left: 6px; padding-right: 6px" value="'.$langs->trans("Go").'">';
1852
+	$ret .= "</form>\n";
1853 1853
 	return $ret;
1854 1854
 }
1855 1855
 
1856 1856
 
1857
-if (! function_exists("llxFooter"))
1857
+if (!function_exists("llxFooter"))
1858 1858
 {
1859 1859
 	/**
1860 1860
 	 * Show HTML footer
@@ -1866,7 +1866,7 @@  discard block
 block discarded – undo
1866 1866
 	 * @param	int		$disabledoutputofmessages	Clear all messages stored into session without diplaying them
1867 1867
 	 * @return	void
1868 1868
 	 */
1869
-	function llxFooter($comment='',$zone='private', $disabledoutputofmessages=0)
1869
+	function llxFooter($comment = '', $zone = 'private', $disabledoutputofmessages = 0)
1870 1870
 	{
1871 1871
 		global $conf, $langs, $user, $object;
1872 1872
 		global $delayedhtmlcontent;
@@ -1876,10 +1876,10 @@  discard block
 block discarded – undo
1876 1876
 
1877 1877
 		// Code for search criteria persistence.
1878 1878
 		// Save $user->lastsearch_values if defined (define on list pages when a form field search_xxx exists)
1879
-		if (is_object($user) && ! empty($user->lastsearch_values_tmp) && is_array($user->lastsearch_values_tmp))
1879
+		if (is_object($user) && !empty($user->lastsearch_values_tmp) && is_array($user->lastsearch_values_tmp))
1880 1880
 		{
1881 1881
 			// Clean data
1882
-			foreach($user->lastsearch_values_tmp as $key => $val)
1882
+			foreach ($user->lastsearch_values_tmp as $key => $val)
1883 1883
 			{
1884 1884
 				unset($_SESSION['lastsearch_values_tmp_'.$key]);
1885 1885
 				if (count($val))
@@ -1887,14 +1887,14 @@  discard block
 block discarded – undo
1887 1887
 					if (empty($val['sortfield'])) unset($val['sortfield']);
1888 1888
 					if (empty($val['sortorder'])) unset($val['sortorder']);
1889 1889
 					dol_syslog('Save lastsearch_values_tmp_'.$key.'='.json_encode($val, 0)." (systematic recording of last search criteria)");
1890
-					$_SESSION['lastsearch_values_tmp_'.$key]=json_encode($val);
1890
+					$_SESSION['lastsearch_values_tmp_'.$key] = json_encode($val);
1891 1891
 					unset($_SESSION['lastsearch_values_'.$key]);
1892 1892
 				}
1893 1893
 			}
1894 1894
 		}
1895 1895
 
1896 1896
 		// Core error message
1897
-		if (! empty($conf->global->MAIN_CORE_ERROR))
1897
+		if (!empty($conf->global->MAIN_CORE_ERROR))
1898 1898
 		{
1899 1899
 			// Ajax version
1900 1900
 			if ($conf->use_javascript_ajax)
@@ -1923,14 +1923,14 @@  discard block
 block discarded – undo
1923 1923
 
1924 1924
 		printCommonFooter($zone);
1925 1925
 
1926
-		if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '</div> <!-- End div id-container -->'."\n";	// End div container
1926
+		if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '</div> <!-- End div id-container -->'."\n"; // End div container
1927 1927
 
1928
-		if (! empty($delayedhtmlcontent)) print $delayedhtmlcontent;
1928
+		if (!empty($delayedhtmlcontent)) print $delayedhtmlcontent;
1929 1929
 
1930 1930
 		// TODO Move this in lib_head.js.php
1931 1931
 
1932 1932
 		// Wrapper to show tooltips (html or onclick popup)
1933
-		if (! empty($conf->use_javascript_ajax) && empty($conf->dol_no_mouse_hover))
1933
+		if (!empty($conf->use_javascript_ajax) && empty($conf->dol_no_mouse_hover))
1934 1934
 		{
1935 1935
 			print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip -->\n";
1936 1936
 			print '<script type="text/javascript">
@@ -1958,7 +1958,7 @@  discard block
 block discarded – undo
1958 1958
 		}
1959 1959
 
1960 1960
 		// Wrapper to manage document_preview
1961
-		if (! empty($conf->use_javascript_ajax) && ($conf->browser->layout != 'phone'))
1961
+		if (!empty($conf->use_javascript_ajax) && ($conf->browser->layout != 'phone'))
1962 1962
 		{
1963 1963
 			print "\n<!-- JS CODE TO ENABLE document_preview -->\n";
1964 1964
 			print '<script type="text/javascript">
@@ -1973,7 +1973,7 @@  discard block
 block discarded – undo
1973 1973
 		}
1974 1974
 
1975 1975
 		// Wrapper to manage dropdown
1976
-		if (! empty($conf->use_javascript_ajax) && ! defined('JS_JQUERY_DISABLE_DROPDOWN'))
1976
+		if (!empty($conf->use_javascript_ajax) && !defined('JS_JQUERY_DISABLE_DROPDOWN'))
1977 1977
 		{
1978 1978
 			print "\n<!-- JS CODE TO ENABLE dropdown -->\n";
1979 1979
 			print '<script type="text/javascript">
@@ -2012,7 +2012,7 @@  discard block
 block discarded – undo
2012 2012
 		}
2013 2013
 
2014 2014
 		// Wrapper to add log when clicking on download or preview
2015
-		if (! empty($conf->blockedlog->enabled) && is_object($object) && $object->id > 0 && $object->statut > 0)
2015
+		if (!empty($conf->blockedlog->enabled) && is_object($object) && $object->id > 0 && $object->statut > 0)
2016 2016
 		{
2017 2017
 			if (in_array($object->element, array('facture')))       // Restrict for the moment to element 'facture'
2018 2018
 			{
Please login to merge, or discard this patch.
Braces   +492 added lines, -192 removed lines patch added patch discarded remove patch
@@ -48,7 +48,8 @@  discard block
 block discarded – undo
48 48
 }
49 49
 
50 50
 // Removed magic_quotes
51
-if (function_exists('get_magic_quotes_gpc'))	// magic_quotes_* deprecated in PHP 5.0 and removed in PHP 5.5
51
+if (function_exists('get_magic_quotes_gpc')) {
52
+	// magic_quotes_* deprecated in PHP 5.0 and removed in PHP 5.5
52 53
 {
53 54
 	if (get_magic_quotes_gpc())
54 55
 	{
@@ -59,6 +60,7 @@  discard block
 block discarded – undo
59 60
 		function stripslashes_deep($value)
60 61
 		{
61 62
 			return (is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value));
63
+}
62 64
 		}
63 65
 		$_GET     = array_map('stripslashes_deep', $_GET);
64 66
 		$_POST    = array_map('stripslashes_deep', $_POST);
@@ -98,7 +100,9 @@  discard block
 block discarded – undo
98 100
 	$inj += preg_match('/<script/i', $val);
99 101
 	$inj += preg_match('/<iframe/i', $val);
100 102
 	$inj += preg_match('/Set\.constructor/i', $val);	// ECMA script 6
101
-	if (! defined('NOSTYLECHECK')) $inj += preg_match('/<style/i', $val);
103
+	if (! defined('NOSTYLECHECK')) {
104
+		$inj += preg_match('/<style/i', $val);
105
+	}
102 106
 	$inj += preg_match('/base[\s]+href/si', $val);
103 107
 	$inj += preg_match('/<.*onmouse/si', $val);       // onmousexxx can be set on img or any html tag like <img title='...' onmouseover=alert(1)>
104 108
 	$inj += preg_match('/onerror\s*=/i', $val);       // onerror can be set on img or any html tag like <img title='...' onerror = alert(1)>
@@ -112,8 +116,14 @@  discard block
 block discarded – undo
112 116
 		$inj += preg_match('/vbscript:/i', $val);
113 117
 	//}
114 118
 	// For XSS Injection done by adding javascript closing html tags like with onmousemove, etc... (closing a src or href tag with not cleaned param)
115
-	if ($type == 1) $inj += preg_match('/"/i', $val);		// We refused " in GET parameters value
116
-	if ($type == 2) $inj += preg_match('/[;"]/', $val);		// PHP_SELF is a file system path. It can contains spaces.
119
+	if ($type == 1) {
120
+		$inj += preg_match('/"/i', $val);
121
+	}
122
+	// We refused " in GET parameters value
123
+	if ($type == 2) {
124
+		$inj += preg_match('/[;"]/', $val);
125
+	}
126
+	// PHP_SELF is a file system path. It can contains spaces.
117 127
 	return $inj;
118 128
 }
119 129
 
@@ -133,16 +143,14 @@  discard block
 block discarded – undo
133 143
 			if (analyseVarsForSqlAndScriptsInjection($value,$type))
134 144
 			{
135 145
 				$var[$key] = $value;
136
-			}
137
-			else
146
+			} else
138 147
 			{
139 148
 				print 'Access refused by SQL/Script injection protection in main.inc.php (type='.htmlentities($type).' key='.htmlentities($key).' value='.htmlentities($value).' page='.htmlentities($_SERVER["REQUEST_URI"]).')';
140 149
 				exit;
141 150
 			}
142 151
 		}
143 152
 		return true;
144
-	}
145
-	else
153
+	} else
146 154
 	{
147 155
 		return (test_sql_and_script_inject($var,$type) <= 0);
148 156
 	}
@@ -150,7 +158,9 @@  discard block
 block discarded – undo
150 158
 
151 159
 
152 160
 // Check consistency of NOREQUIREXXX DEFINES
153
-if ((defined('NOREQUIREDB') || defined('NOREQUIRETRAN')) && ! defined('NOREQUIREMENU')) dol_print_error('','If define NOREQUIREDB or NOREQUIRETRAN are set, you must also set NOREQUIREMENU or not use them');
161
+if ((defined('NOREQUIREDB') || defined('NOREQUIRETRAN')) && ! defined('NOREQUIREMENU')) {
162
+	dol_print_error('','If define NOREQUIREDB or NOREQUIRETRAN are set, you must also set NOREQUIREMENU or not use them');
163
+}
154 164
 
155 165
 // Sanity check on URL
156 166
 if (! empty($_SERVER["PHP_SELF"]))
@@ -191,20 +201,26 @@  discard block
 block discarded – undo
191 201
 	{
192 202
 		$postkey=$tmpautoset[0].'_'.$tmpkey;
193 203
 		//var_dump('tmpkey='.$tmpkey.' postkey='.$postkey.' value='.$_POST[$postkey]);
194
-		if (! empty($_POST[$postkey])) $cookiearrayvalue[$tmpkey]=$_POST[$postkey];
204
+		if (! empty($_POST[$postkey])) {
205
+			$cookiearrayvalue[$tmpkey]=$_POST[$postkey];
206
+		}
195 207
 	}
196 208
 	$cookiename=$tmpautoset[0];
197 209
 	$cookievalue=json_encode($cookiearrayvalue);
198 210
 	//var_dump('setcookie cookiename='.$cookiename.' cookievalue='.$cookievalue);
199 211
 	setcookie($cookiename, empty($cookievalue)?'':$cookievalue, empty($cookievalue)?0:(time()+(86400*354)), '/', null, false, true);	// keep cookie 1 year and add tag httponly
200
-	if (empty($cookievalue)) unset($_COOKIE[$cookiename]);
201
-}
212
+	if (empty($cookievalue)) {
213
+		unset($_COOKIE[$cookiename]);
214
+	}
215
+	}
202 216
 
203 217
 // Init session. Name of session is specific to Dolibarr instance.
204 218
 $prefix=dol_getprefix();
205 219
 $sessionname='DOLSESSID_'.$prefix;
206 220
 $sessiontimeout='DOLSESSTIMEOUT_'.$prefix;
207
-if (! empty($_COOKIE[$sessiontimeout])) ini_set('session.gc_maxlifetime',$_COOKIE[$sessiontimeout]);
221
+if (! empty($_COOKIE[$sessiontimeout])) {
222
+	ini_set('session.gc_maxlifetime',$_COOKIE[$sessiontimeout]);
223
+}
208 224
 session_name($sessionname);
209 225
 session_set_cookie_params(0, '/', null, false, true);   // Add tag httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start.
210 226
 // This create lock released until session_write_close() or end of page.
@@ -212,11 +228,13 @@  discard block
 block discarded – undo
212 228
 if (! defined('NOSESSION'))
213 229
 {
214 230
 	session_start();
215
-	if (ini_get('register_globals'))    // Deprecated in 5.3 and removed in 5.4. To solve bug in using $_SESSION
231
+	if (ini_get('register_globals')) {
232
+		// Deprecated in 5.3 and removed in 5.4. To solve bug in using $_SESSION
216 233
 	{
217 234
 		foreach ($_SESSION as $key=>$value)
218 235
 		{
219 236
 			if (isset($GLOBALS[$key])) unset($GLOBALS[$key]);
237
+	}
220 238
 		}
221 239
 	}
222 240
 }
@@ -239,9 +257,13 @@  discard block
 block discarded – undo
239 257
 	$conf->browser->tablet=$tmp['tablet'];	   // TODO deprecated, use ->layout
240 258
 	//var_dump($conf->browser);
241 259
 
242
-	if ($conf->browser->layout == 'phone') $conf->dol_no_mouse_hover=1;
243
-	if ($conf->browser->layout == 'phone') $conf->global->MAIN_TESTMENUHIDER=1;
244
-}
260
+	if ($conf->browser->layout == 'phone') {
261
+		$conf->dol_no_mouse_hover=1;
262
+	}
263
+	if ($conf->browser->layout == 'phone') {
264
+		$conf->global->MAIN_TESTMENUHIDER=1;
265
+	}
266
+	}
245 267
 
246 268
 // Force HTTPS if required ($conf->file->main_force_https is 0/1 or https dolibarr root url)
247 269
 // $_SERVER["HTTPS"] is 'on' when link is https, otherwise $_SERVER["HTTPS"] is empty or 'off'
@@ -250,19 +272,19 @@  discard block
 block discarded – undo
250 272
 	$newurl='';
251 273
 	if (is_numeric($conf->file->main_force_https))
252 274
 	{
253
-		if ($conf->file->main_force_https == '1' && ! empty($_SERVER["SCRIPT_URI"]))	// If SCRIPT_URI supported by server
275
+		if ($conf->file->main_force_https == '1' && ! empty($_SERVER["SCRIPT_URI"])) {
276
+			// If SCRIPT_URI supported by server
254 277
 		{
255 278
 			if (preg_match('/^http:/i',$_SERVER["SCRIPT_URI"]) && ! preg_match('/^https:/i',$_SERVER["SCRIPT_URI"]))	// If link is http
256 279
 			{
257 280
 				$newurl=preg_replace('/^http:/i','https:',$_SERVER["SCRIPT_URI"]);
258
-			}
259 281
 		}
260
-		else	// Check HTTPS environment variable (Apache/mod_ssl only)
282
+			}
283
+		} else	// Check HTTPS environment variable (Apache/mod_ssl only)
261 284
 		{
262 285
 			$newurl=preg_replace('/^http:/i','https:',DOL_MAIN_URL_ROOT).$_SERVER["REQUEST_URI"];
263 286
 		}
264
-	}
265
-	else
287
+	} else
266 288
 	{
267 289
 		// Check HTTPS environment variable (Apache/mod_ssl only)
268 290
 		$newurl=$conf->file->main_force_https.$_SERVER["REQUEST_URI"];
@@ -273,8 +295,7 @@  discard block
 block discarded – undo
273 295
 		dol_syslog("main.inc: dolibarr_main_force_https is on, we make a redirect to ".$newurl);
274 296
 		header("Location: ".$newurl);
275 297
 		exit;
276
-	}
277
-	else
298
+	} else
278 299
 	{
279 300
 		dol_syslog("main.inc: dolibarr_main_force_https is on but we failed to forge new https url so no redirect is done", LOG_WARNING);
280 301
 	}
@@ -282,8 +303,14 @@  discard block
 block discarded – undo
282 303
 
283 304
 
284 305
 // Loading of additional presentation includes
285
-if (! defined('NOREQUIREHTML')) require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php';	    // Need 660ko memory (800ko in 2.2)
286
-if (! defined('NOREQUIREAJAX') && $conf->use_javascript_ajax) require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';	// Need 22ko memory
306
+if (! defined('NOREQUIREHTML')) {
307
+	require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php';
308
+}
309
+// Need 660ko memory (800ko in 2.2)
310
+if (! defined('NOREQUIREAJAX') && $conf->use_javascript_ajax) {
311
+	require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
312
+}
313
+// Need 22ko memory
287 314
 
288 315
 // If install or upgrade process not done or not completely finished, we call the install page.
289 316
 if (! empty($conf->global->MAIN_NOT_INSTALLED) || ! empty($conf->global->MAIN_NOT_UPGRADED))
@@ -301,9 +328,11 @@  discard block
 block discarded – undo
301 328
 	$dolibarrversionlastupgrade=preg_split('/[.-]/',$versiontocompare);
302 329
 	$dolibarrversionprogram=preg_split('/[.-]/',DOL_VERSION);
303 330
 	$rescomp=versioncompare($dolibarrversionprogram,$dolibarrversionlastupgrade);
304
-	if ($rescomp > 0)   // Programs have a version higher than database. We did not add "&& $rescomp < 3" because we want upgrade process for build upgrades
331
+	if ($rescomp > 0) {
332
+		// Programs have a version higher than database. We did not add "&& $rescomp < 3" because we want upgrade process for build upgrades
305 333
 	{
306 334
 		dol_syslog("main.inc: database version ".$versiontocompare." is lower than programs version ".DOL_VERSION.". Redirect to install page.", LOG_WARNING);
335
+	}
307 336
 		header("Location: ".DOL_URL_ROOT."/install/index.php");
308 337
 		exit;
309 338
 	}
@@ -313,25 +342,31 @@  discard block
 block discarded – undo
313 342
 if (! defined('NOTOKENRENEWAL'))
314 343
 {
315 344
 	// roulement des jetons car cree a chaque appel
316
-	if (isset($_SESSION['newtoken'])) $_SESSION['token'] = $_SESSION['newtoken'];
345
+	if (isset($_SESSION['newtoken'])) {
346
+		$_SESSION['token'] = $_SESSION['newtoken'];
347
+	}
317 348
 
318 349
 	// Save in $_SESSION['newtoken'] what will be next token. Into forms, we will add param token = $_SESSION['newtoken']
319 350
 	$token = dol_hash(uniqid(mt_rand(),TRUE)); // Generates a hash of a random number
320 351
 	$_SESSION['newtoken'] = $token;
321 352
 }
322
-if (! defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && ! empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN))	// Check validity of token, only if option enabled (this option breaks some features sometimes)
353
+if (! defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && ! empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) {
354
+	// Check validity of token, only if option enabled (this option breaks some features sometimes)
323 355
 {
324 356
 	if ($_SERVER['REQUEST_METHOD'] == 'POST' && ! GETPOST('token','alpha')) // Note, offender can still send request by GET
325 357
 	{
326 358
 		print "Access refused by CSRF protection in main.inc.php. Token not provided.\n";
359
+}
327 360
 		print "If you access your server behind a proxy using url rewriting, you might check that all HTTP header is propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file).\n";
328 361
 		die;
329 362
 	}
330
-	if ($_SERVER['REQUEST_METHOD'] === 'POST')  // This test must be after loading $_SESSION['token'].
363
+	if ($_SERVER['REQUEST_METHOD'] === 'POST') {
364
+		// This test must be after loading $_SESSION['token'].
331 365
 	{
332 366
 		if (GETPOST('token', 'alpha') != $_SESSION['token'])
333 367
 		{
334 368
 			dol_syslog("Invalid token in ".$_SERVER['HTTP_REFERER'].", action=".GETPOST('action','aZ09').", _POST['token']=".GETPOST('token','alpha').", _SESSION['token']=".$_SESSION['token'], LOG_WARNING);
369
+	}
335 370
 			//print 'Unset POST by CSRF protection in main.inc.php.';	// Do not output anything because this create problems when using the BACK button on browsers.
336 371
 			unset($_POST);
337 372
 		}
@@ -339,7 +374,9 @@  discard block
 block discarded – undo
339 374
 }
340 375
 
341 376
 // Disable modules (this must be after session_start and after conf has been loaded)
342
-if (GETPOST('disablemodules','alpha'))  $_SESSION["disablemodules"]=GETPOST('disablemodules','alpha');
377
+if (GETPOST('disablemodules','alpha')) {
378
+	$_SESSION["disablemodules"]=GETPOST('disablemodules','alpha');
379
+}
343 380
 if (! empty($_SESSION["disablemodules"]))
344 381
 {
345 382
 	$disabled_modules=explode(',',$_SESSION["disablemodules"]);
@@ -347,11 +384,15 @@  discard block
 block discarded – undo
347 384
 	{
348 385
 		if ($module)
349 386
 		{
350
-			if (empty($conf->$module)) $conf->$module=new stdClass();
387
+			if (empty($conf->$module)) {
388
+				$conf->$module=new stdClass();
389
+			}
351 390
 			$conf->$module->enabled=false;
352
-			if ($module == 'fournisseur')		// Special case
391
+			if ($module == 'fournisseur') {
392
+				// Special case
353 393
 			{
354 394
 				$conf->supplier_order->enabled=0;
395
+			}
355 396
 				$conf->supplier_invoice->enabled=0;
356 397
 			}
357 398
 		}
@@ -369,9 +410,13 @@  discard block
 block discarded – undo
369 410
 	// Example: 'http', 'dolibarr', 'ldap', 'http,forceuser'
370 411
 
371 412
 	// Authentication mode
372
-	if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='http,dolibarr';
413
+	if (empty($dolibarr_main_authentication)) {
414
+		$dolibarr_main_authentication='http,dolibarr';
415
+	}
373 416
 	// Authentication mode: forceuser
374
-	if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user='auto';
417
+	if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) {
418
+		$dolibarr_auto_user='auto';
419
+	}
375 420
 	// Set authmode
376 421
 	$authmode=explode(',',$dolibarr_main_authentication);
377 422
 
@@ -406,11 +451,13 @@  discard block
 block discarded – undo
406 451
 		//dol_syslog("POST key=".join(array_keys($_POST),',').' value='.join($_POST,','));
407 452
 
408 453
 		// If in demo mode, we check we go to home page through the public/demo/index.php page
409
-		if (! empty($dolibarr_main_demo) && $_SERVER['PHP_SELF'] == DOL_URL_ROOT.'/index.php')  // We ask index page
454
+		if (! empty($dolibarr_main_demo) && $_SERVER['PHP_SELF'] == DOL_URL_ROOT.'/index.php') {
455
+			// We ask index page
410 456
 		{
411 457
 			if (empty($_SERVER['HTTP_REFERER']) || ! preg_match('/public/',$_SERVER['HTTP_REFERER']))
412 458
 			{
413 459
 				dol_syslog("Call index page from another url than demo page (call is done from page ".$_SERVER['HTTP_REFERER'].")");
460
+		}
414 461
 				$url='';
415 462
 				$url.=($url?'&':'').($dol_hide_topmenu?'dol_hide_topmenu='.$dol_hide_topmenu:'');
416 463
 				$url.=($url?'&':'').($dol_hide_leftmenu?'dol_hide_leftmenu='.$dol_hide_leftmenu:'');
@@ -455,7 +502,9 @@  discard block
 block discarded – undo
455 502
 				$hookmanager->initHooks(array('login'));
456 503
 				$parameters=array('dol_authmode'=>$dol_authmode, 'dol_loginmesg'=>$_SESSION["dol_loginmesg"]);
457 504
 				$reshook=$hookmanager->executeHooks('afterLoginFailed',$parameters,$user,$action);    // Note that $action and $object may have been modified by some hooks
458
-				if ($reshook < 0) $error++;
505
+				if ($reshook < 0) {
506
+					$error++;
507
+				}
459 508
 
460 509
 				// Note: exit is done later
461 510
 			}
@@ -467,13 +516,21 @@  discard block
 block discarded – undo
467 516
 
468 517
 		// Define if we received data to test the login.
469 518
 		$goontestloop=false;
470
-		if (isset($_SERVER["REMOTE_USER"]) && in_array('http',$authmode)) $goontestloop=true;
471
-		if ($dolibarr_main_authentication == 'forceuser' && ! empty($dolibarr_auto_user)) $goontestloop=true;
472
-		if (GETPOST("username","alpha",2) || ! empty($_COOKIE['login_dolibarr']) || GETPOST('openid_mode','alpha',1)) $goontestloop=true;
519
+		if (isset($_SERVER["REMOTE_USER"]) && in_array('http',$authmode)) {
520
+			$goontestloop=true;
521
+		}
522
+		if ($dolibarr_main_authentication == 'forceuser' && ! empty($dolibarr_auto_user)) {
523
+			$goontestloop=true;
524
+		}
525
+		if (GETPOST("username","alpha",2) || ! empty($_COOKIE['login_dolibarr']) || GETPOST('openid_mode','alpha',1)) {
526
+			$goontestloop=true;
527
+		}
473 528
 
474
-		if (! is_object($langs)) // This can occurs when calling page with NOREQUIRETRAN defined, however we need langs for error messages.
529
+		if (! is_object($langs)) {
530
+			// This can occurs when calling page with NOREQUIRETRAN defined, however we need langs for error messages.
475 531
 		{
476 532
 			include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
533
+		}
477 534
 			$langs=new Translate("",$conf);
478 535
 			$langcode=(GETPOST('lang','aZ09',1)?GETPOST('lang','aZ09',1):(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT));
479 536
 			$langs->setDefaultLang($langcode);
@@ -500,7 +557,9 @@  discard block
 block discarded – undo
500 557
 					$datenow=dol_now();
501 558
 					$datefirst=dol_stringtotime($_POST["dst_first"]);
502 559
 					$datesecond=dol_stringtotime($_POST["dst_second"]);
503
-					if ($datenow >= $datefirst && $datenow < $datesecond) $dol_dst=1;
560
+					if ($datenow >= $datefirst && $datenow < $datesecond) {
561
+						$dol_dst=1;
562
+					}
504 563
 				}
505 564
 				//print $datefirst.'-'.$datesecond.'-'.$datenow.'-'.$dol_tz.'-'.$dol_tzstring.'-'.$dol_dst; exit;
506 565
 			}
@@ -513,7 +572,9 @@  discard block
 block discarded – undo
513 572
 
514 573
 				// Bad password. No authmode has found a good password.
515 574
 				// We set a generic message if not defined inside function checkLoginPassEntity or subfunctions
516
-				if (empty($_SESSION["dol_loginmesg"])) $_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword");
575
+				if (empty($_SESSION["dol_loginmesg"])) {
576
+					$_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword");
577
+				}
517 578
 
518 579
 				// TODO @deprecated Remove this. Hook must be used, not this trigger.
519 580
 				$user->trigger_mesg=$langs->trans("ErrorBadLoginPassword").' - login='.GETPOST("username","alpha",2);
@@ -531,19 +592,26 @@  discard block
 block discarded – undo
531 592
 				$hookmanager->initHooks(array('login'));
532 593
 				$parameters=array('dol_authmode'=>$dol_authmode, 'dol_loginmesg'=>$_SESSION["dol_loginmesg"]);
533 594
 				$reshook=$hookmanager->executeHooks('afterLoginFailed',$parameters,$user,$action);    // Note that $action and $object may have been modified by some hooks
534
-				if ($reshook < 0) $error++;
595
+				if ($reshook < 0) {
596
+					$error++;
597
+				}
535 598
 
536 599
 				// Note: exit is done in next chapter
537 600
 			}
538 601
 		}
539 602
 
540 603
 		// End test login / passwords
541
-		if (! $login || (in_array('ldap',$authmode) && empty($passwordtotest)))	// With LDAP we refused empty password because some LDAP are "opened" for anonymous access so connexion is a success.
604
+		if (! $login || (in_array('ldap',$authmode) && empty($passwordtotest))) {
605
+			// With LDAP we refused empty password because some LDAP are "opened" for anonymous access so connexion is a success.
542 606
 		{
543 607
 			// No data to test login, so we show the login page
544 608
 			dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." showing the login form and exit");
545
-			if (defined('NOREDIRECTBYMAINTOLOGIN')) return 'ERROR_NOT_LOGGED';
546
-			else dol_loginfunction($langs,$conf,(! empty($mysoc)?$mysoc:''));
609
+		}
610
+			if (defined('NOREDIRECTBYMAINTOLOGIN')) {
611
+				return 'ERROR_NOT_LOGGED';
612
+			} else {
613
+				dol_loginfunction($langs,$conf,(! empty($mysoc)?$mysoc:''));
614
+			}
547 615
 			exit;
548 616
 		}
549 617
 
@@ -588,17 +656,24 @@  discard block
 block discarded – undo
588 656
 			$hookmanager->initHooks(array('login'));
589 657
 			$parameters=array('dol_authmode'=>$dol_authmode, 'dol_loginmesg'=>$_SESSION["dol_loginmesg"]);
590 658
 			$reshook=$hookmanager->executeHooks('afterLoginFailed',$parameters,$user,$action);    // Note that $action and $object may have been modified by some hooks
591
-			if ($reshook < 0) $error++;
659
+			if ($reshook < 0) {
660
+				$error++;
661
+			}
592 662
 
593 663
 			$paramsurl=array();
594
-			if (GETPOST('textbrowser','int')) $paramsurl[]='textbrowser='.GETPOST('textbrowser','int');
595
-			if (GETPOST('nojs','int'))        $paramsurl[]='nojs='.GETPOST('nojs','int');
596
-			if (GETPOST('lang','aZ09'))       $paramsurl[]='lang='.GETPOST('lang','aZ09');
664
+			if (GETPOST('textbrowser','int')) {
665
+				$paramsurl[]='textbrowser='.GETPOST('textbrowser','int');
666
+			}
667
+			if (GETPOST('nojs','int')) {
668
+				$paramsurl[]='nojs='.GETPOST('nojs','int');
669
+			}
670
+			if (GETPOST('lang','aZ09')) {
671
+				$paramsurl[]='lang='.GETPOST('lang','aZ09');
672
+			}
597 673
 			header('Location: '.DOL_URL_ROOT.'/index.php'.(count($paramsurl)?'?'.implode('&',$paramsurl):''));
598 674
 			exit;
599 675
 		}
600
-	}
601
-	else
676
+	} else
602 677
 	{
603 678
 		// We are already into an authenticated session
604 679
 		$login=$_SESSION["dol_login"];
@@ -648,27 +723,38 @@  discard block
 block discarded – undo
648 723
 			$hookmanager->initHooks(array('login'));
649 724
 			$parameters=array('dol_authmode'=>$dol_authmode, 'dol_loginmesg'=>$_SESSION["dol_loginmesg"]);
650 725
 			$reshook=$hookmanager->executeHooks('afterLoginFailed',$parameters,$user,$action);    // Note that $action and $object may have been modified by some hooks
651
-			if ($reshook < 0) $error++;
726
+			if ($reshook < 0) {
727
+				$error++;
728
+			}
652 729
 
653 730
 			$paramsurl=array();
654
-			if (GETPOST('textbrowser','int')) $paramsurl[]='textbrowser='.GETPOST('textbrowser','int');
655
-			if (GETPOST('nojs','int'))        $paramsurl[]='nojs='.GETPOST('nojs','int');
656
-			if (GETPOST('lang','aZ09'))       $paramsurl[]='lang='.GETPOST('lang','aZ09');
731
+			if (GETPOST('textbrowser','int')) {
732
+				$paramsurl[]='textbrowser='.GETPOST('textbrowser','int');
733
+			}
734
+			if (GETPOST('nojs','int')) {
735
+				$paramsurl[]='nojs='.GETPOST('nojs','int');
736
+			}
737
+			if (GETPOST('lang','aZ09')) {
738
+				$paramsurl[]='lang='.GETPOST('lang','aZ09');
739
+			}
657 740
 			header('Location: '.DOL_URL_ROOT.'/index.php'.(count($paramsurl)?'?'.implode('&',$paramsurl):''));
658 741
 			exit;
659
-		}
660
-		else
742
+		} else
661 743
 		{
662 744
 		   // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
663 745
 		   $hookmanager->initHooks(array('main'));
664 746
 
665 747
 		   // Code for search criteria persistence.
666
-		   if (! empty($_GET['save_lastsearch_values']))    // Keep $_GET here
748
+		   if (! empty($_GET['save_lastsearch_values'])) {
749
+		   	// Keep $_GET here
667 750
 		   {
668 751
 			   $relativepathstring = preg_replace('/\?.*$/','',$_SERVER["HTTP_REFERER"]);
752
+		   }
669 753
 			   $relativepathstring = preg_replace('/^https?:\/\/[^\/]*/','',$relativepathstring);     // Get full path except host server
670 754
 			   // Clean $relativepathstring
671
-   			   if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring);
755
+   			   if (constant('DOL_URL_ROOT')) {
756
+   			   	$relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring);
757
+   			   }
672 758
 			   $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
673 759
 			   $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
674 760
 			   //var_dump($relativepathstring);
@@ -709,11 +795,21 @@  discard block
 block discarded – undo
709 795
 		$_SESSION["dol_company"]=$conf->global->MAIN_INFO_SOCIETE_NOM;
710 796
 		$_SESSION["dol_entity"]=$conf->entity;
711 797
 		// Store value into session (values stored only if defined)
712
-		if (! empty($dol_hide_topmenu))         $_SESSION['dol_hide_topmenu']=$dol_hide_topmenu;
713
-		if (! empty($dol_hide_leftmenu))        $_SESSION['dol_hide_leftmenu']=$dol_hide_leftmenu;
714
-		if (! empty($dol_optimize_smallscreen)) $_SESSION['dol_optimize_smallscreen']=$dol_optimize_smallscreen;
715
-		if (! empty($dol_no_mouse_hover))       $_SESSION['dol_no_mouse_hover']=$dol_no_mouse_hover;
716
-		if (! empty($dol_use_jmobile))          $_SESSION['dol_use_jmobile']=$dol_use_jmobile;
798
+		if (! empty($dol_hide_topmenu)) {
799
+			$_SESSION['dol_hide_topmenu']=$dol_hide_topmenu;
800
+		}
801
+		if (! empty($dol_hide_leftmenu)) {
802
+			$_SESSION['dol_hide_leftmenu']=$dol_hide_leftmenu;
803
+		}
804
+		if (! empty($dol_optimize_smallscreen)) {
805
+			$_SESSION['dol_optimize_smallscreen']=$dol_optimize_smallscreen;
806
+		}
807
+		if (! empty($dol_no_mouse_hover)) {
808
+			$_SESSION['dol_no_mouse_hover']=$dol_no_mouse_hover;
809
+		}
810
+		if (! empty($dol_use_jmobile)) {
811
+			$_SESSION['dol_use_jmobile']=$dol_use_jmobile;
812
+		}
717 813
 
718 814
 		dol_syslog("This is a new started user session. _SESSION['dol_login']=".$_SESSION["dol_login"]." Session id=".session_id());
719 815
 
@@ -739,7 +835,9 @@  discard block
 block discarded – undo
739 835
 		$hookmanager->initHooks(array('login'));
740 836
 		$parameters=array('dol_authmode'=>$dol_authmode, 'dol_loginfo'=>$loginfo);
741 837
 		$reshook=$hookmanager->executeHooks('afterLogin',$parameters,$user,$action);    // Note that $action and $object may have been modified by some hooks
742
-		if ($reshook < 0) $error++;
838
+		if ($reshook < 0) {
839
+			$error++;
840
+		}
743 841
 
744 842
 		if ($error)
745 843
 		{
@@ -747,20 +845,23 @@  discard block
 block discarded – undo
747 845
 			session_destroy();
748 846
 			dol_print_error($db,'Error in some hooks afterLogin (or old trigger USER_LOGIN)');
749 847
 			exit;
750
-		}
751
-		else
848
+		} else
752 849
 		{
753 850
 			$db->commit();
754 851
 		}
755 852
 
756 853
 		// Change landing page if defined.
757 854
 		$landingpage=(empty($user->conf->MAIN_LANDING_PAGE)?(empty($conf->global->MAIN_LANDING_PAGE)?'':$conf->global->MAIN_LANDING_PAGE):$user->conf->MAIN_LANDING_PAGE);
758
-		if (! empty($landingpage))    // Example: /index.php
855
+		if (! empty($landingpage)) {
856
+			// Example: /index.php
759 857
 		{
760 858
 			$newpath=dol_buildpath($landingpage, 1);
761
-			if ($_SERVER["PHP_SELF"] != $newpath)   // not already on landing page (avoid infinite loop)
859
+		}
860
+			if ($_SERVER["PHP_SELF"] != $newpath) {
861
+				// not already on landing page (avoid infinite loop)
762 862
 			{
763 863
 				header('Location: '.$newpath);
864
+			}
764 865
 				exit;
765 866
 			}
766 867
 		}
@@ -783,8 +884,14 @@  discard block
 block discarded – undo
783 884
      */
784 885
 
785 886
 	// Set liste_limit
786
-	if (isset($user->conf->MAIN_SIZE_LISTE_LIMIT))	$conf->liste_limit = $user->conf->MAIN_SIZE_LISTE_LIMIT;	// Can be 0
787
-	if (isset($user->conf->PRODUIT_LIMIT_SIZE))	$conf->product->limit_size = $user->conf->PRODUIT_LIMIT_SIZE;	// Can be 0
887
+	if (isset($user->conf->MAIN_SIZE_LISTE_LIMIT)) {
888
+		$conf->liste_limit = $user->conf->MAIN_SIZE_LISTE_LIMIT;
889
+	}
890
+	// Can be 0
891
+	if (isset($user->conf->PRODUIT_LIMIT_SIZE)) {
892
+		$conf->product->limit_size = $user->conf->PRODUIT_LIMIT_SIZE;
893
+	}
894
+	// Can be 0
788 895
 
789 896
 	// Replace conf->css by personalized value if theme not forced
790 897
 	if (empty($conf->global->MAIN_FORCETHEME) && ! empty($user->conf->MAIN_THEME))
@@ -803,31 +910,47 @@  discard block
 block discarded – undo
803 910
 
804 911
 
805 912
 // Set javascript option
806
-if (! GETPOST('nojs','int'))   // If javascript was not disabled on URL
913
+if (! GETPOST('nojs','int')) {
914
+	// If javascript was not disabled on URL
807 915
 {
808 916
 	if (! empty($user->conf->MAIN_DISABLE_JAVASCRIPT))
809 917
 	{
810 918
 		$conf->use_javascript_ajax=! $user->conf->MAIN_DISABLE_JAVASCRIPT;
919
+}
811 920
 	}
921
+} else {
922
+	$conf->use_javascript_ajax=0;
812 923
 }
813
-else $conf->use_javascript_ajax=0;
814 924
 // Set MAIN_OPTIMIZEFORTEXTBROWSER
815
-if (GETPOST('textbrowser','int') || (! empty($conf->browser->name) && $conf->browser->name == 'lynxlinks') || ! empty($user->conf->MAIN_OPTIMIZEFORTEXTBROWSER))   // If we must enable text browser
925
+if (GETPOST('textbrowser','int') || (! empty($conf->browser->name) && $conf->browser->name == 'lynxlinks') || ! empty($user->conf->MAIN_OPTIMIZEFORTEXTBROWSER)) {
926
+	// If we must enable text browser
816 927
 {
817 928
 	$conf->global->MAIN_OPTIMIZEFORTEXTBROWSER=1;
818 929
 }
819
-elseif (! empty($user->conf->MAIN_OPTIMIZEFORTEXTBROWSER))
930
+} elseif (! empty($user->conf->MAIN_OPTIMIZEFORTEXTBROWSER))
820 931
 {
821 932
 	$conf->global->MAIN_OPTIMIZEFORTEXTBROWSER=$user->conf->MAIN_OPTIMIZEFORTEXTBROWSER;
822 933
 }
823 934
 
824 935
 // Set terminal output option according to conf->browser.
825
-if (GETPOST('dol_hide_leftmenu','int') || ! empty($_SESSION['dol_hide_leftmenu']))               $conf->dol_hide_leftmenu=1;
826
-if (GETPOST('dol_hide_topmenu','int') || ! empty($_SESSION['dol_hide_topmenu']))                 $conf->dol_hide_topmenu=1;
827
-if (GETPOST('dol_optimize_smallscreen','int') || ! empty($_SESSION['dol_optimize_smallscreen'])) $conf->dol_optimize_smallscreen=1;
828
-if (GETPOST('dol_no_mouse_hover','int') || ! empty($_SESSION['dol_no_mouse_hover']))             $conf->dol_no_mouse_hover=1;
829
-if (GETPOST('dol_use_jmobile','int') || ! empty($_SESSION['dol_use_jmobile']))                   $conf->dol_use_jmobile=1;
830
-if (! empty($conf->browser->layout) && $conf->browser->layout != 'classic') $conf->dol_no_mouse_hover=1;
936
+if (GETPOST('dol_hide_leftmenu','int') || ! empty($_SESSION['dol_hide_leftmenu'])) {
937
+	$conf->dol_hide_leftmenu=1;
938
+}
939
+if (GETPOST('dol_hide_topmenu','int') || ! empty($_SESSION['dol_hide_topmenu'])) {
940
+	$conf->dol_hide_topmenu=1;
941
+}
942
+if (GETPOST('dol_optimize_smallscreen','int') || ! empty($_SESSION['dol_optimize_smallscreen'])) {
943
+	$conf->dol_optimize_smallscreen=1;
944
+}
945
+if (GETPOST('dol_no_mouse_hover','int') || ! empty($_SESSION['dol_no_mouse_hover'])) {
946
+	$conf->dol_no_mouse_hover=1;
947
+}
948
+if (GETPOST('dol_use_jmobile','int') || ! empty($_SESSION['dol_use_jmobile'])) {
949
+	$conf->dol_use_jmobile=1;
950
+}
951
+if (! empty($conf->browser->layout) && $conf->browser->layout != 'classic') {
952
+	$conf->dol_no_mouse_hover=1;
953
+}
831 954
 if ((! empty($conf->browser->layout) && $conf->browser->layout == 'phone')
832 955
 	|| (! empty($_SESSION['dol_screenwidth']) && $_SESSION['dol_screenwidth'] < 400)
833 956
 	|| (! empty($_SESSION['dol_screenheight']) && $_SESSION['dol_screenheight'] < 400)
@@ -836,7 +959,9 @@  discard block
 block discarded – undo
836 959
 	$conf->dol_optimize_smallscreen=1;
837 960
 }
838 961
 // If we force to use jmobile, then we reenable javascript
839
-if (! empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax=1;
962
+if (! empty($conf->dol_use_jmobile)) {
963
+	$conf->use_javascript_ajax=1;
964
+}
840 965
 // Replace themes bugged with jmobile with eldy
841 966
 if (! empty($conf->dol_use_jmobile) && in_array($conf->theme,array('bureau2crea','cameleo','amarok')))
842 967
 {
@@ -847,7 +972,8 @@  discard block
 block discarded – undo
847 972
 
848 973
 if (! defined('NOREQUIRETRAN'))
849 974
 {
850
-	if (! GETPOST('lang','aZ09'))	// If language was not forced on URL
975
+	if (! GETPOST('lang','aZ09')) {
976
+		// If language was not forced on URL
851 977
 	{
852 978
 		// If user has chosen its own language
853 979
 		if (! empty($user->conf->MAIN_LANG_DEFAULT))
@@ -857,6 +983,7 @@  discard block
 block discarded – undo
857 983
 			if ($langs->getDefaultLang() != $user->conf->MAIN_LANG_DEFAULT)
858 984
 			{
859 985
 				$langs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT);
986
+	}
860 987
 			}
861 988
 		}
862 989
 	}
@@ -866,7 +993,9 @@  discard block
 block discarded – undo
866 993
 {
867 994
 	// If the login is not recovered, it is identified with an account that does not exist.
868 995
 	// Hacking attempt?
869
-	if (! $user->login) accessforbidden();
996
+	if (! $user->login) {
997
+		accessforbidden();
998
+	}
870 999
 
871 1000
 	// Check if user is active
872 1001
 	if ($user->statut < 1)
@@ -917,8 +1046,7 @@  discard block
 block discarded – undo
917 1046
 	define('ROWS_7',7);
918 1047
 	define('ROWS_8',8);
919 1048
 	define('ROWS_9',9);
920
-}
921
-else
1049
+} else
922 1050
 {
923 1051
 	define('ROWS_1',0);
924 1052
 	define('ROWS_2',1);
@@ -936,18 +1064,22 @@  discard block
 block discarded – undo
936 1064
 // Init menu manager
937 1065
 if (! defined('NOREQUIREMENU'))
938 1066
 {
939
-	if (empty($user->societe_id))    // If internal user or not defined
1067
+	if (empty($user->societe_id)) {
1068
+		// If internal user or not defined
940 1069
 	{
941 1070
 		$conf->standard_menu=(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?(empty($conf->global->MAIN_MENU_STANDARD)?'eldy_menu.php':$conf->global->MAIN_MENU_STANDARD):$conf->global->MAIN_MENU_STANDARD_FORCED);
942 1071
 	}
943
-	else                        // If external user
1072
+	} else                        // If external user
944 1073
 	{
945 1074
 		$conf->standard_menu=(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?(empty($conf->global->MAIN_MENUFRONT_STANDARD)?'eldy_menu.php':$conf->global->MAIN_MENUFRONT_STANDARD):$conf->global->MAIN_MENUFRONT_STANDARD_FORCED);
946 1075
 	}
947 1076
 
948 1077
 	// Load the menu manager (only if not already done)
949 1078
 	$file_menu=$conf->standard_menu;
950
-	if (GETPOST('menu','alpha')) $file_menu=GETPOST('menu','alpha');     // example: menu=eldy_menu.php
1079
+	if (GETPOST('menu','alpha')) {
1080
+		$file_menu=GETPOST('menu','alpha');
1081
+	}
1082
+	// example: menu=eldy_menu.php
951 1083
 	if (! class_exists('MenuManager'))
952 1084
 	{
953 1085
 		$menufound=0;
@@ -955,11 +1087,15 @@  discard block
 block discarded – undo
955 1087
 		foreach($dirmenus as $dirmenu)
956 1088
 		{
957 1089
 			$menufound=dol_include_once($dirmenu."standard/".$file_menu);
958
-			if (class_exists('MenuManager')) break;
1090
+			if (class_exists('MenuManager')) {
1091
+				break;
1092
+			}
959 1093
 		}
960
-		if (! class_exists('MenuManager'))	// If failed to include, we try with standard eldy_menu.php
1094
+		if (! class_exists('MenuManager')) {
1095
+			// If failed to include, we try with standard eldy_menu.php
961 1096
 		{
962 1097
 			dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING);
1098
+		}
963 1099
 			$file_menu='eldy_menu.php';
964 1100
 			include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu;
965 1101
 		}
@@ -1033,8 +1169,11 @@  discard block
 block discarded – undo
1033 1169
 {
1034 1170
 	global $conf;
1035 1171
 
1036
-	if ($contenttype == 'text/html' ) header("Content-Type: text/html; charset=".$conf->file->character_set_client);
1037
-	else header("Content-Type: ".$contenttype);
1172
+	if ($contenttype == 'text/html' ) {
1173
+		header("Content-Type: text/html; charset=".$conf->file->character_set_client);
1174
+	} else {
1175
+		header("Content-Type: ".$contenttype);
1176
+	}
1038 1177
 	// Security options
1039 1178
 	header("X-Content-Type-Options: nosniff");  // With the nosniff option, if the server says the content is text/html, the browser will render it as text/html (note that most browsers now force this option to on)
1040 1179
 	header("X-Frame-Options: SAMEORIGIN");      // Frames allowed only if on same domain (stop some XSS attacks)
@@ -1074,52 +1213,78 @@  discard block
 block discarded – undo
1074 1213
 
1075 1214
 	top_httphead();
1076 1215
 
1077
-	if (empty($conf->css)) $conf->css = '/theme/eldy/style.css.php';	// If not defined, eldy by default
1216
+	if (empty($conf->css)) {
1217
+		$conf->css = '/theme/eldy/style.css.php';
1218
+	}
1219
+	// If not defined, eldy by default
1078 1220
 
1079 1221
 	if (! empty($conf->global->MAIN_ACTIVATE_HTML4)) {
1080 1222
 		$doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
1081
-	}else {
1223
+	} else {
1082 1224
 		$doctype = '<!doctype html>';
1083 1225
 	}
1084 1226
 	print $doctype."\n";
1085
-	if (! empty($conf->global->MAIN_USE_CACHE_MANIFEST)) print '<html lang="'.substr($langs->defaultlang,0,2).'" manifest="'.DOL_URL_ROOT.'/cache.manifest">'."\n";
1086
-	else print '<html lang="'.substr($langs->defaultlang,0,2).'">'."\n";
1227
+	if (! empty($conf->global->MAIN_USE_CACHE_MANIFEST)) {
1228
+		print '<html lang="'.substr($langs->defaultlang,0,2).'" manifest="'.DOL_URL_ROOT.'/cache.manifest">'."\n";
1229
+	} else {
1230
+		print '<html lang="'.substr($langs->defaultlang,0,2).'">'."\n";
1231
+	}
1087 1232
 	//print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">'."\n";
1088 1233
 	if (empty($disablehead))
1089 1234
 	{
1090 1235
 		print "<head>\n";
1091
-		if (GETPOST('dol_basehref','alpha')) print '<base href="'.dol_escape_htmltag(GETPOST('dol_basehref','alpha')).'">'."\n";
1236
+		if (GETPOST('dol_basehref','alpha')) {
1237
+			print '<base href="'.dol_escape_htmltag(GETPOST('dol_basehref','alpha')).'">'."\n";
1238
+		}
1092 1239
 		// Displays meta
1093 1240
 		print '<meta name="robots" content="noindex'.($disablenofollow?'':',nofollow').'">'."\n";	// Do not index
1094 1241
 		print '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n";		// Scale for mobile device
1095 1242
 		print '<meta name="author" content="Dolibarr Development Team">'."\n";
1096 1243
 		// Favicon
1097 1244
 		$favicon=dol_buildpath('/theme/'.$conf->theme.'/img/favicon.ico',1);
1098
-		if (! empty($conf->global->MAIN_FAVICON_URL)) $favicon=$conf->global->MAIN_FAVICON_URL;
1099
-		if (empty($conf->dol_use_jmobile)) print '<link rel="shortcut icon" type="image/x-icon" href="'.$favicon.'"/>'."\n";	// Not required into an Android webview
1245
+		if (! empty($conf->global->MAIN_FAVICON_URL)) {
1246
+			$favicon=$conf->global->MAIN_FAVICON_URL;
1247
+		}
1248
+		if (empty($conf->dol_use_jmobile)) {
1249
+			print '<link rel="shortcut icon" type="image/x-icon" href="'.$favicon.'"/>'."\n";
1250
+		}
1251
+		// Not required into an Android webview
1100 1252
 		//if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<link rel="top" title="'.$langs->trans("Home").'" href="'.(DOL_URL_ROOT?DOL_URL_ROOT:'/').'">'."\n";
1101 1253
 		//if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<link rel="copyright" title="GNU General Public License" href="http://www.gnu.org/copyleft/gpl.html#SEC1">'."\n";
1102 1254
 		//if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<link rel="author" title="Dolibarr Development Team" href="https://www.dolibarr.org">'."\n";
1103 1255
 
1104 1256
 		// Displays title
1105 1257
 		$appli=constant('DOL_APPLICATION_TITLE');
1106
-		if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE;
1258
+		if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
1259
+			$appli=$conf->global->MAIN_APPLICATION_TITLE;
1260
+		}
1107 1261
 
1108
-		if ($title && ! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/noapp/',$conf->global->MAIN_HTML_TITLE)) print '<title>'.dol_htmlentities($title).'</title>';
1109
-		else if ($title) print '<title>'.dol_htmlentities($appli.' - '.$title).'</title>';
1110
-		else print "<title>".dol_htmlentities($appli)."</title>";
1262
+		if ($title && ! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/noapp/',$conf->global->MAIN_HTML_TITLE)) {
1263
+			print '<title>'.dol_htmlentities($title).'</title>';
1264
+		} else if ($title) {
1265
+			print '<title>'.dol_htmlentities($appli.' - '.$title).'</title>';
1266
+		} else {
1267
+			print "<title>".dol_htmlentities($appli)."</title>";
1268
+		}
1111 1269
 		print "\n";
1112 1270
 
1113 1271
 		//$ext='';
1114 1272
 		//if (! empty($conf->dol_use_jmobile)) $ext='version='.urlencode(DOL_VERSION);
1115 1273
 		$ext='version='.urlencode(DOL_VERSION);
1116 1274
 
1117
-		if (GETPOST('version','int')) $ext='version='.GETPOST('version','int');	// usefull to force no cache on css/js
1118
-		if (GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)) $ext.='&testmenuhider='.(GETPOST('testmenuhider','int')?GETPOST('testmenuhider','int'):$conf->global->MAIN_TESTMENUHIDER);
1275
+		if (GETPOST('version','int')) {
1276
+			$ext='version='.GETPOST('version','int');
1277
+		}
1278
+		// usefull to force no cache on css/js
1279
+		if (GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)) {
1280
+			$ext.='&testmenuhider='.(GETPOST('testmenuhider','int')?GETPOST('testmenuhider','int'):$conf->global->MAIN_TESTMENUHIDER);
1281
+		}
1119 1282
 
1120 1283
 		$themeparam='?lang='.$langs->defaultlang.'&amp;theme='.$conf->theme.(GETPOST('optioncss','aZ09')?'&amp;optioncss='.GETPOST('optioncss','aZ09',1):'').'&amp;userid='.$user->id.'&amp;entity='.$conf->entity;
1121 1284
 		$themeparam.=($ext?'&amp;'.$ext:'');
1122
-		if (! empty($_SESSION['dol_resetcache'])) $themeparam.='&amp;dol_resetcache='.$_SESSION['dol_resetcache'];
1285
+		if (! empty($_SESSION['dol_resetcache'])) {
1286
+			$themeparam.='&amp;dol_resetcache='.$_SESSION['dol_resetcache'];
1287
+		}
1123 1288
 		if (GETPOST('dol_hide_topmenu','int'))           { $themeparam.='&amp;dol_hide_topmenu='.GETPOST('dol_hide_topmenu','int'); }
1124 1289
 		if (GETPOST('dol_hide_leftmenu','int'))          { $themeparam.='&amp;dol_hide_leftmenu='.GETPOST('dol_hide_leftmenu','int'); }
1125 1290
 		if (GETPOST('dol_optimize_smallscreen','int'))   { $themeparam.='&amp;dol_optimize_smallscreen='.GETPOST('dol_optimize_smallscreen','int'); }
@@ -1130,10 +1295,21 @@  discard block
 block discarded – undo
1130 1295
 		{
1131 1296
 			print '<!-- Includes CSS for JQuery (Ajax library) -->'."\n";
1132 1297
 			$jquerytheme = 'smoothness';
1133
-			if (!empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME;
1134
-			if (constant('JS_JQUERY_UI')) print '<link rel="stylesheet" type="text/css" href="'.JS_JQUERY_UI.'css/'.$jquerytheme.'/jquery-ui.min.css'.($ext?'?'.$ext:'').'">'."\n";  // JQuery
1135
-			else print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/css/'.$jquerytheme.'/jquery-ui.css'.($ext?'?'.$ext:'').'">'."\n";    // JQuery
1136
-			if (! defined('DISABLE_JQUERY_JNOTIFY')) print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify-alt.min.css'.($ext?'?'.$ext:'').'">'."\n";          // JNotify
1298
+			if (!empty($conf->global->MAIN_USE_JQUERY_THEME)) {
1299
+				$jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME;
1300
+			}
1301
+			if (constant('JS_JQUERY_UI')) {
1302
+				print '<link rel="stylesheet" type="text/css" href="'.JS_JQUERY_UI.'css/'.$jquerytheme.'/jquery-ui.min.css'.($ext?'?'.$ext:'').'">'."\n";
1303
+			}
1304
+			// JQuery
1305
+			else {
1306
+				print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/css/'.$jquerytheme.'/jquery-ui.css'.($ext?'?'.$ext:'').'">'."\n";
1307
+			}
1308
+			// JQuery
1309
+			if (! defined('DISABLE_JQUERY_JNOTIFY')) {
1310
+				print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify-alt.min.css'.($ext?'?'.$ext:'').'">'."\n";
1311
+			}
1312
+			// JNotify
1137 1313
 			/* Removed a old hidden problematic feature never used in Dolibarr. If an external module need datatable, the module must provide all lib it needs and manage version problems with other dolibarr components
1138 1314
             if (! empty($conf->global->MAIN_USE_JQUERY_DATATABLES) || (defined('REQUIRE_JQUERY_DATATABLES') && constant('REQUIRE_JQUERY_DATATABLES')))     // jQuery datatables
1139 1315
             {
@@ -1141,9 +1317,11 @@  discard block
 block discarded – undo
1141 1317
                 print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extensions/Buttons/css/buttons.dataTables.min.css'.($ext?'?'.$ext:'').'">'."\n";
1142 1318
                 print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extensions/ColReorder/css/colReorder.dataTables.min.css'.($ext?'?'.$ext:'').'"></script>'."\n";
1143 1319
             }*/
1144
-			if (! defined('DISABLE_SELECT2') && (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')))     // jQuery plugin "mutiselect", "multiple-select", "select2"...
1320
+			if (! defined('DISABLE_SELECT2') && (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))) {
1321
+				// jQuery plugin "mutiselect", "multiple-select", "select2"...
1145 1322
 			{
1146 1323
 				$tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT;
1324
+			}
1147 1325
 				print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/'.$tmpplugin.'/dist/css/'.$tmpplugin.'.css'.($ext?'?'.$ext:'').'">'."\n";
1148 1326
 			}
1149 1327
 			// jQuery Timepicker
@@ -1163,13 +1341,15 @@  discard block
 block discarded – undo
1163 1341
 		// Output style sheets (optioncss='print' or ''). Note: $conf->css looks like '/theme/eldy/style.css.php'
1164 1342
 		$themepath=dol_buildpath($conf->css,1);
1165 1343
 		$themesubdir='';
1166
-		if (! empty($conf->modules_parts['theme']))	// This slow down
1344
+		if (! empty($conf->modules_parts['theme'])) {
1345
+			// This slow down
1167 1346
 		{
1168 1347
 			foreach($conf->modules_parts['theme'] as $reldir)
1169 1348
 			{
1170 1349
 				if (file_exists(dol_buildpath($reldir.$conf->css, 0)))
1171 1350
 				{
1172 1351
 					$themepath=dol_buildpath($reldir.$conf->css, 1);
1352
+		}
1173 1353
 					$themesubdir=$reldir;
1174 1354
 					break;
1175 1355
 				}
@@ -1177,7 +1357,9 @@  discard block
 block discarded – undo
1177 1357
 		}
1178 1358
 		//print 'themepath='.$themepath.' themeparam='.$themeparam;exit;
1179 1359
 		print '<link rel="stylesheet" type="text/css" href="'.$themepath.$themeparam.'">'."\n";
1180
-		if (! empty($conf->global->MAIN_FIX_FLASH_ON_CHROME)) print '<!-- Includes CSS that does not exists as a workaround of flash bug of chrome -->'."\n".'<link rel="stylesheet" type="text/css" href="filethatdoesnotexiststosolvechromeflashbug">'."\n";
1360
+		if (! empty($conf->global->MAIN_FIX_FLASH_ON_CHROME)) {
1361
+			print '<!-- Includes CSS that does not exists as a workaround of flash bug of chrome -->'."\n".'<link rel="stylesheet" type="text/css" href="filethatdoesnotexiststosolvechromeflashbug">'."\n";
1362
+		}
1181 1363
 
1182 1364
 		// CSS forced by modules (relative url starting with /)
1183 1365
 		if (! empty($conf->modules_parts['css']))
@@ -1188,11 +1370,15 @@  discard block
 block discarded – undo
1188 1370
 				$filescss=(array) $filescss;	// To be sure filecss is an array
1189 1371
 				foreach($filescss as $cssfile)
1190 1372
 				{
1191
-					if (empty($cssfile)) dol_syslog("Warning: module ".$modcss." declared a css path file into its descriptor that is empty.", LOG_WARNING);
1373
+					if (empty($cssfile)) {
1374
+						dol_syslog("Warning: module ".$modcss." declared a css path file into its descriptor that is empty.", LOG_WARNING);
1375
+					}
1192 1376
 					// cssfile is a relative path
1193 1377
 					print '<!-- Includes CSS added by module '.$modcss. ' -->'."\n".'<link rel="stylesheet" type="text/css" href="'.dol_buildpath($cssfile,1);
1194 1378
 					// We add params only if page is not static, because some web server setup does not return content type text/css if url has parameters, so browser cache is not used.
1195
-					if (!preg_match('/\.css$/i',$cssfile)) print $themeparam;
1379
+					if (!preg_match('/\.css$/i',$cssfile)) {
1380
+						print $themeparam;
1381
+					}
1196 1382
 					print '">'."\n";
1197 1383
 				}
1198 1384
 			}
@@ -1204,7 +1390,9 @@  discard block
 block discarded – undo
1204 1390
 			{
1205 1391
 				print '<!-- Includes CSS added by page -->'."\n".'<link rel="stylesheet" type="text/css" title="default" href="'.dol_buildpath($cssfile,1);
1206 1392
 				// We add params only if page is not static, because some web server setup does not return content type text/css if url has parameters and browser cache is not used.
1207
-				if (!preg_match('/\.css$/i',$cssfile)) print $themeparam;
1393
+				if (!preg_match('/\.css$/i',$cssfile)) {
1394
+					print $themeparam;
1395
+				}
1208 1396
 				print '">'."\n";
1209 1397
 			}
1210 1398
 		}
@@ -1214,16 +1402,27 @@  discard block
 block discarded – undo
1214 1402
 		{
1215 1403
 			// JQuery. Must be before other includes
1216 1404
 			print '<!-- Includes JS for JQuery -->'."\n";
1217
-			if (defined('JS_JQUERY') && constant('JS_JQUERY')) print '<script type="text/javascript" src="'.JS_JQUERY.'jquery.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1218
-			else print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1405
+			if (defined('JS_JQUERY') && constant('JS_JQUERY')) {
1406
+				print '<script type="text/javascript" src="'.JS_JQUERY.'jquery.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1407
+			} else {
1408
+				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1409
+			}
1219 1410
 			if (! empty($conf->global->MAIN_FEATURES_LEVEL) && ! defined('JS_JQUERY_MIGRATE_DISABLED'))
1220 1411
 			{
1221
-				if (defined('JS_JQUERY_MIGRATE') && constant('JS_JQUERY_MIGRATE')) print '<script type="text/javascript" src="'.JS_JQUERY_MIGRATE.'jquery-migrate.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1222
-				else print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-migrate.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1412
+				if (defined('JS_JQUERY_MIGRATE') && constant('JS_JQUERY_MIGRATE')) {
1413
+					print '<script type="text/javascript" src="'.JS_JQUERY_MIGRATE.'jquery-migrate.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1414
+				} else {
1415
+					print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-migrate.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1416
+				}
1417
+			}
1418
+			if (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI')) {
1419
+				print '<script type="text/javascript" src="'.JS_JQUERY_UI.'jquery-ui.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1420
+			} else {
1421
+				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-ui.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1422
+			}
1423
+			if (! defined('DISABLE_JQUERY_TABLEDND')) {
1424
+				print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/tablednd/jquery.tablednd.0.6.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1223 1425
 			}
1224
-			if (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI')) print '<script type="text/javascript" src="'.JS_JQUERY_UI.'jquery-ui.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1225
-			else print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-ui.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1226
-			if (! defined('DISABLE_JQUERY_TABLEDND')) print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/tablednd/jquery.tablednd.0.6.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1227 1426
 			// jQuery jnotify
1228 1427
 			if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! defined('DISABLE_JQUERY_JNOTIFY'))
1229 1428
 			{
@@ -1238,8 +1437,7 @@  discard block
 block discarded – undo
1238 1437
 					print '<script type="text/javascript" src="'.JS_JQUERY_FLOT.'jquery.flot.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1239 1438
 					print '<script type="text/javascript" src="'.JS_JQUERY_FLOT.'jquery.flot.pie.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1240 1439
 					print '<script type="text/javascript" src="'.JS_JQUERY_FLOT.'jquery.flot.stack.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1241
-				}
1242
-				else
1440
+				} else
1243 1441
 				{
1244 1442
 					print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1245 1443
 					print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.pie.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
@@ -1285,9 +1483,11 @@  discard block
 block discarded – undo
1285 1483
             	print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.js'.($ext?'?'.$ext:'').'"></script>'."\n";
1286 1484
             	print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/timepicker.js.php?lang='.$langs->defaultlang.($ext?'&amp;'.$ext:'').'"></script>'."\n";
1287 1485
             }
1288
-            if (! defined('DISABLE_SELECT2') && (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')))     // jQuery plugin "mutiselect", "multiple-select", "select2", ...
1486
+            if (! defined('DISABLE_SELECT2') && (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))) {
1487
+            	// jQuery plugin "mutiselect", "multiple-select", "select2", ...
1289 1488
             {
1290 1489
             	$tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT;
1490
+            }
1291 1491
             	print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/'.$tmpplugin.'/dist/js/'.$tmpplugin.'.full.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";	// We include full because we need the support of containerCssClass
1292 1492
             }
1293 1493
         }
@@ -1300,10 +1500,12 @@  discard block
 block discarded – undo
1300 1500
                 print '<!-- Includes JS for CKEditor -->'."\n";
1301 1501
                 $pathckeditor = DOL_URL_ROOT . '/includes/ckeditor/ckeditor/';
1302 1502
                 $jsckeditor='ckeditor.js';
1303
-                if (constant('JS_CKEDITOR'))	// To use external ckeditor 4 js lib
1503
+                if (constant('JS_CKEDITOR')) {
1504
+                	// To use external ckeditor 4 js lib
1304 1505
                 {
1305 1506
                 	$pathckeditor=constant('JS_CKEDITOR');
1306 1507
                 }
1508
+                }
1307 1509
                 print '<script type="text/javascript">';
1308 1510
                 print 'var CKEDITOR_BASEPATH = \''.$pathckeditor.'\';'."\n";
1309 1511
                 print 'var ckeditorConfig = \''.dol_buildpath($themesubdir.'/theme/'.$conf->theme.'/ckeditor/config.js'.($ext?'?'.$ext:''),1).'\';'."\n";		// $themesubdir='' in standard usage
@@ -1317,8 +1519,12 @@  discard block
 block discarded – undo
1317 1519
             if (! defined('DISABLE_BROWSER_NOTIF'))
1318 1520
             {
1319 1521
                 $enablebrowsernotif=false;
1320
-                if (! empty($conf->agenda->enabled) && ! empty($conf->global->AGENDA_REMINDER_BROWSER)) $enablebrowsernotif=true;
1321
-                if ($conf->browser->layout == 'phone') $enablebrowsernotif=false;
1522
+                if (! empty($conf->agenda->enabled) && ! empty($conf->global->AGENDA_REMINDER_BROWSER)) {
1523
+                	$enablebrowsernotif=true;
1524
+                }
1525
+                if ($conf->browser->layout == 'phone') {
1526
+                	$enablebrowsernotif=false;
1527
+                }
1322 1528
                 if ($enablebrowsernotif)
1323 1529
                 {
1324 1530
                     print '<!-- Includes JS of Dolibarr (brwoser layout = '.$conf->browser->layout.')-->'."\n";
@@ -1331,9 +1537,11 @@  discard block
 block discarded – undo
1331 1537
             print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/lib_head.js.php?lang='.$langs->defaultlang.($ext?'&amp;'.$ext:'').'"></script>'."\n";
1332 1538
 
1333 1539
             // JS forced by modules (relative url starting with /)
1334
-            if (! empty($conf->modules_parts['js']))		// $conf->modules_parts['js'] is array('module'=>array('file1','file2'))
1540
+            if (! empty($conf->modules_parts['js'])) {
1541
+            	// $conf->modules_parts['js'] is array('module'=>array('file1','file2'))
1335 1542
         	{
1336 1543
         		$arrayjs=(array) $conf->modules_parts['js'];
1544
+            }
1337 1545
 	            foreach($arrayjs as $modjs => $filesjs)
1338 1546
 	            {
1339 1547
         			$filesjs=(array) $filesjs;	// To be sure filejs is an array
@@ -1353,18 +1561,24 @@  discard block
 block discarded – undo
1353 1561
                     if (preg_match('/^http/i',$jsfile))
1354 1562
                     {
1355 1563
                         print '<script type="text/javascript" src="'.$jsfile.'"></script>'."\n";
1356
-                    }
1357
-                    else
1564
+                    } else
1358 1565
                     {
1359
-                        if (! preg_match('/^\//',$jsfile)) $jsfile='/'.$jsfile;	// For backward compatibility
1566
+                        if (! preg_match('/^\//',$jsfile)) {
1567
+                        	$jsfile='/'.$jsfile;
1568
+                        }
1569
+                        // For backward compatibility
1360 1570
                         print '<script type="text/javascript" src="'.dol_buildpath($jsfile,1).'"></script>'."\n";
1361 1571
                     }
1362 1572
                 }
1363 1573
             }
1364 1574
         }
1365 1575
 
1366
-        if (! empty($head)) print $head."\n";
1367
-        if (! empty($conf->global->MAIN_HTML_HEADER)) print $conf->global->MAIN_HTML_HEADER."\n";
1576
+        if (! empty($head)) {
1577
+        	print $head."\n";
1578
+        }
1579
+        if (! empty($conf->global->MAIN_HTML_HEADER)) {
1580
+        	print $conf->global->MAIN_HTML_HEADER."\n";
1581
+        }
1368 1582
 
1369 1583
         print "</head>\n\n";
1370 1584
     }
@@ -1432,13 +1646,20 @@  discard block
 block discarded – undo
1432 1646
 			$appli=$conf->global->MAIN_APPLICATION_TITLE;
1433 1647
 			if (preg_match('/\d\.\d/', $appli))
1434 1648
 			{
1435
-				if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")";	// If new title contains a version that is different than core
1649
+				if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) {
1650
+					$appli.=" (".DOL_VERSION.")";
1651
+				}
1652
+				// If new title contains a version that is different than core
1653
+			} else {
1654
+				$appli.=" ".DOL_VERSION;
1436 1655
 			}
1437
-			else $appli.=" ".DOL_VERSION;
1656
+		} else {
1657
+			$appli.=" ".DOL_VERSION;
1438 1658
 		}
1439
-		else $appli.=" ".DOL_VERSION;
1440 1659
 
1441
-		if (! empty($conf->global->MAIN_FEATURES_LEVEL)) $appli.="<br>".$langs->trans("LevelOfFeature").': '.$conf->global->MAIN_FEATURES_LEVEL;
1660
+		if (! empty($conf->global->MAIN_FEATURES_LEVEL)) {
1661
+			$appli.="<br>".$langs->trans("LevelOfFeature").': '.$conf->global->MAIN_FEATURES_LEVEL;
1662
+		}
1442 1663
 
1443 1664
 		$logouttext='';
1444 1665
 		if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
@@ -1452,8 +1673,7 @@  discard block
 block discarded – undo
1452 1673
 				//$logouttext .= img_picto($langs->trans('Logout').":".$langs->trans('Logout'), 'logout_top.png', 'class="login"', 0, 0, 1);
1453 1674
 				$logouttext .='<span class="fa fa-sign-out atoplogin"></span>';
1454 1675
 				$logouttext .='</a>';
1455
-			}
1456
-			else
1676
+			} else
1457 1677
 			{
1458 1678
 				$logouthtmltext.=$langs->trans("NoLogoutProcessWithAuthMode",$_SESSION["dol_authmode"]);
1459 1679
 				$logouttext .= img_picto($langs->trans('Logout').":".$langs->trans('Logout'), 'logout_top.png', 'class="login"', 0, 0, 1);
@@ -1480,10 +1700,18 @@  discard block
 block discarded – undo
1480 1700
 		$result=$hookmanager->executeHooks('printTopRightMenu',$parameters);    // Note that $action and $object may have been modified by some hooks
1481 1701
 		if (is_numeric($result))
1482 1702
 		{
1483
-			if (empty($result)) $toprightmenu.=$hookmanager->resPrint;		// add
1484
-			else  $toprightmenu=$hookmanager->resPrint;						// replace
1703
+			if (empty($result)) {
1704
+				$toprightmenu.=$hookmanager->resPrint;
1705
+			}
1706
+			// add
1707
+			else {
1708
+				$toprightmenu=$hookmanager->resPrint;
1709
+			}
1710
+			// replace
1711
+		} else {
1712
+			$toprightmenu.=$result;
1485 1713
 		}
1486
-		else $toprightmenu.=$result;	// For backward compatibility
1714
+		// For backward compatibility
1487 1715
 
1488 1716
 		// Link to module builder
1489 1717
 		if (! empty($conf->modulebuilder->enabled))
@@ -1503,7 +1731,9 @@  discard block
 block discarded – undo
1503 1731
 			if (is_array($_POST))
1504 1732
 			{
1505 1733
 				foreach($_POST as $key=>$value) {
1506
-					if ($key!=='action' && !is_array($value)) $qs.='&'.$key.'='.urlencode($value);
1734
+					if ($key!=='action' && !is_array($value)) {
1735
+						$qs.='&'.$key.'='.urlencode($value);
1736
+					}
1507 1737
 				}
1508 1738
 			}
1509 1739
 			$qs.=(($qs && $morequerystring)?'&':'').$morequerystring;
@@ -1523,7 +1753,9 @@  discard block
 block discarded – undo
1523 1753
 			$helppage='';
1524 1754
 			$mode='';
1525 1755
 
1526
-			if (empty($helppagename)) $helppagename='EN:User_documentation|FR:Documentation_utilisateur|ES:Documentación_usuarios';
1756
+			if (empty($helppagename)) {
1757
+				$helppagename='EN:User_documentation|FR:Documentation_utilisateur|ES:Documentación_usuarios';
1758
+			}
1527 1759
 
1528 1760
 			// Get helpbaseurl, helppage and mode from helppagename and langs
1529 1761
 			$arrayres=getHelpParamFor($helppagename,$langs);
@@ -1537,10 +1769,15 @@  discard block
 block discarded – undo
1537 1769
 				$text='';
1538 1770
 				$title=$appli.'<br>';
1539 1771
 				$title.=$langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage': 'GoToHelpPage');
1540
-				if ($mode == 'wiki') $title.=' - '.$langs->trans("PageWiki").' &quot;'.dol_escape_htmltag(strtr($helppage,'_',' ')).'&quot;';
1772
+				if ($mode == 'wiki') {
1773
+					$title.=' - '.$langs->trans("PageWiki").' &quot;'.dol_escape_htmltag(strtr($helppage,'_',' ')).'&quot;';
1774
+				}
1541 1775
 				$text.='<a class="help" target="_blank" href="';
1542
-				if ($mode == 'wiki') $text.=sprintf($helpbaseurl,urlencode(html_entity_decode($helppage)));
1543
-				else $text.=sprintf($helpbaseurl,$helppage);
1776
+				if ($mode == 'wiki') {
1777
+					$text.=sprintf($helpbaseurl,urlencode(html_entity_decode($helppage)));
1778
+				} else {
1779
+					$text.=sprintf($helpbaseurl,$helppage);
1780
+				}
1544 1781
 				$text.='">';
1545 1782
 				//$text.=img_picto('', 'helpdoc_top').' ';
1546 1783
 				$text.='<span class="fa fa-question-circle atoplogin"></span>';
@@ -1568,8 +1805,10 @@  discard block
 block discarded – undo
1568 1805
 		print "<!-- End top horizontal menu -->\n\n";
1569 1806
 	}
1570 1807
 
1571
-	if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '<!-- Begin div id-container --><div id="id-container" class="id-container'.($morecss?' '.$morecss:'').'">';
1572
-}
1808
+	if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) {
1809
+		print '<!-- Begin div id-container --><div id="id-container" class="id-container'.($morecss?' '.$morecss:'').'">';
1810
+	}
1811
+	}
1573 1812
 
1574 1813
 
1575 1814
 /**
@@ -1594,7 +1833,9 @@  discard block
 block discarded – undo
1594 1833
 	$searchform='';
1595 1834
 	$bookmarks='';
1596 1835
 
1597
-	if (! empty($menu_array_before)) dol_syslog("Deprecated parameter menu_array_before was used when calling main::left_menu function. Menu entries of module should now be defined into module descriptor and not provided when calling left_menu.", LOG_WARNING);
1836
+	if (! empty($menu_array_before)) {
1837
+		dol_syslog("Deprecated parameter menu_array_before was used when calling main::left_menu function. Menu entries of module should now be defined into module descriptor and not provided when calling left_menu.", LOG_WARNING);
1838
+	}
1598 1839
 
1599 1840
 	if (empty($conf->dol_hide_leftmenu) && (! defined('NOREQUIREMENU') || ! constant('NOREQUIREMENU')))
1600 1841
 	{
@@ -1605,16 +1846,22 @@  discard block
 block discarded – undo
1605 1846
 
1606 1847
 		print "\n";
1607 1848
 
1608
-		if ($conf->browser->layout == 'phone') $conf->global->MAIN_USE_OLD_SEARCH_FORM=1;	// Select into select2 is awfull on smartphone
1849
+		if ($conf->browser->layout == 'phone') {
1850
+			$conf->global->MAIN_USE_OLD_SEARCH_FORM=1;
1851
+		}
1852
+		// Select into select2 is awfull on smartphone
1609 1853
 		if ($conf->use_javascript_ajax && empty($conf->global->MAIN_USE_OLD_SEARCH_FORM))
1610 1854
 		{
1611
-			if (! is_object($form)) $form=new Form($db);
1855
+			if (! is_object($form)) {
1856
+				$form=new Form($db);
1857
+			}
1612 1858
 			$selected=-1;
1613 1859
 			$searchform.=$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'vmenusearchselectcombo', 1, $langs->trans("Search"), 1);
1614
-		}
1615
-		else
1860
+		} else
1616 1861
 		{
1617
-			if (! is_object($form)) $form=new Form($db);
1862
+			if (! is_object($form)) {
1863
+				$form=new Form($db);
1864
+			}
1618 1865
 			$selected=-1;
1619 1866
 			$usedbyinclude=1;
1620 1867
 			include_once DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php';
@@ -1632,8 +1879,9 @@  discard block
 block discarded – undo
1632 1879
 		if (empty($reshook))
1633 1880
 		{
1634 1881
 			$searchform.=$hookmanager->resPrint;
1882
+		} else {
1883
+			$searchform=$hookmanager->resPrint;
1635 1884
 		}
1636
-		else $searchform=$hookmanager->resPrint;
1637 1885
 
1638 1886
 		if ($conf->use_javascript_ajax && ! empty($conf->global->MAIN_USE_OLD_SEARCH_FORM))
1639 1887
 		{
@@ -1673,15 +1921,27 @@  discard block
 block discarded – undo
1673 1921
 		print '<div id="blockvmenuhelp" class="blockvmenuhelp">'."\n";
1674 1922
 
1675 1923
 		// Version
1676
-		if (empty($conf->global->MAIN_HIDE_VERSION))    // Version is already on help picto and on login page.
1924
+		if (empty($conf->global->MAIN_HIDE_VERSION)) {
1925
+			// Version is already on help picto and on login page.
1677 1926
 		{
1678 1927
 			$doliurl='https://www.dolibarr.org';
1928
+		}
1679 1929
 			//local communities
1680
-			if (preg_match('/fr/i',$langs->defaultlang)) $doliurl='https://www.dolibarr.fr';
1681
-			if (preg_match('/es/i',$langs->defaultlang)) $doliurl='https://www.dolibarr.es';
1682
-			if (preg_match('/de/i',$langs->defaultlang)) $doliurl='https://www.dolibarr.de';
1683
-			if (preg_match('/it/i',$langs->defaultlang)) $doliurl='https://www.dolibarr.it';
1684
-			if (preg_match('/gr/i',$langs->defaultlang)) $doliurl='https://www.dolibarr.gr';
1930
+			if (preg_match('/fr/i',$langs->defaultlang)) {
1931
+				$doliurl='https://www.dolibarr.fr';
1932
+			}
1933
+			if (preg_match('/es/i',$langs->defaultlang)) {
1934
+				$doliurl='https://www.dolibarr.es';
1935
+			}
1936
+			if (preg_match('/de/i',$langs->defaultlang)) {
1937
+				$doliurl='https://www.dolibarr.de';
1938
+			}
1939
+			if (preg_match('/it/i',$langs->defaultlang)) {
1940
+				$doliurl='https://www.dolibarr.it';
1941
+			}
1942
+			if (preg_match('/gr/i',$langs->defaultlang)) {
1943
+				$doliurl='https://www.dolibarr.gr';
1944
+			}
1685 1945
 
1686 1946
 			$appli=constant('DOL_APPLICATION_TITLE');
1687 1947
 			if (! empty($conf->global->MAIN_APPLICATION_TITLE))
@@ -1689,17 +1949,28 @@  discard block
 block discarded – undo
1689 1949
 				$appli=$conf->global->MAIN_APPLICATION_TITLE; $doliurl='';
1690 1950
 				if (preg_match('/\d\.\d/', $appli))
1691 1951
 				{
1692
-					if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")";	// If new title contains a version that is different than core
1952
+					if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) {
1953
+						$appli.=" (".DOL_VERSION.")";
1954
+					}
1955
+					// If new title contains a version that is different than core
1956
+				} else {
1957
+					$appli.=" ".DOL_VERSION;
1693 1958
 				}
1694
-				else $appli.=" ".DOL_VERSION;
1959
+			} else {
1960
+				$appli.=" ".DOL_VERSION;
1695 1961
 			}
1696
-			else $appli.=" ".DOL_VERSION;
1697 1962
 			print '<div id="blockvmenuhelpapp" class="blockvmenuhelp">';
1698
-			if ($doliurl) print '<a class="help" target="_blank" href="'.$doliurl.'">';
1699
-			else print '<span class="help">';
1963
+			if ($doliurl) {
1964
+				print '<a class="help" target="_blank" href="'.$doliurl.'">';
1965
+			} else {
1966
+				print '<span class="help">';
1967
+			}
1700 1968
 			print $appli;
1701
-			if ($doliurl) print '</a>';
1702
-			else print '</span>';
1969
+			if ($doliurl) {
1970
+				print '</a>';
1971
+			} else {
1972
+				print '</span>';
1973
+			}
1703 1974
 			print '</div>'."\n";
1704 1975
 		}
1705 1976
 
@@ -1748,8 +2019,10 @@  discard block
 block discarded – undo
1748 2019
 	print "\n";
1749 2020
 	print '<!-- Begin right area -->'."\n";
1750 2021
 
1751
-	if (empty($leftmenuwithoutmainarea)) main_area($title);
1752
-}
2022
+	if (empty($leftmenuwithoutmainarea)) {
2023
+		main_area($title);
2024
+	}
2025
+	}
1753 2026
 
1754 2027
 
1755 2028
 /**
@@ -1762,14 +2035,18 @@  discard block
 block discarded – undo
1762 2035
 {
1763 2036
 	global $conf, $langs;
1764 2037
 
1765
-	if (empty($conf->dol_hide_leftmenu)) print '<div id="id-right">';
2038
+	if (empty($conf->dol_hide_leftmenu)) {
2039
+		print '<div id="id-right">';
2040
+	}
1766 2041
 
1767 2042
 	print "\n";
1768 2043
 
1769 2044
 	print '<!-- Begin div class="fiche" -->'."\n".'<div class="fiche">'."\n";
1770 2045
 
1771
-	if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) print info_admin($langs->trans("WarningYouAreInMaintenanceMode",$conf->global->MAIN_ONLY_LOGIN_ALLOWED));
1772
-}
2046
+	if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) {
2047
+		print info_admin($langs->trans("WarningYouAreInMaintenanceMode",$conf->global->MAIN_ONLY_LOGIN_ALLOWED));
2048
+	}
2049
+	}
1773 2050
 
1774 2051
 
1775 2052
 /**
@@ -1791,24 +2068,31 @@  discard block
 block discarded – undo
1791 2068
 		$helpbaseurl='%s';
1792 2069
 		$helppage=$helppagename;
1793 2070
 		$mode='local';
1794
-	}
1795
-	else
2071
+	} else
1796 2072
 	{
1797 2073
 		// If WIKI URL
1798 2074
 		if (preg_match('/^es/i',$langs->defaultlang))
1799 2075
 		{
1800 2076
 			$helpbaseurl='http://wiki.dolibarr.org/index.php/%s';
1801
-			if (preg_match('/ES:([^|]+)/i',$helppagename,$reg)) $helppage=$reg[1];
2077
+			if (preg_match('/ES:([^|]+)/i',$helppagename,$reg)) {
2078
+				$helppage=$reg[1];
2079
+			}
1802 2080
 		}
1803 2081
 		if (preg_match('/^fr/i',$langs->defaultlang))
1804 2082
 		{
1805 2083
 			$helpbaseurl='http://wiki.dolibarr.org/index.php/%s';
1806
-			if (preg_match('/FR:([^|]+)/i',$helppagename,$reg)) $helppage=$reg[1];
2084
+			if (preg_match('/FR:([^|]+)/i',$helppagename,$reg)) {
2085
+				$helppage=$reg[1];
2086
+			}
1807 2087
 		}
1808
-		if (empty($helppage))	// If help page not already found
2088
+		if (empty($helppage)) {
2089
+			// If help page not already found
1809 2090
 		{
1810 2091
 			$helpbaseurl='http://wiki.dolibarr.org/index.php/%s';
1811
-			if (preg_match('/EN:([^|]+)/i',$helppagename,$reg)) $helppage=$reg[1];
2092
+		}
2093
+			if (preg_match('/EN:([^|]+)/i',$helppagename,$reg)) {
2094
+				$helppage=$reg[1];
2095
+			}
1812 2096
 		}
1813 2097
 		$mode='wiki';
1814 2098
 	}
@@ -1884,8 +2168,12 @@  discard block
 block discarded – undo
1884 2168
 				unset($_SESSION['lastsearch_values_tmp_'.$key]);
1885 2169
 				if (count($val))
1886 2170
 				{
1887
-					if (empty($val['sortfield'])) unset($val['sortfield']);
1888
-					if (empty($val['sortorder'])) unset($val['sortorder']);
2171
+					if (empty($val['sortfield'])) {
2172
+						unset($val['sortfield']);
2173
+					}
2174
+					if (empty($val['sortorder'])) {
2175
+						unset($val['sortorder']);
2176
+					}
1889 2177
 					dol_syslog('Save lastsearch_values_tmp_'.$key.'='.json_encode($val, 0)." (systematic recording of last search criteria)");
1890 2178
 					$_SESSION['lastsearch_values_tmp_'.$key]=json_encode($val);
1891 2179
 					unset($_SESSION['lastsearch_values_'.$key]);
@@ -1916,16 +2204,26 @@  discard block
 block discarded – undo
1916 2204
 
1917 2205
 		print '</div> <!-- End div class="fiche" -->'."\n"; // End div fiche
1918 2206
 
1919
-		if (empty($conf->dol_hide_leftmenu)) print '</div> <!-- End div id-right -->'; // End div id-right
2207
+		if (empty($conf->dol_hide_leftmenu)) {
2208
+			print '</div> <!-- End div id-right -->';
2209
+		}
2210
+		// End div id-right
1920 2211
 
1921 2212
 		print "\n";
1922
-		if ($comment) print '<!-- '.$comment.' -->'."\n";
2213
+		if ($comment) {
2214
+			print '<!-- '.$comment.' -->'."\n";
2215
+		}
1923 2216
 
1924 2217
 		printCommonFooter($zone);
1925 2218
 
1926
-		if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '</div> <!-- End div id-container -->'."\n";	// End div container
2219
+		if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) {
2220
+			print '</div> <!-- End div id-container -->'."\n";
2221
+		}
2222
+		// End div container
1927 2223
 
1928
-		if (! empty($delayedhtmlcontent)) print $delayedhtmlcontent;
2224
+		if (! empty($delayedhtmlcontent)) {
2225
+			print $delayedhtmlcontent;
2226
+		}
1929 2227
 
1930 2228
 		// TODO Move this in lib_head.js.php
1931 2229
 
@@ -2014,9 +2312,11 @@  discard block
 block discarded – undo
2014 2312
 		// Wrapper to add log when clicking on download or preview
2015 2313
 		if (! empty($conf->blockedlog->enabled) && is_object($object) && $object->id > 0 && $object->statut > 0)
2016 2314
 		{
2017
-			if (in_array($object->element, array('facture')))       // Restrict for the moment to element 'facture'
2315
+			if (in_array($object->element, array('facture'))) {
2316
+				// Restrict for the moment to element 'facture'
2018 2317
 			{
2019 2318
 				print "\n<!-- JS CODE TO ENABLE log when making a download or a preview of a document -->\n";
2319
+			}
2020 2320
 				?>
2021 2321
     			<script type="text/javascript">
2022 2322
     			jQuery(document).ready(function () {
Please login to merge, or discard this patch.
htdocs/product/class/productcustomerprice.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -507,7 +507,7 @@
 block discarded – undo
507 507
 	/**
508 508
 	 * Update object into database
509 509
 	 *
510
-	 * @param User $user that modifies
510
+	 * @param integer $user that modifies
511 511
 	 * @param int $notrigger triggers after, 1=disable triggers
512 512
 	 * @param int $forceupdateaffiliate update price on each soc child
513 513
 	 * @return int <0 if KO, >0 if OK
Please login to merge, or discard this patch.
Braces   +108 added lines, -64 removed lines patch added patch discarded remove patch
@@ -75,34 +75,48 @@  discard block
 block discarded – undo
75 75
 
76 76
 		// Clean parameters
77 77
 
78
-		if (isset($this->entity))
79
-			$this->entity = trim($this->entity);
80
-		if (isset($this->fk_product))
81
-			$this->fk_product = trim($this->fk_product);
82
-		if (isset($this->fk_soc))
83
-			$this->fk_soc = trim($this->fk_soc);
84
-		if (isset($this->price))
85
-			$this->price = trim($this->price);
86
-		if (isset($this->price_ttc))
87
-			$this->price_ttc = trim($this->price_ttc);
88
-		if (isset($this->price_min))
89
-			$this->price_min = trim($this->price_min);
90
-		if (isset($this->price_min_ttc))
91
-			$this->price_min_ttc = trim($this->price_min_ttc);
92
-		if (isset($this->price_base_type))
93
-			$this->price_base_type = trim($this->price_base_type);
94
-		if (isset($this->tva_tx))
95
-			$this->tva_tx = trim($this->tva_tx);
96
-		if (isset($this->recuperableonly))
97
-			$this->recuperableonly = trim($this->recuperableonly);
98
-		if (isset($this->localtax1_tx))
99
-			$this->localtax1_tx = trim($this->localtax1_tx);
100
-		if (isset($this->localtax2_tx))
101
-			$this->localtax2_tx = trim($this->localtax2_tx);
102
-		if (isset($this->fk_user))
103
-			$this->fk_user = trim($this->fk_user);
104
-		if (isset($this->import_key))
105
-			$this->import_key = trim($this->import_key);
78
+		if (isset($this->entity)) {
79
+					$this->entity = trim($this->entity);
80
+		}
81
+		if (isset($this->fk_product)) {
82
+					$this->fk_product = trim($this->fk_product);
83
+		}
84
+		if (isset($this->fk_soc)) {
85
+					$this->fk_soc = trim($this->fk_soc);
86
+		}
87
+		if (isset($this->price)) {
88
+					$this->price = trim($this->price);
89
+		}
90
+		if (isset($this->price_ttc)) {
91
+					$this->price_ttc = trim($this->price_ttc);
92
+		}
93
+		if (isset($this->price_min)) {
94
+					$this->price_min = trim($this->price_min);
95
+		}
96
+		if (isset($this->price_min_ttc)) {
97
+					$this->price_min_ttc = trim($this->price_min_ttc);
98
+		}
99
+		if (isset($this->price_base_type)) {
100
+					$this->price_base_type = trim($this->price_base_type);
101
+		}
102
+		if (isset($this->tva_tx)) {
103
+					$this->tva_tx = trim($this->tva_tx);
104
+		}
105
+		if (isset($this->recuperableonly)) {
106
+					$this->recuperableonly = trim($this->recuperableonly);
107
+		}
108
+		if (isset($this->localtax1_tx)) {
109
+					$this->localtax1_tx = trim($this->localtax1_tx);
110
+		}
111
+		if (isset($this->localtax2_tx)) {
112
+					$this->localtax2_tx = trim($this->localtax2_tx);
113
+		}
114
+		if (isset($this->fk_user)) {
115
+					$this->fk_user = trim($this->fk_user);
116
+		}
117
+		if (isset($this->import_key)) {
118
+					$this->import_key = trim($this->import_key);
119
+		}
106 120
 
107 121
 			// Check parameters
108 122
 			// Put here code to add control on parameters values
@@ -308,8 +322,12 @@  discard block
 block discarded – undo
308 322
 	{
309 323
 		global $langs;
310 324
 
311
-		if ( empty($sortfield)) $sortfield = "t.rowid";
312
-		if ( empty($sortorder)) $sortorder = "DESC";
325
+		if ( empty($sortfield)) {
326
+			$sortfield = "t.rowid";
327
+		}
328
+		if ( empty($sortorder)) {
329
+			$sortorder = "DESC";
330
+		}
313 331
 
314 332
 		$sql = "SELECT";
315 333
 		$sql .= " t.rowid,";
@@ -343,9 +361,11 @@  discard block
 block discarded – undo
343 361
 		// Manage filter
344 362
 		if (count($filter) > 0) {
345 363
 			foreach ( $filter as $key => $value ) {
346
-				if (strpos($key, 'date')) 				// To allow $filter['YEAR(s.dated)']=>$year
364
+				if (strpos($key, 'date')) {
365
+					// To allow $filter['YEAR(s.dated)']=>$year
347 366
 				{
348 367
 					$sql .= ' AND ' . $key . ' = \'' . $value . '\'';
368
+				}
349 369
 				} elseif ($key == 'soc.nom') {
350 370
 					$sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\'';
351 371
 				} elseif ($key == 'prod.ref') {
@@ -356,7 +376,9 @@  discard block
 block discarded – undo
356 376
 			}
357 377
 		}
358 378
 		$sql.= $this->db->order($sortfield, $sortorder);
359
-		if (! empty($limit)) $sql .= ' ' . $this->db->plimit($limit + 1, $offset);
379
+		if (! empty($limit)) {
380
+			$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
381
+		}
360 382
 
361 383
 		dol_syslog(get_class($this) . "::fetch_all", LOG_DEBUG);
362 384
 		$resql = $this->db->query($sql);
@@ -416,8 +438,12 @@  discard block
 block discarded – undo
416 438
 	{
417 439
 		global $langs;
418 440
 
419
-		if (! empty($sortfield)) $sortfield = "t.rowid";
420
-		if (! empty($sortorder)) $sortorder = "DESC";
441
+		if (! empty($sortfield)) {
442
+			$sortfield = "t.rowid";
443
+		}
444
+		if (! empty($sortorder)) {
445
+			$sortorder = "DESC";
446
+		}
421 447
 
422 448
 		$sql = "SELECT";
423 449
 		$sql .= " t.rowid,";
@@ -450,9 +476,11 @@  discard block
 block discarded – undo
450 476
 		// Manage filter
451 477
 		if (count($filter) > 0) {
452 478
 			foreach ( $filter as $key => $value ) {
453
-				if (strpos($key, 'date')) 				// To allow $filter['YEAR(s.dated)']=>$year
479
+				if (strpos($key, 'date')) {
480
+					// To allow $filter['YEAR(s.dated)']=>$year
454 481
 				{
455 482
 					$sql .= ' AND ' . $key . ' = \'' . $value . '\'';
483
+				}
456 484
 				} elseif ($key == 'soc.nom') {
457 485
 					$sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\'';
458 486
 				} else {
@@ -462,7 +490,9 @@  discard block
 block discarded – undo
462 490
 		}
463 491
 
464 492
 		$sql.= $this->db->order($sortfield, $sortorder);
465
-		if (! empty($limit)) $sql .= ' ' . $this->db->plimit($limit + 1, $offset);
493
+		if (! empty($limit)) {
494
+			$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
495
+		}
466 496
 
467 497
 		dol_syslog(get_class($this) . "::fetch_all_log", LOG_DEBUG);
468 498
 		$resql = $this->db->query($sql);
@@ -523,34 +553,48 @@  discard block
 block discarded – undo
523 553
 
524 554
 		// Clean parameters
525 555
 
526
-		if (isset($this->entity))
527
-			$this->entity = trim($this->entity);
528
-		if (isset($this->fk_product))
529
-			$this->fk_product = trim($this->fk_product);
530
-		if (isset($this->fk_soc))
531
-			$this->fk_soc = trim($this->fk_soc);
532
-		if (isset($this->price))
533
-			$this->price = trim($this->price);
534
-		if (isset($this->price_ttc))
535
-			$this->price_ttc = trim($this->price_ttc);
536
-		if (isset($this->price_min))
537
-			$this->price_min = trim($this->price_min);
538
-		if (isset($this->price_min_ttc))
539
-			$this->price_min_ttc = trim($this->price_min_ttc);
540
-		if (isset($this->price_base_type))
541
-			$this->price_base_type = trim($this->price_base_type);
542
-		if (isset($this->tva_tx))
543
-			$this->tva_tx = trim($this->tva_tx);
544
-		if (isset($this->recuperableonly))
545
-			$this->recuperableonly = trim($this->recuperableonly);
546
-		if (isset($this->localtax1_tx))
547
-			$this->localtax1_tx = trim($this->localtax1_tx);
548
-		if (isset($this->localtax2_tx))
549
-			$this->localtax2_tx = trim($this->localtax2_tx);
550
-		if (isset($this->fk_user))
551
-			$this->fk_user = trim($this->fk_user);
552
-		if (isset($this->import_key))
553
-			$this->import_key = trim($this->import_key);
556
+		if (isset($this->entity)) {
557
+					$this->entity = trim($this->entity);
558
+		}
559
+		if (isset($this->fk_product)) {
560
+					$this->fk_product = trim($this->fk_product);
561
+		}
562
+		if (isset($this->fk_soc)) {
563
+					$this->fk_soc = trim($this->fk_soc);
564
+		}
565
+		if (isset($this->price)) {
566
+					$this->price = trim($this->price);
567
+		}
568
+		if (isset($this->price_ttc)) {
569
+					$this->price_ttc = trim($this->price_ttc);
570
+		}
571
+		if (isset($this->price_min)) {
572
+					$this->price_min = trim($this->price_min);
573
+		}
574
+		if (isset($this->price_min_ttc)) {
575
+					$this->price_min_ttc = trim($this->price_min_ttc);
576
+		}
577
+		if (isset($this->price_base_type)) {
578
+					$this->price_base_type = trim($this->price_base_type);
579
+		}
580
+		if (isset($this->tva_tx)) {
581
+					$this->tva_tx = trim($this->tva_tx);
582
+		}
583
+		if (isset($this->recuperableonly)) {
584
+					$this->recuperableonly = trim($this->recuperableonly);
585
+		}
586
+		if (isset($this->localtax1_tx)) {
587
+					$this->localtax1_tx = trim($this->localtax1_tx);
588
+		}
589
+		if (isset($this->localtax2_tx)) {
590
+					$this->localtax2_tx = trim($this->localtax2_tx);
591
+		}
592
+		if (isset($this->fk_user)) {
593
+					$this->fk_user = trim($this->fk_user);
594
+		}
595
+		if (isset($this->import_key)) {
596
+					$this->import_key = trim($this->import_key);
597
+		}
554 598
 
555 599
 			// Check parameters
556 600
 			// Put here code to add a control on parameters values
Please login to merge, or discard this patch.
Spacing   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  * \ingroup produit
22 22
  * \brief File of class to manage predefined price products or services by customer
23 23
  */
24
-require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
24
+require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
25 25
 
26 26
 /**
27 27
  * File of class to manage predefined price products or services by customer
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	var $localtax2_type;
48 48
 	var $localtax2_tx;
49 49
 	var $fk_user;
50
-	var $lines = array ();
50
+	var $lines = array();
51 51
 
52 52
 	/**
53 53
 	 * Constructor
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		}
140 140
 
141 141
 		// Insert request
142
-		$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_customer_price(";
142
+		$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_customer_price(";
143 143
 		$sql .= "entity,";
144 144
 		$sql .= "datec,";
145 145
 		$sql .= "fk_product,";
@@ -159,39 +159,39 @@  discard block
 block discarded – undo
159 159
 		$sql .= "fk_user,";
160 160
 		$sql .= "import_key";
161 161
 		$sql .= ") VALUES (";
162
-		$sql .= " " . $conf->entity . ",";
163
-		$sql .= " '" . $this->db->idate(dol_now()) . "',";
164
-		$sql .= " " . (! isset($this->fk_product) ? 'NULL' : "'" . $this->db->escape($this->fk_product) . "'") . ",";
165
-		$sql .= " " . (! isset($this->fk_soc) ? 'NULL' : "'" . $this->db->escape($this->fk_soc) . "'") . ",";
166
-		$sql .= " " . (empty($this->price) ? '0' : "'" . $this->db->escape($this->price) . "'") . ",";
167
-		$sql .= " " . (empty($this->price_ttc) ? '0' : "'" . $this->db->escape($this->price_ttc) . "'") . ",";
168
-		$sql .= " " . (empty($this->price_min) ? '0' : "'" . $this->db->escape($this->price_min) . "'") . ",";
169
-		$sql .= " " . (empty($this->price_min_ttc) ? '0' : "'" . $this->db->escape($this->price_min_ttc) . "'") . ",";
170
-		$sql .= " " . (! isset($this->price_base_type) ? 'NULL' : "'" . $this->db->escape($this->price_base_type) . "'") . ",";
162
+		$sql .= " ".$conf->entity.",";
163
+		$sql .= " '".$this->db->idate(dol_now())."',";
164
+		$sql .= " ".(!isset($this->fk_product) ? 'NULL' : "'".$this->db->escape($this->fk_product)."'").",";
165
+		$sql .= " ".(!isset($this->fk_soc) ? 'NULL' : "'".$this->db->escape($this->fk_soc)."'").",";
166
+		$sql .= " ".(empty($this->price) ? '0' : "'".$this->db->escape($this->price)."'").",";
167
+		$sql .= " ".(empty($this->price_ttc) ? '0' : "'".$this->db->escape($this->price_ttc)."'").",";
168
+		$sql .= " ".(empty($this->price_min) ? '0' : "'".$this->db->escape($this->price_min)."'").",";
169
+		$sql .= " ".(empty($this->price_min_ttc) ? '0' : "'".$this->db->escape($this->price_min_ttc)."'").",";
170
+		$sql .= " ".(!isset($this->price_base_type) ? 'NULL' : "'".$this->db->escape($this->price_base_type)."'").",";
171 171
 		$sql .= " ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null").",";
172
-		$sql .= " " . (! isset($this->tva_tx) ? 'NULL' : (empty($this->tva_tx)?0:$this->tva_tx)) . ",";
173
-		$sql .= " " . (! isset($this->recuperableonly) ? 'NULL' : "'" . $this->db->escape($this->recuperableonly) . "'") . ",";
174
-		$sql .= " " . (empty($this->localtax1_type) ? "'0'" : "'" . $this->db->escape($this->localtax1_type) . "'") . ",";
175
-		$sql .= " " . (! isset($this->localtax1_tx) ? 'NULL' : (empty($this->localtax1_tx)?0:$this->localtax1_tx)) . ",";
176
-		$sql .= " " . (empty($this->localtax2_type) ? "'0'" : "'" . $this->db->escape($this->localtax2_type) . "'") . ",";
177
-		$sql .= " " . (! isset($this->localtax2_tx) ? 'NULL' : (empty($this->localtax2_tx)?0:$this->localtax2_tx)) . ",";
178
-		$sql .= " " . $user->id . ",";
179
-		$sql .= " " . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . "";
172
+		$sql .= " ".(!isset($this->tva_tx) ? 'NULL' : (empty($this->tva_tx) ? 0 : $this->tva_tx)).",";
173
+		$sql .= " ".(!isset($this->recuperableonly) ? 'NULL' : "'".$this->db->escape($this->recuperableonly)."'").",";
174
+		$sql .= " ".(empty($this->localtax1_type) ? "'0'" : "'".$this->db->escape($this->localtax1_type)."'").",";
175
+		$sql .= " ".(!isset($this->localtax1_tx) ? 'NULL' : (empty($this->localtax1_tx) ? 0 : $this->localtax1_tx)).",";
176
+		$sql .= " ".(empty($this->localtax2_type) ? "'0'" : "'".$this->db->escape($this->localtax2_type)."'").",";
177
+		$sql .= " ".(!isset($this->localtax2_tx) ? 'NULL' : (empty($this->localtax2_tx) ? 0 : $this->localtax2_tx)).",";
178
+		$sql .= " ".$user->id.",";
179
+		$sql .= " ".(!isset($this->import_key) ? 'NULL' : "'".$this->db->escape($this->import_key)."'")."";
180 180
 		$sql .= ")";
181 181
 
182 182
 		$this->db->begin();
183 183
 
184
-		dol_syslog(get_class($this) . "::create", LOG_DEBUG);
184
+		dol_syslog(get_class($this)."::create", LOG_DEBUG);
185 185
 		$resql = $this->db->query($sql);
186
-		if (! $resql) {
187
-			$error ++;
188
-			$this->errors [] = "Error " . $this->db->lasterror();
186
+		if (!$resql) {
187
+			$error++;
188
+			$this->errors [] = "Error ".$this->db->lasterror();
189 189
 		}
190 190
 
191
-		if (! $error) {
192
-			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "product_customer_price");
191
+		if (!$error) {
192
+			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_customer_price");
193 193
 
194
-			if (! $notrigger) {
194
+			if (!$notrigger) {
195 195
 				// Uncomment this and change MYOBJECT to your own tag if you
196 196
 				// want this action calls a trigger.
197 197
 
@@ -204,21 +204,21 @@  discard block
 block discarded – undo
204 204
 			}
205 205
 		}
206 206
 
207
-		if (! $error) {
207
+		if (!$error) {
208 208
 			$result = $this->setPriceOnAffiliateThirdparty($user, $forceupdateaffiliate);
209 209
 			if ($result < 0) {
210
-				$error ++;
210
+				$error++;
211 211
 			}
212 212
 		}
213 213
 
214 214
 		// Commit or rollback
215 215
 		if ($error) {
216
-			foreach ( $this->errors as $errmsg ) {
217
-				dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR);
218
-				$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
216
+			foreach ($this->errors as $errmsg) {
217
+				dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
218
+				$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
219 219
 			}
220 220
 			$this->db->rollback();
221
-			return - 1 * $error;
221
+			return -1 * $error;
222 222
 		} else {
223 223
 			$this->db->commit();
224 224
 			return $this->id;
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
 		$sql .= " t.fk_user,";
257 257
 		$sql .= " t.import_key";
258 258
 
259
-		$sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price as t";
260
-		$sql .= " WHERE t.rowid = " . $id;
259
+		$sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t";
260
+		$sql .= " WHERE t.rowid = ".$id;
261 261
 
262
-		dol_syslog(get_class($this) . "::fetch", LOG_DEBUG);
262
+		dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
263 263
 		$resql = $this->db->query($sql);
264 264
 		if ($resql) {
265 265
 			if ($this->db->num_rows($resql)) {
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 
290 290
 			return 1;
291 291
 		} else {
292
-			$this->error = "Error " . $this->db->lasterror();
293
-			return - 1;
292
+			$this->error = "Error ".$this->db->lasterror();
293
+			return -1;
294 294
 		}
295 295
 	}
296 296
 
@@ -308,8 +308,8 @@  discard block
 block discarded – undo
308 308
 	{
309 309
 		global $langs;
310 310
 
311
-		if ( empty($sortfield)) $sortfield = "t.rowid";
312
-		if ( empty($sortorder)) $sortorder = "DESC";
311
+		if (empty($sortfield)) $sortfield = "t.rowid";
312
+		if (empty($sortorder)) $sortorder = "DESC";
313 313
 
314 314
 		$sql = "SELECT";
315 315
 		$sql .= " t.rowid,";
@@ -333,39 +333,39 @@  discard block
 block discarded – undo
333 333
 		$sql .= " t.import_key,";
334 334
 		$sql .= " soc.nom as socname,";
335 335
 		$sql .= " prod.ref as prodref";
336
-		$sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price as t ";
337
-		$sql .= " ," . MAIN_DB_PREFIX . "product as prod ";
338
-		$sql .= " ," . MAIN_DB_PREFIX . "societe as soc ";
336
+		$sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t ";
337
+		$sql .= " ,".MAIN_DB_PREFIX."product as prod ";
338
+		$sql .= " ,".MAIN_DB_PREFIX."societe as soc ";
339 339
 		$sql .= " WHERE soc.rowid=t.fk_soc ";
340 340
 		$sql .= " AND prod.rowid=t.fk_product ";
341
-		$sql .= " AND prod.entity IN (" . getEntity('product') . ")";
341
+		$sql .= " AND prod.entity IN (".getEntity('product').")";
342 342
 
343 343
 		// Manage filter
344 344
 		if (count($filter) > 0) {
345
-			foreach ( $filter as $key => $value ) {
345
+			foreach ($filter as $key => $value) {
346 346
 				if (strpos($key, 'date')) 				// To allow $filter['YEAR(s.dated)']=>$year
347 347
 				{
348
-					$sql .= ' AND ' . $key . ' = \'' . $value . '\'';
348
+					$sql .= ' AND '.$key.' = \''.$value.'\'';
349 349
 				} elseif ($key == 'soc.nom') {
350
-					$sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\'';
350
+					$sql .= ' AND '.$key.' LIKE \'%'.$value.'%\'';
351 351
 				} elseif ($key == 'prod.ref') {
352
-					$sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\'';
352
+					$sql .= ' AND '.$key.' LIKE \'%'.$value.'%\'';
353 353
 				} else {
354
-					$sql .= ' AND ' . $key . ' = ' . $value;
354
+					$sql .= ' AND '.$key.' = '.$value;
355 355
 				}
356 356
 			}
357 357
 		}
358
-		$sql.= $this->db->order($sortfield, $sortorder);
359
-		if (! empty($limit)) $sql .= ' ' . $this->db->plimit($limit + 1, $offset);
358
+		$sql .= $this->db->order($sortfield, $sortorder);
359
+		if (!empty($limit)) $sql .= ' '.$this->db->plimit($limit + 1, $offset);
360 360
 
361
-		dol_syslog(get_class($this) . "::fetch_all", LOG_DEBUG);
361
+		dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG);
362 362
 		$resql = $this->db->query($sql);
363 363
 		if ($resql) {
364 364
 
365
-			$this->lines = array ();
365
+			$this->lines = array();
366 366
 			$num = $this->db->num_rows($resql);
367 367
 
368
-			while ( $obj = $this->db->fetch_object($resql) ) {
368
+			while ($obj = $this->db->fetch_object($resql)) {
369 369
 
370 370
 				$line = new PriceByCustomerLine();
371 371
 
@@ -397,8 +397,8 @@  discard block
 block discarded – undo
397 397
 
398 398
 			return $num;
399 399
 		} else {
400
-			$this->error = "Error " . $this->db->lasterror();
401
-			return - 1;
400
+			$this->error = "Error ".$this->db->lasterror();
401
+			return -1;
402 402
 		}
403 403
 	}
404 404
 
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
 	{
417 417
 		global $langs;
418 418
 
419
-		if (! empty($sortfield)) $sortfield = "t.rowid";
420
-		if (! empty($sortorder)) $sortorder = "DESC";
419
+		if (!empty($sortfield)) $sortfield = "t.rowid";
420
+		if (!empty($sortorder)) $sortorder = "DESC";
421 421
 
422 422
 		$sql = "SELECT";
423 423
 		$sql .= " t.rowid,";
@@ -440,38 +440,38 @@  discard block
 block discarded – undo
440 440
 		$sql .= " t.import_key,";
441 441
 		$sql .= " soc.nom as socname,";
442 442
 		$sql .= " prod.ref as prodref";
443
-		$sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price_log as t ";
444
-		$sql .= " ," . MAIN_DB_PREFIX . "product as prod ";
445
-		$sql .= " ," . MAIN_DB_PREFIX . "societe as soc ";
443
+		$sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price_log as t ";
444
+		$sql .= " ,".MAIN_DB_PREFIX."product as prod ";
445
+		$sql .= " ,".MAIN_DB_PREFIX."societe as soc ";
446 446
 		$sql .= " WHERE soc.rowid=t.fk_soc ";
447 447
 		$sql .= " AND prod.rowid=t.fk_product ";
448
-		$sql .= " AND prod.entity IN (" . getEntity('product') . ")";
448
+		$sql .= " AND prod.entity IN (".getEntity('product').")";
449 449
 
450 450
 		// Manage filter
451 451
 		if (count($filter) > 0) {
452
-			foreach ( $filter as $key => $value ) {
452
+			foreach ($filter as $key => $value) {
453 453
 				if (strpos($key, 'date')) 				// To allow $filter['YEAR(s.dated)']=>$year
454 454
 				{
455
-					$sql .= ' AND ' . $key . ' = \'' . $value . '\'';
455
+					$sql .= ' AND '.$key.' = \''.$value.'\'';
456 456
 				} elseif ($key == 'soc.nom') {
457
-					$sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\'';
457
+					$sql .= ' AND '.$key.' LIKE \'%'.$value.'%\'';
458 458
 				} else {
459
-					$sql .= ' AND ' . $key . ' = ' . $value;
459
+					$sql .= ' AND '.$key.' = '.$value;
460 460
 				}
461 461
 			}
462 462
 		}
463 463
 
464
-		$sql.= $this->db->order($sortfield, $sortorder);
465
-		if (! empty($limit)) $sql .= ' ' . $this->db->plimit($limit + 1, $offset);
464
+		$sql .= $this->db->order($sortfield, $sortorder);
465
+		if (!empty($limit)) $sql .= ' '.$this->db->plimit($limit + 1, $offset);
466 466
 
467
-		dol_syslog(get_class($this) . "::fetch_all_log", LOG_DEBUG);
467
+		dol_syslog(get_class($this)."::fetch_all_log", LOG_DEBUG);
468 468
 		$resql = $this->db->query($sql);
469 469
 		if ($resql) {
470 470
 
471
-			$this->lines = array ();
471
+			$this->lines = array();
472 472
 			$num = $this->db->num_rows($resql);
473 473
 
474
-			while ( $obj = $this->db->fetch_object($resql) ) {
474
+			while ($obj = $this->db->fetch_object($resql)) {
475 475
 
476 476
 				$line = new PriceByCustomerLine();
477 477
 
@@ -503,8 +503,8 @@  discard block
 block discarded – undo
503 503
 
504 504
 			return $num;
505 505
 		} else {
506
-			$this->error = "Error " . $this->db->lasterror();
507
-			return - 1;
506
+			$this->error = "Error ".$this->db->lasterror();
507
+			return -1;
508 508
 		}
509 509
 	}
510 510
 
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 
589 589
 		// Do a copy of current record into log table
590 590
 		// Insert request
591
-		$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_customer_price_log(";
591
+		$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_customer_price_log(";
592 592
 
593 593
 		$sql .= "entity,";
594 594
 		$sql .= "datec,";
@@ -631,75 +631,75 @@  discard block
 block discarded – undo
631 631
 		$sql .= " t.fk_user,";
632 632
 		$sql .= " t.import_key";
633 633
 
634
-		$sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price as t";
635
-		$sql .= " WHERE t.rowid = " . $this->id;
634
+		$sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t";
635
+		$sql .= " WHERE t.rowid = ".$this->id;
636 636
 
637 637
 		$this->db->begin();
638
-		dol_syslog(get_class($this) . "::update", LOG_DEBUG);
638
+		dol_syslog(get_class($this)."::update", LOG_DEBUG);
639 639
 		$resql = $this->db->query($sql);
640
-		if (! $resql) {
641
-			$error ++;
642
-			$this->errors [] = "Error " . $this->db->lasterror();
640
+		if (!$resql) {
641
+			$error++;
642
+			$this->errors [] = "Error ".$this->db->lasterror();
643 643
 		}
644 644
 
645 645
 		// Update request
646
-		$sql = "UPDATE " . MAIN_DB_PREFIX . "product_customer_price SET";
647
-
648
-		$sql .= " entity=" . $conf->entity . ",";
649
-		$sql .= " datec='" . $this->db->idate(dol_now()) . "',";
650
-		$sql .= " tms=" . (dol_strlen($this->tms) != 0 ? "'" . $this->db->idate($this->tms) . "'" : 'null') . ",";
651
-		$sql .= " fk_product=" . (isset($this->fk_product) ? $this->fk_product : "null") . ",";
652
-		$sql .= " fk_soc=" . (isset($this->fk_soc) ? $this->fk_soc : "null") . ",";
653
-		$sql .= " price=" . (isset($this->price) ? $this->price : "null") . ",";
654
-		$sql .= " price_ttc=" . (isset($this->price_ttc) ? $this->price_ttc : "null") . ",";
655
-		$sql .= " price_min=" . (isset($this->price_min) ? $this->price_min : "null") . ",";
656
-		$sql .= " price_min_ttc=" . (isset($this->price_min_ttc) ? $this->price_min_ttc : "null") . ",";
657
-		$sql .= " price_base_type=" . (isset($this->price_base_type) ? "'" . $this->db->escape($this->price_base_type) . "'" : "null") . ",";
646
+		$sql = "UPDATE ".MAIN_DB_PREFIX."product_customer_price SET";
647
+
648
+		$sql .= " entity=".$conf->entity.",";
649
+		$sql .= " datec='".$this->db->idate(dol_now())."',";
650
+		$sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
651
+		$sql .= " fk_product=".(isset($this->fk_product) ? $this->fk_product : "null").",";
652
+		$sql .= " fk_soc=".(isset($this->fk_soc) ? $this->fk_soc : "null").",";
653
+		$sql .= " price=".(isset($this->price) ? $this->price : "null").",";
654
+		$sql .= " price_ttc=".(isset($this->price_ttc) ? $this->price_ttc : "null").",";
655
+		$sql .= " price_min=".(isset($this->price_min) ? $this->price_min : "null").",";
656
+		$sql .= " price_min_ttc=".(isset($this->price_min_ttc) ? $this->price_min_ttc : "null").",";
657
+		$sql .= " price_base_type=".(isset($this->price_base_type) ? "'".$this->db->escape($this->price_base_type)."'" : "null").",";
658 658
 		$sql .= " default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null").",";
659
-		$sql .= " tva_tx=" . (isset($this->tva_tx) ? (empty($this->tva_tx)?0:$this->tva_tx) : "null") . ",";
660
-		$sql .= " recuperableonly=" . (isset($this->recuperableonly) ? $this->recuperableonly : "null") . ",";
661
-		$sql .= " localtax1_tx=" . (isset($this->localtax1_tx) ? (empty($this->localtax1_tx)?0:$this->localtax1_tx) : "null") . ",";
662
-		$sql .= " localtax2_tx=" . (isset($this->localtax2_tx) ? (empty($this->localtax2_tx)?0:$this->localtax2_tx) : "null") . ",";
663
-		$sql .= " localtax1_type=" . (! empty($this->localtax1_type) ? "'".$this->db->escape($this->localtax1_type)."'": "'0'") . ",";
664
-		$sql .= " localtax2_type=" . (! empty($this->localtax2_type) ? "'".$this->db->escape($this->localtax2_type)."'": "'0'") . ",";
665
-		$sql .= " fk_user=" . $user->id . ",";
666
-		$sql .= " import_key=" . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . "";
667
-
668
-		$sql .= " WHERE rowid=" . $this->id;
669
-
670
-		dol_syslog(get_class($this) . "::update", LOG_DEBUG);
659
+		$sql .= " tva_tx=".(isset($this->tva_tx) ? (empty($this->tva_tx) ? 0 : $this->tva_tx) : "null").",";
660
+		$sql .= " recuperableonly=".(isset($this->recuperableonly) ? $this->recuperableonly : "null").",";
661
+		$sql .= " localtax1_tx=".(isset($this->localtax1_tx) ? (empty($this->localtax1_tx) ? 0 : $this->localtax1_tx) : "null").",";
662
+		$sql .= " localtax2_tx=".(isset($this->localtax2_tx) ? (empty($this->localtax2_tx) ? 0 : $this->localtax2_tx) : "null").",";
663
+		$sql .= " localtax1_type=".(!empty($this->localtax1_type) ? "'".$this->db->escape($this->localtax1_type)."'" : "'0'").",";
664
+		$sql .= " localtax2_type=".(!empty($this->localtax2_type) ? "'".$this->db->escape($this->localtax2_type)."'" : "'0'").",";
665
+		$sql .= " fk_user=".$user->id.",";
666
+		$sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null")."";
667
+
668
+		$sql .= " WHERE rowid=".$this->id;
669
+
670
+		dol_syslog(get_class($this)."::update", LOG_DEBUG);
671 671
 		$resql = $this->db->query($sql);
672
-		if (! $resql) {
673
-			$error ++;
674
-			$this->errors [] = "Error " . $this->db->lasterror();
672
+		if (!$resql) {
673
+			$error++;
674
+			$this->errors [] = "Error ".$this->db->lasterror();
675 675
 		}
676 676
 
677
-		if (! $error) {
678
-			if (! $notrigger) {
677
+		if (!$error) {
678
+			if (!$notrigger) {
679 679
 				// Call triggers
680
-				include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
681
-				$interface=new Interfaces($this->db);
682
-				$result=$interface->run_triggers('PRODUCT_CUSTOMER_PRICE_UPDATE',$this,$user,$langs,$conf);
683
-				if ($result < 0) { $error++; $this->errors=$interface->errors; }
680
+				include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
681
+				$interface = new Interfaces($this->db);
682
+				$result = $interface->run_triggers('PRODUCT_CUSTOMER_PRICE_UPDATE', $this, $user, $langs, $conf);
683
+				if ($result < 0) { $error++; $this->errors = $interface->errors; }
684 684
 				// End call triggers
685 685
 			}
686 686
 		}
687 687
 
688
-		if (! $error) {
688
+		if (!$error) {
689 689
 			$result = $this->setPriceOnAffiliateThirdparty($user, $forceupdateaffiliate);
690 690
 			if ($result < 0) {
691
-				$error ++;
691
+				$error++;
692 692
 			}
693 693
 		}
694 694
 
695 695
 		// Commit or rollback
696 696
 		if ($error) {
697
-			foreach ( $this->errors as $errmsg ) {
698
-				dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR);
699
-				$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
697
+			foreach ($this->errors as $errmsg) {
698
+				dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
699
+				$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
700 700
 			}
701 701
 			$this->db->rollback();
702
-			return - 1 * $error;
702
+			return -1 * $error;
703 703
 		} else {
704 704
 			$this->db->commit();
705 705
 			return 1;
@@ -719,37 +719,37 @@  discard block
 block discarded – undo
719 719
 
720 720
 		// Find all susidiaries
721 721
 		$sql = "SELECT s.rowid";
722
-		$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
723
-		$sql .= " WHERE s.parent = " . $this->fk_soc;
724
-		$sql .= " AND s.entity IN (" . getEntity('societe') . ")";
722
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
723
+		$sql .= " WHERE s.parent = ".$this->fk_soc;
724
+		$sql .= " AND s.entity IN (".getEntity('societe').")";
725 725
 
726
-		dol_syslog(get_class($this) . "::setPriceOnAffiliateThirdparty", LOG_DEBUG);
726
+		dol_syslog(get_class($this)."::setPriceOnAffiliateThirdparty", LOG_DEBUG);
727 727
 		$resql = $this->db->query($sql);
728 728
 
729 729
 		if ($resql) {
730 730
 
731
-			$this->lines = array ();
731
+			$this->lines = array();
732 732
 			$num = $this->db->num_rows($resql);
733 733
 
734
-			while ( ($obj = $this->db->fetch_object($resql)) && (empty($error)) ) {
734
+			while (($obj = $this->db->fetch_object($resql)) && (empty($error))) {
735 735
 
736 736
 				// find if there is an existing line for the product and the subsidiaries
737 737
 				$prodsocprice = new Productcustomerprice($this->db);
738 738
 
739
-				$filter = array (
740
-					't.fk_product' => $this->fk_product,'t.fk_soc' => $obj->rowid
739
+				$filter = array(
740
+					't.fk_product' => $this->fk_product, 't.fk_soc' => $obj->rowid
741 741
 				);
742 742
 
743 743
 				$result = $prodsocprice->fetch_all('', '', 0, 0, $filter);
744 744
 				if ($result < 0) {
745
-					$error ++;
745
+					$error++;
746 746
 					$this->error = $prodsocprice->error;
747 747
 				} else {
748 748
 
749 749
 					// There is one line
750 750
 					if (count($prodsocprice->lines) > 0) {
751 751
 						// If force update => Update
752
-						if (! empty($forceupdateaffiliate)) {
752
+						if (!empty($forceupdateaffiliate)) {
753 753
 
754 754
 							$prodsocpriceupd = new Productcustomerprice($this->db);
755 755
 							$prodsocpriceupd->fetch($prodsocprice->lines [0]->id);
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 
763 763
 							$resultupd = $prodsocpriceupd->update($user, 0, $forceupdateaffiliate);
764 764
 							if ($result < 0) {
765
-								$error ++;
765
+								$error++;
766 766
 								$this->error = $prodsocpriceupd->error;
767 767
 							}
768 768
 						}
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
 
780 780
 						$resultupd = $prodsocpricenew->create($user, 0, $forceupdateaffiliate);
781 781
 						if ($result < 0) {
782
-							$error ++;
782
+							$error++;
783 783
 							$this->error = $prodsocpriceupd->error;
784 784
 						}
785 785
 					}
@@ -790,11 +790,11 @@  discard block
 block discarded – undo
790 790
 			if (empty($error)) {
791 791
 				return 1;
792 792
 			} else {
793
-				return - 1;
793
+				return -1;
794 794
 			}
795 795
 		} else {
796
-			$this->error = "Error " . $this->db->lasterror();
797
-			return - 1;
796
+			$this->error = "Error ".$this->db->lasterror();
797
+			return -1;
798 798
 		}
799 799
 	}
800 800
 
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
 
813 813
 		$this->db->begin();
814 814
 
815
-		if (! $error) {
816
-			if (! $notrigger) {
815
+		if (!$error) {
816
+			if (!$notrigger) {
817 817
 				// Uncomment this and change MYOBJECT to your own tag if you
818 818
 				// want this action calls a trigger.
819 819
 
@@ -826,26 +826,26 @@  discard block
 block discarded – undo
826 826
 			}
827 827
 		}
828 828
 
829
-		if (! $error) {
830
-			$sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_customer_price";
831
-			$sql .= " WHERE rowid=" . $this->id;
829
+		if (!$error) {
830
+			$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_customer_price";
831
+			$sql .= " WHERE rowid=".$this->id;
832 832
 
833
-			dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
833
+			dol_syslog(get_class($this)."::delete", LOG_DEBUG);
834 834
 			$resql = $this->db->query($sql);
835
-			if (! $resql) {
836
-				$error ++;
837
-				$this->errors [] = "Error " . $this->db->lasterror();
835
+			if (!$resql) {
836
+				$error++;
837
+				$this->errors [] = "Error ".$this->db->lasterror();
838 838
 			}
839 839
 		}
840 840
 
841 841
 		// Commit or rollback
842 842
 		if ($error) {
843
-			foreach ( $this->errors as $errmsg ) {
844
-				dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
845
-				$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
843
+			foreach ($this->errors as $errmsg) {
844
+				dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
845
+				$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
846 846
 			}
847 847
 			$this->db->rollback();
848
-			return - 1 * $error;
848
+			return -1 * $error;
849 849
 		} else {
850 850
 			$this->db->commit();
851 851
 			return 1;
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 
867 867
 		$object = new Productcustomerprice($this->db);
868 868
 
869
-		$object->context['createfromclone']='createfromclone';
869
+		$object->context['createfromclone'] = 'createfromclone';
870 870
 
871 871
 		$this->db->begin();
872 872
 
@@ -884,21 +884,21 @@  discard block
 block discarded – undo
884 884
 		// Other options
885 885
 		if ($result < 0) {
886 886
 			$this->error = $object->error;
887
-			$error ++;
887
+			$error++;
888 888
 		}
889 889
 
890
-		if (! $error) {
890
+		if (!$error) {
891 891
 		}
892 892
 
893 893
 		unset($object->context['createfromclone']);
894 894
 
895 895
 		// End
896
-		if (! $error) {
896
+		if (!$error) {
897 897
 			$this->db->commit();
898 898
 			return $object->id;
899 899
 		} else {
900 900
 			$this->db->rollback();
901
-			return - 1;
901
+			return -1;
902 902
 		}
903 903
 	}
904 904
 
Please login to merge, or discard this patch.
htdocs/product/class/propalmergepdfproduct.class.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -297,7 +297,7 @@
 block discarded – undo
297 297
     /**
298 298
      *  Update object into database
299 299
      *
300
-     *  @param	User	$user        User that modifies
300
+     *  @param	integer	$user        User that modifies
301 301
      *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
302 302
      *  @return int     		   	 <0 if KO, >0 if OK
303 303
      */
Please login to merge, or discard this patch.
Braces   +39 added lines, -27 removed lines patch added patch discarded remove patch
@@ -73,12 +73,24 @@  discard block
 block discarded – undo
73 73
 
74 74
 		// Clean parameters
75 75
         
76
-		if (isset($this->fk_product)) $this->fk_product=trim($this->fk_product);
77
-		if (isset($this->file_name)) $this->file_name=trim($this->file_name);
78
-		if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author);
79
-		if (isset($this->fk_user_mod)) $this->fk_user_mod=trim($this->fk_user_mod);
80
-		if (isset($this->lang)) $this->lang=trim($this->lang);
81
-		if (isset($this->import_key)) $this->import_key=trim($this->import_key);
76
+		if (isset($this->fk_product)) {
77
+			$this->fk_product=trim($this->fk_product);
78
+		}
79
+		if (isset($this->file_name)) {
80
+			$this->file_name=trim($this->file_name);
81
+		}
82
+		if (isset($this->fk_user_author)) {
83
+			$this->fk_user_author=trim($this->fk_user_author);
84
+		}
85
+		if (isset($this->fk_user_mod)) {
86
+			$this->fk_user_mod=trim($this->fk_user_mod);
87
+		}
88
+		if (isset($this->lang)) {
89
+			$this->lang=trim($this->lang);
90
+		}
91
+		if (isset($this->import_key)) {
92
+			$this->import_key=trim($this->import_key);
93
+		}
82 94
 
83 95
         
84 96
 
@@ -146,8 +158,7 @@  discard block
 block discarded – undo
146 158
 			}
147 159
 			$this->db->rollback();
148 160
 			return -1*$error;
149
-		}
150
-		else
161
+		} else
151 162
 		{
152 163
 			$this->db->commit();
153 164
             return $this->id;
@@ -207,8 +218,7 @@  discard block
 block discarded – undo
207 218
             $this->db->free($resql);
208 219
 
209 220
             return 1;
210
-        }
211
-        else
221
+        } else
212 222
         {
213 223
       	    $this->error="Error ".$this->db->lasterror();
214 224
             dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
@@ -272,7 +282,7 @@  discard block
 block discarded – undo
272 282
 	    			
273 283
 	    			if ($conf->global->MAIN_MULTILANGS) {
274 284
 	    				$this->lines[$obj->file_name.'_'.$obj->lang]=$line;
275
-	    			}else {
285
+	    			} else {
276 286
 	    				$this->lines[$obj->file_name]=$line;
277 287
 	    			}
278 288
 	    			
@@ -284,8 +294,7 @@  discard block
 block discarded – undo
284 294
     		$this->db->free($resql);
285 295
     
286 296
     		return 1;
287
-    	}
288
-    	else
297
+    	} else
289 298
     	{
290 299
     		$this->error="Error ".$this->db->lasterror();
291 300
     		dol_syslog(get_class($this)."::fetch_by_product ".$this->error, LOG_ERR);
@@ -308,10 +317,18 @@  discard block
 block discarded – undo
308 317
 
309 318
 		// Clean parameters
310 319
         
311
-		if (isset($this->fk_product)) $this->fk_product=trim($this->fk_product);
312
-		if (isset($this->file_name)) $this->file_name=trim($this->file_name);
313
-		if (isset($this->fk_user_mod)) $this->fk_user_mod=trim($this->fk_user_mod);
314
-		if (isset($this->lang)) $this->lang=trim($this->lang);
320
+		if (isset($this->fk_product)) {
321
+			$this->fk_product=trim($this->fk_product);
322
+		}
323
+		if (isset($this->file_name)) {
324
+			$this->file_name=trim($this->file_name);
325
+		}
326
+		if (isset($this->fk_user_mod)) {
327
+			$this->fk_user_mod=trim($this->fk_user_mod);
328
+		}
329
+		if (isset($this->lang)) {
330
+			$this->lang=trim($this->lang);
331
+		}
315 332
 		
316 333
 
317 334
         
@@ -364,8 +381,7 @@  discard block
 block discarded – undo
364 381
 			}
365 382
 			$this->db->rollback();
366 383
 			return -1*$error;
367
-		}
368
-		else
384
+		} else
369 385
 		{
370 386
 			$this->db->commit();
371 387
 			return 1;
@@ -423,8 +439,7 @@  discard block
 block discarded – undo
423 439
 			}
424 440
 			$this->db->rollback();
425 441
 			return -1*$error;
426
-		}
427
-		else
442
+		} else
428 443
 		{
429 444
 			$this->db->commit();
430 445
 			return 1;
@@ -487,8 +502,7 @@  discard block
 block discarded – undo
487 502
 			}
488 503
 			$this->db->rollback();
489 504
 			return -1*$error;
490
-		}
491
-		else
505
+		} else
492 506
 		{
493 507
 			$this->db->commit();
494 508
 			return 1;
@@ -544,8 +558,7 @@  discard block
 block discarded – undo
544 558
 			}
545 559
 			$this->db->rollback();
546 560
 			return -1*$error;
547
-		}
548
-		else
561
+		} else
549 562
 		{
550 563
 			$this->db->commit();
551 564
 			return 1;
@@ -599,8 +612,7 @@  discard block
 block discarded – undo
599 612
 		{
600 613
 			$this->db->commit();
601 614
 			return $object->id;
602
-		}
603
-		else
615
+		} else
604 616
 		{
605 617
 			$this->db->rollback();
606 618
 			return -1;
Please login to merge, or discard this patch.
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -47,28 +47,28 @@  discard block
 block discarded – undo
47 47
 
48 48
 
49 49
 
50
-    /**
51
-     *  Constructor
52
-     *
53
-     *  @param	DoliDb		$db      Database handler
54
-     */
55
-    function __construct($db)
56
-    {
57
-        $this->db = $db;
58
-        return 1;
59
-    }
60
-
61
-
62
-    /**
63
-     *  Create object into database
64
-     *
65
-     *  @param	User	$user        User that creates
66
-     *  @param  int		$notrigger   0=launch triggers after, 1=disable triggers
67
-     *  @return int      		   	 <0 if KO, Id of created object if OK
68
-     */
69
-    function create($user, $notrigger=0)
70
-    {
71
-    	global $conf, $langs;
50
+	/**
51
+	 *  Constructor
52
+	 *
53
+	 *  @param	DoliDb		$db      Database handler
54
+	 */
55
+	function __construct($db)
56
+	{
57
+		$this->db = $db;
58
+		return 1;
59
+	}
60
+
61
+
62
+	/**
63
+	 *  Create object into database
64
+	 *
65
+	 *  @param	User	$user        User that creates
66
+	 *  @param  int		$notrigger   0=launch triggers after, 1=disable triggers
67
+	 *  @return int      		   	 <0 if KO, Id of created object if OK
68
+	 */
69
+	function create($user, $notrigger=0)
70
+	{
71
+		global $conf, $langs;
72 72
 		$error=0;
73 73
 
74 74
 		// Clean parameters
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 		// Check parameters
86 86
 		// Put here code to add control on parameters values
87 87
 
88
-        // Insert request
88
+		// Insert request
89 89
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."propal_merge_pdf_product(";
90 90
 
91 91
 		$sql.= "fk_product,";
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 		$sql.= "datec";
99 99
 
100 100
 
101
-        $sql.= ") VALUES (";
101
+		$sql.= ") VALUES (";
102 102
 
103 103
 		$sql.= " ".(! isset($this->fk_product)?'NULL':"'".$this->db->escape($this->fk_product)."'").",";
104 104
 		$sql.= " ".(! isset($this->file_name)?'NULL':"'".$this->db->escape($this->file_name)."'").",";
@@ -115,34 +115,34 @@  discard block
 block discarded – undo
115 115
 		$this->db->begin();
116 116
 
117 117
 	   	dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
118
-        $resql=$this->db->query($sql);
119
-    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
118
+		$resql=$this->db->query($sql);
119
+		if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
120 120
 
121 121
 		if (! $error)
122
-        {
123
-            $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal_merge_pdf_product");
122
+		{
123
+			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal_merge_pdf_product");
124 124
 
125 125
 			if (! $notrigger)
126 126
 			{
127
-	            // Uncomment this and change MYOBJECT to your own tag if you
128
-	            // want this action calls a trigger.
129
-
130
-	            //// Call triggers
131
-	            //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
132
-	            //$interface=new Interfaces($this->db);
133
-	            //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
134
-	            //if ($result < 0) { $error++; $this->errors=$interface->errors; }
135
-	            //// End call triggers
127
+				// Uncomment this and change MYOBJECT to your own tag if you
128
+				// want this action calls a trigger.
129
+
130
+				//// Call triggers
131
+				//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
132
+				//$interface=new Interfaces($this->db);
133
+				//$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
134
+				//if ($result < 0) { $error++; $this->errors=$interface->errors; }
135
+				//// End call triggers
136 136
 			}
137
-        }
137
+		}
138 138
 
139
-        // Commit or rollback
140
-        if ($error)
139
+		// Commit or rollback
140
+		if ($error)
141 141
 		{
142 142
 			foreach($this->errors as $errmsg)
143 143
 			{
144
-	            dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
145
-	            $this->error.=($this->error?', '.$errmsg:$errmsg);
144
+				dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
145
+				$this->error.=($this->error?', '.$errmsg:$errmsg);
146 146
 			}
147 147
 			$this->db->rollback();
148 148
 			return -1*$error;
@@ -150,22 +150,22 @@  discard block
 block discarded – undo
150 150
 		else
151 151
 		{
152 152
 			$this->db->commit();
153
-            return $this->id;
153
+			return $this->id;
154 154
 		}
155
-    }
155
+	}
156 156
 
157 157
 
158
-    /**
159
-     *  Load object in memory from the database
160
-     *
161
-     *  @param	int		$id    Id object
162
-     *  @return int          	<0 if KO, >0 if OK
163
-     */
164
-    function fetch($id)
165
-    {
166
-    	global $langs,$conf;
158
+	/**
159
+	 *  Load object in memory from the database
160
+	 *
161
+	 *  @param	int		$id    Id object
162
+	 *  @return int          	<0 if KO, >0 if OK
163
+	 */
164
+	function fetch($id)
165
+	{
166
+		global $langs,$conf;
167 167
 
168
-        $sql = "SELECT";
168
+		$sql = "SELECT";
169 169
 		$sql.= " t.rowid,";
170 170
 
171 171
 		$sql.= " t.fk_product,";
@@ -178,18 +178,18 @@  discard block
 block discarded – undo
178 178
 		$sql.= " t.import_key";
179 179
 
180 180
 
181
-        $sql.= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t";
182
-        $sql.= " WHERE t.rowid = ".$id;
181
+		$sql.= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t";
182
+		$sql.= " WHERE t.rowid = ".$id;
183 183
 
184
-    	dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
185
-        $resql=$this->db->query($sql);
186
-        if ($resql)
187
-        {
188
-            if ($this->db->num_rows($resql))
189
-            {
190
-                $obj = $this->db->fetch_object($resql);
184
+		dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
185
+		$resql=$this->db->query($sql);
186
+		if ($resql)
187
+		{
188
+			if ($this->db->num_rows($resql))
189
+			{
190
+				$obj = $this->db->fetch_object($resql);
191 191
 
192
-                $this->id    = $obj->rowid;
192
+				$this->id    = $obj->rowid;
193 193
 
194 194
 				$this->fk_product = $obj->fk_product;
195 195
 				$this->file_name = $obj->file_name;
@@ -203,107 +203,107 @@  discard block
 block discarded – undo
203 203
 				$this->import_key = $obj->import_key;
204 204
 
205 205
 
206
-            }
207
-            $this->db->free($resql);
208
-
209
-            return 1;
210
-        }
211
-        else
212
-        {
213
-      	    $this->error="Error ".$this->db->lasterror();
214
-            dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
215
-            return -1;
216
-        }
217
-    }
218
-
219
-    /**
220
-     *  Load object in memory from the database
221
-     *
222
-     *  @param	int		$product_id    	Id object
223
-     *  @param	string	$lang  			Lang string code
224
-     *  @return int          	<0 if KO, >0 if OK
225
-     */
226
-    function fetch_by_product($product_id, $lang='')
227
-    {
228
-    	global $langs,$conf;
229
-
230
-    	$sql = "SELECT";
231
-    	$sql.= " t.rowid,";
232
-
233
-    	$sql.= " t.fk_product,";
234
-    	$sql.= " t.file_name,";
235
-    	$sql.= " t.lang,";
236
-    	$sql.= " t.fk_user_author,";
237
-    	$sql.= " t.fk_user_mod,";
238
-    	$sql.= " t.datec,";
239
-    	$sql.= " t.tms,";
240
-    	$sql.= " t.import_key";
241
-
242
-
243
-    	$sql.= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t";
244
-    	$sql.= " WHERE t.fk_product = ".$product_id;
245
-    	if ($conf->global->MAIN_MULTILANGS && !empty($lang)) {
246
-    		$sql.= " AND t.lang = '".$lang."'";
247
-    	}
248
-
249
-    	dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
250
-    	$resql=$this->db->query($sql);
251
-    	if ($resql)
252
-    	{
253
-    		if ($this->db->num_rows($resql))
254
-    		{
255
-    			while($obj = $this->db->fetch_object($resql)) {
256
-
257
-    				$line = new PropalmergepdfproductLine();
258
-
259
-	    			$line->id    = $obj->rowid;
260
-
261
-	    			$line->fk_product = $obj->fk_product;
262
-	    			$line->file_name = $obj->file_name;
263
-	    			if ($conf->global->MAIN_MULTILANGS) {
264
-	    				$line->lang = $obj->lang;
265
-	    			}
266
-	    			$line->fk_user_author = $obj->fk_user_author;
267
-	    			$line->fk_user_mod = $obj->fk_user_mod;
268
-	    			$line->datec = $this->db->jdate($obj->datec);
269
-	    			$line->tms = $this->db->jdate($obj->tms);
270
-	    			$line->import_key = $obj->import_key;
271
-
272
-
273
-	    			if ($conf->global->MAIN_MULTILANGS) {
274
-	    				$this->lines[$obj->file_name.'_'.$obj->lang]=$line;
275
-	    			}else {
276
-	    				$this->lines[$obj->file_name]=$line;
277
-	    			}
278
-
279
-
280
-    			}
281
-
282
-
283
-    		}
284
-    		$this->db->free($resql);
285
-
286
-    		return 1;
287
-    	}
288
-    	else
289
-    	{
290
-    		$this->error="Error ".$this->db->lasterror();
291
-    		dol_syslog(get_class($this)."::fetch_by_product ".$this->error, LOG_ERR);
292
-    		return -1;
293
-    	}
294
-    }
295
-
296
-
297
-    /**
298
-     *  Update object into database
299
-     *
300
-     *  @param	User	$user        User that modifies
301
-     *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
302
-     *  @return int     		   	 <0 if KO, >0 if OK
303
-     */
304
-    function update($user=0, $notrigger=0)
305
-    {
306
-    	global $conf, $langs;
206
+			}
207
+			$this->db->free($resql);
208
+
209
+			return 1;
210
+		}
211
+		else
212
+		{
213
+	  		$this->error="Error ".$this->db->lasterror();
214
+			dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
215
+			return -1;
216
+		}
217
+	}
218
+
219
+	/**
220
+	 *  Load object in memory from the database
221
+	 *
222
+	 *  @param	int		$product_id    	Id object
223
+	 *  @param	string	$lang  			Lang string code
224
+	 *  @return int          	<0 if KO, >0 if OK
225
+	 */
226
+	function fetch_by_product($product_id, $lang='')
227
+	{
228
+		global $langs,$conf;
229
+
230
+		$sql = "SELECT";
231
+		$sql.= " t.rowid,";
232
+
233
+		$sql.= " t.fk_product,";
234
+		$sql.= " t.file_name,";
235
+		$sql.= " t.lang,";
236
+		$sql.= " t.fk_user_author,";
237
+		$sql.= " t.fk_user_mod,";
238
+		$sql.= " t.datec,";
239
+		$sql.= " t.tms,";
240
+		$sql.= " t.import_key";
241
+
242
+
243
+		$sql.= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t";
244
+		$sql.= " WHERE t.fk_product = ".$product_id;
245
+		if ($conf->global->MAIN_MULTILANGS && !empty($lang)) {
246
+			$sql.= " AND t.lang = '".$lang."'";
247
+		}
248
+
249
+		dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
250
+		$resql=$this->db->query($sql);
251
+		if ($resql)
252
+		{
253
+			if ($this->db->num_rows($resql))
254
+			{
255
+				while($obj = $this->db->fetch_object($resql)) {
256
+
257
+					$line = new PropalmergepdfproductLine();
258
+
259
+					$line->id    = $obj->rowid;
260
+
261
+					$line->fk_product = $obj->fk_product;
262
+					$line->file_name = $obj->file_name;
263
+					if ($conf->global->MAIN_MULTILANGS) {
264
+						$line->lang = $obj->lang;
265
+					}
266
+					$line->fk_user_author = $obj->fk_user_author;
267
+					$line->fk_user_mod = $obj->fk_user_mod;
268
+					$line->datec = $this->db->jdate($obj->datec);
269
+					$line->tms = $this->db->jdate($obj->tms);
270
+					$line->import_key = $obj->import_key;
271
+
272
+
273
+					if ($conf->global->MAIN_MULTILANGS) {
274
+						$this->lines[$obj->file_name.'_'.$obj->lang]=$line;
275
+					}else {
276
+						$this->lines[$obj->file_name]=$line;
277
+					}
278
+
279
+
280
+				}
281
+
282
+
283
+			}
284
+			$this->db->free($resql);
285
+
286
+			return 1;
287
+		}
288
+		else
289
+		{
290
+			$this->error="Error ".$this->db->lasterror();
291
+			dol_syslog(get_class($this)."::fetch_by_product ".$this->error, LOG_ERR);
292
+			return -1;
293
+		}
294
+	}
295
+
296
+
297
+	/**
298
+	 *  Update object into database
299
+	 *
300
+	 *  @param	User	$user        User that modifies
301
+	 *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
302
+	 *  @return int     		   	 <0 if KO, >0 if OK
303
+	 */
304
+	function update($user=0, $notrigger=0)
305
+	{
306
+		global $conf, $langs;
307 307
 		$error=0;
308 308
 
309 309
 		// Clean parameters
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
 		// Check parameters
320 320
 		// Put here code to add a control on parameters values
321 321
 
322
-        // Update request
323
-        $sql = "UPDATE ".MAIN_DB_PREFIX."propal_merge_pdf_product SET";
322
+		// Update request
323
+		$sql = "UPDATE ".MAIN_DB_PREFIX."propal_merge_pdf_product SET";
324 324
 
325 325
 		$sql.= " fk_product=".(isset($this->fk_product)?$this->fk_product:"null").",";
326 326
 		$sql.= " file_name=".(isset($this->file_name)?"'".$this->db->escape($this->file_name)."'":"null").",";
@@ -330,37 +330,37 @@  discard block
 block discarded – undo
330 330
 		$sql.= " fk_user_mod=".$user->id;
331 331
 
332 332
 
333
-        $sql.= " WHERE rowid=".$this->id;
333
+		$sql.= " WHERE rowid=".$this->id;
334 334
 
335 335
 		$this->db->begin();
336 336
 
337 337
 		dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
338
-        $resql = $this->db->query($sql);
339
-    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
338
+		$resql = $this->db->query($sql);
339
+		if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
340 340
 
341 341
 		if (! $error)
342 342
 		{
343 343
 			if (! $notrigger)
344 344
 			{
345
-	            // Uncomment this and change MYOBJECT to your own tag if you
346
-	            // want this action calls a trigger.
347
-
348
-	            //// Call triggers
349
-	            //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
350
-	            //$interface=new Interfaces($this->db);
351
-	            //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
352
-	            //if ($result < 0) { $error++; $this->errors=$interface->errors; }
353
-	            //// End call triggers
354
-	    	}
345
+				// Uncomment this and change MYOBJECT to your own tag if you
346
+				// want this action calls a trigger.
347
+
348
+				//// Call triggers
349
+				//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
350
+				//$interface=new Interfaces($this->db);
351
+				//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
352
+				//if ($result < 0) { $error++; $this->errors=$interface->errors; }
353
+				//// End call triggers
354
+			}
355 355
 		}
356 356
 
357
-        // Commit or rollback
357
+		// Commit or rollback
358 358
 		if ($error)
359 359
 		{
360 360
 			foreach($this->errors as $errmsg)
361 361
 			{
362
-	            dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
363
-	            $this->error.=($this->error?', '.$errmsg:$errmsg);
362
+				dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
363
+				$this->error.=($this->error?', '.$errmsg:$errmsg);
364 364
 			}
365 365
 			$this->db->rollback();
366 366
 			return -1*$error;
@@ -370,16 +370,16 @@  discard block
 block discarded – undo
370 370
 			$this->db->commit();
371 371
 			return 1;
372 372
 		}
373
-    }
373
+	}
374 374
 
375 375
 
376 376
  	/**
377
-	 *  Delete object in database
378
-	 *
379
-     *	@param  User	$user        User that deletes
380
-     *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
381
-	 *  @return	int					 <0 if KO, >0 if OK
382
-	 */
377
+ 	 *  Delete object in database
378
+ 	 *
379
+ 	 *	@param  User	$user        User that deletes
380
+ 	 *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
381
+ 	 *  @return	int					 <0 if KO, >0 if OK
382
+ 	 */
383 383
 	function delete($user, $notrigger=0)
384 384
 	{
385 385
 		global $conf, $langs;
@@ -392,34 +392,34 @@  discard block
 block discarded – undo
392 392
 			if (! $notrigger)
393 393
 			{
394 394
 				// Uncomment this and change MYOBJECT to your own tag if you
395
-		        // want this action calls a trigger.
396
-
397
-		        //// Call triggers
398
-		        //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
399
-		        //$interface=new Interfaces($this->db);
400
-		        //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
401
-		        //if ($result < 0) { $error++; $this->errors=$interface->errors; }
402
-		        //// End call triggers
395
+				// want this action calls a trigger.
396
+
397
+				//// Call triggers
398
+				//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
399
+				//$interface=new Interfaces($this->db);
400
+				//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
401
+				//if ($result < 0) { $error++; $this->errors=$interface->errors; }
402
+				//// End call triggers
403 403
 			}
404 404
 		}
405 405
 
406 406
 		if (! $error)
407 407
 		{
408
-    		$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product";
409
-    		$sql.= " WHERE rowid=".$this->id;
408
+			$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product";
409
+			$sql.= " WHERE rowid=".$this->id;
410 410
 
411
-    		dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
412
-    		$resql = $this->db->query($sql);
413
-        	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
411
+			dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
412
+			$resql = $this->db->query($sql);
413
+			if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
414 414
 		}
415 415
 
416
-        // Commit or rollback
416
+		// Commit or rollback
417 417
 		if ($error)
418 418
 		{
419 419
 			foreach($this->errors as $errmsg)
420 420
 			{
421
-	            dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
422
-	            $this->error.=($this->error?', '.$errmsg:$errmsg);
421
+				dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
422
+				$this->error.=($this->error?', '.$errmsg:$errmsg);
423 423
 			}
424 424
 			$this->db->rollback();
425 425
 			return -1*$error;
Please login to merge, or discard this patch.
Spacing   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -31,18 +31,18 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class Propalmergepdfproduct extends CommonObject
33 33
 {
34
-	var $element='propal_merge_pdf_product';			//!< Id that identify managed objects
35
-	var $table_element='propal_merge_pdf_product';		//!< Name of table without prefix where object is stored
34
+	var $element = 'propal_merge_pdf_product'; //!< Id that identify managed objects
35
+	var $table_element = 'propal_merge_pdf_product'; //!< Name of table without prefix where object is stored
36 36
 
37 37
 	var $fk_product;
38 38
 	var $file_name;
39 39
 	var $fk_user_author;
40 40
 	var $fk_user_mod;
41
-	var $datec='';
42
-	var $tms='';
41
+	var $datec = '';
42
+	var $tms = '';
43 43
 	var $lang;
44 44
 
45
-	var $lines=array();
45
+	var $lines = array();
46 46
 
47 47
 
48 48
 
@@ -66,19 +66,19 @@  discard block
 block discarded – undo
66 66
      *  @param  int		$notrigger   0=launch triggers after, 1=disable triggers
67 67
      *  @return int      		   	 <0 if KO, Id of created object if OK
68 68
      */
69
-    function create($user, $notrigger=0)
69
+    function create($user, $notrigger = 0)
70 70
     {
71 71
     	global $conf, $langs;
72
-		$error=0;
72
+		$error = 0;
73 73
 
74 74
 		// Clean parameters
75 75
 
76
-		if (isset($this->fk_product)) $this->fk_product=trim($this->fk_product);
77
-		if (isset($this->file_name)) $this->file_name=trim($this->file_name);
78
-		if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author);
79
-		if (isset($this->fk_user_mod)) $this->fk_user_mod=trim($this->fk_user_mod);
80
-		if (isset($this->lang)) $this->lang=trim($this->lang);
81
-		if (isset($this->import_key)) $this->import_key=trim($this->import_key);
76
+		if (isset($this->fk_product)) $this->fk_product = trim($this->fk_product);
77
+		if (isset($this->file_name)) $this->file_name = trim($this->file_name);
78
+		if (isset($this->fk_user_author)) $this->fk_user_author = trim($this->fk_user_author);
79
+		if (isset($this->fk_user_mod)) $this->fk_user_mod = trim($this->fk_user_mod);
80
+		if (isset($this->lang)) $this->lang = trim($this->lang);
81
+		if (isset($this->import_key)) $this->import_key = trim($this->import_key);
82 82
 
83 83
 
84 84
 
@@ -88,41 +88,41 @@  discard block
 block discarded – undo
88 88
         // Insert request
89 89
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."propal_merge_pdf_product(";
90 90
 
91
-		$sql.= "fk_product,";
92
-		$sql.= "file_name,";
91
+		$sql .= "fk_product,";
92
+		$sql .= "file_name,";
93 93
 		if ($conf->global->MAIN_MULTILANGS) {
94
-			$sql.= "lang,";
94
+			$sql .= "lang,";
95 95
 		}
96
-		$sql.= "fk_user_author,";
97
-		$sql.= "fk_user_mod,";
98
-		$sql.= "datec";
96
+		$sql .= "fk_user_author,";
97
+		$sql .= "fk_user_mod,";
98
+		$sql .= "datec";
99 99
 
100 100
 
101
-        $sql.= ") VALUES (";
101
+        $sql .= ") VALUES (";
102 102
 
103
-		$sql.= " ".(! isset($this->fk_product)?'NULL':"'".$this->db->escape($this->fk_product)."'").",";
104
-		$sql.= " ".(! isset($this->file_name)?'NULL':"'".$this->db->escape($this->file_name)."'").",";
103
+		$sql .= " ".(!isset($this->fk_product) ? 'NULL' : "'".$this->db->escape($this->fk_product)."'").",";
104
+		$sql .= " ".(!isset($this->file_name) ? 'NULL' : "'".$this->db->escape($this->file_name)."'").",";
105 105
 		if ($conf->global->MAIN_MULTILANGS) {
106
-			$sql.= " ".(! isset($this->lang)?'NULL':"'".$this->db->escape($this->lang)."'").",";
106
+			$sql .= " ".(!isset($this->lang) ? 'NULL' : "'".$this->db->escape($this->lang)."'").",";
107 107
 		}
108
-		$sql.= " ".$user->id.",";
109
-		$sql.= " ".$user->id.",";
110
-		$sql.= " '".$this->db->idate(dol_now())."'";
108
+		$sql .= " ".$user->id.",";
109
+		$sql .= " ".$user->id.",";
110
+		$sql .= " '".$this->db->idate(dol_now())."'";
111 111
 
112 112
 
113
-		$sql.= ")";
113
+		$sql .= ")";
114 114
 
115 115
 		$this->db->begin();
116 116
 
117 117
 	   	dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
118
-        $resql=$this->db->query($sql);
119
-    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
118
+        $resql = $this->db->query($sql);
119
+    	if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
120 120
 
121
-		if (! $error)
121
+		if (!$error)
122 122
         {
123 123
             $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal_merge_pdf_product");
124 124
 
125
-			if (! $notrigger)
125
+			if (!$notrigger)
126 126
 			{
127 127
 	            // Uncomment this and change MYOBJECT to your own tag if you
128 128
 	            // want this action calls a trigger.
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
         // Commit or rollback
140 140
         if ($error)
141 141
 		{
142
-			foreach($this->errors as $errmsg)
142
+			foreach ($this->errors as $errmsg)
143 143
 			{
144 144
 	            dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
145
-	            $this->error.=($this->error?', '.$errmsg:$errmsg);
145
+	            $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
146 146
 			}
147 147
 			$this->db->rollback();
148
-			return -1*$error;
148
+			return -1 * $error;
149 149
 		}
150 150
 		else
151 151
 		{
@@ -163,33 +163,33 @@  discard block
 block discarded – undo
163 163
      */
164 164
     function fetch($id)
165 165
     {
166
-    	global $langs,$conf;
166
+    	global $langs, $conf;
167 167
 
168 168
         $sql = "SELECT";
169
-		$sql.= " t.rowid,";
169
+		$sql .= " t.rowid,";
170 170
 
171
-		$sql.= " t.fk_product,";
172
-		$sql.= " t.file_name,";
173
-		$sql.= " t.lang,";
174
-		$sql.= " t.fk_user_author,";
175
-		$sql.= " t.fk_user_mod,";
176
-		$sql.= " t.datec,";
177
-		$sql.= " t.tms,";
178
-		$sql.= " t.import_key";
171
+		$sql .= " t.fk_product,";
172
+		$sql .= " t.file_name,";
173
+		$sql .= " t.lang,";
174
+		$sql .= " t.fk_user_author,";
175
+		$sql .= " t.fk_user_mod,";
176
+		$sql .= " t.datec,";
177
+		$sql .= " t.tms,";
178
+		$sql .= " t.import_key";
179 179
 
180 180
 
181
-        $sql.= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t";
182
-        $sql.= " WHERE t.rowid = ".$id;
181
+        $sql .= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t";
182
+        $sql .= " WHERE t.rowid = ".$id;
183 183
 
184 184
     	dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
185
-        $resql=$this->db->query($sql);
185
+        $resql = $this->db->query($sql);
186 186
         if ($resql)
187 187
         {
188 188
             if ($this->db->num_rows($resql))
189 189
             {
190 190
                 $obj = $this->db->fetch_object($resql);
191 191
 
192
-                $this->id    = $obj->rowid;
192
+                $this->id = $obj->rowid;
193 193
 
194 194
 				$this->fk_product = $obj->fk_product;
195 195
 				$this->file_name = $obj->file_name;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         }
211 211
         else
212 212
         {
213
-      	    $this->error="Error ".$this->db->lasterror();
213
+      	    $this->error = "Error ".$this->db->lasterror();
214 214
             dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
215 215
             return -1;
216 216
         }
@@ -223,40 +223,40 @@  discard block
 block discarded – undo
223 223
      *  @param	string	$lang  			Lang string code
224 224
      *  @return int          	<0 if KO, >0 if OK
225 225
      */
226
-    function fetch_by_product($product_id, $lang='')
226
+    function fetch_by_product($product_id, $lang = '')
227 227
     {
228
-    	global $langs,$conf;
228
+    	global $langs, $conf;
229 229
 
230 230
     	$sql = "SELECT";
231
-    	$sql.= " t.rowid,";
231
+    	$sql .= " t.rowid,";
232 232
 
233
-    	$sql.= " t.fk_product,";
234
-    	$sql.= " t.file_name,";
235
-    	$sql.= " t.lang,";
236
-    	$sql.= " t.fk_user_author,";
237
-    	$sql.= " t.fk_user_mod,";
238
-    	$sql.= " t.datec,";
239
-    	$sql.= " t.tms,";
240
-    	$sql.= " t.import_key";
233
+    	$sql .= " t.fk_product,";
234
+    	$sql .= " t.file_name,";
235
+    	$sql .= " t.lang,";
236
+    	$sql .= " t.fk_user_author,";
237
+    	$sql .= " t.fk_user_mod,";
238
+    	$sql .= " t.datec,";
239
+    	$sql .= " t.tms,";
240
+    	$sql .= " t.import_key";
241 241
 
242 242
 
243
-    	$sql.= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t";
244
-    	$sql.= " WHERE t.fk_product = ".$product_id;
243
+    	$sql .= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t";
244
+    	$sql .= " WHERE t.fk_product = ".$product_id;
245 245
     	if ($conf->global->MAIN_MULTILANGS && !empty($lang)) {
246
-    		$sql.= " AND t.lang = '".$lang."'";
246
+    		$sql .= " AND t.lang = '".$lang."'";
247 247
     	}
248 248
 
249 249
     	dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
250
-    	$resql=$this->db->query($sql);
250
+    	$resql = $this->db->query($sql);
251 251
     	if ($resql)
252 252
     	{
253 253
     		if ($this->db->num_rows($resql))
254 254
     		{
255
-    			while($obj = $this->db->fetch_object($resql)) {
255
+    			while ($obj = $this->db->fetch_object($resql)) {
256 256
 
257 257
     				$line = new PropalmergepdfproductLine();
258 258
 
259
-	    			$line->id    = $obj->rowid;
259
+	    			$line->id = $obj->rowid;
260 260
 
261 261
 	    			$line->fk_product = $obj->fk_product;
262 262
 	    			$line->file_name = $obj->file_name;
@@ -271,9 +271,9 @@  discard block
 block discarded – undo
271 271
 
272 272
 
273 273
 	    			if ($conf->global->MAIN_MULTILANGS) {
274
-	    				$this->lines[$obj->file_name.'_'.$obj->lang]=$line;
275
-	    			}else {
276
-	    				$this->lines[$obj->file_name]=$line;
274
+	    				$this->lines[$obj->file_name.'_'.$obj->lang] = $line;
275
+	    			} else {
276
+	    				$this->lines[$obj->file_name] = $line;
277 277
 	    			}
278 278
 
279 279
 
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
     	}
288 288
     	else
289 289
     	{
290
-    		$this->error="Error ".$this->db->lasterror();
290
+    		$this->error = "Error ".$this->db->lasterror();
291 291
     		dol_syslog(get_class($this)."::fetch_by_product ".$this->error, LOG_ERR);
292 292
     		return -1;
293 293
     	}
@@ -301,17 +301,17 @@  discard block
 block discarded – undo
301 301
      *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
302 302
      *  @return int     		   	 <0 if KO, >0 if OK
303 303
      */
304
-    function update($user=0, $notrigger=0)
304
+    function update($user = 0, $notrigger = 0)
305 305
     {
306 306
     	global $conf, $langs;
307
-		$error=0;
307
+		$error = 0;
308 308
 
309 309
 		// Clean parameters
310 310
 
311
-		if (isset($this->fk_product)) $this->fk_product=trim($this->fk_product);
312
-		if (isset($this->file_name)) $this->file_name=trim($this->file_name);
313
-		if (isset($this->fk_user_mod)) $this->fk_user_mod=trim($this->fk_user_mod);
314
-		if (isset($this->lang)) $this->lang=trim($this->lang);
311
+		if (isset($this->fk_product)) $this->fk_product = trim($this->fk_product);
312
+		if (isset($this->file_name)) $this->file_name = trim($this->file_name);
313
+		if (isset($this->fk_user_mod)) $this->fk_user_mod = trim($this->fk_user_mod);
314
+		if (isset($this->lang)) $this->lang = trim($this->lang);
315 315
 
316 316
 
317 317
 
@@ -322,25 +322,25 @@  discard block
 block discarded – undo
322 322
         // Update request
323 323
         $sql = "UPDATE ".MAIN_DB_PREFIX."propal_merge_pdf_product SET";
324 324
 
325
-		$sql.= " fk_product=".(isset($this->fk_product)?$this->fk_product:"null").",";
326
-		$sql.= " file_name=".(isset($this->file_name)?"'".$this->db->escape($this->file_name)."'":"null").",";
325
+		$sql .= " fk_product=".(isset($this->fk_product) ? $this->fk_product : "null").",";
326
+		$sql .= " file_name=".(isset($this->file_name) ? "'".$this->db->escape($this->file_name)."'" : "null").",";
327 327
 		if ($conf->global->MAIN_MULTILANGS) {
328
-			$sql.= " lang=".(isset($this->lang)?"'".$this->db->escape($this->lang)."'":"null").",";
328
+			$sql .= " lang=".(isset($this->lang) ? "'".$this->db->escape($this->lang)."'" : "null").",";
329 329
 		}
330
-		$sql.= " fk_user_mod=".$user->id;
330
+		$sql .= " fk_user_mod=".$user->id;
331 331
 
332 332
 
333
-        $sql.= " WHERE rowid=".$this->id;
333
+        $sql .= " WHERE rowid=".$this->id;
334 334
 
335 335
 		$this->db->begin();
336 336
 
337 337
 		dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
338 338
         $resql = $this->db->query($sql);
339
-    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
339
+    	if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
340 340
 
341
-		if (! $error)
341
+		if (!$error)
342 342
 		{
343
-			if (! $notrigger)
343
+			if (!$notrigger)
344 344
 			{
345 345
 	            // Uncomment this and change MYOBJECT to your own tag if you
346 346
 	            // want this action calls a trigger.
@@ -357,13 +357,13 @@  discard block
 block discarded – undo
357 357
         // Commit or rollback
358 358
 		if ($error)
359 359
 		{
360
-			foreach($this->errors as $errmsg)
360
+			foreach ($this->errors as $errmsg)
361 361
 			{
362 362
 	            dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
363
-	            $this->error.=($this->error?', '.$errmsg:$errmsg);
363
+	            $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
364 364
 			}
365 365
 			$this->db->rollback();
366
-			return -1*$error;
366
+			return -1 * $error;
367 367
 		}
368 368
 		else
369 369
 		{
@@ -380,16 +380,16 @@  discard block
 block discarded – undo
380 380
      *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
381 381
 	 *  @return	int					 <0 if KO, >0 if OK
382 382
 	 */
383
-	function delete($user, $notrigger=0)
383
+	function delete($user, $notrigger = 0)
384 384
 	{
385 385
 		global $conf, $langs;
386
-		$error=0;
386
+		$error = 0;
387 387
 
388 388
 		$this->db->begin();
389 389
 
390
-		if (! $error)
390
+		if (!$error)
391 391
 		{
392
-			if (! $notrigger)
392
+			if (!$notrigger)
393 393
 			{
394 394
 				// Uncomment this and change MYOBJECT to your own tag if you
395 395
 		        // want this action calls a trigger.
@@ -403,26 +403,26 @@  discard block
 block discarded – undo
403 403
 			}
404 404
 		}
405 405
 
406
-		if (! $error)
406
+		if (!$error)
407 407
 		{
408 408
     		$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product";
409
-    		$sql.= " WHERE rowid=".$this->id;
409
+    		$sql .= " WHERE rowid=".$this->id;
410 410
 
411 411
     		dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
412 412
     		$resql = $this->db->query($sql);
413
-        	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
413
+        	if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
414 414
 		}
415 415
 
416 416
         // Commit or rollback
417 417
 		if ($error)
418 418
 		{
419
-			foreach($this->errors as $errmsg)
419
+			foreach ($this->errors as $errmsg)
420 420
 			{
421 421
 	            dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
422
-	            $this->error.=($this->error?', '.$errmsg:$errmsg);
422
+	            $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
423 423
 			}
424 424
 			$this->db->rollback();
425
-			return -1*$error;
425
+			return -1 * $error;
426 426
 		}
427 427
 		else
428 428
 		{
@@ -440,16 +440,16 @@  discard block
 block discarded – undo
440 440
 	 *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
441 441
 	 *  @return	int					 <0 if KO, >0 if OK
442 442
 	 */
443
-	function delete_by_product($user, $product_id, $lang_id='',  $notrigger=0)
443
+	function delete_by_product($user, $product_id, $lang_id = '', $notrigger = 0)
444 444
 	{
445 445
 		global $conf, $langs;
446
-		$error=0;
446
+		$error = 0;
447 447
 
448 448
 		$this->db->begin();
449 449
 
450
-		if (! $error)
450
+		if (!$error)
451 451
 		{
452
-			if (! $notrigger)
452
+			if (!$notrigger)
453 453
 			{
454 454
 				// Uncomment this and change MYOBJECT to your own tag if you
455 455
 				// want this action calls a trigger.
@@ -463,30 +463,30 @@  discard block
 block discarded – undo
463 463
 			}
464 464
 		}
465 465
 
466
-		if (! $error)
466
+		if (!$error)
467 467
 		{
468 468
 			$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product";
469
-			$sql.= " WHERE fk_product=".$product_id;
469
+			$sql .= " WHERE fk_product=".$product_id;
470 470
 
471 471
 			if ($conf->global->MAIN_MULTILANGS && !empty($lang_id)) {
472
-				$sql.= " AND lang='".$lang_id."'";
472
+				$sql .= " AND lang='".$lang_id."'";
473 473
 			}
474 474
 
475 475
 			dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
476 476
 			$resql = $this->db->query($sql);
477
-			if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
477
+			if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
478 478
 		}
479 479
 
480 480
 		// Commit or rollback
481 481
 		if ($error)
482 482
 		{
483
-			foreach($this->errors as $errmsg)
483
+			foreach ($this->errors as $errmsg)
484 484
 			{
485 485
 				dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
486
-				$this->error.=($this->error?', '.$errmsg:$errmsg);
486
+				$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
487 487
 			}
488 488
 			$this->db->rollback();
489
-			return -1*$error;
489
+			return -1 * $error;
490 490
 		}
491 491
 		else
492 492
 		{
@@ -504,13 +504,13 @@  discard block
 block discarded – undo
504 504
 	function delete_by_file($user)
505 505
 	{
506 506
 		global $conf, $langs;
507
-		$error=0;
507
+		$error = 0;
508 508
 
509 509
 		$this->db->begin();
510 510
 
511
-		if (! $error)
511
+		if (!$error)
512 512
 		{
513
-			if (! $notrigger)
513
+			if (!$notrigger)
514 514
 			{
515 515
 				// Uncomment this and change MYOBJECT to your own tag if you
516 516
 				// want this action calls a trigger.
@@ -524,26 +524,26 @@  discard block
 block discarded – undo
524 524
 			}
525 525
 		}
526 526
 
527
-		if (! $error)
527
+		if (!$error)
528 528
 		{
529 529
 			$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product";
530
-			$sql.= " WHERE fk_product=".$this->fk_product." AND file_name='".$this->db->escape($this->file_name)."'";
530
+			$sql .= " WHERE fk_product=".$this->fk_product." AND file_name='".$this->db->escape($this->file_name)."'";
531 531
 
532 532
 			dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
533 533
 			$resql = $this->db->query($sql);
534
-			if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
534
+			if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
535 535
 		}
536 536
 
537 537
 		// Commit or rollback
538 538
 		if ($error)
539 539
 		{
540
-			foreach($this->errors as $errmsg)
540
+			foreach ($this->errors as $errmsg)
541 541
 			{
542 542
 				dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
543
-				$this->error.=($this->error?', '.$errmsg:$errmsg);
543
+				$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
544 544
 			}
545 545
 			$this->db->rollback();
546
-			return -1*$error;
546
+			return -1 * $error;
547 547
 		}
548 548
 		else
549 549
 		{
@@ -562,40 +562,40 @@  discard block
 block discarded – undo
562 562
 	 */
563 563
 	function createFromClone($fromid)
564 564
 	{
565
-		global $user,$langs;
565
+		global $user, $langs;
566 566
 
567
-		$error=0;
567
+		$error = 0;
568 568
 
569
-		$object=new Propalmergepdfproduct($this->db);
569
+		$object = new Propalmergepdfproduct($this->db);
570 570
 
571 571
 		$this->db->begin();
572 572
 
573 573
 		// Load source object
574 574
 		$object->fetch($fromid);
575
-		$object->id=0;
576
-		$object->statut=0;
575
+		$object->id = 0;
576
+		$object->statut = 0;
577 577
 
578 578
 		// Clear fields
579 579
 		// ...
580 580
 
581 581
 		// Create clone
582
-		$result=$object->create($user);
582
+		$result = $object->create($user);
583 583
 
584 584
 		// Other options
585 585
 		if ($result < 0)
586 586
 		{
587
-			$this->error=$object->error;
587
+			$this->error = $object->error;
588 588
 			$error++;
589 589
 		}
590 590
 
591
-		if (! $error)
591
+		if (!$error)
592 592
 		{
593 593
 
594 594
 
595 595
 		}
596 596
 
597 597
 		// End
598
-		if (! $error)
598
+		if (!$error)
599 599
 		{
600 600
 			$this->db->commit();
601 601
 			return $object->id;
@@ -616,15 +616,15 @@  discard block
 block discarded – undo
616 616
 	 */
617 617
 	function initAsSpecimen()
618 618
 	{
619
-		$this->id=0;
619
+		$this->id = 0;
620 620
 
621
-		$this->fk_product='';
622
-		$this->file_name='';
623
-		$this->fk_user_author='';
624
-		$this->fk_user_mod='';
625
-		$this->datec='';
626
-		$this->tms='';
627
-		$this->import_key='';
621
+		$this->fk_product = '';
622
+		$this->file_name = '';
623
+		$this->fk_user_author = '';
624
+		$this->fk_user_mod = '';
625
+		$this->datec = '';
626
+		$this->tms = '';
627
+		$this->import_key = '';
628 628
 
629 629
 
630 630
 	}
@@ -643,8 +643,8 @@  discard block
 block discarded – undo
643 643
 	var $lang;
644 644
 	var $fk_user_author;
645 645
 	var $fk_user_mod;
646
-	var $datec='';
647
-	var $tms='';
646
+	var $datec = '';
647
+	var $tms = '';
648 648
 	var $import_key;
649 649
 
650 650
 	function __construct() {
Please login to merge, or discard this patch.
htdocs/product/dynamic_price/class/price_global_variable_updater.class.php 4 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     /**
169 169
      *  Update object into database
170 170
      *
171
-     *  @param	User	$user        User that modifies
171
+     *  @param	integer	$user        User that modifies
172 172
      *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
173 173
      *  @return int     		   	 <0 if KO, >0 if OK
174 174
      */
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
      *  Update next_update into database
540 540
      *
541 541
      *  @param	string	$next_update Next update to write
542
-     *  @param	User	$user        User that modifies
542
+     *  @param	integer	$user        User that modifies
543 543
      *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
544 544
      *  @return int     		   	 <0 if KO, >0 if OK
545 545
      */
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
      *  Update last_status into database
584 584
      *
585 585
      *  @param	string	$last_status Status to write
586
-     *  @param	User	$user        User that modifies
586
+     *  @param	integer	$user        User that modifies
587 587
      *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
588 588
      *  @return int     		   	 <0 if KO, >0 if OK
589 589
      */
Please login to merge, or discard this patch.
Indentation   +587 added lines, -587 removed lines patch added patch discarded remove patch
@@ -29,591 +29,591 @@
 block discarded – undo
29 29
  */
30 30
 class PriceGlobalVariableUpdater
31 31
 {
32
-    var $db;							//!< To store db handler
33
-    var $error;							//!< To return error code (or message)
34
-    var $errors=array();				//!< To return several error codes (or messages)
35
-    var $types=array(0, 1);				//!< Updater types
36
-    var $update_min = 5;				//!< Minimal update rate
37
-    var $id;
38
-    var $type;
39
-    var $description;
40
-    var $parameters;
41
-    var $fk_variable;
42
-    var $update_interval;				//!< Interval in mins
43
-    var $next_update;					//!< Next update timestamp
44
-    var $last_status;
45
-    public $table_element = "c_price_global_variable_updater";
46
-
47
-    /**
48
-     *  Constructor
49
-     *
50
-     *  @param	DoliDb		$db      Database handler
51
-     */
52
-    function __construct($db)
53
-    {
54
-        $this->db = $db;
55
-        return 1;
56
-    }
57
-
58
-
59
-    /**
60
-     *  Create object into database
61
-     *
62
-     *  @param	User	$user        User that creates
63
-     *  @param  int		$notrigger   0=launch triggers after, 1=disable triggers
64
-     *  @return int      		   	 <0 if KO, Id of created object if OK
65
-     */
66
-    function create($user, $notrigger=0)
67
-    {
68
-        $error=0;
69
-
70
-        $this->checkParameters();
71
-
72
-        // Insert request
73
-        $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (";
74
-        $sql.= "type, description, parameters, fk_variable, update_interval, next_update, last_status";
75
-        $sql.= ") VALUES (";
76
-        $sql.= " ".$this->type.",";
77
-        $sql.= " ".(isset($this->description)?"'".$this->db->escape($this->description)."'":"''").",";
78
-        $sql.= " ".(isset($this->parameters)?"'".$this->db->escape($this->parameters)."'":"''").",";
79
-        $sql.= " ".$this->fk_variable.",";
80
-        $sql.= " ".$this->update_interval.",";
81
-        $sql.= " ".$this->next_update.",";
82
-        $sql.= " ".(isset($this->last_status)?"'".$this->db->escape($this->last_status)."'":"''");
83
-        $sql.= ")";
84
-
85
-        $this->db->begin();
86
-
87
-        dol_syslog(get_class($this)."::create", LOG_DEBUG);
88
-        $resql=$this->db->query($sql);
89
-        if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
90
-
91
-        if (! $error)
92
-        {
93
-            $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
94
-
95
-            if (! $notrigger)
96
-            {
97
-                // Uncomment this and change MYOBJECT to your own tag if you
98
-                // want this action calls a trigger.
99
-
100
-                //// Call triggers
101
-                //$result=$this->call_trigger('MYOBJECT_CREATE',$user);
102
-                //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
103
-                //// End call triggers
104
-            }
105
-        }
106
-
107
-        // Commit or rollback
108
-        if ($error)
109
-        {
110
-            foreach($this->errors as $errmsg)
111
-            {
112
-                dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
113
-                $this->error.=($this->error?', '.$errmsg:$errmsg);
114
-            }
115
-            $this->db->rollback();
116
-            return -1*$error;
117
-        }
118
-        else
119
-        {
120
-            $this->db->commit();
121
-            return $this->id;
122
-        }
123
-    }
124
-
125
-
126
-    /**
127
-     *  Load object in memory from the database
128
-     *
129
-     *  @param		int		$id    	Id object
130
-     *  @return		int			    < 0 if KO, 0 if OK but not found, > 0 if OK
131
-     */
132
-    function fetch($id)
133
-    {
134
-        $sql = "SELECT type, description, parameters, fk_variable, update_interval, next_update, last_status";
135
-        $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
136
-        $sql.= " WHERE rowid = ".$id;
137
-
138
-        dol_syslog(get_class($this)."::fetch");
139
-        $resql=$this->db->query($sql);
140
-        if ($resql)
141
-        {
142
-            $obj = $this->db->fetch_object($resql);
143
-            if ($obj)
144
-            {
145
-                $this->id				= $id;
146
-                $this->type				= $obj->type;
147
-                $this->description		= $obj->description;
148
-                $this->parameters		= $obj->parameters;
149
-                $this->fk_variable		= $obj->fk_variable;
150
-                $this->update_interval	= $obj->update_interval;
151
-                $this->next_update		= $obj->next_update;
152
-                $this->last_status		= $obj->last_status;
153
-                $this->checkParameters();
154
-                return 1;
155
-            }
156
-            else
157
-            {
158
-                return 0;
159
-            }
160
-        }
161
-        else
162
-        {
163
-            $this->error="Error ".$this->db->lasterror();
164
-            return -1;
165
-        }
166
-    }
167
-
168
-    /**
169
-     *  Update object into database
170
-     *
171
-     *  @param	User	$user        User that modifies
172
-     *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
173
-     *  @return int     		   	 <0 if KO, >0 if OK
174
-     */
175
-    function update($user=0, $notrigger=0)
176
-    {
177
-        $error=0;
178
-
179
-        $this->checkParameters();
180
-
181
-        // Update request
182
-        $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
183
-        $sql.= " type = ".$this->type.",";
184
-        $sql.= " description = ".(isset($this->description)?"'".$this->db->escape($this->description)."'":"''").",";
185
-        $sql.= " parameters = ".(isset($this->parameters)?"'".$this->db->escape($this->parameters)."'":"''").",";
186
-        $sql.= " fk_variable = ".$this->fk_variable.",";
187
-        $sql.= " update_interval = ".$this->update_interval.",";
188
-        $sql.= " next_update = ".$this->next_update.",";
189
-        $sql.= " last_status = ".(isset($this->last_status)?"'".$this->db->escape($this->last_status)."'":"''");
190
-        $sql.= " WHERE rowid = ".$this->id;
191
-
192
-        $this->db->begin();
193
-
194
-        dol_syslog(get_class($this)."::update");
195
-        $resql = $this->db->query($sql);
196
-        if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
197
-
198
-        if (! $error)
199
-        {
200
-            if (! $notrigger)
201
-            {
202
-                // Uncomment this and change MYOBJECT to your own tag if you
203
-                // want this action calls a trigger.
204
-
205
-                //// Call triggers
206
-                //$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
207
-                //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
208
-                //// End call triggers
209
-             }
210
-        }
211
-
212
-        // Commit or rollback
213
-        if ($error)
214
-        {
215
-            foreach($this->errors as $errmsg)
216
-            {
217
-                dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
218
-                $this->error.=($this->error?', '.$errmsg:$errmsg);
219
-            }
220
-            $this->db->rollback();
221
-            return -1*$error;
222
-        }
223
-        else
224
-        {
225
-            $this->db->commit();
226
-            return 1;
227
-        }
228
-    }
229
-
230
-    /**
231
-     *  Delete object in database
232
-     *
233
-     * 	@param	int		$rowid		 Row id of global variable
234
-     *	@param  User	$user        User that deletes
235
-     *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
236
-     *  @return	int					 <0 if KO, >0 if OK
237
-     */
238
-    function delete($rowid, $user, $notrigger=0)
239
-    {
240
-        $error=0;
241
-
242
-        $this->db->begin();
243
-
244
-        if (! $error)
245
-        {
246
-            if (! $notrigger)
247
-            {
248
-                // Uncomment this and change MYOBJECT to your own tag if you
249
-                // want this action calls a trigger.
250
-
251
-                //// Call triggers
252
-                //$result=$this->call_trigger('MYOBJECT_DELETE',$user);
253
-                //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
254
-                //// End call triggers
255
-            }
256
-        }
257
-
258
-        if (! $error)
259
-        {
260
-            $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
261
-            $sql.= " WHERE rowid = ".$rowid;
262
-
263
-            dol_syslog(get_class($this)."::delete");
264
-            $resql = $this->db->query($sql);
265
-            if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
266
-        }
267
-
268
-        // Commit or rollback
269
-        if ($error)
270
-        {
271
-            foreach($this->errors as $errmsg)
272
-            {
273
-                dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
274
-                $this->error.=($this->error?', '.$errmsg:$errmsg);
275
-            }
276
-            $this->db->rollback();
277
-            return -1*$error;
278
-        }
279
-        else
280
-        {
281
-            $this->db->commit();
282
-            return 1;
283
-        }
284
-    }
285
-
286
-    /**
287
-     *	Initialise object with example values
288
-     *	Id must be 0 if object instance is a specimen
289
-     *
290
-     *	@return	void
291
-     */
292
-    function initAsSpecimen()
293
-    {
294
-        $this->id=0;
295
-        $this->type=0;
296
-        $this->description='';
297
-        $this->parameters='';
298
-        $this->fk_variable=0;
299
-        $this->update_interval=0;
300
-        $this->next_update=0;
301
-        $this->last_status='';
302
-    }
303
-
304
-    /**
305
-     *	Returns the last updated time in string html format, returns "never" if its less than 1
306
-     *
307
-     *	@return	string
308
-     */
309
-    function getLastUpdated()
310
-    {
311
-        global $langs;
312
-        $last = $this->next_update - ($this->update_interval * 60);
313
-        if ($last < 1) {
314
-            return $langs->trans("Never");
315
-        }
316
-        $status = empty($this->last_status) ? $langs->trans("CorrectlyUpdated") : $this->last_status;
317
-        return $status.'<br>'.dol_print_date($last, '%d/%m/%Y %H:%M:%S');
318
-    }
319
-
320
-    /**
321
-     *	Checks if all parameters are in order
322
-     *
323
-     *	@return	void
324
-     */
325
-    function checkParameters()
326
-    {
327
-        // Clean parameters
328
-        if (isset($this->description)) $this->description=trim($this->description);
329
-        if (isset($this->parameters)) $this->parameters=trim($this->parameters);
330
-        else $this->parameters="";
331
-        if (isset($this->last_status)) $this->last_status=trim($this->last_status);
332
-
333
-        // Check parameters
334
-        if (empty($this->type) || !is_numeric($this->type) || !in_array($this->type, $this->types)) $this->type=0;
335
-        if (empty($this->update_interval) || !is_numeric($this->update_interval) || $this->update_interval < 1) $this->update_interval=$this->update_min;
336
-        if (empty($this->next_update) || !is_numeric($this->next_update) || $this->next_update < 0) $this->next_update=0;
337
-    }
338
-
339
-    /**
340
-     *  List all price global variables
341
-     *
342
-     *  @return	array				Array of price global variable updaters
343
-     */
344
-    function listUpdaters()
345
-    {
346
-        $sql = "SELECT rowid, type, description, parameters, fk_variable, update_interval, next_update, last_status";
347
-        $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
348
-
349
-        dol_syslog(get_class($this)."::listUpdaters");
350
-        $resql=$this->db->query($sql);
351
-        if ($resql)
352
-        {
353
-            $retarray = array();
354
-
355
-            while ($record = $this->db->fetch_array($resql))
356
-            {
357
-                $updater_obj = new PriceGlobalVariableUpdater($this->db);
358
-                $updater_obj->id				= $record["rowid"];
359
-                $updater_obj->type				= $record["type"];
360
-                $updater_obj->description		= $record["description"];
361
-                $updater_obj->parameters		= $record["parameters"];
362
-                $updater_obj->fk_variable		= $record["fk_variable"];
363
-                $updater_obj->update_interval	= $record["update_interval"];
364
-                $updater_obj->next_update		= $record["next_update"];
365
-                $updater_obj->last_status		= $record["last_status"];
366
-                $updater_obj->checkParameters();
367
-                $retarray[]=$updater_obj;
368
-            }
369
-
370
-            $this->db->free($resql);
371
-            return $retarray;
372
-        }
373
-        else
374
-        {
375
-            $this->error=$this->db->error();
376
-            return -1;
377
-        }
378
-    }
379
-
380
-    /**
381
-     *  List all updaters which need to be processed
382
-     *
383
-     *  @return	array				Array of price global variable updaters
384
-     */
385
-    function listPendingUpdaters()
386
-    {
387
-        $sql = "SELECT rowid, type, description, parameters, fk_variable, update_interval, next_update, last_status";
388
-        $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
389
-        $sql.= " WHERE next_update < ".dol_now();
390
-
391
-        dol_syslog(get_class($this)."::processUpdaters");
392
-        $resql=$this->db->query($sql);
393
-        if ($resql)
394
-        {
395
-            $retarray = array();
396
-
397
-            while ($record = $this->db->fetch_array($resql))
398
-            {
399
-                $updater_obj = new PriceGlobalVariableUpdater($this->db);
400
-                $updater_obj->id				= $record["rowid"];
401
-                $updater_obj->type				= $record["type"];
402
-                $updater_obj->description		= $record["description"];
403
-                $updater_obj->parameters		= $record["parameters"];
404
-                $updater_obj->fk_variable		= $record["fk_variable"];
405
-                $updater_obj->update_interval	= $record["update_interval"];
406
-                $updater_obj->next_update		= $record["next_update"];
407
-                $updater_obj->last_status		= $record["last_status"];
408
-                $updater_obj->checkParameters();
409
-                $retarray[]=$updater_obj;
410
-            }
411
-
412
-            $this->db->free($resql);
413
-            return $retarray;
414
-        }
415
-        else
416
-        {
417
-            $this->error=$this->db->error();
418
-            return -1;
419
-        }
420
-    }
421
-
422
-    /**
423
-     *	Handles the processing of this updater
424
-     *
425
-     *  @return	int					 <0 if KO, 0 if OK but no global variable found, >0 if OK
426
-     */
427
-    function process()
428
-    {
429
-        global $langs, $user;
430
-        $langs->load("errors");
431
-
432
-        $this->error = null;
433
-        $this->checkParameters();
434
-
435
-        //Try to load the target global variable and abort if fails
436
-        if ($this->fk_variable < 1) {
437
-            $this->error = $langs->trans("ErrorGlobalVariableUpdater5");
438
-            return 0;
439
-        }
440
-        $price_globals = new PriceGlobalVariable($this->db);
441
-        $res = $price_globals->fetch($this->fk_variable);
442
-        if ($res < 1) {
443
-            $this->error = $langs->trans("ErrorGlobalVariableUpdater5");
444
-            return 0;
445
-        }
446
-
447
-        //Process depending of type
448
-        if ($this->type == 0 || $this->type == 1) {
449
-            //Get and check if required parameters are present
450
-            $parameters = json_decode($this->parameters, true);
451
-            if (!isset($parameters)) {
452
-                $this->error = $langs->trans("ErrorGlobalVariableUpdater1", $this->parameters);
453
-                return -1;
454
-            }
455
-            $url = $parameters['URL'];
456
-            if (!isset($url)) {
457
-                $this->error = $langs->trans("ErrorGlobalVariableUpdater2", 'URL');
458
-                return -1;
459
-            }
460
-            $value = $parameters['VALUE'];
461
-            if (!isset($value)) {
462
-                $this->error = $langs->trans("ErrorGlobalVariableUpdater2", 'VALUE');
463
-                return -1;
464
-            }
465
-            $result = "";
466
-            if ($this->type == 0) {
467
-                // Call JSON request
468
-                include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
469
-                $tmpresult=getURLContent($url);
470
-                $code=$tmpresult['http_code'];
471
-                $result=$tmpresult['content'];
472
-
473
-                if (!isset($result)) {
474
-                    $this->error = $langs->trans("ErrorGlobalVariableUpdater0", "empty response");
475
-                    return -1;
476
-                }
477
-                if ($code !== 200) {
478
-                    $this->error = $langs->trans("ErrorGlobalVariableUpdater0", $code.' '.$tmpresult['curl_error_msg']);
479
-                    return -1;
480
-                }
481
-
482
-                //Decode returned response
483
-                $result = json_decode($result, true);
484
-            } elseif ($this->type == 1) {
485
-                $ns = $parameters['NS'];
486
-                if (!isset($ns)) {
487
-                    $this->error = $langs->trans("ErrorGlobalVariableUpdater2", 'NS');
488
-                    return -1;
489
-                }
490
-                $method = $parameters['METHOD'];
491
-                if (!isset($method)) {
492
-                    $this->error = $langs->trans("ErrorGlobalVariableUpdater2", 'METHOD');
493
-                    return -1;
494
-                }
495
-                $data = $parameters['DATA'];
496
-                if (!isset($data)) {
497
-                    $this->error = $langs->trans("ErrorGlobalVariableUpdater2", 'DATA');
498
-                    return -1;
499
-                }
500
-
501
-                //SOAP client
502
-                require_once NUSOAP_PATH.'/nusoap.php';
503
-                $soap_client = new nusoap_client($url);
504
-                $soap_client->soap_defencoding='UTF-8';
505
-                $soap_client->decodeUTF8(false);
506
-                $result = $soap_client->call($method, $data, $ns,'');
507
-
508
-                //Check if result is a error
509
-                if ($result === false) {
510
-                    $this->error = $langs->trans("ErrorGlobalVariableUpdater4", $soap_client->error_str);
511
-                    return -1;
512
-                }
513
-            }
514
-
515
-            //Explode value and walk for each key in value array to get the relevant key
516
-            $value = explode(',', $value);
517
-            foreach ($value as $key) {
518
-                $result = $result[$key];
519
-            }
520
-            if (!isset($result)) {
521
-                $this->error = $langs->trans("ErrorGlobalVariableUpdater3");
522
-                return -1;
523
-            }
524
-
525
-            //Save data to global and update it
526
-            $price_globals->value = $result;
527
-            $price_globals->update($user);
528
-        }
529
-        return 1;
530
-    }
531
-
532
-    /**
533
-     *  Update next_update into database
534
-     *
535
-     *  @param	string	$next_update Next update to write
536
-     *  @param	User	$user        User that modifies
537
-     *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
538
-     *  @return int     		   	 <0 if KO, >0 if OK
539
-     */
540
-    function update_next_update($next_update, $user=0, $notrigger=0)
541
-    {
542
-        $error=0;
543
-
544
-        $this->next_update = $next_update;
545
-        $this->checkParameters();
546
-
547
-        // Update request
548
-        $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
549
-        $sql.= " next_update = ".$this->next_update;
550
-        $sql.= " WHERE rowid = ".$this->id;
551
-
552
-        $this->db->begin();
553
-
554
-        dol_syslog(get_class($this)."::update_next_update");
555
-        $resql = $this->db->query($sql);
556
-        if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
557
-
558
-        // Commit or rollback
559
-        if ($error)
560
-        {
561
-            foreach($this->errors as $errmsg)
562
-            {
563
-                dol_syslog(get_class($this)."::update_next_update ".$errmsg, LOG_ERR);
564
-                $this->error.=($this->error?', '.$errmsg:$errmsg);
565
-            }
566
-            $this->db->rollback();
567
-            return -1*$error;
568
-        }
569
-        else
570
-        {
571
-            $this->db->commit();
572
-            return 1;
573
-        }
574
-    }
575
-
576
-    /**
577
-     *  Update last_status into database
578
-     *
579
-     *  @param	string	$last_status Status to write
580
-     *  @param	User	$user        User that modifies
581
-     *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
582
-     *  @return int     		   	 <0 if KO, >0 if OK
583
-     */
584
-    function update_status($last_status, $user=0, $notrigger=0)
585
-    {
586
-        $error=0;
587
-
588
-        $this->last_status = $last_status;
589
-        $this->checkParameters();
590
-
591
-        // Update request
592
-        $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
593
-        $sql.= " last_status = ".(isset($this->last_status)?"'".$this->db->escape($this->last_status)."'":"''");
594
-        $sql.= " WHERE rowid = ".$this->id;
595
-
596
-        $this->db->begin();
597
-
598
-        dol_syslog(get_class($this)."::update_status");
599
-        $resql = $this->db->query($sql);
600
-        if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
601
-
602
-        // Commit or rollback
603
-        if ($error)
604
-        {
605
-            foreach($this->errors as $errmsg)
606
-            {
607
-                dol_syslog(get_class($this)."::update_status ".$errmsg, LOG_ERR);
608
-                $this->error.=($this->error?', '.$errmsg:$errmsg);
609
-            }
610
-            $this->db->rollback();
611
-            return -1*$error;
612
-        }
613
-        else
614
-        {
615
-            $this->db->commit();
616
-            return 1;
617
-        }
618
-    }
32
+	var $db;							//!< To store db handler
33
+	var $error;							//!< To return error code (or message)
34
+	var $errors=array();				//!< To return several error codes (or messages)
35
+	var $types=array(0, 1);				//!< Updater types
36
+	var $update_min = 5;				//!< Minimal update rate
37
+	var $id;
38
+	var $type;
39
+	var $description;
40
+	var $parameters;
41
+	var $fk_variable;
42
+	var $update_interval;				//!< Interval in mins
43
+	var $next_update;					//!< Next update timestamp
44
+	var $last_status;
45
+	public $table_element = "c_price_global_variable_updater";
46
+
47
+	/**
48
+	 *  Constructor
49
+	 *
50
+	 *  @param	DoliDb		$db      Database handler
51
+	 */
52
+	function __construct($db)
53
+	{
54
+		$this->db = $db;
55
+		return 1;
56
+	}
57
+
58
+
59
+	/**
60
+	 *  Create object into database
61
+	 *
62
+	 *  @param	User	$user        User that creates
63
+	 *  @param  int		$notrigger   0=launch triggers after, 1=disable triggers
64
+	 *  @return int      		   	 <0 if KO, Id of created object if OK
65
+	 */
66
+	function create($user, $notrigger=0)
67
+	{
68
+		$error=0;
69
+
70
+		$this->checkParameters();
71
+
72
+		// Insert request
73
+		$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (";
74
+		$sql.= "type, description, parameters, fk_variable, update_interval, next_update, last_status";
75
+		$sql.= ") VALUES (";
76
+		$sql.= " ".$this->type.",";
77
+		$sql.= " ".(isset($this->description)?"'".$this->db->escape($this->description)."'":"''").",";
78
+		$sql.= " ".(isset($this->parameters)?"'".$this->db->escape($this->parameters)."'":"''").",";
79
+		$sql.= " ".$this->fk_variable.",";
80
+		$sql.= " ".$this->update_interval.",";
81
+		$sql.= " ".$this->next_update.",";
82
+		$sql.= " ".(isset($this->last_status)?"'".$this->db->escape($this->last_status)."'":"''");
83
+		$sql.= ")";
84
+
85
+		$this->db->begin();
86
+
87
+		dol_syslog(get_class($this)."::create", LOG_DEBUG);
88
+		$resql=$this->db->query($sql);
89
+		if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
90
+
91
+		if (! $error)
92
+		{
93
+			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
94
+
95
+			if (! $notrigger)
96
+			{
97
+				// Uncomment this and change MYOBJECT to your own tag if you
98
+				// want this action calls a trigger.
99
+
100
+				//// Call triggers
101
+				//$result=$this->call_trigger('MYOBJECT_CREATE',$user);
102
+				//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
103
+				//// End call triggers
104
+			}
105
+		}
106
+
107
+		// Commit or rollback
108
+		if ($error)
109
+		{
110
+			foreach($this->errors as $errmsg)
111
+			{
112
+				dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
113
+				$this->error.=($this->error?', '.$errmsg:$errmsg);
114
+			}
115
+			$this->db->rollback();
116
+			return -1*$error;
117
+		}
118
+		else
119
+		{
120
+			$this->db->commit();
121
+			return $this->id;
122
+		}
123
+	}
124
+
125
+
126
+	/**
127
+	 *  Load object in memory from the database
128
+	 *
129
+	 *  @param		int		$id    	Id object
130
+	 *  @return		int			    < 0 if KO, 0 if OK but not found, > 0 if OK
131
+	 */
132
+	function fetch($id)
133
+	{
134
+		$sql = "SELECT type, description, parameters, fk_variable, update_interval, next_update, last_status";
135
+		$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
136
+		$sql.= " WHERE rowid = ".$id;
137
+
138
+		dol_syslog(get_class($this)."::fetch");
139
+		$resql=$this->db->query($sql);
140
+		if ($resql)
141
+		{
142
+			$obj = $this->db->fetch_object($resql);
143
+			if ($obj)
144
+			{
145
+				$this->id				= $id;
146
+				$this->type				= $obj->type;
147
+				$this->description		= $obj->description;
148
+				$this->parameters		= $obj->parameters;
149
+				$this->fk_variable		= $obj->fk_variable;
150
+				$this->update_interval	= $obj->update_interval;
151
+				$this->next_update		= $obj->next_update;
152
+				$this->last_status		= $obj->last_status;
153
+				$this->checkParameters();
154
+				return 1;
155
+			}
156
+			else
157
+			{
158
+				return 0;
159
+			}
160
+		}
161
+		else
162
+		{
163
+			$this->error="Error ".$this->db->lasterror();
164
+			return -1;
165
+		}
166
+	}
167
+
168
+	/**
169
+	 *  Update object into database
170
+	 *
171
+	 *  @param	User	$user        User that modifies
172
+	 *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
173
+	 *  @return int     		   	 <0 if KO, >0 if OK
174
+	 */
175
+	function update($user=0, $notrigger=0)
176
+	{
177
+		$error=0;
178
+
179
+		$this->checkParameters();
180
+
181
+		// Update request
182
+		$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
183
+		$sql.= " type = ".$this->type.",";
184
+		$sql.= " description = ".(isset($this->description)?"'".$this->db->escape($this->description)."'":"''").",";
185
+		$sql.= " parameters = ".(isset($this->parameters)?"'".$this->db->escape($this->parameters)."'":"''").",";
186
+		$sql.= " fk_variable = ".$this->fk_variable.",";
187
+		$sql.= " update_interval = ".$this->update_interval.",";
188
+		$sql.= " next_update = ".$this->next_update.",";
189
+		$sql.= " last_status = ".(isset($this->last_status)?"'".$this->db->escape($this->last_status)."'":"''");
190
+		$sql.= " WHERE rowid = ".$this->id;
191
+
192
+		$this->db->begin();
193
+
194
+		dol_syslog(get_class($this)."::update");
195
+		$resql = $this->db->query($sql);
196
+		if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
197
+
198
+		if (! $error)
199
+		{
200
+			if (! $notrigger)
201
+			{
202
+				// Uncomment this and change MYOBJECT to your own tag if you
203
+				// want this action calls a trigger.
204
+
205
+				//// Call triggers
206
+				//$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
207
+				//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
208
+				//// End call triggers
209
+			 }
210
+		}
211
+
212
+		// Commit or rollback
213
+		if ($error)
214
+		{
215
+			foreach($this->errors as $errmsg)
216
+			{
217
+				dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
218
+				$this->error.=($this->error?', '.$errmsg:$errmsg);
219
+			}
220
+			$this->db->rollback();
221
+			return -1*$error;
222
+		}
223
+		else
224
+		{
225
+			$this->db->commit();
226
+			return 1;
227
+		}
228
+	}
229
+
230
+	/**
231
+	 *  Delete object in database
232
+	 *
233
+	 * 	@param	int		$rowid		 Row id of global variable
234
+	 *	@param  User	$user        User that deletes
235
+	 *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
236
+	 *  @return	int					 <0 if KO, >0 if OK
237
+	 */
238
+	function delete($rowid, $user, $notrigger=0)
239
+	{
240
+		$error=0;
241
+
242
+		$this->db->begin();
243
+
244
+		if (! $error)
245
+		{
246
+			if (! $notrigger)
247
+			{
248
+				// Uncomment this and change MYOBJECT to your own tag if you
249
+				// want this action calls a trigger.
250
+
251
+				//// Call triggers
252
+				//$result=$this->call_trigger('MYOBJECT_DELETE',$user);
253
+				//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
254
+				//// End call triggers
255
+			}
256
+		}
257
+
258
+		if (! $error)
259
+		{
260
+			$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
261
+			$sql.= " WHERE rowid = ".$rowid;
262
+
263
+			dol_syslog(get_class($this)."::delete");
264
+			$resql = $this->db->query($sql);
265
+			if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
266
+		}
267
+
268
+		// Commit or rollback
269
+		if ($error)
270
+		{
271
+			foreach($this->errors as $errmsg)
272
+			{
273
+				dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
274
+				$this->error.=($this->error?', '.$errmsg:$errmsg);
275
+			}
276
+			$this->db->rollback();
277
+			return -1*$error;
278
+		}
279
+		else
280
+		{
281
+			$this->db->commit();
282
+			return 1;
283
+		}
284
+	}
285
+
286
+	/**
287
+	 *	Initialise object with example values
288
+	 *	Id must be 0 if object instance is a specimen
289
+	 *
290
+	 *	@return	void
291
+	 */
292
+	function initAsSpecimen()
293
+	{
294
+		$this->id=0;
295
+		$this->type=0;
296
+		$this->description='';
297
+		$this->parameters='';
298
+		$this->fk_variable=0;
299
+		$this->update_interval=0;
300
+		$this->next_update=0;
301
+		$this->last_status='';
302
+	}
303
+
304
+	/**
305
+	 *	Returns the last updated time in string html format, returns "never" if its less than 1
306
+	 *
307
+	 *	@return	string
308
+	 */
309
+	function getLastUpdated()
310
+	{
311
+		global $langs;
312
+		$last = $this->next_update - ($this->update_interval * 60);
313
+		if ($last < 1) {
314
+			return $langs->trans("Never");
315
+		}
316
+		$status = empty($this->last_status) ? $langs->trans("CorrectlyUpdated") : $this->last_status;
317
+		return $status.'<br>'.dol_print_date($last, '%d/%m/%Y %H:%M:%S');
318
+	}
319
+
320
+	/**
321
+	 *	Checks if all parameters are in order
322
+	 *
323
+	 *	@return	void
324
+	 */
325
+	function checkParameters()
326
+	{
327
+		// Clean parameters
328
+		if (isset($this->description)) $this->description=trim($this->description);
329
+		if (isset($this->parameters)) $this->parameters=trim($this->parameters);
330
+		else $this->parameters="";
331
+		if (isset($this->last_status)) $this->last_status=trim($this->last_status);
332
+
333
+		// Check parameters
334
+		if (empty($this->type) || !is_numeric($this->type) || !in_array($this->type, $this->types)) $this->type=0;
335
+		if (empty($this->update_interval) || !is_numeric($this->update_interval) || $this->update_interval < 1) $this->update_interval=$this->update_min;
336
+		if (empty($this->next_update) || !is_numeric($this->next_update) || $this->next_update < 0) $this->next_update=0;
337
+	}
338
+
339
+	/**
340
+	 *  List all price global variables
341
+	 *
342
+	 *  @return	array				Array of price global variable updaters
343
+	 */
344
+	function listUpdaters()
345
+	{
346
+		$sql = "SELECT rowid, type, description, parameters, fk_variable, update_interval, next_update, last_status";
347
+		$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
348
+
349
+		dol_syslog(get_class($this)."::listUpdaters");
350
+		$resql=$this->db->query($sql);
351
+		if ($resql)
352
+		{
353
+			$retarray = array();
354
+
355
+			while ($record = $this->db->fetch_array($resql))
356
+			{
357
+				$updater_obj = new PriceGlobalVariableUpdater($this->db);
358
+				$updater_obj->id				= $record["rowid"];
359
+				$updater_obj->type				= $record["type"];
360
+				$updater_obj->description		= $record["description"];
361
+				$updater_obj->parameters		= $record["parameters"];
362
+				$updater_obj->fk_variable		= $record["fk_variable"];
363
+				$updater_obj->update_interval	= $record["update_interval"];
364
+				$updater_obj->next_update		= $record["next_update"];
365
+				$updater_obj->last_status		= $record["last_status"];
366
+				$updater_obj->checkParameters();
367
+				$retarray[]=$updater_obj;
368
+			}
369
+
370
+			$this->db->free($resql);
371
+			return $retarray;
372
+		}
373
+		else
374
+		{
375
+			$this->error=$this->db->error();
376
+			return -1;
377
+		}
378
+	}
379
+
380
+	/**
381
+	 *  List all updaters which need to be processed
382
+	 *
383
+	 *  @return	array				Array of price global variable updaters
384
+	 */
385
+	function listPendingUpdaters()
386
+	{
387
+		$sql = "SELECT rowid, type, description, parameters, fk_variable, update_interval, next_update, last_status";
388
+		$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
389
+		$sql.= " WHERE next_update < ".dol_now();
390
+
391
+		dol_syslog(get_class($this)."::processUpdaters");
392
+		$resql=$this->db->query($sql);
393
+		if ($resql)
394
+		{
395
+			$retarray = array();
396
+
397
+			while ($record = $this->db->fetch_array($resql))
398
+			{
399
+				$updater_obj = new PriceGlobalVariableUpdater($this->db);
400
+				$updater_obj->id				= $record["rowid"];
401
+				$updater_obj->type				= $record["type"];
402
+				$updater_obj->description		= $record["description"];
403
+				$updater_obj->parameters		= $record["parameters"];
404
+				$updater_obj->fk_variable		= $record["fk_variable"];
405
+				$updater_obj->update_interval	= $record["update_interval"];
406
+				$updater_obj->next_update		= $record["next_update"];
407
+				$updater_obj->last_status		= $record["last_status"];
408
+				$updater_obj->checkParameters();
409
+				$retarray[]=$updater_obj;
410
+			}
411
+
412
+			$this->db->free($resql);
413
+			return $retarray;
414
+		}
415
+		else
416
+		{
417
+			$this->error=$this->db->error();
418
+			return -1;
419
+		}
420
+	}
421
+
422
+	/**
423
+	 *	Handles the processing of this updater
424
+	 *
425
+	 *  @return	int					 <0 if KO, 0 if OK but no global variable found, >0 if OK
426
+	 */
427
+	function process()
428
+	{
429
+		global $langs, $user;
430
+		$langs->load("errors");
431
+
432
+		$this->error = null;
433
+		$this->checkParameters();
434
+
435
+		//Try to load the target global variable and abort if fails
436
+		if ($this->fk_variable < 1) {
437
+			$this->error = $langs->trans("ErrorGlobalVariableUpdater5");
438
+			return 0;
439
+		}
440
+		$price_globals = new PriceGlobalVariable($this->db);
441
+		$res = $price_globals->fetch($this->fk_variable);
442
+		if ($res < 1) {
443
+			$this->error = $langs->trans("ErrorGlobalVariableUpdater5");
444
+			return 0;
445
+		}
446
+
447
+		//Process depending of type
448
+		if ($this->type == 0 || $this->type == 1) {
449
+			//Get and check if required parameters are present
450
+			$parameters = json_decode($this->parameters, true);
451
+			if (!isset($parameters)) {
452
+				$this->error = $langs->trans("ErrorGlobalVariableUpdater1", $this->parameters);
453
+				return -1;
454
+			}
455
+			$url = $parameters['URL'];
456
+			if (!isset($url)) {
457
+				$this->error = $langs->trans("ErrorGlobalVariableUpdater2", 'URL');
458
+				return -1;
459
+			}
460
+			$value = $parameters['VALUE'];
461
+			if (!isset($value)) {
462
+				$this->error = $langs->trans("ErrorGlobalVariableUpdater2", 'VALUE');
463
+				return -1;
464
+			}
465
+			$result = "";
466
+			if ($this->type == 0) {
467
+				// Call JSON request
468
+				include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
469
+				$tmpresult=getURLContent($url);
470
+				$code=$tmpresult['http_code'];
471
+				$result=$tmpresult['content'];
472
+
473
+				if (!isset($result)) {
474
+					$this->error = $langs->trans("ErrorGlobalVariableUpdater0", "empty response");
475
+					return -1;
476
+				}
477
+				if ($code !== 200) {
478
+					$this->error = $langs->trans("ErrorGlobalVariableUpdater0", $code.' '.$tmpresult['curl_error_msg']);
479
+					return -1;
480
+				}
481
+
482
+				//Decode returned response
483
+				$result = json_decode($result, true);
484
+			} elseif ($this->type == 1) {
485
+				$ns = $parameters['NS'];
486
+				if (!isset($ns)) {
487
+					$this->error = $langs->trans("ErrorGlobalVariableUpdater2", 'NS');
488
+					return -1;
489
+				}
490
+				$method = $parameters['METHOD'];
491
+				if (!isset($method)) {
492
+					$this->error = $langs->trans("ErrorGlobalVariableUpdater2", 'METHOD');
493
+					return -1;
494
+				}
495
+				$data = $parameters['DATA'];
496
+				if (!isset($data)) {
497
+					$this->error = $langs->trans("ErrorGlobalVariableUpdater2", 'DATA');
498
+					return -1;
499
+				}
500
+
501
+				//SOAP client
502
+				require_once NUSOAP_PATH.'/nusoap.php';
503
+				$soap_client = new nusoap_client($url);
504
+				$soap_client->soap_defencoding='UTF-8';
505
+				$soap_client->decodeUTF8(false);
506
+				$result = $soap_client->call($method, $data, $ns,'');
507
+
508
+				//Check if result is a error
509
+				if ($result === false) {
510
+					$this->error = $langs->trans("ErrorGlobalVariableUpdater4", $soap_client->error_str);
511
+					return -1;
512
+				}
513
+			}
514
+
515
+			//Explode value and walk for each key in value array to get the relevant key
516
+			$value = explode(',', $value);
517
+			foreach ($value as $key) {
518
+				$result = $result[$key];
519
+			}
520
+			if (!isset($result)) {
521
+				$this->error = $langs->trans("ErrorGlobalVariableUpdater3");
522
+				return -1;
523
+			}
524
+
525
+			//Save data to global and update it
526
+			$price_globals->value = $result;
527
+			$price_globals->update($user);
528
+		}
529
+		return 1;
530
+	}
531
+
532
+	/**
533
+	 *  Update next_update into database
534
+	 *
535
+	 *  @param	string	$next_update Next update to write
536
+	 *  @param	User	$user        User that modifies
537
+	 *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
538
+	 *  @return int     		   	 <0 if KO, >0 if OK
539
+	 */
540
+	function update_next_update($next_update, $user=0, $notrigger=0)
541
+	{
542
+		$error=0;
543
+
544
+		$this->next_update = $next_update;
545
+		$this->checkParameters();
546
+
547
+		// Update request
548
+		$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
549
+		$sql.= " next_update = ".$this->next_update;
550
+		$sql.= " WHERE rowid = ".$this->id;
551
+
552
+		$this->db->begin();
553
+
554
+		dol_syslog(get_class($this)."::update_next_update");
555
+		$resql = $this->db->query($sql);
556
+		if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
557
+
558
+		// Commit or rollback
559
+		if ($error)
560
+		{
561
+			foreach($this->errors as $errmsg)
562
+			{
563
+				dol_syslog(get_class($this)."::update_next_update ".$errmsg, LOG_ERR);
564
+				$this->error.=($this->error?', '.$errmsg:$errmsg);
565
+			}
566
+			$this->db->rollback();
567
+			return -1*$error;
568
+		}
569
+		else
570
+		{
571
+			$this->db->commit();
572
+			return 1;
573
+		}
574
+	}
575
+
576
+	/**
577
+	 *  Update last_status into database
578
+	 *
579
+	 *  @param	string	$last_status Status to write
580
+	 *  @param	User	$user        User that modifies
581
+	 *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
582
+	 *  @return int     		   	 <0 if KO, >0 if OK
583
+	 */
584
+	function update_status($last_status, $user=0, $notrigger=0)
585
+	{
586
+		$error=0;
587
+
588
+		$this->last_status = $last_status;
589
+		$this->checkParameters();
590
+
591
+		// Update request
592
+		$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
593
+		$sql.= " last_status = ".(isset($this->last_status)?"'".$this->db->escape($this->last_status)."'":"''");
594
+		$sql.= " WHERE rowid = ".$this->id;
595
+
596
+		$this->db->begin();
597
+
598
+		dol_syslog(get_class($this)."::update_status");
599
+		$resql = $this->db->query($sql);
600
+		if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
601
+
602
+		// Commit or rollback
603
+		if ($error)
604
+		{
605
+			foreach($this->errors as $errmsg)
606
+			{
607
+				dol_syslog(get_class($this)."::update_status ".$errmsg, LOG_ERR);
608
+				$this->error.=($this->error?', '.$errmsg:$errmsg);
609
+			}
610
+			$this->db->rollback();
611
+			return -1*$error;
612
+		}
613
+		else
614
+		{
615
+			$this->db->commit();
616
+			return 1;
617
+		}
618
+	}
619 619
 }
Please login to merge, or discard this patch.
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
  */
30 30
 class PriceGlobalVariableUpdater
31 31
 {
32
-    var $db;							//!< To store db handler
33
-    var $error;							//!< To return error code (or message)
34
-    var $errors=array();				//!< To return several error codes (or messages)
35
-    var $types=array(0, 1);				//!< Updater types
36
-    var $update_min = 5;				//!< Minimal update rate
32
+    var $db; //!< To store db handler
33
+    var $error; //!< To return error code (or message)
34
+    var $errors = array(); //!< To return several error codes (or messages)
35
+    var $types = array(0, 1); //!< Updater types
36
+    var $update_min = 5; //!< Minimal update rate
37 37
     var $id;
38 38
     var $type;
39 39
     var $description;
40 40
     var $parameters;
41 41
     var $fk_variable;
42
-    var $update_interval;				//!< Interval in mins
43
-    var $next_update;					//!< Next update timestamp
42
+    var $update_interval; //!< Interval in mins
43
+    var $next_update; //!< Next update timestamp
44 44
     var $last_status;
45 45
     public $table_element = "c_price_global_variable_updater";
46 46
 
@@ -63,36 +63,36 @@  discard block
 block discarded – undo
63 63
      *  @param  int		$notrigger   0=launch triggers after, 1=disable triggers
64 64
      *  @return int      		   	 <0 if KO, Id of created object if OK
65 65
      */
66
-    function create($user, $notrigger=0)
66
+    function create($user, $notrigger = 0)
67 67
     {
68
-        $error=0;
68
+        $error = 0;
69 69
 
70 70
         $this->checkParameters();
71 71
 
72 72
         // Insert request
73 73
         $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (";
74
-        $sql.= "type, description, parameters, fk_variable, update_interval, next_update, last_status";
75
-        $sql.= ") VALUES (";
76
-        $sql.= " ".$this->type.",";
77
-        $sql.= " ".(isset($this->description)?"'".$this->db->escape($this->description)."'":"''").",";
78
-        $sql.= " ".(isset($this->parameters)?"'".$this->db->escape($this->parameters)."'":"''").",";
79
-        $sql.= " ".$this->fk_variable.",";
80
-        $sql.= " ".$this->update_interval.",";
81
-        $sql.= " ".$this->next_update.",";
82
-        $sql.= " ".(isset($this->last_status)?"'".$this->db->escape($this->last_status)."'":"''");
83
-        $sql.= ")";
74
+        $sql .= "type, description, parameters, fk_variable, update_interval, next_update, last_status";
75
+        $sql .= ") VALUES (";
76
+        $sql .= " ".$this->type.",";
77
+        $sql .= " ".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "''").",";
78
+        $sql .= " ".(isset($this->parameters) ? "'".$this->db->escape($this->parameters)."'" : "''").",";
79
+        $sql .= " ".$this->fk_variable.",";
80
+        $sql .= " ".$this->update_interval.",";
81
+        $sql .= " ".$this->next_update.",";
82
+        $sql .= " ".(isset($this->last_status) ? "'".$this->db->escape($this->last_status)."'" : "''");
83
+        $sql .= ")";
84 84
 
85 85
         $this->db->begin();
86 86
 
87 87
         dol_syslog(get_class($this)."::create", LOG_DEBUG);
88
-        $resql=$this->db->query($sql);
89
-        if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
88
+        $resql = $this->db->query($sql);
89
+        if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
90 90
 
91
-        if (! $error)
91
+        if (!$error)
92 92
         {
93 93
             $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
94 94
 
95
-            if (! $notrigger)
95
+            if (!$notrigger)
96 96
             {
97 97
                 // Uncomment this and change MYOBJECT to your own tag if you
98 98
                 // want this action calls a trigger.
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
         // Commit or rollback
108 108
         if ($error)
109 109
         {
110
-            foreach($this->errors as $errmsg)
110
+            foreach ($this->errors as $errmsg)
111 111
             {
112 112
                 dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
113
-                $this->error.=($this->error?', '.$errmsg:$errmsg);
113
+                $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
114 114
             }
115 115
             $this->db->rollback();
116
-            return -1*$error;
116
+            return -1 * $error;
117 117
         }
118 118
         else
119 119
         {
@@ -132,22 +132,22 @@  discard block
 block discarded – undo
132 132
     function fetch($id)
133 133
     {
134 134
         $sql = "SELECT type, description, parameters, fk_variable, update_interval, next_update, last_status";
135
-        $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
136
-        $sql.= " WHERE rowid = ".$id;
135
+        $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
136
+        $sql .= " WHERE rowid = ".$id;
137 137
 
138 138
         dol_syslog(get_class($this)."::fetch");
139
-        $resql=$this->db->query($sql);
139
+        $resql = $this->db->query($sql);
140 140
         if ($resql)
141 141
         {
142 142
             $obj = $this->db->fetch_object($resql);
143 143
             if ($obj)
144 144
             {
145
-                $this->id				= $id;
146
-                $this->type				= $obj->type;
145
+                $this->id = $id;
146
+                $this->type = $obj->type;
147 147
                 $this->description		= $obj->description;
148
-                $this->parameters		= $obj->parameters;
148
+                $this->parameters = $obj->parameters;
149 149
                 $this->fk_variable		= $obj->fk_variable;
150
-                $this->update_interval	= $obj->update_interval;
150
+                $this->update_interval = $obj->update_interval;
151 151
                 $this->next_update		= $obj->next_update;
152 152
                 $this->last_status		= $obj->last_status;
153 153
                 $this->checkParameters();
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         }
161 161
         else
162 162
         {
163
-            $this->error="Error ".$this->db->lasterror();
163
+            $this->error = "Error ".$this->db->lasterror();
164 164
             return -1;
165 165
         }
166 166
     }
@@ -172,32 +172,32 @@  discard block
 block discarded – undo
172 172
      *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
173 173
      *  @return int     		   	 <0 if KO, >0 if OK
174 174
      */
175
-    function update($user=0, $notrigger=0)
175
+    function update($user = 0, $notrigger = 0)
176 176
     {
177
-        $error=0;
177
+        $error = 0;
178 178
 
179 179
         $this->checkParameters();
180 180
 
181 181
         // Update request
182 182
         $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
183
-        $sql.= " type = ".$this->type.",";
184
-        $sql.= " description = ".(isset($this->description)?"'".$this->db->escape($this->description)."'":"''").",";
185
-        $sql.= " parameters = ".(isset($this->parameters)?"'".$this->db->escape($this->parameters)."'":"''").",";
186
-        $sql.= " fk_variable = ".$this->fk_variable.",";
187
-        $sql.= " update_interval = ".$this->update_interval.",";
188
-        $sql.= " next_update = ".$this->next_update.",";
189
-        $sql.= " last_status = ".(isset($this->last_status)?"'".$this->db->escape($this->last_status)."'":"''");
190
-        $sql.= " WHERE rowid = ".$this->id;
183
+        $sql .= " type = ".$this->type.",";
184
+        $sql .= " description = ".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "''").",";
185
+        $sql .= " parameters = ".(isset($this->parameters) ? "'".$this->db->escape($this->parameters)."'" : "''").",";
186
+        $sql .= " fk_variable = ".$this->fk_variable.",";
187
+        $sql .= " update_interval = ".$this->update_interval.",";
188
+        $sql .= " next_update = ".$this->next_update.",";
189
+        $sql .= " last_status = ".(isset($this->last_status) ? "'".$this->db->escape($this->last_status)."'" : "''");
190
+        $sql .= " WHERE rowid = ".$this->id;
191 191
 
192 192
         $this->db->begin();
193 193
 
194 194
         dol_syslog(get_class($this)."::update");
195 195
         $resql = $this->db->query($sql);
196
-        if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
196
+        if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
197 197
 
198
-        if (! $error)
198
+        if (!$error)
199 199
         {
200
-            if (! $notrigger)
200
+            if (!$notrigger)
201 201
             {
202 202
                 // Uncomment this and change MYOBJECT to your own tag if you
203 203
                 // want this action calls a trigger.
@@ -212,13 +212,13 @@  discard block
 block discarded – undo
212 212
         // Commit or rollback
213 213
         if ($error)
214 214
         {
215
-            foreach($this->errors as $errmsg)
215
+            foreach ($this->errors as $errmsg)
216 216
             {
217 217
                 dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
218
-                $this->error.=($this->error?', '.$errmsg:$errmsg);
218
+                $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
219 219
             }
220 220
             $this->db->rollback();
221
-            return -1*$error;
221
+            return -1 * $error;
222 222
         }
223 223
         else
224 224
         {
@@ -235,15 +235,15 @@  discard block
 block discarded – undo
235 235
      *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
236 236
      *  @return	int					 <0 if KO, >0 if OK
237 237
      */
238
-    function delete($rowid, $user, $notrigger=0)
238
+    function delete($rowid, $user, $notrigger = 0)
239 239
     {
240
-        $error=0;
240
+        $error = 0;
241 241
 
242 242
         $this->db->begin();
243 243
 
244
-        if (! $error)
244
+        if (!$error)
245 245
         {
246
-            if (! $notrigger)
246
+            if (!$notrigger)
247 247
             {
248 248
                 // Uncomment this and change MYOBJECT to your own tag if you
249 249
                 // want this action calls a trigger.
@@ -255,26 +255,26 @@  discard block
 block discarded – undo
255 255
             }
256 256
         }
257 257
 
258
-        if (! $error)
258
+        if (!$error)
259 259
         {
260 260
             $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
261
-            $sql.= " WHERE rowid = ".$rowid;
261
+            $sql .= " WHERE rowid = ".$rowid;
262 262
 
263 263
             dol_syslog(get_class($this)."::delete");
264 264
             $resql = $this->db->query($sql);
265
-            if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
265
+            if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
266 266
         }
267 267
 
268 268
         // Commit or rollback
269 269
         if ($error)
270 270
         {
271
-            foreach($this->errors as $errmsg)
271
+            foreach ($this->errors as $errmsg)
272 272
             {
273 273
                 dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
274
-                $this->error.=($this->error?', '.$errmsg:$errmsg);
274
+                $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
275 275
             }
276 276
             $this->db->rollback();
277
-            return -1*$error;
277
+            return -1 * $error;
278 278
         }
279 279
         else
280 280
         {
@@ -291,14 +291,14 @@  discard block
 block discarded – undo
291 291
      */
292 292
     function initAsSpecimen()
293 293
     {
294
-        $this->id=0;
295
-        $this->type=0;
296
-        $this->description='';
297
-        $this->parameters='';
298
-        $this->fk_variable=0;
299
-        $this->update_interval=0;
300
-        $this->next_update=0;
301
-        $this->last_status='';
294
+        $this->id = 0;
295
+        $this->type = 0;
296
+        $this->description = '';
297
+        $this->parameters = '';
298
+        $this->fk_variable = 0;
299
+        $this->update_interval = 0;
300
+        $this->next_update = 0;
301
+        $this->last_status = '';
302 302
     }
303 303
 
304 304
     /**
@@ -325,15 +325,15 @@  discard block
 block discarded – undo
325 325
     function checkParameters()
326 326
     {
327 327
         // Clean parameters
328
-        if (isset($this->description)) $this->description=trim($this->description);
329
-        if (isset($this->parameters)) $this->parameters=trim($this->parameters);
330
-        else $this->parameters="";
331
-        if (isset($this->last_status)) $this->last_status=trim($this->last_status);
328
+        if (isset($this->description)) $this->description = trim($this->description);
329
+        if (isset($this->parameters)) $this->parameters = trim($this->parameters);
330
+        else $this->parameters = "";
331
+        if (isset($this->last_status)) $this->last_status = trim($this->last_status);
332 332
 
333 333
         // Check parameters
334
-        if (empty($this->type) || !is_numeric($this->type) || !in_array($this->type, $this->types)) $this->type=0;
335
-        if (empty($this->update_interval) || !is_numeric($this->update_interval) || $this->update_interval < 1) $this->update_interval=$this->update_min;
336
-        if (empty($this->next_update) || !is_numeric($this->next_update) || $this->next_update < 0) $this->next_update=0;
334
+        if (empty($this->type) || !is_numeric($this->type) || !in_array($this->type, $this->types)) $this->type = 0;
335
+        if (empty($this->update_interval) || !is_numeric($this->update_interval) || $this->update_interval < 1) $this->update_interval = $this->update_min;
336
+        if (empty($this->next_update) || !is_numeric($this->next_update) || $this->next_update < 0) $this->next_update = 0;
337 337
     }
338 338
 
339 339
     /**
@@ -344,10 +344,10 @@  discard block
 block discarded – undo
344 344
     function listUpdaters()
345 345
     {
346 346
         $sql = "SELECT rowid, type, description, parameters, fk_variable, update_interval, next_update, last_status";
347
-        $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
347
+        $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
348 348
 
349 349
         dol_syslog(get_class($this)."::listUpdaters");
350
-        $resql=$this->db->query($sql);
350
+        $resql = $this->db->query($sql);
351 351
         if ($resql)
352 352
         {
353 353
             $retarray = array();
@@ -355,16 +355,16 @@  discard block
 block discarded – undo
355 355
             while ($record = $this->db->fetch_array($resql))
356 356
             {
357 357
                 $updater_obj = new PriceGlobalVariableUpdater($this->db);
358
-                $updater_obj->id				= $record["rowid"];
359
-                $updater_obj->type				= $record["type"];
358
+                $updater_obj->id = $record["rowid"];
359
+                $updater_obj->type = $record["type"];
360 360
                 $updater_obj->description		= $record["description"];
361
-                $updater_obj->parameters		= $record["parameters"];
361
+                $updater_obj->parameters = $record["parameters"];
362 362
                 $updater_obj->fk_variable		= $record["fk_variable"];
363
-                $updater_obj->update_interval	= $record["update_interval"];
363
+                $updater_obj->update_interval = $record["update_interval"];
364 364
                 $updater_obj->next_update		= $record["next_update"];
365 365
                 $updater_obj->last_status		= $record["last_status"];
366 366
                 $updater_obj->checkParameters();
367
-                $retarray[]=$updater_obj;
367
+                $retarray[] = $updater_obj;
368 368
             }
369 369
 
370 370
             $this->db->free($resql);
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
         }
373 373
         else
374 374
         {
375
-            $this->error=$this->db->error();
375
+            $this->error = $this->db->error();
376 376
             return -1;
377 377
         }
378 378
     }
@@ -385,11 +385,11 @@  discard block
 block discarded – undo
385 385
     function listPendingUpdaters()
386 386
     {
387 387
         $sql = "SELECT rowid, type, description, parameters, fk_variable, update_interval, next_update, last_status";
388
-        $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
389
-        $sql.= " WHERE next_update < ".dol_now();
388
+        $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
389
+        $sql .= " WHERE next_update < ".dol_now();
390 390
 
391 391
         dol_syslog(get_class($this)."::processUpdaters");
392
-        $resql=$this->db->query($sql);
392
+        $resql = $this->db->query($sql);
393 393
         if ($resql)
394 394
         {
395 395
             $retarray = array();
@@ -397,16 +397,16 @@  discard block
 block discarded – undo
397 397
             while ($record = $this->db->fetch_array($resql))
398 398
             {
399 399
                 $updater_obj = new PriceGlobalVariableUpdater($this->db);
400
-                $updater_obj->id				= $record["rowid"];
401
-                $updater_obj->type				= $record["type"];
400
+                $updater_obj->id = $record["rowid"];
401
+                $updater_obj->type = $record["type"];
402 402
                 $updater_obj->description		= $record["description"];
403
-                $updater_obj->parameters		= $record["parameters"];
403
+                $updater_obj->parameters = $record["parameters"];
404 404
                 $updater_obj->fk_variable		= $record["fk_variable"];
405
-                $updater_obj->update_interval	= $record["update_interval"];
405
+                $updater_obj->update_interval = $record["update_interval"];
406 406
                 $updater_obj->next_update		= $record["next_update"];
407 407
                 $updater_obj->last_status		= $record["last_status"];
408 408
                 $updater_obj->checkParameters();
409
-                $retarray[]=$updater_obj;
409
+                $retarray[] = $updater_obj;
410 410
             }
411 411
 
412 412
             $this->db->free($resql);
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
         }
415 415
         else
416 416
         {
417
-            $this->error=$this->db->error();
417
+            $this->error = $this->db->error();
418 418
             return -1;
419 419
         }
420 420
     }
@@ -466,9 +466,9 @@  discard block
 block discarded – undo
466 466
             if ($this->type == 0) {
467 467
                 // Call JSON request
468 468
                 include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
469
-                $tmpresult=getURLContent($url);
470
-                $code=$tmpresult['http_code'];
471
-                $result=$tmpresult['content'];
469
+                $tmpresult = getURLContent($url);
470
+                $code = $tmpresult['http_code'];
471
+                $result = $tmpresult['content'];
472 472
 
473 473
                 if (!isset($result)) {
474 474
                     $this->error = $langs->trans("ErrorGlobalVariableUpdater0", "empty response");
@@ -501,9 +501,9 @@  discard block
 block discarded – undo
501 501
                 //SOAP client
502 502
                 require_once NUSOAP_PATH.'/nusoap.php';
503 503
                 $soap_client = new nusoap_client($url);
504
-                $soap_client->soap_defencoding='UTF-8';
504
+                $soap_client->soap_defencoding = 'UTF-8';
505 505
                 $soap_client->decodeUTF8(false);
506
-                $result = $soap_client->call($method, $data, $ns,'');
506
+                $result = $soap_client->call($method, $data, $ns, '');
507 507
 
508 508
                 //Check if result is a error
509 509
                 if ($result === false) {
@@ -537,34 +537,34 @@  discard block
 block discarded – undo
537 537
      *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
538 538
      *  @return int     		   	 <0 if KO, >0 if OK
539 539
      */
540
-    function update_next_update($next_update, $user=0, $notrigger=0)
540
+    function update_next_update($next_update, $user = 0, $notrigger = 0)
541 541
     {
542
-        $error=0;
542
+        $error = 0;
543 543
 
544 544
         $this->next_update = $next_update;
545 545
         $this->checkParameters();
546 546
 
547 547
         // Update request
548 548
         $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
549
-        $sql.= " next_update = ".$this->next_update;
550
-        $sql.= " WHERE rowid = ".$this->id;
549
+        $sql .= " next_update = ".$this->next_update;
550
+        $sql .= " WHERE rowid = ".$this->id;
551 551
 
552 552
         $this->db->begin();
553 553
 
554 554
         dol_syslog(get_class($this)."::update_next_update");
555 555
         $resql = $this->db->query($sql);
556
-        if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
556
+        if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
557 557
 
558 558
         // Commit or rollback
559 559
         if ($error)
560 560
         {
561
-            foreach($this->errors as $errmsg)
561
+            foreach ($this->errors as $errmsg)
562 562
             {
563 563
                 dol_syslog(get_class($this)."::update_next_update ".$errmsg, LOG_ERR);
564
-                $this->error.=($this->error?', '.$errmsg:$errmsg);
564
+                $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
565 565
             }
566 566
             $this->db->rollback();
567
-            return -1*$error;
567
+            return -1 * $error;
568 568
         }
569 569
         else
570 570
         {
@@ -581,34 +581,34 @@  discard block
 block discarded – undo
581 581
      *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
582 582
      *  @return int     		   	 <0 if KO, >0 if OK
583 583
      */
584
-    function update_status($last_status, $user=0, $notrigger=0)
584
+    function update_status($last_status, $user = 0, $notrigger = 0)
585 585
     {
586
-        $error=0;
586
+        $error = 0;
587 587
 
588 588
         $this->last_status = $last_status;
589 589
         $this->checkParameters();
590 590
 
591 591
         // Update request
592 592
         $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
593
-        $sql.= " last_status = ".(isset($this->last_status)?"'".$this->db->escape($this->last_status)."'":"''");
594
-        $sql.= " WHERE rowid = ".$this->id;
593
+        $sql .= " last_status = ".(isset($this->last_status) ? "'".$this->db->escape($this->last_status)."'" : "''");
594
+        $sql .= " WHERE rowid = ".$this->id;
595 595
 
596 596
         $this->db->begin();
597 597
 
598 598
         dol_syslog(get_class($this)."::update_status");
599 599
         $resql = $this->db->query($sql);
600
-        if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
600
+        if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
601 601
 
602 602
         // Commit or rollback
603 603
         if ($error)
604 604
         {
605
-            foreach($this->errors as $errmsg)
605
+            foreach ($this->errors as $errmsg)
606 606
             {
607 607
                 dol_syslog(get_class($this)."::update_status ".$errmsg, LOG_ERR);
608
-                $this->error.=($this->error?', '.$errmsg:$errmsg);
608
+                $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
609 609
             }
610 610
             $this->db->rollback();
611
-            return -1*$error;
611
+            return -1 * $error;
612 612
         }
613 613
         else
614 614
         {
Please login to merge, or discard this patch.
Braces   +29 added lines, -25 removed lines patch added patch discarded remove patch
@@ -114,8 +114,7 @@  discard block
 block discarded – undo
114 114
             }
115 115
             $this->db->rollback();
116 116
             return -1*$error;
117
-        }
118
-        else
117
+        } else
119 118
         {
120 119
             $this->db->commit();
121 120
             return $this->id;
@@ -152,13 +151,11 @@  discard block
 block discarded – undo
152 151
                 $this->last_status		= $obj->last_status;
153 152
                 $this->checkParameters();
154 153
                 return 1;
155
-            }
156
-            else
154
+            } else
157 155
             {
158 156
                 return 0;
159 157
             }
160
-        }
161
-        else
158
+        } else
162 159
         {
163 160
             $this->error="Error ".$this->db->lasterror();
164 161
             return -1;
@@ -219,8 +216,7 @@  discard block
 block discarded – undo
219 216
             }
220 217
             $this->db->rollback();
221 218
             return -1*$error;
222
-        }
223
-        else
219
+        } else
224 220
         {
225 221
             $this->db->commit();
226 222
             return 1;
@@ -275,8 +271,7 @@  discard block
 block discarded – undo
275 271
             }
276 272
             $this->db->rollback();
277 273
             return -1*$error;
278
-        }
279
-        else
274
+        } else
280 275
         {
281 276
             $this->db->commit();
282 277
             return 1;
@@ -325,15 +320,28 @@  discard block
 block discarded – undo
325 320
     function checkParameters()
326 321
     {
327 322
         // Clean parameters
328
-        if (isset($this->description)) $this->description=trim($this->description);
329
-        if (isset($this->parameters)) $this->parameters=trim($this->parameters);
330
-        else $this->parameters="";
331
-        if (isset($this->last_status)) $this->last_status=trim($this->last_status);
323
+        if (isset($this->description)) {
324
+        	$this->description=trim($this->description);
325
+        }
326
+        if (isset($this->parameters)) {
327
+        	$this->parameters=trim($this->parameters);
328
+        } else {
329
+        	$this->parameters="";
330
+        }
331
+        if (isset($this->last_status)) {
332
+        	$this->last_status=trim($this->last_status);
333
+        }
332 334
 
333 335
         // Check parameters
334
-        if (empty($this->type) || !is_numeric($this->type) || !in_array($this->type, $this->types)) $this->type=0;
335
-        if (empty($this->update_interval) || !is_numeric($this->update_interval) || $this->update_interval < 1) $this->update_interval=$this->update_min;
336
-        if (empty($this->next_update) || !is_numeric($this->next_update) || $this->next_update < 0) $this->next_update=0;
336
+        if (empty($this->type) || !is_numeric($this->type) || !in_array($this->type, $this->types)) {
337
+        	$this->type=0;
338
+        }
339
+        if (empty($this->update_interval) || !is_numeric($this->update_interval) || $this->update_interval < 1) {
340
+        	$this->update_interval=$this->update_min;
341
+        }
342
+        if (empty($this->next_update) || !is_numeric($this->next_update) || $this->next_update < 0) {
343
+        	$this->next_update=0;
344
+        }
337 345
     }
338 346
 
339 347
     /**
@@ -369,8 +377,7 @@  discard block
 block discarded – undo
369 377
 
370 378
             $this->db->free($resql);
371 379
             return $retarray;
372
-        }
373
-        else
380
+        } else
374 381
         {
375 382
             $this->error=$this->db->error();
376 383
             return -1;
@@ -411,8 +418,7 @@  discard block
 block discarded – undo
411 418
 
412 419
             $this->db->free($resql);
413 420
             return $retarray;
414
-        }
415
-        else
421
+        } else
416 422
         {
417 423
             $this->error=$this->db->error();
418 424
             return -1;
@@ -565,8 +571,7 @@  discard block
 block discarded – undo
565 571
             }
566 572
             $this->db->rollback();
567 573
             return -1*$error;
568
-        }
569
-        else
574
+        } else
570 575
         {
571 576
             $this->db->commit();
572 577
             return 1;
@@ -609,8 +614,7 @@  discard block
 block discarded – undo
609 614
             }
610 615
             $this->db->rollback();
611 616
             return -1*$error;
612
-        }
613
-        else
617
+        } else
614 618
         {
615 619
             $this->db->commit();
616 620
             return 1;
Please login to merge, or discard this patch.
htdocs/core/class/smtps.class.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -876,7 +876,7 @@
 block discarded – undo
876 876
 	 * addresses and to sort them by Domain.
877 877
 	 *
878 878
 	 * @param 	string 	$_type 			TO, CC, or BCC lists to add addrresses into
879
-	 * @param 	mixed 	$_addrList 		Array or COMMA delimited string of addresses
879
+	 * @param 	string 	$_addrList 		Array or COMMA delimited string of addresses
880 880
 	 * @return void
881 881
 	 *
882 882
 	 */
Please login to merge, or discard this patch.
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
 	 * Message Sensitivity
119 119
 	 */
120 120
 	var $_arySensitivity = array ( false,
121
-                                  'Personal',
122
-                                  'Private',
123
-                                  'Company Confidential' );
121
+								  'Personal',
122
+								  'Private',
123
+								  'Company Confidential' );
124 124
 
125 125
 	/**
126 126
 	 * Message Sensitivity
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 	 * Message Priority
133 133
 	 */
134 134
 	var $_aryPriority = array ( 'Bulk',
135
-                                'Highest',
136
-                                'High',
137
-                                'Normal',
138
-                                'Low',
139
-                                'Lowest' );
135
+								'Highest',
136
+								'High',
137
+								'Normal',
138
+								'Low',
139
+								'Lowest' );
140 140
 
141 141
 	/**
142 142
 	 * Content-Transfer-Encoding
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
 	 * Content-Transfer-Encoding
149 149
 	 */
150 150
 	var $_smtpsTransEncodeTypes = array( '7bit',               // Simple 7-bit ASCII
151
-                                         '8bit',               // 8-bit coding with line termination characters
152
-                                         'base64',             // 3 octets encoded into 4 sextets with offset
153
-                                         'binary',             // Arbitrary binary stream
154
-                                         'mac-binhex40',       // Macintosh binary to hex encoding
155
-                                         'quoted-printable',   // Mostly 7-bit, with 8-bit characters encoded as "=HH"
156
-                                         'uuencode' );         // UUENCODE encoding
151
+										 '8bit',               // 8-bit coding with line termination characters
152
+										 'base64',             // 3 octets encoded into 4 sextets with offset
153
+										 'binary',             // Arbitrary binary stream
154
+										 'mac-binhex40',       // Macintosh binary to hex encoding
155
+										 'quoted-printable',   // Mostly 7-bit, with 8-bit characters encoded as "=HH"
156
+										 'uuencode' );         // UUENCODE encoding
157 157
 
158 158
 	/**
159 159
 	 * Content-Transfer-Encoding
@@ -229,54 +229,54 @@  discard block
 block discarded – undo
229 229
 	var $_moreInHeader = '';
230 230
 
231 231
 
232
-    /**
233
-     * Set delivery receipt
234
-     *
235
-     * @param	int		$_val		Value
236
-     * @return	void
237
-     */
232
+	/**
233
+	 * Set delivery receipt
234
+	 *
235
+	 * @param	int		$_val		Value
236
+	 * @return	void
237
+	 */
238 238
 	function setDeliveryReceipt($_val = 0)
239 239
 	{
240 240
 		$this->_deliveryReceipt = $_val;
241 241
 	}
242 242
 
243
-    /**
244
-     * get delivery receipt
245
-     *
246
-     * @return	int		Delivery receipt
247
-     */
243
+	/**
244
+	 * get delivery receipt
245
+	 *
246
+	 * @return	int		Delivery receipt
247
+	 */
248 248
 	function getDeliveryReceipt()
249 249
 	{
250 250
 		return $this->_deliveryReceipt;
251 251
 	}
252 252
 
253
-    /**
254
-     * Set trackid
255
-     *
256
-     * @param	string		$_val		Value
257
-     * @return	void
258
-     */
253
+	/**
254
+	 * Set trackid
255
+	 *
256
+	 * @param	string		$_val		Value
257
+	 * @return	void
258
+	 */
259 259
 	function setTrackId($_val = '')
260 260
 	{
261 261
 		$this->_trackId = $_val;
262 262
 	}
263 263
 
264
-    /**
265
-     * Set moreInHeader
266
-     *
267
-     * @param	string		$_val		Value
268
-     * @return	void
269
-     */
264
+	/**
265
+	 * Set moreInHeader
266
+	 *
267
+	 * @param	string		$_val		Value
268
+	 * @return	void
269
+	 */
270 270
 	function setMoreInHeader($_val = '')
271 271
 	{
272 272
 		$this->_moreinheader = $_val;
273 273
 	}
274 274
 
275 275
 	/**
276
-     * get trackid
277
-     *
278
-     * @return	string		Track id
279
-     */
276
+	 * get trackid
277
+	 *
278
+	 * @return	string		Track id
279
+	 */
280 280
 	function getTrackId()
281 281
 	{
282 282
 		return $this->_trackId;
@@ -289,27 +289,27 @@  discard block
 block discarded – undo
289 289
 	 */
290 290
 	function getMoreInHeader()
291 291
 	{
292
-	    return $this->_moreinheader;
292
+		return $this->_moreinheader;
293 293
 	}
294 294
 
295
-    /**
296
-     * Set errors to
297
-     *
298
-     * @param	string		$_strErrorsTo		Errors to
299
-     * @return	void
300
-     */
295
+	/**
296
+	 * Set errors to
297
+	 *
298
+	 * @param	string		$_strErrorsTo		Errors to
299
+	 * @return	void
300
+	 */
301 301
 	function setErrorsTo($_strErrorsTo)
302 302
 	{
303 303
 		if ( $_strErrorsTo )
304 304
 		$this->_errorsTo = $this->_strip_email($_strErrorsTo);
305 305
 	}
306 306
 
307
-    /**
308
-     * Get errors to
309
-     *
310
-     * @param	boolean		$_part		Variant
311
-     * @return	string					Errors to
312
-     */
307
+	/**
308
+	 * Get errors to
309
+	 *
310
+	 * @param	boolean		$_part		Variant
311
+	 * @return	string					Errors to
312
+	 */
313 313
 	function getErrorsTo($_part = true )
314 314
 	{
315 315
 		$_retValue = '';
@@ -376,11 +376,11 @@  discard block
 block discarded – undo
376 376
 		{
377 377
 			//See if we can connect to the SMTP server
378 378
 			if ($this->socket = @fsockopen(
379
-    			preg_replace('@tls://@i','',$this->getHost()),       // Host to 'hit', IP or domain
380
-    			$this->getPort(),       // which Port number to use
381
-    			$this->errno,           // actual system level error
382
-    			$this->errstr,          // and any text that goes with the error
383
-    			$this->_smtpTimeout
379
+				preg_replace('@tls://@i','',$this->getHost()),       // Host to 'hit', IP or domain
380
+				$this->getPort(),       // which Port number to use
381
+				$this->errno,           // actual system level error
382
+				$this->errstr,          // and any text that goes with the error
383
+				$this->_smtpTimeout
384 384
 			))  // timeout for reading/writing data over the socket
385 385
 			{
386 386
 				// Fix from PHP SMTP class by 'Chris Ryan'
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 		{
432 432
 			if ($usetls)
433 433
 			{
434
-			    /*
434
+				/*
435 435
 			    The following dialog illustrates how a client and server can start a TLS STARTTLS session
436 436
 			    S: <waits for connection on TCP port 25>
437 437
 			    C: <opens connection>
@@ -540,13 +540,13 @@  discard block
 block discarded – undo
540 540
 				// and send it out "single file"
541 541
 				foreach ( $this->get_RCPT_list() as $_address )
542 542
 				{
543
-				    /* Note:
543
+					/* Note:
544 544
 				     * BCC email addresses must be listed in the RCPT TO command list,
545 545
                      * but the BCC header should not be printed under the DATA command.
546 546
 				     * http://stackoverflow.com/questions/2750211/sending-bcc-emails-using-a-smtp-server
547 547
 				     */
548 548
 
549
-    				/*
549
+					/*
550 550
 					 * TODO
551 551
 					 * After each 'RCPT TO:' is sent, we need to make sure it was kosher,
552 552
 					 * if not, the whole message will fail
@@ -908,8 +908,8 @@  discard block
 block discarded – undo
908 908
 	 */
909 909
 	function setReplyTo($_strReplyTo)
910 910
 	{
911
-	    if ( $_strReplyTo )
912
-	        $this->_msgReplyTo = $this->_strip_email($_strReplyTo);
911
+		if ( $_strReplyTo )
912
+			$this->_msgReplyTo = $this->_strip_email($_strReplyTo);
913 913
 	}
914 914
 
915 915
 	/**
@@ -920,14 +920,14 @@  discard block
 block discarded – undo
920 920
 	 */
921 921
 	function getReplyTo($_part = true)
922 922
 	{
923
-	    $_retValue = '';
923
+		$_retValue = '';
924 924
 
925
-	    if ( $_part === true )
926
-	        $_retValue = $this->_msgReplyTo;
927
-	    else
928
-	        $_retValue = $this->_msgReplyTo[$_part];
925
+		if ( $_part === true )
926
+			$_retValue = $this->_msgReplyTo;
927
+		else
928
+			$_retValue = $this->_msgReplyTo[$_part];
929 929
 
930
-	    return $_retValue;
930
+		return $_retValue;
931 931
 	}
932 932
 
933 933
 	/**
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 			$_header .= 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n";
1271 1271
 		}
1272 1272
 		if ( $this->getMoreInHeader() )
1273
-		    $_header .= $this->getMoreInHeader();     // Value must include the "\r\n";
1273
+			$_header .= $this->getMoreInHeader();     // Value must include the "\r\n";
1274 1274
 
1275 1275
 		//$_header .=
1276 1276
 		//                 'Read-Receipt-To: '   . $this->getFrom( 'org' ) . "\r\n"
@@ -1285,11 +1285,11 @@  discard block
 block discarded – undo
1285 1285
 
1286 1286
 		// @CHANGE LDR
1287 1287
 		if ( $this->getDeliveryReceipt() )
1288
-		    $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n";
1288
+			$_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n";
1289 1289
 		if ( $this->getErrorsTo() )
1290
-		    $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n";
1290
+			$_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n";
1291 1291
 		if ( $this->getReplyTo() )
1292
-		    $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n";
1292
+			$_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n";
1293 1293
 
1294 1294
 		$_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n";
1295 1295
 		$_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART?'MAIN_MAIL_USE_MULTI_PART':'No MAIN_MAIL_USE_MULTI_PART') . "\r\n";
@@ -1347,7 +1347,7 @@  discard block
 block discarded – undo
1347 1347
 	 */
1348 1348
 	function getBodyContent()
1349 1349
 	{
1350
-	    global $conf;
1350
+		global $conf;
1351 1351
 
1352 1352
 		// Generate a new Boundary string
1353 1353
 		$this->_setBoundary();
@@ -1467,13 +1467,13 @@  discard block
 block discarded – undo
1467 1467
 
1468 1468
 					if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART))  // Add plain text message part before html part
1469 1469
 					{
1470
-					    $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
1471
-    					$content .= "\r\n";
1472
-	       				$content .= "--" . $this->_getBoundary('alternative') . "\r\n";
1470
+						$content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
1471
+						$content .= "\r\n";
1472
+		   				$content .= "--" . $this->_getBoundary('alternative') . "\r\n";
1473 1473
 
1474
-	       				$content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n";
1475
-	       				$content.= "\r\n". $_content['dataText'] . "\r\n";
1476
-	       				$content.= "--" . $this->_getBoundary('alternative') . "\r\n";
1474
+		   				$content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n";
1475
+		   				$content.= "\r\n". $_content['dataText'] . "\r\n";
1476
+		   				$content.= "--" . $this->_getBoundary('alternative') . "\r\n";
1477 1477
 					}
1478 1478
 
1479 1479
 					$content .= 'Content-Type: ' . $_content['mimeType'] . '; '
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
 
1496 1496
 					if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART))  // Add plain text message part after html part
1497 1497
 					{
1498
-					    $content.= "--" . $this->_getBoundary('alternative') . "--". "\r\n";
1498
+						$content.= "--" . $this->_getBoundary('alternative') . "--". "\r\n";
1499 1499
 					}
1500 1500
 
1501 1501
 					$content .= "\r\n";
@@ -1722,8 +1722,8 @@  discard block
 block discarded – undo
1722 1722
 		$_retVal = true;
1723 1723
 
1724 1724
 		$server_response = '';
1725
-        // avoid infinite loop
1726
-        $limit=0;
1725
+		// avoid infinite loop
1726
+		$limit=0;
1727 1727
 
1728 1728
 		while ( substr($server_response,3,1) != ' ' && $limit<100)
1729 1729
 		{
@@ -1732,7 +1732,7 @@  discard block
 block discarded – undo
1732 1732
 				$this->_setErr(121, "Couldn't get mail server response codes");
1733 1733
 				$_retVal = false;
1734 1734
 			}
1735
-            $limit++;
1735
+			$limit++;
1736 1736
 		}
1737 1737
 
1738 1738
 		if( !( substr($server_response, 0, 3) == $response ) )
@@ -1775,7 +1775,7 @@  discard block
 block discarded – undo
1775 1775
 	function _setErr ( $_errNum, $_errMsg )
1776 1776
 	{
1777 1777
 		$this->_smtpsErrors[] = array( 'num' => $_errNum,
1778
-                                       'msg' => $_errMsg );
1778
+									   'msg' => $_errMsg );
1779 1779
 	}
1780 1780
 
1781 1781
 	/**
Please login to merge, or discard this patch.
Spacing   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 	/**
118 118
 	 * Message Sensitivity
119 119
 	 */
120
-	var $_arySensitivity = array ( false,
120
+	var $_arySensitivity = array(false,
121 121
                                   'Personal',
122 122
                                   'Private',
123
-                                  'Company Confidential' );
123
+                                  'Company Confidential');
124 124
 
125 125
 	/**
126 126
 	 * Message Sensitivity
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
 	/**
132 132
 	 * Message Priority
133 133
 	 */
134
-	var $_aryPriority = array ( 'Bulk',
134
+	var $_aryPriority = array('Bulk',
135 135
                                 'Highest',
136 136
                                 'High',
137 137
                                 'Normal',
138 138
                                 'Low',
139
-                                'Lowest' );
139
+                                'Lowest');
140 140
 
141 141
 	/**
142 142
 	 * Content-Transfer-Encoding
@@ -147,13 +147,13 @@  discard block
 block discarded – undo
147 147
 	/**
148 148
 	 * Content-Transfer-Encoding
149 149
 	 */
150
-	var $_smtpsTransEncodeTypes = array( '7bit',               // Simple 7-bit ASCII
151
-                                         '8bit',               // 8-bit coding with line termination characters
152
-                                         'base64',             // 3 octets encoded into 4 sextets with offset
153
-                                         'binary',             // Arbitrary binary stream
154
-                                         'mac-binhex40',       // Macintosh binary to hex encoding
155
-                                         'quoted-printable',   // Mostly 7-bit, with 8-bit characters encoded as "=HH"
156
-                                         'uuencode' );         // UUENCODE encoding
150
+	var $_smtpsTransEncodeTypes = array('7bit', // Simple 7-bit ASCII
151
+                                         '8bit', // 8-bit coding with line termination characters
152
+                                         'base64', // 3 octets encoded into 4 sextets with offset
153
+                                         'binary', // Arbitrary binary stream
154
+                                         'mac-binhex40', // Macintosh binary to hex encoding
155
+                                         'quoted-printable', // Mostly 7-bit, with 8-bit characters encoded as "=HH"
156
+                                         'uuencode'); // UUENCODE encoding
157 157
 
158 158
 	/**
159 159
 	 * Content-Transfer-Encoding
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
      */
301 301
 	function setErrorsTo($_strErrorsTo)
302 302
 	{
303
-		if ( $_strErrorsTo )
303
+		if ($_strErrorsTo)
304 304
 		$this->_errorsTo = $this->_strip_email($_strErrorsTo);
305 305
 	}
306 306
 
@@ -310,11 +310,11 @@  discard block
 block discarded – undo
310 310
      * @param	boolean		$_part		Variant
311 311
      * @return	string					Errors to
312 312
      */
313
-	function getErrorsTo($_part = true )
313
+	function getErrorsTo($_part = true)
314 314
 	{
315 315
 		$_retValue = '';
316 316
 
317
-		if ( $_part === true )
317
+		if ($_part === true)
318 318
 		$_retValue = $this->_errorsTo;
319 319
 		else
320 320
 		$_retValue = $this->_errorsTo[$_part];
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	 * @param	boolean		$_vDebug		Value for debug
329 329
 	 * @return 	void
330 330
 	 */
331
-	function setDebug($_vDebug = false )
331
+	function setDebug($_vDebug = false)
332 332
 	{
333 333
 		$this->_debug = $_vDebug;
334 334
 	}
@@ -357,29 +357,29 @@  discard block
 block discarded – undo
357 357
 		// We have to make sure the HOST given is valid
358 358
 		// This is done here because '@fsockopen' will not give me this
359 359
 		// information if it failes to connect because it can't find the HOST
360
-		$host=$this->getHost();
361
-		$usetls = preg_match('@tls://@i',$host);
360
+		$host = $this->getHost();
361
+		$usetls = preg_match('@tls://@i', $host);
362 362
 
363
-		$host=preg_replace('@tcp://@i','',$host);	// Remove prefix
364
-		$host=preg_replace('@ssl://@i','',$host);	// Remove prefix
365
-		$host=preg_replace('@tls://@i','',$host);	// Remove prefix
363
+		$host = preg_replace('@tcp://@i', '', $host); // Remove prefix
364
+		$host = preg_replace('@ssl://@i', '', $host); // Remove prefix
365
+		$host = preg_replace('@tls://@i', '', $host); // Remove prefix
366 366
 
367 367
 		// @CHANGE LDR
368 368
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
369 369
 
370
-		if ( (! is_ip($host)) && ((gethostbyname($host)) == $host))
370
+		if ((!is_ip($host)) && ((gethostbyname($host)) == $host))
371 371
 		{
372
-			$this->_setErr(99, $host . ' is either offline or is an invalid host name.');
372
+			$this->_setErr(99, $host.' is either offline or is an invalid host name.');
373 373
 			$_retVal = false;
374 374
 		}
375 375
 		else
376 376
 		{
377 377
 			//See if we can connect to the SMTP server
378 378
 			if ($this->socket = @fsockopen(
379
-    			preg_replace('@tls://@i','',$this->getHost()),       // Host to 'hit', IP or domain
380
-    			$this->getPort(),       // which Port number to use
381
-    			$this->errno,           // actual system level error
382
-    			$this->errstr,          // and any text that goes with the error
379
+    			preg_replace('@tls://@i', '', $this->getHost()), // Host to 'hit', IP or domain
380
+    			$this->getPort(), // which Port number to use
381
+    			$this->errno, // actual system level error
382
+    			$this->errstr, // and any text that goes with the error
383 383
     			$this->_smtpTimeout
384 384
 			))  // timeout for reading/writing data over the socket
385 385
 			{
@@ -390,14 +390,14 @@  discard block
 block discarded – undo
390 390
 				if (function_exists('stream_set_timeout')) stream_set_timeout($this->socket, $this->_smtpTimeout, 0);
391 391
 
392 392
 				// Check response from Server
393
-				if ( $_retVal = $this->server_parse($this->socket, "220") )
393
+				if ($_retVal = $this->server_parse($this->socket, "220"))
394 394
 				$_retVal = $this->socket;
395 395
 			}
396 396
 			// This connection attempt failed.
397 397
 			else
398 398
 			{
399 399
 				// @CHANGE LDR
400
-				if (empty($this->errstr)) $this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort();
400
+				if (empty($this->errstr)) $this->errstr = 'Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort();
401 401
 				$this->_setErr($this->errno, $this->errstr);
402 402
 				$_retVal = false;
403 403
 			}
@@ -418,16 +418,16 @@  discard block
 block discarded – undo
418 418
 		// Send the RFC2554 specified EHLO.
419 419
 		// This improvment as provided by 'SirSir' to
420 420
 		// accomodate both SMTP AND ESMTP capable servers
421
-		$host=$this->getHost();
422
-		$usetls = preg_match('@tls://@i',$host);
421
+		$host = $this->getHost();
422
+		$usetls = preg_match('@tls://@i', $host);
423 423
 
424
-		$host=preg_replace('@tcp://@i','',$host);	// Remove prefix
425
-		$host=preg_replace('@ssl://@i','',$host);	// Remove prefix
426
-		$host=preg_replace('@tls://@i','',$host);	// Remove prefix
424
+		$host = preg_replace('@tcp://@i', '', $host); // Remove prefix
425
+		$host = preg_replace('@ssl://@i', '', $host); // Remove prefix
426
+		$host = preg_replace('@tls://@i', '', $host); // Remove prefix
427 427
 
428
-		if ($usetls) $host='tls://'.$host;
428
+		if ($usetls) $host = 'tls://'.$host;
429 429
 
430
-		if ( $_retVal = $this->socket_send_str('EHLO ' . $host, '250') )
430
+		if ($_retVal = $this->socket_send_str('EHLO '.$host, '250'))
431 431
 		{
432 432
 			if ($usetls)
433 433
 			{
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 				// the answer with list of supported AUTH methods. They may differs between non STARTTLS and with STARTTLS.
465 465
 				if (!$_retVal = $this->socket_send_str('EHLO '.$host, '250'))
466 466
 				{
467
-					$this->_setErr(126, '"' . $host . '" does not support authenticated connections.');
467
+					$this->_setErr(126, '"'.$host.'" does not support authenticated connections.');
468 468
 					return $_retVal;
469 469
 				}
470 470
 			}
@@ -477,12 +477,12 @@  discard block
 block discarded – undo
477 477
 
478 478
 			// The error here just means the ID/password combo doesn't work.
479 479
 			// There is not a method to determine which is the problem, ID or password
480
-			if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') )
480
+			if (!$_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235'))
481 481
 			$this->_setErr(130, 'Invalid Authentication Credentials.');
482 482
 		}
483 483
 		else
484 484
 		{
485
-			$this->_setErr(126, '"' . $host . '" does not support authenticated connections.');
485
+			$this->_setErr(126, '"'.$host.'" does not support authenticated connections.');
486 486
 		}
487 487
 
488 488
 		return $_retVal;
@@ -504,10 +504,10 @@  discard block
 block discarded – undo
504 504
 		$_retVal = false;
505 505
 
506 506
 		// Connect to Server
507
-		if ( $this->socket = $this->_server_connect() )
507
+		if ($this->socket = $this->_server_connect())
508 508
 		{
509 509
 			// If a User ID *and* a password is given, assume Authentication is desired
510
-			if( !empty($this->_smtpsID) && !empty($this->_smtpsPW) )
510
+			if (!empty($this->_smtpsID) && !empty($this->_smtpsPW))
511 511
 			{
512 512
 				// Send the RFC2554 specified EHLO.
513 513
 				$_retVal = $this->_server_authenticate();
@@ -517,28 +517,28 @@  discard block
 block discarded – undo
517 517
 			else
518 518
 			{
519 519
 				// Send the RFC821 specified HELO.
520
-				$host=$this->getHost();
521
-				$usetls = preg_match('@tls://@i',$host);
520
+				$host = $this->getHost();
521
+				$usetls = preg_match('@tls://@i', $host);
522 522
 
523
-				$host=preg_replace('@tcp://@i','',$host);	// Remove prefix
524
-				$host=preg_replace('@ssl://@i','',$host);	// Remove prefix
525
-				$host=preg_replace('@tls://@i','',$host);	// Remove prefix
523
+				$host = preg_replace('@tcp://@i', '', $host); // Remove prefix
524
+				$host = preg_replace('@ssl://@i', '', $host); // Remove prefix
525
+				$host = preg_replace('@tls://@i', '', $host); // Remove prefix
526 526
 
527
-				$_retVal = $this->socket_send_str('HELO ' . $host, '250');
527
+				$_retVal = $this->socket_send_str('HELO '.$host, '250');
528 528
 			}
529 529
 
530 530
 			// Well, did we get to the server?
531
-			if ( $_retVal )
531
+			if ($_retVal)
532 532
 			{
533 533
 				// From this point onward most server response codes should be 250
534 534
 				// Specify who the mail is from....
535 535
 				// This has to be the raw email address, strip the "name" off
536
-				$this->socket_send_str('MAIL FROM: ' . $this->getFrom('addr'), '250');
536
+				$this->socket_send_str('MAIL FROM: '.$this->getFrom('addr'), '250');
537 537
 
538 538
 				// 'RCPT TO:' must be given a single address, so this has to loop
539 539
 				// through the list of addresses, regardless of TO, CC or BCC
540 540
 				// and send it out "single file"
541
-				foreach ( $this->get_RCPT_list() as $_address )
541
+				foreach ($this->get_RCPT_list() as $_address)
542 542
 				{
543 543
 				    /* Note:
544 544
 				     * BCC email addresses must be listed in the RCPT TO command list,
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 					 * mark the last address as "bad" and start the address loop over again.
555 555
 					 * If any address fails, the entire message fails.
556 556
 					 */
557
-					$this->socket_send_str('RCPT TO: <' . $_address . '>', '250');
557
+					$this->socket_send_str('RCPT TO: <'.$_address.'>', '250');
558 558
 				}
559 559
 
560 560
 				// Tell the server we are ready to start sending data
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
 
565 565
 				// Now we are ready for the message...
566 566
 				// Ok, all the ingredients are mixed in let's cook this puppy...
567
-				$this->socket_send_str($this->getHeader().$this->getBodyContent() . "\r\n" . '.', '250');
567
+				$this->socket_send_str($this->getHeader().$this->getBodyContent()."\r\n".'.', '250');
568 568
 
569 569
 				// Now tell the server we are done and close the socket...
570 570
 				fputs($this->socket, 'QUIT');
@@ -614,13 +614,13 @@  discard block
 block discarded – undo
614 614
 		$_retVal = true;
615 615
 
616 616
 		// if we have a path...
617
-		if ( ! empty ($_strConfigPath) )
617
+		if (!empty ($_strConfigPath))
618 618
 		{
619 619
 			// If the path is not valid, this will NOT generate an error,
620 620
 			// it will simply return FALSE.
621
-			if ( ! @include ( $_strConfigPath ) )
621
+			if (!@include ($_strConfigPath))
622 622
 			{
623
-				$this->_setErr(110, '"' . $_strConfigPath . '" is not a valid path.');
623
+				$this->_setErr(110, '"'.$_strConfigPath.'" is not a valid path.');
624 624
 				$_retVal = false;
625 625
 			}
626 626
 		}
@@ -630,13 +630,13 @@  discard block
 block discarded – undo
630 630
 		{
631 631
 			// Set these properties ONLY if they are set in the php.ini file.
632 632
 			// Otherwise the default values will be used.
633
-			if ( $_host = ini_get('SMTPs') )
633
+			if ($_host = ini_get('SMTPs'))
634 634
 			$this->setHost($_host);
635 635
 
636
-			if ( $_port = ini_get('smtp_port') )
636
+			if ($_port = ini_get('smtp_port'))
637 637
 			$this->setPort($_port);
638 638
 
639
-			if ( $_from = ini_get('sendmail_from') )
639
+			if ($_from = ini_get('sendmail_from'))
640 640
 			$this->setFrom($_from);
641 641
 		}
642 642
 
@@ -655,8 +655,8 @@  discard block
 block discarded – undo
655 655
 	 */
656 656
 	function setTransportType($_type = 0)
657 657
 	{
658
-		if ( ( is_numeric($_type) ) &&
659
-		( ( $_type >= 0 ) && ( $_type <= 3 ) ) )
658
+		if ((is_numeric($_type)) &&
659
+		(($_type >= 0) && ($_type <= 3)))
660 660
 		$this->_transportType = $_type;
661 661
 	}
662 662
 
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 	 */
699 699
 	function setHost($_strHost)
700 700
 	{
701
-		if ( $_strHost )
701
+		if ($_strHost)
702 702
 		$this->_smtpsHost = $_strHost;
703 703
 	}
704 704
 
@@ -723,8 +723,8 @@  discard block
 block discarded – undo
723 723
 	 */
724 724
 	function setPort($_intPort)
725 725
 	{
726
-		if ( ( is_numeric($_intPort) ) &&
727
-		( ( $_intPort >= 1 ) && ( $_intPort <= 65536 ) ) )
726
+		if ((is_numeric($_intPort)) &&
727
+		(($_intPort >= 1) && ($_intPort <= 65536)))
728 728
 		$this->_smtpsPort = $_intPort;
729 729
 	}
730 730
 
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 	 */
791 791
 	function setCharSet($_strCharSet)
792 792
 	{
793
-		if ( $_strCharSet )
793
+		if ($_strCharSet)
794 794
 		$this->_smtpsCharSet = $_strCharSet;
795 795
 	}
796 796
 
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
 	 */
879 879
 	function setFrom($_strFrom)
880 880
 	{
881
-		if ( $_strFrom )
881
+		if ($_strFrom)
882 882
 		$this->_msgFrom = $this->_strip_email($_strFrom);
883 883
 	}
884 884
 
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 	{
893 893
 		$_retValue = '';
894 894
 
895
-		if ( $_part === true )
895
+		if ($_part === true)
896 896
 		$_retValue = $this->_msgFrom;
897 897
 		else
898 898
 		$_retValue = $this->_msgFrom[$_part];
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 	 */
909 909
 	function setReplyTo($_strReplyTo)
910 910
 	{
911
-	    if ( $_strReplyTo )
911
+	    if ($_strReplyTo)
912 912
 	        $this->_msgReplyTo = $this->_strip_email($_strReplyTo);
913 913
 	}
914 914
 
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
 	{
923 923
 	    $_retValue = '';
924 924
 
925
-	    if ( $_part === true )
925
+	    if ($_part === true)
926 926
 	        $_retValue = $this->_msgReplyTo;
927 927
 	    else
928 928
 	        $_retValue = $this->_msgReplyTo[$_part];
@@ -948,13 +948,13 @@  discard block
 block discarded – undo
948 948
 		$aryHost = $this->_msgRecipients;
949 949
 
950 950
 		// Only run this if we have something
951
-		if ( !empty ($_addrList ))
951
+		if (!empty ($_addrList))
952 952
 		{
953 953
 			// $_addrList can be a STRING or an array
954
-			if ( is_string($_addrList) )
954
+			if (is_string($_addrList))
955 955
 			{
956 956
 				// This could be a COMMA delimited string
957
-				if ( strstr($_addrList, ',') )
957
+				if (strstr($_addrList, ','))
958 958
 				// "explode "list" into an array
959 959
 				$_addrList = explode(',', $_addrList);
960 960
 
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 			}
965 965
 
966 966
 			// take the array of addresses and split them further
967
-			foreach ( $_addrList as $_strAddr )
967
+			foreach ($_addrList as $_strAddr)
968 968
 			{
969 969
 				// Strip off the end '>'
970 970
 				$_strAddr = str_replace('>', '', $_strAddr);
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 				$_tmpaddr = explode('<', $_strAddr);
975 975
 
976 976
 				// We have a "Real Name" and eMail address
977
-				if ( count($_tmpaddr) == 2 )
977
+				if (count($_tmpaddr) == 2)
978 978
 				{
979 979
 					$_tmpHost = explode('@', $_tmpaddr[1]);
980 980
 					$_tmpaddr[0] = trim($_tmpaddr[0], ' ">');
@@ -1029,10 +1029,10 @@  discard block
 block discarded – undo
1029 1029
 		$_tmpAry = explode('<', $_strAddr);
1030 1030
 
1031 1031
 		// Do we have a "Real name"
1032
-		if ( count($_tmpAry) == 2 )
1032
+		if (count($_tmpAry) == 2)
1033 1033
 		{
1034 1034
 			// We may not really have a "Real Name"
1035
-			if ( $_tmpAry[0])
1035
+			if ($_tmpAry[0])
1036 1036
 			$_aryEmail['real'] = trim($_tmpAry[0], ' ">');
1037 1037
 
1038 1038
 			$_aryEmail['addr'] = $_tmpAry[1];
@@ -1041,10 +1041,10 @@  discard block
 block discarded – undo
1041 1041
 		$_aryEmail['addr'] = $_tmpAry[0];
1042 1042
 
1043 1043
 		// Pull User Name and Host.tld apart
1044
-		list($_aryEmail['user'], $_aryEmail['host'] ) = explode('@', $_aryEmail['addr']);
1044
+		list($_aryEmail['user'], $_aryEmail['host']) = explode('@', $_aryEmail['addr']);
1045 1045
 
1046 1046
 		// Put the brackets back around the address
1047
-		$_aryEmail['addr'] = '<' . $_aryEmail['addr'] . '>';
1047
+		$_aryEmail['addr'] = '<'.$_aryEmail['addr'].'>';
1048 1048
 
1049 1049
 		return $_aryEmail;
1050 1050
 	}
@@ -1061,17 +1061,17 @@  discard block
 block discarded – undo
1061 1061
 		/**
1062 1062
 		 * An array of bares addresses for use with 'RCPT TO:'
1063 1063
 		 */
1064
-		$_RCPT_list=array();
1064
+		$_RCPT_list = array();
1065 1065
 
1066 1066
 		// walk down Recipients array and pull just email addresses
1067
-		foreach ( $this->_msgRecipients as $_host => $_list )
1067
+		foreach ($this->_msgRecipients as $_host => $_list)
1068 1068
 		{
1069
-			foreach ( $_list as $_subList )
1069
+			foreach ($_list as $_subList)
1070 1070
 			{
1071
-				foreach ( $_subList as $_name => $_addr )
1071
+				foreach ($_subList as $_name => $_addr)
1072 1072
 				{
1073 1073
 					// build RCPT list
1074
-					$_RCPT_list[] = $_name . '@' . $_host;
1074
+					$_RCPT_list[] = $_name.'@'.$_host;
1075 1075
 				}
1076 1076
 			}
1077 1077
 		}
@@ -1088,27 +1088,27 @@  discard block
 block discarded – undo
1088 1088
 	function get_email_list($_which = null)
1089 1089
 	{
1090 1090
 		// We need to know which address segment to pull
1091
-		if ( $_which )
1091
+		if ($_which)
1092 1092
 		{
1093 1093
 			// Make sure we have addresses to process
1094
-			if ( $this->_msgRecipients )
1094
+			if ($this->_msgRecipients)
1095 1095
 			{
1096
-				$_RCPT_list=array();
1096
+				$_RCPT_list = array();
1097 1097
 				// walk down Recipients array and pull just email addresses
1098
-				foreach ( $this->_msgRecipients as $_host => $_list )
1098
+				foreach ($this->_msgRecipients as $_host => $_list)
1099 1099
 				{
1100
-					if ( $this->_msgRecipients[$_host][$_which] )
1100
+					if ($this->_msgRecipients[$_host][$_which])
1101 1101
 					{
1102
-						foreach ( $this->_msgRecipients[$_host][$_which] as $_addr => $_realName )
1102
+						foreach ($this->_msgRecipients[$_host][$_which] as $_addr => $_realName)
1103 1103
 						{
1104
-							if ( $_realName )	// @CHANGE LDR
1104
+							if ($_realName)	// @CHANGE LDR
1105 1105
 							{
1106
-								$_realName = '"' . $_realName . '"';
1107
-								$_RCPT_list[] = $_realName . ' <' . $_addr . '@' . $_host . '>';
1106
+								$_realName = '"'.$_realName.'"';
1107
+								$_RCPT_list[] = $_realName.' <'.$_addr.'@'.$_host.'>';
1108 1108
 							}
1109 1109
 							else
1110 1110
 							{
1111
-								$_RCPT_list[] = $_addr . '@' . $_host;
1111
+								$_RCPT_list[] = $_addr.'@'.$_host;
1112 1112
 							}
1113 1113
 						}
1114 1114
 					}
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
 	 */
1139 1139
 	function setTO($_addrTo)
1140 1140
 	{
1141
-		if ( $_addrTo )
1141
+		if ($_addrTo)
1142 1142
 		$this->_buildAddrList('to', $_addrTo);
1143 1143
 	}
1144 1144
 
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
 	 */
1161 1161
 	function setCC($_strCC)
1162 1162
 	{
1163
-		if ( $_strCC )
1163
+		if ($_strCC)
1164 1164
 		$this->_buildAddrList('cc', $_strCC);
1165 1165
 	}
1166 1166
 
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
 	 */
1183 1183
 	function setBCC($_strBCC)
1184 1184
 	{
1185
-		if ( $_strBCC )
1185
+		if ($_strBCC)
1186 1186
 		$this->_buildAddrList('bcc', $_strBCC);
1187 1187
 	}
1188 1188
 
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
 	 */
1205 1205
 	function setSubject($_strSubject = '')
1206 1206
 	{
1207
-		if ( $_strSubject )
1207
+		if ($_strSubject)
1208 1208
 		$this->_msgSubject = $_strSubject;
1209 1209
 	}
1210 1210
 
@@ -1227,11 +1227,11 @@  discard block
 block discarded – undo
1227 1227
 	{
1228 1228
 		global $conf;
1229 1229
 
1230
-		$_header = 'From: '       . $this->getFrom('org') . "\r\n"
1231
-		. 'To: '         . $this->getTO()          . "\r\n";
1230
+		$_header = 'From: '.$this->getFrom('org')."\r\n"
1231
+		. 'To: '.$this->getTO()."\r\n";
1232 1232
 
1233
-		if ( $this->getCC() )
1234
-		$_header .= 'Cc: ' . $this->getCC()  . "\r\n";
1233
+		if ($this->getCC())
1234
+		$_header .= 'Cc: '.$this->getCC()."\r\n";
1235 1235
 
1236 1236
 		/* Note:
1237 1237
 		 * BCC email addresses must be listed in the RCPT TO command list,
@@ -1244,56 +1244,56 @@  discard block
 block discarded – undo
1244 1244
 		$_header .= 'Bcc: ' . $this->getBCC()  . "\r\n";
1245 1245
         */
1246 1246
 
1247
-		$host=$this->getHost();
1248
-		$usetls = preg_match('@tls://@i',$host);
1247
+		$host = $this->getHost();
1248
+		$usetls = preg_match('@tls://@i', $host);
1249 1249
 
1250
-		$host=preg_replace('@tcp://@i','',$host);	// Remove prefix
1251
-		$host=preg_replace('@ssl://@i','',$host);	// Remove prefix
1252
-		$host=preg_replace('@tls://@i','',$host);	// Remove prefix
1250
+		$host = preg_replace('@tcp://@i', '', $host); // Remove prefix
1251
+		$host = preg_replace('@ssl://@i', '', $host); // Remove prefix
1252
+		$host = preg_replace('@tls://@i', '', $host); // Remove prefix
1253 1253
 
1254
-		$host=dol_getprefix('email');
1254
+		$host = dol_getprefix('email');
1255 1255
 
1256 1256
 		//NOTE: Message-ID should probably contain the username of the user who sent the msg
1257
-		$_header .= 'Subject: '    . $this->getSubject()     . "\r\n";
1258
-		$_header .= 'Date: '       . date("r")               . "\r\n";
1257
+		$_header .= 'Subject: '.$this->getSubject()."\r\n";
1258
+		$_header .= 'Date: '.date("r")."\r\n";
1259 1259
 
1260 1260
 		$trackid = $this->getTrackId();
1261 1261
 		if ($trackid)
1262 1262
 		{
1263 1263
 			// References is kept in response and Message-ID is returned into In-Reply-To:
1264
-			$_header .= 'Message-ID: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n";
1265
-			$_header .= 'References: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n";
1266
-			$_header .= 'X-Dolibarr-TRACKID: ' . $trackid . "\r\n";
1264
+			$_header .= 'Message-ID: <'.time().'.SMTPs-dolibarr-'.$trackid.'@'.$host.">\r\n";
1265
+			$_header .= 'References: <'.time().'.SMTPs-dolibarr-'.$trackid.'@'.$host.">\r\n";
1266
+			$_header .= 'X-Dolibarr-TRACKID: '.$trackid."\r\n";
1267 1267
 		}
1268 1268
 		else
1269 1269
 		{
1270
-			$_header .= 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n";
1270
+			$_header .= 'Message-ID: <'.time().'.SMTPs@'.$host.">\r\n";
1271 1271
 		}
1272
-		if ( $this->getMoreInHeader() )
1273
-		    $_header .= $this->getMoreInHeader();     // Value must include the "\r\n";
1272
+		if ($this->getMoreInHeader())
1273
+		    $_header .= $this->getMoreInHeader(); // Value must include the "\r\n";
1274 1274
 
1275 1275
 		//$_header .=
1276 1276
 		//                 'Read-Receipt-To: '   . $this->getFrom( 'org' ) . "\r\n"
1277 1277
 		//                 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n";
1278 1278
 
1279
-		if ( $this->getSensitivity() )
1280
-		$_header .= 'Sensitivity: ' . $this->getSensitivity()  . "\r\n";
1279
+		if ($this->getSensitivity())
1280
+		$_header .= 'Sensitivity: '.$this->getSensitivity()."\r\n";
1281 1281
 
1282
-		if ( $this->_msgPriority != 3 )
1282
+		if ($this->_msgPriority != 3)
1283 1283
 		$_header .= $this->getPriority();
1284 1284
 
1285 1285
 
1286 1286
 		// @CHANGE LDR
1287
-		if ( $this->getDeliveryReceipt() )
1288
-		    $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n";
1289
-		if ( $this->getErrorsTo() )
1290
-		    $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n";
1291
-		if ( $this->getReplyTo() )
1292
-		    $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n";
1287
+		if ($this->getDeliveryReceipt())
1288
+		    $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr')."\r\n";
1289
+		if ($this->getErrorsTo())
1290
+		    $_header .= 'Errors-To: '.$this->getErrorsTo('addr')."\r\n";
1291
+		if ($this->getReplyTo())
1292
+		    $_header .= "Reply-To: ".$this->getReplyTo('addr')."\r\n";
1293 1293
 
1294
-		$_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n";
1295
-		$_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART?'MAIN_MAIL_USE_MULTI_PART':'No MAIN_MAIL_USE_MULTI_PART') . "\r\n";
1296
-		$_header .= 'Mime-Version: 1.0' . "\r\n";
1294
+		$_header .= 'X-Mailer: Dolibarr version '.DOL_VERSION.' (using SMTPs Mailer)'."\r\n";
1295
+		$_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART ? 'MAIN_MAIL_USE_MULTI_PART' : 'No MAIN_MAIL_USE_MULTI_PART')."\r\n";
1296
+		$_header .= 'Mime-Version: 1.0'."\r\n";
1297 1297
 
1298 1298
 
1299 1299
 		return $_header;
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 	{
1311 1311
 		//if ( $strContent )
1312 1312
 		//{
1313
-		if ( $strType == 'html' )
1313
+		if ($strType == 'html')
1314 1314
 		$strMimeType = 'text/html';
1315 1315
 		else
1316 1316
 		$strMimeType = 'text/plain';
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
 
1328 1328
 		// Make RFC2045 Compliant
1329 1329
 		//$strContent = rtrim(chunk_split($strContent));    // Function chunck_split seems ko if not used on a base64 content
1330
-		$strContent = rtrim(wordwrap($strContent, 75, "\r\n"));   // TODO Using this method creates unexpected line break on text/plain content.
1330
+		$strContent = rtrim(wordwrap($strContent, 75, "\r\n")); // TODO Using this method creates unexpected line break on text/plain content.
1331 1331
 
1332 1332
 		$this->_msgContent[$strType] = array();
1333 1333
 
@@ -1335,7 +1335,7 @@  discard block
 block discarded – undo
1335 1335
 		$this->_msgContent[$strType]['data']     = $strContent;
1336 1336
 		$this->_msgContent[$strType]['dataText'] = $strContentAltText;
1337 1337
 
1338
-		if ( $this->getMD5flag() )
1338
+		if ($this->getMD5flag())
1339 1339
 		$this->_msgContent[$strType]['md5']      = dol_hash($strContent, 3);
1340 1340
 		//}
1341 1341
 	}
@@ -1359,49 +1359,49 @@  discard block
 block discarded – undo
1359 1359
 		$keyCount = count($_types);
1360 1360
 
1361 1361
 		// If we have ZERO, we have a problem
1362
-		if( $keyCount === 0 )
1362
+		if ($keyCount === 0)
1363 1363
 		die ("Sorry, no content");
1364 1364
 
1365 1365
 		// If we have ONE, we can use the simple format
1366
-		else if( $keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART))
1366
+		else if ($keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART))
1367 1367
 		{
1368 1368
 			$_msgData = $this->_msgContent;
1369 1369
 			$_msgData = $_msgData[$_types[0]];
1370 1370
 
1371
-			$content = 'Content-Type: ' . $_msgData['mimeType'] . '; charset="' . $this->getCharSet() . '"' . "\r\n"
1372
-			. 'Content-Transfer-Encoding: ' . $this->getTransEncodeType() . "\r\n"
1373
-			. 'Content-Disposition: inline'  . "\r\n"
1374
-			. 'Content-Description: message' . "\r\n";
1371
+			$content = 'Content-Type: '.$_msgData['mimeType'].'; charset="'.$this->getCharSet().'"'."\r\n"
1372
+			. 'Content-Transfer-Encoding: '.$this->getTransEncodeType()."\r\n"
1373
+			. 'Content-Disposition: inline'."\r\n"
1374
+			. 'Content-Description: message'."\r\n";
1375 1375
 
1376
-			if ( $this->getMD5flag() )
1377
-			$content .= 'Content-MD5: ' . $_msgData['md5'] . "\r\n";
1376
+			if ($this->getMD5flag())
1377
+			$content .= 'Content-MD5: '.$_msgData['md5']."\r\n";
1378 1378
 
1379 1379
 			$content .= "\r\n"
1380
-			.  $_msgData['data'] . "\r\n";
1380
+			.  $_msgData['data']."\r\n";
1381 1381
 		}
1382 1382
 
1383 1383
 		// If we have more than ONE, we use the multi-part format
1384
-		else if( $keyCount >= 1 || ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART))
1384
+		else if ($keyCount >= 1 || !empty($conf->global->MAIN_MAIL_USE_MULTI_PART))
1385 1385
 		{
1386 1386
 			// Since this is an actual multi-part message
1387 1387
 			// We need to define a content message Boundary
1388 1388
 			// NOTE: This was 'multipart/alternative', but Windows based mail servers have issues with this.
1389 1389
 
1390 1390
 			//$content = 'Content-Type: multipart/related; boundary="' . $this->_getBoundary() . '"'   . "\r\n";
1391
-			$content = 'Content-Type: multipart/mixed; boundary="' . $this->_getBoundary('mixed') . '"'   . "\r\n";
1391
+			$content = 'Content-Type: multipart/mixed; boundary="'.$this->_getBoundary('mixed').'"'."\r\n";
1392 1392
 
1393 1393
 			//                     . "\r\n"
1394 1394
 			//                     . 'This is a multi-part message in MIME format.' . "\r\n";
1395 1395
 			$content .= "Content-Transfer-Encoding: 8bit\r\n";
1396 1396
 			$content .= "\r\n";
1397 1397
 
1398
-			$content .= "--" . $this->_getBoundary('mixed') . "\r\n";
1398
+			$content .= "--".$this->_getBoundary('mixed')."\r\n";
1399 1399
 
1400 1400
 			if (key_exists('image', $this->_msgContent))     // If inline image found
1401 1401
 			{
1402
-				$content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
1402
+				$content .= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"'."\r\n";
1403 1403
 				$content .= "\r\n";
1404
-				$content .= "--" . $this->_getBoundary('alternative') . "\r\n";
1404
+				$content .= "--".$this->_getBoundary('alternative')."\r\n";
1405 1405
 			}
1406 1406
 
1407 1407
 
@@ -1409,93 +1409,93 @@  discard block
 block discarded – undo
1409 1409
 
1410 1410
 
1411 1411
 			// Loop through message content array
1412
-			foreach ($this->_msgContent as $type => $_content )
1412
+			foreach ($this->_msgContent as $type => $_content)
1413 1413
 			{
1414
-				if ( $type == 'attachment' )
1414
+				if ($type == 'attachment')
1415 1415
 				{
1416 1416
 					// loop through all attachments
1417
-					foreach ( $_content as $_file => $_data )
1417
+					foreach ($_content as $_file => $_data)
1418 1418
 					{
1419
-						$content .= "--" . $this->_getBoundary('mixed') . "\r\n"
1420
-						.  'Content-Disposition: attachment; filename="' . $_data['fileName'] . '"' . "\r\n"
1421
-						.  'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['fileName'] . '"' . "\r\n"
1422
-						.  'Content-Transfer-Encoding: base64' . "\r\n"
1423
-						.  'Content-Description: File Attachment' . "\r\n";
1419
+						$content .= "--".$this->_getBoundary('mixed')."\r\n"
1420
+						.  'Content-Disposition: attachment; filename="'.$_data['fileName'].'"'."\r\n"
1421
+						.  'Content-Type: '.$_data['mimeType'].'; name="'.$_data['fileName'].'"'."\r\n"
1422
+						.  'Content-Transfer-Encoding: base64'."\r\n"
1423
+						.  'Content-Description: File Attachment'."\r\n";
1424 1424
 
1425
-						if ( $this->getMD5flag() )
1426
-						$content .= 'Content-MD5: ' . $_data['md5'] . "\r\n";
1425
+						if ($this->getMD5flag())
1426
+						$content .= 'Content-MD5: '.$_data['md5']."\r\n";
1427 1427
 
1428
-						$content .= "\r\n" .  $_data['data'] . "\r\n\r\n";
1428
+						$content .= "\r\n".$_data['data']."\r\n\r\n";
1429 1429
 					}
1430 1430
 				}
1431 1431
 				// @CHANGE LDR
1432
-				else if ( $type == 'image' )
1432
+				else if ($type == 'image')
1433 1433
 				{
1434 1434
 					// loop through all images
1435
-					foreach ( $_content as $_image => $_data )
1435
+					foreach ($_content as $_image => $_data)
1436 1436
 					{
1437
-						$content .= "--" . $this->_getBoundary('related') . "\r\n";  // always related for an inline image
1437
+						$content .= "--".$this->_getBoundary('related')."\r\n"; // always related for an inline image
1438 1438
 
1439
-						$content .= 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['imageName'] . '"' . "\r\n"
1440
-						.  'Content-Transfer-Encoding: base64' . "\r\n"
1441
-						.  'Content-Disposition: inline; filename="' . $_data['imageName'] . '"' . "\r\n"
1442
-						.  'Content-ID: <' . $_data['cid'] . '> ' . "\r\n";
1439
+						$content .= 'Content-Type: '.$_data['mimeType'].'; name="'.$_data['imageName'].'"'."\r\n"
1440
+						.  'Content-Transfer-Encoding: base64'."\r\n"
1441
+						.  'Content-Disposition: inline; filename="'.$_data['imageName'].'"'."\r\n"
1442
+						.  'Content-ID: <'.$_data['cid'].'> '."\r\n";
1443 1443
 
1444
-						if ( $this->getMD5flag() )
1445
-						$content .= 'Content-MD5: ' . $_data['md5'] . "\r\n";
1444
+						if ($this->getMD5flag())
1445
+						$content .= 'Content-MD5: '.$_data['md5']."\r\n";
1446 1446
 
1447 1447
 						$content .= "\r\n"
1448
-						. $_data['data'] . "\r\n";
1448
+						. $_data['data']."\r\n";
1449 1449
 					}
1450 1450
 
1451 1451
 					// always end related and end alternative after inline images
1452
-					$content.= "--" . $this->_getBoundary('related') . "--" . "\r\n";
1453
-					$content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n";
1454
-					$content.= "\r\n";
1452
+					$content .= "--".$this->_getBoundary('related')."--"."\r\n";
1453
+					$content .= "\r\n"."--".$this->_getBoundary('alternative')."--"."\r\n";
1454
+					$content .= "\r\n";
1455 1455
 				}
1456 1456
 				else
1457 1457
 				{
1458 1458
 					if (key_exists('image', $this->_msgContent))
1459 1459
 					{
1460
-						$content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n";
1461
-						$content.= "\r\n" . ($_content['dataText']?$_content['dataText']:strip_tags($_content['data'])) . "\r\n"; // Add plain text message
1462
-						$content.= "--" . $this->_getBoundary('alternative') . "\r\n";
1463
-						$content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n";
1464
-						$content.= "\r\n";
1465
-						$content.= "--" . $this->_getBoundary('related') . "\r\n";
1460
+						$content .= "Content-Type: text/plain; charset=".$this->getCharSet()."\r\n";
1461
+						$content .= "\r\n".($_content['dataText'] ? $_content['dataText'] : strip_tags($_content['data']))."\r\n"; // Add plain text message
1462
+						$content .= "--".$this->_getBoundary('alternative')."\r\n";
1463
+						$content .= 'Content-Type: multipart/related; boundary="'.$this->_getBoundary('related').'"'."\r\n";
1464
+						$content .= "\r\n";
1465
+						$content .= "--".$this->_getBoundary('related')."\r\n";
1466 1466
 					}
1467 1467
 
1468
-					if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART))  // Add plain text message part before html part
1468
+					if (!key_exists('image', $this->_msgContent) && $_content['dataText'] && !empty($conf->global->MAIN_MAIL_USE_MULTI_PART))  // Add plain text message part before html part
1469 1469
 					{
1470
-					    $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
1470
+					    $content .= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"'."\r\n";
1471 1471
     					$content .= "\r\n";
1472
-	       				$content .= "--" . $this->_getBoundary('alternative') . "\r\n";
1472
+	       				$content .= "--".$this->_getBoundary('alternative')."\r\n";
1473 1473
 
1474
-	       				$content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n";
1475
-	       				$content.= "\r\n". $_content['dataText'] . "\r\n";
1476
-	       				$content.= "--" . $this->_getBoundary('alternative') . "\r\n";
1474
+	       				$content .= "Content-Type: text/plain; charset=".$this->getCharSet()."\r\n";
1475
+	       				$content .= "\r\n".$_content['dataText']."\r\n";
1476
+	       				$content .= "--".$this->_getBoundary('alternative')."\r\n";
1477 1477
 					}
1478 1478
 
1479
-					$content .= 'Content-Type: ' . $_content['mimeType'] . '; '
1479
+					$content .= 'Content-Type: '.$_content['mimeType'].'; '
1480 1480
 					//                             . 'charset="' . $this->getCharSet() . '"';
1481
-					. 'charset=' . $this->getCharSet() . '';
1481
+					. 'charset='.$this->getCharSet().'';
1482 1482
 
1483 1483
 					//                    $content .= ( $type == 'html') ? '; name="HTML Part"' : '';
1484
-					$content .=  "\r\n";
1484
+					$content .= "\r\n";
1485 1485
 					//                    $content .= 'Content-Transfer-Encoding: ';
1486 1486
 					//                    $content .= ($type == 'html') ? 'quoted-printable' : $this->getTransEncodeType();
1487 1487
 					//                    $content .=  "\r\n"
1488 1488
 					//                             . 'Content-Disposition: inline'  . "\r\n"
1489 1489
 					//                             . 'Content-Description: ' . $type . ' message' . "\r\n";
1490 1490
 
1491
-					if ( $this->getMD5flag() )
1492
-					$content .= 'Content-MD5: ' . $_content['md5'] . "\r\n";
1491
+					if ($this->getMD5flag())
1492
+					$content .= 'Content-MD5: '.$_content['md5']."\r\n";
1493 1493
 
1494
-					$content .= "\r\n"	. $_content['data'] . "\r\n";
1494
+					$content .= "\r\n".$_content['data']."\r\n";
1495 1495
 
1496
-					if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART))  // Add plain text message part after html part
1496
+					if (!key_exists('image', $this->_msgContent) && $_content['dataText'] && !empty($conf->global->MAIN_MAIL_USE_MULTI_PART))  // Add plain text message part after html part
1497 1497
 					{
1498
-					    $content.= "--" . $this->_getBoundary('alternative') . "--". "\r\n";
1498
+					    $content .= "--".$this->_getBoundary('alternative')."--"."\r\n";
1499 1499
 					}
1500 1500
 
1501 1501
 					$content .= "\r\n";
@@ -1504,7 +1504,7 @@  discard block
 block discarded – undo
1504 1504
 
1505 1505
 			// Close message boundries
1506 1506
 			//            $content .= "\r\n--" . $this->_getBoundary() . '--' . "\r\n" ;
1507
-			$content .= "--" . $this->_getBoundary('mixed') . '--' . "\r\n" ;
1507
+			$content .= "--".$this->_getBoundary('mixed').'--'."\r\n";
1508 1508
 		}
1509 1509
 
1510 1510
 		return $content;
@@ -1521,15 +1521,15 @@  discard block
 block discarded – undo
1521 1521
 	 */
1522 1522
 	function setAttachment($strContent, $strFileName = 'unknown', $strMimeType = 'unknown')
1523 1523
 	{
1524
-		if ( $strContent )
1524
+		if ($strContent)
1525 1525
 		{
1526
-			$strContent = rtrim(chunk_split(base64_encode($strContent), 76, "\r\n"));    // 76 max is defined into http://tools.ietf.org/html/rfc2047
1526
+			$strContent = rtrim(chunk_split(base64_encode($strContent), 76, "\r\n")); // 76 max is defined into http://tools.ietf.org/html/rfc2047
1527 1527
 
1528 1528
 			$this->_msgContent['attachment'][$strFileName]['mimeType'] = $strMimeType;
1529 1529
 			$this->_msgContent['attachment'][$strFileName]['fileName'] = $strFileName;
1530 1530
 			$this->_msgContent['attachment'][$strFileName]['data']     = $strContent;
1531 1531
 
1532
-			if ( $this->getMD5flag() )
1532
+			if ($this->getMD5flag())
1533 1533
 			$this->_msgContent['attachment'][$strFileName]['md5']      = dol_hash($strContent, 3);
1534 1534
 		}
1535 1535
 	}
@@ -1556,7 +1556,7 @@  discard block
 block discarded – undo
1556 1556
 			$this->_msgContent['image'][$strImageName]['cid']      = $strImageCid;
1557 1557
 			$this->_msgContent['image'][$strImageName]['data']     = $strContent;
1558 1558
 
1559
-			if ( $this->getMD5flag() )
1559
+			if ($this->getMD5flag())
1560 1560
 			$this->_msgContent['image'][$strImageName]['md5']      = dol_hash($strContent, 3);
1561 1561
 		}
1562 1562
 	}
@@ -1576,8 +1576,8 @@  discard block
 block discarded – undo
1576 1576
 	 */
1577 1577
 	function setSensitivity($_value = 0)
1578 1578
 	{
1579
-		if ( ( is_numeric($_value) ) &&
1580
-		( ( $_value >= 0 ) && ( $_value <= 3 ) ) )
1579
+		if ((is_numeric($_value)) &&
1580
+		(($_value >= 0) && ($_value <= 3)))
1581 1581
 		$this->_msgSensitivity = $_value;
1582 1582
 	}
1583 1583
 
@@ -1609,10 +1609,10 @@  discard block
 block discarded – undo
1609 1609
 	 * @param 	integer 	$_value 	Message Priority
1610 1610
 	 * @return 	void
1611 1611
 	 */
1612
-	function setPriority ( $_value = 3 )
1612
+	function setPriority($_value = 3)
1613 1613
 	{
1614
-		if ( ( is_numeric($_value) ) &&
1615
-		( ( $_value >= 0 ) && ( $_value <= 5 ) ) )
1614
+		if ((is_numeric($_value)) &&
1615
+		(($_value >= 0) && ($_value <= 5)))
1616 1616
 		$this->_msgPriority = $_value;
1617 1617
 	}
1618 1618
 
@@ -1630,9 +1630,9 @@  discard block
 block discarded – undo
1630 1630
 	 */
1631 1631
 	function getPriority()
1632 1632
 	{
1633
-		return 'Importance: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n"
1634
-		. 'Priority: '   . $this->_aryPriority[$this->_msgPriority] . "\r\n"
1635
-		. 'X-Priority: ' . $this->_msgPriority . ' (' . $this->_aryPriority[$this->_msgPriority] . ')' . "\r\n";
1633
+		return 'Importance: '.$this->_aryPriority[$this->_msgPriority]."\r\n"
1634
+		. 'Priority: '.$this->_aryPriority[$this->_msgPriority]."\r\n"
1635
+		. 'X-Priority: '.$this->_msgPriority.' ('.$this->_aryPriority[$this->_msgPriority].')'."\r\n";
1636 1636
 	}
1637 1637
 
1638 1638
 	/**
@@ -1666,7 +1666,7 @@  discard block
 block discarded – undo
1666 1666
 	 */
1667 1667
 	function setXheader($strXdata)
1668 1668
 	{
1669
-		if ( $strXdata )
1669
+		if ($strXdata)
1670 1670
 		$this->_msgXheader[] = $strXdata;
1671 1671
 	}
1672 1672
 
@@ -1687,7 +1687,7 @@  discard block
 block discarded – undo
1687 1687
 	 */
1688 1688
 	function _setBoundary()
1689 1689
 	{
1690
-		$this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary";
1690
+		$this->_smtpsBoundary = "multipart_x.".time().".x_boundary";
1691 1691
 		$this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2"), 3);
1692 1692
 		$this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3);
1693 1693
 	}
@@ -1698,7 +1698,7 @@  discard block
 block discarded – undo
1698 1698
 	 * @param  string $type				Type of boundary
1699 1699
 	 * @return string $_smtpsBoundary 	MIME message Boundary
1700 1700
 	 */
1701
-	function _getBoundary($type='mixed')
1701
+	function _getBoundary($type = 'mixed')
1702 1702
 	{
1703 1703
 		if ($type == 'mixed') return $this->_smtpsBoundary;
1704 1704
 		else if ($type == 'related') return $this->_smtpsRelatedBoundary;
@@ -1723,11 +1723,11 @@  discard block
 block discarded – undo
1723 1723
 
1724 1724
 		$server_response = '';
1725 1725
         // avoid infinite loop
1726
-        $limit=0;
1726
+        $limit = 0;
1727 1727
 
1728
-		while ( substr($server_response,3,1) != ' ' && $limit<100)
1728
+		while (substr($server_response, 3, 1) != ' ' && $limit < 100)
1729 1729
 		{
1730
-			if( !( $server_response = fgets($socket, 256) ) )
1730
+			if (!($server_response = fgets($socket, 256)))
1731 1731
 			{
1732 1732
 				$this->_setErr(121, "Couldn't get mail server response codes");
1733 1733
 				$_retVal = false;
@@ -1735,7 +1735,7 @@  discard block
 block discarded – undo
1735 1735
             $limit++;
1736 1736
 		}
1737 1737
 
1738
-		if( !( substr($server_response, 0, 3) == $response ) )
1738
+		if (!(substr($server_response, 0, 3) == $response))
1739 1739
 		{
1740 1740
 			$this->_setErr(120, "Ran into problems sending Mail.\r\nResponse: $server_response");
1741 1741
 			$_retVal = false;
@@ -1752,13 +1752,13 @@  discard block
 block discarded – undo
1752 1752
 	 * @param 	string		$CRLF			CRLF
1753 1753
 	 * @return 	boolean|null						True or false
1754 1754
 	 */
1755
-	function socket_send_str( $_strSend, $_returnCode = null, $CRLF = "\r\n" )
1755
+	function socket_send_str($_strSend, $_returnCode = null, $CRLF = "\r\n")
1756 1756
 	{
1757
-		if ($this->_debug) $this->log.=$_strSend;	// @CHANGE LDR for log
1758
-		fputs($this->socket, $_strSend . $CRLF);
1759
-		if ($this->_debug) $this->log.=' ('.$_returnCode.')' . $CRLF;
1757
+		if ($this->_debug) $this->log .= $_strSend; // @CHANGE LDR for log
1758
+		fputs($this->socket, $_strSend.$CRLF);
1759
+		if ($this->_debug) $this->log .= ' ('.$_returnCode.')'.$CRLF;
1760 1760
 
1761
-		if ( $_returnCode )
1761
+		if ($_returnCode)
1762 1762
 		return $this->server_parse($this->socket, $_returnCode);
1763 1763
 	}
1764 1764
 
@@ -1772,10 +1772,10 @@  discard block
 block discarded – undo
1772 1772
 	 * @param  string $_errMsg  Error Message
1773 1773
 	 * @return void
1774 1774
 	 */
1775
-	function _setErr ( $_errNum, $_errMsg )
1775
+	function _setErr($_errNum, $_errMsg)
1776 1776
 	{
1777
-		$this->_smtpsErrors[] = array( 'num' => $_errNum,
1778
-                                       'msg' => $_errMsg );
1777
+		$this->_smtpsErrors[] = array('num' => $_errNum,
1778
+                                       'msg' => $_errMsg);
1779 1779
 	}
1780 1780
 
1781 1781
 	/**
@@ -1787,9 +1787,9 @@  discard block
 block discarded – undo
1787 1787
 	{
1788 1788
 		$_errMsg = array();
1789 1789
 
1790
-		foreach ( $this->_smtpsErrors as $_err => $_info )
1790
+		foreach ($this->_smtpsErrors as $_err => $_info)
1791 1791
 		{
1792
-			$_errMsg[] = 'Error [' . $_info['num'] .']: '. $_info['msg'];
1792
+			$_errMsg[] = 'Error ['.$_info['num'].']: '.$_info['msg'];
1793 1793
 		}
1794 1794
 
1795 1795
 		return implode("\n", $_errMsg);
Please login to merge, or discard this patch.
Braces   +185 added lines, -124 removed lines patch added patch discarded remove patch
@@ -300,8 +300,9 @@  discard block
 block discarded – undo
300 300
      */
301 301
 	function setErrorsTo($_strErrorsTo)
302 302
 	{
303
-		if ( $_strErrorsTo )
304
-		$this->_errorsTo = $this->_strip_email($_strErrorsTo);
303
+		if ( $_strErrorsTo ) {
304
+				$this->_errorsTo = $this->_strip_email($_strErrorsTo);
305
+		}
305 306
 	}
306 307
 
307 308
     /**
@@ -314,10 +315,11 @@  discard block
 block discarded – undo
314 315
 	{
315 316
 		$_retValue = '';
316 317
 
317
-		if ( $_part === true )
318
-		$_retValue = $this->_errorsTo;
319
-		else
320
-		$_retValue = $this->_errorsTo[$_part];
318
+		if ( $_part === true ) {
319
+				$_retValue = $this->_errorsTo;
320
+		} else {
321
+				$_retValue = $this->_errorsTo[$_part];
322
+		}
321 323
 
322 324
 		return $_retValue;
323 325
 	}
@@ -371,8 +373,7 @@  discard block
 block discarded – undo
371 373
 		{
372 374
 			$this->_setErr(99, $host . ' is either offline or is an invalid host name.');
373 375
 			$_retVal = false;
374
-		}
375
-		else
376
+		} else
376 377
 		{
377 378
 			//See if we can connect to the SMTP server
378 379
 			if ($this->socket = @fsockopen(
@@ -381,23 +382,28 @@  discard block
 block discarded – undo
381 382
     			$this->errno,           // actual system level error
382 383
     			$this->errstr,          // and any text that goes with the error
383 384
     			$this->_smtpTimeout
384
-			))  // timeout for reading/writing data over the socket
385
+			)) {
386
+				// timeout for reading/writing data over the socket
385 387
 			{
386 388
 				// Fix from PHP SMTP class by 'Chris Ryan'
387 389
 				// Sometimes the SMTP server takes a little longer to respond
388 390
 				// so we will give it a longer timeout for the first read
389 391
 				// Windows still does not have support for this timeout function
390 392
 				if (function_exists('stream_set_timeout')) stream_set_timeout($this->socket, $this->_smtpTimeout, 0);
393
+			}
391 394
 
392 395
 				// Check response from Server
393
-				if ( $_retVal = $this->server_parse($this->socket, "220") )
394
-				$_retVal = $this->socket;
396
+				if ( $_retVal = $this->server_parse($this->socket, "220") ) {
397
+								$_retVal = $this->socket;
398
+				}
395 399
 			}
396 400
 			// This connection attempt failed.
397 401
 			else
398 402
 			{
399 403
 				// @CHANGE LDR
400
-				if (empty($this->errstr)) $this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort();
404
+				if (empty($this->errstr)) {
405
+					$this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort();
406
+				}
401 407
 				$this->_setErr($this->errno, $this->errstr);
402 408
 				$_retVal = false;
403 409
 			}
@@ -425,7 +431,9 @@  discard block
 block discarded – undo
425 431
 		$host=preg_replace('@ssl://@i','',$host);	// Remove prefix
426 432
 		$host=preg_replace('@tls://@i','',$host);	// Remove prefix
427 433
 
428
-		if ($usetls) $host='tls://'.$host;
434
+		if ($usetls) {
435
+			$host='tls://'.$host;
436
+		}
429 437
 
430 438
 		if ( $_retVal = $this->socket_send_str('EHLO ' . $host, '250') )
431 439
 		{
@@ -477,10 +485,10 @@  discard block
 block discarded – undo
477 485
 
478 486
 			// The error here just means the ID/password combo doesn't work.
479 487
 			// There is not a method to determine which is the problem, ID or password
480
-			if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') )
481
-			$this->_setErr(130, 'Invalid Authentication Credentials.');
482
-		}
483
-		else
488
+			if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') ) {
489
+						$this->_setErr(130, 'Invalid Authentication Credentials.');
490
+			}
491
+		} else
484 492
 		{
485 493
 			$this->_setErr(126, '"' . $host . '" does not support authenticated connections.');
486 494
 		}
@@ -630,14 +638,17 @@  discard block
 block discarded – undo
630 638
 		{
631 639
 			// Set these properties ONLY if they are set in the php.ini file.
632 640
 			// Otherwise the default values will be used.
633
-			if ( $_host = ini_get('SMTPs') )
634
-			$this->setHost($_host);
641
+			if ( $_host = ini_get('SMTPs') ) {
642
+						$this->setHost($_host);
643
+			}
635 644
 
636
-			if ( $_port = ini_get('smtp_port') )
637
-			$this->setPort($_port);
645
+			if ( $_port = ini_get('smtp_port') ) {
646
+						$this->setPort($_port);
647
+			}
638 648
 
639
-			if ( $_from = ini_get('sendmail_from') )
640
-			$this->setFrom($_from);
649
+			if ( $_from = ini_get('sendmail_from') ) {
650
+						$this->setFrom($_from);
651
+			}
641 652
 		}
642 653
 
643 654
 		// Send back what we have
@@ -656,8 +667,9 @@  discard block
 block discarded – undo
656 667
 	function setTransportType($_type = 0)
657 668
 	{
658 669
 		if ( ( is_numeric($_type) ) &&
659
-		( ( $_type >= 0 ) && ( $_type <= 3 ) ) )
660
-		$this->_transportType = $_type;
670
+		( ( $_type >= 0 ) && ( $_type <= 3 ) ) ) {
671
+				$this->_transportType = $_type;
672
+		}
661 673
 	}
662 674
 
663 675
 	/**
@@ -698,8 +710,9 @@  discard block
 block discarded – undo
698 710
 	 */
699 711
 	function setHost($_strHost)
700 712
 	{
701
-		if ( $_strHost )
702
-		$this->_smtpsHost = $_strHost;
713
+		if ( $_strHost ) {
714
+				$this->_smtpsHost = $_strHost;
715
+		}
703 716
 	}
704 717
 
705 718
 	/**
@@ -724,8 +737,9 @@  discard block
 block discarded – undo
724 737
 	function setPort($_intPort)
725 738
 	{
726 739
 		if ( ( is_numeric($_intPort) ) &&
727
-		( ( $_intPort >= 1 ) && ( $_intPort <= 65536 ) ) )
728
-		$this->_smtpsPort = $_intPort;
740
+		( ( $_intPort >= 1 ) && ( $_intPort <= 65536 ) ) ) {
741
+				$this->_smtpsPort = $_intPort;
742
+		}
729 743
 	}
730 744
 
731 745
 	/**
@@ -790,8 +804,9 @@  discard block
 block discarded – undo
790 804
 	 */
791 805
 	function setCharSet($_strCharSet)
792 806
 	{
793
-		if ( $_strCharSet )
794
-		$this->_smtpsCharSet = $_strCharSet;
807
+		if ( $_strCharSet ) {
808
+				$this->_smtpsCharSet = $_strCharSet;
809
+		}
795 810
 	}
796 811
 
797 812
 	/**
@@ -821,8 +836,9 @@  discard block
 block discarded – undo
821 836
 	 */
822 837
 	function setTransEncode($_strTransEncode)
823 838
 	{
824
-		if (array_search($_strTransEncode, $this->_smtpsTransEncodeTypes))
825
-		$this->_smtpsTransEncode = $_strTransEncode;
839
+		if (array_search($_strTransEncode, $this->_smtpsTransEncodeTypes)) {
840
+				$this->_smtpsTransEncode = $_strTransEncode;
841
+		}
826 842
 	}
827 843
 
828 844
 	/**
@@ -853,8 +869,9 @@  discard block
 block discarded – undo
853 869
 	 */
854 870
 	function setTransEncodeType($_strTransEncodeType)
855 871
 	{
856
-		if (array_search($_strTransEncodeType, $this->_smtpsTransEncodeTypes))
857
-		$this->_smtpsTransEncodeType = $_strTransEncodeType;
872
+		if (array_search($_strTransEncodeType, $this->_smtpsTransEncodeTypes)) {
873
+				$this->_smtpsTransEncodeType = $_strTransEncodeType;
874
+		}
858 875
 	}
859 876
 
860 877
 	/**
@@ -878,8 +895,9 @@  discard block
 block discarded – undo
878 895
 	 */
879 896
 	function setFrom($_strFrom)
880 897
 	{
881
-		if ( $_strFrom )
882
-		$this->_msgFrom = $this->_strip_email($_strFrom);
898
+		if ( $_strFrom ) {
899
+				$this->_msgFrom = $this->_strip_email($_strFrom);
900
+		}
883 901
 	}
884 902
 
885 903
 	/**
@@ -892,10 +910,11 @@  discard block
 block discarded – undo
892 910
 	{
893 911
 		$_retValue = '';
894 912
 
895
-		if ( $_part === true )
896
-		$_retValue = $this->_msgFrom;
897
-		else
898
-		$_retValue = $this->_msgFrom[$_part];
913
+		if ( $_part === true ) {
914
+				$_retValue = $this->_msgFrom;
915
+		} else {
916
+				$_retValue = $this->_msgFrom[$_part];
917
+		}
899 918
 
900 919
 		return $_retValue;
901 920
 	}
@@ -908,8 +927,9 @@  discard block
 block discarded – undo
908 927
 	 */
909 928
 	function setReplyTo($_strReplyTo)
910 929
 	{
911
-	    if ( $_strReplyTo )
912
-	        $this->_msgReplyTo = $this->_strip_email($_strReplyTo);
930
+	    if ( $_strReplyTo ) {
931
+	    	        $this->_msgReplyTo = $this->_strip_email($_strReplyTo);
932
+	    }
913 933
 	}
914 934
 
915 935
 	/**
@@ -922,10 +942,11 @@  discard block
 block discarded – undo
922 942
 	{
923 943
 	    $_retValue = '';
924 944
 
925
-	    if ( $_part === true )
926
-	        $_retValue = $this->_msgReplyTo;
927
-	    else
928
-	        $_retValue = $this->_msgReplyTo[$_part];
945
+	    if ( $_part === true ) {
946
+	    	        $_retValue = $this->_msgReplyTo;
947
+	    } else {
948
+	    	        $_retValue = $this->_msgReplyTo[$_part];
949
+	    }
929 950
 
930 951
 	    return $_retValue;
931 952
 	}
@@ -954,13 +975,15 @@  discard block
 block discarded – undo
954 975
 			if ( is_string($_addrList) )
955 976
 			{
956 977
 				// This could be a COMMA delimited string
957
-				if ( strstr($_addrList, ',') )
958
-				// "explode "list" into an array
978
+				if ( strstr($_addrList, ',') ) {
979
+								// "explode "list" into an array
959 980
 				$_addrList = explode(',', $_addrList);
981
+				}
960 982
 
961 983
 				// Stick it in an array
962
-				else
963
-				$_addrList = array($_addrList);
984
+				else {
985
+								$_addrList = array($_addrList);
986
+				}
964 987
 			}
965 988
 
966 989
 			// take the array of addresses and split them further
@@ -1032,13 +1055,14 @@  discard block
 block discarded – undo
1032 1055
 		if ( count($_tmpAry) == 2 )
1033 1056
 		{
1034 1057
 			// We may not really have a "Real Name"
1035
-			if ( $_tmpAry[0])
1036
-			$_aryEmail['real'] = trim($_tmpAry[0], ' ">');
1058
+			if ( $_tmpAry[0]) {
1059
+						$_aryEmail['real'] = trim($_tmpAry[0], ' ">');
1060
+			}
1037 1061
 
1038 1062
 			$_aryEmail['addr'] = $_tmpAry[1];
1063
+		} else {
1064
+				$_aryEmail['addr'] = $_tmpAry[0];
1039 1065
 		}
1040
-		else
1041
-		$_aryEmail['addr'] = $_tmpAry[0];
1042 1066
 
1043 1067
 		// Pull User Name and Host.tld apart
1044 1068
 		list($_aryEmail['user'], $_aryEmail['host'] ) = explode('@', $_aryEmail['addr']);
@@ -1101,12 +1125,13 @@  discard block
 block discarded – undo
1101 1125
 					{
1102 1126
 						foreach ( $this->_msgRecipients[$_host][$_which] as $_addr => $_realName )
1103 1127
 						{
1104
-							if ( $_realName )	// @CHANGE LDR
1128
+							if ( $_realName ) {
1129
+								// @CHANGE LDR
1105 1130
 							{
1106 1131
 								$_realName = '"' . $_realName . '"';
1107
-								$_RCPT_list[] = $_realName . ' <' . $_addr . '@' . $_host . '>';
1108 1132
 							}
1109
-							else
1133
+								$_RCPT_list[] = $_realName . ' <' . $_addr . '@' . $_host . '>';
1134
+							} else
1110 1135
 							{
1111 1136
 								$_RCPT_list[] = $_addr . '@' . $_host;
1112 1137
 							}
@@ -1115,14 +1140,12 @@  discard block
 block discarded – undo
1115 1140
 				}
1116 1141
 
1117 1142
 				return implode(', ', $_RCPT_list);
1118
-			}
1119
-			else
1143
+			} else
1120 1144
 			{
1121 1145
 				$this->_setErr(101, 'No eMail Address for message to be sent to.');
1122 1146
 				return false;
1123 1147
 			}
1124
-		}
1125
-		else
1148
+		} else
1126 1149
 		{
1127 1150
 			$this->_setErr(102, 'eMail type not defined.');
1128 1151
 			return false;
@@ -1138,8 +1161,9 @@  discard block
 block discarded – undo
1138 1161
 	 */
1139 1162
 	function setTO($_addrTo)
1140 1163
 	{
1141
-		if ( $_addrTo )
1142
-		$this->_buildAddrList('to', $_addrTo);
1164
+		if ( $_addrTo ) {
1165
+				$this->_buildAddrList('to', $_addrTo);
1166
+		}
1143 1167
 	}
1144 1168
 
1145 1169
 	/**
@@ -1160,8 +1184,9 @@  discard block
 block discarded – undo
1160 1184
 	 */
1161 1185
 	function setCC($_strCC)
1162 1186
 	{
1163
-		if ( $_strCC )
1164
-		$this->_buildAddrList('cc', $_strCC);
1187
+		if ( $_strCC ) {
1188
+				$this->_buildAddrList('cc', $_strCC);
1189
+		}
1165 1190
 	}
1166 1191
 
1167 1192
 	/**
@@ -1182,8 +1207,9 @@  discard block
 block discarded – undo
1182 1207
 	 */
1183 1208
 	function setBCC($_strBCC)
1184 1209
 	{
1185
-		if ( $_strBCC )
1186
-		$this->_buildAddrList('bcc', $_strBCC);
1210
+		if ( $_strBCC ) {
1211
+				$this->_buildAddrList('bcc', $_strBCC);
1212
+		}
1187 1213
 	}
1188 1214
 
1189 1215
 	/**
@@ -1204,8 +1230,9 @@  discard block
 block discarded – undo
1204 1230
 	 */
1205 1231
 	function setSubject($_strSubject = '')
1206 1232
 	{
1207
-		if ( $_strSubject )
1208
-		$this->_msgSubject = $_strSubject;
1233
+		if ( $_strSubject ) {
1234
+				$this->_msgSubject = $_strSubject;
1235
+		}
1209 1236
 	}
1210 1237
 
1211 1238
 	/**
@@ -1230,8 +1257,9 @@  discard block
 block discarded – undo
1230 1257
 		$_header = 'From: '       . $this->getFrom('org') . "\r\n"
1231 1258
 		. 'To: '         . $this->getTO()          . "\r\n";
1232 1259
 
1233
-		if ( $this->getCC() )
1234
-		$_header .= 'Cc: ' . $this->getCC()  . "\r\n";
1260
+		if ( $this->getCC() ) {
1261
+				$_header .= 'Cc: ' . $this->getCC()  . "\r\n";
1262
+		}
1235 1263
 
1236 1264
 		/* Note:
1237 1265
 		 * BCC email addresses must be listed in the RCPT TO command list,
@@ -1264,32 +1292,38 @@  discard block
 block discarded – undo
1264 1292
 			$_header .= 'Message-ID: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n";
1265 1293
 			$_header .= 'References: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n";
1266 1294
 			$_header .= 'X-Dolibarr-TRACKID: ' . $trackid . "\r\n";
1267
-		}
1268
-		else
1295
+		} else
1269 1296
 		{
1270 1297
 			$_header .= 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n";
1271 1298
 		}
1272
-		if ( $this->getMoreInHeader() )
1273
-		    $_header .= $this->getMoreInHeader();     // Value must include the "\r\n";
1299
+		if ( $this->getMoreInHeader() ) {
1300
+				    $_header .= $this->getMoreInHeader();
1301
+		}
1302
+		// Value must include the "\r\n";
1274 1303
 
1275 1304
 		//$_header .=
1276 1305
 		//                 'Read-Receipt-To: '   . $this->getFrom( 'org' ) . "\r\n"
1277 1306
 		//                 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n";
1278 1307
 
1279
-		if ( $this->getSensitivity() )
1280
-		$_header .= 'Sensitivity: ' . $this->getSensitivity()  . "\r\n";
1308
+		if ( $this->getSensitivity() ) {
1309
+				$_header .= 'Sensitivity: ' . $this->getSensitivity()  . "\r\n";
1310
+		}
1281 1311
 
1282
-		if ( $this->_msgPriority != 3 )
1283
-		$_header .= $this->getPriority();
1312
+		if ( $this->_msgPriority != 3 ) {
1313
+				$_header .= $this->getPriority();
1314
+		}
1284 1315
 
1285 1316
 
1286 1317
 		// @CHANGE LDR
1287
-		if ( $this->getDeliveryReceipt() )
1288
-		    $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n";
1289
-		if ( $this->getErrorsTo() )
1290
-		    $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n";
1291
-		if ( $this->getReplyTo() )
1292
-		    $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n";
1318
+		if ( $this->getDeliveryReceipt() ) {
1319
+				    $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n";
1320
+		}
1321
+		if ( $this->getErrorsTo() ) {
1322
+				    $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n";
1323
+		}
1324
+		if ( $this->getReplyTo() ) {
1325
+				    $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n";
1326
+		}
1293 1327
 
1294 1328
 		$_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n";
1295 1329
 		$_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART?'MAIN_MAIL_USE_MULTI_PART':'No MAIN_MAIL_USE_MULTI_PART') . "\r\n";
@@ -1310,10 +1344,11 @@  discard block
 block discarded – undo
1310 1344
 	{
1311 1345
 		//if ( $strContent )
1312 1346
 		//{
1313
-		if ( $strType == 'html' )
1314
-		$strMimeType = 'text/html';
1315
-		else
1316
-		$strMimeType = 'text/plain';
1347
+		if ( $strType == 'html' ) {
1348
+				$strMimeType = 'text/html';
1349
+		} else {
1350
+				$strMimeType = 'text/plain';
1351
+		}
1317 1352
 
1318 1353
 		// Make RFC821 Compliant, replace bare linefeeds
1319 1354
 		$strContent = preg_replace("/(?<!\r)\n/si", "\r\n", $strContent);
@@ -1335,8 +1370,9 @@  discard block
 block discarded – undo
1335 1370
 		$this->_msgContent[$strType]['data']     = $strContent;
1336 1371
 		$this->_msgContent[$strType]['dataText'] = $strContentAltText;
1337 1372
 
1338
-		if ( $this->getMD5flag() )
1339
-		$this->_msgContent[$strType]['md5']      = dol_hash($strContent, 3);
1373
+		if ( $this->getMD5flag() ) {
1374
+				$this->_msgContent[$strType]['md5']      = dol_hash($strContent, 3);
1375
+		}
1340 1376
 		//}
1341 1377
 	}
1342 1378
 
@@ -1359,8 +1395,9 @@  discard block
 block discarded – undo
1359 1395
 		$keyCount = count($_types);
1360 1396
 
1361 1397
 		// If we have ZERO, we have a problem
1362
-		if( $keyCount === 0 )
1363
-		die ("Sorry, no content");
1398
+		if( $keyCount === 0 ) {
1399
+				die ("Sorry, no content");
1400
+		}
1364 1401
 
1365 1402
 		// If we have ONE, we can use the simple format
1366 1403
 		else if( $keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART))
@@ -1373,8 +1410,9 @@  discard block
 block discarded – undo
1373 1410
 			. 'Content-Disposition: inline'  . "\r\n"
1374 1411
 			. 'Content-Description: message' . "\r\n";
1375 1412
 
1376
-			if ( $this->getMD5flag() )
1377
-			$content .= 'Content-MD5: ' . $_msgData['md5'] . "\r\n";
1413
+			if ( $this->getMD5flag() ) {
1414
+						$content .= 'Content-MD5: ' . $_msgData['md5'] . "\r\n";
1415
+			}
1378 1416
 
1379 1417
 			$content .= "\r\n"
1380 1418
 			.  $_msgData['data'] . "\r\n";
@@ -1397,9 +1435,11 @@  discard block
 block discarded – undo
1397 1435
 
1398 1436
 			$content .= "--" . $this->_getBoundary('mixed') . "\r\n";
1399 1437
 
1400
-			if (key_exists('image', $this->_msgContent))     // If inline image found
1438
+			if (key_exists('image', $this->_msgContent)) {
1439
+				// If inline image found
1401 1440
 			{
1402 1441
 				$content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
1442
+			}
1403 1443
 				$content .= "\r\n";
1404 1444
 				$content .= "--" . $this->_getBoundary('alternative') . "\r\n";
1405 1445
 			}
@@ -1422,8 +1462,9 @@  discard block
 block discarded – undo
1422 1462
 						.  'Content-Transfer-Encoding: base64' . "\r\n"
1423 1463
 						.  'Content-Description: File Attachment' . "\r\n";
1424 1464
 
1425
-						if ( $this->getMD5flag() )
1426
-						$content .= 'Content-MD5: ' . $_data['md5'] . "\r\n";
1465
+						if ( $this->getMD5flag() ) {
1466
+												$content .= 'Content-MD5: ' . $_data['md5'] . "\r\n";
1467
+						}
1427 1468
 
1428 1469
 						$content .= "\r\n" .  $_data['data'] . "\r\n\r\n";
1429 1470
 					}
@@ -1441,8 +1482,9 @@  discard block
 block discarded – undo
1441 1482
 						.  'Content-Disposition: inline; filename="' . $_data['imageName'] . '"' . "\r\n"
1442 1483
 						.  'Content-ID: <' . $_data['cid'] . '> ' . "\r\n";
1443 1484
 
1444
-						if ( $this->getMD5flag() )
1445
-						$content .= 'Content-MD5: ' . $_data['md5'] . "\r\n";
1485
+						if ( $this->getMD5flag() ) {
1486
+												$content .= 'Content-MD5: ' . $_data['md5'] . "\r\n";
1487
+						}
1446 1488
 
1447 1489
 						$content .= "\r\n"
1448 1490
 						. $_data['data'] . "\r\n";
@@ -1452,8 +1494,7 @@  discard block
 block discarded – undo
1452 1494
 					$content.= "--" . $this->_getBoundary('related') . "--" . "\r\n";
1453 1495
 					$content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n";
1454 1496
 					$content.= "\r\n";
1455
-				}
1456
-				else
1497
+				} else
1457 1498
 				{
1458 1499
 					if (key_exists('image', $this->_msgContent))
1459 1500
 					{
@@ -1465,9 +1506,11 @@  discard block
 block discarded – undo
1465 1506
 						$content.= "--" . $this->_getBoundary('related') . "\r\n";
1466 1507
 					}
1467 1508
 
1468
-					if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART))  // Add plain text message part before html part
1509
+					if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) {
1510
+						// Add plain text message part before html part
1469 1511
 					{
1470 1512
 					    $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
1513
+					}
1471 1514
     					$content .= "\r\n";
1472 1515
 	       				$content .= "--" . $this->_getBoundary('alternative') . "\r\n";
1473 1516
 
@@ -1488,15 +1531,18 @@  discard block
 block discarded – undo
1488 1531
 					//                             . 'Content-Disposition: inline'  . "\r\n"
1489 1532
 					//                             . 'Content-Description: ' . $type . ' message' . "\r\n";
1490 1533
 
1491
-					if ( $this->getMD5flag() )
1492
-					$content .= 'Content-MD5: ' . $_content['md5'] . "\r\n";
1534
+					if ( $this->getMD5flag() ) {
1535
+										$content .= 'Content-MD5: ' . $_content['md5'] . "\r\n";
1536
+					}
1493 1537
 
1494 1538
 					$content .= "\r\n"	. $_content['data'] . "\r\n";
1495 1539
 
1496
-					if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART))  // Add plain text message part after html part
1540
+					if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) {
1541
+						// Add plain text message part after html part
1497 1542
 					{
1498 1543
 					    $content.= "--" . $this->_getBoundary('alternative') . "--". "\r\n";
1499 1544
 					}
1545
+					}
1500 1546
 
1501 1547
 					$content .= "\r\n";
1502 1548
 				}
@@ -1529,8 +1575,9 @@  discard block
 block discarded – undo
1529 1575
 			$this->_msgContent['attachment'][$strFileName]['fileName'] = $strFileName;
1530 1576
 			$this->_msgContent['attachment'][$strFileName]['data']     = $strContent;
1531 1577
 
1532
-			if ( $this->getMD5flag() )
1533
-			$this->_msgContent['attachment'][$strFileName]['md5']      = dol_hash($strContent, 3);
1578
+			if ( $this->getMD5flag() ) {
1579
+						$this->_msgContent['attachment'][$strFileName]['md5']      = dol_hash($strContent, 3);
1580
+			}
1534 1581
 		}
1535 1582
 	}
1536 1583
 
@@ -1556,8 +1603,9 @@  discard block
 block discarded – undo
1556 1603
 			$this->_msgContent['image'][$strImageName]['cid']      = $strImageCid;
1557 1604
 			$this->_msgContent['image'][$strImageName]['data']     = $strContent;
1558 1605
 
1559
-			if ( $this->getMD5flag() )
1560
-			$this->_msgContent['image'][$strImageName]['md5']      = dol_hash($strContent, 3);
1606
+			if ( $this->getMD5flag() ) {
1607
+						$this->_msgContent['image'][$strImageName]['md5']      = dol_hash($strContent, 3);
1608
+			}
1561 1609
 		}
1562 1610
 	}
1563 1611
 	// END @CHANGE LDR
@@ -1577,8 +1625,9 @@  discard block
 block discarded – undo
1577 1625
 	function setSensitivity($_value = 0)
1578 1626
 	{
1579 1627
 		if ( ( is_numeric($_value) ) &&
1580
-		( ( $_value >= 0 ) && ( $_value <= 3 ) ) )
1581
-		$this->_msgSensitivity = $_value;
1628
+		( ( $_value >= 0 ) && ( $_value <= 3 ) ) ) {
1629
+				$this->_msgSensitivity = $_value;
1630
+		}
1582 1631
 	}
1583 1632
 
1584 1633
 	/**
@@ -1612,8 +1661,9 @@  discard block
 block discarded – undo
1612 1661
 	function setPriority ( $_value = 3 )
1613 1662
 	{
1614 1663
 		if ( ( is_numeric($_value) ) &&
1615
-		( ( $_value >= 0 ) && ( $_value <= 5 ) ) )
1616
-		$this->_msgPriority = $_value;
1664
+		( ( $_value >= 0 ) && ( $_value <= 5 ) ) ) {
1665
+				$this->_msgPriority = $_value;
1666
+		}
1617 1667
 	}
1618 1668
 
1619 1669
 	/**
@@ -1666,8 +1716,9 @@  discard block
 block discarded – undo
1666 1716
 	 */
1667 1717
 	function setXheader($strXdata)
1668 1718
 	{
1669
-		if ( $strXdata )
1670
-		$this->_msgXheader[] = $strXdata;
1719
+		if ( $strXdata ) {
1720
+				$this->_msgXheader[] = $strXdata;
1721
+		}
1671 1722
 	}
1672 1723
 
1673 1724
 	/**
@@ -1700,9 +1751,13 @@  discard block
 block discarded – undo
1700 1751
 	 */
1701 1752
 	function _getBoundary($type='mixed')
1702 1753
 	{
1703
-		if ($type == 'mixed') return $this->_smtpsBoundary;
1704
-		else if ($type == 'related') return $this->_smtpsRelatedBoundary;
1705
-		else if ($type == 'alternative') return $this->_smtpsAlternativeBoundary;
1754
+		if ($type == 'mixed') {
1755
+			return $this->_smtpsBoundary;
1756
+		} else if ($type == 'related') {
1757
+			return $this->_smtpsRelatedBoundary;
1758
+		} else if ($type == 'alternative') {
1759
+			return $this->_smtpsAlternativeBoundary;
1760
+		}
1706 1761
 	}
1707 1762
 
1708 1763
 	/**
@@ -1754,12 +1809,18 @@  discard block
 block discarded – undo
1754 1809
 	 */
1755 1810
 	function socket_send_str( $_strSend, $_returnCode = null, $CRLF = "\r\n" )
1756 1811
 	{
1757
-		if ($this->_debug) $this->log.=$_strSend;	// @CHANGE LDR for log
1812
+		if ($this->_debug) {
1813
+			$this->log.=$_strSend;
1814
+		}
1815
+		// @CHANGE LDR for log
1758 1816
 		fputs($this->socket, $_strSend . $CRLF);
1759
-		if ($this->_debug) $this->log.=' ('.$_returnCode.')' . $CRLF;
1817
+		if ($this->_debug) {
1818
+			$this->log.=' ('.$_returnCode.')' . $CRLF;
1819
+		}
1760 1820
 
1761
-		if ( $_returnCode )
1762
-		return $this->server_parse($this->socket, $_returnCode);
1821
+		if ( $_returnCode ) {
1822
+				return $this->server_parse($this->socket, $_returnCode);
1823
+		}
1763 1824
 	}
1764 1825
 
1765 1826
 	// =============================================================
Please login to merge, or discard this patch.
htdocs/livraison/class/livraison.class.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -536,7 +536,7 @@
 block discarded – undo
536 536
 	 * Update a livraison line (only extrafields)
537 537
 	 *
538 538
 	 * @param 	int		$id					Id of line (livraison line)
539
-	 * @param	array		$array_options		extrafields array
539
+	 * @param	integer		$array_options		extrafields array
540 540
 	 * @return	int							<0 if KO, >0 if OK
541 541
 	 */
542 542
 	function update_line($id, $array_options=0)
Please login to merge, or discard this patch.
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
 		$error = 0;
88 88
 
89
-        $now=dol_now();
89
+		$now=dol_now();
90 90
 
91 91
 		/* On positionne en mode brouillon le bon de livraison */
92 92
 		$this->brouillon = 1;
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
 		$sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null");
121 121
 		$sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null");
122 122
 		$sql.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null");
123
-        $sql.= ", ".(int) $this->fk_incoterms;
124
-        $sql.= ", '".$this->db->escape($this->location_incoterms)."'";
123
+		$sql.= ", ".(int) $this->fk_incoterms;
124
+		$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
125 125
 		$sql.= ")";
126 126
 
127 127
 		dol_syslog("Livraison::create", LOG_DEBUG);
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 		$sql.=" l.total_ht, l.fk_statut, l.fk_user_valid, l.note_private, l.note_public";
261 261
 		$sql.= ", l.date_delivery, l.fk_address, l.model_pdf";
262 262
 		$sql.= ", el.fk_source as origin_id, el.sourcetype as origin";
263
-        $sql.= ', l.fk_incoterms, l.location_incoterms';
264
-        $sql.= ", i.libelle as libelle_incoterms";
263
+		$sql.= ', l.fk_incoterms, l.location_incoterms';
264
+		$sql.= ", i.libelle as libelle_incoterms";
265 265
 		$sql.= " FROM ".MAIN_DB_PREFIX."livraison as l";
266 266
 		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = l.rowid AND el.targettype = '".$this->db->escape($this->element)."'";
267 267
 		$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON l.fk_incoterms = i.rowid';
@@ -337,13 +337,13 @@  discard block
 block discarded – undo
337 337
 	/**
338 338
 	 *        Validate object and update stock if option enabled
339 339
 	 *
340
-     *        @param 	User	$user        Object user that validate
341
-     *        @return   int
340
+	 *        @param 	User	$user        Object user that validate
341
+	 *        @return   int
342 342
 	 */
343 343
 	function valid($user)
344 344
 	{
345 345
 		global $conf, $langs;
346
-        require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
346
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
347 347
 
348 348
 		dol_syslog(get_class($this)."::valid begin");
349 349
 
@@ -351,8 +351,8 @@  discard block
 block discarded – undo
351 351
 
352 352
 		$error = 0;
353 353
 
354
-        if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->livraison->creer))
355
-       	|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->livraison_advance->validate)))
354
+		if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->livraison->creer))
355
+	   	|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->livraison_advance->validate)))
356 356
 		{
357 357
 			if (! empty($conf->global->LIVRAISON_ADDON_NUMBER))
358 358
 			{
@@ -371,14 +371,14 @@  discard block
 block discarded – undo
371 371
 					$soc->fetch($this->socid);
372 372
 
373 373
 					if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life
374
-		            {
375
-		                $numref = $objMod->livraison_get_num($soc,$this);
376
-		            }
377
-		            else
378 374
 					{
379
-		                $numref = $this->ref;
380
-		            }
381
-            		$this->newref = $numref;
375
+						$numref = $objMod->livraison_get_num($soc,$this);
376
+					}
377
+					else
378
+					{
379
+						$numref = $this->ref;
380
+					}
381
+					$this->newref = $numref;
382 382
 
383 383
 					// Tester si non deja au statut valide. Si oui, on arrete afin d'eviter
384 384
 					// de decrementer 2 fois le stock.
@@ -407,24 +407,24 @@  discard block
 block discarded – undo
407 407
 					$sql.= " AND fk_statut = 0";
408 408
 
409 409
 					$resql=$this->db->query($sql);
410
-			        if (! $resql)
411
-			        {
412
-			            dol_print_error($this->db);
413
-			            $this->error=$this->db->lasterror();
414
-			            $error++;
415
-			        }
416
-
417
-			        if (! $error && ! $notrigger)
418
-			        {
419
-			            // Call trigger
420
-			            $result=$this->call_trigger('DELIVERY_VALIDATE',$user);
421
-			            if ($result < 0) $error++;
422
-			            // End call triggers
423
-			        }
410
+					if (! $resql)
411
+					{
412
+						dol_print_error($this->db);
413
+						$this->error=$this->db->lasterror();
414
+						$error++;
415
+					}
416
+
417
+					if (! $error && ! $notrigger)
418
+					{
419
+						// Call trigger
420
+						$result=$this->call_trigger('DELIVERY_VALIDATE',$user);
421
+						if ($result < 0) $error++;
422
+						// End call triggers
423
+					}
424 424
 
425 425
 					if (! $error)
426 426
 					{
427
-			            $this->oldref = $this->ref;
427
+						$this->oldref = $this->ref;
428 428
 
429 429
 						// Rename directory if dir was a temporary ref
430 430
 						if (preg_match('/^[\(]?PROV/i', $this->ref))
@@ -441,17 +441,17 @@  discard block
 block discarded – undo
441 441
 
442 442
 								if (@rename($dirsource, $dirdest))
443 443
 								{
444
-			                        dol_syslog("Rename ok");
445
-			                        // Rename docs starting with $oldref with $newref
446
-			                        $listoffiles=dol_dir_list($conf->expedition->dir_output.'/receipt/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
447
-			                        foreach($listoffiles as $fileentry)
448
-			                        {
449
-			                        	$dirsource=$fileentry['name'];
450
-			                        	$dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
451
-			                        	$dirsource=$fileentry['path'].'/'.$dirsource;
452
-			                        	$dirdest=$fileentry['path'].'/'.$dirdest;
453
-			                        	@rename($dirsource, $dirdest);
454
-			                        }
444
+									dol_syslog("Rename ok");
445
+									// Rename docs starting with $oldref with $newref
446
+									$listoffiles=dol_dir_list($conf->expedition->dir_output.'/receipt/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
447
+									foreach($listoffiles as $fileentry)
448
+									{
449
+										$dirsource=$fileentry['name'];
450
+										$dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
451
+										$dirsource=$fileentry['path'].'/'.$dirsource;
452
+										$dirdest=$fileentry['path'].'/'.$dirdest;
453
+										@rename($dirsource, $dirdest);
454
+									}
455 455
 								}
456 456
 							}
457 457
 						}
@@ -466,16 +466,16 @@  discard block
 block discarded – undo
466 466
 						dol_syslog(get_class($this)."::valid ok");
467 467
 					}
468 468
 
469
-			        if (! $error)
470
-			        {
471
-			            $this->db->commit();
472
-			            return 1;
473
-			        }
474
-			        else
469
+					if (! $error)
470
+					{
471
+						$this->db->commit();
472
+						return 1;
473
+					}
474
+					else
475 475
 					{
476
-			            $this->db->rollback();
477
-			            return -1;
478
-			        }
476
+						$this->db->rollback();
477
+						return -1;
478
+					}
479 479
 				}
480 480
 			}
481 481
 		}
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 	{
617 617
 		global $conf, $langs, $user;
618 618
 
619
-        require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
619
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
620 620
 		$this->db->begin();
621 621
 
622 622
 		$error=0;
@@ -660,14 +660,14 @@  discard block
 block discarded – undo
660 660
 						}
661 661
 					}
662 662
 
663
-                    // Call trigger
664
-                    $result=$this->call_trigger('DELIVERY_DELETE',$user);
665
-                    if ($result < 0)
666
-                    {
667
-                        $this->db->rollback();
668
-                        return -4;
669
-                    }
670
-                    // End call triggers
663
+					// Call trigger
664
+					$result=$this->call_trigger('DELIVERY_DELETE',$user);
665
+					if ($result < 0)
666
+					{
667
+						$this->db->rollback();
668
+						return -4;
669
+					}
670
+					// End call triggers
671 671
 
672 672
 					return 1;
673 673
 				}
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 	 *	Return clicable name (with picto eventually)
698 698
 	 *
699 699
 	 *	@param	int		$withpicto					0=No picto, 1=Include picto into link, 2=Only picto
700
-     *  @param  int     $save_lastsearch_value		-1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
700
+	 *  @param  int     $save_lastsearch_value		-1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
701 701
 	 *	@return	string								Chaine avec URL
702 702
 	 */
703 703
 	function getNomUrl($withpicto=0, $save_lastsearch_value=-1)
@@ -711,16 +711,16 @@  discard block
 block discarded – undo
711 711
 
712 712
 		$url=DOL_URL_ROOT.'/livraison/card.php?id='.$this->id;
713 713
 
714
-        //if ($option !== 'nolink')
715
-        //{
716
-        	// Add param to save lastsearch_values or not
717
-        	$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
718
-        	if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
719
-        	if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
720
-        //}
714
+		//if ($option !== 'nolink')
715
+		//{
716
+			// Add param to save lastsearch_values or not
717
+			$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
718
+			if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
719
+			if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
720
+		//}
721 721
 
722 722
 
723
-        $linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
723
+		$linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
724 724
 		$linkend='</a>';
725 725
 
726 726
 		if ($withpicto) $result.=($linkstart.img_object($label, $picto, 'class="classfortooltip"').$linkend);
@@ -837,11 +837,11 @@  discard block
 block discarded – undo
837 837
 
838 838
 
839 839
 	/**
840
-     *  Initialise an instance with random values.
841
-     *  Used to build previews or test instances.
842
-     *	id must be 0 if object instance is a specimen.
843
-     *
844
-     *  @return	void
840
+	 *  Initialise an instance with random values.
841
+	 *  Used to build previews or test instances.
842
+	 *	id must be 0 if object instance is a specimen.
843
+	 *
844
+	 *  @return	void
845 845
 	 */
846 846
 	function initAsSpecimen()
847 847
 	{
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
 
850 850
 		$now=dol_now();
851 851
 
852
-        // Load array of products prodids
852
+		// Load array of products prodids
853 853
 		$num_prods = 0;
854 854
 		$prodids = array();
855 855
 		$sql = "SELECT rowid";
Please login to merge, or discard this patch.
Spacing   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
31 31
 require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
32 32
 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
33
-if (! empty($conf->propal->enabled))   require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
34
-if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
33
+if (!empty($conf->propal->enabled))   require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
34
+if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
35 35
 
36 36
 
37 37
 /**
@@ -39,16 +39,16 @@  discard block
 block discarded – undo
39 39
  */
40 40
 class Livraison extends CommonObject
41 41
 {
42
-	public $element="delivery";
43
-	public $fk_element="fk_livraison";
44
-	public $table_element="livraison";
45
-	public $table_element_line="livraisondet";
42
+	public $element = "delivery";
43
+	public $fk_element = "fk_livraison";
44
+	public $table_element = "livraison";
45
+	public $table_element_line = "livraisondet";
46 46
 
47 47
 	var $brouillon;
48 48
 	var $socid;
49 49
 	var $ref_customer;
50 50
 
51
-	var $date_delivery;    // Date really received
51
+	var $date_delivery; // Date really received
52 52
 	var $date_creation;
53 53
 	var $date_valid;
54 54
 	var $model_pdf;
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 
83 83
 		dol_syslog("Livraison::create");
84 84
 
85
-		if (empty($this->model_pdf)) $this->model_pdf=$conf->global->LIVRAISON_ADDON_PDF;
85
+		if (empty($this->model_pdf)) $this->model_pdf = $conf->global->LIVRAISON_ADDON_PDF;
86 86
 
87 87
 		$error = 0;
88 88
 
89
-        $now=dol_now();
89
+        $now = dol_now();
90 90
 
91 91
 		/* On positionne en mode brouillon le bon de livraison */
92 92
 		$this->brouillon = 1;
@@ -96,36 +96,36 @@  discard block
 block discarded – undo
96 96
 		$this->db->begin();
97 97
 
98 98
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."livraison (";
99
-		$sql.= "ref";
100
-		$sql.= ", entity";
101
-		$sql.= ", fk_soc";
102
-		$sql.= ", ref_customer";
103
-		$sql.= ", date_creation";
104
-		$sql.= ", fk_user_author";
105
-		$sql.= ", date_delivery";
106
-		$sql.= ", fk_address";
107
-		$sql.= ", note_private";
108
-		$sql.= ", note_public";
109
-		$sql.= ", model_pdf";
110
-		$sql.= ", fk_incoterms, location_incoterms";
111
-		$sql.= ") VALUES (";
112
-		$sql.= "'(PROV)'";
113
-		$sql.= ", ".$conf->entity;
114
-		$sql.= ", ".$this->socid;
115
-		$sql.= ", '".$this->db->escape($this->ref_customer)."'";
116
-		$sql.= ", '".$this->db->idate($now)."'";
117
-		$sql.= ", ".$user->id;
118
-		$sql.= ", ".($this->date_delivery?"'".$this->db->idate($this->date_delivery)."'":"null");
119
-		$sql.= ", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address : "null");
120
-		$sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null");
121
-		$sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null");
122
-		$sql.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null");
123
-        $sql.= ", ".(int) $this->fk_incoterms;
124
-        $sql.= ", '".$this->db->escape($this->location_incoterms)."'";
125
-		$sql.= ")";
99
+		$sql .= "ref";
100
+		$sql .= ", entity";
101
+		$sql .= ", fk_soc";
102
+		$sql .= ", ref_customer";
103
+		$sql .= ", date_creation";
104
+		$sql .= ", fk_user_author";
105
+		$sql .= ", date_delivery";
106
+		$sql .= ", fk_address";
107
+		$sql .= ", note_private";
108
+		$sql .= ", note_public";
109
+		$sql .= ", model_pdf";
110
+		$sql .= ", fk_incoterms, location_incoterms";
111
+		$sql .= ") VALUES (";
112
+		$sql .= "'(PROV)'";
113
+		$sql .= ", ".$conf->entity;
114
+		$sql .= ", ".$this->socid;
115
+		$sql .= ", '".$this->db->escape($this->ref_customer)."'";
116
+		$sql .= ", '".$this->db->idate($now)."'";
117
+		$sql .= ", ".$user->id;
118
+		$sql .= ", ".($this->date_delivery ? "'".$this->db->idate($this->date_delivery)."'" : "null");
119
+		$sql .= ", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address : "null");
120
+		$sql .= ", ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null");
121
+		$sql .= ", ".(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null");
122
+		$sql .= ", ".(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null");
123
+        $sql .= ", ".(int) $this->fk_incoterms;
124
+        $sql .= ", '".$this->db->escape($this->location_incoterms)."'";
125
+		$sql .= ")";
126 126
 
127 127
 		dol_syslog("Livraison::create", LOG_DEBUG);
128
-		$resql=$this->db->query($sql);
128
+		$resql = $this->db->query($sql);
129 129
 		if ($resql)
130 130
 		{
131 131
 			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."livraison");
@@ -133,14 +133,14 @@  discard block
 block discarded – undo
133 133
 			$numref = "(PROV".$this->id.")";
134 134
 
135 135
 			$sql = "UPDATE ".MAIN_DB_PREFIX."livraison ";
136
-			$sql.= "SET ref = '".$this->db->escape($numref)."'";
137
-			$sql.= " WHERE rowid = ".$this->id;
136
+			$sql .= "SET ref = '".$this->db->escape($numref)."'";
137
+			$sql .= " WHERE rowid = ".$this->id;
138 138
 
139 139
 			dol_syslog("Livraison::create", LOG_DEBUG);
140
-			$resql=$this->db->query($sql);
140
+			$resql = $this->db->query($sql);
141 141
 			if ($resql)
142 142
 			{
143
-				if (! $conf->expedition_bon->enabled)
143
+				if (!$conf->expedition_bon->enabled)
144 144
 				{
145 145
 					$commande = new Commande($this->db);
146 146
 					$commande->id = $this->commande_id;
@@ -151,19 +151,19 @@  discard block
 block discarded – undo
151 151
 				/*
152 152
 				 *  Insertion des produits dans la base
153 153
 				 */
154
-				$num=count($this->lines);
154
+				$num = count($this->lines);
155 155
 				for ($i = 0; $i < $num; $i++)
156 156
 				{
157
-					$origin_id=$this->lines[$i]->origin_line_id;
158
-					if (! $origin_id) $origin_id=$this->lines[$i]->commande_ligne_id;	// For backward compatibility
157
+					$origin_id = $this->lines[$i]->origin_line_id;
158
+					if (!$origin_id) $origin_id = $this->lines[$i]->commande_ligne_id; // For backward compatibility
159 159
 
160
-					if (! $this->create_line($origin_id, $this->lines[$i]->qty, $this->lines[$i]->fk_product, $this->lines[$i]->description))
160
+					if (!$this->create_line($origin_id, $this->lines[$i]->qty, $this->lines[$i]->fk_product, $this->lines[$i]->description))
161 161
 					{
162 162
 						$error++;
163 163
 					}
164 164
 				}
165 165
 
166
-				if (! $error && $this->id && $this->origin_id)
166
+				if (!$error && $this->id && $this->origin_id)
167 167
 				{
168 168
 					$ret = $this->add_object_linked();
169 169
 					if (!$ret)
@@ -171,18 +171,18 @@  discard block
 block discarded – undo
171 171
 						$error++;
172 172
 					}
173 173
 
174
-					if (! $conf->expedition_bon->enabled)
174
+					if (!$conf->expedition_bon->enabled)
175 175
 					{
176 176
 						// TODO uniformiser les statuts
177
-						$ret = $this->setStatut(2,$this->origin_id,$this->origin);
178
-						if (! $ret)
177
+						$ret = $this->setStatut(2, $this->origin_id, $this->origin);
178
+						if (!$ret)
179 179
 						{
180 180
 							$error++;
181 181
 						}
182 182
 					}
183 183
 				}
184 184
 
185
-				if (! $error)
185
+				if (!$error)
186 186
 				{
187 187
 					$this->db->commit();
188 188
 					return $this->id;
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 				else
191 191
 				{
192 192
 					$error++;
193
-					$this->error=$this->db->lasterror()." - sql=".$this->db->lastqueryerror;
193
+					$this->error = $this->db->lasterror()." - sql=".$this->db->lastqueryerror;
194 194
 					$this->db->rollback();
195 195
 					return -3;
196 196
 				}
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 			else
199 199
 			{
200 200
 				$error++;
201
-				$this->error=$this->db->lasterror()." - sql=".$this->db->lastqueryerror;
201
+				$this->error = $this->db->lasterror()." - sql=".$this->db->lastqueryerror;
202 202
 				$this->db->rollback();
203 203
 				return -2;
204 204
 			}
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 		else
207 207
 		{
208 208
 			$error++;
209
-			$this->error=$this->db->lasterror()." - sql=".$this->db->lastqueryerror;
209
+			$this->error = $this->db->lasterror()." - sql=".$this->db->lastqueryerror;
210 210
 			$this->db->rollback();
211 211
 			return -1;
212 212
 		}
@@ -228,19 +228,19 @@  discard block
 block discarded – undo
228 228
 		$j = 0;
229 229
 
230 230
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."livraisondet (fk_livraison, fk_origin_line,";
231
-		$sql.= " fk_product, description, qty)";
232
-		$sql.= " VALUES (".$this->id.",".$origin_id.",";
233
-		$sql.= " ".($idprod>0?$idprod:"null").",";
234
-		$sql.= " ".($description?"'".$this->db->escape($description)."'":"null").",";
235
-		$sql.= $qty.")";
231
+		$sql .= " fk_product, description, qty)";
232
+		$sql .= " VALUES (".$this->id.",".$origin_id.",";
233
+		$sql .= " ".($idprod > 0 ? $idprod : "null").",";
234
+		$sql .= " ".($description ? "'".$this->db->escape($description)."'" : "null").",";
235
+		$sql .= $qty.")";
236 236
 
237 237
 		dol_syslog(get_class($this)."::create_line", LOG_DEBUG);
238
-		if (! $this->db->query($sql) )
238
+		if (!$this->db->query($sql))
239 239
 		{
240 240
 			$error++;
241 241
 		}
242 242
 
243
-		if ($error == 0 )
243
+		if ($error == 0)
244 244
 		{
245 245
 			return 1;
246 246
 		}
@@ -257,15 +257,15 @@  discard block
 block discarded – undo
257 257
 		global $conf;
258 258
 
259 259
 		$sql = "SELECT l.rowid, l.fk_soc, l.date_creation, l.date_valid, l.ref, l.ref_customer, l.fk_user_author,";
260
-		$sql.=" l.total_ht, l.fk_statut, l.fk_user_valid, l.note_private, l.note_public";
261
-		$sql.= ", l.date_delivery, l.fk_address, l.model_pdf";
262
-		$sql.= ", el.fk_source as origin_id, el.sourcetype as origin";
263
-        $sql.= ', l.fk_incoterms, l.location_incoterms';
264
-        $sql.= ", i.libelle as libelle_incoterms";
265
-		$sql.= " FROM ".MAIN_DB_PREFIX."livraison as l";
266
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = l.rowid AND el.targettype = '".$this->db->escape($this->element)."'";
267
-		$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON l.fk_incoterms = i.rowid';
268
-		$sql.= " WHERE l.rowid = ".$id;
260
+		$sql .= " l.total_ht, l.fk_statut, l.fk_user_valid, l.note_private, l.note_public";
261
+		$sql .= ", l.date_delivery, l.fk_address, l.model_pdf";
262
+		$sql .= ", el.fk_source as origin_id, el.sourcetype as origin";
263
+        $sql .= ', l.fk_incoterms, l.location_incoterms';
264
+        $sql .= ", i.libelle as libelle_incoterms";
265
+		$sql .= " FROM ".MAIN_DB_PREFIX."livraison as l";
266
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = l.rowid AND el.targettype = '".$this->db->escape($this->element)."'";
267
+		$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON l.fk_incoterms = i.rowid';
268
+		$sql .= " WHERE l.rowid = ".$id;
269 269
 
270 270
 		dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
271 271
 		$result = $this->db->query($sql);
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
 				$this->note_private         = $obj->note_private;
291 291
 				$this->note_public          = $obj->note_public;
292 292
 				$this->modelpdf             = $obj->model_pdf;
293
-				$this->origin               = $obj->origin;		// May be 'shipping'
294
-				$this->origin_id            = $obj->origin_id;	// May be id of shipping
293
+				$this->origin               = $obj->origin; // May be 'shipping'
294
+				$this->origin_id            = $obj->origin_id; // May be id of shipping
295 295
 
296 296
 				//Incoterms
297 297
 				$this->fk_incoterms = $obj->fk_incoterms;
@@ -305,14 +305,14 @@  discard block
 block discarded – undo
305 305
 				// Retrieve all extrafields for delivery
306 306
 				// fetch optionals attributes and labels
307 307
 				require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
308
-				$extrafields=new ExtraFields($this->db);
309
-				$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
310
-				$this->fetch_optionals($this->id,$extralabels);
308
+				$extrafields = new ExtraFields($this->db);
309
+				$extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true);
310
+				$this->fetch_optionals($this->id, $extralabels);
311 311
 
312 312
 				/*
313 313
 				 * Lignes
314 314
 				 */
315
-				$result=$this->fetch_lines();
315
+				$result = $this->fetch_lines();
316 316
 				if ($result < 0)
317 317
 				{
318 318
 					return -3;
@@ -322,14 +322,14 @@  discard block
 block discarded – undo
322 322
 			}
323 323
 			else
324 324
 			{
325
-				$this->error='Delivery with id '.$id.' not found sql='.$sql;
325
+				$this->error = 'Delivery with id '.$id.' not found sql='.$sql;
326 326
 				dol_syslog(get_class($this).'::fetch Error '.$this->error, LOG_ERR);
327 327
 				return -2;
328 328
 			}
329 329
 		}
330 330
 		else
331 331
 		{
332
-			$this->error=$this->db->error();
332
+			$this->error = $this->db->error();
333 333
 			return -1;
334 334
 		}
335 335
 	}
@@ -351,19 +351,19 @@  discard block
 block discarded – undo
351 351
 
352 352
 		$error = 0;
353 353
 
354
-        if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->livraison->creer))
355
-       	|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->livraison_advance->validate)))
354
+        if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->livraison->creer))
355
+       	|| (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->livraison_advance->validate)))
356 356
 		{
357
-			if (! empty($conf->global->LIVRAISON_ADDON_NUMBER))
357
+			if (!empty($conf->global->LIVRAISON_ADDON_NUMBER))
358 358
 			{
359 359
 				// Definition du nom de module de numerotation de commande
360 360
 				$modName = $conf->global->LIVRAISON_ADDON_NUMBER;
361 361
 
362
-				if (is_readable(DOL_DOCUMENT_ROOT .'/core/modules/livraison/'.$modName.'.php'))
362
+				if (is_readable(DOL_DOCUMENT_ROOT.'/core/modules/livraison/'.$modName.'.php'))
363 363
 				{
364
-					require_once DOL_DOCUMENT_ROOT .'/core/modules/livraison/'.$modName.'.php';
364
+					require_once DOL_DOCUMENT_ROOT.'/core/modules/livraison/'.$modName.'.php';
365 365
 
366
-					$now=dol_now();
366
+					$now = dol_now();
367 367
 
368 368
 					// Recuperation de la nouvelle reference
369 369
 					$objMod = new $modName($this->db);
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 
373 373
 					if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life
374 374
 		            {
375
-		                $numref = $objMod->livraison_get_num($soc,$this);
375
+		                $numref = $objMod->livraison_get_num($soc, $this);
376 376
 		            }
377 377
 		            else
378 378
 					{
@@ -383,12 +383,12 @@  discard block
 block discarded – undo
383 383
 					// Tester si non deja au statut valide. Si oui, on arrete afin d'eviter
384 384
 					// de decrementer 2 fois le stock.
385 385
 					$sql = "SELECT ref";
386
-					$sql.= " FROM ".MAIN_DB_PREFIX."livraison";
387
-					$sql.= " WHERE ref = '".$this->db->escape($numref)."'";
388
-					$sql.= " AND fk_statut <> 0";
389
-					$sql.= " AND entity = ".$conf->entity;
386
+					$sql .= " FROM ".MAIN_DB_PREFIX."livraison";
387
+					$sql .= " WHERE ref = '".$this->db->escape($numref)."'";
388
+					$sql .= " AND fk_statut <> 0";
389
+					$sql .= " AND entity = ".$conf->entity;
390 390
 
391
-					$resql=$this->db->query($sql);
391
+					$resql = $this->db->query($sql);
392 392
 					if ($resql)
393 393
 					{
394 394
 						$num = $this->db->num_rows($resql);
@@ -399,30 +399,30 @@  discard block
 block discarded – undo
399 399
 					}
400 400
 
401 401
 					$sql = "UPDATE ".MAIN_DB_PREFIX."livraison SET";
402
-					$sql.= " ref='".$this->db->escape($numref)."'";
403
-					$sql.= ", fk_statut = 1";
404
-					$sql.= ", date_valid = '".$this->db->idate($now)."'";
405
-					$sql.= ", fk_user_valid = ".$user->id;
406
-					$sql.= " WHERE rowid = ".$this->id;
407
-					$sql.= " AND fk_statut = 0";
408
-
409
-					$resql=$this->db->query($sql);
410
-			        if (! $resql)
402
+					$sql .= " ref='".$this->db->escape($numref)."'";
403
+					$sql .= ", fk_statut = 1";
404
+					$sql .= ", date_valid = '".$this->db->idate($now)."'";
405
+					$sql .= ", fk_user_valid = ".$user->id;
406
+					$sql .= " WHERE rowid = ".$this->id;
407
+					$sql .= " AND fk_statut = 0";
408
+
409
+					$resql = $this->db->query($sql);
410
+			        if (!$resql)
411 411
 			        {
412 412
 			            dol_print_error($this->db);
413
-			            $this->error=$this->db->lasterror();
413
+			            $this->error = $this->db->lasterror();
414 414
 			            $error++;
415 415
 			        }
416 416
 
417
-			        if (! $error && ! $notrigger)
417
+			        if (!$error && !$notrigger)
418 418
 			        {
419 419
 			            // Call trigger
420
-			            $result=$this->call_trigger('DELIVERY_VALIDATE',$user);
420
+			            $result = $this->call_trigger('DELIVERY_VALIDATE', $user);
421 421
 			            if ($result < 0) $error++;
422 422
 			            // End call triggers
423 423
 			        }
424 424
 
425
-					if (! $error)
425
+					if (!$error)
426 426
 					{
427 427
 			            $this->oldref = $this->ref;
428 428
 
@@ -443,13 +443,13 @@  discard block
 block discarded – undo
443 443
 								{
444 444
 			                        dol_syslog("Rename ok");
445 445
 			                        // Rename docs starting with $oldref with $newref
446
-			                        $listoffiles=dol_dir_list($conf->expedition->dir_output.'/receipt/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
447
-			                        foreach($listoffiles as $fileentry)
446
+			                        $listoffiles = dol_dir_list($conf->expedition->dir_output.'/receipt/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
447
+			                        foreach ($listoffiles as $fileentry)
448 448
 			                        {
449
-			                        	$dirsource=$fileentry['name'];
450
-			                        	$dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
451
-			                        	$dirsource=$fileentry['path'].'/'.$dirsource;
452
-			                        	$dirdest=$fileentry['path'].'/'.$dirdest;
449
+			                        	$dirsource = $fileentry['name'];
450
+			                        	$dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
451
+			                        	$dirsource = $fileentry['path'].'/'.$dirsource;
452
+			                        	$dirdest = $fileentry['path'].'/'.$dirdest;
453 453
 			                        	@rename($dirsource, $dirdest);
454 454
 			                        }
455 455
 								}
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 						}
458 458
 
459 459
 						// Set new ref and current status
460
-						if (! $error)
460
+						if (!$error)
461 461
 						{
462 462
 							$this->ref = $numref;
463 463
 							$this->statut = 1;
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 						dol_syslog(get_class($this)."::valid ok");
467 467
 					}
468 468
 
469
-			        if (! $error)
469
+			        if (!$error)
470 470
 			        {
471 471
 			            $this->db->commit();
472 472
 			            return 1;
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 		}
482 482
 		else
483 483
 		{
484
-			$this->error="Non autorise";
484
+			$this->error = "Non autorise";
485 485
 			dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
486 486
 			return -1;
487 487
 		}
@@ -497,11 +497,11 @@  discard block
 block discarded – undo
497 497
 	function create_from_sending($user, $sending_id)
498 498
 	{
499 499
 		$expedition = new Expedition($this->db);
500
-		$result=$expedition->fetch($sending_id);
500
+		$result = $expedition->fetch($sending_id);
501 501
 
502 502
 		$this->lines = array();
503 503
 
504
-		$num=count($expedition->lines);
504
+		$num = count($expedition->lines);
505 505
 		for ($i = 0; $i < $num; $i++)
506 506
 		{
507 507
 			$line = new LivraisonLigne($this->db);
@@ -523,10 +523,10 @@  discard block
 block discarded – undo
523 523
 		$this->date_delivery        = $expedition->date_delivery;
524 524
 		$this->fk_delivery_address  = $expedition->fk_delivery_address;
525 525
 		$this->socid                = $expedition->socid;
526
-		$this->ref_customer			= $expedition->ref_customer;
526
+		$this->ref_customer = $expedition->ref_customer;
527 527
 
528 528
 		//Incoterms
529
-		$this->fk_incoterms		= $expedition->fk_incoterms;
529
+		$this->fk_incoterms = $expedition->fk_incoterms;
530 530
 		$this->location_incoterms = $expedition->location_incoterms;
531 531
 
532 532
 		return $this->create($user);
@@ -539,26 +539,26 @@  discard block
 block discarded – undo
539 539
 	 * @param	array		$array_options		extrafields array
540 540
 	 * @return	int							<0 if KO, >0 if OK
541 541
 	 */
542
-	function update_line($id, $array_options=0)
542
+	function update_line($id, $array_options = 0)
543 543
 	{
544 544
 		global $conf;
545 545
 		$error = 0;
546 546
 
547
-		if ($id > 0 && !$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used
547
+		if ($id > 0 && !$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used
548 548
 		{
549 549
 			$livraisonline = new LivraisonLigne($this->db);
550
-			$livraisonline->array_options=$array_options;
551
-			$livraisonline->id=$id;
552
-			$result=$livraisonline->insertExtraFields();
550
+			$livraisonline->array_options = $array_options;
551
+			$livraisonline->id = $id;
552
+			$result = $livraisonline->insertExtraFields();
553 553
 
554 554
 			if ($result < 0)
555 555
 			{
556
-				$this->error[]=$livraisonline->error;
556
+				$this->error[] = $livraisonline->error;
557 557
 				$error++;
558 558
 			}
559 559
 		}
560 560
 
561
-		if (! $error) return 1;
561
+		if (!$error) return 1;
562 562
 		else return -1;
563 563
 	}
564 564
 
@@ -592,9 +592,9 @@  discard block
 block discarded – undo
592 592
 		if ($this->statut == 0)
593 593
 		{
594 594
 			$sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet";
595
-			$sql.= " WHERE rowid = ".$lineid;
595
+			$sql .= " WHERE rowid = ".$lineid;
596 596
 
597
-			if ($this->db->query($sql) )
597
+			if ($this->db->query($sql))
598 598
 			{
599 599
 				$this->update_price();
600 600
 
@@ -619,30 +619,30 @@  discard block
 block discarded – undo
619 619
         require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
620 620
 		$this->db->begin();
621 621
 
622
-		$error=0;
622
+		$error = 0;
623 623
 
624 624
 		$sql = "DELETE FROM ".MAIN_DB_PREFIX."livraisondet";
625
-		$sql.= " WHERE fk_livraison = ".$this->id;
625
+		$sql .= " WHERE fk_livraison = ".$this->id;
626 626
 		if ($this->db->query($sql))
627 627
 		{
628 628
 			// Delete linked object
629 629
 			$res = $this->deleteObjectLinked();
630 630
 			if ($res < 0) $error++;
631 631
 
632
-			if (! $error)
632
+			if (!$error)
633 633
 			{
634 634
 				$sql = "DELETE FROM ".MAIN_DB_PREFIX."livraison";
635
-				$sql.= " WHERE rowid = ".$this->id;
635
+				$sql .= " WHERE rowid = ".$this->id;
636 636
 				if ($this->db->query($sql))
637 637
 				{
638 638
 					$this->db->commit();
639 639
 
640 640
 					// On efface le repertoire de pdf provisoire
641 641
 					$ref = dol_sanitizeFileName($this->ref);
642
-					if (! empty($conf->expedition->dir_output))
642
+					if (!empty($conf->expedition->dir_output))
643 643
 					{
644
-						$dir = $conf->expedition->dir_output . '/receipt/' . $ref ;
645
-						$file = $dir . '/' . $ref . '.pdf';
644
+						$dir = $conf->expedition->dir_output.'/receipt/'.$ref;
645
+						$file = $dir.'/'.$ref.'.pdf';
646 646
 						if (file_exists($file))
647 647
 						{
648 648
 							if (!dol_delete_file($file))
@@ -654,14 +654,14 @@  discard block
 block discarded – undo
654 654
 						{
655 655
 							if (!dol_delete_dir($dir))
656 656
 							{
657
-								$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
657
+								$this->error = $langs->trans("ErrorCanNotDeleteDir", $dir);
658 658
 								return 0;
659 659
 							}
660 660
 						}
661 661
 					}
662 662
 
663 663
                     // Call trigger
664
-                    $result=$this->call_trigger('DELIVERY_DELETE',$user);
664
+                    $result = $this->call_trigger('DELIVERY_DELETE', $user);
665 665
                     if ($result < 0)
666 666
                     {
667 667
                         $this->db->rollback();
@@ -673,21 +673,21 @@  discard block
 block discarded – undo
673 673
 				}
674 674
 				else
675 675
 				{
676
-					$this->error=$this->db->lasterror()." - sql=$sql";
676
+					$this->error = $this->db->lasterror()." - sql=$sql";
677 677
 					$this->db->rollback();
678 678
 					return -3;
679 679
 				}
680 680
 			}
681 681
 			else
682 682
 			{
683
-				$this->error=$this->db->lasterror()." - sql=$sql";
683
+				$this->error = $this->db->lasterror()." - sql=$sql";
684 684
 				$this->db->rollback();
685 685
 				return -2;
686 686
 			}
687 687
 		}
688 688
 		else
689 689
 		{
690
-			$this->error=$this->db->lasterror()." - sql=$sql";
690
+			$this->error = $this->db->lasterror()." - sql=$sql";
691 691
 			$this->db->rollback();
692 692
 			return -1;
693 693
 		}
@@ -700,32 +700,32 @@  discard block
 block discarded – undo
700 700
      *  @param  int     $save_lastsearch_value		-1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
701 701
 	 *	@return	string								Chaine avec URL
702 702
 	 */
703
-	function getNomUrl($withpicto=0, $save_lastsearch_value=-1)
703
+	function getNomUrl($withpicto = 0, $save_lastsearch_value = -1)
704 704
 	{
705 705
 		global $langs;
706 706
 
707
-		$result='';
708
-		$picto='sending';
707
+		$result = '';
708
+		$picto = 'sending';
709 709
 
710
-		$label=$langs->trans("ShowReceiving").': '.$this->ref;
710
+		$label = $langs->trans("ShowReceiving").': '.$this->ref;
711 711
 
712
-		$url=DOL_URL_ROOT.'/livraison/card.php?id='.$this->id;
712
+		$url = DOL_URL_ROOT.'/livraison/card.php?id='.$this->id;
713 713
 
714 714
         //if ($option !== 'nolink')
715 715
         //{
716 716
         	// Add param to save lastsearch_values or not
717
-        	$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
718
-        	if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
719
-        	if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
717
+        	$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
718
+        	if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
719
+        	if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
720 720
         //}
721 721
 
722 722
 
723 723
         $linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
724
-		$linkend='</a>';
724
+		$linkend = '</a>';
725 725
 
726
-		if ($withpicto) $result.=($linkstart.img_object($label, $picto, 'class="classfortooltip"').$linkend);
727
-		if ($withpicto && $withpicto != 2) $result.=' ';
728
-		$result.=$linkstart.$this->ref.$linkend;
726
+		if ($withpicto) $result .= ($linkstart.img_object($label, $picto, 'class="classfortooltip"').$linkend);
727
+		if ($withpicto && $withpicto != 2) $result .= ' ';
728
+		$result .= $linkstart.$this->ref.$linkend;
729 729
 		return $result;
730 730
 	}
731 731
 
@@ -739,12 +739,12 @@  discard block
 block discarded – undo
739 739
 		$this->lines = array();
740 740
 
741 741
 		$sql = "SELECT ld.rowid, ld.fk_product, ld.description, ld.subprice, ld.total_ht, ld.qty as qty_shipped, ld.fk_origin_line, ";
742
-		$sql.= " cd.qty as qty_asked, cd.label as custom_label,";
743
-		$sql.= " p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc";
744
-		$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld";
745
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on p.rowid = ld.fk_product";
746
-		$sql.= " WHERE ld.fk_origin_line = cd.rowid";
747
-		$sql.= " AND ld.fk_livraison = ".$this->id;
742
+		$sql .= " cd.qty as qty_asked, cd.label as custom_label,";
743
+		$sql .= " p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc";
744
+		$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld";
745
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on p.rowid = ld.fk_product";
746
+		$sql .= " WHERE ld.fk_origin_line = cd.rowid";
747
+		$sql .= " AND ld.fk_livraison = ".$this->id;
748 748
 
749 749
 		dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
750 750
 		$resql = $this->db->query($sql);
@@ -758,23 +758,23 @@  discard block
 block discarded – undo
758 758
 
759 759
 				$obj = $this->db->fetch_object($resql);
760 760
 
761
-				$line->id					= $obj->rowid;
762
-				$line->label			= $obj->custom_label;
761
+				$line->id = $obj->rowid;
762
+				$line->label = $obj->custom_label;
763 763
 				$line->description		= $obj->description;
764
-				$line->fk_product		= $obj->fk_product;
765
-				$line->qty_asked		= $obj->qty_asked;
764
+				$line->fk_product = $obj->fk_product;
765
+				$line->qty_asked = $obj->qty_asked;
766 766
 				$line->qty_shipped		= $obj->qty_shipped;
767 767
 
768
-				$line->ref				= $obj->product_ref;		// deprecated
769
-				$line->libelle			= $obj->product_label;		// deprecated
770
-				$line->product_label	= $obj->product_label;		// Product label
771
-				$line->product_ref		= $obj->product_ref;		// Product ref
772
-				$line->product_desc		= $obj->product_desc;		// Product description
768
+				$line->ref = $obj->product_ref; // deprecated
769
+				$line->libelle = $obj->product_label; // deprecated
770
+				$line->product_label	= $obj->product_label; // Product label
771
+				$line->product_ref = $obj->product_ref; // Product ref
772
+				$line->product_desc		= $obj->product_desc; // Product description
773 773
 				$line->product_type		= $obj->fk_product_type;
774
-				$line->fk_origin_line 	= $obj->fk_origin_line;
774
+				$line->fk_origin_line = $obj->fk_origin_line;
775 775
 
776
-				$line->price			= $obj->price;
777
-				$line->total_ht			= $obj->total_ht;
776
+				$line->price = $obj->price;
777
+				$line->total_ht = $obj->total_ht;
778 778
 
779 779
 				$this->lines[$i] = $line;
780 780
 
@@ -793,9 +793,9 @@  discard block
 block discarded – undo
793 793
 	 *  @param	int			$mode		Mode
794 794
 	 *  @return string      			Label
795 795
 	 */
796
-	function getLibStatut($mode=0)
796
+	function getLibStatut($mode = 0)
797 797
 	{
798
-		return $this->LibStatut($this->statut,$mode);
798
+		return $this->LibStatut($this->statut, $mode);
799 799
 	}
800 800
 
801 801
 	/**
@@ -805,33 +805,33 @@  discard block
 block discarded – undo
805 805
 	 *  @param  int			$mode       0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
806 806
 	 *  @return string					Label
807 807
 	 */
808
-	function LibStatut($statut,$mode)
808
+	function LibStatut($statut, $mode)
809 809
 	{
810 810
 		global $langs;
811 811
 
812
-		if ($mode==0)
812
+		if ($mode == 0)
813 813
 		{
814
-			if ($statut==-1) return $langs->trans('StatusDeliveryCanceled');
815
-			if ($statut==0)  return $langs->trans('StatusDeliveryDraft');
816
-			if ($statut==1)  return $langs->trans('StatusDeliveryValidated');
814
+			if ($statut == -1) return $langs->trans('StatusDeliveryCanceled');
815
+			if ($statut == 0)  return $langs->trans('StatusDeliveryDraft');
816
+			if ($statut == 1)  return $langs->trans('StatusDeliveryValidated');
817 817
 		}
818
-		if ($mode==1)
818
+		if ($mode == 1)
819 819
 		{
820
-			if ($statut==-1) return $langs->trans($this->statuts[$statut]);
821
-			if ($statut==0)  return $langs->trans($this->statuts[$statut]);
822
-			if ($statut==1)  return $langs->trans($this->statuts[$statut]);
820
+			if ($statut == -1) return $langs->trans($this->statuts[$statut]);
821
+			if ($statut == 0)  return $langs->trans($this->statuts[$statut]);
822
+			if ($statut == 1)  return $langs->trans($this->statuts[$statut]);
823 823
 		}
824 824
 		if ($mode == 4)
825 825
 		{
826
-			if ($statut==-1) return img_picto($langs->trans('StatusDeliveryCanceled'),'statut5').' '.$langs->trans('StatusDeliveryCanceled');
827
-			if ($statut==0)  return img_picto($langs->trans('StatusDeliveryDraft'),'statut0').' '.$langs->trans('StatusDeliveryDraft');
828
-			if ($statut==1)  return img_picto($langs->trans('StatusDeliveryValidated'),'statut4').' '.$langs->trans('StatusDeliveryValidated');
826
+			if ($statut == -1) return img_picto($langs->trans('StatusDeliveryCanceled'), 'statut5').' '.$langs->trans('StatusDeliveryCanceled');
827
+			if ($statut == 0)  return img_picto($langs->trans('StatusDeliveryDraft'), 'statut0').' '.$langs->trans('StatusDeliveryDraft');
828
+			if ($statut == 1)  return img_picto($langs->trans('StatusDeliveryValidated'), 'statut4').' '.$langs->trans('StatusDeliveryValidated');
829 829
 		}
830 830
 		if ($mode == 6)
831 831
 		{
832
-			if ($statut==-1) return $langs->trans('StatusDeliveryCanceled').' '.img_picto($langs->trans('StatusDeliveryCanceled'),'statut5');
833
-			if ($statut==0)  return $langs->trans('StatusDeliveryDraft').' '.img_picto($langs->trans('StatusDeliveryDraft'),'statut0');
834
-			if ($statut==1)  return $langs->trans('StatusDeliveryValidated').' '.img_picto($langs->trans('StatusDeliveryValidated'),'statut4');
832
+			if ($statut == -1) return $langs->trans('StatusDeliveryCanceled').' '.img_picto($langs->trans('StatusDeliveryCanceled'), 'statut5');
833
+			if ($statut == 0)  return $langs->trans('StatusDeliveryDraft').' '.img_picto($langs->trans('StatusDeliveryDraft'), 'statut0');
834
+			if ($statut == 1)  return $langs->trans('StatusDeliveryValidated').' '.img_picto($langs->trans('StatusDeliveryValidated'), 'statut4');
835 835
 		}
836 836
 	}
837 837
 
@@ -845,17 +845,17 @@  discard block
 block discarded – undo
845 845
 	 */
846 846
 	function initAsSpecimen()
847 847
 	{
848
-		global $user,$langs,$conf;
848
+		global $user, $langs, $conf;
849 849
 
850
-		$now=dol_now();
850
+		$now = dol_now();
851 851
 
852 852
         // Load array of products prodids
853 853
 		$num_prods = 0;
854 854
 		$prodids = array();
855 855
 		$sql = "SELECT rowid";
856
-		$sql.= " FROM ".MAIN_DB_PREFIX."product";
857
-		$sql.= " WHERE entity IN (".getEntity('product').")";
858
-		$sql.= " AND tosell = 1";
856
+		$sql .= " FROM ".MAIN_DB_PREFIX."product";
857
+		$sql .= " WHERE entity IN (".getEntity('product').")";
858
+		$sql .= " AND tosell = 1";
859 859
 		$resql = $this->db->query($sql);
860 860
 		if ($resql)
861 861
 		{
@@ -870,16 +870,16 @@  discard block
 block discarded – undo
870 870
 		}
871 871
 
872 872
 		// Initialise parametres
873
-		$this->id=0;
873
+		$this->id = 0;
874 874
 		$this->ref = 'SPECIMEN';
875
-		$this->specimen=1;
875
+		$this->specimen = 1;
876 876
 		$this->socid = 1;
877 877
 		$this->date_delivery = $now;
878
-		$this->note_public='Public note';
879
-		$this->note_private='Private note';
878
+		$this->note_public = 'Public note';
879
+		$this->note_private = 'Private note';
880 880
 
881
-		$i=0;
882
-		$line=new LivraisonLigne($this->db);
881
+		$i = 0;
882
+		$line = new LivraisonLigne($this->db);
883 883
 		$line->fk_product     = $prodids[0];
884 884
 		$line->qty_asked      = 10;
885 885
 		$line->qty_shipped    = 9;
@@ -903,14 +903,14 @@  discard block
 block discarded – undo
903 903
 		global $langs;
904 904
 
905 905
 		// Get the linked object
906
-		$this->fetchObjectLinked('','',$this->id,$this->element);
906
+		$this->fetchObjectLinked('', '', $this->id, $this->element);
907 907
 		//var_dump($this->linkedObjectIds);
908 908
 		// Get the product ref and qty in source
909 909
 		$sqlSourceLine = "SELECT st.rowid, st.description, st.qty";
910
-		$sqlSourceLine.= ", p.ref, p.label";
911
-		$sqlSourceLine.= " FROM ".MAIN_DB_PREFIX.$this->linkedObjectIds[0]['type']."det as st";
912
-		$sqlSourceLine.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON st.fk_product = p.rowid";
913
-		$sqlSourceLine.= " WHERE fk_".$this->linked_object[0]['type']." = ".$this->linked_object[0]['linkid'];
910
+		$sqlSourceLine .= ", p.ref, p.label";
911
+		$sqlSourceLine .= " FROM ".MAIN_DB_PREFIX.$this->linkedObjectIds[0]['type']."det as st";
912
+		$sqlSourceLine .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON st.fk_product = p.rowid";
913
+		$sqlSourceLine .= " WHERE fk_".$this->linked_object[0]['type']." = ".$this->linked_object[0]['linkid'];
914 914
 
915 915
 		$resultSourceLine = $this->db->query($sqlSourceLine);
916 916
 		if ($resultSourceLine)
@@ -924,15 +924,15 @@  discard block
 block discarded – undo
924 924
 
925 925
 				// Recupere les lignes de la source deja livrees
926 926
 				$sql = "SELECT ld.fk_origin_line, sum(ld.qty) as qty";
927
-				$sql.= " FROM ".MAIN_DB_PREFIX."livraisondet as ld, ".MAIN_DB_PREFIX."livraison as l,";
928
-				$sql.= " ".MAIN_DB_PREFIX.$this->linked_object[0]['type']." as c";
929
-				$sql.= ", ".MAIN_DB_PREFIX.$this->linked_object[0]['type']."det as cd";
930
-				$sql.= " WHERE ld.fk_livraison = l.rowid";
931
-				$sql.= " AND ld.fk_origin_line = cd.rowid";
932
-				$sql.= " AND cd.fk_".$this->linked_object[0]['type']." = c.rowid";
933
-				$sql.= " AND cd.fk_".$this->linked_object[0]['type']." = ".$this->linked_object[0]['linkid'];
934
-				$sql.= " AND ld.fk_origin_line = ".$objSourceLine->rowid;
935
-				$sql.= " GROUP BY ld.fk_origin_line";
927
+				$sql .= " FROM ".MAIN_DB_PREFIX."livraisondet as ld, ".MAIN_DB_PREFIX."livraison as l,";
928
+				$sql .= " ".MAIN_DB_PREFIX.$this->linked_object[0]['type']." as c";
929
+				$sql .= ", ".MAIN_DB_PREFIX.$this->linked_object[0]['type']."det as cd";
930
+				$sql .= " WHERE ld.fk_livraison = l.rowid";
931
+				$sql .= " AND ld.fk_origin_line = cd.rowid";
932
+				$sql .= " AND cd.fk_".$this->linked_object[0]['type']." = c.rowid";
933
+				$sql .= " AND cd.fk_".$this->linked_object[0]['type']." = ".$this->linked_object[0]['linkid'];
934
+				$sql .= " AND ld.fk_origin_line = ".$objSourceLine->rowid;
935
+				$sql .= " GROUP BY ld.fk_origin_line";
936 936
 
937 937
 				$result = $this->db->query($sql);
938 938
 				$row = $this->db->fetch_row($result);
@@ -949,13 +949,13 @@  discard block
 block discarded – undo
949 949
 					}
950 950
 
951 951
 					$array[$i]['ref'] = $objSourceLine->ref;
952
-					$array[$i]['label'] = $objSourceLine->label?$objSourceLine->label:$objSourceLine->description;
952
+					$array[$i]['label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description;
953 953
 				}
954
-				elseif($objSourceLine->qty - $row[1] < 0)
954
+				elseif ($objSourceLine->qty - $row[1] < 0)
955 955
 				{
956
-					$array[$i]['qty'] = $objSourceLine->qty - $row[1]. " Erreur livraison !";
956
+					$array[$i]['qty'] = $objSourceLine->qty - $row[1]." Erreur livraison !";
957 957
 					$array[$i]['ref'] = $objSourceLine->ref;
958
-					$array[$i]['label'] = $objSourceLine->label?$objSourceLine->label:$objSourceLine->description;
958
+					$array[$i]['label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description;
959 959
 				}
960 960
 
961 961
 					$i++;
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 		}
965 965
 		else
966 966
 		{
967
-			$this->error=$this->db->error()." - sql=$sqlSourceLine";
967
+			$this->error = $this->db->error()." - sql=$sqlSourceLine";
968 968
 			return -1;
969 969
 		}
970 970
 	}
@@ -981,11 +981,11 @@  discard block
 block discarded – undo
981 981
 		if ($user->rights->expedition->creer)
982 982
 		{
983 983
 			$sql = "UPDATE ".MAIN_DB_PREFIX."livraison";
984
-			$sql.= " SET date_delivery = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null');
985
-			$sql.= " WHERE rowid = ".$this->id;
984
+			$sql .= " SET date_delivery = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null');
985
+			$sql .= " WHERE rowid = ".$this->id;
986 986
 
987 987
 			dol_syslog(get_class($this)."::set_date_livraison", LOG_DEBUG);
988
-			$resql=$this->db->query($sql);
988
+			$resql = $this->db->query($sql);
989 989
 			if ($resql)
990 990
 			{
991 991
 				$this->date_delivery = $date_livraison;
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
 			}
994 994
 			else
995 995
 			{
996
-				$this->error=$this->db->error();
996
+				$this->error = $this->db->error();
997 997
 				return -1;
998 998
 			}
999 999
 		}
@@ -1013,19 +1013,19 @@  discard block
 block discarded – undo
1013 1013
 	 *  @param     int			$hideref        Hide ref
1014 1014
 	 *  @return    int             				0 if KO, 1 if OK
1015 1015
 	 */
1016
-	public function generateDocument($modele, $outputlangs='',$hidedetails=0,$hidedesc=0,$hideref=0)
1016
+	public function generateDocument($modele, $outputlangs = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1017 1017
 	{
1018
-		global $conf,$user,$langs;
1018
+		global $conf, $user, $langs;
1019 1019
 
1020 1020
 		$langs->load("deliveries");
1021 1021
 
1022
-		if (! dol_strlen($modele)) {
1022
+		if (!dol_strlen($modele)) {
1023 1023
 
1024 1024
 			$modele = 'typhon';
1025 1025
 
1026 1026
 			if ($this->modelpdf) {
1027 1027
 				$modele = $this->modelpdf;
1028
-			} elseif (! empty($conf->global->LIVRAISON_ADDON_PDF)) {
1028
+			} elseif (!empty($conf->global->LIVRAISON_ADDON_PDF)) {
1029 1029
 				$modele = $conf->global->LIVRAISON_ADDON_PDF;
1030 1030
 			}
1031 1031
 		}
@@ -1070,8 +1070,8 @@  discard block
 block discarded – undo
1070 1070
 	var $price;
1071 1071
 	var $fk_product;
1072 1072
 	var $origin_id;
1073
-	var $label;       // Label produit
1074
-	var $description;  // Description produit
1073
+	var $label; // Label produit
1074
+	var $description; // Description produit
1075 1075
 	/**
1076 1076
 	 * @deprecated
1077 1077
 	 * @see product_ref
@@ -1086,8 +1086,8 @@  discard block
 block discarded – undo
1086 1086
 	public $product_ref;
1087 1087
 	public $product_label;
1088 1088
 
1089
-	public $element='livraisondet';
1090
-	public $table_element='livraisondet';
1089
+	public $element = 'livraisondet';
1090
+	public $table_element = 'livraisondet';
1091 1091
 
1092 1092
 	/**
1093 1093
 	 *	Constructor
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
 	 */
1097 1097
 	function __construct($db)
1098 1098
 	{
1099
-		$this->db=$db;
1099
+		$this->db = $db;
1100 1100
 	}
1101 1101
 
1102 1102
 }
Please login to merge, or discard this patch.
Braces   +98 added lines, -61 removed lines patch added patch discarded remove patch
@@ -30,8 +30,12 @@  discard block
 block discarded – undo
30 30
 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
31 31
 require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
32 32
 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
33
-if (! empty($conf->propal->enabled))   require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
34
-if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
33
+if (! empty($conf->propal->enabled)) {
34
+	require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
35
+}
36
+if (! empty($conf->commande->enabled)) {
37
+	require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
38
+}
35 39
 
36 40
 
37 41
 /**
@@ -82,7 +86,9 @@  discard block
 block discarded – undo
82 86
 
83 87
 		dol_syslog("Livraison::create");
84 88
 
85
-		if (empty($this->model_pdf)) $this->model_pdf=$conf->global->LIVRAISON_ADDON_PDF;
89
+		if (empty($this->model_pdf)) {
90
+			$this->model_pdf=$conf->global->LIVRAISON_ADDON_PDF;
91
+		}
86 92
 
87 93
 		$error = 0;
88 94
 
@@ -155,7 +161,10 @@  discard block
 block discarded – undo
155 161
 				for ($i = 0; $i < $num; $i++)
156 162
 				{
157 163
 					$origin_id=$this->lines[$i]->origin_line_id;
158
-					if (! $origin_id) $origin_id=$this->lines[$i]->commande_ligne_id;	// For backward compatibility
164
+					if (! $origin_id) {
165
+						$origin_id=$this->lines[$i]->commande_ligne_id;
166
+					}
167
+					// For backward compatibility
159 168
 
160 169
 					if (! $this->create_line($origin_id, $this->lines[$i]->qty, $this->lines[$i]->fk_product, $this->lines[$i]->description))
161 170
 					{
@@ -186,24 +195,21 @@  discard block
 block discarded – undo
186 195
 				{
187 196
 					$this->db->commit();
188 197
 					return $this->id;
189
-				}
190
-				else
198
+				} else
191 199
 				{
192 200
 					$error++;
193 201
 					$this->error=$this->db->lasterror()." - sql=".$this->db->lastqueryerror;
194 202
 					$this->db->rollback();
195 203
 					return -3;
196 204
 				}
197
-			}
198
-			else
205
+			} else
199 206
 			{
200 207
 				$error++;
201 208
 				$this->error=$this->db->lasterror()." - sql=".$this->db->lastqueryerror;
202 209
 				$this->db->rollback();
203 210
 				return -2;
204 211
 			}
205
-		}
206
-		else
212
+		} else
207 213
 		{
208 214
 			$error++;
209 215
 			$this->error=$this->db->lasterror()." - sql=".$this->db->lastqueryerror;
@@ -299,7 +305,9 @@  discard block
 block discarded – undo
299 305
 				$this->libelle_incoterms = $obj->libelle_incoterms;
300 306
 				$this->db->free($result);
301 307
 
302
-				if ($this->statut == 0) $this->brouillon = 1;
308
+				if ($this->statut == 0) {
309
+					$this->brouillon = 1;
310
+				}
303 311
 
304 312
 
305 313
 				// Retrieve all extrafields for delivery
@@ -319,15 +327,13 @@  discard block
 block discarded – undo
319 327
 				}
320 328
 
321 329
 				return 1;
322
-			}
323
-			else
330
+			} else
324 331
 			{
325 332
 				$this->error='Delivery with id '.$id.' not found sql='.$sql;
326 333
 				dol_syslog(get_class($this).'::fetch Error '.$this->error, LOG_ERR);
327 334
 				return -2;
328 335
 			}
329
-		}
330
-		else
336
+		} else
331 337
 		{
332 338
 			$this->error=$this->db->error();
333 339
 			return -1;
@@ -370,11 +376,12 @@  discard block
 block discarded – undo
370 376
 					$soc = new Societe($this->db);
371 377
 					$soc->fetch($this->socid);
372 378
 
373
-					if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life
379
+					if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) {
380
+						// empty should not happened, but when it occurs, the test save life
374 381
 		            {
375 382
 		                $numref = $objMod->livraison_get_num($soc,$this);
376
-		            }
377
-		            else
383
+					}
384
+		            } else
378 385
 					{
379 386
 		                $numref = $this->ref;
380 387
 		            }
@@ -418,7 +425,9 @@  discard block
 block discarded – undo
418 425
 			        {
419 426
 			            // Call trigger
420 427
 			            $result=$this->call_trigger('DELIVERY_VALIDATE',$user);
421
-			            if ($result < 0) $error++;
428
+			            if ($result < 0) {
429
+			            	$error++;
430
+			            }
422 431
 			            // End call triggers
423 432
 			        }
424 433
 
@@ -470,16 +479,14 @@  discard block
 block discarded – undo
470 479
 			        {
471 480
 			            $this->db->commit();
472 481
 			            return 1;
473
-			        }
474
-			        else
482
+			        } else
475 483
 					{
476 484
 			            $this->db->rollback();
477 485
 			            return -1;
478 486
 			        }
479 487
 				}
480 488
 			}
481
-		}
482
-		else
489
+		} else
483 490
 		{
484 491
 			$this->error="Non autorise";
485 492
 			dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
@@ -544,9 +551,11 @@  discard block
 block discarded – undo
544 551
 		global $conf;
545 552
 		$error = 0;
546 553
 
547
-		if ($id > 0 && !$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used
554
+		if ($id > 0 && !$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) {
555
+			// For avoid conflicts if trigger used
548 556
 		{
549 557
 			$livraisonline = new LivraisonLigne($this->db);
558
+		}
550 559
 			$livraisonline->array_options=$array_options;
551 560
 			$livraisonline->id=$id;
552 561
 			$result=$livraisonline->insertExtraFields();
@@ -558,8 +567,11 @@  discard block
 block discarded – undo
558 567
 			}
559 568
 		}
560 569
 
561
-		if (! $error) return 1;
562
-		else return -1;
570
+		if (! $error) {
571
+			return 1;
572
+		} else {
573
+			return -1;
574
+		}
563 575
 	}
564 576
 
565 577
 
@@ -599,8 +611,7 @@  discard block
 block discarded – undo
599 611
 				$this->update_price();
600 612
 
601 613
 				return 1;
602
-			}
603
-			else
614
+			} else
604 615
 			{
605 616
 				return 0;
606 617
 			}
@@ -627,7 +638,9 @@  discard block
 block discarded – undo
627 638
 		{
628 639
 			// Delete linked object
629 640
 			$res = $this->deleteObjectLinked();
630
-			if ($res < 0) $error++;
641
+			if ($res < 0) {
642
+				$error++;
643
+			}
631 644
 
632 645
 			if (! $error)
633 646
 			{
@@ -670,22 +683,19 @@  discard block
 block discarded – undo
670 683
                     // End call triggers
671 684
 
672 685
 					return 1;
673
-				}
674
-				else
686
+				} else
675 687
 				{
676 688
 					$this->error=$this->db->lasterror()." - sql=$sql";
677 689
 					$this->db->rollback();
678 690
 					return -3;
679 691
 				}
680
-			}
681
-			else
692
+			} else
682 693
 			{
683 694
 				$this->error=$this->db->lasterror()." - sql=$sql";
684 695
 				$this->db->rollback();
685 696
 				return -2;
686 697
 			}
687
-		}
688
-		else
698
+		} else
689 699
 		{
690 700
 			$this->error=$this->db->lasterror()." - sql=$sql";
691 701
 			$this->db->rollback();
@@ -715,16 +725,24 @@  discard block
 block discarded – undo
715 725
         //{
716 726
         	// Add param to save lastsearch_values or not
717 727
         	$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
718
-        	if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
719
-        	if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
728
+        	if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) {
729
+        		$add_save_lastsearch_values=1;
730
+        	}
731
+        	if ($add_save_lastsearch_values) {
732
+        		$url.='&save_lastsearch_values=1';
733
+        	}
720 734
         //}
721 735
 
722 736
 
723 737
         $linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
724 738
 		$linkend='</a>';
725 739
 
726
-		if ($withpicto) $result.=($linkstart.img_object($label, $picto, 'class="classfortooltip"').$linkend);
727
-		if ($withpicto && $withpicto != 2) $result.=' ';
740
+		if ($withpicto) {
741
+			$result.=($linkstart.img_object($label, $picto, 'class="classfortooltip"').$linkend);
742
+		}
743
+		if ($withpicto && $withpicto != 2) {
744
+			$result.=' ';
745
+		}
728 746
 		$result.=$linkstart.$this->ref.$linkend;
729 747
 		return $result;
730 748
 	}
@@ -811,27 +829,51 @@  discard block
 block discarded – undo
811 829
 
812 830
 		if ($mode==0)
813 831
 		{
814
-			if ($statut==-1) return $langs->trans('StatusDeliveryCanceled');
815
-			if ($statut==0)  return $langs->trans('StatusDeliveryDraft');
816
-			if ($statut==1)  return $langs->trans('StatusDeliveryValidated');
832
+			if ($statut==-1) {
833
+				return $langs->trans('StatusDeliveryCanceled');
834
+			}
835
+			if ($statut==0) {
836
+				return $langs->trans('StatusDeliveryDraft');
837
+			}
838
+			if ($statut==1) {
839
+				return $langs->trans('StatusDeliveryValidated');
840
+			}
817 841
 		}
818 842
 		if ($mode==1)
819 843
 		{
820
-			if ($statut==-1) return $langs->trans($this->statuts[$statut]);
821
-			if ($statut==0)  return $langs->trans($this->statuts[$statut]);
822
-			if ($statut==1)  return $langs->trans($this->statuts[$statut]);
844
+			if ($statut==-1) {
845
+				return $langs->trans($this->statuts[$statut]);
846
+			}
847
+			if ($statut==0) {
848
+				return $langs->trans($this->statuts[$statut]);
849
+			}
850
+			if ($statut==1) {
851
+				return $langs->trans($this->statuts[$statut]);
852
+			}
823 853
 		}
824 854
 		if ($mode == 4)
825 855
 		{
826
-			if ($statut==-1) return img_picto($langs->trans('StatusDeliveryCanceled'),'statut5').' '.$langs->trans('StatusDeliveryCanceled');
827
-			if ($statut==0)  return img_picto($langs->trans('StatusDeliveryDraft'),'statut0').' '.$langs->trans('StatusDeliveryDraft');
828
-			if ($statut==1)  return img_picto($langs->trans('StatusDeliveryValidated'),'statut4').' '.$langs->trans('StatusDeliveryValidated');
856
+			if ($statut==-1) {
857
+				return img_picto($langs->trans('StatusDeliveryCanceled'),'statut5').' '.$langs->trans('StatusDeliveryCanceled');
858
+			}
859
+			if ($statut==0) {
860
+				return img_picto($langs->trans('StatusDeliveryDraft'),'statut0').' '.$langs->trans('StatusDeliveryDraft');
861
+			}
862
+			if ($statut==1) {
863
+				return img_picto($langs->trans('StatusDeliveryValidated'),'statut4').' '.$langs->trans('StatusDeliveryValidated');
864
+			}
829 865
 		}
830 866
 		if ($mode == 6)
831 867
 		{
832
-			if ($statut==-1) return $langs->trans('StatusDeliveryCanceled').' '.img_picto($langs->trans('StatusDeliveryCanceled'),'statut5');
833
-			if ($statut==0)  return $langs->trans('StatusDeliveryDraft').' '.img_picto($langs->trans('StatusDeliveryDraft'),'statut0');
834
-			if ($statut==1)  return $langs->trans('StatusDeliveryValidated').' '.img_picto($langs->trans('StatusDeliveryValidated'),'statut4');
868
+			if ($statut==-1) {
869
+				return $langs->trans('StatusDeliveryCanceled').' '.img_picto($langs->trans('StatusDeliveryCanceled'),'statut5');
870
+			}
871
+			if ($statut==0) {
872
+				return $langs->trans('StatusDeliveryDraft').' '.img_picto($langs->trans('StatusDeliveryDraft'),'statut0');
873
+			}
874
+			if ($statut==1) {
875
+				return $langs->trans('StatusDeliveryValidated').' '.img_picto($langs->trans('StatusDeliveryValidated'),'statut4');
876
+			}
835 877
 		}
836 878
 	}
837 879
 
@@ -942,16 +984,14 @@  discard block
 block discarded – undo
942 984
 					if ($row[0] == $objSourceLine->rowid)
943 985
 					{
944 986
 						$array[$i]['qty'] = $objSourceLine->qty - $row[1];
945
-					}
946
-					else
987
+					} else
947 988
 					{
948 989
 						$array[$i]['qty'] = $objSourceLine->qty;
949 990
 					}
950 991
 
951 992
 					$array[$i]['ref'] = $objSourceLine->ref;
952 993
 					$array[$i]['label'] = $objSourceLine->label?$objSourceLine->label:$objSourceLine->description;
953
-				}
954
-				elseif($objSourceLine->qty - $row[1] < 0)
994
+				} elseif($objSourceLine->qty - $row[1] < 0)
955 995
 				{
956 996
 					$array[$i]['qty'] = $objSourceLine->qty - $row[1]. " Erreur livraison !";
957 997
 					$array[$i]['ref'] = $objSourceLine->ref;
@@ -961,8 +1001,7 @@  discard block
 block discarded – undo
961 1001
 					$i++;
962 1002
 			}
963 1003
 			return $array;
964
-		}
965
-		else
1004
+		} else
966 1005
 		{
967 1006
 			$this->error=$this->db->error()." - sql=$sqlSourceLine";
968 1007
 			return -1;
@@ -990,14 +1029,12 @@  discard block
 block discarded – undo
990 1029
 			{
991 1030
 				$this->date_delivery = $date_livraison;
992 1031
 				return 1;
993
-			}
994
-			else
1032
+			} else
995 1033
 			{
996 1034
 				$this->error=$this->db->error();
997 1035
 				return -1;
998 1036
 			}
999
-		}
1000
-		else
1037
+		} else
1001 1038
 		{
1002 1039
 			return -2;
1003 1040
 		}
Please login to merge, or discard this patch.
htdocs/core/class/html.formadmin.class.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -334,7 +334,7 @@
 block discarded – undo
334 334
 	 *
335 335
 	 *    	@param      string	$selected       Paper format pre-selected
336 336
 	 *    	@param      string	$htmlname       Name of HTML select field
337
-	 * 		@param		string	$filter			Value to filter on code
337
+	 * 		@param		integer	$filter			Value to filter on code
338 338
 	 * 		@param		int		$showempty		Add empty value
339 339
 	 * 		@return		string					Return HTML output
340 340
 	 */
Please login to merge, or discard this patch.
Indentation   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 
88 88
 		foreach ($langs_available as $key => $value)
89 89
 		{
90
-		    $valuetoshow=$value;
91
-		    if ($showcode) $valuetoshow=$key.' - '.$value;
90
+			$valuetoshow=$value;
91
+			if ($showcode) $valuetoshow=$key.' - '.$value;
92 92
 
93 93
 			if ($filter && is_array($filter))
94 94
 			{
@@ -109,79 +109,79 @@  discard block
 block discarded – undo
109 109
 		$out.= '</select>';
110 110
 
111 111
 		// Make select dynamic
112
-        include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
113
-        $out.= ajax_combobox($htmlname);
112
+		include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
113
+		$out.= ajax_combobox($htmlname);
114 114
 
115 115
 		return $out;
116 116
 	}
117 117
 
118 118
 	/**
119
-     *    Return list of available menus (eldy_backoffice, ...)
120
-     *
121
-     *    @param	string		$selected        Preselected menu value
122
-     *    @param    string		$htmlname        Name of html select
123
-     *    @param    array		$dirmenuarray    Array of directories to scan
124
-     *    @param    string		$moreattrib      More attributes on html select tag
125
-     *    @return	integer|null
126
-     */
127
-    function select_menu($selected, $htmlname, $dirmenuarray, $moreattrib='')
128
-    {
129
-        global $langs,$conf;
119
+	 *    Return list of available menus (eldy_backoffice, ...)
120
+	 *
121
+	 *    @param	string		$selected        Preselected menu value
122
+	 *    @param    string		$htmlname        Name of html select
123
+	 *    @param    array		$dirmenuarray    Array of directories to scan
124
+	 *    @param    string		$moreattrib      More attributes on html select tag
125
+	 *    @return	integer|null
126
+	 */
127
+	function select_menu($selected, $htmlname, $dirmenuarray, $moreattrib='')
128
+	{
129
+		global $langs,$conf;
130 130
 
131
-        // Clean parameters
131
+		// Clean parameters
132 132
 
133 133
 
134
-        // Check parameters
135
-        if (! is_array($dirmenuarray)) return -1;
134
+		// Check parameters
135
+		if (! is_array($dirmenuarray)) return -1;
136 136
 
137 137
 		$menuarray=array();
138
-        foreach ($conf->file->dol_document_root as $dirroot)
139
-        {
140
-            foreach($dirmenuarray as $dirtoscan)
141
-            {
142
-                $dir=$dirroot.$dirtoscan;
143
-                //print $dir.'<br>';
144
-                if (is_dir($dir))
145
-                {
146
-    	            $handle=opendir($dir);
147
-    	            if (is_resource($handle))
148
-    	            {
149
-    	                while (($file = readdir($handle))!==false)
150
-    	                {
151
-    	                    if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && substr($file, 0, 5) != 'index')
152
-    	                    {
153
-    	                        if (preg_match('/lib\.php$/i',$file)) continue;	// We exclude library files
154
-    	                        if (preg_match('/eldy_(backoffice|frontoffice)\.php$/i',$file)) continue;		// We exclude all menu manager files
155
-    	                        if (preg_match('/auguria_(backoffice|frontoffice)\.php$/i',$file)) continue;	// We exclude all menu manager files
156
-    	                        if (preg_match('/smartphone_(backoffice|frontoffice)\.php$/i',$file)) continue;	// We exclude all menu manager files
157
-
158
-    	                        $filelib=preg_replace('/\.php$/i','',$file);
159
-    	        				$prefix='';
160
-    	        				// 0=Recommanded, 1=Experimental, 2=Developpement, 3=Other
161
-    	        				if (preg_match('/^eldy/i',$file)) $prefix='0';
162
-                                else if (preg_match('/^smartphone/i',$file)) $prefix='2';
163
-    	        				else $prefix='3';
164
-
165
-    	                        if ($file == $selected)
166
-    	                        {
167
-    	        					$menuarray[$prefix.'_'.$file]='<option value="'.$file.'" selected>'.$filelib.'</option>';
168
-    	                        }
169
-    	                        else
170
-    	                        {
171
-    	                            $menuarray[$prefix.'_'.$file]='<option value="'.$file.'">'.$filelib.'</option>';
172
-    	                        }
173
-    	                    }
174
-    	                }
175
-    	                closedir($handle);
176
-    	            }
177
-                }
178
-            }
179
-        }
138
+		foreach ($conf->file->dol_document_root as $dirroot)
139
+		{
140
+			foreach($dirmenuarray as $dirtoscan)
141
+			{
142
+				$dir=$dirroot.$dirtoscan;
143
+				//print $dir.'<br>';
144
+				if (is_dir($dir))
145
+				{
146
+					$handle=opendir($dir);
147
+					if (is_resource($handle))
148
+					{
149
+						while (($file = readdir($handle))!==false)
150
+						{
151
+							if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && substr($file, 0, 5) != 'index')
152
+							{
153
+								if (preg_match('/lib\.php$/i',$file)) continue;	// We exclude library files
154
+								if (preg_match('/eldy_(backoffice|frontoffice)\.php$/i',$file)) continue;		// We exclude all menu manager files
155
+								if (preg_match('/auguria_(backoffice|frontoffice)\.php$/i',$file)) continue;	// We exclude all menu manager files
156
+								if (preg_match('/smartphone_(backoffice|frontoffice)\.php$/i',$file)) continue;	// We exclude all menu manager files
157
+
158
+								$filelib=preg_replace('/\.php$/i','',$file);
159
+								$prefix='';
160
+								// 0=Recommanded, 1=Experimental, 2=Developpement, 3=Other
161
+								if (preg_match('/^eldy/i',$file)) $prefix='0';
162
+								else if (preg_match('/^smartphone/i',$file)) $prefix='2';
163
+								else $prefix='3';
164
+
165
+								if ($file == $selected)
166
+								{
167
+									$menuarray[$prefix.'_'.$file]='<option value="'.$file.'" selected>'.$filelib.'</option>';
168
+								}
169
+								else
170
+								{
171
+									$menuarray[$prefix.'_'.$file]='<option value="'.$file.'">'.$filelib.'</option>';
172
+								}
173
+							}
174
+						}
175
+						closedir($handle);
176
+					}
177
+				}
178
+			}
179
+		}
180 180
 		ksort($menuarray);
181 181
 
182 182
 		// Output combo list of menus
183
-        print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>';
184
-        $oldprefix='';
183
+		print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>';
184
+		$oldprefix='';
185 185
 		foreach ($menuarray as $key => $val)
186 186
 		{
187 187
 			$tab=explode('_',$key);
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 				// Affiche titre
194 194
 				print '<option value="-1" disabled>';
195 195
 				if ($newprefix=='0') print '-- '.$langs->trans("VersionRecommanded").' --';
196
-                if ($newprefix=='1') print '-- '.$langs->trans("VersionExperimental").' --';
196
+				if ($newprefix=='1') print '-- '.$langs->trans("VersionExperimental").' --';
197 197
 				if ($newprefix=='2') print '-- '.$langs->trans("VersionDevelopment").' --';
198 198
 				if ($newprefix=='3') print '-- '.$langs->trans("Other").' --';
199 199
 				print '</option>';
@@ -202,67 +202,67 @@  discard block
 block discarded – undo
202 202
 			print $val."\n";	// Show menu entry
203 203
 		}
204 204
 		print '</select>';
205
-    }
206
-
207
-    /**
208
-     *  Return combo list of available menu families
209
-     *
210
-     *  @param	string		$selected        Menu pre-selected
211
-     *  @param	string		$htmlname        Name of html select
212
-     *  @param	string[]	$dirmenuarray    Directories to scan
213
-     *  @return	void
214
-     */
215
-    function select_menu_families($selected, $htmlname, $dirmenuarray)
216
-    {
205
+	}
206
+
207
+	/**
208
+	 *  Return combo list of available menu families
209
+	 *
210
+	 *  @param	string		$selected        Menu pre-selected
211
+	 *  @param	string		$htmlname        Name of html select
212
+	 *  @param	string[]	$dirmenuarray    Directories to scan
213
+	 *  @return	void
214
+	 */
215
+	function select_menu_families($selected, $htmlname, $dirmenuarray)
216
+	{
217 217
 		global $langs,$conf;
218 218
 
219
-        //$expdevmenu=array('smartphone_backoffice.php','smartphone_frontoffice.php');  // Menu to disable if $conf->global->MAIN_FEATURES_LEVEL is not set
219
+		//$expdevmenu=array('smartphone_backoffice.php','smartphone_frontoffice.php');  // Menu to disable if $conf->global->MAIN_FEATURES_LEVEL is not set
220 220
 		$expdevmenu=array();
221 221
 
222 222
 		$menuarray=array();
223 223
 
224 224
 		foreach($dirmenuarray as $dirmenu)
225 225
 		{
226
-            foreach ($conf->file->dol_document_root as $dirroot)
227
-            {
228
-                $dir=$dirroot.$dirmenu;
229
-                if (is_dir($dir))
230
-                {
231
-	                $handle=opendir($dir);
232
-	                if (is_resource($handle))
233
-	                {
234
-	        			while (($file = readdir($handle))!==false)
235
-	        			{
236
-	        				if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
237
-	        				{
238
-	        					$filelib=preg_replace('/(_backoffice|_frontoffice)?\.php$/i','',$file);
239
-	        					if (preg_match('/^index/i',$filelib)) continue;
240
-	        					if (preg_match('/^default/i',$filelib)) continue;
241
-	        					if (preg_match('/^empty/i',$filelib)) continue;
242
-	        					if (preg_match('/\.lib/i',$filelib)) continue;
243
-	        					if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file,$expdevmenu)) continue;
244
-
245
-	        					$menuarray[$filelib]=1;
246
-	        				}
247
-	        				$menuarray['all']=1;
248
-	        			}
249
-	        			closedir($handle);
250
-	                }
251
-                }
252
-            }
226
+			foreach ($conf->file->dol_document_root as $dirroot)
227
+			{
228
+				$dir=$dirroot.$dirmenu;
229
+				if (is_dir($dir))
230
+				{
231
+					$handle=opendir($dir);
232
+					if (is_resource($handle))
233
+					{
234
+						while (($file = readdir($handle))!==false)
235
+						{
236
+							if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
237
+							{
238
+								$filelib=preg_replace('/(_backoffice|_frontoffice)?\.php$/i','',$file);
239
+								if (preg_match('/^index/i',$filelib)) continue;
240
+								if (preg_match('/^default/i',$filelib)) continue;
241
+								if (preg_match('/^empty/i',$filelib)) continue;
242
+								if (preg_match('/\.lib/i',$filelib)) continue;
243
+								if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file,$expdevmenu)) continue;
244
+
245
+								$menuarray[$filelib]=1;
246
+							}
247
+							$menuarray['all']=1;
248
+						}
249
+						closedir($handle);
250
+					}
251
+				}
252
+			}
253 253
 		}
254 254
 
255 255
 		ksort($menuarray);
256 256
 
257 257
 		// Affichage liste deroulante des menus
258
-        print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
259
-        $oldprefix='';
258
+		print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
259
+		$oldprefix='';
260 260
 		foreach ($menuarray as $key => $val)
261 261
 		{
262 262
 			$tab=explode('_',$key);
263 263
 			$newprefix=$tab[0];
264 264
 			print '<option value="'.$key.'"';
265
-            if ($key == $selected)
265
+			if ($key == $selected)
266 266
 			{
267 267
 				print '	selected';
268 268
 			}
@@ -272,21 +272,21 @@  discard block
 block discarded – undo
272 272
 			print '</option>'."\n";
273 273
 		}
274 274
 		print '</select>';
275
-    }
276
-
277
-
278
-    /**
279
-     *  Return a HTML select list of timezones
280
-     *
281
-     *  @param	string		$selected        Menu pre-selectionnee
282
-     *  @param  string		$htmlname        Nom de la zone select
283
-     *  @return	void
284
-     */
285
-    function select_timezone($selected,$htmlname)
286
-    {
275
+	}
276
+
277
+
278
+	/**
279
+	 *  Return a HTML select list of timezones
280
+	 *
281
+	 *  @param	string		$selected        Menu pre-selectionnee
282
+	 *  @param  string		$htmlname        Nom de la zone select
283
+	 *  @return	void
284
+	 */
285
+	function select_timezone($selected,$htmlname)
286
+	{
287 287
 		global $langs,$conf;
288 288
 
289
-        print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
289
+		print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
290 290
 		print '<option value="-1">&nbsp;</option>';
291 291
 
292 292
 		$arraytz=array(
@@ -345,24 +345,24 @@  discard block
 block discarded – undo
345 345
 		$sql = "SELECT code, label, width, height, unit";
346 346
 		$sql.= " FROM ".MAIN_DB_PREFIX."c_paper_format";
347 347
 		$sql.= " WHERE active=1";
348
-        if ($filter) $sql.=" AND code LIKE '%".$this->db->escape($filter)."%'";
349
-
350
-        $resql=$this->db->query($sql);
351
-        if ($resql)
352
-        {
353
-            $num=$this->db->num_rows($resql);
354
-            $i=0;
355
-            while ($i < $num)
356
-            {
357
-                $obj=$this->db->fetch_object($resql);
358
-                $unitKey = $langs->trans('SizeUnit'.$obj->unit);
359
-
360
-                $paperformat[$obj->code]= $langs->trans('PaperFormat'.strtoupper($obj->code)).' - '.round($obj->width).'x'.round($obj->height).' '.($unitKey == 'SizeUnit'.$obj->unit ? $obj->unit : $unitKey);
361
-
362
-                $i++;
363
-            }
364
-        }
365
-        else
348
+		if ($filter) $sql.=" AND code LIKE '%".$this->db->escape($filter)."%'";
349
+
350
+		$resql=$this->db->query($sql);
351
+		if ($resql)
352
+		{
353
+			$num=$this->db->num_rows($resql);
354
+			$i=0;
355
+			while ($i < $num)
356
+			{
357
+				$obj=$this->db->fetch_object($resql);
358
+				$unitKey = $langs->trans('SizeUnit'.$obj->unit);
359
+
360
+				$paperformat[$obj->code]= $langs->trans('PaperFormat'.strtoupper($obj->code)).' - '.round($obj->width).'x'.round($obj->height).' '.($unitKey == 'SizeUnit'.$obj->unit ? $obj->unit : $unitKey);
361
+
362
+				$i++;
363
+			}
364
+		}
365
+		else
366 366
 		{
367 367
 			dol_print_error($this->db);
368 368
 			return '';
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 		}
379 379
 		foreach ($paperformat as $key => $value)
380 380
 		{
381
-            if ($selected == $key)
381
+			if ($selected == $key)
382 382
 			{
383 383
 				$out.= '<option value="'.$key.'" selected>'.$value.'</option>';
384 384
 			}
Please login to merge, or discard this patch.
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -58,59 +58,59 @@  discard block
 block discarded – undo
58 58
 	 *      @param      int         $showcode       Add language code into label
59 59
 	 *      @return		string						Return HTML select string with list of languages
60 60
 	 */
61
-	function select_language($selected='', $htmlname='lang_id', $showauto=0, $filter=null, $showempty='', $showwarning=0, $disabled=0, $morecss='', $showcode=0)
61
+	function select_language($selected = '', $htmlname = 'lang_id', $showauto = 0, $filter = null, $showempty = '', $showwarning = 0, $disabled = 0, $morecss = '', $showcode = 0)
62 62
 	{
63 63
 		global $langs;
64 64
 
65
-		$langs_available=$langs->get_available_languages(DOL_DOCUMENT_ROOT,12);
65
+		$langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12);
66 66
 
67
-		$out='';
67
+		$out = '';
68 68
 
69
-		$out.= '<select class="flat'.($morecss?' '.$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled?' disabled':'').'>';
69
+		$out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled ? ' disabled' : '').'>';
70 70
 		if ($showempty)
71 71
 		{
72
-			$out.= '<option value="0"';
73
-			if ($selected == '') $out.= ' selected';
74
-			$out.= '>';
75
-			if ($showempty != '1') $out.=$showempty;
76
-			else $out.='&nbsp;';
77
-			$out.='</option>';
72
+			$out .= '<option value="0"';
73
+			if ($selected == '') $out .= ' selected';
74
+			$out .= '>';
75
+			if ($showempty != '1') $out .= $showempty;
76
+			else $out .= '&nbsp;';
77
+			$out .= '</option>';
78 78
 		}
79 79
 		if ($showauto)
80 80
 		{
81
-			$out.= '<option value="auto"';
82
-			if ($selected == 'auto') $out.= ' selected';
83
-			$out.= '>'.$langs->trans("AutoDetectLang").'</option>';
81
+			$out .= '<option value="auto"';
82
+			if ($selected == 'auto') $out .= ' selected';
83
+			$out .= '>'.$langs->trans("AutoDetectLang").'</option>';
84 84
 		}
85 85
 
86 86
 		asort($langs_available);
87 87
 
88 88
 		foreach ($langs_available as $key => $value)
89 89
 		{
90
-		    $valuetoshow=$value;
91
-		    if ($showcode) $valuetoshow=$key.' - '.$value;
90
+		    $valuetoshow = $value;
91
+		    if ($showcode) $valuetoshow = $key.' - '.$value;
92 92
 
93 93
 			if ($filter && is_array($filter))
94 94
 			{
95
-				if ( ! array_key_exists($key, $filter))
95
+				if (!array_key_exists($key, $filter))
96 96
 				{
97
-					$out.= '<option value="'.$key.'">'.$valuetoshow.'</option>';
97
+					$out .= '<option value="'.$key.'">'.$valuetoshow.'</option>';
98 98
 				}
99 99
 			}
100 100
 			else if ($selected == $key)
101 101
 			{
102
-				$out.= '<option value="'.$key.'" selected>'.$valuetoshow.'</option>';
102
+				$out .= '<option value="'.$key.'" selected>'.$valuetoshow.'</option>';
103 103
 			}
104 104
 			else
105 105
 			{
106
-				$out.= '<option value="'.$key.'">'.$valuetoshow.'</option>';
106
+				$out .= '<option value="'.$key.'">'.$valuetoshow.'</option>';
107 107
 			}
108 108
 		}
109
-		$out.= '</select>';
109
+		$out .= '</select>';
110 110
 
111 111
 		// Make select dynamic
112
-        include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
113
-        $out.= ajax_combobox($htmlname);
112
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
113
+        $out .= ajax_combobox($htmlname);
114 114
 
115 115
 		return $out;
116 116
 	}
@@ -124,51 +124,51 @@  discard block
 block discarded – undo
124 124
      *    @param    string		$moreattrib      More attributes on html select tag
125 125
      *    @return	integer|null
126 126
      */
127
-    function select_menu($selected, $htmlname, $dirmenuarray, $moreattrib='')
127
+    function select_menu($selected, $htmlname, $dirmenuarray, $moreattrib = '')
128 128
     {
129
-        global $langs,$conf;
129
+        global $langs, $conf;
130 130
 
131 131
         // Clean parameters
132 132
 
133 133
 
134 134
         // Check parameters
135
-        if (! is_array($dirmenuarray)) return -1;
135
+        if (!is_array($dirmenuarray)) return -1;
136 136
 
137
-		$menuarray=array();
137
+		$menuarray = array();
138 138
         foreach ($conf->file->dol_document_root as $dirroot)
139 139
         {
140
-            foreach($dirmenuarray as $dirtoscan)
140
+            foreach ($dirmenuarray as $dirtoscan)
141 141
             {
142
-                $dir=$dirroot.$dirtoscan;
142
+                $dir = $dirroot.$dirtoscan;
143 143
                 //print $dir.'<br>';
144 144
                 if (is_dir($dir))
145 145
                 {
146
-    	            $handle=opendir($dir);
146
+    	            $handle = opendir($dir);
147 147
     	            if (is_resource($handle))
148 148
     	            {
149
-    	                while (($file = readdir($handle))!==false)
149
+    	                while (($file = readdir($handle)) !== false)
150 150
     	                {
151 151
     	                    if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && substr($file, 0, 5) != 'index')
152 152
     	                    {
153
-    	                        if (preg_match('/lib\.php$/i',$file)) continue;	// We exclude library files
154
-    	                        if (preg_match('/eldy_(backoffice|frontoffice)\.php$/i',$file)) continue;		// We exclude all menu manager files
155
-    	                        if (preg_match('/auguria_(backoffice|frontoffice)\.php$/i',$file)) continue;	// We exclude all menu manager files
156
-    	                        if (preg_match('/smartphone_(backoffice|frontoffice)\.php$/i',$file)) continue;	// We exclude all menu manager files
153
+    	                        if (preg_match('/lib\.php$/i', $file)) continue; // We exclude library files
154
+    	                        if (preg_match('/eldy_(backoffice|frontoffice)\.php$/i', $file)) continue; // We exclude all menu manager files
155
+    	                        if (preg_match('/auguria_(backoffice|frontoffice)\.php$/i', $file)) continue; // We exclude all menu manager files
156
+    	                        if (preg_match('/smartphone_(backoffice|frontoffice)\.php$/i', $file)) continue; // We exclude all menu manager files
157 157
 
158
-    	                        $filelib=preg_replace('/\.php$/i','',$file);
159
-    	        				$prefix='';
158
+    	                        $filelib = preg_replace('/\.php$/i', '', $file);
159
+    	        				$prefix = '';
160 160
     	        				// 0=Recommanded, 1=Experimental, 2=Developpement, 3=Other
161
-    	        				if (preg_match('/^eldy/i',$file)) $prefix='0';
162
-                                else if (preg_match('/^smartphone/i',$file)) $prefix='2';
163
-    	        				else $prefix='3';
161
+    	        				if (preg_match('/^eldy/i', $file)) $prefix = '0';
162
+                                else if (preg_match('/^smartphone/i', $file)) $prefix = '2';
163
+    	        				else $prefix = '3';
164 164
 
165 165
     	                        if ($file == $selected)
166 166
     	                        {
167
-    	        					$menuarray[$prefix.'_'.$file]='<option value="'.$file.'" selected>'.$filelib.'</option>';
167
+    	        					$menuarray[$prefix.'_'.$file] = '<option value="'.$file.'" selected>'.$filelib.'</option>';
168 168
     	                        }
169 169
     	                        else
170 170
     	                        {
171
-    	                            $menuarray[$prefix.'_'.$file]='<option value="'.$file.'">'.$filelib.'</option>';
171
+    	                            $menuarray[$prefix.'_'.$file] = '<option value="'.$file.'">'.$filelib.'</option>';
172 172
     	                        }
173 173
     	                    }
174 174
     	                }
@@ -180,26 +180,26 @@  discard block
 block discarded – undo
180 180
 		ksort($menuarray);
181 181
 
182 182
 		// Output combo list of menus
183
-        print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>';
184
-        $oldprefix='';
183
+        print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
184
+        $oldprefix = '';
185 185
 		foreach ($menuarray as $key => $val)
186 186
 		{
187
-			$tab=explode('_',$key);
188
-			$newprefix=$tab[0];
189
-			if ($newprefix=='1' && ($conf->global->MAIN_FEATURES_LEVEL < 1)) continue;
190
-			if ($newprefix=='2' && ($conf->global->MAIN_FEATURES_LEVEL < 2)) continue;
187
+			$tab = explode('_', $key);
188
+			$newprefix = $tab[0];
189
+			if ($newprefix == '1' && ($conf->global->MAIN_FEATURES_LEVEL < 1)) continue;
190
+			if ($newprefix == '2' && ($conf->global->MAIN_FEATURES_LEVEL < 2)) continue;
191 191
 			if ($newprefix != $oldprefix)	// Add separators
192 192
 			{
193 193
 				// Affiche titre
194 194
 				print '<option value="-1" disabled>';
195
-				if ($newprefix=='0') print '-- '.$langs->trans("VersionRecommanded").' --';
196
-                if ($newprefix=='1') print '-- '.$langs->trans("VersionExperimental").' --';
197
-				if ($newprefix=='2') print '-- '.$langs->trans("VersionDevelopment").' --';
198
-				if ($newprefix=='3') print '-- '.$langs->trans("Other").' --';
195
+				if ($newprefix == '0') print '-- '.$langs->trans("VersionRecommanded").' --';
196
+                if ($newprefix == '1') print '-- '.$langs->trans("VersionExperimental").' --';
197
+				if ($newprefix == '2') print '-- '.$langs->trans("VersionDevelopment").' --';
198
+				if ($newprefix == '3') print '-- '.$langs->trans("Other").' --';
199 199
 				print '</option>';
200
-				$oldprefix=$newprefix;
200
+				$oldprefix = $newprefix;
201 201
 			}
202
-			print $val."\n";	// Show menu entry
202
+			print $val."\n"; // Show menu entry
203 203
 		}
204 204
 		print '</select>';
205 205
     }
@@ -214,37 +214,37 @@  discard block
 block discarded – undo
214 214
      */
215 215
     function select_menu_families($selected, $htmlname, $dirmenuarray)
216 216
     {
217
-		global $langs,$conf;
217
+		global $langs, $conf;
218 218
 
219 219
         //$expdevmenu=array('smartphone_backoffice.php','smartphone_frontoffice.php');  // Menu to disable if $conf->global->MAIN_FEATURES_LEVEL is not set
220
-		$expdevmenu=array();
220
+		$expdevmenu = array();
221 221
 
222
-		$menuarray=array();
222
+		$menuarray = array();
223 223
 
224
-		foreach($dirmenuarray as $dirmenu)
224
+		foreach ($dirmenuarray as $dirmenu)
225 225
 		{
226 226
             foreach ($conf->file->dol_document_root as $dirroot)
227 227
             {
228
-                $dir=$dirroot.$dirmenu;
228
+                $dir = $dirroot.$dirmenu;
229 229
                 if (is_dir($dir))
230 230
                 {
231
-	                $handle=opendir($dir);
231
+	                $handle = opendir($dir);
232 232
 	                if (is_resource($handle))
233 233
 	                {
234
-	        			while (($file = readdir($handle))!==false)
234
+	        			while (($file = readdir($handle)) !== false)
235 235
 	        			{
236 236
 	        				if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
237 237
 	        				{
238
-	        					$filelib=preg_replace('/(_backoffice|_frontoffice)?\.php$/i','',$file);
239
-	        					if (preg_match('/^index/i',$filelib)) continue;
240
-	        					if (preg_match('/^default/i',$filelib)) continue;
241
-	        					if (preg_match('/^empty/i',$filelib)) continue;
242
-	        					if (preg_match('/\.lib/i',$filelib)) continue;
243
-	        					if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file,$expdevmenu)) continue;
244
-
245
-	        					$menuarray[$filelib]=1;
238
+	        					$filelib = preg_replace('/(_backoffice|_frontoffice)?\.php$/i', '', $file);
239
+	        					if (preg_match('/^index/i', $filelib)) continue;
240
+	        					if (preg_match('/^default/i', $filelib)) continue;
241
+	        					if (preg_match('/^empty/i', $filelib)) continue;
242
+	        					if (preg_match('/\.lib/i', $filelib)) continue;
243
+	        					if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file, $expdevmenu)) continue;
244
+
245
+	        					$menuarray[$filelib] = 1;
246 246
 	        				}
247
-	        				$menuarray['all']=1;
247
+	        				$menuarray['all'] = 1;
248 248
 	        			}
249 249
 	        			closedir($handle);
250 250
 	                }
@@ -256,11 +256,11 @@  discard block
 block discarded – undo
256 256
 
257 257
 		// Affichage liste deroulante des menus
258 258
         print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
259
-        $oldprefix='';
259
+        $oldprefix = '';
260 260
 		foreach ($menuarray as $key => $val)
261 261
 		{
262
-			$tab=explode('_',$key);
263
-			$newprefix=$tab[0];
262
+			$tab = explode('_', $key);
263
+			$newprefix = $tab[0];
264 264
 			print '<option value="'.$key.'"';
265 265
             if ($key == $selected)
266 266
 			{
@@ -282,14 +282,14 @@  discard block
 block discarded – undo
282 282
      *  @param  string		$htmlname        Nom de la zone select
283 283
      *  @return	void
284 284
      */
285
-    function select_timezone($selected,$htmlname)
285
+    function select_timezone($selected, $htmlname)
286 286
     {
287
-		global $langs,$conf;
287
+		global $langs, $conf;
288 288
 
289 289
         print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
290 290
 		print '<option value="-1">&nbsp;</option>';
291 291
 
292
-		$arraytz=array(
292
+		$arraytz = array(
293 293
 			"Pacific/Midway"=>"GMT-11:00",
294 294
 			"Pacific/Fakaofo"=>"GMT-10:00",
295 295
 			"America/Anchorage"=>"GMT-09:00",
@@ -336,28 +336,28 @@  discard block
 block discarded – undo
336 336
 	 * 		@param		int		$showempty		Add empty value
337 337
 	 * 		@return		string					Return HTML output
338 338
 	 */
339
-	function select_paper_format($selected='',$htmlname='paperformat_id',$filter=0,$showempty=0)
339
+	function select_paper_format($selected = '', $htmlname = 'paperformat_id', $filter = 0, $showempty = 0)
340 340
 	{
341 341
 		global $langs;
342 342
 
343 343
 		$langs->load("dict");
344 344
 
345 345
 		$sql = "SELECT code, label, width, height, unit";
346
-		$sql.= " FROM ".MAIN_DB_PREFIX."c_paper_format";
347
-		$sql.= " WHERE active=1";
348
-        if ($filter) $sql.=" AND code LIKE '%".$this->db->escape($filter)."%'";
346
+		$sql .= " FROM ".MAIN_DB_PREFIX."c_paper_format";
347
+		$sql .= " WHERE active=1";
348
+        if ($filter) $sql .= " AND code LIKE '%".$this->db->escape($filter)."%'";
349 349
 
350
-        $resql=$this->db->query($sql);
350
+        $resql = $this->db->query($sql);
351 351
         if ($resql)
352 352
         {
353
-            $num=$this->db->num_rows($resql);
354
-            $i=0;
353
+            $num = $this->db->num_rows($resql);
354
+            $i = 0;
355 355
             while ($i < $num)
356 356
             {
357
-                $obj=$this->db->fetch_object($resql);
357
+                $obj = $this->db->fetch_object($resql);
358 358
                 $unitKey = $langs->trans('SizeUnit'.$obj->unit);
359 359
 
360
-                $paperformat[$obj->code]= $langs->trans('PaperFormat'.strtoupper($obj->code)).' - '.round($obj->width).'x'.round($obj->height).' '.($unitKey == 'SizeUnit'.$obj->unit ? $obj->unit : $unitKey);
360
+                $paperformat[$obj->code] = $langs->trans('PaperFormat'.strtoupper($obj->code)).' - '.round($obj->width).'x'.round($obj->height).' '.($unitKey == 'SizeUnit'.$obj->unit ? $obj->unit : $unitKey);
361 361
 
362 362
                 $i++;
363 363
             }
@@ -367,27 +367,27 @@  discard block
 block discarded – undo
367 367
 			dol_print_error($this->db);
368 368
 			return '';
369 369
 		}
370
-		$out='';
370
+		$out = '';
371 371
 
372
-		$out.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
372
+		$out .= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
373 373
 		if ($showempty)
374 374
 		{
375
-			$out.= '<option value=""';
376
-			if ($selected == '') $out.= ' selected';
377
-			$out.= '>&nbsp;</option>';
375
+			$out .= '<option value=""';
376
+			if ($selected == '') $out .= ' selected';
377
+			$out .= '>&nbsp;</option>';
378 378
 		}
379 379
 		foreach ($paperformat as $key => $value)
380 380
 		{
381 381
             if ($selected == $key)
382 382
 			{
383
-				$out.= '<option value="'.$key.'" selected>'.$value.'</option>';
383
+				$out .= '<option value="'.$key.'" selected>'.$value.'</option>';
384 384
 			}
385 385
 			else
386 386
 			{
387
-				$out.= '<option value="'.$key.'">'.$value.'</option>';
387
+				$out .= '<option value="'.$key.'">'.$value.'</option>';
388 388
 			}
389 389
 		}
390
-		$out.= '</select>';
390
+		$out .= '</select>';
391 391
 
392 392
 		return $out;
393 393
 	}
Please login to merge, or discard this patch.
Braces   +95 added lines, -40 removed lines patch added patch discarded remove patch
@@ -70,16 +70,23 @@  discard block
 block discarded – undo
70 70
 		if ($showempty)
71 71
 		{
72 72
 			$out.= '<option value="0"';
73
-			if ($selected == '') $out.= ' selected';
73
+			if ($selected == '') {
74
+				$out.= ' selected';
75
+			}
74 76
 			$out.= '>';
75
-			if ($showempty != '1') $out.=$showempty;
76
-			else $out.='&nbsp;';
77
+			if ($showempty != '1') {
78
+				$out.=$showempty;
79
+			} else {
80
+				$out.='&nbsp;';
81
+			}
77 82
 			$out.='</option>';
78 83
 		}
79 84
 		if ($showauto)
80 85
 		{
81 86
 			$out.= '<option value="auto"';
82
-			if ($selected == 'auto') $out.= ' selected';
87
+			if ($selected == 'auto') {
88
+				$out.= ' selected';
89
+			}
83 90
 			$out.= '>'.$langs->trans("AutoDetectLang").'</option>';
84 91
 		}
85 92
 
@@ -88,7 +95,9 @@  discard block
 block discarded – undo
88 95
 		foreach ($langs_available as $key => $value)
89 96
 		{
90 97
 		    $valuetoshow=$value;
91
-		    if ($showcode) $valuetoshow=$key.' - '.$value;
98
+		    if ($showcode) {
99
+		    	$valuetoshow=$key.' - '.$value;
100
+		    }
92 101
 
93 102
 			if ($filter && is_array($filter))
94 103
 			{
@@ -96,12 +105,10 @@  discard block
 block discarded – undo
96 105
 				{
97 106
 					$out.= '<option value="'.$key.'">'.$valuetoshow.'</option>';
98 107
 				}
99
-			}
100
-			else if ($selected == $key)
108
+			} else if ($selected == $key)
101 109
 			{
102 110
 				$out.= '<option value="'.$key.'" selected>'.$valuetoshow.'</option>';
103
-			}
104
-			else
111
+			} else
105 112
 			{
106 113
 				$out.= '<option value="'.$key.'">'.$valuetoshow.'</option>';
107 114
 			}
@@ -132,7 +139,9 @@  discard block
 block discarded – undo
132 139
 
133 140
 
134 141
         // Check parameters
135
-        if (! is_array($dirmenuarray)) return -1;
142
+        if (! is_array($dirmenuarray)) {
143
+        	return -1;
144
+        }
136 145
 
137 146
 		$menuarray=array();
138 147
         foreach ($conf->file->dol_document_root as $dirroot)
@@ -150,23 +159,38 @@  discard block
 block discarded – undo
150 159
     	                {
151 160
     	                    if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && substr($file, 0, 5) != 'index')
152 161
     	                    {
153
-    	                        if (preg_match('/lib\.php$/i',$file)) continue;	// We exclude library files
154
-    	                        if (preg_match('/eldy_(backoffice|frontoffice)\.php$/i',$file)) continue;		// We exclude all menu manager files
155
-    	                        if (preg_match('/auguria_(backoffice|frontoffice)\.php$/i',$file)) continue;	// We exclude all menu manager files
156
-    	                        if (preg_match('/smartphone_(backoffice|frontoffice)\.php$/i',$file)) continue;	// We exclude all menu manager files
162
+    	                        if (preg_match('/lib\.php$/i',$file)) {
163
+    	                        	continue;
164
+    	                        }
165
+    	                        // We exclude library files
166
+    	                        if (preg_match('/eldy_(backoffice|frontoffice)\.php$/i',$file)) {
167
+    	                        	continue;
168
+    	                        }
169
+    	                        // We exclude all menu manager files
170
+    	                        if (preg_match('/auguria_(backoffice|frontoffice)\.php$/i',$file)) {
171
+    	                        	continue;
172
+    	                        }
173
+    	                        // We exclude all menu manager files
174
+    	                        if (preg_match('/smartphone_(backoffice|frontoffice)\.php$/i',$file)) {
175
+    	                        	continue;
176
+    	                        }
177
+    	                        // We exclude all menu manager files
157 178
 
158 179
     	                        $filelib=preg_replace('/\.php$/i','',$file);
159 180
     	        				$prefix='';
160 181
     	        				// 0=Recommanded, 1=Experimental, 2=Developpement, 3=Other
161
-    	        				if (preg_match('/^eldy/i',$file)) $prefix='0';
162
-                                else if (preg_match('/^smartphone/i',$file)) $prefix='2';
163
-    	        				else $prefix='3';
182
+    	        				if (preg_match('/^eldy/i',$file)) {
183
+    	        					$prefix='0';
184
+    	        				} else if (preg_match('/^smartphone/i',$file)) {
185
+                                	$prefix='2';
186
+                                } else {
187
+    	        					$prefix='3';
188
+    	        				}
164 189
 
165 190
     	                        if ($file == $selected)
166 191
     	                        {
167 192
     	        					$menuarray[$prefix.'_'.$file]='<option value="'.$file.'" selected>'.$filelib.'</option>';
168
-    	                        }
169
-    	                        else
193
+    	                        } else
170 194
     	                        {
171 195
     	                            $menuarray[$prefix.'_'.$file]='<option value="'.$file.'">'.$filelib.'</option>';
172 196
     	                        }
@@ -186,16 +210,30 @@  discard block
 block discarded – undo
186 210
 		{
187 211
 			$tab=explode('_',$key);
188 212
 			$newprefix=$tab[0];
189
-			if ($newprefix=='1' && ($conf->global->MAIN_FEATURES_LEVEL < 1)) continue;
190
-			if ($newprefix=='2' && ($conf->global->MAIN_FEATURES_LEVEL < 2)) continue;
191
-			if ($newprefix != $oldprefix)	// Add separators
213
+			if ($newprefix=='1' && ($conf->global->MAIN_FEATURES_LEVEL < 1)) {
214
+				continue;
215
+			}
216
+			if ($newprefix=='2' && ($conf->global->MAIN_FEATURES_LEVEL < 2)) {
217
+				continue;
218
+			}
219
+			if ($newprefix != $oldprefix) {
220
+				// Add separators
192 221
 			{
193 222
 				// Affiche titre
194 223
 				print '<option value="-1" disabled>';
195
-				if ($newprefix=='0') print '-- '.$langs->trans("VersionRecommanded").' --';
196
-                if ($newprefix=='1') print '-- '.$langs->trans("VersionExperimental").' --';
197
-				if ($newprefix=='2') print '-- '.$langs->trans("VersionDevelopment").' --';
198
-				if ($newprefix=='3') print '-- '.$langs->trans("Other").' --';
224
+			}
225
+				if ($newprefix=='0') {
226
+					print '-- '.$langs->trans("VersionRecommanded").' --';
227
+				}
228
+                if ($newprefix=='1') {
229
+                	print '-- '.$langs->trans("VersionExperimental").' --';
230
+                }
231
+				if ($newprefix=='2') {
232
+					print '-- '.$langs->trans("VersionDevelopment").' --';
233
+				}
234
+				if ($newprefix=='3') {
235
+					print '-- '.$langs->trans("Other").' --';
236
+				}
199 237
 				print '</option>';
200 238
 				$oldprefix=$newprefix;
201 239
 			}
@@ -236,11 +274,21 @@  discard block
 block discarded – undo
236 274
 	        				if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
237 275
 	        				{
238 276
 	        					$filelib=preg_replace('/(_backoffice|_frontoffice)?\.php$/i','',$file);
239
-	        					if (preg_match('/^index/i',$filelib)) continue;
240
-	        					if (preg_match('/^default/i',$filelib)) continue;
241
-	        					if (preg_match('/^empty/i',$filelib)) continue;
242
-	        					if (preg_match('/\.lib/i',$filelib)) continue;
243
-	        					if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file,$expdevmenu)) continue;
277
+	        					if (preg_match('/^index/i',$filelib)) {
278
+	        						continue;
279
+	        					}
280
+	        					if (preg_match('/^default/i',$filelib)) {
281
+	        						continue;
282
+	        					}
283
+	        					if (preg_match('/^empty/i',$filelib)) {
284
+	        						continue;
285
+	        					}
286
+	        					if (preg_match('/\.lib/i',$filelib)) {
287
+	        						continue;
288
+	        					}
289
+	        					if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file,$expdevmenu)) {
290
+	        						continue;
291
+	        					}
244 292
 
245 293
 	        					$menuarray[$filelib]=1;
246 294
 	        				}
@@ -267,8 +315,11 @@  discard block
 block discarded – undo
267 315
 				print '	selected';
268 316
 			}
269 317
 			print '>';
270
-			if ($key == 'all') print $langs->trans("AllMenus");
271
-			else print $key;
318
+			if ($key == 'all') {
319
+				print $langs->trans("AllMenus");
320
+			} else {
321
+				print $key;
322
+			}
272 323
 			print '</option>'."\n";
273 324
 		}
274 325
 		print '</select>';
@@ -319,7 +370,9 @@  discard block
 block discarded – undo
319 370
 		foreach ($arraytz as $lib => $gmt)
320 371
 		{
321 372
 			print '<option value="'.$lib.'"';
322
-			if ($selected == $lib || $selected == $gmt) print ' selected';
373
+			if ($selected == $lib || $selected == $gmt) {
374
+				print ' selected';
375
+			}
323 376
 			print '>'.$gmt.'</option>'."\n";
324 377
 		}
325 378
 		print '</select>';
@@ -345,7 +398,9 @@  discard block
 block discarded – undo
345 398
 		$sql = "SELECT code, label, width, height, unit";
346 399
 		$sql.= " FROM ".MAIN_DB_PREFIX."c_paper_format";
347 400
 		$sql.= " WHERE active=1";
348
-        if ($filter) $sql.=" AND code LIKE '%".$this->db->escape($filter)."%'";
401
+        if ($filter) {
402
+        	$sql.=" AND code LIKE '%".$this->db->escape($filter)."%'";
403
+        }
349 404
 
350 405
         $resql=$this->db->query($sql);
351 406
         if ($resql)
@@ -361,8 +416,7 @@  discard block
 block discarded – undo
361 416
 
362 417
                 $i++;
363 418
             }
364
-        }
365
-        else
419
+        } else
366 420
 		{
367 421
 			dol_print_error($this->db);
368 422
 			return '';
@@ -373,7 +427,9 @@  discard block
 block discarded – undo
373 427
 		if ($showempty)
374 428
 		{
375 429
 			$out.= '<option value=""';
376
-			if ($selected == '') $out.= ' selected';
430
+			if ($selected == '') {
431
+				$out.= ' selected';
432
+			}
377 433
 			$out.= '>&nbsp;</option>';
378 434
 		}
379 435
 		foreach ($paperformat as $key => $value)
@@ -381,8 +437,7 @@  discard block
 block discarded – undo
381 437
             if ($selected == $key)
382 438
 			{
383 439
 				$out.= '<option value="'.$key.'" selected>'.$value.'</option>';
384
-			}
385
-			else
440
+			} else
386 441
 			{
387 442
 				$out.= '<option value="'.$key.'">'.$value.'</option>';
388 443
 			}
Please login to merge, or discard this patch.