Passed
Pull Request — master (#2)
by
unknown
26:19
created
dolibarr/htdocs/core/lib/memory.lib.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
  *  \brief		Set of function for memory/cache management
22 22
  */
23 23
 
24
-global $shmkeys,$shmoffset;
24
+global $shmkeys, $shmoffset;
25 25
 
26
-$shmkeys=array('main'=>1,'admin'=>2,'dict'=>3,'companies'=>4,'suppliers'=>5,'products'=>6,
27
-				'commercial'=>7,'compta'=>8,'projects'=>9,'cashdesk'=>10,'agenda'=>11,'bills'=>12,
28
-				'propal'=>13,'boxes'=>14,'banks'=>15,'other'=>16,'errors'=>17,'members'=>18,'ecm'=>19,
29
-				'orders'=>20,'users'=>21,'help'=>22,'stocks'=>23,'interventions'=>24,
30
-				'donations'=>25,'contracts'=>26);
31
-$shmoffset=1000;	// Max number of entries found into a language file. If too low, some entries will be overwritten.
26
+$shmkeys = array('main'=>1, 'admin'=>2, 'dict'=>3, 'companies'=>4, 'suppliers'=>5, 'products'=>6,
27
+				'commercial'=>7, 'compta'=>8, 'projects'=>9, 'cashdesk'=>10, 'agenda'=>11, 'bills'=>12,
28
+				'propal'=>13, 'boxes'=>14, 'banks'=>15, 'other'=>16, 'errors'=>17, 'members'=>18, 'ecm'=>19,
29
+				'orders'=>20, 'users'=>21, 'help'=>22, 'stocks'=>23, 'interventions'=>24,
30
+				'donations'=>25, 'contracts'=>26);
31
+$shmoffset = 1000; // Max number of entries found into a language file. If too low, some entries will be overwritten.
32 32
 
33 33
 
34 34
 
@@ -39,27 +39,27 @@  discard block
 block discarded – undo
39 39
  * 	@param	string		$data			Data to save
40 40
  * 	@return	int							<0 if KO, Nb of bytes written if OK
41 41
  */
42
-function dol_setcache($memoryid,$data)
42
+function dol_setcache($memoryid, $data)
43 43
 {
44 44
 	global $conf;
45
-	$result=0;
45
+	$result = 0;
46 46
 
47 47
 	// Using a memcached server
48
-	if (! empty($conf->memcached->enabled) && class_exists('Memcached'))
48
+	if (!empty($conf->memcached->enabled) && class_exists('Memcached'))
49 49
 	{
50 50
 	    global $dolmemcache;
51
-		if (empty($dolmemcache) || ! is_object($dolmemcache))
51
+		if (empty($dolmemcache) || !is_object($dolmemcache))
52 52
     	{
53
-       	    $dolmemcache=new Memcached();
54
-       		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
55
-       		$result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
56
-       		if (! $result) return -1;
53
+       	    $dolmemcache = new Memcached();
54
+       		$tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
55
+       		$result = $dolmemcache->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
56
+       		if (!$result) return -1;
57 57
        	}
58 58
        	
59
-	    $memoryid=session_name().'_'.$memoryid;
59
+	    $memoryid = session_name().'_'.$memoryid;
60 60
 		//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
61
-		$dolmemcache->add($memoryid,$data);    // This fails if key already exists
62
-		$rescode=$dolmemcache->getResultCode();
61
+		$dolmemcache->add($memoryid, $data); // This fails if key already exists
62
+		$rescode = $dolmemcache->getResultCode();
63 63
 		if ($rescode == 0)
64 64
 		{
65 65
 			return count($data);
@@ -69,20 +69,20 @@  discard block
 block discarded – undo
69 69
 			return -$rescode;
70 70
 		}
71 71
 	}
72
-	else if (! empty($conf->memcached->enabled) && class_exists('Memcache'))
72
+	else if (!empty($conf->memcached->enabled) && class_exists('Memcache'))
73 73
 	{
74 74
 		global $dolmemcache;
75
-		if (empty($dolmemcache) || ! is_object($dolmemcache))
75
+		if (empty($dolmemcache) || !is_object($dolmemcache))
76 76
     	{
77
-       	    $dolmemcache=new Memcache();
78
-       		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
79
-       		$result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
80
-       		if (! $result) return -1;
77
+       	    $dolmemcache = new Memcache();
78
+       		$tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
79
+       		$result = $dolmemcache->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
80
+       		if (!$result) return -1;
81 81
        	}
82 82
 	    
83
-       	$memoryid=session_name().'_'.$memoryid;
83
+       	$memoryid = session_name().'_'.$memoryid;
84 84
 		//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
85
-		$result=$dolmemcache->add($memoryid,$data);    // This fails if key already exists
85
+		$result = $dolmemcache->add($memoryid, $data); // This fails if key already exists
86 86
 		if ($result)
87 87
 		{
88 88
 			return count($data);
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	// Using shmop
96 96
 	else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
97 97
 	{
98
-		$result=dol_setshmop($memoryid,$data);
98
+		$result = dol_setshmop($memoryid, $data);
99 99
 	}
100 100
 
101 101
 	return $result;
@@ -112,22 +112,22 @@  discard block
 block discarded – undo
112 112
 	global $conf;
113 113
 
114 114
 	// Using a memcached server
115
-	if (! empty($conf->memcached->enabled) && class_exists('Memcached'))
115
+	if (!empty($conf->memcached->enabled) && class_exists('Memcached'))
116 116
 	{
117 117
 		global $m;
118
-		if (empty($m) || ! is_object($m))
118
+		if (empty($m) || !is_object($m))
119 119
     	{
120
-            $m=new Memcached();
121
-       		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
122
-       		$result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
123
-       		if (! $result) return -1;
120
+            $m = new Memcached();
121
+       		$tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
122
+       		$result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
123
+       		if (!$result) return -1;
124 124
        	}
125 125
 	    
126
-		$memoryid=session_name().'_'.$memoryid;
126
+		$memoryid = session_name().'_'.$memoryid;
127 127
 		//$m->setOption(Memcached::OPT_COMPRESSION, false);
128 128
 		//print "Get memoryid=".$memoryid;
129
-		$data=$m->get($memoryid);
130
-		$rescode=$m->getResultCode();
129
+		$data = $m->get($memoryid);
130
+		$rescode = $m->getResultCode();
131 131
 		//print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n<br>";
132 132
 		//var_dump($data);
133 133
 		if ($rescode == 0)
@@ -139,20 +139,20 @@  discard block
 block discarded – undo
139 139
 			return -$rescode;
140 140
 		}
141 141
 	}
142
-	else if (! empty($conf->memcached->enabled) && class_exists('Memcache'))
142
+	else if (!empty($conf->memcached->enabled) && class_exists('Memcache'))
143 143
 	{
144 144
 		global $m;
145
-		if (empty($m) || ! is_object($m))
145
+		if (empty($m) || !is_object($m))
146 146
     	{
147
-       	    $m=new Memcache();
148
-       		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
149
-       		$result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
150
-       		if (! $result) return -1;
147
+       	    $m = new Memcache();
148
+       		$tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
149
+       		$result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
150
+       		if (!$result) return -1;
151 151
        	}
152 152
 	    
153
-       	$memoryid=session_name().'_'.$memoryid;
153
+       	$memoryid = session_name().'_'.$memoryid;
154 154
 		//$m->setOption(Memcached::OPT_COMPRESSION, false);
155
-		$data=$m->get($memoryid);
155
+		$data = $m->get($memoryid);
156 156
 		//print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n<br>";
157 157
 		//var_dump($data);
158 158
 		if ($data)
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	// Using shmop
168 168
 	else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
169 169
 	{
170
-		$data=dol_getshmop($memoryid);
170
+		$data = dol_getshmop($memoryid);
171 171
 		return $data;
172 172
 	}
173 173
 
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
  */
185 185
 function dol_getshmopaddress($memoryid)
186 186
 {
187
-	global $shmkeys,$shmoffset;
187
+	global $shmkeys, $shmoffset;
188 188
 	if (empty($shmkeys[$memoryid])) return 0;
189
-	return $shmkeys[$memoryid]+$shmoffset;
189
+	return $shmkeys[$memoryid] + $shmoffset;
190 190
 }
191 191
 
192 192
 /**
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
  */
197 197
 function dol_listshmop()
198 198
 {
199
-	global $shmkeys,$shmoffset;
199
+	global $shmkeys, $shmoffset;
200 200
 
201
-	$resarray=array();
202
-	foreach($shmkeys as $key => $val)
201
+	$resarray = array();
202
+	foreach ($shmkeys as $key => $val)
203 203
 	{
204
-		$result=dol_getshmop($key);
205
-		if (! is_numeric($result) || $result > 0) $resarray[$key]=$result;
204
+		$result = dol_getshmop($key);
205
+		if (!is_numeric($result) || $result > 0) $resarray[$key] = $result;
206 206
 	}
207 207
 	return $resarray;
208 208
 }
@@ -214,27 +214,27 @@  discard block
 block discarded – undo
214 214
  * 	@param	string	$data			Data to save
215 215
  * 	@return	int						<0 if KO, Nb of bytes written if OK
216 216
  */
217
-function dol_setshmop($memoryid,$data)
217
+function dol_setshmop($memoryid, $data)
218 218
 {
219
-	global $shmkeys,$shmoffset;
219
+	global $shmkeys, $shmoffset;
220 220
 
221 221
 	//print 'dol_setshmop memoryid='.$memoryid."<br>\n";
222
-	if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_write")) return 0;
223
-	$shmkey=dol_getshmopaddress($memoryid);
224
-	$newdata=serialize($data);
225
-	$size=strlen($newdata);
222
+	if (empty($shmkeys[$memoryid]) || !function_exists("shmop_write")) return 0;
223
+	$shmkey = dol_getshmopaddress($memoryid);
224
+	$newdata = serialize($data);
225
+	$size = strlen($newdata);
226 226
 	//print 'dol_setshmop memoryid='.$memoryid." shmkey=".$shmkey." newdata=".$size."bytes<br>\n";
227
-	$handle=shmop_open($shmkey,'c',0644,6+$size);
227
+	$handle = shmop_open($shmkey, 'c', 0644, 6 + $size);
228 228
 	if ($handle)
229 229
 	{
230
-		$shm_bytes_written1=shmop_write($handle,str_pad($size,6),0);
231
-		$shm_bytes_written2=shmop_write($handle,$newdata,6);
232
-		if (($shm_bytes_written1 + $shm_bytes_written2) != (6+dol_strlen($newdata)))
230
+		$shm_bytes_written1 = shmop_write($handle, str_pad($size, 6), 0);
231
+		$shm_bytes_written2 = shmop_write($handle, $newdata, 6);
232
+		if (($shm_bytes_written1 + $shm_bytes_written2) != (6 + dol_strlen($newdata)))
233 233
 		{
234 234
    			print "Couldn't write the entire length of data\n";
235 235
 		}
236 236
 		shmop_close($handle);
237
-		return ($shm_bytes_written1+$shm_bytes_written2);
237
+		return ($shm_bytes_written1 + $shm_bytes_written2);
238 238
 	}
239 239
 	else
240 240
 	{
@@ -251,16 +251,16 @@  discard block
 block discarded – undo
251 251
  */
252 252
 function dol_getshmop($memoryid)
253 253
 {
254
-	global $shmkeys,$shmoffset;
254
+	global $shmkeys, $shmoffset;
255 255
 
256
-	if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) return 0;
257
-	$shmkey=dol_getshmopaddress($memoryid);
256
+	if (empty($shmkeys[$memoryid]) || !function_exists("shmop_open")) return 0;
257
+	$shmkey = dol_getshmopaddress($memoryid);
258 258
 	//print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey."<br>\n";
259
-	$handle=@shmop_open($shmkey,'a',0,0);
259
+	$handle = @shmop_open($shmkey, 'a', 0, 0);
260 260
 	if ($handle)
261 261
 	{
262
-		$size=trim(shmop_read($handle,0,6));
263
-		if ($size) $data=unserialize(shmop_read($handle,6,$size));
262
+		$size = trim(shmop_read($handle, 0, 6));
263
+		if ($size) $data = unserialize(shmop_read($handle, 6, $size));
264 264
 		else return -1;
265 265
 		shmop_close($handle);
266 266
 	}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/xcal.lib.php 1 patch
Spacing   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -32,66 +32,66 @@  discard block
 block discarded – undo
32 32
  *	@param		string	$outputfile			Output file
33 33
  *	@return		int							<0 if ko, Nb of events in file if ok
34 34
  */
35
-function build_calfile($format,$title,$desc,$events_array,$outputfile)
35
+function build_calfile($format, $title, $desc, $events_array, $outputfile)
36 36
 {
37
-	global $conf,$langs;
37
+	global $conf, $langs;
38 38
 
39 39
 	dol_syslog("xcal.lib.php::build_calfile Build cal file ".$outputfile." to format ".$format);
40 40
 
41 41
 	if (empty($outputfile)) return -1;
42 42
 
43 43
     // Note: A cal file is an UTF8 encoded file
44
-	$calfileh=fopen($outputfile,'w');
44
+	$calfileh = fopen($outputfile, 'w');
45 45
 	if ($calfileh)
46 46
 	{
47 47
 	    include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
48
-		$now=dol_now();
48
+		$now = dol_now();
49 49
 
50
-		$encoding='';
51
-		if ($format == 'vcal') $encoding='ENCODING=QUOTED-PRINTABLE:';
50
+		$encoding = '';
51
+		if ($format == 'vcal') $encoding = 'ENCODING=QUOTED-PRINTABLE:';
52 52
 
53 53
 		// Print header
54
-		fwrite($calfileh,"BEGIN:VCALENDAR\n");
55
-		fwrite($calfileh,"VERSION:2.0\n");
56
-		fwrite($calfileh,"METHOD:PUBLISH\n");
54
+		fwrite($calfileh, "BEGIN:VCALENDAR\n");
55
+		fwrite($calfileh, "VERSION:2.0\n");
56
+		fwrite($calfileh, "METHOD:PUBLISH\n");
57 57
 		//fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."//EN\n");
58
-		fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."\n");
59
-		fwrite($calfileh,"CALSCALE:GREGORIAN\n");
60
-		fwrite($calfileh,"X-WR-CALNAME:".$encoding.format_cal($format,$title)."\n");
61
-        fwrite($calfileh,"X-WR-CALDESC:".$encoding.format_cal($format,$desc)."\n");
58
+		fwrite($calfileh, "PRODID:-//DOLIBARR ".DOL_VERSION."\n");
59
+		fwrite($calfileh, "CALSCALE:GREGORIAN\n");
60
+		fwrite($calfileh, "X-WR-CALNAME:".$encoding.format_cal($format, $title)."\n");
61
+        fwrite($calfileh, "X-WR-CALDESC:".$encoding.format_cal($format, $desc)."\n");
62 62
         //fwrite($calfileh,"X-WR-TIMEZONE:Europe/Paris\n");
63
-        if (! empty($conf->global->MAIN_AGENDA_EXPORT_CACHE)
64
-        && $conf->global->MAIN_AGENDA_EXPORT_CACHE > 60){
65
-	        $hh=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'hour');
66
-	        $mm=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'min');
67
-	        $ss=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'sec');
68
-	        fwrite($calfileh,"X-PUBLISHED-TTL: P".$hh."H".$mm."M".$ss."S\n");
63
+        if (!empty($conf->global->MAIN_AGENDA_EXPORT_CACHE)
64
+        && $conf->global->MAIN_AGENDA_EXPORT_CACHE > 60) {
65
+	        $hh = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, 'hour');
66
+	        $mm = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, 'min');
67
+	        $ss = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, 'sec');
68
+	        fwrite($calfileh, "X-PUBLISHED-TTL: P".$hh."H".$mm."M".$ss."S\n");
69 69
         }
70 70
 
71 71
 		foreach ($events_array as $key => $event)
72 72
 		{
73
-			$eventqualified=true;
73
+			$eventqualified = true;
74 74
 			if ($eventqualified)
75 75
 			{
76 76
 				// See http://fr.wikipedia.org/wiki/ICalendar for format
77 77
 				// See http://www.ietf.org/rfc/rfc2445.txt for RFC
78
-				$uid 		  = $event['uid'];
79
-				$type         = $event['type'];
80
-                $startdate    = $event['startdate'];
78
+				$uid = $event['uid'];
79
+				$type = $event['type'];
80
+                $startdate = $event['startdate'];
81 81
 				$duration	  = $event['duration'];
82
-				$enddate	  = $event['enddate'];
83
-				$summary  	  = $event['summary'];
82
+				$enddate = $event['enddate'];
83
+				$summary = $event['summary'];
84 84
 				$category	  = $event['category'];
85 85
                 $priority     = $event['priority'];
86 86
                 $fulldayevent = $event['fulldayevent'];
87 87
 				$location     = $event['location'];
88
-				$email 		  = $event['email'];
89
-				$url		  = $event['url'];
90
-				$transparency = $event['transparency'];		// OPAQUE (busy) or TRANSPARENT (not busy)
91
-				$description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']);
92
- 				$description=dol_string_nohtmltag($description,0);	// Remove html tags
93
-                $created      = $event['created'];
94
- 				$modified     = $event['modified'];
88
+				$email = $event['email'];
89
+				$url = $event['url'];
90
+				$transparency = $event['transparency']; // OPAQUE (busy) or TRANSPARENT (not busy)
91
+				$description = preg_replace('/<br[\s\/]?>/i', "\n", $event['desc']);
92
+ 				$description = dol_string_nohtmltag($description, 0); // Remove html tags
93
+                $created = $event['created'];
94
+ 				$modified = $event['modified'];
95 95
 
96 96
 				// Uncomment for tests
97 97
 				//$summary="Resume";
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
 				//$description="MemberValidatedInDolibarr gd gdf gd gdff\nNom: tgdf g dfgdf gfd r ter\nType: gdfgfdf dfg fd gfd gd gdf gdf gfd gdfg dfg ddf\nAuteur: AD01fg dgdgdfg df gdf gd";
100 100
 
101 101
 				// Format
102
-				$summary=format_cal($format,$summary);
103
-				$description=format_cal($format,$description);
104
-				$category=format_cal($format,$category);
105
-				$location=format_cal($format,$location);
102
+				$summary = format_cal($format, $summary);
103
+				$description = format_cal($format, $description);
104
+				$category = format_cal($format, $category);
105
+				$location = format_cal($format, $location);
106 106
 
107 107
 				// Output the vCard/iCal VEVENT object
108 108
 				/*
@@ -140,22 +140,22 @@  discard block
 block discarded – undo
140 140
                 */
141 141
 				if ($type == 'event')
142 142
 				{
143
-					fwrite($calfileh,"BEGIN:VEVENT\n");
144
-					fwrite($calfileh,"UID:".$uid."\n");
145
-					if (! empty($email))
143
+					fwrite($calfileh, "BEGIN:VEVENT\n");
144
+					fwrite($calfileh, "UID:".$uid."\n");
145
+					if (!empty($email))
146 146
 					{
147
-						fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n");
148
-						fwrite($calfileh,"CONTACT:MAILTO:".$email."\n");
147
+						fwrite($calfileh, "ORGANIZER:MAILTO:".$email."\n");
148
+						fwrite($calfileh, "CONTACT:MAILTO:".$email."\n");
149 149
 					}
150
-					if (! empty($url))
150
+					if (!empty($url))
151 151
 					{
152
-						fwrite($calfileh,"URL:".$url."\n");
152
+						fwrite($calfileh, "URL:".$url."\n");
153 153
 					};
154 154
 
155
-                    if ($created)  fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n");
156
-                    if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n");
157
-                    fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n");
158
-					fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n");
155
+                    if ($created)  fwrite($calfileh, "CREATED:".dol_print_date($created, 'dayhourxcard', true)."\n");
156
+                    if ($modified) fwrite($calfileh, "LAST-MODIFIED:".dol_print_date($modified, 'dayhourxcard', true)."\n");
157
+                    fwrite($calfileh, "SUMMARY:".$encoding.$summary."\n");
158
+					fwrite($calfileh, "DESCRIPTION:".$encoding.$description."\n");
159 159
 
160 160
 					/* Other keys:
161 161
 					// Status values for a "VEVENT"
@@ -178,44 +178,44 @@  discard block
 block discarded – undo
178 178
                     //fwrite($calfileh,"X-MICROSOFT-CDO-BUSYSTATUS:1\n");
179 179
                     //ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=Laurent Destailleur;X-NUM-GUESTS=0:mailto:[email protected]
180 180
 
181
-                    if (! empty($location)) fwrite($calfileh,"LOCATION:".$encoding.$location."\n");
182
-					if ($fulldayevent) fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n");
183
-                    if ($fulldayevent) fwrite($calfileh,"X-MICROSOFT-CDO-ALLDAYEVENT:1\n");
181
+                    if (!empty($location)) fwrite($calfileh, "LOCATION:".$encoding.$location."\n");
182
+					if ($fulldayevent) fwrite($calfileh, "X-FUNAMBOL-ALLDAY:1\n");
183
+                    if ($fulldayevent) fwrite($calfileh, "X-MICROSOFT-CDO-ALLDAYEVENT:1\n");
184 184
 
185 185
 					// Date must be GMT dates
186 186
 					// Current date
187
-					fwrite($calfileh,"DTSTAMP:".dol_print_date($now,'dayhourxcard',true)."\n");
187
+					fwrite($calfileh, "DTSTAMP:".dol_print_date($now, 'dayhourxcard', true)."\n");
188 188
 					// Start date
189
-                    $prefix='';
190
-                    $startdatef = dol_print_date($startdate,'dayhourxcard',true);
189
+                    $prefix = '';
190
+                    $startdatef = dol_print_date($startdate, 'dayhourxcard', true);
191 191
                     if ($fulldayevent)
192 192
 					{
193
-                        $prefix=';VALUE=DATE';
194
-					    $startdatef = dol_print_date($startdate,'dayxcard',false);     // Local time
193
+                        $prefix = ';VALUE=DATE';
194
+					    $startdatef = dol_print_date($startdate, 'dayxcard', false); // Local time
195 195
 					}
196
-					fwrite($calfileh,"DTSTART".$prefix.":".$startdatef."\n");
196
+					fwrite($calfileh, "DTSTART".$prefix.":".$startdatef."\n");
197 197
                     // End date
198 198
 					if ($fulldayevent)
199 199
 					{
200
-    					if (empty($enddate)) $enddate=dol_time_plus_duree($startdate,1,'d');
200
+    					if (empty($enddate)) $enddate = dol_time_plus_duree($startdate, 1, 'd');
201 201
 					}
202 202
 					else
203 203
 					{
204
-                        if (empty($enddate)) $enddate=$startdate+$duration;
204
+                        if (empty($enddate)) $enddate = $startdate + $duration;
205 205
 					}
206
-                    $prefix='';
207
-					$enddatef = dol_print_date($enddate,'dayhourxcard',true);
206
+                    $prefix = '';
207
+					$enddatef = dol_print_date($enddate, 'dayhourxcard', true);
208 208
 					if ($fulldayevent)
209 209
 					{
210
-                        $prefix=';VALUE=DATE';
211
-					    $enddatef = dol_print_date($enddate+1,'dayxcard',false);
210
+                        $prefix = ';VALUE=DATE';
211
+					    $enddatef = dol_print_date($enddate + 1, 'dayxcard', false);
212 212
 					    //$enddatef .= dol_print_date($enddate+1,'dayhourxcard',false);   // Local time
213 213
 					}
214
-                    fwrite($calfileh,"DTEND".$prefix.":".$enddatef."\n");
215
-					fwrite($calfileh,'STATUS:CONFIRMED'."\n");
216
-					if (! empty($transparency)) fwrite($calfileh,"TRANSP:".$transparency."\n");
217
-					if (! empty($category)) fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n");
218
-					fwrite($calfileh,"END:VEVENT\n");
214
+                    fwrite($calfileh, "DTEND".$prefix.":".$enddatef."\n");
215
+					fwrite($calfileh, 'STATUS:CONFIRMED'."\n");
216
+					if (!empty($transparency)) fwrite($calfileh, "TRANSP:".$transparency."\n");
217
+					if (!empty($category)) fwrite($calfileh, "CATEGORIES:".$encoding.$category."\n");
218
+					fwrite($calfileh, "END:VEVENT\n");
219 219
 				}
220 220
 
221 221
 				// Output the vCard/iCal VTODO object
@@ -225,30 +225,30 @@  discard block
 block discarded – undo
225 225
 				// Output the vCard/iCal VJOURNAL object
226 226
 				if ($type == 'journal')
227 227
 				{
228
-					fwrite($calfileh,"BEGIN:VJOURNAL\n");
229
-					fwrite($calfileh,"UID:".$uid."\n");
230
-					if (! empty($email))
228
+					fwrite($calfileh, "BEGIN:VJOURNAL\n");
229
+					fwrite($calfileh, "UID:".$uid."\n");
230
+					if (!empty($email))
231 231
 					{
232
-						fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n");
233
-						fwrite($calfileh,"CONTACT:MAILTO:".$email."\n");
232
+						fwrite($calfileh, "ORGANIZER:MAILTO:".$email."\n");
233
+						fwrite($calfileh, "CONTACT:MAILTO:".$email."\n");
234 234
 					}
235
-					if (! empty($url))
235
+					if (!empty($url))
236 236
 					{
237
-						fwrite($calfileh,"URL:".$url."\n");
237
+						fwrite($calfileh, "URL:".$url."\n");
238 238
 					};
239 239
 
240
-                    if ($created)  fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n");
241
-                    if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n");
242
-					fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n");
243
-					fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n");
244
-					fwrite($calfileh,'STATUS:CONFIRMED'."\n");
245
-					fwrite($calfileh,"CATEGORIES:".$category."\n");
246
-					fwrite($calfileh,"LOCATION:".$location."\n");
247
-					fwrite($calfileh,"TRANSP:OPAQUE\n");
248
-					fwrite($calfileh,"CLASS:CONFIDENTIAL\n");
249
-					fwrite($calfileh,"DTSTAMP:".dol_print_date($startdatef,'dayhourxcard',true)."\n");
250
-
251
-					fwrite($calfileh,"END:VJOURNAL\n");
240
+                    if ($created)  fwrite($calfileh, "CREATED:".dol_print_date($created, 'dayhourxcard', true)."\n");
241
+                    if ($modified) fwrite($calfileh, "LAST-MODIFIED:".dol_print_date($modified, 'dayhourxcard', true)."\n");
242
+					fwrite($calfileh, "SUMMARY:".$encoding.$summary."\n");
243
+					fwrite($calfileh, "DESCRIPTION:".$encoding.$description."\n");
244
+					fwrite($calfileh, 'STATUS:CONFIRMED'."\n");
245
+					fwrite($calfileh, "CATEGORIES:".$category."\n");
246
+					fwrite($calfileh, "LOCATION:".$location."\n");
247
+					fwrite($calfileh, "TRANSP:OPAQUE\n");
248
+					fwrite($calfileh, "CLASS:CONFIDENTIAL\n");
249
+					fwrite($calfileh, "DTSTAMP:".dol_print_date($startdatef, 'dayhourxcard', true)."\n");
250
+
251
+					fwrite($calfileh, "END:VJOURNAL\n");
252 252
 				}
253 253
 
254 254
 
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
 		}
268 268
 
269 269
 		// Footer
270
-		fwrite($calfileh,"END:VCALENDAR");
270
+		fwrite($calfileh, "END:VCALENDAR");
271 271
 
272 272
 		fclose($calfileh);
273
-		if (! empty($conf->global->MAIN_UMASK))
273
+		if (!empty($conf->global->MAIN_UMASK))
274 274
 			@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
275 275
 	}
276 276
 	else
@@ -292,43 +292,43 @@  discard block
 block discarded – undo
292 292
  *	@param		string	$filter				Filter
293 293
  *	@return		int							<0 if ko, Nb of events in file if ok
294 294
  */
295
-function build_rssfile($format,$title,$desc,$events_array,$outputfile,$filter='')
295
+function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = '')
296 296
 {
297
-	global $user,$conf,$langs;
297
+	global $user, $conf, $langs;
298 298
 	global $dolibarr_main_url_root;
299 299
 
300 300
 	dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format);
301 301
 
302 302
 	if (empty($outputfile)) return -1;
303 303
 
304
-	$fichier=fopen($outputfile,'w');
304
+	$fichier = fopen($outputfile, 'w');
305 305
 	if ($fichier)
306 306
 	{
307
-		$date=date("r");
307
+		$date = date("r");
308 308
 
309 309
 		// Print header
310
-		$form='<?xml version="1.0" encoding="'.$langs->charset_output.'"?>';
310
+		$form = '<?xml version="1.0" encoding="'.$langs->charset_output.'"?>';
311 311
 		fwrite($fichier, $form);
312 312
 		fwrite($fichier, "\n");
313
-		$form='<rss version="2.0">';
313
+		$form = '<rss version="2.0">';
314 314
 		fwrite($fichier, $form);
315 315
 		fwrite($fichier, "\n");
316 316
 
317
-		$form="<channel>\n<title>".$title."</title>\n";
317
+		$form = "<channel>\n<title>".$title."</title>\n";
318 318
 		fwrite($fichier, $form);
319 319
 
320
-		$form='<description><![CDATA['.$desc.'.]]></description>'."\n".
320
+		$form = '<description><![CDATA['.$desc.'.]]></description>'."\n".
321 321
 //		'<language>fr</language>'."\n".
322 322
 		'<copyright>Dolibarr</copyright>'."\n".
323 323
 		'<lastBuildDate>'.$date.'</lastBuildDate>'."\n".
324 324
 		'<generator>Dolibarr</generator>'."\n";
325 325
 
326 326
 		// Define $urlwithroot
327
-		$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
328
-		$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;			// This is to use external domain name found into config file
327
+		$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
328
+		$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
329 329
 		//$urlwithroot=DOL_MAIN_URL_ROOT;						// This is to use same domain name than current
330
-  		$url=$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY);
331
-		$form.='<link><![CDATA['.$url.']]></link>'."\n";
330
+  		$url = $urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY);
331
+		$form .= '<link><![CDATA['.$url.']]></link>'."\n";
332 332
 
333 333
 		//print $form;
334 334
 		fwrite($fichier, $form);
@@ -336,12 +336,12 @@  discard block
 block discarded – undo
336 336
 
337 337
 		foreach ($events_array as $key => $event)
338 338
 		{
339
-			$eventqualified=true;
339
+			$eventqualified = true;
340 340
 			if ($filter)
341 341
 			{
342 342
 				// TODO Add a filter
343 343
 
344
-				$eventqualified=false;
344
+				$eventqualified = false;
345 345
 			}
346 346
 
347 347
 			if ($eventqualified)
@@ -350,16 +350,16 @@  discard block
 block discarded – undo
350 350
 				$startdate	  = $event['startdate'];
351 351
 				$summary  	  = $event['summary'];
352 352
 				$url		  = $event['url'];
353
-				$author		  = $event['author'];
354
-				$category	  = $event['category'];
353
+				$author = $event['author'];
354
+				$category = $event['category'];
355 355
 				/* No place inside a RSS
356 356
                 $priority     = $event['priority'];
357 357
                 $fulldayevent = $event['fulldayevent'];
358 358
                 $location     = $event['location'];
359 359
                 $email        = $event['email'];
360 360
                 */
361
-				$description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']);
362
- 				$description=dol_string_nohtmltag($description,0);	// Remove html tags
361
+				$description = preg_replace('/<br[\s\/]?>/i', "\n", $event['desc']);
362
+ 				$description = dol_string_nohtmltag($description, 0); // Remove html tags
363 363
 
364 364
 				fwrite($fichier, "<item>\n");
365 365
 				fwrite($fichier, "<title><![CDATA[".$summary."]]></title>\n");
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 		fwrite($fichier, '</rss>');
383 383
 
384 384
 		fclose($fichier);
385
-		if (! empty($conf->global->MAIN_UMASK))
385
+		if (!empty($conf->global->MAIN_UMASK))
386 386
 			@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
387 387
 	}
388 388
 }
@@ -395,24 +395,24 @@  discard block
 block discarded – undo
395 395
  * 	@param 		string	$string		string to encode
396 396
  * 	@return		string				string encoded
397 397
  */
398
-function format_cal($format,$string)
398
+function format_cal($format, $string)
399 399
 {
400 400
 	global $conf;
401 401
 
402
-	$newstring=$string;
402
+	$newstring = $string;
403 403
 
404 404
 	if ($format == 'vcal')
405 405
 	{
406
-		$newstring=quotedPrintEncode($newstring);
406
+		$newstring = quotedPrintEncode($newstring);
407 407
 	}
408 408
 	if ($format == 'ical')
409 409
 	{
410 410
 		// Replace new lines chars by '\n'
411
-		$newstring=preg_replace('/'."\r\n".'/i',"\n",$newstring);
412
-		$newstring=preg_replace('/'."\n\r".'/i',"\n",$newstring);
413
-		$newstring=preg_replace('/'."\n".'/i','\n',$newstring);
411
+		$newstring = preg_replace('/'."\r\n".'/i', "\n", $newstring);
412
+		$newstring = preg_replace('/'."\n\r".'/i', "\n", $newstring);
413
+		$newstring = preg_replace('/'."\n".'/i', '\n', $newstring);
414 414
 		// Must not exceed 75 char. Cut with "\r\n"+Space
415
-		$newstring=calEncode($newstring);
415
+		$newstring = calEncode($newstring);
416 416
 	}
417 417
 
418 418
 	return $newstring;
@@ -434,14 +434,14 @@  discard block
 block discarded – undo
434 434
 	// If mb_ functions exists, it's better to use them
435 435
 	if (function_exists('mb_strlen'))
436 436
 	{
437
-	    $strlength=mb_strlen($line, 'UTF-8');
437
+	    $strlength = mb_strlen($line, 'UTF-8');
438 438
 		for ($j = 0; $j <= ($strlength - 1); $j++)
439 439
 		{
440
-			$char = mb_substr($line, $j, 1, 'UTF-8');	// Take char at position $j
440
+			$char = mb_substr($line, $j, 1, 'UTF-8'); // Take char at position $j
441 441
 
442 442
 			if ((mb_strlen($newpara, 'UTF-8') + mb_strlen($char, 'UTF-8')) >= 75)
443 443
 			{
444
-				$out .= $newpara . "\r\n ";	// CRLF + Space for cal
444
+				$out .= $newpara."\r\n "; // CRLF + Space for cal
445 445
 				$newpara = '';
446 446
 			}
447 447
 			$newpara .= $char;
@@ -450,14 +450,14 @@  discard block
 block discarded – undo
450 450
 	}
451 451
 	else
452 452
 	{
453
-	    $strlength=dol_strlen($line);
453
+	    $strlength = dol_strlen($line);
454 454
 		for ($j = 0; $j <= ($strlength - 1); $j++)
455 455
 		{
456
-			$char = substr($line, $j, 1);	// Take char at position $j
456
+			$char = substr($line, $j, 1); // Take char at position $j
457 457
 
458
-			if ((dol_strlen($newpara) + dol_strlen($char)) >= 75 )
458
+			if ((dol_strlen($newpara) + dol_strlen($char)) >= 75)
459 459
 			{
460
-				$out .= $newpara . "\r\n ";	// CRLF + Space for cal
460
+				$out .= $newpara."\r\n "; // CRLF + Space for cal
461 461
 				$newpara = '';
462 462
 			}
463 463
 			$newpara .= $char;
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
  *	@param		int		$forcal		1=For cal
477 477
  *	@return		string 				String converted
478 478
  */
479
-function quotedPrintEncode($str,$forcal=0)
479
+function quotedPrintEncode($str, $forcal = 0)
480 480
 {
481 481
 	$lines = preg_split("/\r\n/", $str);
482 482
 	$out = '';
@@ -485,19 +485,19 @@  discard block
 block discarded – undo
485 485
 	{
486 486
 		$newpara = '';
487 487
 
488
-		$strlength=strlen($line);	// Do not use dol_strlen here, we need number of bytes
488
+		$strlength = strlen($line); // Do not use dol_strlen here, we need number of bytes
489 489
 		for ($j = 0; $j <= ($strlength - 1); $j++)
490 490
 		{
491 491
 			$char = substr($line, $j, 1);
492 492
 			$ascii = ord($char);
493 493
 
494
-			if ( $ascii < 32 || $ascii == 61 || $ascii > 126 )
495
-			$char = '=' . strtoupper(sprintf("%02X", $ascii));
494
+			if ($ascii < 32 || $ascii == 61 || $ascii > 126)
495
+			$char = '='.strtoupper(sprintf("%02X", $ascii));
496 496
 
497
-			if ((strlen($newpara) + strlen($char)) >= 76 )	// Do not use dol_strlen here, we need number of bytes
497
+			if ((strlen($newpara) + strlen($char)) >= 76)	// Do not use dol_strlen here, we need number of bytes
498 498
 			{
499
-				$out .= $newpara . '=' . "\r\n";	// CRLF
500
-				if ($forcal) $out .= " ";		// + Space for cal
499
+				$out .= $newpara.'='."\r\n"; // CRLF
500
+				if ($forcal) $out .= " "; // + Space for cal
501 501
 				$newpara = '';
502 502
 			}
503 503
 			$newpara .= $char;
@@ -516,6 +516,6 @@  discard block
 block discarded – undo
516 516
 function quotedPrintDecode($str)
517 517
 {
518 518
 	$out = preg_replace('/=\r?\n/', '', $str);
519
-	$out = quoted_printable_decode($out);	// Available with PHP 4+
519
+	$out = quoted_printable_decode($out); // Available with PHP 4+
520 520
 	return trim($out);
521 521
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/cron.lib.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -87,18 +87,18 @@  discard block
 block discarded – undo
87 87
 	global $dolibarr_main_url_root;
88 88
 
89 89
 	// Define $urlwithroot
90
-	$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
91
-	$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
90
+	$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
91
+	$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
92 92
 	//$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
93 93
 
94 94
 	// Cron launch
95 95
 	print '<div class="div-table-responsive-no-min">';
96 96
 	print '<u>'.$langs->trans("URLToLaunchCronJobs").':</u><br>';
97
-	$url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login;
98
-	print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
97
+	$url = $urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login;
98
+	print img_picto('', 'object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
99 99
 	print ' '.$langs->trans("OrToLaunchASpecificJob").'<br>';
100
-	$url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid';
101
-	print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
100
+	$url = $urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid';
101
+	print img_picto('', 'object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
102 102
     print '</div>';
103 103
     print '<br>';
104 104
     
@@ -107,22 +107,22 @@  discard block
 block discarded – undo
107 107
 	
108 108
 	print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>';
109 109
 
110
-	$file='/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' [cronjobid]';
110
+	$file = '/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY) ? 'securitykey' : ''.$conf->global->CRON_KEY.'').' '.$logintouse.' [cronjobid]';
111 111
 	print '<textarea class="quatrevingtpercent">..'.$file."</textarea><br>\n";
112 112
 	print '<br>';
113 113
 
114 114
 	// Add note
115 115
 	if (empty($conf->global->CRON_DISABLE_TUTORIAL_CRON))
116 116
 	{
117
-    	$linuxlike=1;
118
-    	if (preg_match('/^win/i',PHP_OS)) $linuxlike=0;
119
-    	if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0;
117
+    	$linuxlike = 1;
118
+    	if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0;
119
+    	if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0;
120 120
     	print $langs->trans("Note").': ';
121 121
     	if ($linuxlike)
122 122
     	{
123 123
     		print $langs->trans("CronExplainHowToRunUnix");
124 124
     		print '<br>';
125
-    		print '<textarea class="quatrevingtpercent">*/5 * * * * pathtoscript/scripts/cron/cron_run_jobs.php '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' &gt; '.DOL_DATA_ROOT.'/cron_run_jobs.php.log</textarea><br>';
125
+    		print '<textarea class="quatrevingtpercent">*/5 * * * * pathtoscript/scripts/cron/cron_run_jobs.php '.(empty($conf->global->CRON_KEY) ? 'securitykey' : ''.$conf->global->CRON_KEY.'').' '.$logintouse.' &gt; '.DOL_DATA_ROOT.'/cron_run_jobs.php.log</textarea><br>';
126 126
     	}
127 127
     	else
128 128
     	{
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/report.lib.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
  *  @param  string              $varlink        Add a variable into the address of the page
39 39
  *	@return	void
40 40
  */
41
-function report_header($reportname,$notused,$period,$periodlink,$description,$builddate,$exportlink='',$moreparam=array(),$calcmode='', $varlink='')
41
+function report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink = '', $moreparam = array(), $calcmode = '', $varlink = '')
42 42
 {
43 43
 	global $langs;
44 44
 
45
-	if (empty($hselected)) $hselected='report';
45
+	if (empty($hselected)) $hselected = 'report';
46 46
 
47 47
 	print "\n\n<!-- start banner of report -->\n";
48 48
 
49
-	if(! empty($varlink)) $varlink = '?'.$varlink;
49
+	if (!empty($varlink)) $varlink = '?'.$varlink;
50 50
 
51
-	$h=0;
51
+	$h = 0;
52 52
 	$head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
53 53
 	$head[$h][1] = $langs->trans("Report");
54 54
 	$head[$h][2] = 'report';
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
 	dol_fiche_head($head, 'report');
59 59
 
60
-	foreach($moreparam as $key => $value)
60
+	foreach ($moreparam as $key => $value)
61 61
 	{
62 62
 		 print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
63 63
 	}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/actions_sendmails.inc.php 1 patch
Spacing   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -32,66 +32,66 @@  discard block
 block discarded – undo
32 32
 /*
33 33
  * Add file in email form
34 34
  */
35
-if (GETPOST('addfile','alpha'))
35
+if (GETPOST('addfile', 'alpha'))
36 36
 {
37
-	$trackid = GETPOST('trackid','aZ09');
37
+	$trackid = GETPOST('trackid', 'aZ09');
38 38
 
39 39
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
40 40
 
41 41
 	// Set tmp user directory
42
-	$vardir=$conf->user->dir_output."/".$user->id;
43
-	$upload_dir_tmp = $vardir.'/temp';             // TODO Add $keytoavoidconflict in upload_dir path
42
+	$vardir = $conf->user->dir_output."/".$user->id;
43
+	$upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path
44 44
 
45 45
 	dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, $trackid, 0);
46
-	$action='presend';
46
+	$action = 'presend';
47 47
 }
48 48
 
49 49
 /*
50 50
  * Remove file in email form
51 51
  */
52
-if (! empty($_POST['removedfile']) && empty($_POST['removAll']))
52
+if (!empty($_POST['removedfile']) && empty($_POST['removAll']))
53 53
 {
54
-	$trackid = GETPOST('trackid','aZ09');
54
+	$trackid = GETPOST('trackid', 'aZ09');
55 55
 
56 56
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
57 57
 
58 58
 	// Set tmp user directory
59
-	$vardir=$conf->user->dir_output."/".$user->id;
60
-	$upload_dir_tmp = $vardir.'/temp';             // TODO Add $keytoavoidconflict in upload_dir path
59
+	$vardir = $conf->user->dir_output."/".$user->id;
60
+	$upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path
61 61
 
62 62
 	// TODO Delete only files that was uploaded from email form. This can be addressed by adding the trackid into the temp path then changing donotdeletefile to 2 instead of 1 to say "delete only if into temp dir"
63 63
 	// GETPOST('removedfile','alpha') is position of file into $_SESSION["listofpaths"...] array.
64
-	dol_remove_file_process(GETPOST('removedfile','alpha'), 0, 1, $trackid);   // We do not delete because if file is the official PDF of doc, we don't want to remove it physically
65
-	$action='presend';
64
+	dol_remove_file_process(GETPOST('removedfile', 'alpha'), 0, 1, $trackid); // We do not delete because if file is the official PDF of doc, we don't want to remove it physically
65
+	$action = 'presend';
66 66
 }
67 67
 
68 68
 /*
69 69
  * Remove all files in email form
70 70
  */
71
-if (GETPOST('removAll','alpha'))
71
+if (GETPOST('removAll', 'alpha'))
72 72
 {
73
-	$trackid = GETPOST('trackid','aZ09');
73
+	$trackid = GETPOST('trackid', 'aZ09');
74 74
 
75
-	$listofpaths=array();
76
-	$listofnames=array();
77
-	$listofmimes=array();
78
-	$keytoavoidconflict = empty($trackid)?'':'-'.$trackid;
79
-	if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
80
-	if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
81
-	if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
75
+	$listofpaths = array();
76
+	$listofnames = array();
77
+	$listofmimes = array();
78
+	$keytoavoidconflict = empty($trackid) ? '' : '-'.$trackid;
79
+	if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
80
+	if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
81
+	if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
82 82
 
83 83
 	include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
84 84
 	$formmail = new FormMail($db);
85 85
 	$formmail->trackid = $trackid;
86 86
 
87
-	foreach($listofpaths as $key => $value)
87
+	foreach ($listofpaths as $key => $value)
88 88
 	{
89 89
 		$pathtodelete = $value;
90 90
 		$filetodelete = $listofnames[$key];
91
-		$result = dol_delete_file($pathtodelete,1); // Delete uploded Files
91
+		$result = dol_delete_file($pathtodelete, 1); // Delete uploded Files
92 92
 
93 93
 		$langs->load("other");
94
-		setEventMessages($langs->trans("FileWasRemoved",$filetodelete), null, 'mesgs');
94
+		setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs');
95 95
 
96 96
 		$formmail->remove_attached_files($key); // Update Session
97 97
 	}
@@ -100,76 +100,76 @@  discard block
 block discarded – undo
100 100
 /*
101 101
  * Send mail
102 102
  */
103
-if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removAll'] && ! $_POST['removedfile'] && ! $_POST['cancel'] && !$_POST['modelselected'])
103
+if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST['removAll'] && !$_POST['removedfile'] && !$_POST['cancel'] && !$_POST['modelselected'])
104 104
 {
105
-	if (empty($trackid)) $trackid = GETPOST('trackid','aZ09');
105
+	if (empty($trackid)) $trackid = GETPOST('trackid', 'aZ09');
106 106
 
107
-	$subject='';$actionmsg='';$actionmsg2='';
107
+	$subject = ''; $actionmsg = ''; $actionmsg2 = '';
108 108
 
109 109
 	$langs->load('mails');
110 110
 
111 111
 	if (is_object($object))
112 112
 	{
113
-		$result=$object->fetch($id);
113
+		$result = $object->fetch($id);
114 114
 
115
-		$sendtosocid=0;    // Thirdparty on object
116
-		if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member','user','expensereport', 'contact')))
115
+		$sendtosocid = 0; // Thirdparty on object
116
+		if (method_exists($object, "fetch_thirdparty") && !in_array($object->element, array('societe', 'member', 'user', 'expensereport', 'contact')))
117 117
 		{
118
-			$result=$object->fetch_thirdparty();
119
-			if ($object->element == 'user' && $result == 0) $result=1;    // Even if not found, we consider ok
120
-			$thirdparty=$object->thirdparty;
121
-			$sendtosocid=$thirdparty->id;
118
+			$result = $object->fetch_thirdparty();
119
+			if ($object->element == 'user' && $result == 0) $result = 1; // Even if not found, we consider ok
120
+			$thirdparty = $object->thirdparty;
121
+			$sendtosocid = $thirdparty->id;
122 122
 		}
123 123
 		else if ($object->element == 'member' || $object->element == 'user')
124 124
 		{
125
-			$thirdparty=$object;
126
-			if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id;
125
+			$thirdparty = $object;
126
+			if ($thirdparty->id > 0) $sendtosocid = $thirdparty->id;
127 127
 		}
128 128
 		else if ($object->element == 'societe')
129 129
 		{
130
-			$thirdparty=$object;
131
-			if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id;
130
+			$thirdparty = $object;
131
+			if ($thirdparty->id > 0) $sendtosocid = $thirdparty->id;
132 132
 		}
133 133
 		else if ($object->element == 'contact')
134 134
 		{
135
-			$contact=$object;
136
-			if ($contact->id > 0) $sendtosocid=$contact->fetch_thirdparty()->id;
135
+			$contact = $object;
136
+			if ($contact->id > 0) $sendtosocid = $contact->fetch_thirdparty()->id;
137 137
 		}
138
-		else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported');
138
+		else dol_print_error('', 'Use actions_sendmails.in.php for an element/object that is not supported');
139 139
 
140 140
 		if (is_object($hookmanager))
141 141
 		{
142
-			$parameters=array();
143
-			$reshook=$hookmanager->executeHooks('initSendToSocid',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
142
+			$parameters = array();
143
+			$reshook = $hookmanager->executeHooks('initSendToSocid', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
144 144
 		}
145 145
 	}
146 146
 	else $thirdparty = $mysoc;
147 147
 
148 148
 	if ($result > 0)
149 149
 	{
150
-		$sendto='';
151
-		$sendtocc='';
152
-		$sendtobcc='';
150
+		$sendto = '';
151
+		$sendtocc = '';
152
+		$sendtobcc = '';
153 153
 		$sendtoid = array();
154
-		$sendtouserid=array();
155
-		$sendtoccuserid=array();
154
+		$sendtouserid = array();
155
+		$sendtoccuserid = array();
156 156
 
157 157
 		// Define $sendto
158
-		$receiver=$_POST['receiver'];
159
-		if (! is_array($receiver))
158
+		$receiver = $_POST['receiver'];
159
+		if (!is_array($receiver))
160 160
 		{
161
-			if ($receiver == '-1') $receiver=array();
162
-			else $receiver=array($receiver);
161
+			if ($receiver == '-1') $receiver = array();
162
+			else $receiver = array($receiver);
163 163
 		}
164
-		$tmparray=array();
164
+		$tmparray = array();
165 165
 		if (trim($_POST['sendto']))
166 166
 		{
167 167
 			// Recipients are provided into free text
168 168
 			$tmparray[] = trim($_POST['sendto']);
169 169
 		}
170
-		if (count($receiver)>0)
170
+		if (count($receiver) > 0)
171 171
 		{
172
-			foreach($receiver as $key=>$val)
172
+			foreach ($receiver as $key=>$val)
173 173
 			{
174 174
 				// Recipient was provided from combo list
175 175
 				if ($val == 'thirdparty') // Id of third party
@@ -183,42 +183,42 @@  discard block
 block discarded – undo
183 183
 				}
184 184
 				elseif ($val)	// Id du contact
185 185
 				{
186
-					$tmparray[] = $thirdparty->contact_get_property((int) $val,'email');
186
+					$tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
187 187
 					$sendtoid[] = $val;
188 188
 				}
189 189
 			}
190 190
 		}
191 191
 		if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
192 192
 		{
193
-			$receiveruser=$_POST['receiveruser'];
194
-			if (is_array($receiveruser) && count($receiveruser)>0)
193
+			$receiveruser = $_POST['receiveruser'];
194
+			if (is_array($receiveruser) && count($receiveruser) > 0)
195 195
 			{
196 196
 				$fuserdest = new User($db);
197
-				foreach($receiveruser as $key=>$val)
197
+				foreach ($receiveruser as $key=>$val)
198 198
 				{
199
-					$tmparray[] = $fuserdest->user_get_property($val,'email');
199
+					$tmparray[] = $fuserdest->user_get_property($val, 'email');
200 200
 					$sendtouserid[] = $val;
201 201
 				}
202 202
 			}
203 203
 		}
204 204
 
205
-		$sendto=implode(',',$tmparray);
205
+		$sendto = implode(',', $tmparray);
206 206
 
207 207
 		// Define $sendtocc
208
-		$receivercc=$_POST['receivercc'];
209
-		if (! is_array($receivercc))
208
+		$receivercc = $_POST['receivercc'];
209
+		if (!is_array($receivercc))
210 210
 		{
211
-			if ($receivercc == '-1') $receivercc=array();
212
-			else $receivercc=array($receivercc);
211
+			if ($receivercc == '-1') $receivercc = array();
212
+			else $receivercc = array($receivercc);
213 213
 		}
214
-		$tmparray=array();
214
+		$tmparray = array();
215 215
 		if (trim($_POST['sendtocc']))
216 216
 		{
217 217
 			$tmparray[] = trim($_POST['sendtocc']);
218 218
 		}
219 219
 		if (count($receivercc) > 0)
220 220
 		{
221
-			foreach($receivercc as $key=>$val)
221
+			foreach ($receivercc as $key=>$val)
222 222
 			{
223 223
 				// Recipient was provided from combo list
224 224
 				if ($val == 'thirdparty') // Id of third party
@@ -232,57 +232,57 @@  discard block
 block discarded – undo
232 232
 				}
233 233
 				elseif ($val)	// Id du contact
234 234
 				{
235
-					$tmparray[] = $thirdparty->contact_get_property((int) $val,'email');
235
+					$tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
236 236
 					//$sendtoid[] = $val;  TODO Add also id of contact in CC ?
237 237
 				}
238 238
 			}
239 239
 		}
240 240
 		if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
241
-			$receiverccuser=$_POST['receiverccuser'];
241
+			$receiverccuser = $_POST['receiverccuser'];
242 242
 
243
-			if (is_array($receiverccuser) && count($receiverccuser)>0)
243
+			if (is_array($receiverccuser) && count($receiverccuser) > 0)
244 244
 			{
245 245
 				$fuserdest = new User($db);
246
-				foreach($receiverccuser as $key=>$val)
246
+				foreach ($receiverccuser as $key=>$val)
247 247
 				{
248
-					$tmparray[] = $fuserdest->user_get_property($val,'email');
248
+					$tmparray[] = $fuserdest->user_get_property($val, 'email');
249 249
 					$sendtoccuserid[] = $val;
250 250
 				}
251 251
 			}
252 252
 		}
253
-		$sendtocc=implode(',',$tmparray);
253
+		$sendtocc = implode(',', $tmparray);
254 254
 
255 255
 		if (dol_strlen($sendto))
256 256
 		{
257 257
             // Define $urlwithroot
258
-            $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
259
-            $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
258
+            $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
259
+            $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
260 260
             //$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
261 261
 
262 262
 		    require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
263 263
 
264 264
 			$langs->load("commercial");
265 265
 
266
-			$fromtype = GETPOST('fromtype','alpha');
266
+			$fromtype = GETPOST('fromtype', 'alpha');
267 267
 			if ($fromtype === 'robot') {
268
-				$from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")) .' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>';
268
+				$from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")).' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>';
269 269
 			}
270 270
 			elseif ($fromtype === 'user') {
271
-				$from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")) .' <'.$user->email.'>';
271
+				$from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")).' <'.$user->email.'>';
272 272
 			}
273 273
 			elseif ($fromtype === 'company') {
274
-				$from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")) .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
274
+				$from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
275 275
 			}
276 276
 			elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) {
277
-				$tmp=explode(',', $user->email_aliases);
277
+				$tmp = explode(',', $user->email_aliases);
278 278
 				$from = trim($tmp[($reg[1] - 1)]);
279 279
 			}
280 280
 			elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) {
281
-				$tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
281
+				$tmp = explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
282 282
 				$from = trim($tmp[($reg[1] - 1)]);
283 283
 			}
284 284
 			elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
285
-				$sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1];
285
+				$sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1];
286 286
 				$resql = $db->query($sql);
287 287
 				$obj = $db->fetch_object($resql);
288 288
 				if ($obj)
@@ -291,39 +291,39 @@  discard block
 block discarded – undo
291 291
 				}
292 292
 			}
293 293
 			else {
294
-				$from = dol_string_nospecial($_POST['fromname'], ' ', array(",")) . ' <' . $_POST['frommail'] .'>';
294
+				$from = dol_string_nospecial($_POST['fromname'], ' ', array(",")).' <'.$_POST['frommail'].'>';
295 295
 			}
296 296
 
297
-			$replyto = dol_string_nospecial($_POST['replytoname'], ' ', array(",")). ' <' . $_POST['replytomail'].'>';
298
-			$message = GETPOST('message','none');
299
-			$subject = GETPOST('subject','none');
297
+			$replyto = dol_string_nospecial($_POST['replytoname'], ' ', array(",")).' <'.$_POST['replytomail'].'>';
298
+			$message = GETPOST('message', 'none');
299
+			$subject = GETPOST('subject', 'none');
300 300
 
301 301
 			// Make a change into HTML code to allow to include images from medias directory with an external reabable URL.
302 302
 			// <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
303 303
 			// become
304 304
 			// <img alt="" src="'.$urlwithroot.'viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
305
-			$message=preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message);
305
+			$message = preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message);
306 306
 
307
-			$sendtobcc= GETPOST('sendtoccc');
307
+			$sendtobcc = GETPOST('sendtoccc');
308 308
 			// Autocomplete the $sendtobcc
309 309
 			// $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO...
310
-			if (! empty($autocopy))
310
+			if (!empty($autocopy))
311 311
 			{
312
-				$sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc?", ":"").$conf->global->$autocopy));
312
+				$sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc ? ", " : "").$conf->global->$autocopy));
313 313
 			}
314 314
 
315 315
 			$deliveryreceipt = $_POST['deliveryreceipt'];
316 316
 
317 317
 			if ($action == 'send' || $action == 'relance')
318 318
 			{
319
-				$actionmsg2=$langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from,4,0,1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto,4,0,1);
319
+				$actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto, 4, 0, 1);
320 320
 				if ($message)
