Test Failed
Branch develop (86e751)
by Laurent
34:11
created
htdocs/core/class/stats.class.php 3 patches
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -45,16 +45,16 @@  discard block
 block discarded – undo
45 45
 	{
46 46
 		global $conf,$user,$langs;
47 47
 
48
-	    if ($startyear > $endyear) return -1;
48
+		if ($startyear > $endyear) return -1;
49 49
 
50 50
 		$datay=array();
51 51
 
52 52
 		// Search into cache
53 53
 		if (! empty($cachedelay))
54
-	    {
55
-	    	include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
56
-	    	include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
57
-	    }
54
+		{
55
+			include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
56
+			include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
57
+		}
58 58
 
59 59
 		$newpathofdestfile=$conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix)?'':$this->cachefilesuffix.'_').$langs->defaultlang.'_entity.'.$conf->entity.'_user'.$user->id.'.cache';
60 60
 		$newmask='0644';
@@ -139,45 +139,45 @@  discard block
 block discarded – undo
139 139
 	{
140 140
 		global $conf,$user,$langs;
141 141
 
142
-        if ($startyear > $endyear) return -1;
143
-
144
-        $datay=array();
145
-
146
-        // Search into cache
147
-        if (! empty($cachedelay))
148
-        {
149
-        	include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
150
-        	include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
151
-        }
152
-
153
-        $newpathofdestfile=$conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix)?'':$this->cachefilesuffix.'_').$langs->defaultlang.'_entity.'.$conf->entity.'_user'.$user->id.'.cache';
154
-        $newmask='0644';
155
-
156
-        $nowgmt = dol_now();
157
-
158
-        $foundintocache=0;
159
-        if ($cachedelay > 0)
160
-        {
161
-        	$filedate=dol_filemtime($newpathofdestfile);
162
-        	if ($filedate >= ($nowgmt - $cachedelay))
163
-        	{
164
-        		$foundintocache=1;
165
-
166
-        		$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$filedate;
167
-        	}
168
-        	else
169
-        	{
170
-        		dol_syslog(get_class($this).'::'.__FUNCTION__." cache file ".$newpathofdestfile." is not found or older than now - cachedelay (".$nowgmt." - ".$cachedelay.") so we can't use it.");
171
-        	}
172
-        }
173
-
174
-        // Load file into $data
175
-        if ($foundintocache)    // Cache file found and is not too old
176
-        {
177
-        	dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
178
-        	$data = json_decode(file_get_contents($newpathofdestfile), true);
179
-        }
180
-        else
142
+		if ($startyear > $endyear) return -1;
143
+
144
+		$datay=array();
145
+
146
+		// Search into cache
147
+		if (! empty($cachedelay))
148
+		{
149
+			include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
150
+			include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
151
+		}
152
+
153
+		$newpathofdestfile=$conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix)?'':$this->cachefilesuffix.'_').$langs->defaultlang.'_entity.'.$conf->entity.'_user'.$user->id.'.cache';
154
+		$newmask='0644';
155
+
156
+		$nowgmt = dol_now();
157
+
158
+		$foundintocache=0;
159
+		if ($cachedelay > 0)
160
+		{
161
+			$filedate=dol_filemtime($newpathofdestfile);
162
+			if ($filedate >= ($nowgmt - $cachedelay))
163
+			{
164
+				$foundintocache=1;
165
+
166
+				$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$filedate;
167
+			}
168
+			else
169
+			{
170
+				dol_syslog(get_class($this).'::'.__FUNCTION__." cache file ".$newpathofdestfile." is not found or older than now - cachedelay (".$nowgmt." - ".$cachedelay.") so we can't use it.");
171
+			}
172
+		}
173
+
174
+		// Load file into $data
175
+		if ($foundintocache)    // Cache file found and is not too old
176
+		{
177
+			dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
178
+			$data = json_decode(file_get_contents($newpathofdestfile), true);
179
+		}
180
+		else
181 181
 		{
182 182
 			$year=$startyear;
183 183
 			while($year <= $endyear)
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
 	 */
230 230
 	function getAverageByMonthWithPrevYear($endyear,$startyear)
231 231
 	{
232
-        if ($startyear > $endyear) return -1;
232
+		if ($startyear > $endyear) return -1;
233 233
 
234
-        $datay=array();
234
+		$datay=array();
235 235
 
236 236
 		$year=$startyear;
237 237
 		while($year <= $endyear)
@@ -267,43 +267,43 @@  discard block
 block discarded – undo
267 267
 	{
268 268
 		global $conf,$user,$langs;
269 269
 
270
-        $datay=array();
271
-
272
-        // Search into cache
273
-        if (! empty($cachedelay))
274
-        {
275
-        	include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
276
-        	include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
277
-        }
278
-
279
-        $newpathofdestfile=$conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix)?'':$this->cachefilesuffix.'_').$langs->defaultlang.'_entity.'.$conf->entity.'_user'.$user->id.'.cache';
280
-        $newmask='0644';
281
-
282
-        $nowgmt = dol_now();
283
-
284
-        $foundintocache=0;
285
-        if ($cachedelay > 0)
286
-        {
287
-        	$filedate=dol_filemtime($newpathofdestfile);
288
-        	if ($filedate >= ($nowgmt - $cachedelay))
289
-        	{
290
-        		$foundintocache=1;
291
-
292
-        		$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$filedate;
293
-        	}
294
-        	else
295
-        	{
296
-        		dol_syslog(get_class($this).'::'.__FUNCTION__." cache file ".$newpathofdestfile." is not found or older than now - cachedelay (".$nowgmt." - ".$cachedelay.") so we can't use it.");
297
-        	}
298
-        }
299
-
300
-        // Load file into $data
301
-        if ($foundintocache)    // Cache file found and is not too old
302
-        {
303
-        	dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
304
-        	$data = json_decode(file_get_contents($newpathofdestfile), true);
305
-        }
306
-        else
270
+		$datay=array();
271
+
272
+		// Search into cache
273
+		if (! empty($cachedelay))
274
+		{
275
+			include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
276
+			include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
277
+		}
278
+
279
+		$newpathofdestfile=$conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix)?'':$this->cachefilesuffix.'_').$langs->defaultlang.'_entity.'.$conf->entity.'_user'.$user->id.'.cache';
280
+		$newmask='0644';
281
+
282
+		$nowgmt = dol_now();
283
+
284
+		$foundintocache=0;
285
+		if ($cachedelay > 0)
286
+		{
287
+			$filedate=dol_filemtime($newpathofdestfile);
288
+			if ($filedate >= ($nowgmt - $cachedelay))
289
+			{
290
+				$foundintocache=1;
291
+
292
+				$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$filedate;
293
+			}
294
+			else
295
+			{
296
+				dol_syslog(get_class($this).'::'.__FUNCTION__." cache file ".$newpathofdestfile." is not found or older than now - cachedelay (".$nowgmt." - ".$cachedelay.") so we can't use it.");
297
+			}
298
+		}
299
+
300
+		// Load file into $data
301
+		if ($foundintocache)    // Cache file found and is not too old
302
+		{
303
+			dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
304
+			$data = json_decode(file_get_contents($newpathofdestfile), true);
305
+		}
306
+		else
307 307
 		{
308 308
 			$data=$this->getAllByProduct($year);
309 309
 			//					$data[$i][]=$datay[$year][$i][1];	// set yval for x=i
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
 				// For some $sql only
392 392
 				if (isset($row->weighted))
393 393
 				{
394
-				    $result[$i]['weighted'] = $row->weighted;
395
-				    if($i>0 && $row->weighted) $result[$i-1]['avg_weighted'] = ($result[$i-1]['weighted'] - $row->weighted) / $row->weighted * 100;
394
+					$result[$i]['weighted'] = $row->weighted;
395
+					if($i>0 && $row->weighted) $result[$i-1]['avg_weighted'] = ($result[$i-1]['weighted'] - $row->weighted) / $row->weighted * 100;
396 396
 				}
397 397
 				$i++;
398 398
 			}
@@ -407,10 +407,10 @@  discard block
 block discarded – undo
407 407
 	/**
408 408
 	 *     Renvoie le nombre de proposition par mois pour une annee donnee
409 409
 	 *
410
-     *     @param   int		$year       Year
411
-     *     @param   string	$sql        SQL
412
-     *     @param	int		$format		0=Label of absiss is a translated text, 1=Label of absiss is a number
413
-     *     @return	array				Array of nb each month
410
+	 *     @param   int		$year       Year
411
+	 *     @param   string	$sql        SQL
412
+	 *     @param	int		$format		0=Label of absiss is a translated text, 1=Label of absiss is a number
413
+	 *     @return	array				Array of nb each month
414 414
 	 */
415 415
 	function _getNbByMonth($year, $sql, $format=0)
416 416
 	{
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 	 *
461 461
 	 *     @param	int		$year       Year
462 462
 	 *     @param   string	$sql		SQL
463
-     *     @param	int		$format		0=Label of absiss is a translated text, 1=Label of absiss is a number
463
+	 *     @param	int		$format		0=Label of absiss is a translated text, 1=Label of absiss is a number
464 464
 	 *     @return	array
465 465
 	 */
466 466
 	function _getAmountByMonth($year, $sql, $format=0)
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 		  	}
485 485
 		  	$this->db->free($resql);
486 486
 		}
487
-        else dol_print_error($this->db);
487
+		else dol_print_error($this->db);
488 488
 
489 489
 		for ($i = 1 ; $i < 13 ; $i++)
490 490
 		{
@@ -506,8 +506,8 @@  discard block
 block discarded – undo
506 506
 	/**
507 507
 	 *	   Renvoie le montant moyen par mois pour une annee donnee
508 508
 	 *
509
-     *     @param	int		$year       Year
510
-     *     @param  	string	$sql        SQL
509
+	 *     @param	int		$year       Year
510
+	 *     @param  	string	$sql        SQL
511 511
 	 *     @param	int		$format		0=Label of absiss is a translated text, 1=Label of absiss is a number
512 512
 	 *     @return	array
513 513
 	 */
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 		  	}
532 532
 		  	$this->db->free($resql);
533 533
 		}
534
-        else dol_print_error($this->db);
534
+		else dol_print_error($this->db);
535 535
 
536 536
 		for ($i = 1 ; $i < 13 ; $i++)
537 537
 		{
@@ -554,9 +554,9 @@  discard block
 block discarded – undo
554 554
 	/**
555 555
 	 *	   Return number or total of product refs
556 556
 	 *
557
-     *     @param  	string	$sql        SQL
558
-     *     @param	int		$limit		Limit
559
-     *     @return	array
557
+	 *     @param  	string	$sql        SQL
558
+	 *     @param	int		$limit		Limit
559
+	 *     @return	array
560 560
 	 */
561 561
 	function _getAllByProduct($sql, $limit=10)
562 562
 	{
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 		  	if ($num > $limit) $result[$i] = array($langs->transnoentitiesnoconv("Other"),$other);
582 582
 		  	$this->db->free($resql);
583 583
 		}
584
-        else dol_print_error($this->db);
584
+		else dol_print_error($this->db);
585 585
 
586 586
 		return $result;
587 587
 	}
Please login to merge, or discard this patch.
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 abstract class Stats
31 31
 {
32 32
 	protected $db;
33
-	var $_lastfetchdate=array();	// Dates of cache file read by methods
34
-	var $cachefilesuffix='';		// Suffix to add to name of cache file (to avoid file name conflicts)
33
+	var $_lastfetchdate = array(); // Dates of cache file read by methods
34
+	var $cachefilesuffix = ''; // Suffix to add to name of cache file (to avoid file name conflicts)
35 35
 
36 36
 	/**
37 37
 	 * Return nb of elements by month for several years
@@ -41,35 +41,35 @@  discard block
 block discarded – undo
41 41
 	 * @param	int		$cachedelay		Delay we accept for cache file (0=No read, no save of cache, -1=No read but save)
42 42
 	 * @return 	array					Array of values
43 43
 	 */
44
-	function getNbByMonthWithPrevYear($endyear,$startyear,$cachedelay=0)
44
+	function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0)
45 45
 	{
46
-		global $conf,$user,$langs;
46
+		global $conf, $user, $langs;
47 47
 
48 48
 	    if ($startyear > $endyear) return -1;
49 49
 
50
-		$datay=array();
50
+		$datay = array();
51 51
 
52 52
 		// Search into cache
53
-		if (! empty($cachedelay))
53
+		if (!empty($cachedelay))
54 54
 	    {
55 55
 	    	include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
56 56
 	    	include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
57 57
 	    }
58 58
 
59
-		$newpathofdestfile=$conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix)?'':$this->cachefilesuffix.'_').$langs->defaultlang.'_entity.'.$conf->entity.'_user'.$user->id.'.cache';
60
-		$newmask='0644';
59
+		$newpathofdestfile = $conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix) ? '' : $this->cachefilesuffix.'_').$langs->defaultlang.'_entity.'.$conf->entity.'_user'.$user->id.'.cache';
60
+		$newmask = '0644';
61 61
 
62 62
 		$nowgmt = dol_now();
63 63
 
64
-		$foundintocache=0;
64
+		$foundintocache = 0;
65 65
 		if ($cachedelay > 0)
66 66
 		{
67
-			$filedate=dol_filemtime($newpathofdestfile);
67
+			$filedate = dol_filemtime($newpathofdestfile);
68 68
 			if ($filedate >= ($nowgmt - $cachedelay))
69 69
 			{
70
-				$foundintocache=1;
70
+				$foundintocache = 1;
71 71
 
72
-				$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$filedate;
72
+				$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__] = $filedate;
73 73
 			}
74 74
 			else
75 75
 			{
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 		}
86 86
 		else
87 87
 		{
88
-			$year=$startyear;
88
+			$year = $startyear;
89 89
 			while ($year <= $endyear)
90 90
 			{
91 91
 				$datay[$year] = $this->getNbByMonth($year);
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 
95 95
 			$data = array();
96 96
 
97
-			for ($i = 0 ; $i < 12 ; $i++)
97
+			for ($i = 0; $i < 12; $i++)
98 98
 			{
99
-				$data[$i][]=$datay[$endyear][$i][0];
100
-				$year=$startyear;
101
-				while($year <= $endyear)
99
+				$data[$i][] = $datay[$endyear][$i][0];
100
+				$year = $startyear;
101
+				while ($year <= $endyear)
102 102
 				{
103
-					$data[$i][]=$datay[$year][$i][1];
103
+					$data[$i][] = $datay[$year][$i][1];
104 104
 					$year++;
105 105
 				}
106 106
 			}
@@ -110,14 +110,14 @@  discard block
 block discarded – undo
110 110
 		if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == -1))
111 111
 		{
112 112
 			dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk.");
113
-			if (! dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp);
113
+			if (!dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp);
114 114
 			$fp = fopen($newpathofdestfile, 'w');
115 115
 			fwrite($fp, json_encode($data));
116 116
 			fclose($fp);
117
-			if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
117
+			if (!empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK;
118 118
 			@chmod($newpathofdestfile, octdec($newmask));
119 119
 
120
-			$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$nowgmt;
120
+			$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt;
121 121
 		}
122 122
 
123 123
 		// return array(array('Month',val1,val2,val3),...)
@@ -135,35 +135,35 @@  discard block
 block discarded – undo
135 135
 	 * @param	int		$cachedelay		Delay we accept for cache file (0=No read, no save of cache, -1=No read but save)
136 136
 	 * @return 	array					Array of values
137 137
 	 */
138
-	function getAmountByMonthWithPrevYear($endyear,$startyear,$cachedelay=0)
138
+	function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0)
139 139
 	{
140
-		global $conf,$user,$langs;
140
+		global $conf, $user, $langs;
141 141
 
142 142
         if ($startyear > $endyear) return -1;
143 143
 
144
-        $datay=array();
144
+        $datay = array();
145 145
 
146 146
         // Search into cache
147
-        if (! empty($cachedelay))
147
+        if (!empty($cachedelay))
148 148
         {
149 149
         	include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
150 150
         	include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
151 151
         }
152 152
 
153
-        $newpathofdestfile=$conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix)?'':$this->cachefilesuffix.'_').$langs->defaultlang.'_entity.'.$conf->entity.'_user'.$user->id.'.cache';
154
-        $newmask='0644';
153
+        $newpathofdestfile = $conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix) ? '' : $this->cachefilesuffix.'_').$langs->defaultlang.'_entity.'.$conf->entity.'_user'.$user->id.'.cache';
154
+        $newmask = '0644';
155 155
 
156 156
         $nowgmt = dol_now();
157 157
 
158
-        $foundintocache=0;
158
+        $foundintocache = 0;
159 159
         if ($cachedelay > 0)
160 160
         {
161
-        	$filedate=dol_filemtime($newpathofdestfile);
161
+        	$filedate = dol_filemtime($newpathofdestfile);
162 162
         	if ($filedate >= ($nowgmt - $cachedelay))
163 163
         	{
164
-        		$foundintocache=1;
164
+        		$foundintocache = 1;
165 165
 
166
-        		$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$filedate;
166
+        		$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__] = $filedate;
167 167
         	}
168 168
         	else
169 169
         	{
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
         }
180 180
         else
181 181
 		{
182
-			$year=$startyear;
183
-			while($year <= $endyear)
182
+			$year = $startyear;
183
+			while ($year <= $endyear)
184 184
 			{
185 185
 				$datay[$year] = $this->getAmountByMonth($year);
186 186
 				$year++;
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
 
189 189
 			$data = array();
190 190
 			// $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...)
191
-			for ($i = 0 ; $i < 12 ; $i++)
191
+			for ($i = 0; $i < 12; $i++)
192 192
 			{
193
-				$data[$i][]=$datay[$endyear][$i][0];	// set label
194
-				$year=$startyear;
195
-				while($year <= $endyear)
193
+				$data[$i][] = $datay[$endyear][$i][0]; // set label
194
+				$year = $startyear;
195
+				while ($year <= $endyear)
196 196
 				{
197
-					$data[$i][]=$datay[$year][$i][1];	// set yval for x=i
197
+					$data[$i][] = $datay[$year][$i][1]; // set yval for x=i
198 198
 					$year++;
199 199
 				}
200 200
 			}
@@ -204,17 +204,17 @@  discard block
 block discarded – undo
204 204
 		if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == -1))
205 205
 		{
206 206
 			dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk.");
207
-			if (! dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp);
207
+			if (!dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp);
208 208
 			$fp = fopen($newpathofdestfile, 'w');
209 209
 			if ($fp)
210 210
 			{
211 211
 				fwrite($fp, json_encode($data));
212 212
 				fclose($fp);
213
-				if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
213
+				if (!empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK;
214 214
 				@chmod($newpathofdestfile, octdec($newmask));
215 215
 			}
216 216
 			else dol_syslog("Failed to write cache file", LOG_ERR);
217
-			$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$nowgmt;
217
+			$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt;
218 218
 		}
219 219
 
220 220
 		return $data;
@@ -227,14 +227,14 @@  discard block
 block discarded – undo
227 227
 	 * @param	int		$startyear		End year
228 228
 	 * @return 	array					Array of values
229 229
 	 */
230
-	function getAverageByMonthWithPrevYear($endyear,$startyear)
230
+	function getAverageByMonthWithPrevYear($endyear, $startyear)
231 231
 	{
232 232
         if ($startyear > $endyear) return -1;
233 233
 
234
-        $datay=array();
234
+        $datay = array();
235 235
 
236
-		$year=$startyear;
237
-		while($year <= $endyear)
236
+		$year = $startyear;
237
+		while ($year <= $endyear)
238 238
 		{
239 239
 			$datay[$year] = $this->getAverageByMonth($year);
240 240
 			$year++;
@@ -242,13 +242,13 @@  discard block
 block discarded – undo
242 242
 
243 243
 		$data = array();
244 244
 
245
-		for ($i = 0 ; $i < 12 ; $i++)
245
+		for ($i = 0; $i < 12; $i++)
246 246
 		{
247
-			$data[$i][]=$datay[$endyear][$i][0];
248
-			$year=$startyear;
249
-			while($year <= $endyear)
247
+			$data[$i][] = $datay[$endyear][$i][0];
248
+			$year = $startyear;
249
+			while ($year <= $endyear)
250 250
 			{
251
-				$data[$i][]=$datay[$year][$i][1];
251
+				$data[$i][] = $datay[$year][$i][1];
252 252
 				$year++;
253 253
 			}
254 254
 		}
@@ -263,33 +263,33 @@  discard block
 block discarded – undo
263 263
 	 * @param	int		$cachedelay		Delay we accept for cache file (0=No read, no save of cache, -1=No read but save)
264 264
 	 * @return 	array					Array of values
265 265
 	 */
266
-	function getAllByProductEntry($year,$cachedelay=0)
266
+	function getAllByProductEntry($year, $cachedelay = 0)
267 267
 	{
268
-		global $conf,$user,$langs;
268
+		global $conf, $user, $langs;
269 269
 
270
-        $datay=array();
270
+        $datay = array();
271 271
 
272 272
         // Search into cache
273
-        if (! empty($cachedelay))
273
+        if (!empty($cachedelay))
274 274
         {
275 275
         	include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
276 276
         	include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
277 277
         }
278 278
 
279
-        $newpathofdestfile=$conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix)?'':$this->cachefilesuffix.'_').$langs->defaultlang.'_entity.'.$conf->entity.'_user'.$user->id.'.cache';
280
-        $newmask='0644';
279
+        $newpathofdestfile = $conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix) ? '' : $this->cachefilesuffix.'_').$langs->defaultlang.'_entity.'.$conf->entity.'_user'.$user->id.'.cache';
280
+        $newmask = '0644';
281 281
 
282 282
         $nowgmt = dol_now();
283 283
 
284
-        $foundintocache=0;
284
+        $foundintocache = 0;
285 285
         if ($cachedelay > 0)
286 286
         {
287
-        	$filedate=dol_filemtime($newpathofdestfile);
287
+        	$filedate = dol_filemtime($newpathofdestfile);
288 288
         	if ($filedate >= ($nowgmt - $cachedelay))
289 289
         	{
290
-        		$foundintocache=1;
290
+        		$foundintocache = 1;
291 291
 
292
-        		$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$filedate;
292
+        		$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__] = $filedate;
293 293
         	}
294 294
         	else
295 295
         	{
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
         }
306 306
         else
307 307
 		{
308
-			$data=$this->getAllByProduct($year);
308
+			$data = $this->getAllByProduct($year);
309 309
 			//					$data[$i][]=$datay[$year][$i][1];	// set yval for x=i
310 310
 		}
311 311
 
@@ -313,16 +313,16 @@  discard block
 block discarded – undo
313 313
 		if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == -1))
314 314
 		{
315 315
 			dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk.");
316
-			if (! dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp);
316
+			if (!dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp);
317 317
 			$fp = fopen($newpathofdestfile, 'w');
318 318
 			if ($fp)
319 319
 			{
320 320
 				fwrite($fp, json_encode($data));
321 321
 				fclose($fp);
322
-				if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
322
+				if (!empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK;
323 323
 				@chmod($newpathofdestfile, octdec($newmask));
324 324
 			}
325
-			$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$nowgmt;
325
+			$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt;
326 326
 		}
327 327
 
328 328
 		return $data;
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 		$result = array();
344 344
 
345 345
 		dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG);
346
-		$resql=$this->db->query($sql);
346
+		$resql = $this->db->query($sql);
347 347
 		if ($resql)
348 348
 		{
349 349
 			$num = $this->db->num_rows($resql);
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 		$result = array();
374 374
 
375 375
 		dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG);
376
-		$resql=$this->db->query($sql);
376
+		$resql = $this->db->query($sql);
377 377
 		if ($resql)
378 378
 		{
379 379
 			$num = $this->db->num_rows($resql);
@@ -383,16 +383,16 @@  discard block
 block discarded – undo
383 383
 				$row = $this->db->fetch_object($resql);
384 384
 				$result[$i]['year'] = $row->year;
385 385
 				$result[$i]['nb'] = $row->nb;
386
-				if($i>0 && $row->nb) $result[$i-1]['nb_diff'] = ($result[$i-1]['nb'] - $row->nb) / $row->nb * 100;
386
+				if ($i > 0 && $row->nb) $result[$i - 1]['nb_diff'] = ($result[$i - 1]['nb'] - $row->nb) / $row->nb * 100;
387 387
 				$result[$i]['total'] = $row->total;
388
-				if($i>0 && $row->total) $result[$i-1]['total_diff'] = ($result[$i-1]['total'] - $row->total) / $row->total * 100;
388
+				if ($i > 0 && $row->total) $result[$i - 1]['total_diff'] = ($result[$i - 1]['total'] - $row->total) / $row->total * 100;
389 389
 				$result[$i]['avg'] = $row->avg;
390
-				if($i>0 && $row->avg) $result[$i-1]['avg_diff'] = ($result[$i-1]['avg'] - $row->avg) / $row->avg * 100;
390
+				if ($i > 0 && $row->avg) $result[$i - 1]['avg_diff'] = ($result[$i - 1]['avg'] - $row->avg) / $row->avg * 100;
391 391
 				// For some $sql only
392 392
 				if (isset($row->weighted))
393 393
 				{
394 394
 				    $result[$i]['weighted'] = $row->weighted;
395
-				    if($i>0 && $row->weighted) $result[$i-1]['avg_weighted'] = ($result[$i-1]['weighted'] - $row->weighted) / $row->weighted * 100;
395
+				    if ($i > 0 && $row->weighted) $result[$i - 1]['avg_weighted'] = ($result[$i - 1]['weighted'] - $row->weighted) / $row->weighted * 100;
396 396
 				}
397 397
 				$i++;
398 398
 			}
@@ -412,13 +412,13 @@  discard block
 block discarded – undo
412 412
      *     @param	int		$format		0=Label of absiss is a translated text, 1=Label of absiss is a number
413 413
      *     @return	array				Array of nb each month
414 414
 	 */
415
-	function _getNbByMonth($year, $sql, $format=0)
415
+	function _getNbByMonth($year, $sql, $format = 0)
416 416
 	{
417
-		$result=array();
418
-		$res=array();
417
+		$result = array();
418
+		$res = array();
419 419
 
420 420
 		dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG);
421
-		$resql=$this->db->query($sql);
421
+		$resql = $this->db->query($sql);
422 422
 		if ($resql)
423 423
 		{
424 424
 			$num = $this->db->num_rows($resql);
@@ -437,18 +437,18 @@  discard block
 block discarded – undo
437 437
 			dol_print_error($this->db);
438 438
 		}
439 439
 
440
-		for ($i = 1 ; $i < 13 ; $i++)
440
+		for ($i = 1; $i < 13; $i++)
441 441
 		{
442
-			$res[$i] = (isset($result[$i])?$result[$i]:0);
442
+			$res[$i] = (isset($result[$i]) ? $result[$i] : 0);
443 443
 		}
444 444
 
445 445
 		$data = array();
446 446
 
447
-		for ($i = 1 ; $i < 13 ; $i++)
447
+		for ($i = 1; $i < 13; $i++)
448 448
 		{
449
-			$month=dol_print_date(dol_mktime(12,0,0,$i,1,$year),($format?"%m":"%b"));
450
-			$month=dol_substr($month,0,3);
451
-			$data[$i-1] = array($month, $res[$i]);
449
+			$month = dol_print_date(dol_mktime(12, 0, 0, $i, 1, $year), ($format ? "%m" : "%b"));
450
+			$month = dol_substr($month, 0, 3);
451
+			$data[$i - 1] = array($month, $res[$i]);
452 452
 		}
453 453
 
454 454
 		return $data;
@@ -463,14 +463,14 @@  discard block
 block discarded – undo
463 463
      *     @param	int		$format		0=Label of absiss is a translated text, 1=Label of absiss is a number
464 464
 	 *     @return	array
465 465
 	 */
466
-	function _getAmountByMonth($year, $sql, $format=0)
466
+	function _getAmountByMonth($year, $sql, $format = 0)
467 467
 	{
468
-		$result=array();
469
-		$res=array();
468
+		$result = array();
469
+		$res = array();
470 470
 
471 471
 		dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG);
472 472
 
473
-		$resql=$this->db->query($sql);
473
+		$resql = $this->db->query($sql);
474 474
 		if ($resql)
475 475
 		{
476 476
 			$num = $this->db->num_rows($resql);
@@ -486,18 +486,18 @@  discard block
 block discarded – undo
486 486
 		}
487 487
         else dol_print_error($this->db);
488 488
 
489
-		for ($i = 1 ; $i < 13 ; $i++)
489
+		for ($i = 1; $i < 13; $i++)
490 490
 		{
491
-			$res[$i] = (int) round((isset($result[$i])?$result[$i]:0));
491
+			$res[$i] = (int) round((isset($result[$i]) ? $result[$i] : 0));
492 492
 		}
493 493
 
494 494
 		$data = array();
495 495
 
496
-		for ($i = 1 ; $i < 13 ; $i++)
496
+		for ($i = 1; $i < 13; $i++)
497 497
 		{
498
-			$month=dol_print_date(dol_mktime(12,0,0,$i,1,$year),($format?"%m":"%b"));
499
-			$month=dol_substr($month,0,3);
500
-			$data[$i-1] = array($month, $res[$i]);
498
+			$month = dol_print_date(dol_mktime(12, 0, 0, $i, 1, $year), ($format ? "%m" : "%b"));
499
+			$month = dol_substr($month, 0, 3);
500
+			$data[$i - 1] = array($month, $res[$i]);
501 501
 		}
502 502
 
503 503
 		return $data;
@@ -511,13 +511,13 @@  discard block
 block discarded – undo
511 511
 	 *     @param	int		$format		0=Label of absiss is a translated text, 1=Label of absiss is a number
512 512
 	 *     @return	array
513 513
 	 */
514
-	function _getAverageByMonth($year, $sql, $format=0)
514
+	function _getAverageByMonth($year, $sql, $format = 0)
515 515
 	{
516
-		$result=array();
517
-		$res=array();
516
+		$result = array();
517
+		$res = array();
518 518
 
519 519
 		dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG);
520
-		$resql=$this->db->query($sql);
520
+		$resql = $this->db->query($sql);
521 521
 		if ($resql)
522 522
 		{
523 523
 			$num = $this->db->num_rows($resql);
@@ -533,18 +533,18 @@  discard block
 block discarded – undo
533 533
 		}
534 534
         else dol_print_error($this->db);
535 535
 
536
-		for ($i = 1 ; $i < 13 ; $i++)
536
+		for ($i = 1; $i < 13; $i++)
537 537
 		{
538
-			$res[$i] = (isset($result[$i])?$result[$i]:0);
538
+			$res[$i] = (isset($result[$i]) ? $result[$i] : 0);
539 539
 		}
540 540
 
541 541
 		$data = array();
542 542
 
543
-		for ($i = 1 ; $i < 13 ; $i++)
543
+		for ($i = 1; $i < 13; $i++)
544 544
 		{
545
-			$month=dol_print_date(dol_mktime(12,0,0,$i,1,$year),($format?"%m":"%b"));
546
-			$month=dol_substr($month,0,3);
547
-			$data[$i-1] = array($month, $res[$i]);
545
+			$month = dol_print_date(dol_mktime(12, 0, 0, $i, 1, $year), ($format ? "%m" : "%b"));
546
+			$month = dol_substr($month, 0, 3);
547
+			$data[$i - 1] = array($month, $res[$i]);
548 548
 		}
549 549
 
550 550
 		return $data;
@@ -558,27 +558,27 @@  discard block
 block discarded – undo
558 558
      *     @param	int		$limit		Limit
559 559
      *     @return	array
560 560
 	 */
561
-	function _getAllByProduct($sql, $limit=10)
561
+	function _getAllByProduct($sql, $limit = 10)
562 562
 	{
563 563
 		global $langs;
564 564
 
565
-		$result=array();
566
-		$res=array();
565
+		$result = array();
566
+		$res = array();
567 567
 
568 568
 		dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG);
569
-		$resql=$this->db->query($sql);
569
+		$resql = $this->db->query($sql);
570 570
 		if ($resql)
571 571
 		{
572 572
 			$num = $this->db->num_rows($resql);
573
-			$i = 0; $other=0;
573
+			$i = 0; $other = 0;
574 574
 			while ($i < $num)
575 575
 			{
576 576
 		  		$row = $this->db->fetch_row($resql);
577
-		  		if ($i < $limit || $num == $limit) $result[$i] = array($row[0],$row[1]);	// Ref of product, nb
577
+		  		if ($i < $limit || $num == $limit) $result[$i] = array($row[0], $row[1]); // Ref of product, nb
578 578
 		  		else $other += $row[1];
579 579
 		  		$i++;
580 580
 		  	}
581
-		  	if ($num > $limit) $result[$i] = array($langs->transnoentitiesnoconv("Other"),$other);
581
+		  	if ($num > $limit) $result[$i] = array($langs->transnoentitiesnoconv("Other"), $other);
582 582
 		  	$this->db->free($resql);
583 583
 		}
584 584
         else dol_print_error($this->db);
Please login to merge, or discard this patch.
Braces   +78 added lines, -44 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@  discard block
 block discarded – undo
45 45
 	{
46 46
 		global $conf,$user,$langs;
47 47
 
48
-	    if ($startyear > $endyear) return -1;
48
+	    if ($startyear > $endyear) {
49
+	    	return -1;
50
+	    }
49 51
 
50 52
 		$datay=array();
51 53
 
@@ -70,20 +72,20 @@  discard block
 block discarded – undo
70 72
 				$foundintocache=1;
71 73
 
72 74
 				$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$filedate;
73
-			}
74
-			else
75
+			} else
75 76
 			{
76 77
 				dol_syslog(get_class($this).'::'.__FUNCTION__." cache file ".$newpathofdestfile." is not found or older than now - cachedelay (".$nowgmt." - ".$cachedelay.") so we can't use it.");
77 78
 			}
78 79
 		}
79 80
 
80 81
 		// Load file into $data
81
-		if ($foundintocache)    // Cache file found and is not too old
82
+		if ($foundintocache) {
83
+			// Cache file found and is not too old
82 84
 		{
83 85
 			dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
84
-			$data = json_decode(file_get_contents($newpathofdestfile), true);
85 86
 		}
86
-		else
87
+			$data = json_decode(file_get_contents($newpathofdestfile), true);
88
+		} else
87 89
 		{
88 90
 			$year=$startyear;
89 91
 			while ($year <= $endyear)
@@ -110,11 +112,15 @@  discard block
 block discarded – undo
110 112
 		if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == -1))
111 113
 		{
112 114
 			dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk.");
113
-			if (! dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp);
115
+			if (! dol_is_dir($conf->user->dir_temp)) {
116
+				dol_mkdir($conf->user->dir_temp);
117
+			}
114 118
 			$fp = fopen($newpathofdestfile, 'w');
115 119
 			fwrite($fp, json_encode($data));
116 120
 			fclose($fp);
117
-			if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
121
+			if (! empty($conf->global->MAIN_UMASK)) {
122
+				$newmask=$conf->global->MAIN_UMASK;
123
+			}
118 124
 			@chmod($newpathofdestfile, octdec($newmask));
119 125
 
120 126
 			$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$nowgmt;
@@ -139,7 +145,9 @@  discard block
 block discarded – undo
139 145
 	{
140 146
 		global $conf,$user,$langs;
141 147
 
142
-        if ($startyear > $endyear) return -1;
148
+        if ($startyear > $endyear) {
149
+        	return -1;
150
+        }
143 151
 
144 152
         $datay=array();
145 153
 
@@ -164,20 +172,20 @@  discard block
 block discarded – undo
164 172
         		$foundintocache=1;
165 173
 
166 174
         		$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$filedate;
167
-        	}
168
-        	else
175
+        	} else
169 176
         	{
170 177
         		dol_syslog(get_class($this).'::'.__FUNCTION__." cache file ".$newpathofdestfile." is not found or older than now - cachedelay (".$nowgmt." - ".$cachedelay.") so we can't use it.");
171 178
         	}
172 179
         }
173 180
 
174 181
         // Load file into $data
175
-        if ($foundintocache)    // Cache file found and is not too old
182
+        if ($foundintocache) {
183
+        	// Cache file found and is not too old
176 184
         {
177 185
         	dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
178
-        	$data = json_decode(file_get_contents($newpathofdestfile), true);
179 186
         }
180
-        else
187
+        	$data = json_decode(file_get_contents($newpathofdestfile), true);
188
+        } else
181 189
 		{
182 190
 			$year=$startyear;
183 191
 			while($year <= $endyear)
@@ -204,16 +212,21 @@  discard block
 block discarded – undo
204 212
 		if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == -1))
205 213
 		{
206 214
 			dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk.");
207
-			if (! dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp);
215
+			if (! dol_is_dir($conf->user->dir_temp)) {
216
+				dol_mkdir($conf->user->dir_temp);
217
+			}
208 218
 			$fp = fopen($newpathofdestfile, 'w');
209 219
 			if ($fp)
210 220
 			{
211 221
 				fwrite($fp, json_encode($data));
212 222
 				fclose($fp);
213
-				if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
223
+				if (! empty($conf->global->MAIN_UMASK)) {
224
+					$newmask=$conf->global->MAIN_UMASK;
225
+				}
214 226
 				@chmod($newpathofdestfile, octdec($newmask));
227
+			} else {
228
+				dol_syslog("Failed to write cache file", LOG_ERR);
215 229
 			}
216
-			else dol_syslog("Failed to write cache file", LOG_ERR);
217 230
 			$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$nowgmt;
218 231
 		}
219 232
 
@@ -229,7 +242,9 @@  discard block
 block discarded – undo
229 242
 	 */
230 243
 	function getAverageByMonthWithPrevYear($endyear,$startyear)
231 244
 	{
232
-        if ($startyear > $endyear) return -1;
245
+        if ($startyear > $endyear) {
246
+        	return -1;
247
+        }
233 248
 
234 249
         $datay=array();
235 250
 
@@ -290,20 +305,20 @@  discard block
 block discarded – undo
290 305
         		$foundintocache=1;
291 306
 
292 307
         		$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$filedate;
293
-        	}
294
-        	else
308
+        	} else
295 309
         	{
296 310
         		dol_syslog(get_class($this).'::'.__FUNCTION__." cache file ".$newpathofdestfile." is not found or older than now - cachedelay (".$nowgmt." - ".$cachedelay.") so we can't use it.");
297 311
         	}
298 312
         }
299 313
 
300 314
         // Load file into $data
301
-        if ($foundintocache)    // Cache file found and is not too old
315
+        if ($foundintocache) {
316
+        	// Cache file found and is not too old
302 317
         {
303 318
         	dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
304
-        	$data = json_decode(file_get_contents($newpathofdestfile), true);
305 319
         }
306
-        else
320
+        	$data = json_decode(file_get_contents($newpathofdestfile), true);
321
+        } else
307 322
 		{
308 323
 			$data=$this->getAllByProduct($year);
309 324
 			//					$data[$i][]=$datay[$year][$i][1];	// set yval for x=i
@@ -313,13 +328,17 @@  discard block
 block discarded – undo
313 328
 		if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == -1))
314 329
 		{
315 330
 			dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk.");
316
-			if (! dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp);
331
+			if (! dol_is_dir($conf->user->dir_temp)) {
332
+				dol_mkdir($conf->user->dir_temp);
333
+			}
317 334
 			$fp = fopen($newpathofdestfile, 'w');
318 335
 			if ($fp)
319 336
 			{
320 337
 				fwrite($fp, json_encode($data));
321 338
 				fclose($fp);
322
-				if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
339
+				if (! empty($conf->global->MAIN_UMASK)) {
340
+					$newmask=$conf->global->MAIN_UMASK;
341
+				}
323 342
 				@chmod($newpathofdestfile, octdec($newmask));
324 343
 			}
325 344
 			$this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$nowgmt;
@@ -355,8 +374,7 @@  discard block
 block discarded – undo
355 374
 				$i++;
356 375
 			}
357 376
 			$this->db->free($resql);
358
-		}
359
-		else {
377
+		} else {
360 378
 			dol_print_error($this->db);
361 379
 		}
362 380
 		return $result;
@@ -383,22 +401,29 @@  discard block
 block discarded – undo
383 401
 				$row = $this->db->fetch_object($resql);
384 402
 				$result[$i]['year'] = $row->year;
385 403
 				$result[$i]['nb'] = $row->nb;
386
-				if($i>0 && $row->nb) $result[$i-1]['nb_diff'] = ($result[$i-1]['nb'] - $row->nb) / $row->nb * 100;
404
+				if($i>0 && $row->nb) {
405
+					$result[$i-1]['nb_diff'] = ($result[$i-1]['nb'] - $row->nb) / $row->nb * 100;
406
+				}
387 407
 				$result[$i]['total'] = $row->total;
388
-				if($i>0 && $row->total) $result[$i-1]['total_diff'] = ($result[$i-1]['total'] - $row->total) / $row->total * 100;
408
+				if($i>0 && $row->total) {
409
+					$result[$i-1]['total_diff'] = ($result[$i-1]['total'] - $row->total) / $row->total * 100;
410
+				}
389 411
 				$result[$i]['avg'] = $row->avg;
390
-				if($i>0 && $row->avg) $result[$i-1]['avg_diff'] = ($result[$i-1]['avg'] - $row->avg) / $row->avg * 100;
412
+				if($i>0 && $row->avg) {
413
+					$result[$i-1]['avg_diff'] = ($result[$i-1]['avg'] - $row->avg) / $row->avg * 100;
414
+				}
391 415
 				// For some $sql only
392 416
 				if (isset($row->weighted))
393 417
 				{
394 418
 				    $result[$i]['weighted'] = $row->weighted;
395
-				    if($i>0 && $row->weighted) $result[$i-1]['avg_weighted'] = ($result[$i-1]['weighted'] - $row->weighted) / $row->weighted * 100;
419
+				    if($i>0 && $row->weighted) {
420
+				    	$result[$i-1]['avg_weighted'] = ($result[$i-1]['weighted'] - $row->weighted) / $row->weighted * 100;
421
+				    }
396 422
 				}
397 423
 				$i++;
398 424
 			}
399 425
 			$this->db->free($resql);
400
-		}
401
-		else {
426
+		} else {
402 427
 			dol_print_error($this->db);
403 428
 		}
404 429
 		return $result;
@@ -431,8 +456,7 @@  discard block
 block discarded – undo
431 456
 				$i++;
432 457
 			}
433 458
 			$this->db->free($resql);
434
-		}
435
-		else
459
+		} else
436 460
 		{
437 461
 			dol_print_error($this->db);
438 462
 		}
@@ -483,8 +507,9 @@  discard block
 block discarded – undo
483 507
 		  		$i++;
484 508
 		  	}
485 509
 		  	$this->db->free($resql);
486
-		}
487
-        else dol_print_error($this->db);
510
+		} else {
511
+        	dol_print_error($this->db);
512
+        }
488 513
 
489 514
 		for ($i = 1 ; $i < 13 ; $i++)
490 515
 		{
@@ -530,8 +555,9 @@  discard block
 block discarded – undo
530 555
 		  		$i++;
531 556
 		  	}
532 557
 		  	$this->db->free($resql);
533
-		}
534
-        else dol_print_error($this->db);
558
+		} else {
559
+        	dol_print_error($this->db);
560
+        }
535 561
 
536 562
 		for ($i = 1 ; $i < 13 ; $i++)
537 563
 		{
@@ -574,14 +600,22 @@  discard block
 block discarded – undo
574 600
 			while ($i < $num)
575 601
 			{
576 602
 		  		$row = $this->db->fetch_row($resql);
577
-		  		if ($i < $limit || $num == $limit) $result[$i] = array($row[0],$row[1]);	// Ref of product, nb
578
-		  		else $other += $row[1];
603
+		  		if ($i < $limit || $num == $limit) {
604
+		  			$result[$i] = array($row[0],$row[1]);
605
+		  		}
606
+		  		// Ref of product, nb
607
+		  		else {
608
+		  			$other += $row[1];
609
+		  		}
579 610
 		  		$i++;
580 611
 		  	}
581
-		  	if ($num > $limit) $result[$i] = array($langs->transnoentitiesnoconv("Other"),$other);
612
+		  	if ($num > $limit) {
613
+		  		$result[$i] = array($langs->transnoentitiesnoconv("Other"),$other);
614
+		  	}
582 615
 		  	$this->db->free($resql);
583
-		}
584
-        else dol_print_error($this->db);
616
+		} else {
617
+        	dol_print_error($this->db);
618
+        }
585 619
 
586 620
 		return $result;
587 621
 	}
Please login to merge, or discard this patch.
htdocs/core/class/ctyperesource.class.php 2 patches
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -99,18 +99,18 @@  discard block
 block discarded – undo
99 99
 		// Put here code to add control on parameters values
100 100
 
101 101
 		// Insert request
102
-		$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
102
+		$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'(';
103 103
 		
104
-		$sql.= 'code,';
105
-		$sql.= 'label';
106
-		$sql.= 'active';
104
+		$sql .= 'code,';
105
+		$sql .= 'label';
106
+		$sql .= 'active';
107 107
 
108 108
 		
109 109
 		$sql .= ') VALUES (';
110 110
 		