321 321
 				{
322
-					$actionmsg=$langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
323
-					$actionmsg=dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
324
-					if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc));
325
-					$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
326
-					$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
322
+					$actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
323
+					$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
324
+					if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc));
325
+					$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject);
326
+					$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":");
327 327
 					$actionmsg = dol_concatdesc($actionmsg, $message);
328 328
 				}
329 329
 			}
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
 			// Create form object
332 332
 			include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
333 333
 			$formmail = new FormMail($db);
334
-			$formmail->trackid = $trackid;      // $trackid must be defined
334
+			$formmail->trackid = $trackid; // $trackid must be defined
335 335
 
336
-			$attachedfiles=$formmail->get_attached_files();
336
+			$attachedfiles = $formmail->get_attached_files();
337 337
 			$filepath = $attachedfiles['paths'];
338 338
 			$filename = $attachedfiles['names'];
339 339
 			$mimetype = $attachedfiles['mimes'];
@@ -383,15 +383,15 @@  discard block
 block discarded – undo
383 383
 			*/
384 384
 
385 385
 			// Make substitution in email content
386
-			$substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object);
386
+			$substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object);
387 387
 			$substitutionarray['__EMAIL__'] = $sendto;
388
-			$substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty))?'<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>':'';
388
+			$substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '';
389 389
 
390
-			$parameters=array('mode'=>'formemail');
390
+			$parameters = array('mode'=>'formemail');
391 391
 			complete_substitutions_array($substitutionarray, $langs, $object, $parameters);
392 392
 
393
-			$subject=make_substitutions($subject, $substitutionarray);
394
-			$message=make_substitutions($message, $substitutionarray);
393
+			$subject = make_substitutions($subject, $substitutionarray);
394
+			$message = make_substitutions($message, $substitutionarray);
395 395
 
396 396
 			if (method_exists($object, 'makeSubstitution'))
397 397
 			{
@@ -401,16 +401,16 @@  discard block
 block discarded – undo
401 401
 
402 402
 			// Send mail (substitutionarray must be done just before this)
403 403
 			if (empty($sendcontext)) $sendcontext = 'standard';
404
-			$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid,'', $sendcontext);
404
+			$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext);
405 405
 
406 406
 			if ($mailfile->error)
407 407
 			{
408 408
 				setEventMessages($mailfile->error, $mailfile->errors, 'errors');
409
-				$action='presend';
409
+				$action = 'presend';
410 410
 			}
411 411
 			else
412 412
 			{
413
-				$result=$mailfile->sendfile();
413
+				$result = $mailfile->sendfile();
414 414
 				if ($result)
415 415
 				{
416 416
 					// Two hooks are available into method $mailfile->sendfile, so dedicated code is no more required
@@ -437,25 +437,25 @@  discard block
 block discarded – undo
437 437
 					// Initialisation of datas of object to call trigger
438 438
 					if (is_object($object))
439 439
 					{
440
-					    if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically
440
+					    if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
441 441
 
442
-						$object->socid			= $sendtosocid;	   // To link to a company
443
-						$object->sendtoid		= $sendtoid;	   // To link to contact addresses. This is an array.
444
-						$object->actiontypecode	= $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
445
-						$object->actionmsg		= $actionmsg;      // Long text (@TODO Replace this with $message, we already have details of email in dedicated properties)
446
-						$object->actionmsg2		= $actionmsg2;     // Short text ($langs->transnoentities('MailSentBy')...);
442
+						$object->socid = $sendtosocid; // To link to a company
443
+						$object->sendtoid = $sendtoid; // To link to contact addresses. This is an array.
444
+						$object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
445
+						$object->actionmsg = $actionmsg; // Long text (@TODO Replace this with $message, we already have details of email in dedicated properties)
446
+						$object->actionmsg2		= $actionmsg2; // Short text ($langs->transnoentities('MailSentBy')...);
447 447
 
448
-						$object->trackid        = $trackid;
448
+						$object->trackid = $trackid;
449 449
 						$object->fk_element		= $object->id;
450 450
 						$object->elementtype	= $object->element;
451
-						if (is_array($attachedfiles) && count($attachedfiles)>0) {
452
-							$object->attachedfiles	= $attachedfiles;
451
+						if (is_array($attachedfiles) && count($attachedfiles) > 0) {
452
+							$object->attachedfiles = $attachedfiles;
453 453
 						}
454
-						if (is_array($sendtouserid) && count($sendtouserid)>0 && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
455
-							$object->sendtouserid	= $sendtouserid;
454
+						if (is_array($sendtouserid) && count($sendtouserid) > 0 && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
455
+							$object->sendtouserid = $sendtouserid;
456 456
 						}
457 457
 
458
-						$object->email_msgid = $mailfile->msgid;	// @TODO Set msgid into $mailfile after sending
458
+						$object->email_msgid = $mailfile->msgid; // @TODO Set msgid into $mailfile after sending
459 459
 						$object->email_from = $from;
460 460
 						$object->email_subject = $subject;
461 461
 						$object->email_to = $sendto;
@@ -465,11 +465,11 @@  discard block
 block discarded – undo
465 465
 						$object->email_msgid = $mailfile->msgid;
466 466
 
467 467
 						// Call of triggers
468
-						if (! empty($trigger_name))
468
+						if (!empty($trigger_name))
469 469
 						{
470
-    						include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
471
-    						$interface=new Interfaces($db);
472
-    						$result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf);
470
+    						include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
471
+    						$interface = new Interfaces($db);
472
+    						$result = $interface->run_triggers($trigger_name, $object, $user, $langs, $conf);
473 473
 							if ($result < 0) {
474 474
     							setEventMessages($interface->error, $interface->errors, 'errors');
475 475
     						}
@@ -478,28 +478,28 @@  discard block
 block discarded – undo
478 478
 
479 479
 					// Redirect here
480 480
 					// This avoid sending mail twice if going out and then back to page
481
-					$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
481
+					$mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2));
482 482
 					setEventMessages($mesg, null, 'mesgs');
483 483
 
484
-  					$moreparam='';
485
-	  				if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2;
486
-		  			header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam);
484
+  					$moreparam = '';
485
+	  				if (isset($paramname2) || isset($paramval2)) $moreparam .= '&'.($paramname2 ? $paramname2 : 'mid').'='.$paramval2;
486
+		  			header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ? $paramname : 'id').'='.(is_object($object) ? $object->id : '').$moreparam);
487 487
 			  		exit;