111
-		$sql .= ' '.(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").',';
112
-		$sql .= ' '.(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").',';
113
-		$sql .= ' '.(! isset($this->active)?'NULL':$this->active);
111
+		$sql .= ' '.(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").',';
112
+		$sql .= ' '.(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").',';
113
+		$sql .= ' '.(!isset($this->active) ? 'NULL' : $this->active);
114 114
 
115 115
 		
116 116
 		$sql .= ')';
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 
120 120
 		$resql = $this->db->query($sql);
121 121
 		if (!$resql) {
122
-			$error ++;
123
-			$this->errors[] = 'Error ' . $this->db->lasterror();
124
-			dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
122
+			$error++;
123
+			$this->errors[] = 'Error '.$this->db->lasterror();
124
+			dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
125 125
 		}
126 126
 
127 127
 		if (!$error) {
128
-			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
128
+			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
129 129
 
130 130
 			if (!$notrigger) {
131 131
 				// Uncomment this and change MYOBJECT to your own tag if you
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		if ($error) {
143 143
 			$this->db->rollback();
144 144
 
145
-			return - 1 * $error;
145
+			return -1 * $error;
146 146
 		} else {
147 147
 			$this->db->commit();
148 148
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 *
160 160
 	 * @return int <0 if KO, 0 if not found, >0 if OK
161 161
 	 */
162
-	public function fetch($id,$code='',$label='')
162
+	public function fetch($id, $code = '', $label = '')
163 163
 	{
164 164
 		dol_syslog(__METHOD__, LOG_DEBUG);
165 165
 
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
 		$sql .= " t.active";
172 172
 
173 173
 		
174
-		$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
175
-		if ($id)   $sql.= " WHERE t.id = ".$id;
176
-		elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'";
177
-		elseif ($label) $sql.= " WHERE t.label = '".$this->db->escape($label)."'";
174
+		$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
175
+		if ($id)   $sql .= " WHERE t.id = ".$id;
176
+		elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape($code)."'";
177
+		elseif ($label) $sql .= " WHERE t.label = '".$this->db->escape($label)."'";
178 178
 		
179 179
 		
180 180
 		$resql = $this->db->query($sql);
@@ -211,10 +211,10 @@  discard block
 block discarded – undo
211 211
 				return 0;
212 212
 			}
213 213
 		} else {
214
-			$this->errors[] = 'Error ' . $this->db->lasterror();
215
-			dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
214
+			$this->errors[] = 'Error '.$this->db->lasterror();
215
+			dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
216 216
 
217
-			return - 1;
217
+			return -1;
218 218
 		}
219 219
 	}
220 220
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 *
231 231
 	 * @return int <0 if KO, >0 if OK
232 232
 	 */
233
-	public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
233
+	public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
234 234
 	{
235 235
 		dol_syslog(__METHOD__, LOG_DEBUG);
236 236
 
@@ -242,24 +242,24 @@  discard block
 block discarded – undo
242 242
 		$sql .= " t.active";
243 243
 
244 244
 		
245
-		$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
245
+		$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
246 246
 
247 247
 		// Manage filter
248 248
 		$sqlwhere = array();
249 249
 		if (count($filter) > 0) {
250 250
 			foreach ($filter as $key => $value) {
251
-				$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
251
+				$sqlwhere [] = $key.' LIKE \'%'.$this->db->escape($value).'%\'';
252 252
 			}
253 253
 		}
254 254
 		
255 255
 		if (count($sqlwhere) > 0) {
256
-			$sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere);
256
+			$sql .= ' WHERE '.implode(' '.$filtermode.' ', $sqlwhere);
257 257
 		}
258 258
 		if (!empty($sortfield)) {
259
-			$sql .= $this->db->order($sortfield,$sortorder);
259
+			$sql .= $this->db->order($sortfield, $sortorder);
260 260
 		}
261 261
 		if (!empty($limit)) {
262
-		 $sql .=  ' ' . $this->db->plimit($limit, $offset);
262
+		 $sql .= ' '.$this->db->plimit($limit, $offset);
263 263
 		}
264 264
 
265 265
 		$resql = $this->db->query($sql);
@@ -281,10 +281,10 @@  discard block
 block discarded – undo
281 281
 
282 282
 			return $num;
283 283
 		} else {
284
-			$this->errors[] = 'Error ' . $this->db->lasterror();
285
-			dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
284
+			$this->errors[] = 'Error '.$this->db->lasterror();
285
+			dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
286 286
 
287
-			return - 1;
287
+			return -1;
288 288
 		}
289 289
 	}
290 290
 
@@ -318,22 +318,22 @@  discard block
 block discarded – undo
318 318
 		// Put here code to add a control on parameters values
319 319
 
320 320
 		// Update request
321
-		$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
321
+		$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET';
322 322
 		
323
-		$sql .= ' code = '.(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").',';
324
-		$sql .= ' label = '.(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").',';
325
-		$sql .= ' active = '.(isset($this->active)?$this->active:"null");
323
+		$sql .= ' code = '.(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").',';
324
+		$sql .= ' label = '.(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").',';
325
+		$sql .= ' active = '.(isset($this->active) ? $this->active : "null");
326 326
 
327 327
         
328
-		$sql .= ' WHERE rowid=' . $this->id;
328
+		$sql .= ' WHERE rowid='.$this->id;
329 329
 
330 330
 		$this->db->begin();
331 331
 
332 332
 		$resql = $this->db->query($sql);
333 333
 		if (!$resql) {
334
-			$error ++;
335
-			$this->errors[] = 'Error ' . $this->db->lasterror();
336
-			dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
334
+			$error++;
335
+			$this->errors[] = 'Error '.$this->db->lasterror();
336
+			dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
337 337
 		}
338 338
 
339 339
 		if (!$error && !$notrigger) {
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 		if ($error) {
351 351
 			$this->db->rollback();
352 352
 
353
-			return - 1 * $error;
353
+			return -1 * $error;
354 354
 		} else {
355 355
 			$this->db->commit();
356 356
 
@@ -389,14 +389,14 @@  discard block
 block discarded – undo
389 389
 		// If you need to delete child tables to, you can insert them here
390 390
 		
391 391
 		if (!$error) {
392
-			$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element;
393
-			$sql .= ' WHERE rowid=' . $this->id;
392
+			$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element;
393
+			$sql .= ' WHERE rowid='.$this->id;
394 394
 
395 395
 			$resql = $this->db->query($sql);
396 396
 			if (!$resql) {
397
-				$error ++;
398
-				$this->errors[] = 'Error ' . $this->db->lasterror();
399
-				dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
397
+				$error++;
398
+				$this->errors[] = 'Error '.$this->db->lasterror();
399
+				dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
400 400
 			}
401 401
 		}
402 402
 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 		if ($error) {
405 405
 			$this->db->rollback();
406 406
 
407
-			return - 1 * $error;
407
+			return -1 * $error;
408 408
 		} else {
409 409
 			$this->db->commit();
410 410
 
@@ -442,9 +442,9 @@  discard block
 block discarded – undo
442 442
 
443 443
 		// Other options
444 444
 		if ($result < 0) {
445
-			$error ++;
445
+			$error++;
446 446
 			$this->errors = $object->errors;
447
-			dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
447
+			dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
448 448
 		}
449 449
 
450 450
 		// End
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 		} else {
456 456
 			$this->db->rollback();
457 457
 
458
-			return - 1;
458
+			return -1;
459 459
 		}
460 460
 	}
461 461
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -172,9 +172,13 @@
 block discarded – undo
172 172
 
173 173
 		
174 174
 		$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
175
-		if ($id)   $sql.= " WHERE t.id = ".$id;
176
-		elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'";
177
-		elseif ($label) $sql.= " WHERE t.label = '".$this->db->escape($label)."'";
175
+		if ($id) {
176
+			$sql.= " WHERE t.id = ".$id;
177
+		} elseif ($code) {
178
+			$sql.= " WHERE t.code = '".$this->db->escape($code)."'";
179
+		} elseif ($label) {
180
+			$sql.= " WHERE t.label = '".$this->db->escape($label)."'";
181
+		}
178 182
 		
179 183
 		
180 184
 		$resql = $this->db->query($sql);
Please login to merge, or discard this patch.
htdocs/core/class/ctypent.class.php 3 patches
Braces   +38 added lines, -20 removed lines patch added patch discarded remove patch
@@ -68,11 +68,21 @@  discard block
 block discarded – undo
68 68
 
69 69
 		// Clean parameters
70 70
 
71
-		if (isset($this->id)) $this->id=trim($this->id);
72
-		if (isset($this->code)) $this->code=trim($this->code);
73
-		if (isset($this->libelle)) $this->libelle=trim($this->libelle);
74
-		if (isset($this->active)) $this->active=trim($this->active);
75
-		if (isset($this->module)) $this->module=trim($this->module);
71
+		if (isset($this->id)) {
72
+			$this->id=trim($this->id);
73
+		}
74
+		if (isset($this->code)) {
75
+			$this->code=trim($this->code);
76
+		}
77
+		if (isset($this->libelle)) {
78
+			$this->libelle=trim($this->libelle);
79
+		}
80
+		if (isset($this->active)) {
81
+			$this->active=trim($this->active);
82
+		}
83
+		if (isset($this->module)) {
84
+			$this->module=trim($this->module);
85
+		}
76 86
 
77 87
 
78 88
 
@@ -134,8 +144,7 @@  discard block
 block discarded – undo
134 144
 			}
135 145
 			$this->db->rollback();
136 146
 			return -1*$error;
137
-		}
138
-		else
147
+		} else
139 148
 		{
140 149
 			$this->db->commit();
141 150
             return $this->id;
@@ -162,9 +171,13 @@  discard block
 block discarded – undo
162 171
 		$sql.= " t.active,";
163 172
 		$sql.= " t.module";
164 173
         $sql.= " FROM ".MAIN_DB_PREFIX."c_typent as t";
165
-        if ($id)   $sql.= " WHERE t.id = ".$id;
166
-        elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'";
167
-        elseif ($label) $sql.= " WHERE t.libelle = '".$this->db->escape($label)."'";
174
+        if ($id) {
175
+        	$sql.= " WHERE t.id = ".$id;
176
+        } elseif ($code) {
177
+        	$sql.= " WHERE t.code = '".$this->db->escape($code)."'";
178
+        } elseif ($label) {
179
+        	$sql.= " WHERE t.libelle = '".$this->db->escape($label)."'";
180
+        }
168 181
 
169 182
         $resql=$this->db->query($sql);
170 183
         if ($resql)
@@ -183,8 +196,7 @@  discard block
 block discarded – undo
183 196
             $this->db->free($resql);
184 197
 
185 198
             return 1;
186
-        }
187
-        else
199
+        } else
188 200
         {
189 201
       	    $this->error="Error ".$this->db->lasterror();
190 202
             return -1;
@@ -205,10 +217,18 @@  discard block
 block discarded – undo
205 217
 		$error=0;
206 218
 
207 219
 		// Clean parameters
208
-		if (isset($this->code)) $this->code=trim($this->code);
209
-		if (isset($this->libelle)) $this->libelle=trim($this->libelle);
210
-		if (isset($this->active)) $this->active=trim($this->active);
211
-		if (isset($this->module)) $this->module=trim($this->module);
220
+		if (isset($this->code)) {
221
+			$this->code=trim($this->code);
222
+		}
223
+		if (isset($this->libelle)) {
224
+			$this->libelle=trim($this->libelle);
225
+		}
226
+		if (isset($this->active)) {
227
+			$this->active=trim($this->active);
228
+		}
229
+		if (isset($this->module)) {
230
+			$this->module=trim($this->module);
231
+		}
212 232
 
213 233
 
214 234
 		// Check parameters
@@ -254,8 +274,7 @@  discard block
 block discarded – undo
254 274
 			}
255 275
 			$this->db->rollback();
256 276
 			return -1*$error;
257
-		}
258
-		else
277
+		} else
259 278
 		{
260 279
 			$this->db->commit();
261 280
 			return 1;
@@ -310,8 +329,7 @@  discard block
 block discarded – undo
310 329
 			}
311 330
 			$this->db->rollback();
312 331
 			return -1*$error;
313
-		}
314
-		else
332
+		} else
315 333
 		{
316 334
 			$this->db->commit();
317 335
 			return 1;
Please login to merge, or discard this patch.
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	//var $element='ctypent';			//!< Id that identify managed objects
34 34
 	//var $table_element='ctypent';	//!< Name of table without prefix where object is stored
35 35
 
36
-    var $id;
36
+	var $id;
37 37
 	var $code;
38 38
 	var $libelle;
39 39
 	var $active;
@@ -42,28 +42,28 @@  discard block
 block discarded – undo
42 42
 
43 43
 
44 44
 
45
-    /**
46
-     *  Constructor
47
-     *
48
-     *  @param      DoliDb		$db      Database handler
49
-     */
50
-    function __construct($db)
51
-    {
52
-        $this->db = $db;
53
-        return 1;
54
-    }
45
+	/**
46
+	 *  Constructor
47
+	 *
48
+	 *  @param      DoliDb		$db      Database handler
49
+	 */
50
+	function __construct($db)
51
+	{
52
+		$this->db = $db;
53
+		return 1;
54
+	}
55 55
 
56 56
 
57
-    /**
58
-     *  Create object into database
59
-     *
60
-     *  @param      User	$user        User that create
61
-     *  @param      int		$notrigger   0=launch triggers after, 1=disable triggers
62
-     *  @return     int      		   	 <0 if KO, Id of created object if OK
63
-     */
64
-    function create($user, $notrigger=0)
65
-    {
66
-    	global $conf, $langs;
57
+	/**
58
+	 *  Create object into database
59
+	 *
60
+	 *  @param      User	$user        User that create
61
+	 *  @param      int		$notrigger   0=launch triggers after, 1=disable triggers
62
+	 *  @return     int      		   	 <0 if KO, Id of created object if OK
63
+	 */
64
+	function create($user, $notrigger=0)
65
+	{
66
+		global $conf, $langs;
67 67
 		$error=0;
68 68
 
69 69
 		// Clean parameters
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 		// Check parameters
80 80
 		// Put here code to add control on parameters values
81 81
 
82
-        // Insert request
82
+		// Insert request
83 83
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_typent(";
84 84
 
85 85
 		$sql.= "id,";
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		$sql.= "module";
90 90
 
91 91
 
92
-        $sql.= ") VALUES (";
92
+		$sql.= ") VALUES (";
93 93
 
94 94
 		$sql.= " ".(! isset($this->id)?'NULL':"'".$this->db->escape($this->id)."'").",";
95 95
 		$sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").",";
@@ -103,34 +103,34 @@  discard block
 block discarded – undo
103 103
 		$this->db->begin();
104 104
 
105 105
 	   	dol_syslog(get_class($this)."::create", LOG_DEBUG);
106
-        $resql=$this->db->query($sql);
107
-    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
106
+		$resql=$this->db->query($sql);
107
+		if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
108 108
 
109 109
 		if (! $error)
110
-        {
111
-            $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_typent");
110
+		{
111
+			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_typent");
112 112
 
113 113
 			if (! $notrigger)
114 114
 			{
115
-	            // Uncomment this and change MYOBJECT to your own tag if you
116
-	            // want this action call a trigger.
117
-
118
-	            //// Call triggers
119
-	            //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
120
-	            //$interface=new Interfaces($this->db);
121
-	            //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
122
-	            //if ($result < 0) { $error++; $this->errors=$interface->errors; }
123
-	            //// End call triggers
115
+				// Uncomment this and change MYOBJECT to your own tag if you
116
+				// want this action call a trigger.
117
+
118
+				//// Call triggers
119
+				//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
120
+				//$interface=new Interfaces($this->db);
121
+				//$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
122
+				//if ($result < 0) { $error++; $this->errors=$interface->errors; }
123
+				//// End call triggers
124 124
 			}
125
-        }
125
+		}
126 126
 
127
-        // Commit or rollback
128
-        if ($error)
127
+		// Commit or rollback
128
+		if ($error)
129 129
 		{
130 130
 			foreach($this->errors as $errmsg)
131 131
 			{
132
-	            dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
133
-	            $this->error.=($this->error?', '.$errmsg:$errmsg);
132
+				dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
133
+				$this->error.=($this->error?', '.$errmsg:$errmsg);
134 134
 			}
135 135
 			$this->db->rollback();
136 136
 			return -1*$error;
@@ -138,70 +138,70 @@  discard block
 block discarded – undo
138 138
 		else
139 139
 		{
140 140
 			$this->db->commit();
141
-            return $this->id;
141
+			return $this->id;
142 142
 		}
143
-    }
144
-
145
-
146
-    /**
147
-     *  Load object in memory from database
148
-     *
149
-     *  @param      int		$id    	Id object
150
-     *  @param		string	$code	Code
151
-     *  @param		string	$label	Label
152
-     *  @return     int          	<0 if KO, >0 if OK
153
-     */
154
-    function fetch($id,$code='',$label='')
155
-    {
156
-    	global $langs;
157
-        $sql = "SELECT";
143
+	}
144
+
145
+
146
+	/**
147
+	 *  Load object in memory from database
148
+	 *
149
+	 *  @param      int		$id    	Id object
150
+	 *  @param		string	$code	Code
151
+	 *  @param		string	$label	Label
152
+	 *  @return     int          	<0 if KO, >0 if OK
153
+	 */
154
+	function fetch($id,$code='',$label='')
155
+	{
156
+		global $langs;
157
+		$sql = "SELECT";
158 158
 		$sql.= " t.id,";
159 159
 		$sql.= " t.code,";
160 160
 		$sql.= " t.libelle as label,";
161 161
 		$sql.= " t.fk_country as country_id,";
162 162
 		$sql.= " t.active,";
163 163
 		$sql.= " t.module";
164
-        $sql.= " FROM ".MAIN_DB_PREFIX."c_typent as t";
165
-        if ($id)   $sql.= " WHERE t.id = ".$id;
166
-        elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'";
167
-        elseif ($label) $sql.= " WHERE t.libelle = '".$this->db->escape($label)."'";
168
-
169
-        $resql=$this->db->query($sql);
170
-        if ($resql)
171
-        {
172
-            if ($this->db->num_rows($resql))
173
-            {
174
-                $obj = $this->db->fetch_object($resql);
175
-
176
-                $this->id    = $obj->id;
164
+		$sql.= " FROM ".MAIN_DB_PREFIX."c_typent as t";
165
+		if ($id)   $sql.= " WHERE t.id = ".$id;
166
+		elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'";
167
+		elseif ($label) $sql.= " WHERE t.libelle = '".$this->db->escape($label)."'";
168
+
169
+		$resql=$this->db->query($sql);
170
+		if ($resql)
171
+		{
172
+			if ($this->db->num_rows($resql))
173
+			{
174
+				$obj = $this->db->fetch_object($resql);
175
+
176
+				$this->id    = $obj->id;
177 177
 				$this->code = $obj->code;
178 178
 				$this->libelle = $obj->label;
179 179
 				$this->country_id = $obj->country_id;
180 180
 				$this->active = $obj->active;
181 181
 				$this->module = $obj->module;
182
-            }
183
-            $this->db->free($resql);
184
-
185
-            return 1;
186
-        }
187
-        else
188
-        {
189
-      	    $this->error="Error ".$this->db->lasterror();
190
-            return -1;
191
-        }
192
-    }
193
-
194
-
195
-    /**
196
-     *  Update object into database
197
-     *
198
-     *  @param      User	$user        User that modify
199
-     *  @param      int		$notrigger	 0=launch triggers after, 1=disable triggers
200
-     *  @return     int     		   	 <0 if KO, >0 if OK
201
-     */
202
-    function update($user=null, $notrigger=0)
203
-    {
204
-    	global $conf, $langs;
182
+			}
183
+			$this->db->free($resql);
184
+
185
+			return 1;
186
+		}
187
+		else
188
+		{
189
+	  		$this->error="Error ".$this->db->lasterror();
190
+			return -1;
191
+		}
192
+	}
193
+
194
+
195
+	/**
196
+	 *  Update object into database
197
+	 *
198
+	 *  @param      User	$user        User that modify
199
+	 *  @param      int		$notrigger	 0=launch triggers after, 1=disable triggers
200
+	 *  @return     int     		   	 <0 if KO, >0 if OK
201
+	 */
202
+	function update($user=null, $notrigger=0)
203
+	{
204
+		global $conf, $langs;
205 205
 		$error=0;
206 206
 
207 207
 		// Clean parameters
@@ -214,43 +214,43 @@  discard block
 block discarded – undo
214 214
 		// Check parameters
215 215
 		// Put here code to add control on parameters values
216 216
 
217
-        // Update request
218
-        $sql = "UPDATE ".MAIN_DB_PREFIX."c_typent SET";
217
+		// Update request
218
+		$sql = "UPDATE ".MAIN_DB_PREFIX."c_typent SET";
219 219
 		$sql.= " code=".(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").",";
220 220
 		$sql.= " libelle=".(isset($this->libelle)?"'".$this->db->escape($this->libelle)."'":"null").",";
221 221
 		$sql.= " active=".(isset($this->active)?$this->active:"null").",";
222 222
 		$sql.= " module=".(isset($this->module)?"'".$this->db->escape($this->module)."'":"null")."";
223
-        $sql.= " WHERE id=".$this->id;
223
+		$sql.= " WHERE id=".$this->id;
224 224
 
225 225
 		$this->db->begin();
226 226
 
227 227
 		dol_syslog(get_class($this)."::update", LOG_DEBUG);
228
-        $resql = $this->db->query($sql);
229
-    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
228
+		$resql = $this->db->query($sql);
229
+		if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
230 230
 
231 231
 		if (! $error)
232 232
 		{
233 233
 			if (! $notrigger)
234 234
 			{
235
-	            // Uncomment this and change MYOBJECT to your own tag if you
236
-	            // want this action call a trigger.
237
-
238
-	            //// Call triggers
239
-	            //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
240
-	            //$interface=new Interfaces($this->db);
241
-	            //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
242
-	            //if ($result < 0) { $error++; $this->errors=$interface->errors; }
243
-	            //// End call triggers
244
-	    	}
235
+				// Uncomment this and change MYOBJECT to your own tag if you
236
+				// want this action call a trigger.
237
+
238
+				//// Call triggers
239
+				//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
240
+				//$interface=new Interfaces($this->db);
241
+				//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
242
+				//if ($result < 0) { $error++; $this->errors=$interface->errors; }
243
+				//// End call triggers
244
+			}
245 245
 		}
246 246
 
247
-        // Commit or rollback
247
+		// Commit or rollback
248 248
 		if ($error)
249 249
 		{
250 250
 			foreach($this->errors as $errmsg)
251 251
 			{
252
-	            dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
253
-	            $this->error.=($this->error?', '.$errmsg:$errmsg);
252
+				dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
253
+				$this->error.=($this->error?', '.$errmsg:$errmsg);
254 254
 			}
255 255
 			$this->db->rollback();
256 256
 			return -1*$error;
@@ -260,16 +260,16 @@  discard block
 block discarded – undo
260 260
 			$this->db->commit();
261 261
 			return 1;
262 262
 		}
263
-    }
263
+	}
264 264
 
265 265
 
266 266
  	/**
267
-	 *  Delete object in database
268
-	 *
269
-     *	@param  User	$user        User that delete
270
-     *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
271
-	 *  @return	int					 <0 if KO, >0 if OK
272
-	 */
267
+ 	 *  Delete object in database
268
+ 	 *
269
+ 	 *	@param  User	$user        User that delete
270
+ 	 *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
271
+ 	 *  @return	int					 <0 if KO, >0 if OK
272
+ 	 */
273 273
 	function delete($user, $notrigger=0)
274 274
 	{
275 275
 		global $conf, $langs;
@@ -282,31 +282,31 @@  discard block
 block discarded – undo
282 282
 
283 283
 		dol_syslog(get_class($this)."::delete", LOG_DEBUG);
284 284
 		$resql = $this->db->query($sql);
285
-    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
285
+		if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
286 286
 
287 287
 		if (! $error)
288 288
 		{
289 289
 			if (! $notrigger)
290 290
 			{
291 291
 				// Uncomment this and change MYOBJECT to your own tag if you
292
-		        // want this action call a trigger.
293
-
294
-		        //// Call triggers
295
-		        //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
296
-		        //$interface=new Interfaces($this->db);
297
-		        //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
298
-		        //if ($result < 0) { $error++; $this->errors=$interface->errors; }
299
-		        //// End call triggers
292
+				// want this action call a trigger.
293
+
294
+				//// Call triggers
295
+				//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
296
+				//$interface=new Interfaces($this->db);
297
+				//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
298
+				//if ($result < 0) { $error++; $this->errors=$interface->errors; }
299
+				//// End call triggers
300 300
 			}
301 301
 		}
302 302
 
303
-        // Commit or rollback
303
+		// Commit or rollback
304 304
 		if ($error)
305 305
 		{
306 306
 			foreach($this->errors as $errmsg)
307 307
 			{
308
-	            dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
309
-	            $this->error.=($this->error?', '.$errmsg:$errmsg);
308
+				dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
309
+				$this->error.=($this->error?', '.$errmsg:$errmsg);
310 310
 			}
311 311
 			$this->db->rollback();
312 312
 			return -1*$error;
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
  */
28 28
 class Ctypent // extends CommonObject
29 29
 {
30
-	var $db;							//!< To store db handler
31
-	var $error;							//!< To return error code (or message)
32
-	var $errors=array();				//!< To return several error codes (or messages)
30
+	var $db; //!< To store db handler
31
+	var $error; //!< To return error code (or message)
32
+	var $errors = array(); //!< To return several error codes (or messages)
33 33
 	//var $element='ctypent';			//!< Id that identify managed objects
34 34
 	//var $table_element='ctypent';	//!< Name of table without prefix where object is stored
35 35
 
@@ -61,18 +61,18 @@  discard block
 block discarded – undo
61 61
      *  @param      int		$notrigger   0=launch triggers after, 1=disable triggers
62 62
      *  @return     int      		   	 <0 if KO, Id of created object if OK
63 63
      */
64
-    function create($user, $notrigger=0)
64
+    function create($user, $notrigger = 0)
65 65
     {
66 66
     	global $conf, $langs;
67
-		$error=0;
67
+		$error = 0;
68 68
 
69 69
 		// Clean parameters
70 70
 
71
-		if (isset($this->id)) $this->id=trim($this->id);
72
-		if (isset($this->code)) $this->code=trim($this->code);
73
-		if (isset($this->libelle)) $this->libelle=trim($this->libelle);
74
-		if (isset($this->active)) $this->active=trim($this->active);
75
-		if (isset($this->module)) $this->module=trim($this->module);
71
+		if (isset($this->id)) $this->id = trim($this->id);
72
+		if (isset($this->code)) $this->code = trim($this->code);
73
+		if (isset($this->libelle)) $this->libelle = trim($this->libelle);
74
+		if (isset($this->active)) $this->active = trim($this->active);
75
+		if (isset($this->module)) $this->module = trim($this->module);
76 76
 
77 77
 
78 78
 
@@ -82,35 +82,35 @@  discard block
 block discarded – undo
82 82
         // Insert request
83 83
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_typent(";
84 84
 
85
-		$sql.= "id,";
86
-		$sql.= "code,";
87
-		$sql.= "libelle,";
88
-		$sql.= "active,";
89
-		$sql.= "module";
85
+		$sql .= "id,";
86
+		$sql .= "code,";
87
+		$sql .= "libelle,";
88
+		$sql .= "active,";
89
+		$sql .= "module";
90 90
 
91 91
 
92
-        $sql.= ") VALUES (";
92
+        $sql .= ") VALUES (";
93 93
 
94
-		$sql.= " ".(! isset($this->id)?'NULL':"'".$this->db->escape($this->id)."'").",";
95
-		$sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").",";
96
-		$sql.= " ".(! isset($this->libelle)?'NULL':"'".$this->db->escape($this->libelle)."'").",";
97
-		$sql.= " ".(! isset($this->active)?'NULL':"'".$this->db->active($this->active)."'").",";
98
-		$sql.= " ".(! isset($this->module)?'NULL':"'".$this->db->escape($this->module)."'")."";
94
+		$sql .= " ".(!isset($this->id) ? 'NULL' : "'".$this->db->escape($this->id)."'").",";
95
+		$sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").",";
96
+		$sql .= " ".(!isset($this->libelle) ? 'NULL' : "'".$this->db->escape($this->libelle)."'").",";
97
+		$sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->active($this->active)."'").",";
98
+		$sql .= " ".(!isset($this->module) ? 'NULL' : "'".$this->db->escape($this->module)."'")."";
99 99
 
100 100
 
101
-		$sql.= ")";
101
+		$sql .= ")";
102 102
 
103 103
 		$this->db->begin();
104 104
 
105 105
 	   	dol_syslog(get_class($this)."::create", LOG_DEBUG);
106
-        $resql=$this->db->query($sql);
107
-    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
106
+        $resql = $this->db->query($sql);
107
+    	if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
108 108
 
109
-		if (! $error)
109
+		if (!$error)
110 110
         {
111 111
             $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_typent");
112 112
 
113
-			if (! $notrigger)
113
+			if (!$notrigger)
114 114
 			{
115 115
 	            // Uncomment this and change MYOBJECT to your own tag if you
116 116
 	            // want this action call a trigger.
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
         // Commit or rollback
128 128
         if ($error)
129 129
 		{
130
-			foreach($this->errors as $errmsg)
130
+			foreach ($this->errors as $errmsg)
131 131
 			{
132 132
 	            dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
133
-	            $this->error.=($this->error?', '.$errmsg:$errmsg);
133
+	            $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
134 134
 			}
135 135
 			$this->db->rollback();
136
-			return -1*$error;
136
+			return -1 * $error;
137 137
 		}
138 138
 		else
139 139
 		{
@@ -151,29 +151,29 @@  discard block
 block discarded – undo
151 151
      *  @param		string	$label	Label
152 152
      *  @return     int          	<0 if KO, >0 if OK
153 153
      */
154
-    function fetch($id,$code='',$label='')
154
+    function fetch($id, $code = '', $label = '')
155 155
     {
156 156
     	global $langs;
157 157
         $sql = "SELECT";
158
-		$sql.= " t.id,";
159
-		$sql.= " t.code,";
160
-		$sql.= " t.libelle as label,";
161
-		$sql.= " t.fk_country as country_id,";
162
-		$sql.= " t.active,";
163
-		$sql.= " t.module";
164
-        $sql.= " FROM ".MAIN_DB_PREFIX."c_typent as t";
165
-        if ($id)   $sql.= " WHERE t.id = ".$id;
166
-        elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'";
167
-        elseif ($label) $sql.= " WHERE t.libelle = '".$this->db->escape($label)."'";
168
-
169
-        $resql=$this->db->query($sql);
158
+		$sql .= " t.id,";
159
+		$sql .= " t.code,";
160
+		$sql .= " t.libelle as label,";
161
+		$sql .= " t.fk_country as country_id,";
162
+		$sql .= " t.active,";
163
+		$sql .= " t.module";
164
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_typent as t";
165
+        if ($id)   $sql .= " WHERE t.id = ".$id;
166
+        elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape($code)."'";
167
+        elseif ($label) $sql .= " WHERE t.libelle = '".$this->db->escape($label)."'";
168
+
169
+        $resql = $this->db->query($sql);
170 170
         if ($resql)
171 171
         {
172 172
             if ($this->db->num_rows($resql))
173 173
             {
174 174
                 $obj = $this->db->fetch_object($resql);
175 175
 
176
-                $this->id    = $obj->id;
176
+                $this->id = $obj->id;
177 177
 				$this->code = $obj->code;
178 178
 				$this->libelle = $obj->label;
179 179
 				$this->country_id = $obj->country_id;
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         }
187 187
         else
188 188
         {
189
-      	    $this->error="Error ".$this->db->lasterror();
189
+      	    $this->error = "Error ".$this->db->lasterror();
190 190
             return -1;
191 191
         }
192 192
     }
@@ -199,16 +199,16 @@  discard block
 block discarded – undo
199 199
      *  @param      int		$notrigger	 0=launch triggers after, 1=disable triggers
200 200
      *  @return     int     		   	 <0 if KO, >0 if OK
201 201
      */
202
-    function update($user=null, $notrigger=0)
202
+    function update($user = null, $notrigger = 0)
203 203
     {
204 204
     	global $conf, $langs;
205
-		$error=0;
205
+		$error = 0;
206 206
 
207 207
 		// Clean parameters
208
-		if (isset($this->code)) $this->code=trim($this->code);
209
-		if (isset($this->libelle)) $this->libelle=trim($this->libelle);
210
-		if (isset($this->active)) $this->active=trim($this->active);
211
-		if (isset($this->module)) $this->module=trim($this->module);
208
+		if (isset($this->code)) $this->code = trim($this->code);
209
+		if (isset($this->libelle)) $this->libelle = trim($this->libelle);
210
+		if (isset($this->active)) $this->active = trim($this->active);
211
+		if (isset($this->module)) $this->module = trim($this->module);
212 212
 
213 213
 
214 214
 		// Check parameters
@@ -216,21 +216,21 @@  discard block
 block discarded – undo
216 216
 
217 217
         // Update request
218 218
         $sql = "UPDATE ".MAIN_DB_PREFIX."c_typent SET";
219
-		$sql.= " code=".(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").",";
220
-		$sql.= " libelle=".(isset($this->libelle)?"'".$this->db->escape($this->libelle)."'":"null").",";
221
-		$sql.= " active=".(isset($this->active)?$this->active:"null").",";
222
-		$sql.= " module=".(isset($this->module)?"'".$this->db->escape($this->module)."'":"null")."";
223
-        $sql.= " WHERE id=".$this->id;
219
+		$sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").",";
220
+		$sql .= " libelle=".(isset($this->libelle) ? "'".$this->db->escape($this->libelle)."'" : "null").",";
221
+		$sql .= " active=".(isset($this->active) ? $this->active : "null").",";
222
+		$sql .= " module=".(isset($this->module) ? "'".$this->db->escape($this->module)."'" : "null")."";
223
+        $sql .= " WHERE id=".$this->id;
224 224
 
225 225
 		$this->db->begin();
226 226
 
227 227
 		dol_syslog(get_class($this)."::update", LOG_DEBUG);
228 228
         $resql = $this->db->query($sql);
229
-    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
229
+    	if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
230 230
 
231
-		if (! $error)
231
+		if (!$error)
232 232
 		{
233
-			if (! $notrigger)
233
+			if (!$notrigger)
234 234
 			{
235 235
 	            // Uncomment this and change MYOBJECT to your own tag if you
236 236
 	            // want this action call a trigger.
@@ -247,13 +247,13 @@  discard block
 block discarded – undo
247 247
         // Commit or rollback
248 248
 		if ($error)
249 249
 		{
250
-			foreach($this->errors as $errmsg)
250
+			foreach ($this->errors as $errmsg)
251 251
 			{
252 252
 	            dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
253
-	            $this->error.=($this->error?', '.$errmsg:$errmsg);
253
+	            $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
254 254
 			}
255 255
 			$this->db->rollback();
256
-			return -1*$error;
256
+			return -1 * $error;
257 257
 		}
258 258
 		else
259 259
 		{
@@ -270,23 +270,23 @@  discard block
 block discarded – undo
270 270
      *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
271 271
 	 *  @return	int					 <0 if KO, >0 if OK
272 272
 	 */
273
-	function delete($user, $notrigger=0)
273
+	function delete($user, $notrigger = 0)
274 274
 	{
275 275
 		global $conf, $langs;
276
-		$error=0;
276
+		$error = 0;
277 277
 
278 278
 		$sql = "DELETE FROM ".MAIN_DB_PREFIX."c_typent";
279
-		$sql.= " WHERE id=".$this->id;
279
+		$sql .= " WHERE id=".$this->id;
280 280
 
281 281
 		$this->db->begin();
282 282
 
283 283
 		dol_syslog(get_class($this)."::delete", LOG_DEBUG);
284 284
 		$resql = $this->db->query($sql);
285
-    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
285
+    	if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
286 286
 
287
-		if (! $error)
287
+		if (!$error)
288 288
 		{
289
-			if (! $notrigger)
289
+			if (!$notrigger)
290 290
 			{
291 291
 				// Uncomment this and change MYOBJECT to your own tag if you
292 292
 		        // want this action call a trigger.
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
         // Commit or rollback
304 304
 		if ($error)
305 305
 		{
306
-			foreach($this->errors as $errmsg)
306
+			foreach ($this->errors as $errmsg)
307 307
 			{
308 308
 	            dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
309
-	            $this->error.=($this->error?', '.$errmsg:$errmsg);
309
+	            $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
310 310
 			}
311 311
 			$this->db->rollback();
312
-			return -1*$error;
312
+			return -1 * $error;
313 313
 		}
314 314
 		else
315 315
 		{
Please login to merge, or discard this patch.
htdocs/core/class/canvas.class.php 3 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -34,21 +34,21 @@  discard block
 block discarded – undo
34 34
 
35 35
 	var $actiontype;
36 36
 
37
-    var $dirmodule;			// Module directory
38
-    var $targetmodule;      // Module concerned by canvas (ex: thirdparty, contact, ...)
39
-    var $canvas;            // Name of canvas (ex: company, individual, product, service, ...)
40
-    var $card;              // Tab (sub-canvas)
37
+	var $dirmodule;			// Module directory
38
+	var $targetmodule;      // Module concerned by canvas (ex: thirdparty, contact, ...)
39
+	var $canvas;            // Name of canvas (ex: company, individual, product, service, ...)
40
+	var $card;              // Tab (sub-canvas)
41 41
 
42
-    var $template_dir;			// Initialized by getCanvas with templates directory
43
-    var $control;           	// Initialized by getCanvas with controller instance
42
+	var $template_dir;			// Initialized by getCanvas with templates directory
43
+	var $control;           	// Initialized by getCanvas with controller instance
44 44
 
45 45
 
46 46
    /**
47
-	*   Constructor
48
-	*
49
-	*   @param     DoliDB	$db          	Database handler
50
-	*   @param     string   $actiontype		Action type ('create', 'view', 'edit', 'list')
51
-	*/
47
+    *   Constructor
48
+    *
49
+    *   @param     DoliDB	$db          	Database handler
50
+    *   @param     string   $actiontype		Action type ('create', 'view', 'edit', 'list')
51
+    */
52 52
 	function __construct($db, $actiontype='view')
53 53
 	{
54 54
 		$this->db = $db;
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	private function _cleanaction($action)
66 66
 	{
67
-	    $newaction = $action;
68
-	    if ($newaction == 'add')    $newaction='create';
69
-	    if ($newaction == 'update') $newaction='edit';
70
-	    if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction='view';
71
-	    return $newaction;
67
+		$newaction = $action;
68
+		if ($newaction == 'add')    $newaction='create';
69
+		if ($newaction == 'update') $newaction='edit';
70
+		if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction='view';
71
+		return $newaction;
72 72
 	}
73 73
 
74 74
 
@@ -85,44 +85,44 @@  discard block
 block discarded – undo
85 85
 		global $conf, $langs;
86 86
 
87 87
 		// Set properties with value specific to dolibarr core: this->targetmodule, this->card, this->canvas
88
-        $this->targetmodule = $module;
89
-        $this->canvas = $canvas;
90
-        $this->card = $card;
91
-        $this->dirmodule = $module;
92
-        // Correct values if canvas is into an external module
88
+		$this->targetmodule = $module;
89
+		$this->canvas = $canvas;
90
+		$this->card = $card;
91
+		$this->dirmodule = $module;
92
+		// Correct values if canvas is into an external module
93 93
 		if (preg_match('/^([^@]+)@([^@]+)$/i',$canvas,$regs))
94 94
 		{
95
-            $this->canvas = $regs[1];
96
-		    $this->dirmodule = $regs[2];
95
+			$this->canvas = $regs[1];
96
+			$this->dirmodule = $regs[2];
97 97
 		}
98 98
 		// For compatibility
99
-        if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; }
99
+		if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; }
100 100
 
101
-        // Control file
101
+		// Control file
102 102
 		$controlclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php');
103 103
 		if (file_exists($controlclassfile))
104 104
 		{
105
-            // Include actions class (controller)
106
-            $this->control_file=$controlclassfile;
107
-            require_once $controlclassfile;
105
+			// Include actions class (controller)
106
+			$this->control_file=$controlclassfile;
107
+			require_once $controlclassfile;
108 108
 
109
-            // Instantiate actions class (controller)
110
-            $controlclassname = 'Actions'.ucfirst($this->card).ucfirst($this->canvas);
111
-            $this->control = new $controlclassname($this->db, $this->dirmodule, $this->targetmodule, $this->canvas, $this->card);
109
+			// Instantiate actions class (controller)
110
+			$controlclassname = 'Actions'.ucfirst($this->card).ucfirst($this->canvas);
111
+			$this->control = new $controlclassname($this->db, $this->dirmodule, $this->targetmodule, $this->canvas, $this->card);
112 112
 		}
113 113
 
114 114
 		// Template dir
115 115
 		$this->template_dir = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/tpl/');
116
-        if (! is_dir($this->template_dir))
117
-        {
118
-            $this->template_dir='';
119
-        }
116
+		if (! is_dir($this->template_dir))
117
+		{
118
+			$this->template_dir='';
119
+		}
120 120
 
121
-        //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'<br>';
122
-        //print ' => template_dir='.$this->template_dir.'<br>';
121
+		//print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'<br>';
122
+		//print ' => template_dir='.$this->template_dir.'<br>';
123 123
 	}
124 124
 
125
-    /**
125
+	/**
126 126
 	 * 	Shared method for canvas to assign values for templates
127 127
 	 *
128 128
 	 * 	@param		string		$action	Action string
@@ -135,19 +135,19 @@  discard block
 block discarded – undo
135 135
 		if (method_exists($this->control,'assign_values')) $this->control->assign_values($action, $id, $ref);
136 136
 	}
137 137
 
138
-    /**
139
-     *	Return the template to display canvas (if it exists)
138
+	/**
139
+	 *	Return the template to display canvas (if it exists)
140 140
 	 *
141 141
 	 *	@param	string	$action		Action code
142
-     *	@return	int		0=Canvas template file does not exist, 1=Canvas template file exists
143
-     */
144
-    function displayCanvasExists($action)
145
-    {
146
-        if (empty($this->template_dir)) return 0;
142
+	 *	@return	int		0=Canvas template file does not exist, 1=Canvas template file exists
143
+	 */
144
+	function displayCanvasExists($action)
145
+	{
146
+		if (empty($this->template_dir)) return 0;
147 147
 
148
-        if (file_exists($this->template_dir.($this->card?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1;
149
-        else return 0;
150
-    }
148
+		if (file_exists($this->template_dir.($this->card?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1;
149
+		else return 0;
150
+	}
151 151
 
152 152
 	/**
153 153
 	 *	Display a canvas page. This will include the template for output.
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	function hasActions()
177 177
 	{
178
-        return (is_object($this->control));
178
+		return (is_object($this->control));
179 179
 	}
180 180
 
181 181
 	/**
182 182
 	 * 	Shared method for canvas to execute actions.
183
-     *  @deprecated Use the doActions of hooks instead of this.
183
+	 *  @deprecated Use the doActions of hooks instead of this.
184 184
 	 * 	            This function is called if you add a doActions class inside your canvas. Try to not
185 185
 	 * 				do that and add action code into a hook instead.
186 186
 	 *
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -30,17 +30,17 @@  discard block
 block discarded – undo
30 30
 {
31 31
 	var $db;
32 32
 	var $error;
33
-	var $errors=array();
33
+	var $errors = array();
34 34
 
35 35
 	var $actiontype;
36 36
 
37
-    var $dirmodule;			// Module directory
38
-    var $targetmodule;      // Module concerned by canvas (ex: thirdparty, contact, ...)
39
-    var $canvas;            // Name of canvas (ex: company, individual, product, service, ...)
40
-    var $card;              // Tab (sub-canvas)
37
+    var $dirmodule; // Module directory
38
+    var $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...)
39
+    var $canvas; // Name of canvas (ex: company, individual, product, service, ...)
40
+    var $card; // Tab (sub-canvas)
41 41
 
42
-    var $template_dir;			// Initialized by getCanvas with templates directory
43
-    var $control;           	// Initialized by getCanvas with controller instance
42
+    var $template_dir; // Initialized by getCanvas with templates directory
43
+    var $control; // Initialized by getCanvas with controller instance
44 44
 
45 45
 
46 46
    /**
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	*   @param     DoliDB	$db          	Database handler
50 50
 	*   @param     string   $actiontype		Action type ('create', 'view', 'edit', 'list')
51 51
 	*/
52
-	function __construct($db, $actiontype='view')
52
+	function __construct($db, $actiontype = 'view')
53 53
 	{
54 54
 		$this->db = $db;
55 55
 
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 	private function _cleanaction($action)
66 66
 	{
67 67
 	    $newaction = $action;
68
-	    if ($newaction == 'add')    $newaction='create';
69
-	    if ($newaction == 'update') $newaction='edit';
70
-	    if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction='view';
68
+	    if ($newaction == 'add')    $newaction = 'create';
69
+	    if ($newaction == 'update') $newaction = 'edit';
70
+	    if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction = 'view';
71 71
 	    return $newaction;
72 72
 	}
73 73
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         $this->card = $card;
91 91
         $this->dirmodule = $module;
92 92
         // Correct values if canvas is into an external module
93
-		if (preg_match('/^([^@]+)@([^@]+)$/i',$canvas,$regs))
93
+		if (preg_match('/^([^@]+)@([^@]+)$/i', $canvas, $regs))
94 94
 		{
95 95
             $this->canvas = $regs[1];
96 96
 		    $this->dirmodule = $regs[2];
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		if (file_exists($controlclassfile))
104 104
 		{
105 105
             // Include actions class (controller)
106
-            $this->control_file=$controlclassfile;
106
+            $this->control_file = $controlclassfile;
107 107
             require_once $controlclassfile;
108 108
 
109 109
             // Instantiate actions class (controller)
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 
114 114
 		// Template dir
115 115
 		$this->template_dir = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/tpl/');
116
-        if (! is_dir($this->template_dir))
116
+        if (!is_dir($this->template_dir))
117 117
         {
118
-            $this->template_dir='';
118
+            $this->template_dir = '';
119 119
         }
120 120
 
121 121
         //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'<br>';
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 	 * 	@param		string		$ref		Object ref (if id not provided)
131 131
 	 * 	@return		void
132 132
 	 */
133
-	function assign_values(&$action='view', $id=0, $ref='')
133
+	function assign_values(&$action = 'view', $id = 0, $ref = '')
134 134
 	{
135
-		if (method_exists($this->control,'assign_values')) $this->control->assign_values($action, $id, $ref);
135
+		if (method_exists($this->control, 'assign_values')) $this->control->assign_values($action, $id, $ref);
136 136
 	}
137 137
 
138 138
     /**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     {
146 146
         if (empty($this->template_dir)) return 0;
147 147
 
148
-        if (file_exists($this->template_dir.($this->card?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1;
148
+        if (file_exists($this->template_dir.($this->card ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php')) return 1;
149 149
         else return 0;
150 150
     }
151 151
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		global $db, $conf, $langs, $user, $canvas;
162 162
 		global $form, $formfile;
163 163
 
164
-		include $this->template_dir.($this->card?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php';        // Include native PHP template
164
+		include $this->template_dir.($this->card ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template
165 165
 	}
166 166
 
167 167
 
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
 	 * 	@return		mixed					Return return code of doActions of canvas
190 190
 	 * 	@see		http://wiki.dolibarr.org/index.php/Canvas_development
191 191
 	 */
192
-	function doActions(&$action='view', $id=0)
192
+	function doActions(&$action = 'view', $id = 0)
193 193
 	{
194
-		if (method_exists($this->control,'doActions'))
194
+		if (method_exists($this->control, 'doActions'))
195 195
 		{
196 196
 			$ret = $this->control->doActions($action, $id);
197 197
 			return $ret;
Please login to merge, or discard this patch.
Braces   +20 added lines, -7 removed lines patch added patch discarded remove patch
@@ -65,9 +65,15 @@  discard block
 block discarded – undo
65 65
 	private function _cleanaction($action)
66 66
 	{
67 67
 	    $newaction = $action;
68
-	    if ($newaction == 'add')    $newaction='create';
69
-	    if ($newaction == 'update') $newaction='edit';
70
-	    if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction='view';
68
+	    if ($newaction == 'add') {
69
+	    	$newaction='create';
70
+	    }
71
+	    if ($newaction == 'update') {
72
+	    	$newaction='edit';
73
+	    }
74
+	    if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') {
75
+	    	$newaction='view';
76
+	    }
71 77
 	    return $newaction;
72 78
 	}
73 79
 
@@ -132,7 +138,9 @@  discard block
 block discarded – undo
132 138
 	 */
133 139
 	function assign_values(&$action='view', $id=0, $ref='')
134 140
 	{
135
-		if (method_exists($this->control,'assign_values')) $this->control->assign_values($action, $id, $ref);
141
+		if (method_exists($this->control,'assign_values')) {
142
+			$this->control->assign_values($action, $id, $ref);
143
+		}
136 144
 	}
137 145
 
138 146
     /**
@@ -143,10 +151,15 @@  discard block
 block discarded – undo
143 151
      */
144 152
     function displayCanvasExists($action)
145 153
     {
146
-        if (empty($this->template_dir)) return 0;
154
+        if (empty($this->template_dir)) {
155
+        	return 0;
156
+        }
147 157
 
148
-        if (file_exists($this->template_dir.($this->card?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1;
149
-        else return 0;
158
+        if (file_exists($this->template_dir.($this->card?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) {
159
+        	return 1;
160
+        } else {
161
+        	return 0;
162
+        }
150 163
     }
151 164
 
152 165
 	/**
Please login to merge, or discard this patch.
htdocs/core/class/fiscalyear.class.php 3 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		$this->db = $db;
57 57
 
58 58
 		$this->statuts_short = array(0 => 'Opened', 1 => 'Closed');
59
-        $this->statuts = array(0 => 'Opened', 1 => 'Closed');
59
+		$this->statuts = array(0 => 'Opened', 1 => 'Closed');
60 60
 
61 61
 		return 1;
62 62
 	}
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
 
135 135
 		// Check parameters
136 136
 		if (empty($this->date_start) && empty($this->date_end))
137
-        {
138
-            $this->error='ErrorBadParameter';
139
-            return -1;
140
-        }
137
+		{
138
+			$this->error='ErrorBadParameter';
139
+			return -1;
140
+		}
141 141
 
142 142
 		$this->db->begin();
143 143
 
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 	}
168 168
 
169 169
 	/**
170
-	* Load an object from database
171
-	*
172
-	* @param	int		$id		Id of record to load
173
-	* @return	int				<0 if KO, >0 if OK
174
-	*/
170
+	 * Load an object from database
171
+	 *
172
+	 * @param	int		$id		Id of record to load
173
+	 * @return	int				<0 if KO, >0 if OK
174
+	 */
175 175
 	function fetch($id)
176 176
 	{
177 177
 		$sql = "SELECT rowid, label, date_start, date_end, statut";
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 	}
202 202
 
203 203
    /**
204
-	*	Delete record
205
-	*
206
-	*	@param	int		$id		Id of record to delete
207
-	*	@return	int				<0 if KO, >0 if OK
208
-	*/
204
+    *	Delete record
205
+    *
206
+    *	@param	int		$id		Id of record to delete
207
+    *	@return	int				<0 if KO, >0 if OK
208
+    */
209 209
 	function delete($id)
210 210
 	{
211 211
 		$this->db->begin();
Please login to merge, or discard this patch.
Braces   +30 added lines, -20 removed lines patch added patch discarded remove patch
@@ -106,15 +106,13 @@  discard block
 block discarded – undo
106 106
 			{
107 107
 				$this->db->commit();
108 108
 				return $this->id;
109
-			}
110
-			else
109
+			} else
111 110
 			{
112 111
 				$this->error=$this->db->lasterror();
113 112
 				$this->db->rollback();
114 113
 				return $result;
115 114
 			}
116
-		}
117
-		else
115
+		} else
118 116
 		{
119 117
 			$this->error=$this->db->lasterror()." sql=".$sql;
120 118
 			$this->db->rollback();
@@ -156,8 +154,7 @@  discard block
 block discarded – undo
156 154
 		{
157 155
 			$this->db->commit();
158 156
 			return 1;
159
-		}
160
-		else
157
+		} else
161 158
 		{
162 159
 			$this->error=$this->db->lasterror();
163 160
 			dol_syslog($this->error, LOG_ERR);
@@ -192,8 +189,7 @@  discard block
 block discarded – undo
192 189
 			$this->statut	    = $obj->statut;
193 190
 
194 191
 			return 1;
195
-		}
196
-		else
192
+		} else
197 193
 		{
198 194
 			$this->error=$this->db->lasterror();
199 195
 			return -1;
@@ -218,8 +214,7 @@  discard block
 block discarded – undo
218 214
 		{
219 215
 			$this->db->commit();
220 216
 			return 1;
221
-		}
222
-		else
217
+		} else
223 218
 		{
224 219
 			$this->error=$this->db->lasterror();
225 220
 			$this->db->rollback();
@@ -259,23 +254,39 @@  discard block
 block discarded – undo
259 254
 		}
260 255
 		if ($mode == 2)
261 256
 		{
262
-			if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]);
263
-			if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts_short[$statut]);
257
+			if ($statut==0) {
258
+				return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]);
259
+			}
260
+			if ($statut==1) {
261
+				return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts_short[$statut]);
262
+			}
264 263
 		}
265 264
 		if ($mode == 3)
266 265
 		{
267
-			if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
268
-			if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8');
266
+			if ($statut==0 && ! empty($this->statuts_short[$statut])) {
267
+				return img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
268
+			}
269
+			if ($statut==1 && ! empty($this->statuts_short[$statut])) {
270
+				return img_picto($langs->trans($this->statuts_short[$statut]),'statut8');
271
+			}
269 272
 		}
270 273
 		if ($mode == 4)
271 274
 		{
272
-			if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]);
273
-			if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts[$statut]);
275
+			if ($statut==0 && ! empty($this->statuts_short[$statut])) {
276
+				return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]);
277
+			}
278
+			if ($statut==1 && ! empty($this->statuts_short[$statut])) {
279
+				return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts[$statut]);
280
+			}
274 281
 		}
275 282
 		if ($mode == 5)
276 283
 		{
277
-			if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
278
-			if ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6');
284
+			if ($statut==0 && ! empty($this->statuts_short[$statut])) {
285
+				return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
286
+			}
287
+			if ($statut==1 && ! empty($this->statuts_short[$statut])) {
288
+				return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6');
289
+			}
279 290
 		}
280 291
 	}
281 292
 
@@ -317,8 +328,7 @@  discard block
 block discarded – undo
317 328
 				$this->date_modification = $this->db->jdate($obj->tms);
318 329
 			}
319 330
 			$this->db->free($result);
320
-		}
321
-		else
331
+		} else
322 332
 		{
323 333
 			dol_print_error($this->db);
324 334
 		}
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -21,18 +21,18 @@  discard block
 block discarded – undo
21 21
  *		\brief      File of class to manage fiscal years
22 22
  */
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
  * Class to manage fiscal year
28 28
  */
29 29
 class Fiscalyear extends CommonObject
30 30
 {
31
-	public $element='fiscalyear';
32
-	public $table_element='accounting_fiscalyear';
31
+	public $element = 'fiscalyear';
32
+	public $table_element = 'accounting_fiscalyear';
33 33
 	public $table_element_line = '';
34 34
 	public $fk_element = '';
35
-	protected $ismultientitymanaged = 1;	// 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
35
+	protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
36 36
 
37 37
 	var $rowid;
38 38
 
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
 	var $date_start;
41 41
 	var $date_end;
42 42
 	var $datec;
43
-	var $statut;		// 0=open, 1=closed
43
+	var $statut; // 0=open, 1=closed
44 44
 	var $entity;
45 45
 
46
-	var $statuts=array();
47
-	var $statuts_short=array();
46
+	var $statuts = array();
47
+	var $statuts_short = array();
48 48
 
49 49
 	/**
50 50
 	 * Constructor
@@ -73,27 +73,27 @@  discard block
 block discarded – undo
73 73
 
74 74
 		$error = 0;
75 75
 
76
-		$now=dol_now();
76
+		$now = dol_now();
77 77
 
78 78
 		$this->db->begin();
79 79
 
80 80
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_fiscalyear (";
81
-		$sql.= "label";
82
-		$sql.= ", date_start";
83
-		$sql.= ", date_end";
84
-		$sql.= ", statut";
85
-		$sql.= ", entity";
86
-		$sql.= ", datec";
87
-		$sql.= ", fk_user_author";
88
-		$sql.= ") VALUES (";
89
-		$sql.= " '".$this->db->escape($this->label)."'";
90
-		$sql.= ", '".$this->db->idate($this->date_start)."'";
91
-		$sql.= ", ".($this->date_end ? "'".$this->db->idate($this->date_end)."'":"null");
92
-		$sql.= ", 0";
93
-		$sql.= ", ".$conf->entity;
94
-		$sql.= ", '".$this->db->idate($now)."'";
95
-		$sql.= ", ". $user->id;
96
-		$sql.= ")";
81
+		$sql .= "label";
82
+		$sql .= ", date_start";
83
+		$sql .= ", date_end";
84
+		$sql .= ", statut";
85
+		$sql .= ", entity";
86
+		$sql .= ", datec";
87
+		$sql .= ", fk_user_author";
88
+		$sql .= ") VALUES (";
89
+		$sql .= " '".$this->db->escape($this->label)."'";
90
+		$sql .= ", '".$this->db->idate($this->date_start)."'";
91
+		$sql .= ", ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : "null");
92
+		$sql .= ", 0";
93
+		$sql .= ", ".$conf->entity;
94
+		$sql .= ", '".$this->db->idate($now)."'";
95
+		$sql .= ", ".$user->id;
96
+		$sql .= ")";
97 97
 
98 98
 		dol_syslog(get_class($this)."::create", LOG_DEBUG);
99 99
 		$result = $this->db->query($sql);
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 		{
102 102
 			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."accounting_fiscalyear");
103 103
 
104
-			$result=$this->update($user);
104
+			$result = $this->update($user);
105 105
 			if ($result > 0)
106 106
 			{
107 107
 				$this->db->commit();
@@ -109,14 +109,14 @@  discard block
 block discarded – undo
109 109
 			}
110 110
 			else
111 111
 			{
112
-				$this->error=$this->db->lasterror();
112
+				$this->error = $this->db->lasterror();
113 113
 				$this->db->rollback();
114 114
 				return $result;
115 115
 			}
116 116
 		}
117 117
 		else
118 118
 		{
119
-			$this->error=$this->db->lasterror()." sql=".$sql;
119
+			$this->error = $this->db->lasterror()." sql=".$sql;
120 120
 			$this->db->rollback();
121 121
 			return -1;
122 122
 		}
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 		// Check parameters
136 136
 		if (empty($this->date_start) && empty($this->date_end))
137 137
         {
138
-            $this->error='ErrorBadParameter';
138
+            $this->error = 'ErrorBadParameter';
139 139
             return -1;
140 140
         }
141 141
 
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 		$sql .= ", date_start = '".$this->db->idate($this->date_start)."'";
147 147
 		$sql .= ", date_end = ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : "null");
148 148
 		$sql .= ", statut = '".$this->db->escape($this->statut)."'";
149
-		$sql .= ", datec = " . ($this->datec != '' ? "'".$this->db->idate($this->datec)."'" : 'null');
150
-		$sql .= ", fk_user_modif = " . $user->id;
149
+		$sql .= ", datec = ".($this->datec != '' ? "'".$this->db->idate($this->datec)."'" : 'null');
150
+		$sql .= ", fk_user_modif = ".$user->id;
151 151
 		$sql .= " WHERE rowid = ".$this->id;
152 152
 
153 153
 		dol_syslog(get_class($this)."::update", LOG_DEBUG);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		}
160 160
 		else
161 161
 		{
162
-			$this->error=$this->db->lasterror();
162
+			$this->error = $this->db->lasterror();
163 163
 			dol_syslog($this->error, LOG_ERR);
164 164
 			$this->db->rollback();
165 165
 			return -1;
@@ -175,27 +175,27 @@  discard block
 block discarded – undo
175 175
 	function fetch($id)
176 176
 	{
177 177
 		$sql = "SELECT rowid, label, date_start, date_end, statut";
178
-		$sql.= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear";
179
-		$sql.= " WHERE rowid = ".$id;
178
+		$sql .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear";
179
+		$sql .= " WHERE rowid = ".$id;
180 180
 
181 181
 		dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
182 182
 		$result = $this->db->query($sql);
183
-		if ( $result )
183
+		if ($result)
184 184
 		{
185 185
 			$obj = $this->db->fetch_object($result);
186 186
 
187
-			$this->id			= $obj->rowid;
188
-			$this->ref			= $obj->rowid;
187
+			$this->id = $obj->rowid;
188
+			$this->ref = $obj->rowid;
189 189
 			$this->date_start	= $this->db->jdate($obj->date_start);
190
-			$this->date_end		= $this->db->jdate($obj->date_end);
191
-			$this->label		= $obj->label;
190
+			$this->date_end = $this->db->jdate($obj->date_end);
191
+			$this->label = $obj->label;
192 192
 			$this->statut	    = $obj->statut;
193 193
 
194 194
 			return 1;
195 195
 		}
196 196
 		else
197 197
 		{
198
-			$this->error=$this->db->lasterror();
198
+			$this->error = $this->db->lasterror();
199 199
 			return -1;
200 200
 		}
201 201
 	}
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		}
222 222
 		else
223 223
 		{
224
-			$this->error=$this->db->lasterror();
224
+			$this->error = $this->db->lasterror();
225 225
 			$this->db->rollback();
226 226
 			return -1;
227 227
 		}
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
 	 * @param	int		$mode   	0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
234 234
 	 * @return  string   		   	Label
235 235
 	 */
236
-	function getLibStatut($mode=0)
236
+	function getLibStatut($mode = 0)
237 237
 	{
238
-		return $this->LibStatut($this->statut,$mode);
238
+		return $this->LibStatut($this->statut, $mode);
239 239
 	}
240 240
 
241 241
 	/**
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 *  @param  int		$mode       0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
246 246
 	 *  @return string      		Label
247 247
 	 */
248
-	function LibStatut($statut,$mode=0)
248
+	function LibStatut($statut, $mode = 0)
249 249
 	{
250 250
 		global $langs;
251 251
 
@@ -259,23 +259,23 @@  discard block
 block discarded – undo
259 259
 		}
260 260
 		if ($mode == 2)
261 261
 		{
262
-			if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]);
263
-			if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts_short[$statut]);
262
+			if ($statut == 0) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts_short[$statut]);
263
+			if ($statut == 1) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut8').' '.$langs->trans($this->statuts_short[$statut]);
264 264
 		}
265 265
 		if ($mode == 3)
266 266
 		{
267
-			if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
268
-			if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8');
267
+			if ($statut == 0 && !empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4');
268
+			if ($statut == 1 && !empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut8');
269 269
 		}
270 270
 		if ($mode == 4)
271 271
 		{
272
-			if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]);
273
-			if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts[$statut]);
272
+			if ($statut == 0 && !empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts[$statut]);
273
+			if ($statut == 1 && !empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut8').' '.$langs->trans($this->statuts[$statut]);
274 274
 		}
275 275
 		if ($mode == 5)
276 276
 		{
277
-			if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
278
-			if ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6');
277
+			if ($statut == 0 && !empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut4');
278
+			if ($statut == 1 && !empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut6');
279 279
 		}
280 280
 	}
281 281
 
@@ -288,9 +288,9 @@  discard block
 block discarded – undo
288 288
 	function info($id)
289 289
 	{
290 290
 		$sql = 'SELECT fy.rowid, fy.datec, fy.fk_user_author, fy.fk_user_modif,';
291
-		$sql.= ' fy.tms';
292
-		$sql.= ' FROM '.MAIN_DB_PREFIX.'accounting_fiscalyear as fy';
293
-		$sql.= ' WHERE fy.rowid = '.$id;
291
+		$sql .= ' fy.tms';
292
+		$sql .= ' FROM '.MAIN_DB_PREFIX.'accounting_fiscalyear as fy';
293
+		$sql .= ' WHERE fy.rowid = '.$id;
294 294
 
295 295
 		dol_syslog(get_class($this)."::fetch info", LOG_DEBUG);
296 296
 		$result = $this->db->query($sql);
Please login to merge, or discard this patch.
htdocs/core/class/html.formmailing.class.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,8 +51,8 @@
 block discarded – undo
51 51
 			$options[-2] = '';   // Note -1 is used for error
52 52
 		}
53 53
 
54
-        $options = $options + $mailing->statut_dest;
54
+		$options = $options + $mailing->statut_dest;
55 55
 
56
-        return Form::selectarray($htmlname, $options, $selectedid, 0, 0, 0, '', 1);
56
+		return Form::selectarray($htmlname, $options, $selectedid, 0, 0, 0, '', 1);
57 57
 	}
58 58
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
  *  \ingroup    core
21 21
  *	\brief      File of predefined functions for HTML forms for mailing module
22 22
  */
23
-require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php';
23
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
24 24
 
25 25
 /**
26 26
  *	Class to offer components to list and upload files
27 27
  */
28 28
 class FormMailing extends Form
29 29
 {
30
-	public $errors=array();
30
+	public $errors = array();
31 31
 
32 32
 	/**
33 33
 	 * Output a select with destinaries status
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @param integer  $show_empty     Show empty option
38 38
 	 * @return string HTML select
39 39
 	 */
40
-	public function selectDestinariesStatus($selectedid='',$htmlname='dest_status', $show_empty=0) {
40
+	public function selectDestinariesStatus($selectedid = '', $htmlname = 'dest_status', $show_empty = 0) {
41 41
 
42 42
 		global $langs;
43 43
 		$langs->load("mails");
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		$options = array();
49 49
 
50 50
 		if ($show_empty) {
51
-			$options[-2] = '';   // Note -1 is used for error
51
+			$options[-2] = ''; // Note -1 is used for error
52 52
 		}
53 53
 
54 54
         $options = $options + $mailing->statut_dest;
Please login to merge, or discard this patch.
htdocs/core/class/html.formsocialcontrib.class.php 3 patches
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -32,85 +32,85 @@
 block discarded – undo
32 32
 
33 33
 
34 34
 	/**
35
-	* Constructor
36
-	*
37
-	* @param		DoliDB		$db      Database handler
38
-	*/
35
+	 * Constructor
36
+	 *
37
+	 * @param		DoliDB		$db      Database handler
38
+	 */
39 39
 	public function __construct($db)
40 40
 	{
41
-	    $this->db = $db;
41
+		$this->db = $db;
42 42
 	}
43 43
 
44
-    /**
45
-     *	Return list of social contributions.
46
-     * 	Use mysoc->country_id or mysoc->country_code so they must be defined.
47
-     *
48
-     *	@param	string	$selected       Preselected type
49
-     *	@param  string	$htmlname       Name of field in form
50
-     * 	@param	int		$useempty		Set to 1 if we want an empty value
51
-     * 	@param	int		$maxlen			Max length of text in combo box
52
-     * 	@param	int		$help			Add or not the admin help picto
53
-     * 	@return	void
54
-     */
55
-    function select_type_socialcontrib($selected='',$htmlname='actioncode', $useempty=0, $maxlen=40, $help=1)
56
-    {
57
-        global $db,$langs,$user,$mysoc;
44
+	/**
45
+	 *	Return list of social contributions.
46
+	 * 	Use mysoc->country_id or mysoc->country_code so they must be defined.
47
+	 *
48
+	 *	@param	string	$selected       Preselected type
49
+	 *	@param  string	$htmlname       Name of field in form
50
+	 * 	@param	int		$useempty		Set to 1 if we want an empty value
51
+	 * 	@param	int		$maxlen			Max length of text in combo box
52
+	 * 	@param	int		$help			Add or not the admin help picto
53
+	 * 	@return	void
54
+	 */
55
+	function select_type_socialcontrib($selected='',$htmlname='actioncode', $useempty=0, $maxlen=40, $help=1)
56
+	{
57
+		global $db,$langs,$user,$mysoc;
58 58
 
59
-        if (empty($mysoc->country_id) && empty($mysoc->country_code))
60
-        {
61
-            dol_print_error('','Call to select_type_socialcontrib with mysoc country not yet defined');
62
-            exit;
63
-        }
59
+		if (empty($mysoc->country_id) && empty($mysoc->country_code))
60
+		{
61
+			dol_print_error('','Call to select_type_socialcontrib with mysoc country not yet defined');
62
+			exit;
63
+		}
64 64
 
65
-        if (! empty($mysoc->country_id))
66
-        {
67
-            $sql = "SELECT c.id, c.libelle as type";
68
-            $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
69
-            $sql.= " WHERE c.active = 1";
70
-            $sql.= " AND c.fk_pays = ".$mysoc->country_id;
71
-            $sql.= " ORDER BY c.libelle ASC";
72
-        }
73
-        else
74
-        {
75
-            $sql = "SELECT c.id, c.libelle as type";
76
-            $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."c_country as co";
77
-            $sql.= " WHERE c.active = 1 AND c.fk_pays = co.rowid";
78
-            $sql.= " AND co.code = '".$mysoc->country_code."'";
79
-            $sql.= " ORDER BY c.libelle ASC";
80
-        }
65
+		if (! empty($mysoc->country_id))
66
+		{
67
+			$sql = "SELECT c.id, c.libelle as type";
68
+			$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
69
+			$sql.= " WHERE c.active = 1";
70
+			$sql.= " AND c.fk_pays = ".$mysoc->country_id;
71
+			$sql.= " ORDER BY c.libelle ASC";
72
+		}
73
+		else
74
+		{
75
+			$sql = "SELECT c.id, c.libelle as type";
76
+			$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."c_country as co";
77
+			$sql.= " WHERE c.active = 1 AND c.fk_pays = co.rowid";
78
+			$sql.= " AND co.code = '".$mysoc->country_code."'";
79
+			$sql.= " ORDER BY c.libelle ASC";
80
+		}
81 81
 
82
-        dol_syslog("Form::select_type_socialcontrib", LOG_DEBUG);
83
-        $resql=$db->query($sql);
84
-        if ($resql)
85
-        {
86
-            $num = $db->num_rows($resql);
87
-            if ($num)
88
-            {
89
-                print '<select class="flat" name="'.$htmlname.'">';
90
-                $i = 0;
82
+		dol_syslog("Form::select_type_socialcontrib", LOG_DEBUG);
83
+		$resql=$db->query($sql);
84
+		if ($resql)
85
+		{
86
+			$num = $db->num_rows($resql);
87
+			if ($num)
88
+			{
89
+				print '<select class="flat" name="'.$htmlname.'">';
90
+				$i = 0;
91 91
 
92
-                if ($useempty) print '<option value="0">&nbsp;</option>';
93
-                while ($i < $num)
94
-                {
95
-                    $obj = $db->fetch_object($resql);
96
-                    print '<option value="'.$obj->id.'"';
97
-                    if ($obj->id == $selected) print ' selected';
98
-                    print '>'.dol_trunc($obj->type,$maxlen);
99
-                    $i++;
100
-                }
101
-                print '</select>';
102
-                if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
103
-            }
104
-            else
105
-            {
106
-                print $langs->trans("ErrorNoSocialContributionForSellerCountry",$mysoc->country_code);
107
-            }
108
-        }
109
-        else
110
-        {
111
-            dol_print_error($db,$db->lasterror());
112
-        }
113
-    }
92
+				if ($useempty) print '<option value="0">&nbsp;</option>';
93
+				while ($i < $num)
94
+				{
95
+					$obj = $db->fetch_object($resql);
96
+					print '<option value="'.$obj->id.'"';
97
+					if ($obj->id == $selected) print ' selected';
98
+					print '>'.dol_trunc($obj->type,$maxlen);
99
+					$i++;
100
+				}
101
+				print '</select>';
102
+				if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
103
+			}
104
+			else
105
+			{
106
+				print $langs->trans("ErrorNoSocialContributionForSellerCountry",$mysoc->country_code);
107
+			}
108
+		}
109
+		else
110
+		{
111
+			dol_print_error($db,$db->lasterror());
112
+		}
113
+	}
114 114
 
115 115
 }
116 116
 
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -52,35 +52,35 @@  discard block
 block discarded – undo
52 52
      * 	@param	int		$help			Add or not the admin help picto
53 53
      * 	@return	void
54 54
      */
55
-    function select_type_socialcontrib($selected='',$htmlname='actioncode', $useempty=0, $maxlen=40, $help=1)
55
+    function select_type_socialcontrib($selected = '', $htmlname = 'actioncode', $useempty = 0, $maxlen = 40, $help = 1)
56 56
     {
57
-        global $db,$langs,$user,$mysoc;
57
+        global $db, $langs, $user, $mysoc;
58 58
 
59 59
         if (empty($mysoc->country_id) && empty($mysoc->country_code))
60 60
         {
61
-            dol_print_error('','Call to select_type_socialcontrib with mysoc country not yet defined');
61
+            dol_print_error('', 'Call to select_type_socialcontrib with mysoc country not yet defined');
62 62
             exit;
63 63
         }
64 64
 
65
-        if (! empty($mysoc->country_id))
65
+        if (!empty($mysoc->country_id))
66 66
         {
67 67
             $sql = "SELECT c.id, c.libelle as type";
68
-            $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
69
-            $sql.= " WHERE c.active = 1";
70
-            $sql.= " AND c.fk_pays = ".$mysoc->country_id;
71
-            $sql.= " ORDER BY c.libelle ASC";
68
+            $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
69
+            $sql .= " WHERE c.active = 1";
70
+            $sql .= " AND c.fk_pays = ".$mysoc->country_id;
71
+            $sql .= " ORDER BY c.libelle ASC";
72 72
         }
73 73
         else
74 74
         {
75 75
             $sql = "SELECT c.id, c.libelle as type";
76
-            $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."c_country as co";
77
-            $sql.= " WHERE c.active = 1 AND c.fk_pays = co.rowid";
78
-            $sql.= " AND co.code = '".$mysoc->country_code."'";
79
-            $sql.= " ORDER BY c.libelle ASC";
76
+            $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."c_country as co";
77
+            $sql .= " WHERE c.active = 1 AND c.fk_pays = co.rowid";
78
+            $sql .= " AND co.code = '".$mysoc->country_code."'";
79
+            $sql .= " ORDER BY c.libelle ASC";
80 80
         }
81 81
 
82 82
         dol_syslog("Form::select_type_socialcontrib", LOG_DEBUG);
83
-        $resql=$db->query($sql);
83
+        $resql = $db->query($sql);
84 84
         if ($resql)
85 85
         {
86 86
             $num = $db->num_rows($resql);
@@ -95,20 +95,20 @@  discard block
 block discarded – undo
95 95
                     $obj = $db->fetch_object($resql);
96 96
                     print '<option value="'.$obj->id.'"';
97 97
                     if ($obj->id == $selected) print ' selected';
98
-                    print '>'.dol_trunc($obj->type,$maxlen);
98
+                    print '>'.dol_trunc($obj->type, $maxlen);
99 99
                     $i++;
100 100
                 }
101 101
                 print '</select>';
102
-                if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
102
+                if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
103 103
             }
104 104
             else
105 105
             {
106
-                print $langs->trans("ErrorNoSocialContributionForSellerCountry",$mysoc->country_code);
106
+                print $langs->trans("ErrorNoSocialContributionForSellerCountry", $mysoc->country_code);
107 107
             }
108 108
         }
109 109
         else
110 110
         {
111
-            dol_print_error($db,$db->lasterror());
111
+            dol_print_error($db, $db->lasterror());
112 112
         }
113 113
     }
114 114
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -9 removed lines patch added patch discarded remove patch
@@ -69,8 +69,7 @@  discard block
 block discarded – undo
69 69
             $sql.= " WHERE c.active = 1";
70 70
             $sql.= " AND c.fk_pays = ".$mysoc->country_id;
71 71
             $sql.= " ORDER BY c.libelle ASC";
72
-        }
73
-        else
72
+        } else
74 73
         {
75 74
             $sql = "SELECT c.id, c.libelle as type";
76 75
             $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."c_country as co";
@@ -89,24 +88,28 @@  discard block
 block discarded – undo
89 88
                 print '<select class="flat" name="'.$htmlname.'">';
90 89
                 $i = 0;
91 90
 
92
-                if ($useempty) print '<option value="0">&nbsp;</option>';
91
+                if ($useempty) {
92
+                	print '<option value="0">&nbsp;</option>';
93
+                }
93 94
                 while ($i < $num)
94 95
                 {
95 96
                     $obj = $db->fetch_object($resql);
96 97
                     print '<option value="'.$obj->id.'"';
97
-                    if ($obj->id == $selected) print ' selected';
98
+                    if ($obj->id == $selected) {
99
+                    	print ' selected';
100
+                    }
98 101
                     print '>'.dol_trunc($obj->type,$maxlen);
99 102
                     $i++;
100 103
                 }
101 104
                 print '</select>';
102
-                if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
103
-            }
104
-            else
105
+                if ($user->admin && $help) {
106
+                	print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
107
+                }
108
+            } else
105 109
             {
106 110
                 print $langs->trans("ErrorNoSocialContributionForSellerCountry",$mysoc->country_code);
107 111
             }
108
-        }
109
-        else
112
+        } else
110 113
         {
111 114
             dol_print_error($db,$db->lasterror());
112 115
         }
Please login to merge, or discard this patch.
htdocs/core/class/cstate.class.php 3 patches
Braces   +27 added lines, -16 removed lines patch added patch discarded remove patch
@@ -71,9 +71,15 @@  discard block
 block discarded – undo
71 71
 		$error=0;
72 72
 
73 73
 		// Clean parameters
74
-		if (isset($this->code_departement)) $this->code_departement=trim($this->code_departement);
75
-		if (isset($this->nom)) $this->nom=trim($this->nom);
76
-		if (isset($this->active)) $this->active=trim($this->active);
74
+		if (isset($this->code_departement)) {
75
+			$this->code_departement=trim($this->code_departement);
76
+		}
77
+		if (isset($this->nom)) {
78
+			$this->nom=trim($this->nom);
79
+		}
80
+		if (isset($this->active)) {
81
+			$this->active=trim($this->active);
82
+		}
77 83
 
78 84
 		// Check parameters
79 85
 		// Put here code to add control on parameters values
@@ -125,8 +131,7 @@  discard block
 block discarded – undo
125 131
 			}
126 132
 			$this->db->rollback();
127 133
 			return -1*$error;
128
-		}
129
-		else
134
+		} else
130 135
 		{
131 136
 			$this->db->commit();
132 137
             return $this->id;
@@ -150,8 +155,11 @@  discard block
 block discarded – undo
150 155
 		$sql.= " t.nom,";
151 156
 		$sql.= " t.active";
152 157
         $sql.= " FROM ".MAIN_DB_PREFIX."c_departements as t";
153
-        if ($id)   $sql.= " WHERE t.rowid = ".$id;
154
-        elseif ($code) $sql.= " WHERE t.code_departement = '".$this->db->escape($code)."'";
158
+        if ($id) {
159
+        	$sql.= " WHERE t.rowid = ".$id;
160
+        } elseif ($code) {
161
+        	$sql.= " WHERE t.code_departement = '".$this->db->escape($code)."'";
162
+        }
155 163
 
156 164
     	dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
157 165
         $resql=$this->db->query($sql);
@@ -169,8 +177,7 @@  discard block
 block discarded – undo
169 177
             $this->db->free($resql);
170 178
 
171 179
             return 1;
172
-        }
173
-        else
180
+        } else
174 181
         {
175 182
       	    $this->error="Error ".$this->db->lasterror();
176 183
             return -1;
@@ -191,9 +198,15 @@  discard block
 block discarded – undo
191 198
 		$error=0;
192 199
 
193 200
 		// Clean parameters
194
-		if (isset($this->code_departement)) $this->code_departement=trim($this->code_departement);
195
-		if (isset($this->nom)) $this->nom=trim($this->nom);
196
-		if (isset($this->active)) $this->active=trim($this->active);
201
+		if (isset($this->code_departement)) {
202
+			$this->code_departement=trim($this->code_departement);
203
+		}
204
+		if (isset($this->nom)) {
205
+			$this->nom=trim($this->nom);
206
+		}
207
+		if (isset($this->active)) {
208
+			$this->active=trim($this->active);
209
+		}
197 210
 
198 211
 
199 212
 		// Check parameters
@@ -238,8 +251,7 @@  discard block
 block discarded – undo
238 251
 			}
239 252
 			$this->db->rollback();
240 253
 			return -1*$error;
241
-		}
242
-		else
254
+		} else
243 255
 		{
244 256
 			$this->db->commit();
245 257
 			return 1;
@@ -294,8 +306,7 @@  discard block
 block discarded – undo
294 306
 			}