488 488
 				}
489 489
 				else
490 490
 				{
491 491
 					$langs->load("other");
492
-					$mesg='<div class="error">';
492
+					$mesg = '<div class="error">';
493 493
 					if ($mailfile->error)
494 494
 					{
495
-						$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
496
-						$mesg.='<br>'.$mailfile->error;
495
+						$mesg .= $langs->trans('ErrorFailedToSendMail', $from, $sendto);
496
+						$mesg .= '<br>'.$mailfile->error;
497 497
 					}
498 498
 					else
499 499
 					{
500
-						$mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
500
+						$mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
501 501
 					}
502
-					$mesg.='</div>';
502
+					$mesg .= '</div>';
503 503
 
504 504
 					setEventMessages($mesg, null, 'warnings');
505 505
 					$action = 'presend';
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 		else
510 510
 		{
511 511
 			$langs->load("errors");
512
-			setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("MailTo")), null, 'warnings');
512
+			setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("MailTo")), null, 'warnings');
513 513
 			dol_syslog('Try to send email with no recipient defined', LOG_WARNING);
514 514
 			$action = 'presend';
515 515
 		}
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 	else
518 518
 	{
519 519
 		$langs->load("other");
520
-		setEventMessages($langs->trans('ErrorFailedToReadObject',$object->element), null, 'errors');
520
+		setEventMessages($langs->trans('ErrorFailedToReadObject', $object->element), null, 'errors');
521 521
 		dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element);
522 522
 		$action = 'presend';
523 523
 	}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/tpl/resource_view.tpl.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@  discard block
 block discarded – undo
1 1
 <!-- BEGIN TEMPLATE resource_view.tpl.php -->
2 2
 <?php
3 3
 // Protection to avoid direct call of template
4
-if (empty($conf) || ! is_object($conf))
4
+if (empty($conf) || !is_object($conf))
5 5
 {
6 6
 	print "Error, template page can't be called as URL";
7 7
 	exit;
8 8
 }
9 9
 
10 10
 
11
-$form= new Form($db);
11
+$form = new Form($db);
12 12
 
13 13
 
14 14
 print '<div class="tagtable centpercent noborder allwidth">';
15 15
 
16
-if($mode == 'edit' )
16
+if ($mode == 'edit')
17 17
 {
18 18
     print '<form class="tagtr liste_titre">';
19 19
     print '<div class="tagtd liste_titre">'.$langs->trans('Resource').'</div>';
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
     print '</form>';
35 35
 }
36 36
 
37
-if( (array) $linked_resources && count($linked_resources) > 0)
37
+if ((array) $linked_resources && count($linked_resources) > 0)
38 38
 {
39 39
 
40 40
 	foreach ($linked_resources as $linked_resource)
41 41
 	{
42 42
 
43
-		$object_resource = fetchObjectByElement($linked_resource['resource_id'],$linked_resource['resource_type']);
43
+		$object_resource = fetchObjectByElement($linked_resource['resource_id'], $linked_resource['resource_type']);
44 44
 
45 45
 		//$element_id = $linked_resource['rowid'];
46 46
 
@@ -56,16 +56,16 @@  discard block
 block discarded – undo
56 56
 
57 57
 			print '<div class="tagtd">'.$object_resource->getNomUrl(1).'</div>';
58 58
 			print '<div class="tagtd">'.$object_resource->type_label.'</div>';
59
-			print '<div class="tagtd" align="center">'.$form->selectyesno('busy',$linked_resource['busy']?1:0,1).'</div>';
60
-			print '<div class="tagtd" align="center">'.$form->selectyesno('mandatory',$linked_resource['mandatory']?1:0,1).'</div>';
59
+			print '<div class="tagtd" align="center">'.$form->selectyesno('busy', $linked_resource['busy'] ? 1 : 0, 1).'</div>';
60
+			print '<div class="tagtd" align="center">'.$form->selectyesno('mandatory', $linked_resource['mandatory'] ? 1 : 0, 1).'</div>';
61 61
 			print '<div class="tagtd" align="right"><input type="submit" class="button" value="'.$langs->trans("Update").'"></div>';
62 62
 			print '</form>';
63 63
 		}
64 64
 		else
65 65
 		{
66
-			$style='';
66
+			$style = '';
67 67
 			if ($linked_resource['rowid'] == GETPOST('lineid'))
68
-				$style='style="background: orange;"';
68
+				$style = 'style="background: orange;"';
69 69
 
70 70
 			print '<form class="tagtr oddeven" '.$style.'>';
71 71
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/tpl/commonfields_edit.tpl.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
  */
23 23
 
24 24
 // Protection to avoid direct call of template
25
-if (empty($conf) || ! is_object($conf))
25
+if (empty($conf) || !is_object($conf))
26 26
 {
27 27
 	print "Error, template page can't be called as URL";
28 28
 	exit;
29 29
 }
30
-if (! is_object($form)) $form=new Form($db);
30
+if (!is_object($form)) $form = new Form($db);
31 31
 
32 32
 ?>
33 33
 <!-- BEGIN PHP TEMPLATE commonfields_edit.tpl.php -->
@@ -35,25 +35,25 @@  discard block
 block discarded – undo
35 35
 
36 36
 $object->fields = dol_sort_array($object->fields, 'position');
37 37
 
38
-foreach($object->fields as $key => $val)
38
+foreach ($object->fields as $key => $val)
39 39
 {
40 40
 	// Discard if extrafield is a hidden field on form
41 41
 	if (abs($val['visible']) != 1) continue;
42 42
 
43
-	if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! verifCond($val['enabled'])) continue;	// We don't want this field
43
+	if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) continue; // We don't want this field
44 44
 
45 45
 	print '<tr><td';
46 46
 	print ' class="titlefieldcreate';
47 47
 	if ($val['notnull'] > 0) print ' fieldrequired';
48 48
 	if ($val['type'] == 'text' || $val['type'] == 'html') print ' tdtop';
49 49
 	print '">';
50
-	if (! empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $val['help']);
50
+	if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $val['help']);
51 51
 	else print $langs->trans($val['label']);