295 307
 			$this->db->rollback();
296 308
 			return -1*$error;
297
-		}
298
-		else
309
+		} else
299 310
 		{
300 311
 			$this->db->commit();
301 312
 			return 1;
Please login to merge, or discard this patch.
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	//var $element='cstate';			//!< Id that identify managed objects
39 39
 	//var $table_element='cstate';	    //!< Name of table without prefix where object is stored
40 40
 
41
-    var $id;
41
+	var $id;
42 42
 	var $code_departement;
43 43
 	var $nom;
44 44
 	var $active;
@@ -46,28 +46,28 @@  discard block
 block discarded – undo
46 46
 
47 47
 
48 48
 
49
-    /**
50
-     *  Constructor
51
-     *
52
-     *  @param      DoliDb		$db      Database handler
53
-     */
54
-    function __construct($db)
55
-    {
56
-        $this->db = $db;
57
-        return 1;
58
-    }
49
+	/**
50
+	 *  Constructor
51
+	 *
52
+	 *  @param      DoliDb		$db      Database handler
53
+	 */
54
+	function __construct($db)
55
+	{
56
+		$this->db = $db;
57
+		return 1;
58
+	}
59 59
 
60 60
 
61
-    /**
62
-     *  Create object into database
63
-     *
64
-     *  @param      User	$user        User that create
65
-     *  @param      int		$notrigger   0=launch triggers after, 1=disable triggers
66
-     *  @return     int      		   	 <0 if KO, Id of created object if OK
67
-     */
68
-    function create($user, $notrigger=0)
69
-    {
70
-    	global $conf, $langs;
61
+	/**
62
+	 *  Create object into database
63
+	 *
64
+	 *  @param      User	$user        User that create
65
+	 *  @param      int		$notrigger   0=launch triggers after, 1=disable triggers
66
+	 *  @return     int      		   	 <0 if KO, Id of created object if OK
67
+	 */
68
+	function create($user, $notrigger=0)
69
+	{
70
+		global $conf, $langs;
71 71
 		$error=0;
72 72
 
73 73
 		// Clean parameters
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
 		// Check parameters
79 79
 		// Put here code to add control on parameters values
80 80
 
81
-        // Insert request
81
+		// Insert request
82 82
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_departements(";
83 83
 		$sql.= "rowid,";
84 84
 		$sql.= "code_departement,";
85 85
 		$sql.= "nom,";
86 86
 		$sql.= "active";
87
-        $sql.= ") VALUES (";
87
+		$sql.= ") VALUES (";
88 88
 		$sql.= " ".(! isset($this->rowid)?'NULL':"'".$this->db->escape($this->rowid)."'").",";
89 89
 		$sql.= " ".(! isset($this->code_departement)?'NULL':"'".$this->db->escape($this->code_departement)."'").",";
90 90
 		$sql.= " ".(! isset($this->nom)?'NULL':"'".$this->db->escape($this->nom)."'").",";
@@ -94,34 +94,34 @@  discard block
 block discarded – undo
94 94
 		$this->db->begin();
95 95
 
96 96
 	   	dol_syslog(get_class($this)."::create", LOG_DEBUG);
97
-        $resql=$this->db->query($sql);
98
-    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
97
+		$resql=$this->db->query($sql);
98
+		if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
99 99
 
100 100
 		if (! $error)
101
-        {
102
-            $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_departements");
101
+		{
102
+			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_departements");
103 103
 
104 104
 			if (! $notrigger)
105 105
 			{
106
-	            // Uncomment this and change MYOBJECT to your own tag if you
107
-	            // want this action call a trigger.
108
-
109
-	            //// Call triggers
110
-	            //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
111
-	            //$interface=new Interfaces($this->db);
112
-	            //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
113
-	            //if ($result < 0) { $error++; $this->errors=$interface->errors; }
114
-	            //// End call triggers
106
+				// Uncomment this and change MYOBJECT to your own tag if you
107
+				// want this action call a trigger.
108
+
109
+				//// Call triggers
110
+				//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
111
+				//$interface=new Interfaces($this->db);
112
+				//$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
113
+				//if ($result < 0) { $error++; $this->errors=$interface->errors; }
114
+				//// End call triggers
115 115
 			}
116
-        }
116
+		}
117 117
 
118
-        // Commit or rollback
119
-        if ($error)
118
+		// Commit or rollback
119
+		if ($error)
120 120
 		{
121 121
 			foreach($this->errors as $errmsg)
122 122
 			{
123
-	            dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
124
-	            $this->error.=($this->error?', '.$errmsg:$errmsg);
123
+				dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
124
+				$this->error.=($this->error?', '.$errmsg:$errmsg);
125 125
 			}
126 126
 			$this->db->rollback();
127 127
 			return -1*$error;
@@ -129,65 +129,65 @@  discard block
 block discarded – undo
129 129
 		else
130 130
 		{
131 131
 			$this->db->commit();
132
-            return $this->id;
132
+			return $this->id;
133 133
 		}
134
-    }
135
-
136
-
137
-    /**
138
-     *  Load object in memory from database
139
-     *
140
-     *  @param      int		$id    	Id object
141
-     *  @param		string	$code	Code
142
-     *  @return     int          	<0 if KO, >0 if OK
143
-     */
144
-    function fetch($id,$code='')
145
-    {
146
-    	global $langs;
147
-        $sql = "SELECT";
134
+	}
135
+
136
+
137
+	/**
138
+	 *  Load object in memory from database
139
+	 *
140
+	 *  @param      int		$id    	Id object
141
+	 *  @param		string	$code	Code
142
+	 *  @return     int          	<0 if KO, >0 if OK
143
+	 */
144
+	function fetch($id,$code='')
145
+	{
146
+		global $langs;
147
+		$sql = "SELECT";
148 148
 		$sql.= " t.rowid,";
149 149
 		$sql.= " t.code_departement,";
150 150
 		$sql.= " t.nom,";
151 151
 		$sql.= " t.active";
152
-        $sql.= " FROM ".MAIN_DB_PREFIX."c_departements as t";
153
-        if ($id)   $sql.= " WHERE t.rowid = ".$id;
154
-        elseif ($code) $sql.= " WHERE t.code_departement = '".$this->db->escape($code)."'";
155
-
156
-    	dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
157
-        $resql=$this->db->query($sql);
158
-        if ($resql)
159
-        {
160
-            if ($this->db->num_rows($resql))
161
-            {
162
-                $obj = $this->db->fetch_object($resql);
163
-
164
-                $this->id    = $obj->rowid;
152
+		$sql.= " FROM ".MAIN_DB_PREFIX."c_departements as t";
153
+		if ($id)   $sql.= " WHERE t.rowid = ".$id;
154
+		elseif ($code) $sql.= " WHERE t.code_departement = '".$this->db->escape($code)."'";
155
+
156
+		dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
157
+		$resql=$this->db->query($sql);
158
+		if ($resql)
159
+		{
160
+			if ($this->db->num_rows($resql))
161
+			{
162
+				$obj = $this->db->fetch_object($resql);
163
+
164
+				$this->id    = $obj->rowid;
165 165
 				$this->code_departement = $obj->code_departement;
166 166
 				$this->nom = $obj->nom;
167 167
 				$this->active = $obj->active;
168
-            }
169
-            $this->db->free($resql);
170
-
171
-            return 1;
172
-        }
173
-        else
174
-        {
175
-      	    $this->error="Error ".$this->db->lasterror();
176
-            return -1;
177
-        }
178
-    }
179
-
180
-
181
-    /**
182
-     *  Update object into database
183
-     *
184
-     *  @param      User	$user        User that modify
185
-     *  @param      int		$notrigger	 0=launch triggers after, 1=disable triggers
186
-     *  @return     int     		   	 <0 if KO, >0 if OK
187
-     */
188
-    function update($user=null, $notrigger=0)
189
-    {
190
-    	global $conf, $langs;
168
+			}
169
+			$this->db->free($resql);
170
+
171
+			return 1;
172
+		}
173
+		else
174
+		{
175
+	  		$this->error="Error ".$this->db->lasterror();
176
+			return -1;
177
+		}
178
+	}
179
+
180
+
181
+	/**
182
+	 *  Update object into database
183
+	 *
184
+	 *  @param      User	$user        User that modify
185
+	 *  @param      int		$notrigger	 0=launch triggers after, 1=disable triggers
186
+	 *  @return     int     		   	 <0 if KO, >0 if OK
187
+	 */
188
+	function update($user=null, $notrigger=0)
189
+	{
190
+		global $conf, $langs;
191 191
 		$error=0;
192 192
 
193 193
 		// Clean parameters
@@ -199,42 +199,42 @@  discard block
 block discarded – undo
199 199
 		// Check parameters
200 200
 		// Put here code to add control on parameters values
201 201
 
202
-        // Update request
203
-        $sql = "UPDATE ".MAIN_DB_PREFIX."c_departements SET";
202
+		// Update request
203
+		$sql = "UPDATE ".MAIN_DB_PREFIX."c_departements SET";
204 204
 		$sql.= " code_departement=".(isset($this->code_departement)?"'".$this->db->escape($this->code_departement)."'":"null").",";
205 205
 		$sql.= " nom=".(isset($this->nom)?"'".$this->db->escape($this->nom)."'":"null").",";
206 206
 		$sql.= " active=".(isset($this->active)?$this->active:"null")."";
207
-        $sql.= " WHERE rowid=".$this->id;
207
+		$sql.= " WHERE rowid=".$this->id;
208 208
 
209 209
 		$this->db->begin();
210 210
 
211 211
 		dol_syslog(get_class($this)."::update", LOG_DEBUG);
212
-        $resql = $this->db->query($sql);
213
-    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
212
+		$resql = $this->db->query($sql);
213
+		if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
214 214
 
215 215
 		if (! $error)
216 216
 		{
217 217
 			if (! $notrigger)
218 218
 			{
219
-	            // Uncomment this and change MYOBJECT to your own tag if you
220
-	            // want this action call a trigger.
221
-
222
-	            //// Call triggers
223
-	            //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
224
-	            //$interface=new Interfaces($this->db);
225
-	            //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
226
-	            //if ($result < 0) { $error++; $this->errors=$interface->errors; }
227
-	            //// End call triggers
228
-	    	}
219
+				// Uncomment this and change MYOBJECT to your own tag if you
220
+				// want this action call a trigger.
221
+
222
+				//// Call triggers
223
+				//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
224
+				//$interface=new Interfaces($this->db);
225
+				//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
226
+				//if ($result < 0) { $error++; $this->errors=$interface->errors; }
227
+				//// End call triggers
228
+			}
229 229
 		}
230 230
 
231
-        // Commit or rollback
231
+		// Commit or rollback
232 232
 		if ($error)
233 233
 		{
234 234
 			foreach($this->errors as $errmsg)
235 235
 			{
236
-	            dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
237
-	            $this->error.=($this->error?', '.$errmsg:$errmsg);
236
+				dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
237
+				$this->error.=($this->error?', '.$errmsg:$errmsg);
238 238
 			}
239 239
 			$this->db->rollback();
240 240
 			return -1*$error;
@@ -244,16 +244,16 @@  discard block
 block discarded – undo
244 244
 			$this->db->commit();
245 245
 			return 1;
246 246
 		}
247
-    }
247
+	}
248 248
 
249 249
 
250 250
  	/**
251 251
  	 *  Delete object in database
252
-	 *
253
-     *	@param  User	$user        User that delete
254
-     *  @param	int		$notrigger	 0=launch triggers after, 1=disable triggers
255
-	 *  @return	int					 <0 if KO, >0 if OK
256
-	 */
252
+ 	 *
253
+ 	 *	@param  User	$user        User that delete
254
+ 	 *  @param	int		$notrigger	 0=launch triggers after, 1=disable triggers
255
+ 	 *  @return	int					 <0 if KO, >0 if OK
256
+ 	 */
257 257
 	function delete($user, $notrigger=0)
258 258
 	{
259 259
 		global $conf, $langs;
@@ -266,31 +266,31 @@  discard block
 block discarded – undo
266 266
 
267 267
 		dol_syslog(get_class($this)."::delete", LOG_DEBUG);
268 268
 		$resql = $this->db->query($sql);
269
-    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
269
+		if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
270 270
 
271 271
 		if (! $error)
272 272
 		{
273 273
 			if (! $notrigger)
274 274
 			{
275 275
 				// Uncomment this and change MYOBJECT to your own tag if you
276
-		        // want this action call a trigger.
277
-
278
-		        //// Call triggers
279
-		        //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
280
-		        //$interface=new Interfaces($this->db);
281
-		        //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
282
-		        //if ($result < 0) { $error++; $this->errors=$interface->errors; }
283
-		        //// End call triggers
276
+				// want this action call a trigger.
277
+
278
+				//// Call triggers
279
+				//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
280
+				//$interface=new Interfaces($this->db);
281
+				//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
282
+				//if ($result < 0) { $error++; $this->errors=$interface->errors; }
283
+				//// End call triggers
284 284
 			}
285 285
 		}
286 286
 
287
-        // Commit or rollback
287
+		// Commit or rollback
288 288
 		if ($error)
289 289
 		{
290 290
 			foreach($this->errors as $errmsg)
291 291
 			{
292
-	            dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
293
-	            $this->error.=($this->error?', '.$errmsg:$errmsg);
292
+				dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
293
+				$this->error.=($this->error?', '.$errmsg:$errmsg);
294 294
 			}
295 295
 			$this->db->rollback();
296 296
 			return -1*$error;
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class Cstate // extends CommonObject
34 34
 {
35
-	var $db;							//!< To store db handler
36
-	var $error;							//!< To return error code (or message)
37
-	var $errors=array();				//!< To return several error codes (or messages)
35
+	var $db; //!< To store db handler
36
+	var $error; //!< To return error code (or message)
37
+	var $errors = array(); //!< To return several error codes (or messages)
38 38
 	//var $element='cstate';			//!< Id that identify managed objects
39 39
 	//var $table_element='cstate';	    //!< Name of table without prefix where object is stored
40 40
 
@@ -65,43 +65,43 @@  discard block
 block discarded – undo
65 65
      *  @param      int		$notrigger   0=launch triggers after, 1=disable triggers
66 66
      *  @return     int      		   	 <0 if KO, Id of created object if OK
67 67
      */
68
-    function create($user, $notrigger=0)
68
+    function create($user, $notrigger = 0)
69 69
     {
70 70
     	global $conf, $langs;
71
-		$error=0;
71
+		$error = 0;
72 72
 
73 73
 		// Clean parameters
74
-		if (isset($this->code_departement)) $this->code_departement=trim($this->code_departement);
75
-		if (isset($this->nom)) $this->nom=trim($this->nom);
76
-		if (isset($this->active)) $this->active=trim($this->active);
74
+		if (isset($this->code_departement)) $this->code_departement = trim($this->code_departement);
75
+		if (isset($this->nom)) $this->nom = trim($this->nom);
76
+		if (isset($this->active)) $this->active = trim($this->active);
77 77
 
78 78
 		// Check parameters
79 79
 		// Put here code to add control on parameters values
80 80
 
81 81
         // Insert request
82 82
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_departements(";
83
-		$sql.= "rowid,";
84
-		$sql.= "code_departement,";
85
-		$sql.= "nom,";
86
-		$sql.= "active";
87
-        $sql.= ") VALUES (";
88
-		$sql.= " ".(! isset($this->rowid)?'NULL':"'".$this->db->escape($this->rowid)."'").",";
89
-		$sql.= " ".(! isset($this->code_departement)?'NULL':"'".$this->db->escape($this->code_departement)."'").",";
90
-		$sql.= " ".(! isset($this->nom)?'NULL':"'".$this->db->escape($this->nom)."'").",";
91
-		$sql.= " ".(! isset($this->active)?'NULL':"'".$this->db->escape($this->active)."'")."";
92
-		$sql.= ")";
83
+		$sql .= "rowid,";
84
+		$sql .= "code_departement,";
85
+		$sql .= "nom,";
86
+		$sql .= "active";
87
+        $sql .= ") VALUES (";
88
+		$sql .= " ".(!isset($this->rowid) ? 'NULL' : "'".$this->db->escape($this->rowid)."'").",";
89
+		$sql .= " ".(!isset($this->code_departement) ? 'NULL' : "'".$this->db->escape($this->code_departement)."'").",";
90
+		$sql .= " ".(!isset($this->nom) ? 'NULL' : "'".$this->db->escape($this->nom)."'").",";
91
+		$sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->escape($this->active)."'")."";
92
+		$sql .= ")";
93 93
 
94 94
 		$this->db->begin();
95 95
 
96 96
 	   	dol_syslog(get_class($this)."::create", LOG_DEBUG);
97
-        $resql=$this->db->query($sql);
98
-    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
97
+        $resql = $this->db->query($sql);
98
+    	if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
99 99
 
100
-		if (! $error)
100
+		if (!$error)
101 101
         {
102 102
             $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_departements");
103 103
 
104
-			if (! $notrigger)
104
+			if (!$notrigger)
105 105
 			{
106 106
 	            // Uncomment this and change MYOBJECT to your own tag if you
107 107
 	            // want this action call a trigger.
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
         // Commit or rollback
119 119
         if ($error)
120 120
 		{
121
-			foreach($this->errors as $errmsg)
121
+			foreach ($this->errors as $errmsg)
122 122
 			{
123 123
 	            dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
124
-	            $this->error.=($this->error?', '.$errmsg:$errmsg);
124
+	            $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
125 125
 			}
126 126
 			$this->db->rollback();
127
-			return -1*$error;
127
+			return -1 * $error;
128 128
 		}
129 129
 		else
130 130
 		{
@@ -141,27 +141,27 @@  discard block
 block discarded – undo
141 141
      *  @param		string	$code	Code
142 142
      *  @return     int          	<0 if KO, >0 if OK
143 143
      */
144
-    function fetch($id,$code='')
144
+    function fetch($id, $code = '')
145 145
     {
146 146
     	global $langs;
147 147
         $sql = "SELECT";
148
-		$sql.= " t.rowid,";
149
-		$sql.= " t.code_departement,";
150
-		$sql.= " t.nom,";
151
-		$sql.= " t.active";
152
-        $sql.= " FROM ".MAIN_DB_PREFIX."c_departements as t";
153
-        if ($id)   $sql.= " WHERE t.rowid = ".$id;
154
-        elseif ($code) $sql.= " WHERE t.code_departement = '".$this->db->escape($code)."'";
148
+		$sql .= " t.rowid,";
149
+		$sql .= " t.code_departement,";
150
+		$sql .= " t.nom,";
151
+		$sql .= " t.active";
152
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_departements as t";
153
+        if ($id)   $sql .= " WHERE t.rowid = ".$id;
154
+        elseif ($code) $sql .= " WHERE t.code_departement = '".$this->db->escape($code)."'";
155 155
 
156 156
     	dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
157
-        $resql=$this->db->query($sql);
157
+        $resql = $this->db->query($sql);
158 158
         if ($resql)
159 159
         {
160 160
             if ($this->db->num_rows($resql))
161 161
             {
162 162
                 $obj = $this->db->fetch_object($resql);
163 163
 
164
-                $this->id    = $obj->rowid;
164
+                $this->id = $obj->rowid;
165 165
 				$this->code_departement = $obj->code_departement;
166 166
 				$this->nom = $obj->nom;
167 167
 				$this->active = $obj->active;
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
         }
173 173
         else
174 174
         {
175
-      	    $this->error="Error ".$this->db->lasterror();
175
+      	    $this->error = "Error ".$this->db->lasterror();
176 176
             return -1;
177 177
         }
178 178
     }
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
      *  @param      int		$notrigger	 0=launch triggers after, 1=disable triggers
186 186
      *  @return     int     		   	 <0 if KO, >0 if OK
187 187
      */
188
-    function update($user=null, $notrigger=0)
188
+    function update($user = null, $notrigger = 0)
189 189
     {
190 190
     	global $conf, $langs;
191
-		$error=0;
191
+		$error = 0;
192 192
 
193 193
 		// Clean parameters
194
-		if (isset($this->code_departement)) $this->code_departement=trim($this->code_departement);
195
-		if (isset($this->nom)) $this->nom=trim($this->nom);
196
-		if (isset($this->active)) $this->active=trim($this->active);
194
+		if (isset($this->code_departement)) $this->code_departement = trim($this->code_departement);
195
+		if (isset($this->nom)) $this->nom = trim($this->nom);
196
+		if (isset($this->active)) $this->active = trim($this->active);
197 197
 
198 198
 
199 199
 		// Check parameters
@@ -201,20 +201,20 @@  discard block
 block discarded – undo
201 201
 
202 202
         // Update request
203 203
         $sql = "UPDATE ".MAIN_DB_PREFIX."c_departements SET";
204
-		$sql.= " code_departement=".(isset($this->code_departement)?"'".$this->db->escape($this->code_departement)."'":"null").",";
205
-		$sql.= " nom=".(isset($this->nom)?"'".$this->db->escape($this->nom)."'":"null").",";
206
-		$sql.= " active=".(isset($this->active)?$this->active:"null")."";
207
-        $sql.= " WHERE rowid=".$this->id;
204
+		$sql .= " code_departement=".(isset($this->code_departement) ? "'".$this->db->escape($this->code_departement)."'" : "null").",";
205
+		$sql .= " nom=".(isset($this->nom) ? "'".$this->db->escape($this->nom)."'" : "null").",";
206
+		$sql .= " active=".(isset($this->active) ? $this->active : "null")."";
207
+        $sql .= " WHERE rowid=".$this->id;
208 208
 
209 209
 		$this->db->begin();
210 210
 
211 211
 		dol_syslog(get_class($this)."::update", LOG_DEBUG);
212 212
         $resql = $this->db->query($sql);
213
-    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
213
+    	if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
214 214
 
215
-		if (! $error)
215
+		if (!$error)
216 216
 		{
217
-			if (! $notrigger)
217
+			if (!$notrigger)
218 218
 			{
219 219
 	            // Uncomment this and change MYOBJECT to your own tag if you
220 220
 	            // want this action call a trigger.
@@ -231,13 +231,13 @@  discard block
 block discarded – undo
231 231
         // Commit or rollback
232 232
 		if ($error)
233 233
 		{
234
-			foreach($this->errors as $errmsg)
234
+			foreach ($this->errors as $errmsg)
235 235
 			{
236 236
 	            dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
237
-	            $this->error.=($this->error?', '.$errmsg:$errmsg);
237
+	            $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
238 238
 			}
239 239
 			$this->db->rollback();
240
-			return -1*$error;
240
+			return -1 * $error;
241 241
 		}
242 242
 		else
243 243
 		{
@@ -254,23 +254,23 @@  discard block
 block discarded – undo
254 254
      *  @param	int		$notrigger	 0=launch triggers after, 1=disable triggers
255 255
 	 *  @return	int					 <0 if KO, >0 if OK
256 256
 	 */
257
-	function delete($user, $notrigger=0)
257
+	function delete($user, $notrigger = 0)
258 258
 	{
259 259
 		global $conf, $langs;
260
-		$error=0;
260
+		$error = 0;
261 261
 
262 262
 		$sql = "DELETE FROM ".MAIN_DB_PREFIX."c_departements";
263
-		$sql.= " WHERE rowid=".$this->id;
263
+		$sql .= " WHERE rowid=".$this->id;
264 264
 
265 265
 		$this->db->begin();
266 266
 
267 267
 		dol_syslog(get_class($this)."::delete", LOG_DEBUG);
268 268
 		$resql = $this->db->query($sql);
269
-    	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
269
+    	if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
270 270
 
271
-		if (! $error)
271
+		if (!$error)
272 272
 		{
273
-			if (! $notrigger)
273
+			if (!$notrigger)
274 274
 			{
275 275
 				// Uncomment this and change MYOBJECT to your own tag if you
276 276
 		        // want this action call a trigger.
@@ -287,13 +287,13 @@  discard block
 block discarded – undo
287 287
         // Commit or rollback
288 288
 		if ($error)
289 289
 		{
290
-			foreach($this->errors as $errmsg)
290
+			foreach ($this->errors as $errmsg)
291 291
 			{
292 292
 	            dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
293
-	            $this->error.=($this->error?', '.$errmsg:$errmsg);
293
+	            $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
294 294
 			}
295 295
 			$this->db->rollback();
296
-			return -1*$error;
296
+			return -1 * $error;
297 297
 		}
298 298
 		else
299 299
 		{
Please login to merge, or discard this patch.
htdocs/core/class/vcard.class.php 3 patches
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
  */
31 31
 function encode($string)
32 32
 {
33
-    return str_replace(";","\;",(dol_quoted_printable_encode(utf8_decode($string))));
33
+	return str_replace(";","\;",(dol_quoted_printable_encode(utf8_decode($string))));
34 34
 }
35 35
 
36 36
 
@@ -44,38 +44,38 @@  discard block
 block discarded – undo
44 44
  */
45 45
 function dol_quoted_printable_encode($input, $line_max=76)
46 46
 {
47
-    $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
48
-    $lines = preg_split("/(\?:\r\n|\r|\n)/", $input);
49
-    $eol = "\r\n";
50
-    $linebreak = "=0D=0A";
51
-    $escape = "=";
52
-    $output = "";
53
-
54
-    $num = count($lines);
55
-    for ($j = 0; $j < $num; $j++)
56
-    {
57
-        $line = $lines[$j];
58
-        $linlen = strlen($line);
59
-        $newline = "";
60
-        for($i = 0; $i < $linlen; $i++) {
61
-            $c = substr($line, $i, 1);
62
-            $dec = ord($c);
63
-            if ( ($dec == 32) && ($i == ($linlen - 1)) ) { // convert space at eol only
64
-                $c = "=20";
65
-            } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
66
-                $h2 = floor($dec/16); $h1 = floor($dec%16);
67
-                $c = $escape.$hex["$h2"].$hex["$h1"];
68
-            }
69
-            if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
70
-                $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay
71
-                $newline = "    ";
72
-            }
73
-            $newline .= $c;
74
-        } // end of for
75
-        $output .= $newline;
76
-        if ($j<count($lines)-1) $output .= $linebreak;
77
-    }
78
-    return trim($output);
47
+	$hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
48
+	$lines = preg_split("/(\?:\r\n|\r|\n)/", $input);
49
+	$eol = "\r\n";
50
+	$linebreak = "=0D=0A";
51
+	$escape = "=";
52
+	$output = "";
53
+
54
+	$num = count($lines);
55
+	for ($j = 0; $j < $num; $j++)
56
+	{
57
+		$line = $lines[$j];
58
+		$linlen = strlen($line);
59
+		$newline = "";
60
+		for($i = 0; $i < $linlen; $i++) {
61
+			$c = substr($line, $i, 1);
62
+			$dec = ord($c);
63
+			if ( ($dec == 32) && ($i == ($linlen - 1)) ) { // convert space at eol only
64
+				$c = "=20";
65
+			} elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
66
+				$h2 = floor($dec/16); $h1 = floor($dec%16);
67
+				$c = $escape.$hex["$h2"].$hex["$h1"];
68
+			}
69
+			if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
70
+				$output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay
71
+				$newline = "    ";
72
+			}
73
+			$newline .= $c;
74
+		} // end of for
75
+		$output .= $newline;
76
+		if ($j<count($lines)-1) $output .= $linebreak;
77
+	}
78
+	return trim($output);
79 79
 }
80 80
 
81 81
 
@@ -84,249 +84,249 @@  discard block
 block discarded – undo
84 84
  */
85 85
 class vCard
86 86
 {
87
-    var $properties;
88
-    var $filename;
89
-
90
-    //var $encoding="UTF-8";
91
-    var $encoding="ISO-8859-1;ENCODING=QUOTED-PRINTABLE";
92
-
93
-
94
-    /**
95
-     *	mise en forme du numero de telephone
96
-     *
97
-     *	@param	int		$number		numero de telephone
98
-     *	@param	string	$type		Type
99
-     *	@return	void
100
-     */
101
-    function setPhoneNumber($number, $type="")
102
-    {
103
-        // type may be PREF | WORK | HOME | VOICE | FAX | MSG | CELL | PAGER | BBS | CAR | MODEM | ISDN | VIDEO or any senseful combination, e.g. "PREF;WORK;VOICE"
104
-        $key = "TEL";
105
-        if ($type!="") $key .= ";".$type;
106
-        $key.= ";CHARSET=".$this->encoding;
107
-        $this->properties[$key] = encode($number);
108
-    }
109
-
110
-    /**
111
-     *	mise en forme de la photo
112
-     *  warning NON TESTE !
113
-     *
114
-     *	@param	string	$type			Type
115
-     *	@param	string	$photo			Photo
116
-     *	@return	void
87
+	var $properties;
88
+	var $filename;
89
+
90
+	//var $encoding="UTF-8";
91
+	var $encoding="ISO-8859-1;ENCODING=QUOTED-PRINTABLE";
92
+
93
+
94
+	/**
95
+	 *	mise en forme du numero de telephone
96
+	 *
97
+	 *	@param	int		$number		numero de telephone
98
+	 *	@param	string	$type		Type
99
+	 *	@return	void
100
+	 */
101
+	function setPhoneNumber($number, $type="")
102
+	{
103
+		// type may be PREF | WORK | HOME | VOICE | FAX | MSG | CELL | PAGER | BBS | CAR | MODEM | ISDN | VIDEO or any senseful combination, e.g. "PREF;WORK;VOICE"
104
+		$key = "TEL";
105
+		if ($type!="") $key .= ";".$type;
106
+		$key.= ";CHARSET=".$this->encoding;
107
+		$this->properties[$key] = encode($number);
108
+	}
109
+
110
+	/**
111
+	 *	mise en forme de la photo
112
+	 *  warning NON TESTE !
113
+	 *
114
+	 *	@param	string	$type			Type
115
+	 *	@param	string	$photo			Photo
116
+	 *	@return	void
117
+	 */
118
+	function setPhoto($type, $photo)
119
+	{ // $type = "GIF" | "JPEG"
120
+		$this->properties["PHOTO;TYPE=$type;ENCODING=BASE64"] = base64_encode($photo);
121
+	}
122
+
123
+	/**
124
+	 *	mise en forme du nom formate
125
+	 *
126
+	 *	@param	string	$name			Name
127
+	 *	@return	void
128
+	 */
129
+	function setFormattedName($name)
130
+	{
131
+		$this->properties["FN;CHARSET=".$this->encoding] = encode($name);
132
+	}
133
+
134
+	/**
135
+	 *	mise en forme du nom complet
136
+	 *
137
+	 *	@param	string	$family			Family
138
+	 *	@param	string	$first			First
139
+	 *	@param	string	$additional		Additionnal
140
+	 *	@param	string	$prefix			Prefix
141
+	 *	@param	string	$suffix			Suffix
142
+	 *	@return	void
143
+	 */
144
+	function setName($family="", $first="", $additional="", $prefix="", $suffix="")
145
+	{
146
+		$this->properties["N;CHARSET=".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix);
147
+		$this->filename = "$first%20$family.vcf";
148
+		if (empty($this->properties["FN"])) $this->setFormattedName(trim("$prefix $first $additional $family $suffix"));
149
+	}
150
+
151
+	/**
152
+	 *	mise en forme de l'anniversaire
153
+	 *
154
+	 *	@param	timestamp	$date		Date
155
+	 *	@return	void
156
+	 */
157
+	function setBirthday($date)
158
+	{ 
159
+		// $date format is YYYY-MM-DD - RFC 2425 and RFC 2426
160
+		$this->properties["BDAY"] = dol_print_date($date, 'dayrfc');
161
+	}
162
+
163
+	/**
164
+	 *	mise en forme de l'adresse
165
+	 *
166
+	 *	@param	string	$postoffice		Postoffice
167
+	 *	@param	string	$extended		Extended
168
+	 *	@param	string	$street			Street
169
+	 *	@param	string	$city			City
170
+	 *	@param	string	$region			Region
171
+	 *	@param	string	$zip			Zip
172
+	 *	@param	string	$country		Country
173
+	 *	@param	string	$type			Type
174
+	 *	@return	void
175
+	 */
176
+	function setAddress($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME;POSTAL")
177
+	{
178
+		// $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL"
179
+		$key = "ADR";
180
+		if ($type!="") $key.= ";$type";
181
+		$key.= ";CHARSET=".$this->encoding;
182
+		$this->properties[$key] = ";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country);
183
+
184
+		if ($this->properties["LABEL;$type;CHARSET=".$this->encoding] == "")
185
+		{
186
+			//$this->setLabel($postoffice, $extended, $street, $city, $region, $zip, $country, $type);
187
+		}
188
+	}
189
+
190
+	/**
191
+	 *	mise en forme du label
192
+	 *
193
+	 *	@param	string	$postoffice		Postoffice
194
+	 *	@param	string	$extended		Extended
195
+	 *	@param	string	$street			Street
196
+	 *	@param	string	$city			City
197
+	 *	@param	string	$region			Region
198
+	 *	@param	string	$zip			Zip
199
+	 *	@param	string	$country		Country
200
+	 *	@param	string	$type			Type
201
+	 *	@return	void
202
+	 */
203
+	function setLabel($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME;POSTAL") {
204
+		$label = "";
205
+		if ($postoffice!="") $label.= "$postoffice\r\n";
206
+		if ($extended!="") $label.= "$extended\r\n";
207
+		if ($street!="") $label.= "$street\r\n";
208
+		if ($zip!="") $label.= "$zip ";
209
+		if ($city!="") $label.= "$city\r\n";
210
+		if ($region!="") $label.= "$region\r\n";
211
+		if ($country!="") $country.= "$country\r\n";
212
+
213
+		$this->properties["LABEL;$type;CHARSET=".$this->encoding] = encode($label);
214
+	}
215
+
216
+	/**
217
+	 *	mise en forme de l'email
218
+	 *
219
+	 *	@param	string	$address		EMail
220
+	 *	@param	string	$type			Vcard type
221
+	 *	@return	void
222
+	 */
223
+	function setEmail($address,$type="internet,pref")
224
+	{
225
+		$this->properties["EMAIL;TYPE=".$type] = $address;
226
+	}
227
+
228
+	/**
229
+	 *	mise en forme de la note
230
+	 *
231
+	 *	@param	string	$note		Note
232
+	 *	@return	void
233
+	 */
234
+	function setNote($note)
235
+	{
236
+		$this->properties["NOTE;CHARSET=".$this->encoding] = encode($note);
237
+	}
238
+
239
+	/**
240
+	 * 	mise en forme de la fonction
241
+	 *
242
+	 *	@param	string	$title		Title
243
+	 *	@return	void
244
+	 */
245
+	function setTitle($title)
246
+	{
247
+		$this->properties["TITLE;CHARSET=".$this->encoding] = encode($title);
248
+	}
249
+
250
+
251
+	/**
252
+	 *	mise en forme de la societe
253
+	 *
254
+	 *	@param	string	$org		Org
255
+	 *	@return	void
256
+	 */
257
+	function setOrg($org)
258
+	{
259
+		$this->properties["ORG;CHARSET=".$this->encoding] = encode($org);
260
+	}
261
+
262
+
263
+	/**
264
+	 * 	mise en forme du logiciel generateur
265
+	 *
266
+	 *  @param	string	$prodid		Prodid
267
+	 *	@return	void
268
+	 */
269
+	function setProdId($prodid)
270
+	{
271
+		$this->properties["PRODID;CHARSET=".$this->encoding] = encode($prodid);
272
+	}
273
+
274
+
275
+	/**
276
+	 * 	mise en forme du logiciel generateur
277
+	 *
278
+	 *  @param	string	$uid	Uid
279
+	 *	@return	void
280
+	 */
281
+	function setUID($uid)
282
+	{
283
+		$this->properties["UID;CHARSET=".$this->encoding] = encode($uid);
284
+	}
285
+
286
+
287
+	/**
288
+	 *  mise en forme de l'url
289
+	 *
290
+	 *	@param	string	$url		URL
291
+	 *  @param	string	$type		Type
292
+	 *	@return	void
293
+	 */
294
+	function setURL($url, $type="")
295
+	{
296
+		// $type may be WORK | HOME
297
+		$key = "URL";
298
+		if ($type!="") $key.= ";$type";
299
+		$this->properties[$key] = $url;
300
+	}
301
+
302
+	/**
303
+	 *  permet d'obtenir une vcard
304
+	 *
305
+	 *  @return	string
306
+	 */
307
+	function getVCard()
308
+	{
309
+		$text = "BEGIN:VCARD\r\n";
310
+		//$text.= "VERSION:3.0\r\n";
311
+		$text.= "VERSION:2.1\r\n";
312
+		foreach($this->properties as $key => $value)
313
+		{
314
+			$text.= "$key:$value\r\n";
315
+		}
316
+		$text.= "REV:".date("Y-m-d")."T".date("H:i:s")."Z\r\n";
317
+		$text.= "MAILER: Dolibarr\r\n";
318
+		$text.= "END:VCARD\r\n";
319
+		return $text;
320
+	}
321
+
322
+	/**
323
+	 *  permet d'obtenir le nom de fichier
324
+	 *
325
+	 *  @return	string		Filename
117 326
 	 */
118
-    function setPhoto($type, $photo)
119
-    { // $type = "GIF" | "JPEG"
120
-        $this->properties["PHOTO;TYPE=$type;ENCODING=BASE64"] = base64_encode($photo);
121
-    }
122
-
123
-    /**
124
-     *	mise en forme du nom formate
125
-     *
126
-     *	@param	string	$name			Name
127
-     *	@return	void
128
-     */
129
-    function setFormattedName($name)
130
-    {
131
-        $this->properties["FN;CHARSET=".$this->encoding] = encode($name);
132
-    }
133
-
134
-    /**
135
-     *	mise en forme du nom complet
136
-     *
137
-     *	@param	string	$family			Family
138
-     *	@param	string	$first			First
139
-     *	@param	string	$additional		Additionnal
140
-     *	@param	string	$prefix			Prefix
141
-     *	@param	string	$suffix			Suffix
142
-     *	@return	void
143
-     */
144
-    function setName($family="", $first="", $additional="", $prefix="", $suffix="")
145
-    {
146
-        $this->properties["N;CHARSET=".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix);
147
-        $this->filename = "$first%20$family.vcf";
148
-        if (empty($this->properties["FN"])) $this->setFormattedName(trim("$prefix $first $additional $family $suffix"));
149
-    }
150
-
151
-    /**
152
-     *	mise en forme de l'anniversaire
153
-     *
154
-     *	@param	timestamp	$date		Date
155
-     *	@return	void
156
-     */
157
-    function setBirthday($date)
158
-    { 
159
-        // $date format is YYYY-MM-DD - RFC 2425 and RFC 2426
160
-        $this->properties["BDAY"] = dol_print_date($date, 'dayrfc');
161
-    }
162
-
163
-    /**
164
-     *	mise en forme de l'adresse
165
-     *
166
-     *	@param	string	$postoffice		Postoffice
167
-     *	@param	string	$extended		Extended
168
-     *	@param	string	$street			Street
169
-     *	@param	string	$city			City
170
-     *	@param	string	$region			Region
171
-     *	@param	string	$zip			Zip
172
-     *	@param	string	$country		Country
173
-     *	@param	string	$type			Type
174
-     *	@return	void
175
-     */
176
-    function setAddress($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME;POSTAL")
177
-    {
178
-        // $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL"
179
-        $key = "ADR";
180
-        if ($type!="") $key.= ";$type";
181
-        $key.= ";CHARSET=".$this->encoding;
182
-        $this->properties[$key] = ";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country);
183
-
184
-        if ($this->properties["LABEL;$type;CHARSET=".$this->encoding] == "")
185
-        {
186
-            //$this->setLabel($postoffice, $extended, $street, $city, $region, $zip, $country, $type);
187
-        }
188
-    }
189
-
190
-    /**
191
-     *	mise en forme du label
192
-     *
193
-     *	@param	string	$postoffice		Postoffice
194
-     *	@param	string	$extended		Extended
195
-     *	@param	string	$street			Street
196
-     *	@param	string	$city			City
197
-     *	@param	string	$region			Region
198
-     *	@param	string	$zip			Zip
199
-     *	@param	string	$country		Country
200
-     *	@param	string	$type			Type
201
-     *	@return	void
202
-     */
203
-    function setLabel($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME;POSTAL") {
204
-        $label = "";
205
-        if ($postoffice!="") $label.= "$postoffice\r\n";
206
-        if ($extended!="") $label.= "$extended\r\n";
207
-        if ($street!="") $label.= "$street\r\n";
208
-        if ($zip!="") $label.= "$zip ";
209
-        if ($city!="") $label.= "$city\r\n";
210
-        if ($region!="") $label.= "$region\r\n";
211
-        if ($country!="") $country.= "$country\r\n";
212
-
213
-        $this->properties["LABEL;$type;CHARSET=".$this->encoding] = encode($label);
214
-    }
215
-
216
-    /**
217
-     *	mise en forme de l'email
218
-     *
219
-     *	@param	string	$address		EMail
220
-     *	@param	string	$type			Vcard type
221
-     *	@return	void
222
-     */
223
-    function setEmail($address,$type="internet,pref")
224
-    {
225
-        $this->properties["EMAIL;TYPE=".$type] = $address;
226
-    }
227
-
228
-    /**
229
-     *	mise en forme de la note
230
-     *
231
-     *	@param	string	$note		Note
232
-     *	@return	void
233
-     */
234
-    function setNote($note)
235
-    {
236
-        $this->properties["NOTE;CHARSET=".$this->encoding] = encode($note);
237
-    }
238
-
239
-    /**
240
-     * 	mise en forme de la fonction
241
-     *
242
-     *	@param	string	$title		Title
243
-     *	@return	void
244
-     */
245
-    function setTitle($title)
246
-    {
247
-        $this->properties["TITLE;CHARSET=".$this->encoding] = encode($title);
248
-    }
249
-
250
-
251
-    /**
252
-     *	mise en forme de la societe
253
-     *
254
-     *	@param	string	$org		Org
255
-     *	@return	void
256
-     */
257
-    function setOrg($org)
258
-    {
259
-        $this->properties["ORG;CHARSET=".$this->encoding] = encode($org);
260
-    }
261
-
262
-
263
-    /**
264
-     * 	mise en forme du logiciel generateur
265
-     *
266
-     *  @param	string	$prodid		Prodid
267
-     *	@return	void
268
-     */
269
-    function setProdId($prodid)
270
-    {
271
-        $this->properties["PRODID;CHARSET=".$this->encoding] = encode($prodid);
272
-    }
273
-
274
-
275
-    /**
276
-     * 	mise en forme du logiciel generateur
277
-     *
278
-     *  @param	string	$uid	Uid
279
-     *	@return	void
280
-     */
281
-    function setUID($uid)
282
-    {
283
-        $this->properties["UID;CHARSET=".$this->encoding] = encode($uid);
284
-    }
285
-
286
-
287
-    /**
288
-     *  mise en forme de l'url
289
-     *
290
-     *	@param	string	$url		URL
291
-     *  @param	string	$type		Type
292
-     *	@return	void
293
-     */
294
-    function setURL($url, $type="")
295
-    {
296
-        // $type may be WORK | HOME
297
-        $key = "URL";
298
-        if ($type!="") $key.= ";$type";
299
-        $this->properties[$key] = $url;
300
-    }
301
-
302
-    /**
303
-     *  permet d'obtenir une vcard
304
-     *
305
-     *  @return	string
306
-     */
307
-    function getVCard()
308
-    {
309
-        $text = "BEGIN:VCARD\r\n";
310
-        //$text.= "VERSION:3.0\r\n";
311
-        $text.= "VERSION:2.1\r\n";
312
-        foreach($this->properties as $key => $value)
313
-        {
314
-            $text.= "$key:$value\r\n";
315
-        }
316
-        $text.= "REV:".date("Y-m-d")."T".date("H:i:s")."Z\r\n";
317
-        $text.= "MAILER: Dolibarr\r\n";
318
-        $text.= "END:VCARD\r\n";
319
-        return $text;
320
-    }
321
-
322
-    /**
323
-     *  permet d'obtenir le nom de fichier
324
-     *
325
-     *  @return	string		Filename
326
-     */
327
-    function getFileName()
328
-    {
329
-        return $this->filename;
330
-    }
327
+	function getFileName()
328
+	{
329
+		return $this->filename;
330
+	}
331 331
 
332 332
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
  */
31 31
 function encode($string)
32 32
 {
33
-    return str_replace(";","\;",(dol_quoted_printable_encode(utf8_decode($string))));
33
+    return str_replace(";", "\;", (dol_quoted_printable_encode(utf8_decode($string))));
34 34
 }
35 35
 
36 36
 
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
  * @param	int		$line_max	Max length of lines
43 43
  * @return	string				Encoded string
44 44
  */
45
-function dol_quoted_printable_encode($input, $line_max=76)
45
+function dol_quoted_printable_encode($input, $line_max = 76)
46 46
 {
47
-    $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
47
+    $hex = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
48 48
     $lines = preg_split("/(\?:\r\n|\r|\n)/", $input);
49 49
     $eol = "\r\n";
50 50
     $linebreak = "=0D=0A";
@@ -57,23 +57,23 @@  discard block
 block discarded – undo
57 57
         $line = $lines[$j];
58 58
         $linlen = strlen($line);
59 59
         $newline = "";
60
-        for($i = 0; $i < $linlen; $i++) {
60
+        for ($i = 0; $i < $linlen; $i++) {
61 61
             $c = substr($line, $i, 1);
62 62
             $dec = ord($c);
63
-            if ( ($dec == 32) && ($i == ($linlen - 1)) ) { // convert space at eol only
63
+            if (($dec == 32) && ($i == ($linlen - 1))) { // convert space at eol only
64 64
                 $c = "=20";
65
-            } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
66
-                $h2 = floor($dec/16); $h1 = floor($dec%16);
65
+            } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) { // always encode "\t", which is *not* required
66
+                $h2 = floor($dec / 16); $h1 = floor($dec % 16);
67 67
                 $c = $escape.$hex["$h2"].$hex["$h1"];
68 68
             }
69
-            if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
69
+            if ((strlen($newline) + strlen($c)) >= $line_max) { // CRLF is not counted
70 70
                 $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay
71 71
                 $newline = "    ";
72 72
             }
73 73
             $newline .= $c;
74 74
         } // end of for
75 75
         $output .= $newline;
76
-        if ($j<count($lines)-1) $output .= $linebreak;
76
+        if ($j < count($lines) - 1) $output .= $linebreak;
77 77
     }
78 78
     return trim($output);
79 79
 }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     var $filename;
89 89
 
90 90
     //var $encoding="UTF-8";
91
-    var $encoding="ISO-8859-1;ENCODING=QUOTED-PRINTABLE";
91
+    var $encoding = "ISO-8859-1;ENCODING=QUOTED-PRINTABLE";
92 92
 
93 93
 
94 94
     /**
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
      *	@param	string	$type		Type
99 99
      *	@return	void
100 100
      */
101
-    function setPhoneNumber($number, $type="")
101
+    function setPhoneNumber($number, $type = "")
102 102
     {
103 103
         // type may be PREF | WORK | HOME | VOICE | FAX | MSG | CELL | PAGER | BBS | CAR | MODEM | ISDN | VIDEO or any senseful combination, e.g. "PREF;WORK;VOICE"
104 104
         $key = "TEL";
105
-        if ($type!="") $key .= ";".$type;
106
-        $key.= ";CHARSET=".$this->encoding;
105
+        if ($type != "") $key .= ";".$type;
106
+        $key .= ";CHARSET=".$this->encoding;
107 107
         $this->properties[$key] = encode($number);
108 108
     }
109 109
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      *	@param	string	$suffix			Suffix
142 142
      *	@return	void
143 143
      */
144
-    function setName($family="", $first="", $additional="", $prefix="", $suffix="")
144
+    function setName($family = "", $first = "", $additional = "", $prefix = "", $suffix = "")
145 145
     {
146 146
         $this->properties["N;CHARSET=".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix);
147 147
         $this->filename = "$first%20$family.vcf";
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
      *	@param	string	$type			Type
174 174
      *	@return	void
175 175
      */
176
-    function setAddress($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME;POSTAL")
176
+    function setAddress($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL")
177 177
     {
178 178
         // $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL"
179 179
         $key = "ADR";
180
-        if ($type!="") $key.= ";$type";
181
-        $key.= ";CHARSET=".$this->encoding;
180
+        if ($type != "") $key .= ";$type";
181
+        $key .= ";CHARSET=".$this->encoding;
182 182
         $this->properties[$key] = ";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country);
183 183
 
184 184
         if ($this->properties["LABEL;$type;CHARSET=".$this->encoding] == "")
@@ -200,15 +200,15 @@  discard block
 block discarded – undo
200 200
      *	@param	string	$type			Type
201 201
      *	@return	void
202 202
      */
203
-    function setLabel($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME;POSTAL") {
203
+    function setLabel($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") {
204 204
         $label = "";
205
-        if ($postoffice!="") $label.= "$postoffice\r\n";
206
-        if ($extended!="") $label.= "$extended\r\n";
207
-        if ($street!="") $label.= "$street\r\n";
208
-        if ($zip!="") $label.= "$zip ";
209
-        if ($city!="") $label.= "$city\r\n";
210
-        if ($region!="") $label.= "$region\r\n";
211
-        if ($country!="") $country.= "$country\r\n";
205
+        if ($postoffice != "") $label .= "$postoffice\r\n";
206
+        if ($extended != "") $label .= "$extended\r\n";
207
+        if ($street != "") $label .= "$street\r\n";
208
+        if ($zip != "") $label .= "$zip ";
209
+        if ($city != "") $label .= "$city\r\n";
210
+        if ($region != "") $label .= "$region\r\n";
211
+        if ($country != "") $country .= "$country\r\n";
212 212
 
213 213
         $this->properties["LABEL;$type;CHARSET=".$this->encoding] = encode($label);
214 214
     }
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
      *	@param	string	$type			Vcard type
221 221
      *	@return	void
222 222
      */
223
-    function setEmail($address,$type="internet,pref")
223
+    function setEmail($address, $type = "internet,pref")
224 224
     {
225 225
         $this->properties["EMAIL;TYPE=".$type] = $address;
226 226
     }
@@ -291,11 +291,11 @@  discard block
 block discarded – undo
291 291
      *  @param	string	$type		Type
292 292
      *	@return	void
293 293
      */
294
-    function setURL($url, $type="")
294
+    function setURL($url, $type = "")
295 295
     {
296 296
         // $type may be WORK | HOME
297 297
         $key = "URL";
298
-        if ($type!="") $key.= ";$type";
298
+        if ($type != "") $key .= ";$type";
299 299
         $this->properties[$key] = $url;
300 300
     }
301 301
 
@@ -308,14 +308,14 @@  discard block
 block discarded – undo
308 308
     {
309 309
         $text = "BEGIN:VCARD\r\n";
310 310
         //$text.= "VERSION:3.0\r\n";
311
-        $text.= "VERSION:2.1\r\n";
312
-        foreach($this->properties as $key => $value)
311
+        $text .= "VERSION:2.1\r\n";
312
+        foreach ($this->properties as $key => $value)
313 313
         {
314
-            $text.= "$key:$value\r\n";
314
+            $text .= "$key:$value\r\n";
315 315
         }
316
-        $text.= "REV:".date("Y-m-d")."T".date("H:i:s")."Z\r\n";
317
-        $text.= "MAILER: Dolibarr\r\n";
318
-        $text.= "END:VCARD\r\n";
316
+        $text .= "REV:".date("Y-m-d")."T".date("H:i:s")."Z\r\n";
317
+        $text .= "MAILER: Dolibarr\r\n";
318
+        $text .= "END:VCARD\r\n";
319 319
         return $text;
320 320
     }
321 321
 
Please login to merge, or discard this patch.
Braces   +36 added lines, -12 removed lines patch added patch discarded remove patch
@@ -73,7 +73,9 @@  discard block
 block discarded – undo
73 73
             $newline .= $c;
74 74
         } // end of for
75 75
         $output .= $newline;
76
-        if ($j<count($lines)-1) $output .= $linebreak;
76
+        if ($j<count($lines)-1) {
77
+        	$output .= $linebreak;
78
+        }
77 79
     }
78 80
     return trim($output);
79 81
 }
@@ -102,7 +104,9 @@  discard block
 block discarded – undo
102 104
     {
103 105
         // type may be PREF | WORK | HOME | VOICE | FAX | MSG | CELL | PAGER | BBS | CAR | MODEM | ISDN | VIDEO or any senseful combination, e.g. "PREF;WORK;VOICE"
104 106
         $key = "TEL";
105
-        if ($type!="") $key .= ";".$type;
107
+        if ($type!="") {
108
+        	$key .= ";".$type;
109
+        }
106 110
         $key.= ";CHARSET=".$this->encoding;
107 111
         $this->properties[$key] = encode($number);
108 112
     }
@@ -145,7 +149,9 @@  discard block
 block discarded – undo
145 149
     {
146 150
         $this->properties["N;CHARSET=".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix);
147 151
         $this->filename = "$first%20$family.vcf";
148
-        if (empty($this->properties["FN"])) $this->setFormattedName(trim("$prefix $first $additional $family $suffix"));
152
+        if (empty($this->properties["FN"])) {
153
+        	$this->setFormattedName(trim("$prefix $first $additional $family $suffix"));
154
+        }
149 155
     }
150 156
 
151 157
     /**
@@ -177,7 +183,9 @@  discard block
 block discarded – undo
177 183
     {
178 184
         // $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL"
179 185
         $key = "ADR";
180
-        if ($type!="") $key.= ";$type";
186
+        if ($type!="") {
187
+        	$key.= ";$type";
188
+        }
181 189
         $key.= ";CHARSET=".$this->encoding;
182 190
         $this->properties[$key] = ";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country);
183 191
 
@@ -202,13 +210,27 @@  discard block
 block discarded – undo
202 210
      */
203 211
     function setLabel($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME;POSTAL") {
204 212
         $label = "";
205
-        if ($postoffice!="") $label.= "$postoffice\r\n";
206
-        if ($extended!="") $label.= "$extended\r\n";
207
-        if ($street!="") $label.= "$street\r\n";
208
-        if ($zip!="") $label.= "$zip ";
209
-        if ($city!="") $label.= "$city\r\n";
210
-        if ($region!="") $label.= "$region\r\n";
211
-        if ($country!="") $country.= "$country\r\n";
213
+        if ($postoffice!="") {
214
+        	$label.= "$postoffice\r\n";
215
+        }
216
+        if ($extended!="") {
217
+        	$label.= "$extended\r\n";
218
+        }
219
+        if ($street!="") {
220
+        	$label.= "$street\r\n";
221
+        }
222
+        if ($zip!="") {
223
+        	$label.= "$zip ";
224
+        }
225
+        if ($city!="") {
226
+        	$label.= "$city\r\n";
227
+        }
228
+        if ($region!="") {
229
+        	$label.= "$region\r\n";
230
+        }
231
+        if ($country!="") {
232
+        	$country.= "$country\r\n";
233
+        }
212 234
 
213 235
         $this->properties["LABEL;$type;CHARSET=".$this->encoding] = encode($label);
214 236
     }
@@ -295,7 +317,9 @@  discard block
 block discarded – undo
295 317
     {
296 318
         // $type may be WORK | HOME
297 319
         $key = "URL";
298
-        if ($type!="") $key.= ";$type";
320
+        if ($type!="") {
321
+        	$key.= ";$type";
322
+        }
299 323
         $this->properties[$key] = $url;
300 324
     }
301 325
 
Please login to merge, or discard this patch.