52 52
 	print '</td>';
53 53
 	print '<td>';
54
-	if (in_array($val['type'], array('int', 'integer'))) $value = GETPOSTISSET($key)?GETPOST($key, 'int'):$object->$key;
55
-	elseif ($val['type'] == 'text' || $val['type'] == 'html') $value = GETPOSTISSET($key)?GETPOST($key,'none'):$object->$key;
56
-	else $value = GETPOSTISSET($key)?GETPOST($key, 'alpha'):$object->$key;
54
+	if (in_array($val['type'], array('int', 'integer'))) $value = GETPOSTISSET($key) ?GETPOST($key, 'int') : $object->$key;
55
+	elseif ($val['type'] == 'text' || $val['type'] == 'html') $value = GETPOSTISSET($key) ?GETPOST($key, 'none') : $object->$key;
56
+	else $value = GETPOSTISSET($key) ?GETPOST($key, 'alpha') : $object->$key;
57 57
 	//var_dump($val.' '.$key.' '.$value);
58 58
 	print $object->showInputField($val, $key, $value, '', '', '', 0);
59 59
 	print '</td>';
Please login to merge, or discard this patch.
dolibarr/htdocs/core/tpl/object_discounts.tpl.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -29,47 +29,47 @@  discard block
 block discarded – undo
29 29
 $isNewObject = empty($object->id) && empty($object->rowid);
30 30
 
31 31
 // Relative and absolute discounts
32
-$addrelativediscount = '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $thirdparty->id . '&backtopage=' . $backtopage . '">' . $langs->trans("EditRelativeDiscount") . '</a>';
33
-$addabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $thirdparty->id . '&backtopage=' . $backtopage . '">' . $langs->trans("EditGlobalDiscounts") . '</a>';
34
-$viewabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $thirdparty->id . '&backtopage=' . $backtopage . '">' . $langs->trans("ViewAvailableGlobalDiscounts") . '</a>';
32
+$addrelativediscount = '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$thirdparty->id.'&backtopage='.$backtopage.'">'.$langs->trans("EditRelativeDiscount").'</a>';
33
+$addabsolutediscount = '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$thirdparty->id.'&backtopage='.$backtopage.'">'.$langs->trans("EditGlobalDiscounts").'</a>';
34
+$viewabsolutediscount = '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$thirdparty->id.'&backtopage='.$backtopage.'">'.$langs->trans("ViewAvailableGlobalDiscounts").'</a>';
35 35
 
36 36
 $fixedDiscount = $thirdparty->remise_percent;
37
-if(! empty($discount_type)) {
37
+if (!empty($discount_type)) {
38 38
 	$fixedDiscount = $thirdparty->remise_supplier_percent;
39 39
 }
40 40
 
41 41
 if ($fixedDiscount > 0)
42 42
 {
43
-	$translationKey = (! empty($discount_type)) ? 'HasRelativeDiscountFromSupplier' : 'CompanyHasRelativeDiscount';
43
+	$translationKey = (!empty($discount_type)) ? 'HasRelativeDiscountFromSupplier' : 'CompanyHasRelativeDiscount';
44 44
 	print $langs->trans($translationKey, $fixedDiscount).'.';
45 45
 }
46 46
 else
47 47
 {
48
-	$translationKey = (! empty($discount_type)) ? 'HasNoRelativeDiscountFromSupplier' : 'CompanyHasNoRelativeDiscount';
48
+	$translationKey = (!empty($discount_type)) ? 'HasNoRelativeDiscountFromSupplier' : 'CompanyHasNoRelativeDiscount';
49 49
 	print $langs->trans($translationKey).'.';
50 50
 }
51
-if($isNewObject) print ' ('.$addrelativediscount.')';
51
+if ($isNewObject) print ' ('.$addrelativediscount.')';
52 52
 
53 53
 // Is there is commercial discount or down payment available ?
54 54
 if ($absolute_discount > 0) {
55 55
 
56
-	if ($cannotApplyDiscount || ! $isInvoice || $isNewObject || $object->statut > $classname::STATUS_DRAFT || $object->type == $classname::TYPE_CREDIT_NOTE || $object->type == $classname::TYPE_DEPOSIT) {
57
-		$translationKey = ! empty($discount_type) ? 'HasAbsoluteDiscountFromSupplier' : 'CompanyHasAbsoluteDiscount';
58
-		$text = $langs->trans($translationKey, price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency)).'.';
56
+	if ($cannotApplyDiscount || !$isInvoice || $isNewObject || $object->statut > $classname::STATUS_DRAFT || $object->type == $classname::TYPE_CREDIT_NOTE || $object->type == $classname::TYPE_DEPOSIT) {
57
+		$translationKey = !empty($discount_type) ? 'HasAbsoluteDiscountFromSupplier' : 'CompanyHasAbsoluteDiscount';
58
+		$text = $langs->trans($translationKey, price($absolute_discount), $langs->transnoentities("Currency".$conf->currency)).'.';
59 59
 
60
-		if ($isInvoice && ! $isNewObject && $object->statut > $classname::STATUS_DRAFT && $object->type != $classname::TYPE_CREDIT_NOTE && $object->type != $classname::TYPE_DEPOSIT) {
60
+		if ($isInvoice && !$isNewObject && $object->statut > $classname::STATUS_DRAFT && $object->type != $classname::TYPE_CREDIT_NOTE && $object->type != $classname::TYPE_DEPOSIT) {
61 61
 			$text = $form->textwithpicto($text, $langs->trans('AbsoluteDiscountUse'));
62 62
 		}
63 63
 
64 64
 		if ($isNewObject) {
65
-			$text.= ' ('.$addabsolutediscount.')';
65
+			$text .= ' ('.$addabsolutediscount.')';
66 66
 		}
67 67
 
68 68
 		print '<br>'.$text;
69 69
 	} else {
70 70
 		// Discount available of type fixed amount (not credit note)
71
-		$more = '(' . $addabsolutediscount . ')';
72
-		$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, GETPOST('discountid'), 'remise_id', $thirdparty->id, $absolute_discount, $filterabsolutediscount, $resteapayer, $more, 0, $discount_type);
71
+		$more = '('.$addabsolutediscount.')';
72
+		$form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, GETPOST('discountid'), 'remise_id', $thirdparty->id, $absolute_discount, $filterabsolutediscount, $resteapayer, $more, 0, $discount_type);
73 73
 	}
74 74
 }
75 75
 
@@ -77,32 +77,32 @@  discard block
 block discarded – undo
77 77
 if ($absolute_creditnote > 0) {
78 78
 
79 79
 	// If validated, we show link "add credit note to payment"
80
-	if ($cannotApplyDiscount || ! $isInvoice || $isNewObject || $object->statut != $classname::STATUS_VALIDATED || $object->type == $classname::TYPE_CREDIT_NOTE) {
81
-		$translationKey = ! empty($discount_type) ? 'HasCreditNoteFromSupplier' : 'CompanyHasCreditNote';
82
-		$text = $langs->trans($translationKey, price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)) . '.';
80
+	if ($cannotApplyDiscount || !$isInvoice || $isNewObject || $object->statut != $classname::STATUS_VALIDATED || $object->type == $classname::TYPE_CREDIT_NOTE) {
81
+		$translationKey = !empty($discount_type) ? 'HasCreditNoteFromSupplier' : 'CompanyHasCreditNote';
82
+		$text = $langs->trans($translationKey, price($absolute_creditnote), $langs->transnoentities("Currency".$conf->currency)).'.';
83 83
 
84
-		if ($isInvoice && ! $isNewObject && $object->statut == $classname::STATUS_DRAFT && $object->type != $classname::TYPE_DEPOSIT) {
84
+		if ($isInvoice && !$isNewObject && $object->statut == $classname::STATUS_DRAFT && $object->type != $classname::TYPE_DEPOSIT) {
85 85
 			$text = $form->textwithpicto($text, $langs->trans('CreditNoteDepositUse'));
86 86
 		}
87 87
 
88 88
 		if ($absolute_discount <= 0 || $isNewObject) {
89
-			$text.= '('.$addabsolutediscount.')';
89
+			$text .= '('.$addabsolutediscount.')';
90 90
 		}
91 91
 
92 92
 		print '<br>'.$text;
93 93
 	} else {  // We can add a credit note on a down payment or standard invoice or situation invoice
94 94
 		// There is credit notes discounts available
95
-		$more = $isInvoice && ! $isNewObject ? ' (' . $viewabsolutediscount . ')' : '';
96
-		$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $thirdparty->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, $discount_type); // We allow credit note even if amount is higher
95
+		$more = $isInvoice && !$isNewObject ? ' ('.$viewabsolutediscount.')' : '';
96
+		$form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $thirdparty->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, $discount_type); // We allow credit note even if amount is higher
97 97
 	}
98 98
 }
99 99
 
100
-if($absolute_discount <= 0 && $absolute_creditnote <= 0) {
101
-	$translationKey = ! empty($discount_type) ? 'HasNoAbsoluteDiscountFromSupplier' : 'CompanyHasNoAbsoluteDiscount';
100
+if ($absolute_discount <= 0 && $absolute_creditnote <= 0) {
101
+	$translationKey = !empty($discount_type) ? 'HasNoAbsoluteDiscountFromSupplier' : 'CompanyHasNoAbsoluteDiscount';
102 102
 	print '<br>'.$langs->trans($translationKey).'.';
103 103
 
104 104
 	if ($isInvoice && $object->statut == $classname::STATUS_DRAFT && $object->type != $classname::TYPE_CREDIT_NOTE && $object->type != $classname::TYPE_DEPOSIT) {
105
-		print ' (' . $addabsolutediscount . ')';
105
+		print ' ('.$addabsolutediscount.')';
106 106
 	}
107 107
 }
108 108
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/tpl/notes.tpl.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  */
19 19
 
20 20
 // Protection to avoid direct call of template
21
-if (empty($object) || ! is_object($object)) {
21
+if (empty($object) || !is_object($object)) {
22 22
 	print "Error, template page can't be called as URL";
23 23
 	exit;
24 24
 }
@@ -29,56 +29,56 @@  discard block
 block discarded – undo
29 29
 $note_public  = 'note_public';
30 30
 $note_private = 'note_private';
31 31
 
32
-$colwidth=(isset($colwidth)?$colwidth:(empty($cssclass)?'25':''));
32
+$colwidth = (isset($colwidth) ? $colwidth : (empty($cssclass) ? '25' : ''));
33 33
 // Set $permission from the $permissionnote var defined on calling page
34
-$permission=(isset($permissionnote)?$permissionnote:(isset($permission)?$permission:(isset($user->rights->$module->create)?$user->rights->$module->create:(isset($user->rights->$module->creer)?$user->rights->$module->creer:0))));
35
-$moreparam=(isset($moreparam)?$moreparam:'');
36
-$value_public=$object->note_public;
37
-$value_private=$object->note_private;
38
-if (! empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PUBLIC_NOTES))
34
+$permission = (isset($permissionnote) ? $permissionnote : (isset($permission) ? $permission : (isset($user->rights->$module->create) ? $user->rights->$module->create : (isset($user->rights->$module->creer) ? $user->rights->$module->creer : 0))));
35
+$moreparam = (isset($moreparam) ? $moreparam : '');
36
+$value_public = $object->note_public;
37
+$value_private = $object->note_private;
38
+if (!empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PUBLIC_NOTES))
39 39
 {
40
-	$stringtoadd=dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --';
41
-	if (GETPOST('action','aZ09') == 'edit'.$note_public)
40
+	$stringtoadd = dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --';
41
+	if (GETPOST('action', 'aZ09') == 'edit'.$note_public)
42 42
 	{
43
-		$value_public=dol_concatdesc($value_public, ($value_public?"\n":"")."-- ".$stringtoadd);
44
-		if (dol_textishtml($value_public)) $value_public.="<br>\n";
45
-		else $value_public.="\n";
43
+		$value_public = dol_concatdesc($value_public, ($value_public ? "\n" : "")."-- ".$stringtoadd);
44
+		if (dol_textishtml($value_public)) $value_public .= "<br>\n";
45
+		else $value_public .= "\n";
46 46
 	}
47 47
 }
48
-if (! empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES))
48
+if (!empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES))
49 49
 {
50
-	$stringtoadd=dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --';
51
-	if (GETPOST('action','aZ09') == 'edit'.$note_private)
50
+	$stringtoadd = dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --';
51
+	if (GETPOST('action', 'aZ09') == 'edit'.$note_private)
52 52
 	{
53
-		$value_private=dol_concatdesc($value_private, ($value_private?"\n":"")."-- ".$stringtoadd);
54
-		if (dol_textishtml($value_private)) $value_private.="<br>\n";
55
-		else $value_private.="\n";
53
+		$value_private = dol_concatdesc($value_private, ($value_private ? "\n" : "")."-- ".$stringtoadd);
54
+		if (dol_textishtml($value_private)) $value_private .= "<br>\n";
55
+		else $value_private .= "\n";
56 56
 	}
57 57
 }
58 58
 
59 59
 // Special cases
60
-if ($module == 'propal')                 { $permission=$user->rights->propale->creer;}
61
-elseif ($module == 'supplier_proposal')  { $permission=$user->rights->supplier_proposal->creer;}
62
-elseif ($module == 'fichinter')          { $permission=$user->rights->ficheinter->creer;}
63
-elseif ($module == 'project')            { $permission=$user->rights->projet->creer;}
64
-elseif ($module == 'project_task')       { $permission=$user->rights->projet->creer;}
65
-elseif ($module == 'invoice_supplier')   { $permission=$user->rights->fournisseur->facture->creer;}
66
-elseif ($module == 'order_supplier')     { $permission=$user->rights->fournisseur->commande->creer;}
67
-elseif ($module == 'societe')     	 	 { $permission=$user->rights->societe->creer;}
68
-elseif ($module == 'contact')     		 { $permission=$user->rights->societe->creer;}
69
-elseif ($module == 'shipping')    		 { $permission=$user->rights->expedition->creer;}
70
-elseif ($module == 'product')    		 { $permission=$user->rights->produit->creer;}
60
+if ($module == 'propal') { $permission = $user->rights->propale->creer; }
61
+elseif ($module == 'supplier_proposal') { $permission = $user->rights->supplier_proposal->creer; }
62
+elseif ($module == 'fichinter') { $permission = $user->rights->ficheinter->creer; }
63
+elseif ($module == 'project') { $permission = $user->rights->projet->creer; }
64
+elseif ($module == 'project_task') { $permission = $user->rights->projet->creer; }
65
+elseif ($module == 'invoice_supplier') { $permission = $user->rights->fournisseur->facture->creer; }
66
+elseif ($module == 'order_supplier') { $permission = $user->rights->fournisseur->commande->creer; }
67
+elseif ($module == 'societe') { $permission = $user->rights->societe->creer; }
68
+elseif ($module == 'contact') { $permission = $user->rights->societe->creer; }
69
+elseif ($module == 'shipping') { $permission = $user->rights->expedition->creer; }
70
+elseif ($module == 'product') { $permission = $user->rights->produit->creer; }
71 71
 //else dol_print_error('','Bad value '.$module.' for param module');
72 72
 
73
-if (! empty($conf->fckeditor->enabled) && ! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata='ckeditor:dolibarr_notes:100%:200::1:12:95%';	// Rem: This var is for all notes, not only thirdparties note.
74
-else $typeofdata='textarea:12:95%';
73
+if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata = 'ckeditor:dolibarr_notes:100%:200::1:12:95%'; // Rem: This var is for all notes, not only thirdparties note.
74
+else $typeofdata = 'textarea:12:95%';
75 75
 
76 76
 print '<!-- BEGIN PHP TEMPLATE NOTES -->'."\n";
77 77
 print '<div class="tagtable border table-border centpercent">'."\n";
78 78
 if ($module != 'product') {
79 79
 	// No public note yet on products
80 80
 	print '<div class="tagtr pair table-border-row">'."\n";
81
-	print '<div class="tagtd tagtdnote tdtop table-key-border-col'.(empty($cssclass)?'':' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n";
81
+	print '<div class="tagtd tagtdnote tdtop table-key-border-col'.(empty($cssclass) ? '' : ' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n";
82 82
 	print $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam, '', 0);
83 83
 	print '</div>'."\n";
84 84
 	print '<div class="tagtd table-val-border-col">'."\n";
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	print '</div>'."\n";
88 88
 }
89 89
 if (empty($user->societe_id)) {
90
-	print '<div class="tagtr '.($module != 'product'?'impair':'pair').' table-border-row">'."\n";
91
-	print '<div class="tagtd tagtdnote tdtop table-key-border-col'.(empty($cssclass)?'':' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n";
90
+	print '<div class="tagtr '.($module != 'product' ? 'impair' : 'pair').' table-border-row">'."\n";
91
+	print '<div class="tagtd tagtdnote tdtop table-key-border-col'.(empty($cssclass) ? '' : ' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n";
92 92
 	print $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam, '', 0);
93 93
 	print '</div>'."\n";
94 94
 	print '<div class="tagtd table-val-border-col">'."\n";
Please login to merge, or discard this patch.