Completed
Branch develop (2c126c)
by Laurent
24:08
created
htdocs/core/lib/website.lib.php 4 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
  *
94 94
  * @param	Website		$website			Web site object
95 95
  * @param	string		$content			Content to replace
96
- * @return	boolean							True if OK
96
+ * @return	string							True if OK
97 97
  */
98 98
 function dolWebsiteReplacementOfLinks($website, $content)
99 99
 {
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
  * Generate a zip with all data of web site.
189 189
  *
190 190
  * @param 	Website		$website		Object website
191
- * @return  void
191
+ * @return  string
192 192
  */
193 193
 function exportWebSite($website)
194 194
 {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
  * @param 	string		$urltograb		URL to grab (exemple: http://www.nltechno.com/ or http://www.nltechno.com/dir1/ or http://www.nltechno.com/dir1/mapage1)
288 288
  * @param 	string		$tmp			Content to parse
289 289
  * @param 	string		$action			Var $action
290
- * @param	string		$modifylinks	0=Do not modify content, 1=Replace links with a link to viewimage
290
+ * @param	integer		$modifylinks	0=Do not modify content, 1=Replace links with a link to viewimage
291 291
  * @return	void
292 292
  */
293 293
 function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0)
Please login to merge, or discard this patch.
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -31,59 +31,59 @@
 block discarded – undo
31 31
  */
32 32
 function dolWebsiteOutput($content)
33 33
 {
34
-    global $db, $langs, $conf, $user;
35
-    global $dolibarr_main_url_root, $dolibarr_main_data_root;
34
+	global $db, $langs, $conf, $user;
35
+	global $dolibarr_main_url_root, $dolibarr_main_data_root;
36 36
 
37
-    dol_syslog("dolWebsiteOutput start (mode=".(defined('USEDOLIBARRSERVER')?'USEDOLIBARRSERVER':'').')');
37
+	dol_syslog("dolWebsiteOutput start (mode=".(defined('USEDOLIBARRSERVER')?'USEDOLIBARRSERVER':'').')');
38 38
 
39
-    // Define $urlwithroot
40
-    $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
41
-    $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
42
-    //$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
39
+	// Define $urlwithroot
40
+	$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
41
+	$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
42
+	//$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
43 43
 
44
-    // Note: This seems never called when page is output inside the website editor (search 'REPLACEMENT OF LINKS When page called by website editor')
44
+	// Note: This seems never called when page is output inside the website editor (search 'REPLACEMENT OF LINKS When page called by website editor')
45 45
 
46
-    if (! defined('USEDOLIBARRSERVER'))	// REPLACEMENT OF LINKS When page called from virtual host
47
-    {
48
-        $symlinktomediaexists=1;
46
+	if (! defined('USEDOLIBARRSERVER'))	// REPLACEMENT OF LINKS When page called from virtual host
47
+	{
48
+		$symlinktomediaexists=1;
49 49
 
50 50
 		// Make a change into HTML code to allow to include images from medias directory correct with direct link for virtual server
51 51
 		// <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
52 52
 		// become
53 53
 		// <img alt="" src="'.$urlwithroot.'/medias/image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
54
-        $nbrep=0;
55
-        if (! $symlinktomediaexists)
56
-        {
57
-            $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/?>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
58
-            $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/',  '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
59
-        }
60
-        else
61
-        {
62
-        	$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/?>)/', '\1medias/\4\5', $content, -1, $nbrep);
63
-            $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep);
64
-        }
65
-    }
66
-    else								// REPLACEMENT OF LINKS When page called from dolibarr server
67
-    {
68
-    	global $website;
69
-
70
-    	// Replace relative link / with dolibarr URL:  ...href="/"...
71
-    	$content=preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep);
72
-    	// Replace relative link /xxx.php with dolibarr URL:  ...href="....php"
73
-    	$content=preg_replace('/(href=")\/?([^\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
74
-
75
-    	// Fix relative link /document.php with correct URL after the DOL_URL_ROOT:  ...href="/document.php?modulepart="
76
-    	$content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep);
77
-    	// Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT:  ...href="/viewimage.php?modulepart="
78
-    	$content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep);
79
-
80
-    	// Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/
81
-    	$content=preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
82
-    }
83
-
84
-    dol_syslog("dolWebsiteOutput end");
85
-
86
-    print $content;
54
+		$nbrep=0;
55
+		if (! $symlinktomediaexists)
56
+		{
57
+			$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/?>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
58
+			$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/',  '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
59
+		}
60
+		else
61
+		{
62
+			$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/?>)/', '\1medias/\4\5', $content, -1, $nbrep);
63
+			$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep);
64
+		}
65
+	}
66
+	else								// REPLACEMENT OF LINKS When page called from dolibarr server
67
+	{
68
+		global $website;
69
+
70
+		// Replace relative link / with dolibarr URL:  ...href="/"...
71
+		$content=preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep);
72
+		// Replace relative link /xxx.php with dolibarr URL:  ...href="....php"
73
+		$content=preg_replace('/(href=")\/?([^\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
74
+
75
+		// Fix relative link /document.php with correct URL after the DOL_URL_ROOT:  ...href="/document.php?modulepart="
76
+		$content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep);
77
+		// Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT:  ...href="/viewimage.php?modulepart="
78
+		$content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep);
79
+
80
+		// Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/
81
+		$content=preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
82
+	}
83
+
84
+	dol_syslog("dolWebsiteOutput end");
85
+
86
+	print $content;
87 87
 }
88 88
 
89 89
 
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -34,33 +34,33 @@  discard block
 block discarded – undo
34 34
     global $db, $langs, $conf, $user;
35 35
     global $dolibarr_main_url_root, $dolibarr_main_data_root;
36 36
 
37
-    dol_syslog("dolWebsiteOutput start (mode=".(defined('USEDOLIBARRSERVER')?'USEDOLIBARRSERVER':'').')');
37
+    dol_syslog("dolWebsiteOutput start (mode=".(defined('USEDOLIBARRSERVER') ? 'USEDOLIBARRSERVER' : '').')');
38 38
 
39 39
     // Define $urlwithroot
40
-    $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
41
-    $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
40
+    $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
41
+    $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
42 42
     //$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
43 43
 
44 44
     // Note: This seems never called when page is output inside the website editor (search 'REPLACEMENT OF LINKS When page called by website editor')
45 45
 
46
-    if (! defined('USEDOLIBARRSERVER'))	// REPLACEMENT OF LINKS When page called from virtual host
46
+    if (!defined('USEDOLIBARRSERVER'))	// REPLACEMENT OF LINKS When page called from virtual host
47 47
     {
48
-        $symlinktomediaexists=1;
48
+        $symlinktomediaexists = 1;
49 49
 
50 50
 		// Make a change into HTML code to allow to include images from medias directory correct with direct link for virtual server
51 51
 		// <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
52 52
 		// become
53 53
 		// <img alt="" src="'.$urlwithroot.'/medias/image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
54
-        $nbrep=0;
55
-        if (! $symlinktomediaexists)
54
+        $nbrep = 0;
55
+        if (!$symlinktomediaexists)
56 56
         {
57
-            $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/?>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
58
-            $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/',  '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
57
+            $content = preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/?>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
58
+            $content = preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
59 59
         }
60 60
         else
61 61
         {
62
-        	$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/?>)/', '\1medias/\4\5', $content, -1, $nbrep);
63
-            $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep);
62
+        	$content = preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/?>)/', '\1medias/\4\5', $content, -1, $nbrep);
63
+            $content = preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep);
64 64
         }
65 65
     }
66 66
     else								// REPLACEMENT OF LINKS When page called from dolibarr server
@@ -68,17 +68,17 @@  discard block
 block discarded – undo
68 68
     	global $website;
69 69
 
70 70
     	// Replace relative link / with dolibarr URL:  ...href="/"...
71
-    	$content=preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep);
71
+    	$content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep);
72 72
     	// Replace relative link /xxx.php with dolibarr URL:  ...href="....php"
73
-    	$content=preg_replace('/(href=")\/?([^\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
73
+    	$content = preg_replace('/(href=")\/?([^\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
74 74
 
75 75
     	// Fix relative link /document.php with correct URL after the DOL_URL_ROOT:  ...href="/document.php?modulepart="
76
-    	$content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep);
76
+    	$content = preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep);
77 77
     	// Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT:  ...href="/viewimage.php?modulepart="
78
-    	$content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep);
78
+    	$content = preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep);
79 79
 
80 80
     	// Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/
81
-    	$content=preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
81
+    	$content = preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
82 82
     }
83 83
 
84 84
     dol_syslog("dolWebsiteOutput end");
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	$content = preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
109 109
 
110 110
 	// <img src="image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png...
111
-	$content = preg_replace('/(<img[^>]*src=")(?!(http|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
111
+	$content = preg_replace('/(<img[^>]*src=")(?!(http|'.preg_quote(DOL_URL_ROOT, '/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
112 112
 
113 113
 	return $content;
114 114
 }
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
 	global $conf, $db, $langs, $mysoc, $user, $website;
154 154
 	global $includehtmlcontentopened;
155 155
 
156
-	$MAXLEVEL=20;
156
+	$MAXLEVEL = 20;
157 157
 
158
-	$fullpathfile=DOL_DATA_ROOT.'/websites/'.$contentfile;
158
+	$fullpathfile = DOL_DATA_ROOT.'/websites/'.$contentfile;
159 159
 
160
-	if (empty($includehtmlcontentopened)) $includehtmlcontentopened=0;
160
+	if (empty($includehtmlcontentopened)) $includehtmlcontentopened = 0;
161 161
 	$includehtmlcontentopened++;
162 162
 	if ($includehtmlcontentopened > $MAXLEVEL)
163 163
 	{
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
 	//print preg_replace(array('/^.*<body[^>]*>/ims','/<\/body>.*$/ims'), array('', ''), $content);*/
170 170
 
171 171
 	ob_start();
172
-	$res = include $fullpathfile;		// Include because we want to execute code content
172
+	$res = include $fullpathfile; // Include because we want to execute code content
173 173
 	$tmpoutput = ob_get_contents();
174 174
 	ob_end_clean();
175 175
 
176 176
 	print "\n".'<!-- include '.$fullpathfile.' level = '.$includehtmlcontentopened.' -->'."\n";
177
-	print preg_replace(array('/^.*<body[^>]*>/ims','/<\/body>.*$/ims'), array('', ''), $tmpoutput);
177
+	print preg_replace(array('/^.*<body[^>]*>/ims', '/<\/body>.*$/ims'), array('', ''), $tmpoutput);
178 178
 
179
-	if (! $res)
179
+	if (!$res)
180 180
 	{
181 181
 		print 'ERROR: FAILED TO INCLUDE PAGE '.$contentfile.".\n";
182 182
 	}
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	$srcdir = $conf->websites->dir_output.'/'.$website->ref;
199 199
 	$destdir = $conf->websites->dir_temp.'/'.$website->ref;
200 200
 
201
-	$arrayreplacement=array();
201
+	$arrayreplacement = array();
202 202
 
203 203
 	dolCopyDir($srcdir, $destdir, 0, 1, $arrayreplacement);
204 204
 
@@ -211,24 +211,24 @@  discard block
 block discarded – undo
211 211
 	dol_mkdir($conf->websites->dir_temp.'/'.$website->ref.'/export');
212 212
 
213 213
 	$filesql = $conf->websites->dir_temp.'/'.$website->ref.'/export/pages.sql';
214
-	$fp = fopen($filesql,"w");
214
+	$fp = fopen($filesql, "w");
215 215
 
216 216
 	$objectpages = new WebsitePage($db);
217 217
 	$listofpages = $objectpages->fetchAll($website->id);
218 218
 
219 219
 	// Assign ->newid and ->newfk_page
220
-	$i=1;
221
-	foreach($listofpages as $pageid => $objectpageold)
220
+	$i = 1;
221
+	foreach ($listofpages as $pageid => $objectpageold)
222 222
 	{
223
-		$objectpageold->newid=$i;
223
+		$objectpageold->newid = $i;
224 224
 		$i++;
225 225
 	}
226
-	$i=1;
227
-	foreach($listofpages as $pageid => $objectpageold)
226
+	$i = 1;
227
+	foreach ($listofpages as $pageid => $objectpageold)
228 228
 	{
229 229
 		// Search newid
230
-		$newfk_page=0;
231
-		foreach($listofpages as $pageid2 => $objectpageold2)
230
+		$newfk_page = 0;
231
+		foreach ($listofpages as $pageid2 => $objectpageold2)
232 232
 		{
233 233
 			if ($pageid2 == $objectpageold->fk_page)
234 234
 			{
@@ -236,40 +236,40 @@  discard block
 block discarded – undo
236 236
 				break;
237 237
 			}
238 238
 		}
239
-		$objectpageold->newfk_page=$newfk_page;
239
+		$objectpageold->newfk_page = $newfk_page;
240 240
 		$i++;
241 241
 	}
242
-	foreach($listofpages as $pageid => $objectpageold)
242
+	foreach ($listofpages as $pageid => $objectpageold)
243 243
 	{
244 244
 		$line = 'INSERT INTO llx_website_page(rowid, fk_page, fk_website, pageurl, title, description, keyword, status, date_creation, tms, lang, import_key, grabbed_from, content)';
245
-		$line.= " VALUES(";
246
-		$line.= $objectpageold->newid."+__MAXROWID__, ";
247
-		$line.= ($objectpageold->newfk_page ? $db->escape($objectpageold->newfk_page)."+__MAXROWID__" : "null").", ";
248
-		$line.= "__WEBSITE_ID__, ";
249
-		$line.= "'".$db->escape($objectpageold->pageurl)."', ";
250
-		$line.= "'".$db->escape($objectpageold->title)."', ";
251
-		$line.= "'".$db->escape($objectpageold->description)."', ";
252
-		$line.= "'".$db->escape($objectpageold->keyword)."', ";
253
-		$line.= "'".$db->escape($objectpageold->status)."', ";
254
-		$line.= "'".$db->idate($objectpageold->date_creation)."', ";
255
-		$line.= "'".$db->idate($objectpageold->date_modification)."', ";
256
-		$line.= "'".$db->escape($objectpageold->lang)."', ";
257
-		$line.= ($objectpageold->import_key ? "'".$db->escape($objectpageold->import_key)."'" : "null").", ";
258
-		$line.= "'".$db->escape($objectpageold->grabbed_from)."', ";
259
-		$line.= "'".$db->escape($objectpageold->content)."'";
260
-		$line.= ");";
261
-		$line.= "\n";
245
+		$line .= " VALUES(";
246
+		$line .= $objectpageold->newid."+__MAXROWID__, ";
247
+		$line .= ($objectpageold->newfk_page ? $db->escape($objectpageold->newfk_page)."+__MAXROWID__" : "null").", ";
248
+		$line .= "__WEBSITE_ID__, ";
249
+		$line .= "'".$db->escape($objectpageold->pageurl)."', ";
250
+		$line .= "'".$db->escape($objectpageold->title)."', ";
251
+		$line .= "'".$db->escape($objectpageold->description)."', ";
252
+		$line .= "'".$db->escape($objectpageold->keyword)."', ";
253
+		$line .= "'".$db->escape($objectpageold->status)."', ";
254
+		$line .= "'".$db->idate($objectpageold->date_creation)."', ";
255
+		$line .= "'".$db->idate($objectpageold->date_modification)."', ";
256
+		$line .= "'".$db->escape($objectpageold->lang)."', ";
257
+		$line .= ($objectpageold->import_key ? "'".$db->escape($objectpageold->import_key)."'" : "null").", ";
258
+		$line .= "'".$db->escape($objectpageold->grabbed_from)."', ";
259
+		$line .= "'".$db->escape($objectpageold->content)."'";
260
+		$line .= ");";
261
+		$line .= "\n";
262 262
 		fputs($fp, $line);
263 263
 	}
264 264
 
265 265
 	fclose($fp);
266
-	if (! empty($conf->global->MAIN_UMASK))
266
+	if (!empty($conf->global->MAIN_UMASK))
267 267
 		@chmod($filesql, octdec($conf->global->MAIN_UMASK));
268 268
 
269 269
 	// Build zip file
270 270
 	$filedir = $conf->websites->dir_temp.'/'.$website->ref;
271 271
 	$fileglob = $conf->websites->dir_temp.'/'.$website->ref.'/export/'.$website->ref.'_export_*.zip';
272
-	$filename = $conf->websites->dir_temp.'/'.$website->ref.'/export/'.$website->ref.'_export_'.dol_print_date(dol_now(),'dayhourlog').'.zip';
272
+	$filename = $conf->websites->dir_temp.'/'.$website->ref.'/export/'.$website->ref.'_export_'.dol_print_date(dol_now(), 'dayhourlog').'.zip';
273 273
 
274 274
 	dol_delete_file($fileglob, 0);
275 275
 	dol_compress_file($filedir, $filename, 'zip');
@@ -290,32 +290,32 @@  discard block
 block discarded – undo
290 290
  * @param	string		$modifylinks	0=Do not modify content, 1=Replace links with a link to viewimage
291 291
  * @return	void
292 292
  */
293
-function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0)
293
+function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks = 0)
294 294
 {
295 295
 	global $conf;
296 296
 
297
-	$alreadygrabbed=array();
297
+	$alreadygrabbed = array();
298 298
 
299
-	if (preg_match('/\/$/', $urltograb)) $urltograb.='.';
300
-	$urltograb = dirname($urltograb);							// So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1
299
+	if (preg_match('/\/$/', $urltograb)) $urltograb .= '.';
300
+	$urltograb = dirname($urltograb); // So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1
301 301
 
302 302
 	preg_match_all('/<img([^\.\/]+)src="([^>"]+)"([^>]*)>/i', $tmp, $regs);
303 303
 
304 304
 	foreach ($regs[0] as $key => $val)
305 305
 	{
306
-		if (preg_match('/^data:image/i', $regs[2][$key])) continue;		// We do nothing for such images
306
+		if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images
307 307
 
308
-		$urltograbbis = $urltograb.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
308
+		$urltograbbis = $urltograb.(preg_match('/^\//', $regs[2][$key]) ? '' : '/').$regs[2][$key];
309 309
 		$linkwithoutdomain = $regs[2][$key];
310
-		$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
310
+		$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key]) ? '' : '/').$regs[2][$key];
311 311
 		if (preg_match('/^http/', $regs[2][$key]))
312 312
 		{
313 313
 			$urltograbbis = $regs[2][$key];
314 314
 			$linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]);
315
-			$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
315
+			$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain) ? '' : '/').$linkwithoutdomain;
316 316
 		}
317 317
 
318
-		$filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
318
+		$filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain) ? '' : '/').$linkwithoutdomain;
319 319
 
320 320
 		// Clean the aa/bb/../cc into aa/cc
321 321
 		$filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave);
@@ -332,25 +332,25 @@  discard block
 block discarded – undo
332 332
 			{
333 333
 				$error++;
334 334
 				setEventMessages($tmpgeturl['curl_error_msg'], null, 'errors');
335
-				$action='create';
335
+				$action = 'create';
336 336
 			}
337 337
 			else
338 338
 			{
339
-				$alreadygrabbed[$urltograbbis]=1;	// Track that file was alreay grabbed.
339
+				$alreadygrabbed[$urltograbbis] = 1; // Track that file was alreay grabbed.
340 340
 
341 341
 				dol_mkdir(dirname($filetosave));
342 342
 
343 343
 				$fp = fopen($filetosave, "w");
344 344
 				fputs($fp, $tmpgeturl['content']);
345 345
 				fclose($fp);
346
-				if (! empty($conf->global->MAIN_UMASK))
346
+				if (!empty($conf->global->MAIN_UMASK))
347 347
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
348 348
 			}
349 349
 		}
350 350
 
351 351
 		if ($modifylinks)
352 352
 		{
353
-			$tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', '<img'.$regs[1][$key].'src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'"'.$regs[3][$key].'>', $tmp);
353
+			$tmp = preg_replace('/'.preg_quote($regs[0][$key], '/').'/i', '<img'.$regs[1][$key].'src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'"'.$regs[3][$key].'>', $tmp);
354 354
 		}
355 355
 	}
356 356
 
@@ -359,21 +359,21 @@  discard block
 block discarded – undo
359 359
 
360 360
 	foreach ($regs[0] as $key => $val)
361 361
 	{
362
-		if (preg_match('/^data:image/i', $regs[2][$key])) continue;		// We do nothing for such images
362
+		if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images
363 363
 
364
-		$urltograbbis = $urltograb.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
364
+		$urltograbbis = $urltograb.(preg_match('/^\//', $regs[2][$key]) ? '' : '/').$regs[2][$key];
365 365
 
366 366
 		$linkwithoutdomain = $regs[2][$key];
367
-		$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
367
+		$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key]) ? '' : '/').$regs[2][$key];
368 368
 
369 369
 		if (preg_match('/^http/', $regs[2][$key]))
370 370
 		{
371 371
 			$urltograbbis = $regs[2][$key];
372 372
 			$linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]);
373
-			$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
373
+			$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain) ? '' : '/').$linkwithoutdomain;
374 374
 		}
375 375
 
376
-		$filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
376
+		$filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain) ? '' : '/').$linkwithoutdomain;
377 377
 
378 378
 		// Clean the aa/bb/../cc into aa/cc
379 379
 		$filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave);
@@ -390,25 +390,25 @@  discard block
 block discarded – undo
390 390
 			{
391 391
 				$error++;
392 392
 				setEventMessages($tmpgeturl['curl_error_msg'], null, 'errors');
393
-				$action='create';
393
+				$action = 'create';
394 394
 			}
395 395
 			else
396 396
 			{
397
-				$alreadygrabbed[$urltograbbis]=1;	// Track that file was alreay grabbed.
397
+				$alreadygrabbed[$urltograbbis] = 1; // Track that file was alreay grabbed.
398 398
 
399 399
 				dol_mkdir(dirname($filetosave));
400 400
 
401 401
 				$fp = fopen($filetosave, "w");
402 402
 				fputs($fp, $tmpgeturl['content']);
403 403
 				fclose($fp);
404
-				if (! empty($conf->global->MAIN_UMASK))
404
+				if (!empty($conf->global->MAIN_UMASK))
405 405
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
406 406
 			}
407 407
 		}
408 408
 
409 409
 		if ($modifylinks)
410 410
 		{
411
-			$tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', 'background'.$regs[1][$key].'url("'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'")', $tmp);
411
+			$tmp = preg_replace('/'.preg_quote($regs[0][$key], '/').'/i', 'background'.$regs[1][$key].'url("'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'")', $tmp);
412 412
 		}
413 413
 	}
414 414
 
Please login to merge, or discard this patch.
Braces   +30 added lines, -19 removed lines patch added patch discarded remove patch
@@ -43,9 +43,11 @@  discard block
 block discarded – undo
43 43
 
44 44
     // Note: This seems never called when page is output inside the website editor (search 'REPLACEMENT OF LINKS When page called by website editor')
45 45
 
46
-    if (! defined('USEDOLIBARRSERVER'))	// REPLACEMENT OF LINKS When page called from virtual host
46
+    if (! defined('USEDOLIBARRSERVER')) {
47
+    	// REPLACEMENT OF LINKS When page called from virtual host
47 48
     {
48 49
         $symlinktomediaexists=1;
50
+    }
49 51
 
50 52
 		// Make a change into HTML code to allow to include images from medias directory correct with direct link for virtual server
51 53
 		// <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
@@ -56,14 +58,12 @@  discard block
 block discarded – undo
56 58
         {
57 59
             $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/?>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
58 60
             $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/',  '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
59
-        }
60
-        else
61
+        } else
61 62
         {
62 63
         	$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/?>)/', '\1medias/\4\5', $content, -1, $nbrep);
63 64
             $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep);
64 65
         }
65
-    }
66
-    else								// REPLACEMENT OF LINKS When page called from dolibarr server
66
+    } else								// REPLACEMENT OF LINKS When page called from dolibarr server
67 67
     {
68 68
     	global $website;
69 69
 
@@ -157,7 +157,9 @@  discard block
 block discarded – undo
157 157
 
158 158
 	$fullpathfile=DOL_DATA_ROOT.'/websites/'.$contentfile;
159 159
 
160
-	if (empty($includehtmlcontentopened)) $includehtmlcontentopened=0;
160
+	if (empty($includehtmlcontentopened)) {
161
+		$includehtmlcontentopened=0;
162
+	}
161 163
 	$includehtmlcontentopened++;
162 164
 	if ($includehtmlcontentopened > $MAXLEVEL)
163 165
 	{
@@ -263,8 +265,9 @@  discard block
 block discarded – undo
263 265
 	}
264 266
 
265 267
 	fclose($fp);
266
-	if (! empty($conf->global->MAIN_UMASK))
267
-		@chmod($filesql, octdec($conf->global->MAIN_UMASK));
268
+	if (! empty($conf->global->MAIN_UMASK)) {
269
+			@chmod($filesql, octdec($conf->global->MAIN_UMASK));
270
+	}
268 271
 
269 272
 	// Build zip file
270 273
 	$filedir = $conf->websites->dir_temp.'/'.$website->ref;
@@ -296,14 +299,19 @@  discard block
 block discarded – undo
296 299
 
297 300
 	$alreadygrabbed=array();
298 301
 
299
-	if (preg_match('/\/$/', $urltograb)) $urltograb.='.';
302
+	if (preg_match('/\/$/', $urltograb)) {
303
+		$urltograb.='.';
304
+	}
300 305
 	$urltograb = dirname($urltograb);							// So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1
301 306
 
302 307
 	preg_match_all('/<img([^\.\/]+)src="([^>"]+)"([^>]*)>/i', $tmp, $regs);
303 308
 
304 309
 	foreach ($regs[0] as $key => $val)
305 310
 	{
306
-		if (preg_match('/^data:image/i', $regs[2][$key])) continue;		// We do nothing for such images
311
+		if (preg_match('/^data:image/i', $regs[2][$key])) {
312
+			continue;
313
+		}
314
+		// We do nothing for such images
307 315
 
308 316
 		$urltograbbis = $urltograb.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
309 317
 		$linkwithoutdomain = $regs[2][$key];
@@ -333,8 +341,7 @@  discard block
 block discarded – undo
333 341
 				$error++;
334 342
 				setEventMessages($tmpgeturl['curl_error_msg'], null, 'errors');
335 343
 				$action='create';
336
-			}
337
-			else
344
+			} else
338 345
 			{
339 346
 				$alreadygrabbed[$urltograbbis]=1;	// Track that file was alreay grabbed.
340 347
 
@@ -343,8 +350,9 @@  discard block
 block discarded – undo
343 350
 				$fp = fopen($filetosave, "w");
344 351
 				fputs($fp, $tmpgeturl['content']);
345 352
 				fclose($fp);
346
-				if (! empty($conf->global->MAIN_UMASK))
347
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
353
+				if (! empty($conf->global->MAIN_UMASK)) {
354
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
355
+				}
348 356
 			}
349 357
 		}
350 358
 
@@ -359,7 +367,10 @@  discard block
 block discarded – undo
359 367
 
360 368
 	foreach ($regs[0] as $key => $val)
361 369
 	{
362
-		if (preg_match('/^data:image/i', $regs[2][$key])) continue;		// We do nothing for such images
370
+		if (preg_match('/^data:image/i', $regs[2][$key])) {
371
+			continue;
372
+		}
373
+		// We do nothing for such images
363 374
 
364 375
 		$urltograbbis = $urltograb.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
365 376
 
@@ -391,8 +402,7 @@  discard block
 block discarded – undo
391 402
 				$error++;
392 403
 				setEventMessages($tmpgeturl['curl_error_msg'], null, 'errors');
393 404
 				$action='create';
394
-			}
395
-			else
405
+			} else
396 406
 			{
397 407
 				$alreadygrabbed[$urltograbbis]=1;	// Track that file was alreay grabbed.
398 408
 
@@ -401,8 +411,9 @@  discard block
 block discarded – undo
401 411
 				$fp = fopen($filetosave, "w");
402 412
 				fputs($fp, $tmpgeturl['content']);
403 413
 				fclose($fp);
404
-				if (! empty($conf->global->MAIN_UMASK))
405
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
414
+				if (! empty($conf->global->MAIN_UMASK)) {
415
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
416
+				}
406 417
 			}
407 418
 		}
408 419
 
Please login to merge, or discard this patch.
htdocs/compta/sociales/card.php 2 patches
Indentation   +243 added lines, -243 removed lines patch added patch discarded remove patch
@@ -63,50 +63,50 @@  discard block
 block discarded – undo
63 63
 }
64 64
 
65 65
 if ($action == 'reopen' && $user->rights->tax->charges->creer) {
66
-    $result = $object->fetch($id);
67
-    if ($object->paye)
68
-    {
69
-        $result = $object->set_unpaid($user);
70
-        if ($result > 0)
71
-        {
72
-            header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
73
-            exit();
74
-        } else {
75
-            setEventMessages($object->error, $object->errors, 'errors');
76
-        }
77
-    }
66
+	$result = $object->fetch($id);
67
+	if ($object->paye)
68
+	{
69
+		$result = $object->set_unpaid($user);
70
+		if ($result > 0)
71
+		{
72
+			header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
73
+			exit();
74
+		} else {
75
+			setEventMessages($object->error, $object->errors, 'errors');
76
+		}
77
+	}
78 78
 }
79 79
 
80 80
 // Link to a project
81 81
 if ($action == 'classin' && $user->rights->tax->charges->creer)
82 82
 {
83
-    $object->fetch($id);
84
-    $object->setProject(GETPOST('projectid'));
83
+	$object->fetch($id);
84
+	$object->setProject(GETPOST('projectid'));
85 85
 }
86 86
 
87 87
 if ($action == 'setlib' && $user->rights->tax->charges->creer)
88 88
 {
89
-    $object->fetch($id);
90
-    $result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY');
91
-    if ($result < 0)
92
-        setEventMessages($object->error, $object->errors, 'errors');
89
+	$object->fetch($id);
90
+	$result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY');
91
+	if ($result < 0)
92
+		setEventMessages($object->error, $object->errors, 'errors');
93 93
 }
94 94
 
95 95
 // payment mode
96 96
 if ($action == 'setmode' && $user->rights->tax->charges->creer) {
97
-    $object->fetch($id);
98
-    $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
99
-    if ($result < 0)
100
-        setEventMessages($object->error, $object->errors, 'errors');
97
+	$object->fetch($id);
98
+	$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
99
+	if ($result < 0)
100
+		setEventMessages($object->error, $object->errors, 'errors');
101 101
 }
102 102
 
103 103
 // bank account
104 104
 if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) {
105
-    $object->fetch($id);
106
-    $result=$object->setBankAccount(GETPOST('fk_account', 'int'));
107
-    if ($result < 0) {
108
-        setEventMessages($object->error, $object->errors, 'errors');
109
-    }
105
+	$object->fetch($id);
106
+	$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
107
+	if ($result < 0) {
108
+		setEventMessages($object->error, $object->errors, 'errors');
109
+	}
110 110
 }
111 111
 
112 112
 // Delete social contribution
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 {
132 132
 	$dateech=dol_mktime(GETPOST('echhour'),GETPOST('echmin'),GETPOST('echsec'),GETPOST('echmonth'),GETPOST('echday'),GETPOST('echyear'));
133 133
 	$dateperiod=dol_mktime(GETPOST('periodhour'),GETPOST('periodmin'),GETPOST('periodsec'),GETPOST('periodmonth'),GETPOST('periodday'),GETPOST('periodyear'));
134
-    $amount=price2num(GETPOST('amount'));
135
-    $actioncode=GETPOST('actioncode');
134
+	$amount=price2num(GETPOST('amount'));
135
+	$actioncode=GETPOST('actioncode');
136 136
 
137 137
 	if (! $dateech)
138 138
 	{
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 		$object->date_ech			= $dateech;
167 167
 		$object->periode			= $dateperiod;
168 168
 		$object->amount				= $amount;
169
-        $object->mode_reglement_id	= GETPOST('mode_reglement_id');
170
-        $object->fk_account			= GETPOST('fk_account', 'int');
169
+		$object->mode_reglement_id	= GETPOST('mode_reglement_id');
170
+		$object->fk_account			= GETPOST('fk_account', 'int');
171 171
 		$object->fk_project			= GETPOST('fk_project');
172 172
 
173 173
 		$id=$object->create($user);
@@ -182,43 +182,43 @@  discard block
 block discarded – undo
182 182
 
183 183
 if ($action == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->creer)
184 184
 {
185
-    $dateech=dol_mktime(GETPOST('echhour'),GETPOST('echmin'),GETPOST('echsec'),GETPOST('echmonth'),GETPOST('echday'),GETPOST('echyear'));
186
-    $dateperiod=dol_mktime(GETPOST('periodhour'),GETPOST('periodmin'),GETPOST('periodsec'),GETPOST('periodmonth'),GETPOST('periodday'),GETPOST('periodyear'));
187
-    $amount=price2num(GETPOST('amount'));
188
-
189
-    if (! $dateech)
190
-    {
191
-        setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateDue")), null, 'errors');
192
-        $action = 'edit';
193
-    }
194
-    elseif (! $dateperiod)
195
-    {
196
-        setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")), null, 'errors');
197
-        $action = 'edit';
198
-    }
199
-    elseif (empty($amount))
200
-    {
201
-        setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
202
-        $action = 'edit';
203
-    }
185
+	$dateech=dol_mktime(GETPOST('echhour'),GETPOST('echmin'),GETPOST('echsec'),GETPOST('echmonth'),GETPOST('echday'),GETPOST('echyear'));
186
+	$dateperiod=dol_mktime(GETPOST('periodhour'),GETPOST('periodmin'),GETPOST('periodsec'),GETPOST('periodmonth'),GETPOST('periodday'),GETPOST('periodyear'));
187
+	$amount=price2num(GETPOST('amount'));
188
+
189
+	if (! $dateech)
190
+	{
191
+		setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateDue")), null, 'errors');
192
+		$action = 'edit';
193
+	}
194
+	elseif (! $dateperiod)
195
+	{
196
+		setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")), null, 'errors');
197
+		$action = 'edit';
198
+	}
199
+	elseif (empty($amount))
200
+	{
201
+		setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
202
+		$action = 'edit';
203
+	}
204 204
 	elseif (! is_numeric($amount))
205 205
 	{
206 206
 		setEventMessages($langs->trans("ErrorFieldMustBeANumeric",$langs->transnoentities("Amount")), null, 'errors');
207 207
 		$action = 'create';
208 208
 	}
209
-    else
209
+	else
210 210
 	{
211
-        $result=$object->fetch($id);
211
+		$result=$object->fetch($id);
212 212
 
213
-        $object->date_ech	= $dateech;
214
-        $object->periode	= $dateperiod;
215
-        $object->amount		= price2num($amount);
213
+		$object->date_ech	= $dateech;
214
+		$object->periode	= $dateperiod;
215
+		$object->amount		= price2num($amount);
216 216
 
217
-        $result=$object->update($user);
218
-        if ($result <= 0)
219
-        {
220
-            setEventMessages($object->error, $object->errors, 'errors');
221
-        }
217
+		$result=$object->update($user);
218
+		if ($result <= 0)
219
+		{
220
+			setEventMessages($object->error, $object->errors, 'errors');
221
+		}
222 222
 	}
223 223
 }
224 224
 
@@ -293,51 +293,51 @@  discard block
 block discarded – undo
293 293
 {
294 294
 	print load_fiche_titre($langs->trans("NewSocialContribution"));
295 295
 
296
-    $var=false;
296
+	$var=false;
297 297
 
298
-    print '<form name="charge" method="post" action="'.$_SERVER["PHP_SELF"].'">';
299
-    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
300
-    print '<input type="hidden" name="action" value="add">';
298
+	print '<form name="charge" method="post" action="'.$_SERVER["PHP_SELF"].'">';
299
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
300
+	print '<input type="hidden" name="action" value="add">';
301 301
 
302
-    dol_fiche_head();
302
+	dol_fiche_head();
303 303
 
304 304
 	print '<table class="border" width="100%">';
305 305
 
306
-    // Label
307
-    print "<tr>";
308
-    print '<td class="titlefieldcreate fieldrequired">';
309
-    print $langs->trans("Label");
310
-    print '</td>';
311
-    print '<td><input type="text" size="34" name="label" class="flat" value="'.dol_escape_htmltag(GETPOST('label','alpha')).'" autofocus></td>';
312
-    print '</tr>';
313
-    print '<tr>';
314
-
315
-    // Type
316
-    print '<td class="fieldrequired">';
317
-    print $langs->trans("Type");
318
-    print '</td>';
319
-    print '<td>';
320
-    $formsocialcontrib->select_type_socialcontrib(GETPOST("actioncode",'alpha')?GETPOST("actioncode",'alpha'):'','actioncode',1);
321
-    print '</td>';
322
-    print '</tr>';
306
+	// Label
307
+	print "<tr>";
308
+	print '<td class="titlefieldcreate fieldrequired">';
309
+	print $langs->trans("Label");
310
+	print '</td>';
311
+	print '<td><input type="text" size="34" name="label" class="flat" value="'.dol_escape_htmltag(GETPOST('label','alpha')).'" autofocus></td>';
312
+	print '</tr>';
313
+	print '<tr>';
314
+
315
+	// Type
316
+	print '<td class="fieldrequired">';
317
+	print $langs->trans("Type");
318
+	print '</td>';
319
+	print '<td>';
320
+	$formsocialcontrib->select_type_socialcontrib(GETPOST("actioncode",'alpha')?GETPOST("actioncode",'alpha'):'','actioncode',1);
321
+	print '</td>';
322
+	print '</tr>';
323 323
 
324 324
 	// Date end period
325
-    print '<tr>';
326
-    print '<td class="fieldrequired">';
327
-    print $langs->trans("PeriodEndDate");
328
-    print '</td>';
325
+	print '<tr>';
326
+	print '<td class="fieldrequired">';
327
+	print $langs->trans("PeriodEndDate");
328
+	print '</td>';
329 329
    	print '<td>';
330
-    print $form->select_date(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1);
330
+	print $form->select_date(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1);
331 331
 	print '</td>';
332
-    print '</tr>';
332
+	print '</tr>';
333 333
 
334
-    // Amount
335
-    print '<tr>';
336
-    print '<td class="fieldrequired">';
337
-    print $langs->trans("Amount");
338
-    print '</td>';
334
+	// Amount
335
+	print '<tr>';
336
+	print '<td class="fieldrequired">';
337
+	print $langs->trans("Amount");
338
+	print '</td>';
339 339
 	print '<td><input type="text" size="6" name="amount" class="flat" value="'.dol_escape_htmltag(GETPOST('amount','alpha')).'"></td>';
340
-    print '</tr>';
340
+	print '</tr>';
341 341
 
342 342
 	// Project
343 343
 	if (! empty($conf->projet->enabled))
@@ -354,30 +354,30 @@  discard block
 block discarded – undo
354 354
 		print '</td></tr>';
355 355
 	}
356 356
 
357
-    // Payment Mode
358
-    print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">';
359
-    $form->select_types_paiements($mode_reglement_id, 'mode_reglement_id');
360
-    print '</td></tr>';
361
-
362
-    // Bank Account
363
-    if (! empty($conf->banque->enabled))
364
-    {
365
-        print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">';
366
-        $form->select_comptes($fk_account, 'fk_account', 0, '', 1);
367
-        print '</td></tr>';
368
-    }
369
-
370
-    // Date due
371
-    print '<tr>';
372
-    print '<td class="fieldrequired">';
373
-    print $langs->trans("DateDue");
374
-    print '</td>';
375
-    print '<td>';
376
-    print $form->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1);
357
+	// Payment Mode
358
+	print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">';
359
+	$form->select_types_paiements($mode_reglement_id, 'mode_reglement_id');
360
+	print '</td></tr>';
361
+
362
+	// Bank Account
363
+	if (! empty($conf->banque->enabled))
364
+	{
365
+		print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">';
366
+		$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
367
+		print '</td></tr>';
368
+	}
369
+
370
+	// Date due
371
+	print '<tr>';
372
+	print '<td class="fieldrequired">';
373
+	print $langs->trans("DateDue");
374
+	print '</td>';
375
+	print '<td>';
376
+	print $form->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1);
377 377
 	print '</td>';
378
-    print "</tr>\n";
378
+	print "</tr>\n";
379 379
 
380
-    print '</table>';
380
+	print '</table>';
381 381
 
382 382
 	dol_fiche_end();
383 383
 
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
388 388
 	print '</div>';
389 389
 
390
-    print '</form>';
390
+	print '</form>';
391 391
 }
392 392
 
393 393
 /* *************************************************************************** */
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 if ($id > 0)
399 399
 {
400 400
 	$object = new ChargeSociales($db);
401
-    $result=$object->fetch($id);
401
+	$result=$object->fetch($id);
402 402
 
403 403
 	if ($result > 0)
404 404
 	{
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 
415 415
 			);
416 416
 
417
-		    print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneTax'),$langs->trans('ConfirmCloneTax',$object->ref),'confirm_clone',$formclone,'yes');
417
+			print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneTax'),$langs->trans('ConfirmCloneTax',$object->ref),'confirm_clone',$formclone,'yes');
418 418
 		}
419 419
 
420 420
 		// Confirmation de la suppression de la charge
@@ -445,34 +445,34 @@  discard block
 block discarded – undo
445 445
 		// Project
446 446
 		if (! empty($conf->projet->enabled))
447 447
 		{
448
-		    $langs->load("projects");
449
-		    $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
450
-		    if ($user->rights->tax->charges->creer)
451
-		    {
452
-		        if ($action != 'classify')
453
-		            $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
454
-		            if ($action == 'classify') {
455
-		                //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
456
-		                $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
457
-		                $morehtmlref.='<input type="hidden" name="action" value="classin">';
458
-		                $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
459
-		                $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
460
-		                $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
461
-		                $morehtmlref.='</form>';
462
-		            } else {
463
-		                $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
464
-		            }
465
-		    } else {
466
-		        if (! empty($object->fk_project)) {
467
-		            $proj = new Project($db);
468
-		            $proj->fetch($object->fk_project);
469
-		            $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
470
-		            $morehtmlref.=$proj->ref;
471
-		            $morehtmlref.='</a>';
472
-		        } else {
473
-		            $morehtmlref.='';
474
-		        }
475
-		    }
448
+			$langs->load("projects");
449
+			$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
450
+			if ($user->rights->tax->charges->creer)
451
+			{
452
+				if ($action != 'classify')
453
+					$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
454
+					if ($action == 'classify') {
455
+						//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
456
+						$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
457
+						$morehtmlref.='<input type="hidden" name="action" value="classin">';
458
+						$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
459
+						$morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
460
+						$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
461
+						$morehtmlref.='</form>';
462
+					} else {
463
+						$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
464
+					}
465
+			} else {
466
+				if (! empty($object->fk_project)) {
467
+					$proj = new Project($db);
468
+					$proj->fetch($object->fk_project);
469
+					$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
470
+					$morehtmlref.=$proj->ref;
471
+					$morehtmlref.='</a>';
472
+				} else {
473
+					$morehtmlref.='';
474
+				}
475
+			}
476 476
 		}
477 477
 		$morehtmlref.='</div>';
478 478
 
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 		print '<tr><td class="titlefield">'.$langs->trans("Type")."</td><td>".$object->type_libelle."</td>";
493 493
 		print "</tr>";
494 494
 
495
-    	// Period end date
495
+		// Period end date
496 496
 		print "<tr><td>".$langs->trans("PeriodEndDate")."</td>";
497 497
 		print "<td>";
498 498
 		if ($action == 'edit')
@@ -517,51 +517,51 @@  discard block
 block discarded – undo
517 517
 		}
518 518
 
519 519
 		// Amount
520
-        if ($action == 'edit')
521
-        {
522
-            print '<tr><td>'.$langs->trans("AmountTTC")."</td><td>";
523
-            print '<input type="text" name="amount" size="12" class="flat" value="'.$object->amount.'">';
524
-            print "</td></tr>";
525
-        }
526
-        else {
527
-            print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
528
-        }
529
-
530
-        // Mode of payment
531
-        print '<tr><td>';
532
-        print '<table class="nobordernopadding" width="100%"><tr><td>';
533
-        print $langs->trans('PaymentMode');
534
-        print '</td>';
535
-        if ($action != 'editmode')
536
-            print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&amp;id=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>';
537
-        print '</tr></table>';
538
-        print '</td><td>';
539
-        if ($action == 'editmode') {
540
-            $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id');
541
-        } else {
542
-            $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none');
543
-        }
544
-        print '</td></tr>';
545
-
546
-        // Bank Account
547
-        if (! empty($conf->banque->enabled))
548
-        {
549
-            print '<tr><td class="nowrap">';
550
-            print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
551
-            print $langs->trans('BankAccount');
552
-            print '<td>';
553
-            if ($action != 'editbankaccount' && $user->rights->tax->charges->creer)
554
-                print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
555
-            print '</tr></table>';
556
-            print '</td><td>';
557
-            if ($action == 'editbankaccount') {
558
-                $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
559
-            } else {
560
-                $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
561
-            }
562
-            print '</td>';
563
-            print '</tr>';
564
-        }
520
+		if ($action == 'edit')
521
+		{
522
+			print '<tr><td>'.$langs->trans("AmountTTC")."</td><td>";
523
+			print '<input type="text" name="amount" size="12" class="flat" value="'.$object->amount.'">';
524
+			print "</td></tr>";
525
+		}
526
+		else {
527
+			print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
528
+		}
529
+
530
+		// Mode of payment
531
+		print '<tr><td>';
532
+		print '<table class="nobordernopadding" width="100%"><tr><td>';
533
+		print $langs->trans('PaymentMode');
534
+		print '</td>';
535
+		if ($action != 'editmode')
536
+			print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&amp;id=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>';
537
+		print '</tr></table>';
538
+		print '</td><td>';
539
+		if ($action == 'editmode') {
540
+			$form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id');
541
+		} else {
542
+			$form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none');
543
+		}
544
+		print '</td></tr>';
545
+
546
+		// Bank Account
547
+		if (! empty($conf->banque->enabled))
548
+		{
549
+			print '<tr><td class="nowrap">';
550
+			print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
551
+			print $langs->trans('BankAccount');
552
+			print '<td>';
553
+			if ($action != 'editbankaccount' && $user->rights->tax->charges->creer)
554
+				print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
555
+			print '</tr></table>';
556
+			print '</td><td>';
557
+			if ($action == 'editbankaccount') {
558
+				$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
559
+			} else {
560
+				$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
561
+			}
562
+			print '</td>';
563
+			print '</tr>';
564
+		}
565 565
 
566 566
 		print '</table>';
567 567
 
@@ -588,59 +588,59 @@  discard block
 block discarded – undo
588 588
 		$resql = $db->query($sql);
589 589
 		if ($resql)
590 590
 		{
591
-		    $totalpaye = 0;
592
-
593
-		    $num = $db->num_rows($resql);
594
-		    $i = 0; $total = 0;
595
-		    print '<table class="noborder paymenttable">';
596
-		    print '<tr class="liste_titre">';
597
-		    print '<td>'.$langs->trans("RefPayment").'</td>';
598
-		    print '<td>'.$langs->trans("Date").'</td>';
599
-		    print '<td>'.$langs->trans("Type").'</td>';
600
-		    print '<td align="right">'.$langs->trans("Amount").'</td>';
601
-		    print '</tr>';
602
-
603
-		    $var=true;
604
-            if ($num > 0)
605
-            {
606
-    		    while ($i < $num)
607
-    		    {
608
-    		        $objp = $db->fetch_object($resql);
609
-
610
-    		        print "<tr ".$bc[$var]."><td>";
611
-    		        print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>';
612
-    		        print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
613
-    		        $labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type;
614
-    		        print "<td>".$labeltype.' '.$objp->num_paiement."</td>\n";
615
-    		        print '<td align="right">'.price($objp->amount)."</td>\n";
616
-    		        print "</tr>";
617
-    		        $totalpaye += $objp->amount;
618
-    		        $i++;
619
-    		    }
620
-            }
621
-            else
622
-		    {
623
-
624
-		        print '<tr class="oddeven"><td colspan="'.$nbcols.'" class="opacitymedium">'.$langs->trans("None").'</td><td></td><td></td><td></td></tr>';
625
-		    }
626
-
627
-		    //if ($object->status == ChargeSociales::STATUS_DRAFT)
628
-		    //{
629
-		        print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\">".price($totalpaye)."</td></tr>\n";
630
-		        print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\">".price($object->amount)."</td></tr>\n";
631
-
632
-		        $resteapayer = $object->amount - $totalpaye;
633
-		        $cssforamountpaymentcomplete = 'amountpaymentcomplete';
634
-
635
-		        print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
636
-		        print '<td align="right"'.($resteapayer?' class="amountremaintopay"':(' class="'.$cssforamountpaymentcomplete.'"')).'>'.price($resteapayer)."</td></tr>\n";
637
-		    //}
638
-		    print "</table>";
639
-		    $db->free($resql);
591
+			$totalpaye = 0;
592
+
593
+			$num = $db->num_rows($resql);
594
+			$i = 0; $total = 0;
595
+			print '<table class="noborder paymenttable">';
596
+			print '<tr class="liste_titre">';
597
+			print '<td>'.$langs->trans("RefPayment").'</td>';
598
+			print '<td>'.$langs->trans("Date").'</td>';
599
+			print '<td>'.$langs->trans("Type").'</td>';
600
+			print '<td align="right">'.$langs->trans("Amount").'</td>';
601
+			print '</tr>';
602
+
603
+			$var=true;
604
+			if ($num > 0)
605
+			{
606
+				while ($i < $num)
607
+				{
608
+					$objp = $db->fetch_object($resql);
609
+
610
+					print "<tr ".$bc[$var]."><td>";
611
+					print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>';
612
+					print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
613
+					$labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type;
614
+					print "<td>".$labeltype.' '.$objp->num_paiement."</td>\n";
615
+					print '<td align="right">'.price($objp->amount)."</td>\n";
616
+					print "</tr>";
617
+					$totalpaye += $objp->amount;
618
+					$i++;
619
+				}
620
+			}
621
+			else
622
+			{
623
+
624
+				print '<tr class="oddeven"><td colspan="'.$nbcols.'" class="opacitymedium">'.$langs->trans("None").'</td><td></td><td></td><td></td></tr>';
625
+			}
626
+
627
+			//if ($object->status == ChargeSociales::STATUS_DRAFT)
628
+			//{
629
+				print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\">".price($totalpaye)."</td></tr>\n";
630
+				print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\">".price($object->amount)."</td></tr>\n";
631
+
632
+				$resteapayer = $object->amount - $totalpaye;
633
+				$cssforamountpaymentcomplete = 'amountpaymentcomplete';
634
+
635
+				print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
636
+				print '<td align="right"'.($resteapayer?' class="amountremaintopay"':(' class="'.$cssforamountpaymentcomplete.'"')).'>'.price($resteapayer)."</td></tr>\n";
637
+			//}
638
+			print "</table>";
639
+			$db->free($resql);
640 640
 		}
641 641
 		else
642 642
 		{
643
-		    dol_print_error($db);
643
+			dol_print_error($db);
644 644
 		}
645 645
 
646 646
 		print '</div>';
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
29 29
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php';
30 30
 require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
31
-if (! empty($conf->projet->enabled))
31
+if (!empty($conf->projet->enabled))
32 32
 {
33 33
 	require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
34 34
 	require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
@@ -37,15 +37,15 @@  discard block
 block discarded – undo
37 37
 $langs->load("compta");
38 38
 $langs->load("bills");
39 39
 
40
-$id=GETPOST('id','int');
41
-$action=GETPOST('action','aZ09');
42
-$confirm=GETPOST('confirm');
40
+$id = GETPOST('id', 'int');
41
+$action = GETPOST('action', 'aZ09');
42
+$confirm = GETPOST('confirm');
43 43
 $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
44 44
 
45 45
 // Security check
46
-$socid = GETPOST('socid','int');
47
-if ($user->societe_id) $socid=$user->societe_id;
48
-$result = restrictedArea($user, 'tax', $id, 'chargesociales','charges');
46
+$socid = GETPOST('socid', 'int');
47
+if ($user->societe_id) $socid = $user->societe_id;
48
+$result = restrictedArea($user, 'tax', $id, 'chargesociales', 'charges');
49 49
 
50 50
 $object = new ChargeSociales($db);
51 51
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         $result = $object->set_unpaid($user);
70 70
         if ($result > 0)
71 71
         {
72
-            header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
72
+            header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
73 73
             exit();
74 74
         } else {
75 75
             setEventMessages($object->error, $object->errors, 'errors');
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 // bank account
104 104
 if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) {
105 105
     $object->fetch($id);
106
-    $result=$object->setBankAccount(GETPOST('fk_account', 'int'));
106
+    $result = $object->setBankAccount(GETPOST('fk_account', 'int'));
107 107
     if ($result < 0) {
108 108
         setEventMessages($object->error, $object->errors, 'errors');
109 109
     }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 if ($action == 'confirm_delete' && $confirm == 'yes')
114 114
 {
115 115
 	$object->fetch($id);
116
-	$result=$object->delete($user);
116
+	$result = $object->delete($user);
117 117
 	if ($result > 0)
118 118
 	{
119 119
 		header("Location: index.php");
@@ -129,22 +129,22 @@  discard block
 block discarded – undo
129 129
 // Add social contribution
130 130
 if ($action == 'add' && $user->rights->tax->charges->creer)
131 131
 {
132
-	$dateech=dol_mktime(GETPOST('echhour'),GETPOST('echmin'),GETPOST('echsec'),GETPOST('echmonth'),GETPOST('echday'),GETPOST('echyear'));
133
-	$dateperiod=dol_mktime(GETPOST('periodhour'),GETPOST('periodmin'),GETPOST('periodsec'),GETPOST('periodmonth'),GETPOST('periodday'),GETPOST('periodyear'));
134
-    $amount=price2num(GETPOST('amount'));
135
-    $actioncode=GETPOST('actioncode');
132
+	$dateech = dol_mktime(GETPOST('echhour'), GETPOST('echmin'), GETPOST('echsec'), GETPOST('echmonth'), GETPOST('echday'), GETPOST('echyear'));
133
+	$dateperiod = dol_mktime(GETPOST('periodhour'), GETPOST('periodmin'), GETPOST('periodsec'), GETPOST('periodmonth'), GETPOST('periodday'), GETPOST('periodyear'));
134
+    $amount = price2num(GETPOST('amount'));
135
+    $actioncode = GETPOST('actioncode');
136 136
 
137
-	if (! $dateech)
137
+	if (!$dateech)
138 138
 	{
139 139
 		setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateDue")), null, 'errors');
140 140
 		$action = 'create';
141 141
 	}
142
-	elseif (! $dateperiod)
142
+	elseif (!$dateperiod)
143 143
 	{
144 144
 		setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")), null, 'errors');
145 145
 		$action = 'create';
146 146
 	}
147
-	elseif (! $actioncode > 0)
147
+	elseif (!$actioncode > 0)
148 148
 	{
149 149
 		setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors');
150 150
 		$action = 'create';
@@ -154,44 +154,44 @@  discard block
 block discarded – undo
154 154
 		setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
155 155
 		$action = 'create';
156 156
 	}
157
-	elseif (! is_numeric($amount))
157
+	elseif (!is_numeric($amount))
158 158
 	{
159
-		setEventMessages($langs->trans("ErrorFieldMustBeANumeric",$langs->transnoentities("Amount")), null, 'errors');
159
+		setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentities("Amount")), null, 'errors');
160 160
 		$action = 'create';
161 161
 	}
162 162
 	else
163 163
 	{
164
-		$object->type				= $actioncode;
165
-		$object->lib				= GETPOST('label');
166
-		$object->date_ech			= $dateech;
164
+		$object->type = $actioncode;
165
+		$object->lib = GETPOST('label');
166
+		$object->date_ech = $dateech;
167 167
 		$object->periode			= $dateperiod;
168 168
 		$object->amount				= $amount;
169
-        $object->mode_reglement_id	= GETPOST('mode_reglement_id');
170
-        $object->fk_account			= GETPOST('fk_account', 'int');
171
-		$object->fk_project			= GETPOST('fk_project');
169
+        $object->mode_reglement_id = GETPOST('mode_reglement_id');
170
+        $object->fk_account = GETPOST('fk_account', 'int');
171
+		$object->fk_project = GETPOST('fk_project');
172 172
 
173
-		$id=$object->create($user);
173
+		$id = $object->create($user);
174 174
 		if ($id <= 0)
175 175
 		{
176 176
 			setEventMessages($object->error, $object->errors, 'errors');
177
-			$action='create';
177
+			$action = 'create';
178 178
 		}
179 179
 	}
180 180
 }
181 181
 
182 182
 
183
-if ($action == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->creer)
183
+if ($action == 'update' && !$_POST["cancel"] && $user->rights->tax->charges->creer)
184 184
 {
185
-    $dateech=dol_mktime(GETPOST('echhour'),GETPOST('echmin'),GETPOST('echsec'),GETPOST('echmonth'),GETPOST('echday'),GETPOST('echyear'));
186
-    $dateperiod=dol_mktime(GETPOST('periodhour'),GETPOST('periodmin'),GETPOST('periodsec'),GETPOST('periodmonth'),GETPOST('periodday'),GETPOST('periodyear'));
187
-    $amount=price2num(GETPOST('amount'));
185
+    $dateech = dol_mktime(GETPOST('echhour'), GETPOST('echmin'), GETPOST('echsec'), GETPOST('echmonth'), GETPOST('echday'), GETPOST('echyear'));
186
+    $dateperiod = dol_mktime(GETPOST('periodhour'), GETPOST('periodmin'), GETPOST('periodsec'), GETPOST('periodmonth'), GETPOST('periodday'), GETPOST('periodyear'));
187
+    $amount = price2num(GETPOST('amount'));
188 188
 
189
-    if (! $dateech)
189
+    if (!$dateech)
190 190
     {
191 191
         setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateDue")), null, 'errors');
192 192
         $action = 'edit';
193 193
     }
194
-    elseif (! $dateperiod)
194
+    elseif (!$dateperiod)
195 195
     {
196 196
         setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")), null, 'errors');
197 197
         $action = 'edit';
@@ -201,20 +201,20 @@  discard block
 block discarded – undo
201 201
         setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
202 202
         $action = 'edit';
203 203
     }
204
-	elseif (! is_numeric($amount))
204
+	elseif (!is_numeric($amount))
205 205
 	{
206
-		setEventMessages($langs->trans("ErrorFieldMustBeANumeric",$langs->transnoentities("Amount")), null, 'errors');
206
+		setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentities("Amount")), null, 'errors');
207 207
 		$action = 'create';
208 208
 	}
209 209
     else
210 210
 	{
211
-        $result=$object->fetch($id);
211
+        $result = $object->fetch($id);
212 212
 
213
-        $object->date_ech	= $dateech;
213
+        $object->date_ech = $dateech;
214 214
         $object->periode	= $dateperiod;
215 215
         $object->amount		= price2num($amount);
216 216
 
217
-        $result=$object->update($user);
217
+        $result = $object->update($user);
218 218
         if ($result <= 0)
219 219
         {
220 220
             setEventMessages($object->error, $object->errors, 'errors');
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 }
224 224
 
225 225
 // Action clone object
226
-if ($action == 'confirm_clone' && $confirm != 'yes') { $action=''; }
226
+if ($action == 'confirm_clone' && $confirm != 'yes') { $action = ''; }
227 227
 
228 228
 if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->charges->creer))
229 229
 {
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 		$object->paye = 0;
239 239
 		$object->id = $object->ref = null;
240 240
 
241
-		if(GETPOST('clone_for_next_month') != '') {
241
+		if (GETPOST('clone_for_next_month') != '') {
242 242
 
243 243
 			$object->date_ech = strtotime('+1month', $object->date_ech);
244 244
 			$object->periode = strtotime('+1month', $object->periode);
@@ -257,17 +257,17 @@  discard block
 block discarded – undo
257 257
 			}
258 258
 			else
259 259
 			{
260
-				$id=$originalId;
260
+				$id = $originalId;
261 261
 				$db->rollback();
262 262
 
263
-				setEventMessages($object->error,$object->errors, 'errors');
263
+				setEventMessages($object->error, $object->errors, 'errors');
264 264
 			}
265 265
 		}
266 266
 	}
267 267
 	else
268 268
 	{
269 269
 		$db->rollback();
270
-		dol_print_error($db,$object->error);
270
+		dol_print_error($db, $object->error);
271 271
 	}
272 272
 }
273 273
 
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
 
282 282
 $form = new Form($db);
283 283
 $formsocialcontrib = new FormSocialContrib($db);
284
-if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
284
+if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
285 285
 
286
-$title = $langs->trans("SocialContribution") . ' - ' . $langs->trans("Card");
287
-$help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:M&oacute;dulo Impuestos y cargas sociales (IVA, impuestos)';
288
-llxHeader("",$title,$help_url);
286
+$title = $langs->trans("SocialContribution").' - '.$langs->trans("Card");
287
+$help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:M&oacute;dulo Impuestos y cargas sociales (IVA, impuestos)';
288
+llxHeader("", $title, $help_url);
289 289
 
290 290
 
291 291
 // Mode creation
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 {
294 294
 	print load_fiche_titre($langs->trans("NewSocialContribution"));
295 295
 
296
-    $var=false;
296
+    $var = false;
297 297
 
298 298
     print '<form name="charge" method="post" action="'.$_SERVER["PHP_SELF"].'">';
299 299
     print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
     print '<td class="titlefieldcreate fieldrequired">';
309 309
     print $langs->trans("Label");
310 310
     print '</td>';
311
-    print '<td><input type="text" size="34" name="label" class="flat" value="'.dol_escape_htmltag(GETPOST('label','alpha')).'" autofocus></td>';
311
+    print '<td><input type="text" size="34" name="label" class="flat" value="'.dol_escape_htmltag(GETPOST('label', 'alpha')).'" autofocus></td>';
312 312
     print '</tr>';
313 313
     print '<tr>';
314 314
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
     print $langs->trans("Type");
318 318
     print '</td>';
319 319
     print '<td>';
320
-    $formsocialcontrib->select_type_socialcontrib(GETPOST("actioncode",'alpha')?GETPOST("actioncode",'alpha'):'','actioncode',1);
320
+    $formsocialcontrib->select_type_socialcontrib(GETPOST("actioncode", 'alpha') ?GETPOST("actioncode", 'alpha') : '', 'actioncode', 1);
321 321
     print '</td>';
322 322
     print '</tr>';
323 323
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
     print $langs->trans("PeriodEndDate");
328 328
     print '</td>';
329 329
    	print '<td>';
330
-    print $form->select_date(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1);
330
+    print $form->select_date(!empty($dateperiod) ? $dateperiod : '-1', 'period', 0, 0, 0, 'charge', 1);
331 331
 	print '</td>';
332 332
     print '</tr>';
333 333
 
@@ -336,33 +336,33 @@  discard block
 block discarded – undo
336 336
     print '<td class="fieldrequired">';
337 337
     print $langs->trans("Amount");
338 338
     print '</td>';
339
-	print '<td><input type="text" size="6" name="amount" class="flat" value="'.dol_escape_htmltag(GETPOST('amount','alpha')).'"></td>';
339
+	print '<td><input type="text" size="6" name="amount" class="flat" value="'.dol_escape_htmltag(GETPOST('amount', 'alpha')).'"></td>';
340 340
     print '</tr>';
341 341
 
342 342
 	// Project
343
-	if (! empty($conf->projet->enabled))
343
+	if (!empty($conf->projet->enabled))
344 344
 	{
345
-		$formproject=new FormProjets($db);
345
+		$formproject = new FormProjets($db);
346 346
 
347 347
 		// Associated project
348 348
 		$langs->load("projects");
349 349
 
350 350
 		print '<tr><td>'.$langs->trans("Project").'</td><td>';
351 351
 
352
-		$numproject=$formproject->select_projects(-1, $projectid,'fk_project',0,0,1,1);
352
+		$numproject = $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1);
353 353
 
354 354
 		print '</td></tr>';
355 355
 	}
356 356
 
357 357
     // Payment Mode
358
-    print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">';
358
+    print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">';
359 359
     $form->select_types_paiements($mode_reglement_id, 'mode_reglement_id');
360 360
     print '</td></tr>';
361 361
 
362 362
     // Bank Account
363
-    if (! empty($conf->banque->enabled))
363
+    if (!empty($conf->banque->enabled))
364 364
     {
365
-        print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">';
365
+        print '<tr><td>'.$langs->trans('BankAccount').'</td><td colspan="2">';
366 366
         $form->select_comptes($fk_account, 'fk_account', 0, '', 1);
367 367
         print '</td></tr>';
368 368
     }
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
     print $langs->trans("DateDue");
374 374
     print '</td>';
375 375
     print '<td>';
376
-    print $form->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1);
376
+    print $form->select_date(!empty($dateech) ? $dateech : '-1', 'ech', 0, 0, 0, 'charge', 1);
377 377
 	print '</td>';
378 378
     print "</tr>\n";
379 379
 
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 	print '<div class="center">';
385 385
 	print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
386 386
 	print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
387
-	print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
387
+	print '<input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">';
388 388
 	print '</div>';
389 389
 
390 390
     print '</form>';
@@ -398,36 +398,36 @@  discard block
 block discarded – undo
398 398
 if ($id > 0)
399 399
 {
400 400
 	$object = new ChargeSociales($db);
401
-    $result=$object->fetch($id);
401
+    $result = $object->fetch($id);
402 402
 
403 403
 	if ($result > 0)
404 404
 	{
405
-		$head=tax_prepare_head($object);
405
+		$head = tax_prepare_head($object);
406 406
 
407 407
 		$totalpaye = $object->getSommePaiement();
408 408
 
409 409
 		// Clone confirmation
410 410
 		if ($action === 'clone')
411 411
 		{
412
-			$formclone=array(
413
-				array('type' => 'checkbox', 'name' => 'clone_for_next_month','label' => $langs->trans("CloneTaxForNextMonth"), 'value' => 1),
412
+			$formclone = array(
413
+				array('type' => 'checkbox', 'name' => 'clone_for_next_month', 'label' => $langs->trans("CloneTaxForNextMonth"), 'value' => 1),
414 414
 
415 415
 			);
416 416
 
417
-		    print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneTax'),$langs->trans('ConfirmCloneTax',$object->ref),'confirm_clone',$formclone,'yes');
417
+		    print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('CloneTax'), $langs->trans('ConfirmCloneTax', $object->ref), 'confirm_clone', $formclone, 'yes');
418 418
 		}
419 419
 
420 420
 		// Confirmation de la suppression de la charge
421 421
 		if ($action == 'paid')
422 422
 		{
423
-			$text=$langs->trans('ConfirmPaySocialContribution');
424
-			print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans('PaySocialContribution'),$text,"confirm_paid",'','',2);
423
+			$text = $langs->trans('ConfirmPaySocialContribution');
424
+			print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PaySocialContribution'), $text, "confirm_paid", '', '', 2);
425 425
 		}
426 426
 
427 427
 		if ($action == 'delete')
428 428
 		{
429
-			$text=$langs->trans('ConfirmDeleteSocialContribution');
430
-			print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('DeleteSocialContribution'),$text,'confirm_delete','','',2);
429
+			$text = $langs->trans('ConfirmDeleteSocialContribution');
430
+			print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteSocialContribution'), $text, 'confirm_delete', '', '', 2);
431 431
 		}
432 432
 
433 433
 		if ($action == 'edit')
@@ -438,47 +438,47 @@  discard block
 block discarded – undo
438 438
 
439 439
 		dol_fiche_head($head, 'card', $langs->trans("SocialContribution"), -1, 'bill');
440 440
 
441
-		$morehtmlref='<div class="refidno">';
441
+		$morehtmlref = '<div class="refidno">';
442 442
 		// Ref customer
443
-		$morehtmlref.=$form->editfieldkey("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1);
444
-		$morehtmlref.=$form->editfieldval("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1);
443
+		$morehtmlref .= $form->editfieldkey("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1);
444
+		$morehtmlref .= $form->editfieldval("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1);
445 445
 		// Project
446
-		if (! empty($conf->projet->enabled))
446
+		if (!empty($conf->projet->enabled))
447 447
 		{
448 448
 		    $langs->load("projects");
449
-		    $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
449
+		    $morehtmlref .= '<br>'.$langs->trans('Project').' ';
450 450
 		    if ($user->rights->tax->charges->creer)
451 451
 		    {
452 452
 		        if ($action != 'classify')
453
-		            $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
453
+		            $morehtmlref .= '<a href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
454 454
 		            if ($action == 'classify') {
455 455
 		                //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
456
-		                $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
457
-		                $morehtmlref.='<input type="hidden" name="action" value="classin">';
458
-		                $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
459
-		                $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
460
-		                $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
461
-		                $morehtmlref.='</form>';
456
+		                $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
457
+		                $morehtmlref .= '<input type="hidden" name="action" value="classin">';
458
+		                $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
459
+		                $morehtmlref .= $formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
460
+		                $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
461
+		                $morehtmlref .= '</form>';
462 462
 		            } else {
463
-		                $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
463
+		                $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
464 464
 		            }
465 465
 		    } else {
466
-		        if (! empty($object->fk_project)) {
466
+		        if (!empty($object->fk_project)) {
467 467
 		            $proj = new Project($db);
468 468
 		            $proj->fetch($object->fk_project);
469
-		            $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
470
-		            $morehtmlref.=$proj->ref;
471
-		            $morehtmlref.='</a>';
469
+		            $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
470
+		            $morehtmlref .= $proj->ref;
471
+		            $morehtmlref .= '</a>';
472 472
 		        } else {
473
-		            $morehtmlref.='';
473
+		            $morehtmlref .= '';
474 474
 		        }
475 475
 		    }
476 476
 		}
477
-		$morehtmlref.='</div>';
477
+		$morehtmlref .= '</div>';
478 478
 
479
-		$linkback = '<a href="' . DOL_URL_ROOT . '/compta/sociales/index.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
479
+		$linkback = '<a href="'.DOL_URL_ROOT.'/compta/sociales/index.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
480 480
 
481
-		$object->totalpaye = $totalpaye;   // To give a chance to dol_banner_tab to use already paid amount to show correct status
481
+		$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status
482 482
 
483 483
 		dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
484 484
 
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 		}
502 502
 		else
503 503
 		{
504
-			print dol_print_date($object->periode,"day");
504
+			print dol_print_date($object->periode, "day");
505 505
 		}
506 506
 		print "</td></tr>";
507 507
 
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 			print "</td></tr>";
514 514
 		}
515 515
 		else {
516
-			print "<tr><td>".$langs->trans("DateDue")."</td><td>".dol_print_date($object->date_ech,'day')."</td></tr>";
516
+			print "<tr><td>".$langs->trans("DateDue")."</td><td>".dol_print_date($object->date_ech, 'day')."</td></tr>";
517 517
 		}
518 518
 
519 519
 		// Amount
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
             print "</td></tr>";
525 525
         }
526 526
         else {
527
-            print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
527
+            print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
528 528
         }
529 529
 
530 530
         // Mode of payment
@@ -533,25 +533,25 @@  discard block
 block discarded – undo
533 533
         print $langs->trans('PaymentMode');
534 534
         print '</td>';
535 535
         if ($action != 'editmode')
536
-            print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&amp;id=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>';
536
+            print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>';
537 537
         print '</tr></table>';
538 538
         print '</td><td>';
539 539
         if ($action == 'editmode') {
540
-            $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id');
540
+            $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id');
541 541
         } else {
542
-            $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none');
542
+            $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none');
543 543
         }
544 544
         print '</td></tr>';
545 545
 
546 546
         // Bank Account
547
-        if (! empty($conf->banque->enabled))
547
+        if (!empty($conf->banque->enabled))
548 548
         {
549 549
             print '<tr><td class="nowrap">';
550 550
             print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
551 551
             print $langs->trans('BankAccount');
552 552
             print '<td>';
553 553
             if ($action != 'editbankaccount' && $user->rights->tax->charges->creer)
554
-                print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
554
+                print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>';
555 555
             print '</tr></table>';
556 556
             print '</td><td>';
557 557
             if ($action == 'editbankaccount') {
@@ -573,16 +573,16 @@  discard block
 block discarded – undo
573 573
 		 * Payments
574 574
 		 */
575 575
 		$sql = "SELECT p.rowid, p.num_paiement, datep as dp, p.amount,";
576
-		$sql.= "c.code as type_code,c.libelle as paiement_type";
577
-		$sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p";
578
-		$sql.= ", ".MAIN_DB_PREFIX."c_paiement as c ";
579
-		$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
580
-		$sql.= " WHERE p.fk_charge = ".$id;
581
-		$sql.= " AND p.fk_charge = cs.rowid";
582
-		$sql.= " AND cs.entity = ".$conf->entity;
583
-		$sql.= " AND p.fk_typepaiement = c.id";
584
-		$sql.= " AND c.entity = " . getEntity('c_paiement');
585
-		$sql.= " ORDER BY dp DESC";
576
+		$sql .= "c.code as type_code,c.libelle as paiement_type";
577
+		$sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as p";
578
+		$sql .= ", ".MAIN_DB_PREFIX."c_paiement as c ";
579
+		$sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
580
+		$sql .= " WHERE p.fk_charge = ".$id;
581
+		$sql .= " AND p.fk_charge = cs.rowid";
582
+		$sql .= " AND cs.entity = ".$conf->entity;
583
+		$sql .= " AND p.fk_typepaiement = c.id";
584
+		$sql .= " AND c.entity = ".getEntity('c_paiement');
585
+		$sql .= " ORDER BY dp DESC";
586 586
 
587 587
 		//print $sql;
588 588
 		$resql = $db->query($sql);
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 		    print '<td align="right">'.$langs->trans("Amount").'</td>';
601 601
 		    print '</tr>';
602 602
 
603
-		    $var=true;
603
+		    $var = true;
604 604
             if ($num > 0)
605 605
             {
606 606
     		    while ($i < $num)
@@ -608,9 +608,9 @@  discard block
 block discarded – undo
608 608
     		        $objp = $db->fetch_object($resql);
609 609
 
610 610
     		        print "<tr ".$bc[$var]."><td>";
611
-    		        print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>';
612
-    		        print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
613
-    		        $labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type;
611
+    		        print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.'</a></td>';
612
+    		        print '<td>'.dol_print_date($db->jdate($objp->dp), 'day')."</td>\n";
613
+    		        $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type;
614 614
     		        print "<td>".$labeltype.' '.$objp->num_paiement."</td>\n";
615 615
     		        print '<td align="right">'.price($objp->amount)."</td>\n";
616 616
     		        print "</tr>";
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 		        $cssforamountpaymentcomplete = 'amountpaymentcomplete';
634 634
 
635 635
 		        print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
636
-		        print '<td align="right"'.($resteapayer?' class="amountremaintopay"':(' class="'.$cssforamountpaymentcomplete.'"')).'>'.price($resteapayer)."</td></tr>\n";
636
+		        print '<td align="right"'.($resteapayer ? ' class="amountremaintopay"' : (' class="'.$cssforamountpaymentcomplete.'"')).'>'.price($resteapayer)."</td></tr>\n";
637 637
 		    //}
638 638
 		    print "</table>";
639 639
 		    $db->free($resql);
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 			// Reopen
675 675
 			if ($object->paye && $user->rights->tax->charges->creer)
676 676
 			{
677
-				print "<a class=\"butAction\" href=\"".dol_buildpath("/compta/sociales/card.php",1). "?id=$object->id&amp;action=reopen\">".$langs->trans("ReOpen")."</a>";
677
+				print "<a class=\"butAction\" href=\"".dol_buildpath("/compta/sociales/card.php", 1)."?id=$object->id&amp;action=reopen\">".$langs->trans("ReOpen")."</a>";
678 678
 			}
679 679
 
680 680
 			// Edit
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 			}
691 691
 
692 692
 			// Classify 'paid'
693
-			if ($object->paye == 0 && round($resteapayer) <=0 && $user->rights->tax->charges->creer)
693
+			if ($object->paye == 0 && round($resteapayer) <= 0 && $user->rights->tax->charges->creer)
694 694
 			{
695 695
 				print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/sociales/card.php?id=$object->id&amp;action=paid\">".$langs->trans("ClassifyPaid")."</a>";
696 696
 			}
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 			// Clone
699 699
 			if ($user->rights->tax->charges->creer)
700 700
 			{
701
-				print "<a class=\"butAction\" href=\"".dol_buildpath("/compta/sociales/card.php",1). "?id=$object->id&amp;action=clone\">".$langs->trans("ToClone")."</a>";
701
+				print "<a class=\"butAction\" href=\"".dol_buildpath("/compta/sociales/card.php", 1)."?id=$object->id&amp;action=clone\">".$langs->trans("ToClone")."</a>";
702 702
 			}
703 703
 
704 704
 			// Delete
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 	else
714 714
 	{
715 715
 		/* Social contribution not found */
716
-		dol_print_error('',$object->error);
716
+		dol_print_error('', $object->error);
717 717
 	}
718 718
 }
719 719
 
Please login to merge, or discard this patch.
htdocs/compta/facture/stats/index.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
 require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
30 30
 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php';
31 31
 
32
-$WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
33
-$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
32
+$WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
33
+$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
34 34
 
35
-$mode=GETPOST("mode")?GETPOST("mode"):'customer';
36
-if ($mode == 'customer' && ! $user->rights->facture->lire) accessforbidden();
37
-if ($mode == 'supplier' && ! $user->rights->fournisseur->facture->lire) accessforbidden();
35
+$mode = GETPOST("mode") ?GETPOST("mode") : 'customer';
36
+if ($mode == 'customer' && !$user->rights->facture->lire) accessforbidden();
37
+if ($mode == 'supplier' && !$user->rights->fournisseur->facture->lire) accessforbidden();
38 38
 
39
-$object_status=GETPOST('object_status');
39
+$object_status = GETPOST('object_status');
40 40
 
41
-$userid=GETPOST('userid','int');
42
-$socid=GETPOST('socid','int');
41
+$userid = GETPOST('userid', 'int');
42
+$socid = GETPOST('socid', 'int');
43 43
 // Security check
44 44
 if ($user->societe_id > 0)
45 45
 {
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
     $socid = $user->societe_id;
48 48
 }
49 49
 
50
-$nowyear=strftime("%Y", dol_now());
51
-$year = GETPOST('year')>0?GETPOST('year'):$nowyear;
50
+$nowyear = strftime("%Y", dol_now());
51
+$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear;
52 52
 //$startyear=$year-2;
53
-$startyear=$year-1;
54
-$endyear=$year;
53
+$startyear = $year - 1;
54
+$endyear = $year;
55 55
 
56 56
 
57 57
 /*
@@ -62,26 +62,26 @@  discard block
 block discarded – undo
62 62
 $langs->load('companies');
63 63
 $langs->load('other');
64 64
 
65
-$form=new Form($db);
65
+$form = new Form($db);
66 66
 
67 67
 llxHeader();
68 68
 
69 69
 if ($mode == 'customer')
70 70
 {
71
-	$title=$langs->trans("BillsStatistics");
72
-	$dir=$conf->facture->dir_temp;
71
+	$title = $langs->trans("BillsStatistics");
72
+	$dir = $conf->facture->dir_temp;
73 73
 }
74 74
 if ($mode == 'supplier')
75 75
 {
76
-	$title=$langs->trans("BillsStatisticsSuppliers");
77
-	$dir=$conf->fournisseur->facture->dir_temp;
76
+	$title = $langs->trans("BillsStatisticsSuppliers");
77
+	$dir = $conf->fournisseur->facture->dir_temp;
78 78
 }
79 79
 
80 80
 print load_fiche_titre($title, $mesg, 'title_accountancy.png');
81 81
 
82 82
 dol_mkdir($dir);
83 83
 
84
-$stats = new FactureStats($db, $socid, $mode, ($userid>0?$userid:0));
84
+$stats = new FactureStats($db, $socid, $mode, ($userid > 0 ? $userid : 0));
85 85
 if ($mode == 'customer')
86 86
 {
87 87
     if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND f.fk_statut IN ('.$db->escape($object_status).')';
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
 // Build graphic number of object
95 95
 // $data = array(array('Lib',val1,val2,val3),...)
96
-$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
96
+$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
97 97
 //var_dump($data);
98 98
 
99 99
 $filenamenb = $dir."/invoicesnbinyear-".$year.".png";
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
 
103 103
 $px1 = new DolGraph();
104 104
 $mesg = $px1->isGraphKo();
105
-if (! $mesg)
105
+if (!$mesg)
106 106
 {
107 107
 	$px1->SetData($data);
108 108
 	$px1->SetPrecisionY(0);
109
-	$i=$startyear;$legend=array();
109
+	$i = $startyear; $legend = array();
110 110
 	while ($i <= $endyear)
111 111
 	{
112
-		$legend[]=$i;
112
+		$legend[] = $i;
113 113
 		$i++;
114 114
 	}
115 115
 	$px1->SetLegend($legend);
@@ -120,14 +120,14 @@  discard block
 block discarded – undo
120 120
 	$px1->SetShading(3);
121 121
 	$px1->SetHorizTickIncrement(1);
122 122
 	$px1->SetPrecisionY(0);
123
-	$px1->mode='depth';
123
+	$px1->mode = 'depth';
124 124
 	$px1->SetTitle($langs->trans("NumberOfBillsByMonth"));
125 125
 
126
-	$px1->draw($filenamenb,$fileurlnb);
126
+	$px1->draw($filenamenb, $fileurlnb);
127 127
 }
128 128
 
129 129
 // Build graphic amount of object
130
-$data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
130
+$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
131 131
 //var_dump($data);
132 132
 // $data = array(array('Lib',val1,val2,val3),...)
133 133
 
@@ -137,28 +137,28 @@  discard block
 block discarded – undo
137 137
 
138 138
 $px2 = new DolGraph();
139 139
 $mesg = $px2->isGraphKo();
140
-if (! $mesg)
140
+if (!$mesg)
141 141
 {
142 142
 	$px2->SetData($data);
143
-	$i=$startyear;$legend=array();
143
+	$i = $startyear; $legend = array();
144 144
 	while ($i <= $endyear)
145 145
 	{
146
-		$legend[]=$i;
146
+		$legend[] = $i;
147 147
 		$i++;
148 148
 	}
149 149
 	$px2->SetLegend($legend);
150 150
 	$px2->SetMaxValue($px2->GetCeilMaxValue());
151
-	$px2->SetMinValue(min(0,$px2->GetFloorMinValue()));
151
+	$px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
152 152
 	$px2->SetWidth($WIDTH);
153 153
 	$px2->SetHeight($HEIGHT);
154 154
 	$px2->SetYLabel($langs->trans("AmountOfBills"));
155 155
 	$px2->SetShading(3);
156 156
 	$px2->SetHorizTickIncrement(1);
157 157
 	$px2->SetPrecisionY(0);
158
-	$px2->mode='depth';
158
+	$px2->mode = 'depth';
159 159
 	$px2->SetTitle($langs->trans("AmountOfBillsByMonthHT"));
160 160
 
161
-	$px2->draw($filenameamount,$fileurlamount);
161
+	$px2->draw($filenameamount, $fileurlamount);
162 162
 }
163 163
 
164 164
 
@@ -179,13 +179,13 @@  discard block
 block discarded – undo
179 179
 
180 180
 $px3 = new DolGraph();
181 181
 $mesg = $px3->isGraphKo();
182
-if (! $mesg)
182
+if (!$mesg)
183 183
 {
184 184
     $px3->SetData($data);
185
-    $i = $startyear;$legend=array();
185
+    $i = $startyear; $legend = array();
186 186
     while ($i <= $endyear)
187 187
     {
188
-        $legend[]=$i;
188
+        $legend[] = $i;
189 189
         $i++;
190 190
     }
191 191
     $px3->SetLegend($legend);
@@ -197,37 +197,37 @@  discard block
 block discarded – undo
197 197
     $px3->SetShading(3);
198 198
     $px3->SetHorizTickIncrement(1);
199 199
     $px3->SetPrecisionY(0);
200
-    $px3->mode='depth';
200
+    $px3->mode = 'depth';
201 201
     $px3->SetTitle($langs->trans("AmountAverage"));
202 202
 
203
-    $px3->draw($filename_avg,$fileurl_avg);
203
+    $px3->draw($filename_avg, $fileurl_avg);
204 204
 }
205 205
 
206 206
 
207 207
 // Show array
208 208
 $data = $stats->getAllByYear();
209
-$arrayyears=array();
210
-foreach($data as $val) {
211
-    $arrayyears[$val['year']]=$val['year'];
209
+$arrayyears = array();
210
+foreach ($data as $val) {
211
+    $arrayyears[$val['year']] = $val['year'];
212 212
 }
213
-if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
213
+if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;
214 214
 
215 215
 
216
-$h=0;
216
+$h = 0;
217 217
 $head = array();
218
-$head[$h][0] = DOL_URL_ROOT . '/compta/facture/stats/index.php?mode='.$mode;
218
+$head[$h][0] = DOL_URL_ROOT.'/compta/facture/stats/index.php?mode='.$mode;
219 219
 $head[$h][1] = $langs->trans("ByMonthYear");
220 220
 $head[$h][2] = 'byyear';
221 221
 $h++;
222 222
 
223
-if ($mode == 'customer') $type='invoice_stats';
224
-if ($mode == 'supplier') $type='supplier_invoice_stats';
223
+if ($mode == 'customer') $type = 'invoice_stats';
224
+if ($mode == 'supplier') $type = 'supplier_invoice_stats';
225 225
 
226
-complete_head_from_modules($conf,$langs,null,$head,$h,$type);
226
+complete_head_from_modules($conf, $langs, null, $head, $h, $type);
227 227
 
228 228
 dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1);
229 229
 
230
-$tmp_companies = $form->select_thirdparty_list($socid,'socid',$filter,1, 0, 0, array(), '', 1);
230
+$tmp_companies = $form->select_thirdparty_list($socid, 'socid', $filter, 1, 0, 0, array(), '', 1);
231 231
 //Array passed as an argument to Form::selectarray to build a proper select input
232 232
 $companies = array();
233 233
 
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
 	print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
248 248
 	// Company
249 249
 	print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
250
-	if ($mode == 'customer') $filter='s.client in (1,2,3)';
251
-	if ($mode == 'supplier') $filter='s.fournisseur = 1';
250
+	if ($mode == 'customer') $filter = 's.client in (1,2,3)';
251
+	if ($mode == 'supplier') $filter = 's.fournisseur = 1';
252 252
 	print $form->selectarray('socid', $companies, $socid, 1, 0, 0, 'style="width: 95%"', 0, 0, 0, '', '', 1);
253 253
 	print '</td></tr>';
254 254
 	// User
@@ -259,21 +259,21 @@  discard block
 block discarded – undo
259 259
 	print '<tr><td align="left">'.$langs->trans("Status").'</td><td align="left">';
260 260
 	if ($mode == 'customer')
261 261
 	{
262
-	    $liststatus=array('0'=>$langs->trans("BillStatusDraft"), '1'=>$langs->trans("BillStatusNotPaid"), '2'=>$langs->trans("BillStatusPaid"), '3'=>$langs->trans("BillStatusCanceled"));
262
+	    $liststatus = array('0'=>$langs->trans("BillStatusDraft"), '1'=>$langs->trans("BillStatusNotPaid"), '2'=>$langs->trans("BillStatusPaid"), '3'=>$langs->trans("BillStatusCanceled"));
263 263
 	    print $form->selectarray('object_status', $liststatus, $object_status, 1);
264 264
 	}
265 265
 	if ($mode == 'supplier')
266 266
 	{
267
-	    $liststatus=array('0'=>$langs->trans("BillStatusDraft"),'1'=>$langs->trans("BillStatusNotPaid"), '2'=>$langs->trans("BillStatusPaid"));
267
+	    $liststatus = array('0'=>$langs->trans("BillStatusDraft"), '1'=>$langs->trans("BillStatusNotPaid"), '2'=>$langs->trans("BillStatusPaid"));
268 268
 	    print $form->selectarray('object_status', $liststatus, $object_status, 1);
269 269
 	}
270 270
 	print '</td></tr>';
271 271
 	// Year
272 272
 	print '<tr><td>'.$langs->trans("Year").'</td><td>';
273
-	if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year;
274
-	if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear;
273
+	if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
274
+	if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;
275 275
 	arsort($arrayyears);
276
-	print $form->selectarray('year',$arrayyears,$year,0);
276
+	print $form->selectarray('year', $arrayyears, $year, 0);
277 277
 	print '</td></tr>';
278 278
 	print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></td></tr>';
279 279
 	print '</table>';
@@ -292,16 +292,16 @@  discard block
 block discarded – undo
292 292
 print '<td align="right">%</td>';
293 293
 print '</tr>';
294 294
 
295
-$oldyear=0;
295
+$oldyear = 0;
296 296
 foreach ($data as $val)
297 297
 {
298 298
 	$year = $val['year'];
299
-	while ($year && $oldyear > $year+1)
299
+	while ($year && $oldyear > $year + 1)
300 300
 	{	// If we have empty year
301 301
 		$oldyear--;
302 302
 
303 303
 		print '<tr class="oddeven" height="24">';
304
-		print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.'&amp;mode='.$mode.($socid>0?'&socid='.$socid:'').($userid>0?'&userid='.$userid:'').'">'.$oldyear.'</a></td>';
304
+		print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.'&amp;mode='.$mode.($socid > 0 ? '&socid='.$socid : '').($userid > 0 ? '&userid='.$userid : '').'">'.$oldyear.'</a></td>';
305 305
 		print '<td align="right">0</td>';
306 306
 		print '<td align="right"></td>';
307 307
 		print '<td align="right">0</td>';
@@ -312,15 +312,15 @@  discard block
 block discarded – undo
312 312
 	}
313 313
 
314 314
 	print '<tr class="oddeven" height="24">';
315
-	print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&amp;mode='.$mode.($socid>0?'&socid='.$socid:'').($userid>0?'&userid='.$userid:'').'">'.$year.'</a></td>';
315
+	print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&amp;mode='.$mode.($socid > 0 ? '&socid='.$socid : '').($userid > 0 ? '&userid='.$userid : '').'">'.$year.'</a></td>';
316 316
 	print '<td align="right">'.$val['nb'].'</td>';
317
-	print '<td align="right" style="'.(($val['nb_diff'] >= 0) ? 'color: green;':'color: red;').'">'.round($val['nb_diff']).'</td>';
318
-	print '<td align="right">'.price(price2num($val['total'],'MT'),1).'</td>';
319
-	print '<td align="right" style="'.(($val['total_diff'] >= 0) ? 'color: green;':'color: red;').'">'.round($val['total_diff']).'</td>';
320
-	print '<td align="right">'.price(price2num($val['avg'],'MT'),1).'</td>';
321
-	print '<td align="right" style="'.(($val['avg_diff'] >= 0) ? 'color: green;':'color: red;').'">'.round($val['avg_diff']).'</td>';
317
+	print '<td align="right" style="'.(($val['nb_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.round($val['nb_diff']).'</td>';
318
+	print '<td align="right">'.price(price2num($val['total'], 'MT'), 1).'</td>';
319
+	print '<td align="right" style="'.(($val['total_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.round($val['total_diff']).'</td>';
320
+	print '<td align="right">'.price(price2num($val['avg'], 'MT'), 1).'</td>';
321
+	print '<td align="right" style="'.(($val['avg_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.round($val['avg_diff']).'</td>';
322 322
 	print '</tr>';
323
-	$oldyear=$year;
323
+	$oldyear = $year;
324 324
 }
325 325
 
326 326
 print '</table>';
Please login to merge, or discard this patch.
htdocs/compta/bank/card.php 2 patches
Indentation   +279 added lines, -279 removed lines patch added patch discarded remove patch
@@ -72,204 +72,204 @@  discard block
 block discarded – undo
72 72
 
73 73
 if ($action == 'add')
74 74
 {
75
-    $error=0;
75
+	$error=0;
76 76
 
77
-    $db->begin();
77
+	$db->begin();
78 78
 
79
-    // Create account
80
-    $object = new Account($db);
79
+	// Create account
80
+	$object = new Account($db);
81 81
 
82
-    $object->ref           = dol_sanitizeFileName(trim($_POST["ref"]));
83
-    $object->label         = trim($_POST["label"]);
84
-    $object->courant       = $_POST["type"];
85
-    $object->clos          = $_POST["clos"];
86
-    $object->rappro        = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1;
87
-    $object->url           = $_POST["url"];
82
+	$object->ref           = dol_sanitizeFileName(trim($_POST["ref"]));
83
+	$object->label         = trim($_POST["label"]);
84
+	$object->courant       = $_POST["type"];
85
+	$object->clos          = $_POST["clos"];
86
+	$object->rappro        = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1;
87
+	$object->url           = $_POST["url"];
88 88
 
89 89
 	$object->bank            = trim($_POST["bank"]);
90
-    $object->code_banque     = trim($_POST["code_banque"]);
91
-    $object->code_guichet    = trim($_POST["code_guichet"]);
92
-    $object->number          = trim($_POST["number"]);
93
-    $object->cle_rib         = trim($_POST["cle_rib"]);
94
-    $object->bic             = trim($_POST["bic"]);
95
-    $object->iban            = trim($_POST["iban"]);
96
-    $object->domiciliation   = trim($_POST["domiciliation"]);
90
+	$object->code_banque     = trim($_POST["code_banque"]);
91
+	$object->code_guichet    = trim($_POST["code_guichet"]);
92
+	$object->number          = trim($_POST["number"]);
93
+	$object->cle_rib         = trim($_POST["cle_rib"]);
94
+	$object->bic             = trim($_POST["bic"]);
95
+	$object->iban            = trim($_POST["iban"]);
96
+	$object->domiciliation   = trim($_POST["domiciliation"]);
97 97
 
98
-    $object->proprio 	     = trim($_POST["proprio"]);
99
-    $object->owner_address   = trim($_POST["owner_address"]);
98
+	$object->proprio 	     = trim($_POST["proprio"]);
99
+	$object->owner_address   = trim($_POST["owner_address"]);
100 100
 
101 101
 	$account_number 		 = GETPOST('account_number','alpha');
102 102
 	if ($account_number <= 0) { $object->account_number = ''; } else { $object->account_number = $account_number; }
103 103
 	$fk_accountancy_journal  = GETPOST('fk_accountancy_journal','int');
104 104
 	if ($fk_accountancy_journal <= 0) { $object->fk_accountancy_journal = ''; } else { $object->fk_accountancy_journal = $fk_accountancy_journal; }
105 105
 
106
-    $object->solde           = $_POST["solde"];
107
-    $object->date_solde      = dol_mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
108
-
109
-    $object->currency_code   = trim($_POST["account_currency_code"]);
110
-
111
-    $object->state_id  	     = $_POST["account_state_id"];
112
-    $object->country_id      = $_POST["account_country_id"];
113
-
114
-    $object->min_allowed     = GETPOST("account_min_allowed",'int');
115
-    $object->min_desired     = GETPOST("account_min_desired",'int');
116
-    $object->comment         = trim(GETPOST("account_comment"));
117
-
118
-    $object->fk_user_author  = $user->id;
119
-
120
-    if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number))
121
-    {
122
-        setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors');
123
-        $action='create';       // Force chargement page en mode creation
124
-        $error++;
125
-    }
126
-    if (empty($object->ref))
127
-    {
128
-        setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
129
-        $action='create';       // Force chargement page en mode creation
130
-        $error++;
131
-    }
132
-    if (empty($object->label))
133
-    {
134
-    	setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
135
-    	$action='create';       // Force chargement page en mode creation
136
-    	$error++;
137
-    }
138
-
139
-    // Fill array 'array_options' with data from add form
140
-    $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
141
-
142
-    if (! $error)
143
-    {
144
-        $id = $object->create($user);
145
-        if ($id > 0)
146
-        {
147
-            // Category association
148
-            $categories = GETPOST('categories', 'array');
149
-            $object->setCategories($categories);
150
-
151
-            $_GET["id"]=$id;            // Force chargement page en mode visu
152
-
153
-            $action='';
154
-        }
155
-        else {
156
-            $error++;
157
-            setEventMessages($object->error, $object->errors, 'errors');
158
-
159
-            $action='create';   // Force chargement page en mode creation
160
-        }
161
-    }
162
-
163
-    if (! $error)
164
-    {
165
-        $db->commit();
166
-    }
167
-    else
168
-    {
169
-        $db->rollback();
170
-    }
106
+	$object->solde           = $_POST["solde"];
107
+	$object->date_solde      = dol_mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
108
+
109
+	$object->currency_code   = trim($_POST["account_currency_code"]);
110
+
111
+	$object->state_id  	     = $_POST["account_state_id"];
112
+	$object->country_id      = $_POST["account_country_id"];
113
+
114
+	$object->min_allowed     = GETPOST("account_min_allowed",'int');
115
+	$object->min_desired     = GETPOST("account_min_desired",'int');
116
+	$object->comment         = trim(GETPOST("account_comment"));
117
+
118
+	$object->fk_user_author  = $user->id;
119
+
120
+	if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number))
121
+	{
122
+		setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors');
123
+		$action='create';       // Force chargement page en mode creation
124
+		$error++;
125
+	}
126
+	if (empty($object->ref))
127
+	{
128
+		setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
129
+		$action='create';       // Force chargement page en mode creation
130
+		$error++;
131
+	}
132
+	if (empty($object->label))
133
+	{
134
+		setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
135
+		$action='create';       // Force chargement page en mode creation
136
+		$error++;
137
+	}
138
+
139
+	// Fill array 'array_options' with data from add form
140
+	$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
141
+
142
+	if (! $error)
143
+	{
144
+		$id = $object->create($user);
145
+		if ($id > 0)
146
+		{
147
+			// Category association
148
+			$categories = GETPOST('categories', 'array');
149
+			$object->setCategories($categories);
150
+
151
+			$_GET["id"]=$id;            // Force chargement page en mode visu
152
+
153
+			$action='';
154
+		}
155
+		else {
156
+			$error++;
157
+			setEventMessages($object->error, $object->errors, 'errors');
158
+
159
+			$action='create';   // Force chargement page en mode creation
160
+		}
161
+	}
162
+
163
+	if (! $error)
164
+	{
165
+		$db->commit();
166
+	}
167
+	else
168
+	{
169
+		$db->rollback();
170
+	}
171 171
 }
172 172
 
173 173
 if ($action == 'update')
174 174
 {
175
-    $error=0;
176
-
177
-    // Update account
178
-    $object = new Account($db);
179
-    $object->fetch(GETPOST("id"));
180
-
181
-    $object->ref             = dol_string_nospecial(trim($_POST["ref"]));
182
-    $object->label           = trim($_POST["label"]);
183
-    $object->courant         = $_POST["type"];
184
-    $object->clos            = $_POST["clos"];
185
-    $object->rappro          = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1;
186
-    $object->url             = trim($_POST["url"]);
187
-
188
-    $object->bank            = trim($_POST["bank"]);
189
-    $object->code_banque     = trim($_POST["code_banque"]);
190
-    $object->code_guichet    = trim($_POST["code_guichet"]);
191
-    $object->number          = trim($_POST["number"]);
192
-    $object->cle_rib         = trim($_POST["cle_rib"]);
193
-    $object->bic             = trim($_POST["bic"]);
194
-    $object->iban            = trim($_POST["iban"]);
195
-    $object->domiciliation   = trim($_POST["domiciliation"]);
196
-
197
-    $object->proprio 	     = trim($_POST["proprio"]);
198
-    $object->owner_address   = trim($_POST["owner_address"]);
175
+	$error=0;
176
+
177
+	// Update account
178
+	$object = new Account($db);
179
+	$object->fetch(GETPOST("id"));
180
+
181
+	$object->ref             = dol_string_nospecial(trim($_POST["ref"]));
182
+	$object->label           = trim($_POST["label"]);
183
+	$object->courant         = $_POST["type"];
184
+	$object->clos            = $_POST["clos"];
185
+	$object->rappro          = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1;
186
+	$object->url             = trim($_POST["url"]);
187
+
188
+	$object->bank            = trim($_POST["bank"]);
189
+	$object->code_banque     = trim($_POST["code_banque"]);
190
+	$object->code_guichet    = trim($_POST["code_guichet"]);
191
+	$object->number          = trim($_POST["number"]);
192
+	$object->cle_rib         = trim($_POST["cle_rib"]);
193
+	$object->bic             = trim($_POST["bic"]);
194
+	$object->iban            = trim($_POST["iban"]);
195
+	$object->domiciliation   = trim($_POST["domiciliation"]);
196
+
197
+	$object->proprio 	     = trim($_POST["proprio"]);
198
+	$object->owner_address   = trim($_POST["owner_address"]);
199 199
 
200 200
 	$account_number 		 = GETPOST('account_number', 'int');
201 201
 	if ($account_number <= 0) { $object->account_number = ''; } else { $object->account_number = $account_number; }
202 202
 	$fk_accountancy_journal  = GETPOST('fk_accountancy_journal','int');
203 203
 	if ($fk_accountancy_journal <= 0) { $object->fk_accountancy_journal = ''; } else { $object->fk_accountancy_journal = $fk_accountancy_journal; }
204 204
 
205
-    $object->currency_code   = trim($_POST["account_currency_code"]);
206
-
207
-    $object->state_id        = $_POST["account_state_id"];
208
-    $object->country_id      = $_POST["account_country_id"];
209
-
210
-    $object->min_allowed     = GETPOST("account_min_allowed",'int');
211
-    $object->min_desired     = GETPOST("account_min_desired",'int');
212
-    $object->comment         = trim(GETPOST("account_comment"));
213
-
214
-    if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number))
215
-    {
216
-        setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'error');
217
-        $action='edit';       // Force chargement page en mode creation
218
-        $error++;
219
-    }
220
-    if (empty($object->ref))
221
-    {
222
-        setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
223
-        $action='edit';       // Force chargement page en mode creation
224
-        $error++;
225
-    }
226
-    if (empty($object->label))
227
-    {
228
-    	setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
229
-    	$action='edit';       // Force chargement page en mode creation
230
-    	$error++;
231
-    }
232
-
233
-    // Fill array 'array_options' with data from add form
234
-    $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
235
-
236
-    if (! $error)
237
-    {
238
-        $result = $object->update($user);
239
-        if ($result >= 0)
240
-        {
241
-            // Category association
242
-            $categories = GETPOST('categories', 'array');
243
-            $object->setCategories($categories);
244
-
245
-            $_GET["id"]=$_POST["id"];   // Force chargement page en mode visu
246
-        }
247
-        else
248
-        {
249
-	        setEventMessages($object->error, $object->errors, 'errors');
250
-            $action='edit';     // Force chargement page edition
251
-        }
252
-    }
205
+	$object->currency_code   = trim($_POST["account_currency_code"]);
206
+
207
+	$object->state_id        = $_POST["account_state_id"];
208
+	$object->country_id      = $_POST["account_country_id"];
209
+
210
+	$object->min_allowed     = GETPOST("account_min_allowed",'int');
211
+	$object->min_desired     = GETPOST("account_min_desired",'int');
212
+	$object->comment         = trim(GETPOST("account_comment"));
213
+
214
+	if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number))
215
+	{
216
+		setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'error');
217
+		$action='edit';       // Force chargement page en mode creation
218
+		$error++;
219
+	}
220
+	if (empty($object->ref))
221
+	{
222
+		setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
223
+		$action='edit';       // Force chargement page en mode creation
224
+		$error++;
225
+	}
226
+	if (empty($object->label))
227
+	{
228
+		setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
229
+		$action='edit';       // Force chargement page en mode creation
230
+		$error++;
231
+	}
232
+
233
+	// Fill array 'array_options' with data from add form
234
+	$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
235
+
236
+	if (! $error)
237
+	{
238
+		$result = $object->update($user);
239
+		if ($result >= 0)
240
+		{
241
+			// Category association
242
+			$categories = GETPOST('categories', 'array');
243
+			$object->setCategories($categories);
244
+
245
+			$_GET["id"]=$_POST["id"];   // Force chargement page en mode visu
246
+		}
247
+		else
248
+		{
249
+			setEventMessages($object->error, $object->errors, 'errors');
250
+			$action='edit';     // Force chargement page edition
251
+		}
252
+	}
253 253
 }
254 254
 
255 255
 if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer)
256 256
 {
257
-    // Delete
258
-    $object = new Account($db);
259
-    $object->fetch(GETPOST("id","int"));
260
-    $result = $object->delete($user);
261
-
262
-    if ($result > 0)
263
-    {
264
-        setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
265
-        header("Location: ".DOL_URL_ROOT."/compta/bank/list.php");
266
-        exit;
267
-    }
268
-    else
269
-    {
270
-        setEventMessages($account->error, $account->errors, 'errors');
271
-        $action='';
272
-    }
257
+	// Delete
258
+	$object = new Account($db);
259
+	$object->fetch(GETPOST("id","int"));
260
+	$result = $object->delete($user);
261
+
262
+	if ($result > 0)
263
+	{
264
+		setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
265
+		header("Location: ".DOL_URL_ROOT."/compta/bank/list.php");
266
+		exit;
267
+	}
268
+	else
269
+	{
270
+		setEventMessages($account->error, $account->errors, 'errors');
271
+		$action='';
272
+	}
273 273
 }
274 274
 
275 275
 
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
 
298 298
 	print load_fiche_titre($langs->trans("NewFinancialAccount"), '', 'title_bank.png');
299 299
 
300
-    if ($conf->use_javascript_ajax)
301
-    {
300
+	if ($conf->use_javascript_ajax)
301
+	{
302 302
 		print "\n".'<script type="text/javascript" language="javascript">';
303
-        print 'jQuery(document).ready(function () {
303
+		print 'jQuery(document).ready(function () {
304 304
                     jQuery("#selecttype").change(function() {
305 305
                         document.formsoc.action.value="create";
306 306
                         document.formsoc.submit();
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
                         document.formsoc.submit();
311 311
                     });
312 312
                })';
313
-        print '</script>'."\n";
314
-    }
313
+		print '</script>'."\n";
314
+	}
315 315
 
316 316
 	print '<form action="'.$_SERVER["PHP_SELF"].'" name="formsoc" method="post">';
317 317
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@@ -347,12 +347,12 @@  discard block
 block discarded – undo
347 347
 	print '</td></tr>';
348 348
 
349 349
 	// Status
350
-    print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
351
-    print '<td>';
352
-    print $form->selectarray("clos", $object->status,(GETPOST("clos",'int')!=''?GETPOST("clos",'int'):$object->clos));
353
-    print '</td></tr>';
350
+	print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
351
+	print '<td>';
352
+	print $form->selectarray("clos", $object->status,(GETPOST("clos",'int')!=''?GETPOST("clos",'int'):$object->clos));
353
+	print '</td></tr>';
354 354
 
355
-    // Country
355
+	// Country
356 356
 	$selectedcode='';
357 357
 	if (isset($_POST["account_country_id"]))
358 358
 	{
@@ -383,24 +383,24 @@  discard block
 block discarded – undo
383 383
 	print '<tr><td>'.$langs->trans("Web").'</td>';
384 384
 	print '<td><input class="minwidth300" type="text" class="flat" name="url" value="'.GETPOST("url").'"></td></tr>';
385 385
 
386
-    // Tags-Categories
387
-    if ($conf->categorie->enabled)
388
-    {
389
-        print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td>';
390
-        $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
391
-        $c = new Categorie($db);
392
-        $cats = $c->containing($object->id,Categorie::TYPE_ACCOUNT);
393
-        foreach($cats as $cat) {
394
-            $arrayselected[] = $cat->id;
395
-        }
396
-        print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
397
-        print "</td></tr>";
398
-    }
386
+	// Tags-Categories
387
+	if ($conf->categorie->enabled)
388
+	{
389
+		print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td>';
390
+		$cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
391
+		$c = new Categorie($db);
392
+		$cats = $c->containing($object->id,Categorie::TYPE_ACCOUNT);
393
+		foreach($cats as $cat) {
394
+			$arrayselected[] = $cat->id;
395
+		}
396
+		print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
397
+		print "</td></tr>";
398
+	}
399 399
 
400 400
 	// Comment
401 401
 	print '<tr><td class="tdtop">'.$langs->trans("Comment").'</td>';
402 402
 	print '<td>';
403
-    // Editor wysiwyg
403
+	// Editor wysiwyg
404 404
 	require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
405 405
 	$doleditor=new DolEditor('account_comment',(GETPOST("account_comment")?GETPOST("account_comment"):$object->comment),'',90,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_4,'90%');
406 406
 	$doleditor->Create();
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
  	// Other attributes
410 410
 	$parameters=array();
411 411
 	$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
412
-    print $hookmanager->resPrint;
412
+	print $hookmanager->resPrint;
413 413
 	if (empty($reshook) && ! empty($extrafields->attribute_label))
414 414
 	{
415 415
 		print $object->showOptionals($extrafields,'edit',$parameters);
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 	print '<table class="border" width="100%">';
505 505
 	// Accountancy code
506 506
 	$fieldrequired='';
507
-    if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) $fieldrequired='fieldrequired ';
507
+	if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) $fieldrequired='fieldrequired ';
508 508
 
509 509
 	if (! empty($conf->accounting->enabled))
510 510
 	{
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 	if (! empty($conf->accounting->enabled))
524 524
 	{
525 525
 		print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
526
-	    print '<td>';
526
+		print '<td>';
527 527
 		print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0);
528 528
 		print '</td></tr>';
529 529
 	}
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 /* ************************************************************************** */
548 548
 else
549 549
 {
550
-    if (($_GET["id"] || $_GET["ref"]) && $action != 'edit')
550
+	if (($_GET["id"] || $_GET["ref"]) && $action != 'edit')
551 551
 	{
552 552
 		$object = new Account($db);
553 553
 		if ($_GET["id"])
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 		print '<td>';
606 606
 		$conciliate=$object->canBeConciliated();
607 607
 		if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
608
-        else if ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')';
608
+		else if ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')';
609 609
 		else print ($object->rappro==1 ? $langs->trans("Yes") : ($langs->trans("No").' ('.$langs->trans("ConciliationDisabled").')'));
610 610
 		print '</td></tr>';
611 611
 
@@ -624,15 +624,15 @@  discard block
 block discarded – undo
624 624
 
625 625
 			print $accountingaccount->getNomUrl(0,1,1,'',1);
626 626
 		} else {
627
-		    print $object->account_number;
627
+			print $object->account_number;
628 628
 		}
629 629
 		print '</td></tr>';
630 630
 
631 631
 		// Accountancy journal
632 632
 		if (! empty($conf->accounting->enabled))
633 633
 		{
634
-		    print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
635
-		    print '<td>';
634
+			print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
635
+			print '<td>';
636 636
 
637 637
 			$accountingjournal = new AccountingJournal($db);
638 638
 			$accountingjournal->fetch($object->fk_accountancy_journal);
@@ -655,12 +655,12 @@  discard block
 block discarded – undo
655 655
 
656 656
 		print '<table class="border centpercent">';
657 657
 
658
-        // Categories
659
-        if ($conf->categorie->enabled) {
660
-            print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td><td>';
661
-            print $form->showCategories($object->id,'bank_account',1);
662
-            print "</td></tr>";
663
-        }
658
+		// Categories
659
+		if ($conf->categorie->enabled) {
660
+			print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td><td>';
661
+			print $form->showCategories($object->id,'bank_account',1);
662
+			print "</td></tr>";
663
+		}
664 664
 
665 665
 		print '<tr><td class="tdtop titlefield">'.$langs->trans("Comment").'</td>';
666 666
 		print '<td>'.dol_htmlentitiesbr($object->comment).'</td></tr>';
@@ -669,11 +669,11 @@  discard block
 block discarded – undo
669 669
 
670 670
 		if ($object->type == Account::TYPE_SAVINGS || $object->type == Account::TYPE_CURRENT)
671 671
 		{
672
-		    print '<br>';
672
+			print '<br>';
673 673
 
674
-		    print '<div class="underbanner clearboth"></div>';
674
+			print '<div class="underbanner clearboth"></div>';
675 675
 
676
-		    print '<table class="border centpercent">';
676
+			print '<table class="border centpercent">';
677 677
 
678 678
 			print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("BankName").'</td>';
679 679
 			print '<td>'.$object->bank.'</td></tr>';
@@ -764,23 +764,23 @@  discard block
 block discarded – undo
764 764
 
765 765
 	}
766 766
 
767
-    /* ************************************************************************** */
768
-    /*                                                                            */
769
-    /* Edition                                                                    */
770
-    /*                                                                            */
771
-    /* ************************************************************************** */
767
+	/* ************************************************************************** */
768
+	/*                                                                            */
769
+	/* Edition                                                                    */
770
+	/*                                                                            */
771
+	/* ************************************************************************** */
772 772
 
773
-    if (GETPOST('id','int') && $action == 'edit' && $user->rights->banque->configurer)
774
-    {
775
-        $object = new Account($db);
776
-        $object->fetch(GETPOST('id','int'));
773
+	if (GETPOST('id','int') && $action == 'edit' && $user->rights->banque->configurer)
774
+	{
775
+		$object = new Account($db);
776
+		$object->fetch(GETPOST('id','int'));
777 777
 
778
-        print load_fiche_titre($langs->trans("EditFinancialAccount"), '', 'title_bank.png');
778
+		print load_fiche_titre($langs->trans("EditFinancialAccount"), '', 'title_bank.png');
779 779
 
780
-        if ($conf->use_javascript_ajax)
781
-        {
782
-            print "\n".'<script type="text/javascript" language="javascript">';
783
-            print 'jQuery(document).ready(function () {
780
+		if ($conf->use_javascript_ajax)
781
+		{
782
+			print "\n".'<script type="text/javascript" language="javascript">';
783
+			print 'jQuery(document).ready(function () {
784 784
                         jQuery("#selecttype").change(function() {
785 785
                             document.formsoc.action.value="edit";
786 786
                             document.formsoc.submit();
@@ -793,33 +793,33 @@  discard block
 block discarded – undo
793 793
                             document.formsoc.submit();
794 794
                         });
795 795
                    })';
796
-            print '</script>'."\n";
797
-        }
796
+			print '</script>'."\n";
797
+		}
798 798
 
799
-        print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post" name="formsoc">';
800
-        print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
801
-        print '<input type="hidden" name="action" value="update">';
802
-        print '<input type="hidden" name="id" value="'.$_REQUEST["id"].'">'."\n\n";
799
+		print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post" name="formsoc">';
800
+		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
801
+		print '<input type="hidden" name="action" value="update">';
802
+		print '<input type="hidden" name="id" value="'.$_REQUEST["id"].'">'."\n\n";
803 803
 
804
-        dol_fiche_head('');
804
+		dol_fiche_head('');
805 805
 
806
-        print '<div class="underbanner clearboth"></div>';
806
+		print '<div class="underbanner clearboth"></div>';
807 807
 
808
-        print '<table class="border" width="100%">';
808
+		print '<table class="border" width="100%">';
809 809
 
810 810
 		// Ref
811 811
 		print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Ref").'</td>';
812 812
 		print '<td><input size="8" type="text" class="flat" name="ref" value="'.(isset($_POST["ref"])?GETPOST("ref"):$object->ref).'"></td></tr>';
813 813
 
814 814
 		// Label
815
-        print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
816
-        print '<td><input type="text" class="flat minwidth300" name="label" value="'.(isset($_POST["label"])?GETPOST("label"):$object->label).'"></td></tr>';
815
+		print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
816
+		print '<td><input type="text" class="flat minwidth300" name="label" value="'.(isset($_POST["label"])?GETPOST("label"):$object->label).'"></td></tr>';
817 817
 
818
-        // Type
819
-        print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
820
-        print '<td class="maxwidth200onsmartphone">';
818
+		// Type
819
+		print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
820
+		print '<td class="maxwidth200onsmartphone">';
821 821
 		$formbank->selectTypeOfBankAccount((isset($_POST["type"])?$_POST["type"]:$object->type),"type");
822
-        print '</td></tr>';
822
+		print '</td></tr>';
823 823
 
824 824
 		// Currency
825 825
 		print '<tr><td class="fieldrequired">'.$langs->trans("Currency");
@@ -834,10 +834,10 @@  discard block
 block discarded – undo
834 834
 		print '</td></tr>';
835 835
 
836 836
 		// Status
837
-        print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
838
-        print '<td class="maxwidth200onsmartphone">';
839
-        print $form->selectarray("clos", $object->status, (isset($_POST["clos"])?$_POST["clos"]:$object->clos));
840
-        print '</td></tr>';
837
+		print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
838
+		print '<td class="maxwidth200onsmartphone">';
839
+		print $form->selectarray("clos", $object->status, (isset($_POST["clos"])?$_POST["clos"]:$object->clos));
840
+		print '</td></tr>';
841 841
 
842 842
 		// Country
843 843
 		$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id;
@@ -865,15 +865,15 @@  discard block
 block discarded – undo
865 865
 		print '</td></tr>';
866 866
 
867 867
 		// Conciliable
868
-        print '<tr><td>'.$langs->trans("Conciliable").'</td>';
869
-        print '<td>';
870
-        $conciliate=$object->canBeConciliated();
871
-        if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
872
-        else if ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')';
873
-        else print '<input type="checkbox" class="flat" name="norappro"'.(($conciliate > 0)?'':' checked="checked"').'"> '.$langs->trans("DisableConciliation");
874
-        print '</td></tr>';
875
-
876
-        // Balance
868
+		print '<tr><td>'.$langs->trans("Conciliable").'</td>';
869
+		print '<td>';
870
+		$conciliate=$object->canBeConciliated();
871
+		if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
872
+		else if ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')';
873
+		else print '<input type="checkbox" class="flat" name="norappro"'.(($conciliate > 0)?'':' checked="checked"').'"> '.$langs->trans("DisableConciliation");
874
+		print '</td></tr>';
875
+
876
+		// Balance
877 877
 		print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
878 878
 		print '<td><input size="12" type="text" class="flat" name="account_min_allowed" value="'.(isset($_POST["account_min_allowed"])?GETPOST("account_min_allowed"):$object->min_allowed).'"></td></tr>';
879 879
 
@@ -881,28 +881,28 @@  discard block
 block discarded – undo
881 881
 		print '<td ><input size="12" type="text" class="flat" name="account_min_desired" value="'.(isset($_POST["account_min_desired"])?GETPOST("account_min_desired"):$object->min_desired).'"></td></tr>';
882 882
 
883 883
 		// Web
884
-        print '<tr><td>'.$langs->trans("Web").'</td>';
885
-        print '<td><input class="maxwidth200onsmartphone" type="text" class="flat" name="url" value="'.(isset($_POST["url"])?GETPOST("url"):$object->url).'">';
886
-        print '</td></tr>';
887
-
888
-        // Tags-Categories
889
-        if ($conf->categorie->enabled)
890
-        {
891
-            print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td>';
892
-            $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
893
-            $c = new Categorie($db);
894
-            $cats = $c->containing($object->id,Categorie::TYPE_ACCOUNT);
895
-            foreach($cats as $cat) {
896
-                $arrayselected[] = $cat->id;
897
-            }
898
-            print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
899
-            print "</td></tr>";
900
-        }
884
+		print '<tr><td>'.$langs->trans("Web").'</td>';
885
+		print '<td><input class="maxwidth200onsmartphone" type="text" class="flat" name="url" value="'.(isset($_POST["url"])?GETPOST("url"):$object->url).'">';
886
+		print '</td></tr>';
887
+
888
+		// Tags-Categories
889
+		if ($conf->categorie->enabled)
890
+		{
891
+			print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td>';
892
+			$cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
893
+			$c = new Categorie($db);
894
+			$cats = $c->containing($object->id,Categorie::TYPE_ACCOUNT);
895
+			foreach($cats as $cat) {
896
+				$arrayselected[] = $cat->id;
897
+			}
898
+			print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
899
+			print "</td></tr>";
900
+		}
901 901
 
902 902
 		// Comment
903 903
 		print '<tr><td class="tdtop">'.$langs->trans("Comment").'</td>';
904 904
 		print '<td>';
905
-	    // Editor wysiwyg
905
+		// Editor wysiwyg
906 906
 		require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
907 907
 		$doleditor=new DolEditor('account_comment',(GETPOST("account_comment")?GETPOST("account_comment"):$object->comment),'',90,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_4,'95%');
908 908
 		$doleditor->Create();
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
 		// Other attributes
912 912
 		$parameters=array();
913 913
 		$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
914
-        print $hookmanager->resPrint;
914
+		print $hookmanager->resPrint;
915 915
 		if (empty($reshook) && ! empty($extrafields->attribute_label))
916 916
 		{
917 917
 			print $object->showOptionals($extrafields,'edit');
@@ -929,15 +929,15 @@  discard block
 block discarded – undo
929 929
 		$tdextra = ' class="titlefieldcreate"';
930 930
 
931 931
 		if (!empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) {
932
-		    $tdextra = ' class="fieldrequired titlefieldcreate"';
932
+			$tdextra = ' class="fieldrequired titlefieldcreate"';
933 933
 		}
934 934
 
935 935
 		print '<tr class="liste_titre_add"><td'.$tdextra.'>'.$langs->trans("AccountancyCode").'</td>';
936 936
 		print '<td>';
937 937
 		if (!empty($conf->accounting->enabled)) {
938
-		    print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);
938
+			print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);
939 939
 		} else {
940
-		    print '<input type="text" name="account_number" value="'.(GETPOST("account_number") ? GETPOST("account_number") : $object->account_number).'">';
940
+			print '<input type="text" name="account_number" value="'.(GETPOST("account_number") ? GETPOST("account_number") : $object->account_number).'">';
941 941
 		}
942 942
 		print '</td></tr>';
943 943
 
@@ -954,9 +954,9 @@  discard block
 block discarded – undo
954 954
 
955 955
 		if ($_POST["type"] == Account::TYPE_SAVINGS || $_POST["type"] == Account::TYPE_CURRENT)
956 956
 		{
957
-		    print '<br>';
957
+			print '<br>';
958 958
 
959
-		    //print '<div class="underbanner clearboth"></div>';
959
+			//print '<div class="underbanner clearboth"></div>';
960 960
 
961 961
 			print '<table class="border" width="100%">';
962 962
 
Please login to merge, or discard this patch.
Spacing   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -28,16 +28,16 @@  discard block
 block discarded – undo
28 28
  */
29 29
 
30 30
 require('../../main.inc.php');
31
-require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php';
32
-require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
33
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
34
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbank.class.php';
35
-require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
36
-require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
37
-if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
38
-if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
39
-if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
40
-if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
31
+require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
32
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
33
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
34
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php';
35
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
36
+require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
37
+if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
38
+if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
39
+if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
40
+if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
41 41
 
42 42
 $langs->load("banks");
43 43
 $langs->load("bills");
@@ -45,22 +45,22 @@  discard block
 block discarded – undo
45 45
 $langs->load("companies");
46 46
 $langs->load("compta");
47 47
 
48
-$action=GETPOST('action','aZ09');
48
+$action = GETPOST('action', 'aZ09');
49 49
 $cancel = GETPOST('cancel', 'alpha');
50 50
 
51 51
 // Security check
52 52
 if (isset($_GET["id"]) || isset($_GET["ref"]))
53 53
 {
54
-	$id = isset($_GET["id"])?GETPOST("id"):(isset($_GET["ref"])?GETPOST("ref"):'');
54
+	$id = isset($_GET["id"]) ?GETPOST("id") : (isset($_GET["ref"]) ?GETPOST("ref") : '');
55 55
 }
56
-$fieldid = isset($_GET["ref"])?'ref':'rowid';
57
-if ($user->societe_id) $socid=$user->societe_id;
58
-$result=restrictedArea($user,'banque',$id,'bank_account&bank_account','','',$fieldid);
56
+$fieldid = isset($_GET["ref"]) ? 'ref' : 'rowid';
57
+if ($user->societe_id) $socid = $user->societe_id;
58
+$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid);
59 59
 
60 60
 $object = new Account($db);
61 61
 $extrafields = new ExtraFields($db);
62 62
 // fetch optionals attributes and labels
63
-$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
63
+$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
64 64
 
65 65
 
66 66
 
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
  * Actions
69 69
  */
70 70
 
71
-if ($cancel) $action='';
71
+if ($cancel) $action = '';
72 72
 
73 73
 if ($action == 'add')
74 74
 {
75
-    $error=0;
75
+    $error = 0;
76 76
 
77 77
     $db->begin();
78 78
 
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
     $object->label         = trim($_POST["label"]);
84 84
     $object->courant       = $_POST["type"];
85 85
     $object->clos          = $_POST["clos"];
86
-    $object->rappro        = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1;
86
+    $object->rappro        = (isset($_POST["norappro"]) && $_POST["norappro"]) ? 0 : 1;
87 87
     $object->url           = $_POST["url"];
88 88
 
89
-	$object->bank            = trim($_POST["bank"]);
89
+	$object->bank = trim($_POST["bank"]);
90 90
     $object->code_banque     = trim($_POST["code_banque"]);
91 91
     $object->code_guichet    = trim($_POST["code_guichet"]);
92 92
     $object->number          = trim($_POST["number"]);
@@ -95,51 +95,51 @@  discard block
 block discarded – undo
95 95
     $object->iban            = trim($_POST["iban"]);
96 96
     $object->domiciliation   = trim($_POST["domiciliation"]);
97 97
 
98
-    $object->proprio 	     = trim($_POST["proprio"]);
98
+    $object->proprio = trim($_POST["proprio"]);
99 99
     $object->owner_address   = trim($_POST["owner_address"]);
100 100
 
101
-	$account_number 		 = GETPOST('account_number','alpha');
101
+	$account_number = GETPOST('account_number', 'alpha');
102 102
 	if ($account_number <= 0) { $object->account_number = ''; } else { $object->account_number = $account_number; }
103
-	$fk_accountancy_journal  = GETPOST('fk_accountancy_journal','int');
103
+	$fk_accountancy_journal = GETPOST('fk_accountancy_journal', 'int');
104 104
 	if ($fk_accountancy_journal <= 0) { $object->fk_accountancy_journal = ''; } else { $object->fk_accountancy_journal = $fk_accountancy_journal; }
105 105
 
106 106
     $object->solde           = $_POST["solde"];
107
-    $object->date_solde      = dol_mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
107
+    $object->date_solde      = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
108 108
 
109 109
     $object->currency_code   = trim($_POST["account_currency_code"]);
110 110
 
111 111
     $object->state_id  	     = $_POST["account_state_id"];
112 112
     $object->country_id      = $_POST["account_country_id"];
113 113
 
114
-    $object->min_allowed     = GETPOST("account_min_allowed",'int');
115
-    $object->min_desired     = GETPOST("account_min_desired",'int');
114
+    $object->min_allowed     = GETPOST("account_min_allowed", 'int');
115
+    $object->min_desired     = GETPOST("account_min_desired", 'int');
116 116
     $object->comment         = trim(GETPOST("account_comment"));
117 117
 
118 118
     $object->fk_user_author  = $user->id;
119 119
 
120 120
     if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number))
121 121
     {
122
-        setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors');
123
-        $action='create';       // Force chargement page en mode creation
122
+        setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors');
123
+        $action = 'create'; // Force chargement page en mode creation
124 124
         $error++;
125 125
     }
126 126
     if (empty($object->ref))
127 127
     {
128
-        setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
129
-        $action='create';       // Force chargement page en mode creation
128
+        setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
129
+        $action = 'create'; // Force chargement page en mode creation
130 130
         $error++;
131 131
     }
132 132
     if (empty($object->label))
133 133
     {
134
-    	setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
135
-    	$action='create';       // Force chargement page en mode creation
134
+    	setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
135
+    	$action = 'create'; // Force chargement page en mode creation
136 136
     	$error++;
137 137
     }
138 138
 
139 139
     // Fill array 'array_options' with data from add form
140
-    $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
140
+    $ret = $extrafields->setOptionalsFromPost($extralabels, $object);
141 141
 
142
-    if (! $error)
142
+    if (!$error)
143 143
     {
144 144
         $id = $object->create($user);
145 145
         if ($id > 0)
@@ -148,19 +148,19 @@  discard block
 block discarded – undo
148 148
             $categories = GETPOST('categories', 'array');
149 149
             $object->setCategories($categories);
150 150
 
151
-            $_GET["id"]=$id;            // Force chargement page en mode visu
151
+            $_GET["id"] = $id; // Force chargement page en mode visu
152 152
 
153
-            $action='';
153
+            $action = '';
154 154
         }
155 155
         else {
156 156
             $error++;
157 157
             setEventMessages($object->error, $object->errors, 'errors');
158 158
 
159
-            $action='create';   // Force chargement page en mode creation
159
+            $action = 'create'; // Force chargement page en mode creation
160 160
         }
161 161
     }
162 162
 
163
-    if (! $error)
163
+    if (!$error)
164 164
     {
165 165
         $db->commit();
166 166
     }
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 
173 173
 if ($action == 'update')
174 174
 {
175
-    $error=0;
175
+    $error = 0;
176 176
 
177 177
     // Update account
178 178
     $object = new Account($db);
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
     $object->label           = trim($_POST["label"]);
183 183
     $object->courant         = $_POST["type"];
184 184
     $object->clos            = $_POST["clos"];
185
-    $object->rappro          = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1;
185
+    $object->rappro          = (isset($_POST["norappro"]) && $_POST["norappro"]) ? 0 : 1;
186 186
     $object->url             = trim($_POST["url"]);
187 187
 
188 188
     $object->bank            = trim($_POST["bank"]);
@@ -194,12 +194,12 @@  discard block
 block discarded – undo
194 194
     $object->iban            = trim($_POST["iban"]);
195 195
     $object->domiciliation   = trim($_POST["domiciliation"]);
196 196
 
197
-    $object->proprio 	     = trim($_POST["proprio"]);
197
+    $object->proprio = trim($_POST["proprio"]);
198 198
     $object->owner_address   = trim($_POST["owner_address"]);
199 199
 
200
-	$account_number 		 = GETPOST('account_number', 'int');
200
+	$account_number = GETPOST('account_number', 'int');
201 201
 	if ($account_number <= 0) { $object->account_number = ''; } else { $object->account_number = $account_number; }
202
-	$fk_accountancy_journal  = GETPOST('fk_accountancy_journal','int');
202
+	$fk_accountancy_journal = GETPOST('fk_accountancy_journal', 'int');
203 203
 	if ($fk_accountancy_journal <= 0) { $object->fk_accountancy_journal = ''; } else { $object->fk_accountancy_journal = $fk_accountancy_journal; }
204 204
 
205 205
     $object->currency_code   = trim($_POST["account_currency_code"]);
@@ -207,33 +207,33 @@  discard block
 block discarded – undo
207 207
     $object->state_id        = $_POST["account_state_id"];
208 208
     $object->country_id      = $_POST["account_country_id"];
209 209
 
210
-    $object->min_allowed     = GETPOST("account_min_allowed",'int');
211
-    $object->min_desired     = GETPOST("account_min_desired",'int');
210
+    $object->min_allowed     = GETPOST("account_min_allowed", 'int');
211
+    $object->min_desired     = GETPOST("account_min_desired", 'int');
212 212
     $object->comment         = trim(GETPOST("account_comment"));
213 213
 
214 214
     if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number))
215 215
     {
216
-        setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'error');
217
-        $action='edit';       // Force chargement page en mode creation
216
+        setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountancyCode")), null, 'error');
217
+        $action = 'edit'; // Force chargement page en mode creation
218 218
         $error++;
219 219
     }
220 220
     if (empty($object->ref))
221 221
     {
222
-        setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
223
-        $action='edit';       // Force chargement page en mode creation
222
+        setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
223
+        $action = 'edit'; // Force chargement page en mode creation
224 224
         $error++;
225 225
     }
226 226
     if (empty($object->label))
227 227
     {
228
-    	setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
229
-    	$action='edit';       // Force chargement page en mode creation
228
+    	setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
229
+    	$action = 'edit'; // Force chargement page en mode creation
230 230
     	$error++;
231 231
     }
232 232
 
233 233
     // Fill array 'array_options' with data from add form
234
-    $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
234
+    $ret = $extrafields->setOptionalsFromPost($extralabels, $object);
235 235
 
236
-    if (! $error)
236
+    if (!$error)
237 237
     {
238 238
         $result = $object->update($user);
239 239
         if ($result >= 0)
@@ -242,12 +242,12 @@  discard block
 block discarded – undo
242 242
             $categories = GETPOST('categories', 'array');
243 243
             $object->setCategories($categories);
244 244
 
245
-            $_GET["id"]=$_POST["id"];   // Force chargement page en mode visu
245
+            $_GET["id"] = $_POST["id"]; // Force chargement page en mode visu
246 246
         }
247 247
         else
248 248
         {
249 249
 	        setEventMessages($object->error, $object->errors, 'errors');
250
-            $action='edit';     // Force chargement page edition
250
+            $action = 'edit'; // Force chargement page edition
251 251
         }
252 252
     }
253 253
 }
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 {
257 257
     // Delete
258 258
     $object = new Account($db);
259
-    $object->fetch(GETPOST("id","int"));
259
+    $object->fetch(GETPOST("id", "int"));
260 260
     $result = $object->delete($user);
261 261
 
262 262
     if ($result > 0)
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
     else
269 269
     {
270 270
         setEventMessages($account->error, $account->errors, 'errors');
271
-        $action='';
271
+        $action = '';
272 272
     }
273 273
 }
274 274
 
@@ -280,20 +280,20 @@  discard block
 block discarded – undo
280 280
 $form = new Form($db);
281 281
 $formbank = new FormBank($db);
282 282
 $formcompany = new FormCompany($db);
283
-if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
283
+if (!empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
284 284
 
285
-$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
285
+$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
286 286
 
287
-$title = $langs->trans("FinancialAccount") . " - " . $langs->trans("Card");
287
+$title = $langs->trans("FinancialAccount")." - ".$langs->trans("Card");
288 288
 $helpurl = "";
289
-llxHeader("",$title,$helpurl);
289
+llxHeader("", $title, $helpurl);
290 290
 
291 291
 
292 292
 // Creation
293 293
 
294 294
 if ($action == 'create')
295 295
 {
296
-	$object=new Account($db);
296
+	$object = new Account($db);
297 297
 
298 298
 	print load_fiche_titre($langs->trans("NewFinancialAccount"), '', 'title_bank.png');
299 299
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 
325 325
 	// Ref
326 326
 	print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Ref").'</td>';
327
-	print '<td><input size="8" type="text" class="flat" name="ref" value="'.dol_escape_htmltag(GETPOST("ref")?GETPOST("ref",'alpha'):$object->ref).'" maxlength="12" autofocus></td></tr>';
327
+	print '<td><input size="8" type="text" class="flat" name="ref" value="'.dol_escape_htmltag(GETPOST("ref") ?GETPOST("ref", 'alpha') : $object->ref).'" maxlength="12" autofocus></td></tr>';
328 328
 
329 329
 	// Label
330 330
 	print '<tr><td class="fieldrequired">'.$langs->trans("LabelBankCashAccount").'</td>';
@@ -333,15 +333,15 @@  discard block
 block discarded – undo
333 333
 	// Type
334 334
 	print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
335 335
 	print '<td>';
336
-	$formbank->selectTypeOfBankAccount(isset($_POST["type"])?$_POST["type"]: Account::TYPE_CURRENT,"type");
336
+	$formbank->selectTypeOfBankAccount(isset($_POST["type"]) ? $_POST["type"] : Account::TYPE_CURRENT, "type");
337 337
 	print '</td></tr>';
338 338
 
339 339
 	// Currency
340 340
 	print '<tr><td class="fieldrequired">'.$langs->trans("Currency").'</td>';
341 341
 	print '<td>';
342
-	$selectedcode=$object->currency_code;
343
-	if (! $selectedcode) $selectedcode=$conf->currency;
344
-	print $form->selectCurrency((isset($_POST["account_currency_code"])?$_POST["account_currency_code"]:$selectedcode), 'account_currency_code');
342
+	$selectedcode = $object->currency_code;
343
+	if (!$selectedcode) $selectedcode = $conf->currency;
344
+	print $form->selectCurrency((isset($_POST["account_currency_code"]) ? $_POST["account_currency_code"] : $selectedcode), 'account_currency_code');
345 345
 	//print $langs->trans("Currency".$conf->currency);
346 346
 	//print '<input type="hidden" name="account_currency_code" value="'.$conf->currency.'">';
347 347
 	print '</td></tr>';
@@ -349,29 +349,29 @@  discard block
 block discarded – undo
349 349
 	// Status
350 350
     print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
351 351
     print '<td>';
352
-    print $form->selectarray("clos", $object->status,(GETPOST("clos",'int')!=''?GETPOST("clos",'int'):$object->clos));
352
+    print $form->selectarray("clos", $object->status, (GETPOST("clos", 'int') != '' ?GETPOST("clos", 'int') : $object->clos));
353 353
     print '</td></tr>';
354 354
 
355 355
     // Country
356
-	$selectedcode='';
356
+	$selectedcode = '';
357 357
 	if (isset($_POST["account_country_id"]))
358 358
 	{
359
-		$selectedcode=$_POST["account_country_id"]?$_POST["account_country_id"]:$object->country_code;
359
+		$selectedcode = $_POST["account_country_id"] ? $_POST["account_country_id"] : $object->country_code;
360 360
 	}
361
-	else if (empty($selectedcode)) $selectedcode=$mysoc->country_code;
362
-	$object->country_code = getCountry($selectedcode, 2);	// Force country code on account to have following field on bank fields matching country rules
361
+	else if (empty($selectedcode)) $selectedcode = $mysoc->country_code;
362
+	$object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules
363 363
 
364 364
 	print '<tr><td class="fieldrequired">'.$langs->trans("BankAccountCountry").'</td>';
365 365
 	print '<td>';
366
-	print $form->select_country($selectedcode,'account_country_id');
367
-	if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
366
+	print $form->select_country($selectedcode, 'account_country_id');
367
+	if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
368 368
 	print '</td></tr>';
369 369
 
370 370
 	// State
371 371
 	print '<tr><td>'.$langs->trans('State').'</td><td>';
372 372
 	if ($selectedcode)
373 373
 	{
374
-		$formcompany->select_departement(isset($_POST["account_state_id"])?$_POST["account_state_id"]:'',$selectedcode,'account_state_id');
374
+		$formcompany->select_departement(isset($_POST["account_state_id"]) ? $_POST["account_state_id"] : '', $selectedcode, 'account_state_id');
375 375
 	}
376 376
 	else
377 377
 	{
@@ -389,8 +389,8 @@  discard block
 block discarded – undo
389 389
         print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td>';
390 390
         $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
391 391
         $c = new Categorie($db);
392
-        $cats = $c->containing($object->id,Categorie::TYPE_ACCOUNT);
393
-        foreach($cats as $cat) {
392
+        $cats = $c->containing($object->id, Categorie::TYPE_ACCOUNT);
393
+        foreach ($cats as $cat) {
394 394
             $arrayselected[] = $cat->id;
395 395
         }
396 396
         print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
@@ -402,17 +402,17 @@  discard block
 block discarded – undo
402 402
 	print '<td>';
403 403
     // Editor wysiwyg
404 404
 	require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
405
-	$doleditor=new DolEditor('account_comment',(GETPOST("account_comment")?GETPOST("account_comment"):$object->comment),'',90,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_4,'90%');
405
+	$doleditor = new DolEditor('account_comment', (GETPOST("account_comment") ?GETPOST("account_comment") : $object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '90%');
406 406
 	$doleditor->Create();
407 407
 	print '</td></tr>';
408 408
 
409 409
  	// Other attributes
410
-	$parameters=array();
411
-	$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
410
+	$parameters = array();
411
+	$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
412 412
     print $hookmanager->resPrint;
413
-	if (empty($reshook) && ! empty($extrafields->attribute_label))
413
+	if (empty($reshook) && !empty($extrafields->attribute_label))
414 414
 	{
415
-		print $object->showOptionals($extrafields,'edit',$parameters);
415
+		print $object->showOptionals($extrafields, 'edit', $parameters);
416 416
 	}
417 417
 
418 418
 	print '</table>';
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 
424 424
 	// Sold
425 425
 	print '<tr><td class="titlefieldcreate">'.$langs->trans("InitialBankBalance").'</td>';
426
-	print '<td><input size="12" type="text" class="flat" name="solde" value="'.(GETPOST("solde")?GETPOST("solde"):price2num($object->solde)).'"></td></tr>';
426
+	print '<td><input size="12" type="text" class="flat" name="solde" value="'.(GETPOST("solde") ?GETPOST("solde") : price2num($object->solde)).'"></td></tr>';
427 427
 
428 428
 	print '<tr><td>'.$langs->trans("Date").'</td>';
429 429
 	print '<td>';
@@ -431,10 +431,10 @@  discard block
 block discarded – undo
431 431
 	print '</td></tr>';
432 432
 
433 433
 	print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
434
-	print '<td><input size="12" type="text" class="flat" name="account_min_allowed" value="'.(GETPOST("account_min_allowed")?GETPOST("account_min_allowed"):$object->min_allowed).'"></td></tr>';
434
+	print '<td><input size="12" type="text" class="flat" name="account_min_allowed" value="'.(GETPOST("account_min_allowed") ?GETPOST("account_min_allowed") : $object->min_allowed).'"></td></tr>';
435 435
 
436 436
 	print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
437
-	print '<td><input size="12" type="text" class="flat" name="account_min_desired" value="'.(GETPOST("account_min_desired")?GETPOST("account_min_desired"):$object->min_desired).'"></td></tr>';
437
+	print '<td><input size="12" type="text" class="flat" name="account_min_desired" value="'.(GETPOST("account_min_desired") ?GETPOST("account_min_desired") : $object->min_desired).'"></td></tr>';
438 438
 
439 439
 	print '</table>';
440 440
 	print '<br>';
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 
446 446
 		// If bank account
447 447
 		print '<tr><td class="titlefieldcreate">'.$langs->trans("BankName").'</td>';
448
-		print '<td><input size="30" type="text" class="flat" name="bank" value="'.(GETPOST('bank')?GETPOST('bank','alpha'):$object->bank).'"></td>';
448
+		print '<td><input size="30" type="text" class="flat" name="bank" value="'.(GETPOST('bank') ?GETPOST('bank', 'alpha') : $object->bank).'"></td>';
449 449
 		print '</tr>';
450 450
 
451 451
 		// Show fields of bank account
@@ -469,32 +469,32 @@  discard block
 block discarded – undo
469 469
 			}
470 470
 
471 471
 			print '<td>'.$langs->trans($val).'</td>';
472
-			print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.(GETPOST($name)?GETPOST($name,'alpha'):$content).'"></td>';
472
+			print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.(GETPOST($name) ?GETPOST($name, 'alpha') : $content).'"></td>';
473 473
 			print '</tr>';
474 474
 		}
475 475
 		$ibankey = FormBank::getIBANLabel($object);
476
-		$bickey="BICNumber";
477
-		if ($object->getCountryCode() == 'IN') $bickey="SWIFT";
476
+		$bickey = "BICNumber";
477
+		if ($object->getCountryCode() == 'IN') $bickey = "SWIFT";
478 478
 
479 479
 		// IBAN
480 480
 		print '<tr><td>'.$langs->trans($ibankey).'</td>';
481
-		print '<td><input size="34" maxlength="34" type="text" class="flat" name="iban" value="'.(GETPOST('iban')?GETPOST('iban','alpha'):$object->iban).'"></td></tr>';
481
+		print '<td><input size="34" maxlength="34" type="text" class="flat" name="iban" value="'.(GETPOST('iban') ?GETPOST('iban', 'alpha') : $object->iban).'"></td></tr>';
482 482
 
483 483
 		print '<tr><td>'.$langs->trans($bickey).'</td>';
484
-		print '<td><input size="11" maxlength="11" type="text" class="flat" name="bic" value="'.(GETPOST('bic')?GETPOST('bic','alpha'):$object->bic).'"></td></tr>';
484
+		print '<td><input size="11" maxlength="11" type="text" class="flat" name="bic" value="'.(GETPOST('bic') ?GETPOST('bic', 'alpha') : $object->bic).'"></td></tr>';
485 485
 
486 486
 		print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
487 487
 		print "<textarea class=\"flat\" name=\"domiciliation\" rows=\"2\" cols=\"40\">";
488
-		print (GETPOST('domiciliation')?GETPOST('domiciliation'):$object->domiciliation);
488
+		print (GETPOST('domiciliation') ?GETPOST('domiciliation') : $object->domiciliation);
489 489
 		print "</textarea></td></tr>";
490 490
 
491 491
 		print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
492
-		print '<td><input size="30" type="text" class="flat" name="proprio" value="'.(GETPOST('proprio')?GETPOST('proprio','alpha'):$object->proprio).'">';
492
+		print '<td><input size="30" type="text" class="flat" name="proprio" value="'.(GETPOST('proprio') ?GETPOST('proprio', 'alpha') : $object->proprio).'">';
493 493
 		print '</td></tr>';
494 494
 
495 495
 		print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
496 496
 		print "<textarea class=\"flat\" name=\"owner_address\" rows=\"2\" cols=\"40\">";
497
-		print (GETPOST('owner_address')?GETPOST('owner_address','alpha'):$object->owner_address);
497
+		print (GETPOST('owner_address') ?GETPOST('owner_address', 'alpha') : $object->owner_address);
498 498
 		print "</textarea></td></tr>";
499 499
 
500 500
 		print '</table>';
@@ -503,10 +503,10 @@  discard block
 block discarded – undo
503 503
 
504 504
 	print '<table class="border" width="100%">';
505 505
 	// Accountancy code
506
-	$fieldrequired='';
507
-    if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) $fieldrequired='fieldrequired ';
506
+	$fieldrequired = '';
507
+    if (!empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) $fieldrequired = 'fieldrequired ';
508 508
 
509
-	if (! empty($conf->accounting->enabled))
509
+	if (!empty($conf->accounting->enabled))
510 510
 	{
511 511
 		print '<tr><td class="'.$fieldrequired.'titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
512 512
 		print '<td>';
@@ -516,11 +516,11 @@  discard block
 block discarded – undo
516 516
 	else
517 517
 	{
518 518
 		print '<tr><td class="'.$fieldrequired.'titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
519
-		print '<td><input type="text" name="account_number" value="'.(GETPOST("account_number")?GETPOST('account_number', 'alpha'):$object->account_number).'"></td></tr>';
519
+		print '<td><input type="text" name="account_number" value="'.(GETPOST("account_number") ?GETPOST('account_number', 'alpha') : $object->account_number).'"></td></tr>';
520 520
 	}
521 521
 
522 522
 	// Accountancy journal
523
-	if (! empty($conf->accounting->enabled))
523
+	if (!empty($conf->accounting->enabled))
524 524
 	{
525 525
 		print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
526 526
 	    print '<td>';
@@ -533,9 +533,9 @@  discard block
 block discarded – undo
533 533
 	dol_fiche_end();
534 534
 
535 535
 	print '<div class="center">';
536
-	print '<input type="submit" class="button" value="' . $langs->trans("CreateAccount") . '">';
536
+	print '<input type="submit" class="button" value="'.$langs->trans("CreateAccount").'">';
537 537
 	print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
538
-	print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
538
+	print '<input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">';
539 539
 	print '</div>';
540 540
 
541 541
 	print '</form>';
@@ -556,12 +556,12 @@  discard block
 block discarded – undo
556 556
 		}
557 557
 		if ($_GET["ref"])
558 558
 		{
559
-			$object->fetch(0,$_GET["ref"]);
560
-			$_GET["id"]=$object->id;
559
+			$object->fetch(0, $_GET["ref"]);
560
+			$_GET["id"] = $object->id;
561 561
 		}
562 562
 
563 563
 		// Show tabs
564
-		$head=bank_prepare_head($object);
564
+		$head = bank_prepare_head($object);
565 565
 		dol_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"), -1, 'account');
566 566
 
567 567
 		$formconfirm = '';
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 		// Confirmation to delete
570 570
 		if ($action == 'delete')
571 571
 		{
572
-			$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans("DeleteAccount"),$langs->trans("ConfirmDeleteAccount"),"confirm_delete");
572
+			$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("DeleteAccount"), $langs->trans("ConfirmDeleteAccount"), "confirm_delete");
573 573
 
574 574
 		}
575 575
 
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 
579 579
 		$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
580 580
 
581
-		$morehtmlref='';
581
+		$morehtmlref = '';
582 582
 		dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
583 583
 
584 584
 
@@ -595,18 +595,18 @@  discard block
 block discarded – undo
595 595
 		// Currency
596 596
 		print '<tr><td>'.$langs->trans("Currency").'</td>';
597 597
 		print '<td>';
598
-		$selectedcode=$object->currency_code;
599
-		if (! $selectedcode) $selectedcode=$conf->currency;
598
+		$selectedcode = $object->currency_code;
599
+		if (!$selectedcode) $selectedcode = $conf->currency;
600 600
 		print $langs->trans("Currency".$selectedcode);
601 601
 		print '</td></tr>';
602 602
 
603 603
 		// Conciliate
604 604
 		print '<tr><td>'.$langs->trans("Conciliable").'</td>';
605 605
 		print '<td>';
606
-		$conciliate=$object->canBeConciliated();
606
+		$conciliate = $object->canBeConciliated();
607 607
 		if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
608 608
         else if ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')';
609
-		else print ($object->rappro==1 ? $langs->trans("Yes") : ($langs->trans("No").' ('.$langs->trans("ConciliationDisabled").')'));
609
+		else print ($object->rappro == 1 ? $langs->trans("Yes") : ($langs->trans("No").' ('.$langs->trans("ConciliationDisabled").')'));
610 610
 		print '</td></tr>';
611 611
 
612 612
 		print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
@@ -618,18 +618,18 @@  discard block
 block discarded – undo
618 618
 		// Accountancy code
619 619
 		print '<tr class="liste_titre_add"><td class="titlefield">'.$langs->trans("AccountancyCode").'</td>';
620 620
 		print '<td>';
621
-		if (! empty($conf->accounting->enabled)) {
621
+		if (!empty($conf->accounting->enabled)) {
622 622
 			$accountingaccount = new AccountingAccount($db);
623
-			$accountingaccount->fetch('',$object->account_number);
623
+			$accountingaccount->fetch('', $object->account_number);
624 624
 
625
-			print $accountingaccount->getNomUrl(0,1,1,'',1);
625
+			print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
626 626
 		} else {
627 627
 		    print $object->account_number;
628 628
 		}
629 629
 		print '</td></tr>';
630 630
 
631 631
 		// Accountancy journal
632
-		if (! empty($conf->accounting->enabled))
632
+		if (!empty($conf->accounting->enabled))
633 633
 		{
634 634
 		    print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
635 635
 		    print '<td>';
@@ -637,14 +637,14 @@  discard block
 block discarded – undo
637 637
 			$accountingjournal = new AccountingJournal($db);
638 638
 			$accountingjournal->fetch($object->fk_accountancy_journal);
639 639
 
640
-			print $accountingjournal->getNomUrl(0,1,1,'',1);
640
+			print $accountingjournal->getNomUrl(0, 1, 1, '', 1);
641 641
 
642 642
 			print '</td></tr>';
643 643
 		}
644 644
 
645 645
 		// Other attributes
646 646
 		$cols = 2;
647
-		include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
647
+		include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
648 648
 
649 649
 		print '</table>';
650 650
 
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
         // Categories
659 659
         if ($conf->categorie->enabled) {
660 660
             print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td><td>';
661
-            print $form->showCategories($object->id,'bank_account',1);
661
+            print $form->showCategories($object->id, 'bank_account', 1);
662 662
             print "</td></tr>";
663 663
         }
664 664
 
@@ -696,27 +696,27 @@  discard block
 block discarded – undo
696 696
 			}
697 697
 
698 698
 			$ibankey = FormBank::getIBANLabel($object);
699
-			$bickey="BICNumber";
700
-			if ($object->getCountryCode() == 'IN') $bickey="SWIFT";
699
+			$bickey = "BICNumber";
700
+			if ($object->getCountryCode() == 'IN') $bickey = "SWIFT";
701 701
 
702 702
 			print '<tr><td>'.$langs->trans($ibankey).'</td>';
703 703
 			print '<td>'.$object->iban.'&nbsp;';
704
-			if (! empty($object->iban)) {
705
-				if (! checkIbanForAccount($object)) {
706
-					print img_picto($langs->trans("IbanNotValid"),'warning');
704
+			if (!empty($object->iban)) {
705
+				if (!checkIbanForAccount($object)) {
706
+					print img_picto($langs->trans("IbanNotValid"), 'warning');
707 707
 				} else {
708
-					print img_picto($langs->trans("IbanValid"),'info');
708
+					print img_picto($langs->trans("IbanValid"), 'info');
709 709
 				}
710 710
 			}
711 711
 			print '</td></tr>';
712 712
 
713 713
 			print '<tr><td>'.$langs->trans($bickey).'</td>';
714 714
 			print '<td>'.$object->bic.'&nbsp;';
715
-			if (! empty($object->bic)) {
716
-				if (! checkSwiftForAccount($object)) {
717
-					print img_picto($langs->trans("SwiftNotValid"),'warning');
715
+			if (!empty($object->bic)) {
716
+				if (!checkSwiftForAccount($object)) {
717
+					print img_picto($langs->trans("SwiftNotValid"), 'warning');
718 718
 				} else {
719
-					print img_picto($langs->trans("SwiftValid"),'info');
719
+					print img_picto($langs->trans("SwiftValid"), 'info');
720 720
 				}
721 721
 			}
722 722
 			print '</td></tr>';
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 			print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$object->id.'">'.$langs->trans("Modify").'</a>';
755 755
 		}
756 756
 
757
-		$canbedeleted=$object->can_be_deleted();   // Renvoi vrai si compte sans mouvements
757
+		$canbedeleted = $object->can_be_deleted(); // Renvoi vrai si compte sans mouvements
758 758
 		if ($user->rights->banque->configurer && $canbedeleted)
759 759
 		{
760 760
 			print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans("Delete").'</a>';
@@ -770,10 +770,10 @@  discard block
 block discarded – undo
770 770
     /*                                                                            */
771 771
     /* ************************************************************************** */
772 772
 
773
-    if (GETPOST('id','int') && $action == 'edit' && $user->rights->banque->configurer)
773
+    if (GETPOST('id', 'int') && $action == 'edit' && $user->rights->banque->configurer)
774 774
     {
775 775
         $object = new Account($db);
776
-        $object->fetch(GETPOST('id','int'));
776
+        $object->fetch(GETPOST('id', 'int'));
777 777
 
778 778
         print load_fiche_titre($langs->trans("EditFinancialAccount"), '', 'title_bank.png');
779 779
 
@@ -809,16 +809,16 @@  discard block
 block discarded – undo
809 809
 
810 810
 		// Ref
811 811
 		print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Ref").'</td>';
812
-		print '<td><input size="8" type="text" class="flat" name="ref" value="'.(isset($_POST["ref"])?GETPOST("ref"):$object->ref).'"></td></tr>';
812
+		print '<td><input size="8" type="text" class="flat" name="ref" value="'.(isset($_POST["ref"]) ?GETPOST("ref") : $object->ref).'"></td></tr>';
813 813
 
814 814
 		// Label
815 815
         print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
816
-        print '<td><input type="text" class="flat minwidth300" name="label" value="'.(isset($_POST["label"])?GETPOST("label"):$object->label).'"></td></tr>';
816
+        print '<td><input type="text" class="flat minwidth300" name="label" value="'.(isset($_POST["label"]) ?GETPOST("label") : $object->label).'"></td></tr>';
817 817
 
818 818
         // Type
819 819
         print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
820 820
         print '<td class="maxwidth200onsmartphone">';
821
-		$formbank->selectTypeOfBankAccount((isset($_POST["type"])?$_POST["type"]:$object->type),"type");
821
+		$formbank->selectTypeOfBankAccount((isset($_POST["type"]) ? $_POST["type"] : $object->type), "type");
822 822
         print '</td></tr>';
823 823
 
824 824
 		// Currency
@@ -826,9 +826,9 @@  discard block
 block discarded – undo
826 826
 		print '<input type="hidden" value="'.$object->currency_code.'">';
827 827
 		print '</td>';
828 828
 		print '<td class="maxwidth200onsmartphone">';
829
-		$selectedcode=$object->currency_code;
830
-		if (! $selectedcode) $selectedcode=$conf->currency;
831
-		print $form->selectCurrency((isset($_POST["account_currency_code"])?$_POST["account_currency_code"]:$selectedcode), 'account_currency_code');
829
+		$selectedcode = $object->currency_code;
830
+		if (!$selectedcode) $selectedcode = $conf->currency;
831
+		print $form->selectCurrency((isset($_POST["account_currency_code"]) ? $_POST["account_currency_code"] : $selectedcode), 'account_currency_code');
832 832
 		//print $langs->trans("Currency".$conf->currency);
833 833
 		//print '<input type="hidden" name="account_currency_code" value="'.$conf->currency.'">';
834 834
 		print '</td></tr>';
@@ -836,27 +836,27 @@  discard block
 block discarded – undo
836 836
 		// Status
837 837
         print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
838 838
         print '<td class="maxwidth200onsmartphone">';
839
-        print $form->selectarray("clos", $object->status, (isset($_POST["clos"])?$_POST["clos"]:$object->clos));
839
+        print $form->selectarray("clos", $object->status, (isset($_POST["clos"]) ? $_POST["clos"] : $object->clos));
840 840
         print '</td></tr>';
841 841
 
842 842
 		// Country
843
-		$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id;
844
-		$selectedcode=$object->country_code;
845
-		if (isset($_POST["account_country_id"])) $selectedcode=$_POST["account_country_id"];
846
-		else if (empty($selectedcode)) $selectedcode=$mysoc->country_code;
847
-		$object->country_code = getCountry($selectedcode, 2);	// Force country code on account to have following field on bank fields matching country rules
843
+		$object->country_id = $object->country_id ? $object->country_id : $mysoc->country_id;
844
+		$selectedcode = $object->country_code;
845
+		if (isset($_POST["account_country_id"])) $selectedcode = $_POST["account_country_id"];
846
+		else if (empty($selectedcode)) $selectedcode = $mysoc->country_code;
847
+		$object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules
848 848
 
849 849
 		print '<tr><td class="fieldrequired">'.$langs->trans("Country").'</td>';
850 850
 		print '<td class="maxwidth200onsmartphone">';
851
-		print $form->select_country($selectedcode,'account_country_id');
852
-		if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
851
+		print $form->select_country($selectedcode, 'account_country_id');
852
+		if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
853 853
 		print '</td></tr>';
854 854
 
855 855
 		// State
856 856
 		print '<tr><td>'.$langs->trans('State').'</td><td class="maxwidth200onsmartphone">';
857 857
 		if ($selectedcode)
858 858
 		{
859
-			print $formcompany->select_state(isset($_POST["account_state_id"])?$_POST["account_state_id"]:$object->state_id,$selectedcode,'account_state_id');
859
+			print $formcompany->select_state(isset($_POST["account_state_id"]) ? $_POST["account_state_id"] : $object->state_id, $selectedcode, 'account_state_id');
860 860
 		}
861 861
 		else
862 862
 		{
@@ -867,22 +867,22 @@  discard block
 block discarded – undo
867 867
 		// Conciliable
868 868
         print '<tr><td>'.$langs->trans("Conciliable").'</td>';
869 869
         print '<td>';
870
-        $conciliate=$object->canBeConciliated();
870
+        $conciliate = $object->canBeConciliated();
871 871
         if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
872 872
         else if ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')';
873
-        else print '<input type="checkbox" class="flat" name="norappro"'.(($conciliate > 0)?'':' checked="checked"').'"> '.$langs->trans("DisableConciliation");
873
+        else print '<input type="checkbox" class="flat" name="norappro"'.(($conciliate > 0) ? '' : ' checked="checked"').'"> '.$langs->trans("DisableConciliation");
874 874
         print '</td></tr>';
875 875
 
876 876
         // Balance
877 877
 		print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
878
-		print '<td><input size="12" type="text" class="flat" name="account_min_allowed" value="'.(isset($_POST["account_min_allowed"])?GETPOST("account_min_allowed"):$object->min_allowed).'"></td></tr>';
878
+		print '<td><input size="12" type="text" class="flat" name="account_min_allowed" value="'.(isset($_POST["account_min_allowed"]) ?GETPOST("account_min_allowed") : $object->min_allowed).'"></td></tr>';
879 879
 
880 880
 		print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
881
-		print '<td ><input size="12" type="text" class="flat" name="account_min_desired" value="'.(isset($_POST["account_min_desired"])?GETPOST("account_min_desired"):$object->min_desired).'"></td></tr>';
881
+		print '<td ><input size="12" type="text" class="flat" name="account_min_desired" value="'.(isset($_POST["account_min_desired"]) ?GETPOST("account_min_desired") : $object->min_desired).'"></td></tr>';
882 882
 
883 883
 		// Web
884 884
         print '<tr><td>'.$langs->trans("Web").'</td>';
885
-        print '<td><input class="maxwidth200onsmartphone" type="text" class="flat" name="url" value="'.(isset($_POST["url"])?GETPOST("url"):$object->url).'">';
885
+        print '<td><input class="maxwidth200onsmartphone" type="text" class="flat" name="url" value="'.(isset($_POST["url"]) ?GETPOST("url") : $object->url).'">';
886 886
         print '</td></tr>';
887 887
 
888 888
         // Tags-Categories
@@ -891,8 +891,8 @@  discard block
 block discarded – undo
891 891
             print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td>';
892 892
             $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
893 893
             $c = new Categorie($db);
894
-            $cats = $c->containing($object->id,Categorie::TYPE_ACCOUNT);
895
-            foreach($cats as $cat) {
894
+            $cats = $c->containing($object->id, Categorie::TYPE_ACCOUNT);
895
+            foreach ($cats as $cat) {
896 896
                 $arrayselected[] = $cat->id;
897 897
             }
898 898
             print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
@@ -904,17 +904,17 @@  discard block
 block discarded – undo
904 904
 		print '<td>';
905 905
 	    // Editor wysiwyg
906 906
 		require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
907
-		$doleditor=new DolEditor('account_comment',(GETPOST("account_comment")?GETPOST("account_comment"):$object->comment),'',90,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_4,'95%');
907
+		$doleditor = new DolEditor('account_comment', (GETPOST("account_comment") ?GETPOST("account_comment") : $object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '95%');
908 908
 		$doleditor->Create();
909 909
 		print '</td></tr>';
910 910
 
911 911
 		// Other attributes
912
-		$parameters=array();
913
-		$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
912
+		$parameters = array();
913
+		$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
914 914
         print $hookmanager->resPrint;
915
-		if (empty($reshook) && ! empty($extrafields->attribute_label))
915
+		if (empty($reshook) && !empty($extrafields->attribute_label))
916 916
 		{
917
-			print $object->showOptionals($extrafields,'edit');
917
+			print $object->showOptionals($extrafields, 'edit');
918 918
 		}
919 919
 
920 920
 		print '</table>';
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 		print '</td></tr>';
943 943
 
944 944
 		// Accountancy journal
945
-		if (! empty($conf->accounting->enabled))
945
+		if (!empty($conf->accounting->enabled))
946 946
 		{
947 947
 			print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
948 948
 			print '<td>';
@@ -991,8 +991,8 @@  discard block
 block discarded – undo
991 991
 			}
992 992
 
993 993
 			$ibankey = FormBank::getIBANLabel($object);
994
-			$bickey="BICNumber";
995
-			if ($object->getCountryCode() == 'IN') $bickey="SWIFT";
994
+			$bickey = "BICNumber";
995
+			if ($object->getCountryCode() == 'IN') $bickey = "SWIFT";
996 996
 
997 997
 			// IBAN
998 998
 			print '<tr><td>'.$langs->trans($ibankey).'</td>';
Please login to merge, or discard this patch.
htdocs/fichinter/class/fichinter.class.php 3 patches
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	public $table_element='fichinter';
39 39
 	public $fk_element='fk_fichinter';
40 40
 	public $table_element_line='fichinterdet';
41
-    public $picto = 'intervention';
41
+	public $picto = 'intervention';
42 42
 
43 43
 	/**
44 44
 	 * {@inheritdoc}
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 *	Constructor
84 84
 	 *
85 85
 	 *  @param	DoliDB	$db		Database handler
86
- 	 */
86
+	 */
87 87
 	function __construct($db)
88 88
 	{
89 89
 		$this->db = $db;
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 *	Create an intervention into data base
153 153
 	 *
154 154
 	 *  @param		User	$user 		Objet user that make creation
155
-     *	@param		int		$notrigger	Disable all triggers
155
+	 *	@param		int		$notrigger	Disable all triggers
156 156
 	 *	@return		int		<0 if KO, >0 if OK
157 157
 	 */
158 158
 	function create($user, $notrigger=0)
@@ -237,13 +237,13 @@  discard block
 block discarded – undo
237 237
 			}
238 238
 
239 239
 			if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
240
-            {
241
-            	$result=$this->insertExtraFields();
242
-            	if ($result < 0)
243
-            	{
244
-            		$error++;
245
-            	}
246
-            }
240
+			{
241
+				$result=$this->insertExtraFields();
242
+				if ($result < 0)
243
+				{
244
+					$error++;
245
+				}
246
+			}
247 247
 
248 248
 			// Add linked object
249 249
 			if (! $error && $this->origin && $this->origin_id)
@@ -253,13 +253,13 @@  discard block
 block discarded – undo
253 253
 			}
254 254
 
255 255
 
256
-            if (! $notrigger)
257
-            {
258
-                // Call trigger
259
-                $result=$this->call_trigger('FICHINTER_CREATE',$user);
260
-                if ($result < 0) { $error++; }
261
-                // End call triggers
262
-            }
256
+			if (! $notrigger)
257
+			{
258
+				// Call trigger
259
+				$result=$this->call_trigger('FICHINTER_CREATE',$user);
260
+				if ($result < 0) { $error++; }
261
+				// End call triggers
262
+			}
263 263
 
264 264
 			if (! $error)
265 265
 			{
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	 *	Update an intervention
288 288
 	 *
289 289
 	 *	@param		User	$user 		Objet user that make creation
290
-     *	@param		int		$notrigger	Disable all triggers
290
+	 *	@param		int		$notrigger	Disable all triggers
291 291
 	 *	@return		int		<0 if KO, >0 if OK
292 292
 	 */
293 293
 	function update($user, $notrigger=0)
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
 
317 317
 			if (! $notrigger)
318 318
 			{
319
-                // Call trigger
320
-                $result=$this->call_trigger('FICHINTER_MODIFY',$user);
321
-                if ($result < 0) { $error++; $this->db->rollback(); return -1; }
322
-                // End call triggers
319
+				// Call trigger
320
+				$result=$this->call_trigger('FICHINTER_MODIFY',$user);
321
+				if ($result < 0) { $error++; $this->db->rollback(); return -1; }
322
+				// End call triggers
323 323
 			}
324 324
 
325 325
 			$this->db->commit();
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 	 *	Validate a intervention
447 447
 	 *
448 448
 	 *	@param		User		$user		User that validate
449
-     *  @param		int			$notrigger	1=Does not execute triggers, 0= execute triggers
449
+	 *  @param		int			$notrigger	1=Does not execute triggers, 0= execute triggers
450 450
 	 *	@return		int						<0 if KO, >0 if OK
451 451
 	 */
452 452
 	function setValid($user, $notrigger=0)
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 			{
472 472
 				$num = $this->ref;
473 473
 			}
474
-            $this->newref = $num;
474
+			$this->newref = $num;
475 475
 
476 476
 			$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter";
477 477
 			$sql.= " SET fk_statut = 1";
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
 
493 493
 			if (! $error && ! $notrigger)
494 494
 			{
495
-                // Call trigger
496
-                $result=$this->call_trigger('FICHINTER_VALIDATE',$user);
497
-                if ($result < 0) { $error++; }
498
-                // End call triggers
495
+				// Call trigger
496
+				$result=$this->call_trigger('FICHINTER_VALIDATE',$user);
497
+				if ($result < 0) { $error++; }
498
+				// End call triggers
499 499
 			}
500 500
 
501 501
 			if (! $error)
@@ -517,17 +517,17 @@  discard block
 block discarded – undo
517 517
 
518 518
 						if (@rename($dirsource, $dirdest))
519 519
 						{
520
-	                        dol_syslog("Rename ok");
521
-	                        // Rename docs starting with $oldref with $newref
522
-	                        $listoffiles=dol_dir_list($conf->ficheinter->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
523
-	                        foreach($listoffiles as $fileentry)
524
-	                        {
525
-	                        	$dirsource=$fileentry['name'];
526
-	                        	$dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
527
-	                        	$dirsource=$fileentry['path'].'/'.$dirsource;
528
-	                        	$dirdest=$fileentry['path'].'/'.$dirdest;
529
-	                        	@rename($dirsource, $dirdest);
530
-	                        }
520
+							dol_syslog("Rename ok");
521
+							// Rename docs starting with $oldref with $newref
522
+							$listoffiles=dol_dir_list($conf->ficheinter->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
523
+							foreach($listoffiles as $fileentry)
524
+							{
525
+								$dirsource=$fileentry['name'];
526
+								$dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
527
+								$dirsource=$fileentry['path'].'/'.$dirsource;
528
+								$dirdest=$fileentry['path'].'/'.$dirdest;
529
+								@rename($dirsource, $dirdest);
530
+							}
531 531
 						}
532 532
 					}
533 533
 				}
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 		if ($mode == 5)
648 648
 			return '<span class="hideonsmartphone">'.$langs->trans($this->statuts_short[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
649 649
 		if ($mode == 6)
650
-		    return '<span class="hideonsmartphone">'.$langs->trans($this->statuts[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
650
+			return '<span class="hideonsmartphone">'.$langs->trans($this->statuts[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
651 651
 
652 652
 		return '';
653 653
 	}
@@ -657,8 +657,8 @@  discard block
 block discarded – undo
657 657
 	 *
658 658
 	 *	@param		int		$withpicto					0=_No picto, 1=Includes the picto in the linkn, 2=Picto only
659 659
 	 *	@param		string	$option						Options
660
-     *  @param	    int   	$notooltip					1=Disable tooltip
661
-     *  @param      int     $save_lastsearch_value		-1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
660
+	 *  @param	    int   	$notooltip					1=Disable tooltip
661
+	 *  @param      int     $save_lastsearch_value		-1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
662 662
 	 *	@return		string								String with URL
663 663
 	 */
664 664
 	function getNomUrl($withpicto=0, $option='', $notooltip=0, $save_lastsearch_value=-1)
@@ -667,20 +667,20 @@  discard block
 block discarded – undo
667 667
 
668 668
 		$result='';
669 669
 
670
-        $label = '<u>' . $langs->trans("ShowIntervention") . '</u>';
671
-        if (! empty($this->ref))
672
-            $label .= '<br><b>' . $langs->trans('Ref') . ':</b> '.$this->ref;
670
+		$label = '<u>' . $langs->trans("ShowIntervention") . '</u>';
671
+		if (! empty($this->ref))
672
+			$label .= '<br><b>' . $langs->trans('Ref') . ':</b> '.$this->ref;
673 673
 
674
-        $picto='intervention';
675
-        $url = DOL_URL_ROOT.'/fichinter/card.php?id='.$this->id;
674
+		$picto='intervention';
675
+		$url = DOL_URL_ROOT.'/fichinter/card.php?id='.$this->id;
676 676
 
677
-        if ($option !== 'nolink')
678
-        {
679
-        	// Add param to save lastsearch_values or not
680
-        	$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
681
-        	if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
682
-        	if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
683
-       	}
677
+		if ($option !== 'nolink')
678
+		{
679
+			// Add param to save lastsearch_values or not
680
+			$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
681
+			if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
682
+			if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
683
+	   	}
684 684
 
685 685
 		$linkclose='';
686 686
 		if (empty($notooltip))
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 		$linkstart.=$linkclose.'>';
699 699
 		$linkend='</a>';
700 700
 
701
-        if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
701
+		if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
702 702
 		if ($withpicto && $withpicto != 2) $result.=' ';
703 703
 		if ($withpicto != 2) $result.=$linkstart.$this->ref.$linkend;
704 704
 		return $result;
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 	function delete($user, $notrigger=0)
834 834
 	{
835 835
 		global $conf,$langs;
836
-        require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
836
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
837 837
 
838 838
 		$error=0;
839 839
 
@@ -899,10 +899,10 @@  discard block
 block discarded – undo
899 899
 
900 900
 				if (! $notrigger)
901 901
 				{
902
-                    // Call trigger
903
-                    $result=$this->call_trigger('FICHINTER_DELETE',$user);
904
-                    if ($result < 0) { $error++; $this->db->rollback(); return -1; }
905
-                    // End call triggers
902
+					// Call trigger
903
+					$result=$this->call_trigger('FICHINTER_DELETE',$user);
904
+					if ($result < 0) { $error++; $this->db->rollback(); return -1; }
905
+					// End call triggers
906 906
 				}
907 907
 
908 908
 				$this->db->commit();
@@ -1024,98 +1024,98 @@  discard block
 block discarded – undo
1024 1024
 
1025 1025
 
1026 1026
 
1027
-    /**
1028
-     *	Load an object from its id and create a new one in database
1029
-     *
1030
-     *	@param		int			$socid			Id of thirdparty
1031
-     *	@return		int							New id of clone
1032
-     */
1033
-    function createFromClone($socid=0)
1034
-    {
1035
-        global $user,$hookmanager;
1027
+	/**
1028
+	 *	Load an object from its id and create a new one in database
1029
+	 *
1030
+	 *	@param		int			$socid			Id of thirdparty
1031
+	 *	@return		int							New id of clone
1032
+	 */
1033
+	function createFromClone($socid=0)
1034
+	{
1035
+		global $user,$hookmanager;
1036 1036
 
1037
-        $error=0;
1037
+		$error=0;
1038 1038
 
1039
-        $this->context['createfromclone'] = 'createfromclone';
1039
+		$this->context['createfromclone'] = 'createfromclone';
1040 1040
 
1041
-        $this->db->begin();
1041
+		$this->db->begin();
1042 1042
 
1043 1043
 		// get extrafields so they will be clone
1044 1044
 		foreach($this->lines as $line)
1045 1045
 			$line->fetch_optionals($line->rowid);
1046 1046
 
1047
-        // Load source object
1048
-        $objFrom = clone $this;
1047
+		// Load source object
1048
+		$objFrom = clone $this;
1049 1049
 
1050
-        // Change socid if needed
1051
-        if (! empty($socid) && $socid != $this->socid)
1052
-        {
1053
-            $objsoc = new Societe($this->db);
1050
+		// Change socid if needed
1051
+		if (! empty($socid) && $socid != $this->socid)
1052
+		{
1053
+			$objsoc = new Societe($this->db);
1054 1054
 
1055
-            if ($objsoc->fetch($socid)>0)
1056
-            {
1057
-                $this->socid 				= $objsoc->id;
1058
-                //$this->cond_reglement_id	= (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
1059
-                //$this->mode_reglement_id	= (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
1060
-                $this->fk_project			= '';
1061
-                $this->fk_delivery_address	= '';
1062
-            }
1055
+			if ($objsoc->fetch($socid)>0)
1056
+			{
1057
+				$this->socid 				= $objsoc->id;
1058
+				//$this->cond_reglement_id	= (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
1059
+				//$this->mode_reglement_id	= (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
1060
+				$this->fk_project			= '';
1061
+				$this->fk_delivery_address	= '';
1062
+			}
1063 1063
 
1064
-            // TODO Change product price if multi-prices
1065
-        }
1064
+			// TODO Change product price if multi-prices
1065
+		}
1066 1066
 
1067
-        $this->id=0;
1067
+		$this->id=0;
1068 1068
 		$this->ref = '';
1069
-        $this->statut=0;
1070
-
1071
-        // Clear fields
1072
-        $this->user_author_id     = $user->id;
1073
-        $this->user_valid         = '';
1074
-        $this->date_creation      = '';
1075
-        $this->date_validation    = '';
1076
-        $this->ref_client         = '';
1077
-
1078
-        // Create clone
1079
-        $result=$this->create($user);
1080
-        if ($result < 0) $error++;
1081
-
1082
-        if (! $error)
1083
-        {
1084
-            // Add lines because it is not included into create function
1085
-            foreach ($this->lines as $line)
1086
-            {
1087
-            	$this->addline($user, $this->id, $line->desc, $line->datei, $line->duration);
1088
-            }
1089
-
1090
-        	// Hook of thirdparty module
1091
-            if (is_object($hookmanager))
1092
-            {
1093
-                $parameters=array('objFrom'=>$objFrom);
1094
-                $action='';
1095
-                $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1096
-                if ($reshook < 0) $error++;
1097
-            }
1098
-
1099
-            // Call trigger
1100
-            $result=$this->call_trigger('INTERVENTION_CLONE',$user);
1101
-            if ($result < 0) $error++;
1102
-            // End call triggers
1103
-        }
1104
-
1105
-        unset($this->context['createfromclone']);
1106
-
1107
-        // End
1108
-        if (! $error)
1109
-        {
1110
-            $this->db->commit();
1111
-            return $this->id;
1112
-        }
1113
-        else
1114
-        {
1115
-            $this->db->rollback();
1116
-            return -1;
1117
-        }
1118
-    }
1069
+		$this->statut=0;
1070
+
1071
+		// Clear fields
1072
+		$this->user_author_id     = $user->id;
1073
+		$this->user_valid         = '';
1074
+		$this->date_creation      = '';
1075
+		$this->date_validation    = '';
1076
+		$this->ref_client         = '';
1077
+
1078
+		// Create clone
1079
+		$result=$this->create($user);
1080
+		if ($result < 0) $error++;
1081
+
1082
+		if (! $error)
1083
+		{
1084
+			// Add lines because it is not included into create function
1085
+			foreach ($this->lines as $line)
1086
+			{
1087
+				$this->addline($user, $this->id, $line->desc, $line->datei, $line->duration);
1088
+			}
1089
+
1090
+			// Hook of thirdparty module
1091
+			if (is_object($hookmanager))
1092
+			{
1093
+				$parameters=array('objFrom'=>$objFrom);
1094
+				$action='';
1095
+				$reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1096
+				if ($reshook < 0) $error++;
1097
+			}
1098
+
1099
+			// Call trigger
1100
+			$result=$this->call_trigger('INTERVENTION_CLONE',$user);
1101
+			if ($result < 0) $error++;
1102
+			// End call triggers
1103
+		}
1104
+
1105
+		unset($this->context['createfromclone']);
1106
+
1107
+		// End
1108
+		if (! $error)
1109
+		{
1110
+			$this->db->commit();
1111
+			return $this->id;
1112
+		}
1113
+		else
1114
+		{
1115
+			$this->db->rollback();
1116
+			return -1;
1117
+		}
1118
+	}
1119 1119
 
1120 1120
 
1121 1121
 	/**
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
 	 *	Insert the line into database
1339 1339
 	 *
1340 1340
 	 *	@param		User	$user 		Objet user that make creation
1341
-     *	@param		int		$notrigger	Disable all triggers
1341
+	 *	@param		int		$notrigger	Disable all triggers
1342 1342
 	 *	@return		int		<0 if ko, >0 if ok
1343 1343
 	 */
1344 1344
 	function insert($user, $notrigger=0)
@@ -1386,14 +1386,14 @@  discard block
 block discarded – undo
1386 1386
 			$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'fichinterdet');
1387 1387
 
1388 1388
 			if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
1389
-            {
1390
-            	$this->id=$this->rowid;
1391
-            	$result=$this->insertExtraFields();
1392
-            	if ($result < 0)
1393
-            	{
1394
-            		$error++;
1395
-            	}
1396
-            }
1389
+			{
1390
+				$this->id=$this->rowid;
1391
+				$result=$this->insertExtraFields();
1392
+				if ($result < 0)
1393
+				{
1394
+					$error++;
1395
+				}
1396
+			}
1397 1397
 
1398 1398
 
1399 1399
 			$result=$this->update_total();
@@ -1404,10 +1404,10 @@  discard block
 block discarded – undo
1404 1404
 
1405 1405
 				if (! $notrigger)
1406 1406
 				{
1407
-                    // Call trigger
1408
-                    $result=$this->call_trigger('LINEFICHINTER_CREATE',$user);
1409
-                    if ($result < 0) { $error++; }
1410
-                    // End call triggers
1407
+					// Call trigger
1408
+					$result=$this->call_trigger('LINEFICHINTER_CREATE',$user);
1409
+					if ($result < 0) { $error++; }
1410
+					// End call triggers
1411 1411
 				}
1412 1412
 			}
1413 1413
 
@@ -1434,7 +1434,7 @@  discard block
 block discarded – undo
1434 1434
 	 *	Update intervention into database
1435 1435
 	 *
1436 1436
 	 *	@param		User	$user 		Objet user that make creation
1437
-     *	@param		int		$notrigger	Disable all triggers
1437
+	 *	@param		int		$notrigger	Disable all triggers
1438 1438
 	 *	@return		int		<0 if ko, >0 if ok
1439 1439
 	 */
1440 1440
 	function update($user,$notrigger=0)
@@ -1457,14 +1457,14 @@  discard block
 block discarded – undo
1457 1457
 		{
1458 1458
 
1459 1459
 			if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
1460
-        	{
1461
-        		$this->id=$this->rowid;
1462
-        		$result=$this->insertExtraFields();
1463
-        		if ($result < 0)
1464
-        		{
1465
-        			$error++;
1466
-        		}
1467
-        	}
1460
+			{
1461
+				$this->id=$this->rowid;
1462
+				$result=$this->insertExtraFields();
1463
+				if ($result < 0)
1464
+				{
1465
+					$error++;
1466
+				}
1467
+			}
1468 1468
 
1469 1469
 			$result=$this->update_total();
1470 1470
 			if ($result > 0)
@@ -1472,10 +1472,10 @@  discard block
 block discarded – undo
1472 1472
 
1473 1473
 				if (! $notrigger)
1474 1474
 				{
1475
-                    // Call trigger
1476
-                    $result=$this->call_trigger('LINEFICHINTER_UPDATE',$user);
1477
-                    if ($result < 0) { $error++; }
1478
-                    // End call triggers
1475
+					// Call trigger
1476
+					$result=$this->call_trigger('LINEFICHINTER_UPDATE',$user);
1477
+					if ($result < 0) { $error++; }
1478
+					// End call triggers
1479 1479
 				}
1480 1480
 			}
1481 1481
 
@@ -1555,7 +1555,7 @@  discard block
 block discarded – undo
1555 1555
 	 *	Delete a intervention line
1556 1556
 	 *
1557 1557
 	 *	@param		User	$user 		Objet user that make creation
1558
-     *	@param		int		$notrigger	Disable all triggers
1558
+	 *	@param		int		$notrigger	Disable all triggers
1559 1559
 	 *	@return     int		>0 if ok, <0 if ko
1560 1560
 	 */
1561 1561
 	function deleteline($user,$notrigger=0)
@@ -1577,14 +1577,14 @@  discard block
 block discarded – undo
1577 1577
 				{
1578 1578
 					if (! $notrigger)
1579 1579
 					{
1580
-                        // Call trigger
1581
-                        $result=$this->call_trigger('LINEFICHINTER_DELETE',$user);
1582
-                        if ($result < 0) { $error++; $this->db->rollback(); return -1; }
1583
-                        // End call triggers
1580
+						// Call trigger
1581
+						$result=$this->call_trigger('LINEFICHINTER_DELETE',$user);
1582
+						if ($result < 0) { $error++; $this->db->rollback(); return -1; }
1583
+						// End call triggers
1584 1584
 					}
1585 1585
 
1586
-                    $this->db->commit();
1587
-                    return $result;
1586
+					$this->db->commit();
1587
+					return $result;
1588 1588
 				}
1589 1589
 				else
1590 1590
 				{
Please login to merge, or discard this patch.
Spacing   +337 added lines, -337 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
  * 	\ingroup    ficheinter
26 26
  * 	\brief      Fichier de la classe des gestion des fiches interventions
27 27
  */
28
-require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
29
-require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php';
28
+require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
29
+require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
30 30
 
31 31
 
32 32
 /**
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
  */
35 35
 class Fichinter extends CommonObject
36 36
 {
37
-	public $element='fichinter';
38
-	public $table_element='fichinter';
39
-	public $fk_element='fk_fichinter';
40
-	public $table_element_line='fichinterdet';
37
+	public $element = 'fichinter';
38
+	public $table_element = 'fichinter';
39
+	public $fk_element = 'fk_fichinter';
40
+	public $table_element_line = 'fichinterdet';
41 41
     public $picto = 'intervention';
42 42
 
43 43
 	/**
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 */
46 46
 	protected $table_ref_field = 'ref';
47 47
 
48
-	var $socid;		// Id client
48
+	var $socid; // Id client
49 49
 
50 50
 	var $author;
51 51
 	var $datec;
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 	var $datet;
56 56
 	var $datem;
57 57
 	var $duration;
58
-	var $statut;		// 0=draft, 1=validated, 2=invoiced, 3=Terminate
58
+	var $statut; // 0=draft, 1=validated, 2=invoiced, 3=Terminate
59 59
 	var $description;
60 60
 	var $fk_contrat;
61
-	var $extraparams=array();
61
+	var $extraparams = array();
62 62
 
63 63
 	var $lines = array();
64 64
 
@@ -93,18 +93,18 @@  discard block
 block discarded – undo
93 93
 		$this->statut = 0;
94 94
 
95 95
 		// List of language codes for status
96
-		$this->statuts[0]='Draft';
97
-		$this->statuts[1]='Validated';
98
-		$this->statuts[2]='StatusInterInvoiced';
99
-		$this->statuts[3]='Done';
100
-		$this->statuts_short[0]='Draft';
101
-		$this->statuts_short[1]='Validated';
102
-		$this->statuts_short[2]='StatusInterInvoiced';
103
-		$this->statuts_short[3]='Done';
104
-		$this->statuts_logo[0]='statut0';
105
-		$this->statuts_logo[1]='statut1';
106
-		$this->statuts_logo[2]='statut6';
107
-		$this->statuts_logo[3]='statut6';
96
+		$this->statuts[0] = 'Draft';
97
+		$this->statuts[1] = 'Validated';
98
+		$this->statuts[2] = 'StatusInterInvoiced';
99
+		$this->statuts[3] = 'Done';
100
+		$this->statuts_short[0] = 'Draft';
101
+		$this->statuts_short[1] = 'Validated';
102
+		$this->statuts_short[2] = 'StatusInterInvoiced';
103
+		$this->statuts_short[3] = 'Done';
104
+		$this->statuts_logo[0] = 'statut0';
105
+		$this->statuts_logo[1] = 'statut1';
106
+		$this->statuts_logo[2] = 'statut6';
107
+		$this->statuts_logo[3] = 'statut6';
108 108
 	}
109 109
 
110 110
 	/**
@@ -116,26 +116,26 @@  discard block
 block discarded – undo
116 116
 	{
117 117
 		global $user;
118 118
 
119
-		$this->nb=array();
119
+		$this->nb = array();
120 120
 		$clause = "WHERE";
121 121
 
122 122
 		$sql = "SELECT count(fi.rowid) as nb";
123
-		$sql.= " FROM ".MAIN_DB_PREFIX."fichinter as fi";
124
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON fi.fk_soc = s.rowid";
123
+		$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as fi";
124
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON fi.fk_soc = s.rowid";
125 125
 		if (!$user->rights->societe->client->voir && !$user->societe_id)
126 126
 		{
127
-			$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
128
-			$sql.= " WHERE sc.fk_user = " .$user->id;
127
+			$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
128
+			$sql .= " WHERE sc.fk_user = ".$user->id;
129 129
 			$clause = "AND";
130 130
 		}
131
-		$sql.= " ".$clause." fi.entity IN (".getEntity($this->element, 1).")";
131
+		$sql .= " ".$clause." fi.entity IN (".getEntity($this->element, 1).")";
132 132
 
133
-		$resql=$this->db->query($sql);
133
+		$resql = $this->db->query($sql);
134 134
 		if ($resql)
135 135
 		{
136
-			while ($obj=$this->db->fetch_object($resql))
136
+			while ($obj = $this->db->fetch_object($resql))
137 137
 			{
138
-				$this->nb["fichinters"]=$obj->nb;
138
+				$this->nb["fichinters"] = $obj->nb;
139 139
 			}
140 140
 			$this->db->free($resql);
141 141
 			return 1;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		else
144 144
 		{
145 145
 			dol_print_error($this->db);
146
-			$this->error=$this->db->error();
146
+			$this->error = $this->db->error();
147 147
 			return -1;
148 148
 		}
149 149
 	}
@@ -155,90 +155,90 @@  discard block
 block discarded – undo
155 155
      *	@param		int		$notrigger	Disable all triggers
156 156
 	 *	@return		int		<0 if KO, >0 if OK
157 157
 	 */
158
-	function create($user, $notrigger=0)
158
+	function create($user, $notrigger = 0)
159 159
 	{
160 160
 		global $conf, $user, $langs;
161 161
 
162 162
 		dol_syslog(get_class($this)."::create ref=".$this->ref);
163 163
 
164 164
 		// Check parameters
165
-		if (! empty($this->ref))	// We check that ref is not already used
165
+		if (!empty($this->ref))	// We check that ref is not already used
166 166
 		{
167
-			$result=self::isExistingObject($this->element, 0, $this->ref);	// Check ref is not yet used
167
+			$result = self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used
168 168
 			if ($result > 0)
169 169
 			{
170
-				$this->error='ErrorRefAlreadyExists';
171
-				dol_syslog(get_class($this)."::create ".$this->error,LOG_WARNING);
170
+				$this->error = 'ErrorRefAlreadyExists';
171
+				dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING);
172 172
 				$this->db->rollback();
173 173
 				return -1;
174 174
 			}
175 175
 		}
176
-		if (! is_numeric($this->duration)) $this->duration = 0;
176
+		if (!is_numeric($this->duration)) $this->duration = 0;
177 177
 
178 178
 		if ($this->socid <= 0)
179 179
 		{
180
-			$this->error='ErrorBadParameterForFunc';
181
-			dol_syslog(get_class($this)."::create ".$this->error,LOG_ERR);
180
+			$this->error = 'ErrorBadParameterForFunc';
181
+			dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
182 182
 			return -1;
183 183
 		}
184 184
 
185 185
 		$soc = new Societe($this->db);
186
-		$result=$soc->fetch($this->socid);
186
+		$result = $soc->fetch($this->socid);
187 187
 
188
-		$now=dol_now();
188
+		$now = dol_now();
189 189
 
190 190
 		$this->db->begin();
191 191
 
192 192
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."fichinter (";
193
-		$sql.= "fk_soc";
194
-		$sql.= ", datec";
195
-		$sql.= ", ref";
196
-		$sql.= ", entity";
197
-		$sql.= ", fk_user_author";
198
-		$sql.= ", fk_user_modif";
199
-		$sql.= ", description";
200
-		$sql.= ", model_pdf";
201
-		$sql.= ", fk_projet";
202
-		$sql.= ", fk_contrat";
203
-		$sql.= ", fk_statut";
204
-		$sql.= ", note_private";
205
-		$sql.= ", note_public";
206
-		$sql.= ") ";
207
-		$sql.= " VALUES (";
208
-		$sql.= $this->socid;
209
-		$sql.= ", '".$this->db->idate($now)."'";
210
-		$sql.= ", '".$this->db->escape($this->ref)."'";
211
-		$sql.= ", ".$conf->entity;
212
-		$sql.= ", ".$user->id;
213
-		$sql.= ", ".$user->id;
214
-		$sql.= ", ".($this->description?"'".$this->db->escape($this->description)."'":"null");
215
-		$sql.= ", '".$this->db->escape($this->modelpdf)."'";
216
-		$sql.= ", ".($this->fk_project ? $this->fk_project : 0);
217
-		$sql.= ", ".($this->fk_contrat ? $this->fk_contrat : 0);
218
-		$sql.= ", ".$this->statut;
219
-		$sql.= ", ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null");
220
-		$sql.= ", ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null");
221
-		$sql.= ")";
193
+		$sql .= "fk_soc";
194
+		$sql .= ", datec";
195
+		$sql .= ", ref";
196
+		$sql .= ", entity";
197
+		$sql .= ", fk_user_author";
198
+		$sql .= ", fk_user_modif";
199
+		$sql .= ", description";
200
+		$sql .= ", model_pdf";
201
+		$sql .= ", fk_projet";
202
+		$sql .= ", fk_contrat";
203
+		$sql .= ", fk_statut";
204
+		$sql .= ", note_private";
205
+		$sql .= ", note_public";
206
+		$sql .= ") ";
207
+		$sql .= " VALUES (";
208
+		$sql .= $this->socid;
209
+		$sql .= ", '".$this->db->idate($now)."'";
210
+		$sql .= ", '".$this->db->escape($this->ref)."'";
211
+		$sql .= ", ".$conf->entity;
212
+		$sql .= ", ".$user->id;
213
+		$sql .= ", ".$user->id;
214
+		$sql .= ", ".($this->description ? "'".$this->db->escape($this->description)."'" : "null");
215
+		$sql .= ", '".$this->db->escape($this->modelpdf)."'";
216
+		$sql .= ", ".($this->fk_project ? $this->fk_project : 0);
217
+		$sql .= ", ".($this->fk_contrat ? $this->fk_contrat : 0);
218
+		$sql .= ", ".$this->statut;
219
+		$sql .= ", ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null");
220
+		$sql .= ", ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null");
221
+		$sql .= ")";
222 222
 
223 223
 		dol_syslog(get_class($this)."::create", LOG_DEBUG);
224
-		$result=$this->db->query($sql);
224
+		$result = $this->db->query($sql);
225 225
 		if ($result)
226 226
 		{
227
-			$this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."fichinter");
227
+			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."fichinter");
228 228
 
229 229
 			if ($this->id)
230 230
 			{
231
-				$this->ref='(PROV'.$this->id.')';
231
+				$this->ref = '(PROV'.$this->id.')';
232 232
 				$sql = 'UPDATE '.MAIN_DB_PREFIX."fichinter SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id;
233 233
 
234 234
 				dol_syslog(get_class($this)."::create", LOG_DEBUG);
235
-				$resql=$this->db->query($sql);
236
-				if (! $resql) $error++;
235
+				$resql = $this->db->query($sql);
236
+				if (!$resql) $error++;
237 237
 			}
238 238
 
239 239
 			if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
240 240
             {
241
-            	$result=$this->insertExtraFields();
241
+            	$result = $this->insertExtraFields();
242 242
             	if ($result < 0)
243 243
             	{
244 244
             		$error++;
@@ -246,22 +246,22 @@  discard block
 block discarded – undo
246 246
             }
247 247
 
248 248
 			// Add linked object
249
-			if (! $error && $this->origin && $this->origin_id)
249
+			if (!$error && $this->origin && $this->origin_id)
250 250
 			{
251 251
 				$ret = $this->add_object_linked();
252
-				if (! $ret)	dol_print_error($this->db);
252
+				if (!$ret)	dol_print_error($this->db);
253 253
 			}
254 254
 
255 255
 
256
-            if (! $notrigger)
256
+            if (!$notrigger)
257 257
             {
258 258
                 // Call trigger
259
-                $result=$this->call_trigger('FICHINTER_CREATE',$user);
259
+                $result = $this->call_trigger('FICHINTER_CREATE', $user);
260 260
                 if ($result < 0) { $error++; }
261 261
                 // End call triggers
262 262
             }
263 263
 
264
-			if (! $error)
264
+			if (!$error)
265 265
 			{
266 266
 				$this->db->commit();
267 267
 				return $this->id;
@@ -269,14 +269,14 @@  discard block
 block discarded – undo
269 269
 			else
270 270
 			{
271 271
 				$this->db->rollback();
272
-				$this->error=join(',',$this->errors);
273
-				dol_syslog(get_class($this)."::create ".$this->error,LOG_ERR);
272
+				$this->error = join(',', $this->errors);
273
+				dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
274 274
 				return -1;
275 275
 			}
276 276
 		}
277 277
 		else
278 278
 		{
279
-			$this->error=$this->db->error();
279
+			$this->error = $this->db->error();
280 280
 			$this->db->rollback();
281 281
 			return -1;
282 282
 		}
@@ -290,34 +290,34 @@  discard block
 block discarded – undo
290 290
      *	@param		int		$notrigger	Disable all triggers
291 291
 	 *	@return		int		<0 if KO, >0 if OK
292 292
 	 */
293
-	function update($user, $notrigger=0)
293
+	function update($user, $notrigger = 0)
294 294
 	{
295
-	 	if (! is_numeric($this->duration)) {
295
+	 	if (!is_numeric($this->duration)) {
296 296
 	 		$this->duration = 0;
297 297
 	 	}
298
-	 	if (! dol_strlen($this->fk_project)) {
298
+	 	if (!dol_strlen($this->fk_project)) {
299 299
 	 		$this->fk_project = 0;
300 300
 	 	}
301 301
 
302 302
 		$this->db->begin();
303 303
 
304 304
 		$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET ";
305
-		$sql.= "description  = '".$this->db->escape($this->description)."'";
306
-		$sql.= ", duree = ".$this->duration;
307
-		$sql.= ", fk_projet = ".$this->fk_project;
308
-		$sql.= ", note_private = ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null");
309
-		$sql.= ", note_public = ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null");
310
-		$sql.= ", fk_user_modif = ".$user->id;
311
-		$sql.= " WHERE rowid = ".$this->id;
305
+		$sql .= "description  = '".$this->db->escape($this->description)."'";
306
+		$sql .= ", duree = ".$this->duration;
307
+		$sql .= ", fk_projet = ".$this->fk_project;
308
+		$sql .= ", note_private = ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null");
309
+		$sql .= ", note_public = ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null");
310
+		$sql .= ", fk_user_modif = ".$user->id;
311
+		$sql .= " WHERE rowid = ".$this->id;
312 312
 
313 313
 		dol_syslog(get_class($this)."::update", LOG_DEBUG);
314 314
 		if ($this->db->query($sql))
315 315
 		{
316 316
 
317
-			if (! $notrigger)
317
+			if (!$notrigger)
318 318
 			{
319 319
                 // Call trigger
320
-                $result=$this->call_trigger('FICHINTER_MODIFY',$user);
320
+                $result = $this->call_trigger('FICHINTER_MODIFY', $user);
321 321
                 if ($result < 0) { $error++; $this->db->rollback(); return -1; }
322 322
                 // End call triggers
323 323
 			}
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 		}
328 328
 		else
329 329
 		{
330
-			$this->error=$this->db->error();
330
+			$this->error = $this->db->error();
331 331
 			$this->db->rollback();
332 332
 			return -1;
333 333
 		}
@@ -340,19 +340,19 @@  discard block
 block discarded – undo
340 340
 	 *	@param		string	$ref		Ref of intervention
341 341
 	 *	@return		int					<0 if KO, >0 if OK
342 342
 	 */
343
-	function fetch($rowid,$ref='')
343
+	function fetch($rowid, $ref = '')
344 344
 	{
345 345
 		$sql = "SELECT f.rowid, f.ref, f.description, f.fk_soc, f.fk_statut,";
346
-		$sql.= " f.datec, f.dateo, f.datee, f.datet, f.fk_user_author,";
347
-		$sql.= " f.date_valid as datev,";
348
-		$sql.= " f.tms as datem,";
349
-		$sql.= " f.duree, f.fk_projet, f.note_public, f.note_private, f.model_pdf, f.extraparams, fk_contrat";
350
-		$sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f";
351
-		if ($ref) $sql.= " WHERE f.ref='".$this->db->escape($ref)."'";
352
-		else $sql.= " WHERE f.rowid=".$rowid;
346
+		$sql .= " f.datec, f.dateo, f.datee, f.datet, f.fk_user_author,";
347
+		$sql .= " f.date_valid as datev,";
348
+		$sql .= " f.tms as datem,";
349
+		$sql .= " f.duree, f.fk_projet, f.note_public, f.note_private, f.model_pdf, f.extraparams, fk_contrat";
350
+		$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
351
+		if ($ref) $sql .= " WHERE f.ref='".$this->db->escape($ref)."'";
352
+		else $sql .= " WHERE f.rowid=".$rowid;
353 353
 
354 354
 		dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
355
-		$resql=$this->db->query($sql);
355
+		$resql = $this->db->query($sql);
356 356
 		if ($resql)
357 357
 		{
358 358
 			if ($this->db->num_rows($resql))
@@ -375,23 +375,23 @@  discard block
 block discarded – undo
375 375
 				$this->note_public  = $obj->note_public;
376 376
 				$this->note_private = $obj->note_private;
377 377
 				$this->modelpdf     = $obj->model_pdf;
378
-				$this->fk_contrat	= $obj->fk_contrat;
378
+				$this->fk_contrat = $obj->fk_contrat;
379 379
 
380
-				$this->user_creation= $obj->fk_user_author;
380
+				$this->user_creation = $obj->fk_user_author;
381 381
 
382
-				$this->extraparams	= (array) json_decode($obj->extraparams, true);
382
+				$this->extraparams = (array) json_decode($obj->extraparams, true);
383 383
 
384 384
 				if ($this->statut == 0) $this->brouillon = 1;
385 385
 
386 386
 				require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
387
-				$extrafields=new ExtraFields($this->db);
388
-				$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
389
-				$this->fetch_optionals($this->id,$extralabels);
387
+				$extrafields = new ExtraFields($this->db);
388
+				$extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true);
389
+				$this->fetch_optionals($this->id, $extralabels);
390 390
 
391 391
 				/*
392 392
 				 * Lines
393 393
 				*/
394
-				$result=$this->fetch_lines();
394
+				$result = $this->fetch_lines();
395 395
 				if ($result < 0)
396 396
 				{
397 397
 					return -3;
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 		}
403 403
 		else
404 404
 		{
405
-			$this->error=$this->db->lasterror();
405
+			$this->error = $this->db->lasterror();
406 406
 			return -1;
407 407
 		}
408 408
 	}
@@ -422,12 +422,12 @@  discard block
 block discarded – undo
422 422
 			$this->db->begin();
423 423
 
424 424
 			$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter";
425
-			$sql.= " SET fk_statut = 0";
426
-			$sql.= " WHERE rowid = ".$this->id;
427
-			$sql.= " AND entity = ".$conf->entity;
425
+			$sql .= " SET fk_statut = 0";
426
+			$sql .= " WHERE rowid = ".$this->id;
427
+			$sql .= " AND entity = ".$conf->entity;
428 428
 
429 429
 			dol_syslog("Fichinter::setDraft", LOG_DEBUG);
430
-			$resql=$this->db->query($sql);
430
+			$resql = $this->db->query($sql);
431 431
 			if ($resql)
432 432
 			{
433 433
 				$this->db->commit();
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 			else
437 437
 			{
438 438
 				$this->db->rollback();
439
-				$this->error=$this->db->lasterror();
439
+				$this->error = $this->db->lasterror();
440 440
 				return -1;
441 441
 			}
442 442
 		}
@@ -449,21 +449,21 @@  discard block
 block discarded – undo
449 449
      *  @param		int			$notrigger	1=Does not execute triggers, 0= execute triggers
450 450
 	 *	@return		int						<0 if KO, >0 if OK
451 451
 	 */
452
-	function setValid($user, $notrigger=0)
452
+	function setValid($user, $notrigger = 0)
453 453
 	{
454 454
 		global $conf;
455 455
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
456 456
 
457
-		$error=0;
457
+		$error = 0;
458 458
 
459 459
 		if ($this->statut != 1)
460 460
 		{
461 461
 			$this->db->begin();
462 462
 
463
-			$now=dol_now();
463
+			$now = dol_now();
464 464
 
465 465
 			// Define new ref
466
-			if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
466
+			if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
467 467
 			{
468 468
 				$num = $this->getNextNumRef($this->thirdparty);
469 469
 			}
@@ -474,31 +474,31 @@  discard block
 block discarded – undo
474 474
             $this->newref = $num;
475 475
 
476 476
 			$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter";
477
-			$sql.= " SET fk_statut = 1";
478
-			$sql.= ", ref = '".$num."'";
479
-			$sql.= ", date_valid = '".$this->db->idate($now)."'";
480
-			$sql.= ", fk_user_valid = ".$user->id;
481
-			$sql.= " WHERE rowid = ".$this->id;
482
-			$sql.= " AND entity = ".$conf->entity;
483
-			$sql.= " AND fk_statut = 0";
477
+			$sql .= " SET fk_statut = 1";
478
+			$sql .= ", ref = '".$num."'";
479
+			$sql .= ", date_valid = '".$this->db->idate($now)."'";
480
+			$sql .= ", fk_user_valid = ".$user->id;
481
+			$sql .= " WHERE rowid = ".$this->id;
482
+			$sql .= " AND entity = ".$conf->entity;
483
+			$sql .= " AND fk_statut = 0";
484 484
 
485 485
 			dol_syslog(get_class($this)."::setValid", LOG_DEBUG);
486
-			$resql=$this->db->query($sql);
487
-			if (! $resql)
486
+			$resql = $this->db->query($sql);
487
+			if (!$resql)
488 488
 			{
489 489
 				dol_print_error($this->db);
490 490
 				$error++;
491 491
 			}
492 492
 
493
-			if (! $error && ! $notrigger)
493
+			if (!$error && !$notrigger)
494 494
 			{
495 495
                 // Call trigger
496
-                $result=$this->call_trigger('FICHINTER_VALIDATE',$user);
496
+                $result = $this->call_trigger('FICHINTER_VALIDATE', $user);
497 497
                 if ($result < 0) { $error++; }
498 498
                 // End call triggers
499 499
 			}
500 500
 
501
-			if (! $error)
501
+			if (!$error)
502 502
 			{
503 503
 				$this->oldref = $this->ref;
504 504
 
@@ -519,13 +519,13 @@  discard block
 block discarded – undo
519 519
 						{
520 520
 	                        dol_syslog("Rename ok");
521 521
 	                        // Rename docs starting with $oldref with $newref
522
-	                        $listoffiles=dol_dir_list($conf->ficheinter->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
523
-	                        foreach($listoffiles as $fileentry)
522
+	                        $listoffiles = dol_dir_list($conf->ficheinter->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
523
+	                        foreach ($listoffiles as $fileentry)
524 524
 	                        {
525
-	                        	$dirsource=$fileentry['name'];
526
-	                        	$dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
527
-	                        	$dirsource=$fileentry['path'].'/'.$dirsource;
528
-	                        	$dirdest=$fileentry['path'].'/'.$dirdest;
525
+	                        	$dirsource = $fileentry['name'];
526
+	                        	$dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
527
+	                        	$dirsource = $fileentry['path'].'/'.$dirsource;
528
+	                        	$dirdest = $fileentry['path'].'/'.$dirdest;
529 529
 	                        	@rename($dirsource, $dirdest);
530 530
 	                        }
531 531
 						}
@@ -534,15 +534,15 @@  discard block
 block discarded – undo
534 534
 			}
535 535
 
536 536
 			// Set new ref and define current statut
537
-			if (! $error)
537
+			if (!$error)
538 538
 			{
539 539
 				$this->ref = $num;
540
-				$this->statut=1;
541
-				$this->brouillon=0;
542
-				$this->date_validation=$now;
540
+				$this->statut = 1;
541
+				$this->brouillon = 0;
542
+				$this->date_validation = $now;
543 543
 			}
544 544
 
545
-			if (! $error)
545
+			if (!$error)
546 546
 			{
547 547
 				$this->db->commit();
548 548
 				return 1;
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 			else
551 551
 			{
552 552
 				$this->db->rollback();
553
-				dol_syslog(get_class($this)."::setValid ".$this->error,LOG_ERR);
553
+				dol_syslog(get_class($this)."::setValid ".$this->error, LOG_ERR);
554 554
 				return -1;
555 555
 			}
556 556
 		}
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 
573 573
 		$thm = $this->author->thm;
574 574
 
575
-		foreach($this->lines as $line) {
575
+		foreach ($this->lines as $line) {
576 576
 			$amount += ($line->duration / 60 / 60 * $thm);
577 577
 		}
578 578
 
@@ -590,19 +590,19 @@  discard block
 block discarded – undo
590 590
 	 *  @param      int                     $hideref        Hide ref
591 591
 	 *  @return     int                                     0 if KO, 1 if OK
592 592
 	 */
593
-	public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
593
+	public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
594 594
 	{
595
-		global $conf,$langs;
595
+		global $conf, $langs;
596 596
 
597 597
 		$langs->load("interventions");
598 598
 
599
-		if (! dol_strlen($modele)) {
599
+		if (!dol_strlen($modele)) {
600 600
 
601 601
 			$modele = 'soleil';
602 602
 
603 603
 			if ($this->modelpdf) {
604 604
 				$modele = $this->modelpdf;
605
-			} elseif (! empty($conf->global->FICHEINTER_ADDON_PDF)) {
605
+			} elseif (!empty($conf->global->FICHEINTER_ADDON_PDF)) {
606 606
 				$modele = $conf->global->FICHEINTER_ADDON_PDF;
607 607
 			}
608 608
 		}
@@ -618,9 +618,9 @@  discard block
 block discarded – undo
618 618
 	 *	@param      int		$mode       0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
619 619
 	 *	@return     string      		Label
620 620
 	 */
621
-	function getLibStatut($mode=0)
621
+	function getLibStatut($mode = 0)
622 622
 	{
623
-		return $this->LibStatut($this->statut,$mode);
623
+		return $this->LibStatut($this->statut, $mode);
624 624
 	}
625 625
 
626 626
 	/**
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 	 *	@param      int		$mode       0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
631 631
 	 *	@return     string      		Label
632 632
 	 */
633
-	function LibStatut($statut,$mode=0)
633
+	function LibStatut($statut, $mode = 0)
634 634
 	{
635 635
 		global $langs;
636 636
 
@@ -643,11 +643,11 @@  discard block
 block discarded – undo
643 643
 		if ($mode == 3)
644 644
 			return img_picto($langs->trans($this->statuts_short[$statut]), $this->statuts_logo[$statut]);
645 645
 		if ($mode == 4)
646
-			return img_picto($langs->trans($this->statuts_short[$statut]),$this->statuts_logo[$statut]).' '.$langs->trans($this->statuts[$statut]);
646
+			return img_picto($langs->trans($this->statuts_short[$statut]), $this->statuts_logo[$statut]).' '.$langs->trans($this->statuts[$statut]);
647 647
 		if ($mode == 5)
648
-			return '<span class="hideonsmartphone">'.$langs->trans($this->statuts_short[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
648
+			return '<span class="hideonsmartphone">'.$langs->trans($this->statuts_short[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]), $this->statuts_logo[$statut]);
649 649
 		if ($mode == 6)
650
-		    return '<span class="hideonsmartphone">'.$langs->trans($this->statuts[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
650
+		    return '<span class="hideonsmartphone">'.$langs->trans($this->statuts[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]), $this->statuts_logo[$statut]);
651 651
 
652 652
 		return '';
653 653
 	}
@@ -661,46 +661,46 @@  discard block
 block discarded – undo
661 661
      *  @param      int     $save_lastsearch_value		-1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
662 662
 	 *	@return		string								String with URL
663 663
 	 */
664
-	function getNomUrl($withpicto=0, $option='', $notooltip=0, $save_lastsearch_value=-1)
664
+	function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $save_lastsearch_value = -1)
665 665
 	{
666 666
 		global $conf, $langs;
667 667
 
668
-		$result='';
668
+		$result = '';
669 669
 
670
-        $label = '<u>' . $langs->trans("ShowIntervention") . '</u>';
671
-        if (! empty($this->ref))
672
-            $label .= '<br><b>' . $langs->trans('Ref') . ':</b> '.$this->ref;
670
+        $label = '<u>'.$langs->trans("ShowIntervention").'</u>';
671
+        if (!empty($this->ref))
672
+            $label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
673 673
 
674
-        $picto='intervention';
674
+        $picto = 'intervention';
675 675
         $url = DOL_URL_ROOT.'/fichinter/card.php?id='.$this->id;
676 676
 
677 677
         if ($option !== 'nolink')
678 678
         {
679 679
         	// Add param to save lastsearch_values or not
680
-        	$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
681
-        	if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
682
-        	if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
680
+        	$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
681
+        	if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
682
+        	if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
683 683
        	}
684 684
 
685
-		$linkclose='';
685
+		$linkclose = '';
686 686
 		if (empty($notooltip))
687 687
 		{
688
-			if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
688
+			if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
689 689
 			{
690
-				$label=$langs->trans("ShowIntervention");
691
-				$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
690
+				$label = $langs->trans("ShowIntervention");
691
+				$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
692 692
 			}
693
-			$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
694
-			$linkclose.=' class="classfortooltip"';
693
+			$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
694
+			$linkclose .= ' class="classfortooltip"';
695 695
 		}
696 696
 
697 697
 		$linkstart = '<a href="'.$url.'"';
698
-		$linkstart.=$linkclose.'>';
699
-		$linkend='</a>';
698
+		$linkstart .= $linkclose.'>';
699
+		$linkend = '</a>';
700 700
 
701
-        if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
702
-		if ($withpicto && $withpicto != 2) $result.=' ';
703
-		if ($withpicto != 2) $result.=$linkstart.$this->ref.$linkend;
701
+        if ($withpicto) $result .= ($linkstart.img_object(($notooltip ? '' : $label), $picto, ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).$linkend);
702
+		if ($withpicto && $withpicto != 2) $result .= ' ';
703
+		if ($withpicto != 2) $result .= $linkstart.$this->ref.$linkend;
704 704
 		return $result;
705 705
 	}
706 706
 
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 		global $conf, $db, $langs;
718 718
 		$langs->load("interventions");
719 719
 
720
-		if (! empty($conf->global->FICHEINTER_ADDON))
720
+		if (!empty($conf->global->FICHEINTER_ADDON))
721 721
 		{
722 722
 			$mybool = false;
723 723
 
@@ -732,26 +732,26 @@  discard block
 block discarded – undo
732 732
 				$dir = dol_buildpath($reldir."core/modules/fichinter/");
733 733
 
734 734
 				// Load file with numbering class (if found)
735
-				$mybool|=@include_once $dir.$file;
735
+				$mybool |= @include_once $dir.$file;
736 736
 			}
737 737
 
738
-			if (! $mybool)
738
+			if (!$mybool)
739 739
 			{
740
-				dol_print_error('',"Failed to include file ".$file);
740
+				dol_print_error('', "Failed to include file ".$file);
741 741
 				return '';
742 742
 			}
743 743
 
744 744
 			$obj = new $classname();
745 745
 			$numref = "";
746
-			$numref = $obj->getNextValue($soc,$this);
746
+			$numref = $obj->getNextValue($soc, $this);
747 747
 
748
-			if ( $numref != "")
748
+			if ($numref != "")
749 749
 			{
750 750
 				return $numref;
751 751
 			}
752 752
 			else
753 753
 			{
754
-				dol_print_error($db,"Fichinter::getNextNumRef ".$obj->error);
754
+				dol_print_error($db, "Fichinter::getNextNumRef ".$obj->error);
755 755
 				return "";
756 756
 			}
757 757
 		}
@@ -774,15 +774,15 @@  discard block
 block discarded – undo
774 774
 		global $conf;
775 775
 
776 776
 		$sql = "SELECT f.rowid,";
777
-		$sql.= " f.datec,";
778
-		$sql.= " f.tms as date_modification,";
779
-		$sql.= " f.date_valid as datev,";
780
-		$sql.= " f.fk_user_author,";
781
-		$sql.= " f.fk_user_modif as fk_user_modification,";
782
-		$sql.= " f.fk_user_valid";
783
-		$sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f";
784
-		$sql.= " WHERE f.rowid = ".$id;
785
-		$sql.= " AND f.entity = ".$conf->entity;
777
+		$sql .= " f.datec,";
778
+		$sql .= " f.tms as date_modification,";
779
+		$sql .= " f.date_valid as datev,";
780
+		$sql .= " f.fk_user_author,";
781
+		$sql .= " f.fk_user_modif as fk_user_modification,";
782
+		$sql .= " f.fk_user_valid";
783
+		$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
784
+		$sql .= " WHERE f.rowid = ".$id;
785
+		$sql .= " AND f.entity = ".$conf->entity;
786 786
 
787 787
 		$resql = $this->db->query($sql);
788 788
 		if ($resql)
@@ -799,19 +799,19 @@  discard block
 block discarded – undo
799 799
 
800 800
 				$cuser = new User($this->db);
801 801
 				$cuser->fetch($obj->fk_user_author);
802
-				$this->user_creation     = $cuser;
802
+				$this->user_creation = $cuser;
803 803
 
804 804
 				if ($obj->fk_user_valid)
805 805
 				{
806 806
 					$vuser = new User($this->db);
807 807
 					$vuser->fetch($obj->fk_user_valid);
808
-					$this->user_validation     = $vuser;
808
+					$this->user_validation = $vuser;
809 809
 				}
810 810
 				if ($obj->fk_user_modification)
811 811
 				{
812 812
 					$muser = new User($this->db);
813 813
 					$muser->fetch($obj->fk_user_modification);
814
-					$this->user_modification   = $muser;
814
+					$this->user_modification = $muser;
815 815
 				}
816 816
 
817 817
 			}
@@ -830,12 +830,12 @@  discard block
 block discarded – undo
830 830
 	 *	@param		int		$notrigger		Disable trigger
831 831
 	 *	@return		int						<0 if KO, >0 if OK
832 832
 	 */
833
-	function delete($user, $notrigger=0)
833
+	function delete($user, $notrigger = 0)
834 834
 	{
835
-		global $conf,$langs;
835
+		global $conf, $langs;
836 836
         require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
837 837
 
838
-		$error=0;
838
+		$error = 0;
839 839
 
840 840
 		$this->db->begin();
841 841
 
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
 		$res = $this->delete_linked_contact();
848 848
 		if ($res < 0)
849 849
 		{
850
-			$this->error='ErrorFailToDeleteLinkedContact';
850
+			$this->error = 'ErrorFailToDeleteLinkedContact';
851 851
 			$error++;
852 852
 		}
853 853
 
@@ -858,49 +858,49 @@  discard block
 block discarded – undo
858 858
 		}
859 859
 
860 860
 		$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet";
861
-		$sql.= " WHERE fk_fichinter = ".$this->id;
861
+		$sql .= " WHERE fk_fichinter = ".$this->id;
862 862
 
863 863
 		dol_syslog("Fichinter::delete", LOG_DEBUG);
864
-		if ( $this->db->query($sql) )
864
+		if ($this->db->query($sql))
865 865
 		{
866 866
 			$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinter";
867
-			$sql.= " WHERE rowid = ".$this->id;
868
-			$sql.= " AND entity = ".$conf->entity;
867
+			$sql .= " WHERE rowid = ".$this->id;
868
+			$sql .= " AND entity = ".$conf->entity;
869 869
 
870 870
 			dol_syslog("Fichinter::delete", LOG_DEBUG);
871
-			if ( $this->db->query($sql) )
871
+			if ($this->db->query($sql))
872 872
 			{
873 873
 
874 874
 				// Remove directory with files
875 875
 				$fichinterref = dol_sanitizeFileName($this->ref);
876 876
 				if ($conf->ficheinter->dir_output)
877 877
 				{
878
-					$dir = $conf->ficheinter->dir_output . "/" . $fichinterref ;
879
-					$file = $conf->ficheinter->dir_output . "/" . $fichinterref . "/" . $fichinterref . ".pdf";
878
+					$dir = $conf->ficheinter->dir_output."/".$fichinterref;
879
+					$file = $conf->ficheinter->dir_output."/".$fichinterref."/".$fichinterref.".pdf";
880 880
 					if (file_exists($file))
881 881
 					{
882 882
 						dol_delete_preview($this);
883 883
 
884
-						if (! dol_delete_file($file,0,0,0,$this)) // For triggers
884
+						if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers
885 885
 						{
886
-							$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
886
+							$this->error = $langs->trans("ErrorCanNotDeleteFile", $file);
887 887
 							return 0;
888 888
 						}
889 889
 					}
890 890
 					if (file_exists($dir))
891 891
 					{
892
-						if (! dol_delete_dir_recursive($dir))
892
+						if (!dol_delete_dir_recursive($dir))
893 893
 						{
894
-							$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
894
+							$this->error = $langs->trans("ErrorCanNotDeleteDir", $dir);
895 895
 							return 0;
896 896
 						}
897 897
 					}
898 898
 				}
899 899
 
900
-				if (! $notrigger)
900
+				if (!$notrigger)
901 901
 				{
902 902
                     // Call trigger
903
-                    $result=$this->call_trigger('FICHINTER_DELETE',$user);
903
+                    $result = $this->call_trigger('FICHINTER_DELETE', $user);
904 904
                     if ($result < 0) { $error++; $this->db->rollback(); return -1; }
905 905
                     // End call triggers
906 906
 				}
@@ -910,14 +910,14 @@  discard block
 block discarded – undo
910 910
 			}
911 911
 			else
912 912
 			{
913
-				$this->error=$this->db->lasterror();
913
+				$this->error = $this->db->lasterror();
914 914
 				$this->db->rollback();
915 915
 				return -2;
916 916
 			}
917 917
 		}
918 918
 		else
919 919
 		{
920
-			$this->error=$this->db->lasterror();
920
+			$this->error = $this->db->lasterror();
921 921
 			$this->db->rollback();
922 922
 			return -1;
923 923
 		}
@@ -937,10 +937,10 @@  discard block
 block discarded – undo
937 937
 		if ($user->rights->ficheinter->creer)
938 938
 		{
939 939
 			$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
940
-			$sql.= " SET datei = '".$this->db->idate($date_delivery)."'";
941
-			$sql.= " WHERE rowid = ".$this->id;
942
-			$sql.= " AND entity = ".$conf->entity;
943
-			$sql.= " AND fk_statut = 0";
940
+			$sql .= " SET datei = '".$this->db->idate($date_delivery)."'";
941
+			$sql .= " WHERE rowid = ".$this->id;
942
+			$sql .= " AND entity = ".$conf->entity;
943
+			$sql .= " AND fk_statut = 0";
944 944
 
945 945
 			if ($this->db->query($sql))
946 946
 			{
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
 			}
950 950
 			else
951 951
 			{
952
-				$this->error=$this->db->error();
952
+				$this->error = $this->db->error();
953 953
 				dol_syslog("Fichinter::set_date_delivery Erreur SQL");
954 954
 				return -1;
955 955
 			}
@@ -970,10 +970,10 @@  discard block
 block discarded – undo
970 970
 		if ($user->rights->ficheinter->creer)
971 971
 		{
972 972
 			$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
973
-			$sql.= " SET description = '".$this->db->escape($description)."',";
974
-			$sql.= " fk_user_modif = ".$user->id;
975
-			$sql.= " WHERE rowid = ".$this->id;
976
-			$sql.= " AND entity = ".$conf->entity;
973
+			$sql .= " SET description = '".$this->db->escape($description)."',";
974
+			$sql .= " fk_user_modif = ".$user->id;
975
+			$sql .= " WHERE rowid = ".$this->id;
976
+			$sql .= " AND entity = ".$conf->entity;
977 977
 
978 978
 			if ($this->db->query($sql))
979 979
 			{
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 			}
983 983
 			else
984 984
 			{
985
-				$this->error=$this->db->error();
985
+				$this->error = $this->db->error();
986 986
 				dol_syslog("Fichinter::set_description Erreur SQL");
987 987
 				return -1;
988 988
 			}
@@ -1004,9 +1004,9 @@  discard block
 block discarded – undo
1004 1004
 		if ($user->rights->ficheinter->creer)
1005 1005
 		{
1006 1006
 			$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
1007
-			$sql.= " SET fk_contrat = '".$contractid."'";
1008
-			$sql.= " WHERE rowid = ".$this->id;
1009
-			$sql.= " AND entity = ".$conf->entity;
1007
+			$sql .= " SET fk_contrat = '".$contractid."'";
1008
+			$sql .= " WHERE rowid = ".$this->id;
1009
+			$sql .= " AND entity = ".$conf->entity;
1010 1010
 
1011 1011
 			if ($this->db->query($sql))
1012 1012
 			{
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 			}
1016 1016
 			else
1017 1017
 			{
1018
-				$this->error=$this->db->error();
1018
+				$this->error = $this->db->error();
1019 1019
 				return -1;
1020 1020
 			}
1021 1021
 		}
@@ -1030,43 +1030,43 @@  discard block
 block discarded – undo
1030 1030
      *	@param		int			$socid			Id of thirdparty
1031 1031
      *	@return		int							New id of clone
1032 1032
      */
1033
-    function createFromClone($socid=0)
1033
+    function createFromClone($socid = 0)
1034 1034
     {
1035
-        global $user,$hookmanager;
1035
+        global $user, $hookmanager;
1036 1036
 
1037
-        $error=0;
1037
+        $error = 0;
1038 1038
 
1039 1039
         $this->context['createfromclone'] = 'createfromclone';
1040 1040
 
1041 1041
         $this->db->begin();
1042 1042
 
1043 1043
 		// get extrafields so they will be clone
1044
-		foreach($this->lines as $line)
1044
+		foreach ($this->lines as $line)
1045 1045
 			$line->fetch_optionals($line->rowid);
1046 1046
 
1047 1047
         // Load source object
1048 1048
         $objFrom = clone $this;
1049 1049
 
1050 1050
         // Change socid if needed
1051
-        if (! empty($socid) && $socid != $this->socid)
1051
+        if (!empty($socid) && $socid != $this->socid)
1052 1052
         {
1053 1053
             $objsoc = new Societe($this->db);
1054 1054
 
1055
-            if ($objsoc->fetch($socid)>0)
1055
+            if ($objsoc->fetch($socid) > 0)
1056 1056
             {
1057
-                $this->socid 				= $objsoc->id;
1057
+                $this->socid = $objsoc->id;
1058 1058
                 //$this->cond_reglement_id	= (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
1059 1059
                 //$this->mode_reglement_id	= (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
1060
-                $this->fk_project			= '';
1061
-                $this->fk_delivery_address	= '';
1060
+                $this->fk_project = '';
1061
+                $this->fk_delivery_address = '';
1062 1062
             }
1063 1063
 
1064 1064
             // TODO Change product price if multi-prices
1065 1065
         }
1066 1066
 
1067
-        $this->id=0;
1067
+        $this->id = 0;
1068 1068
 		$this->ref = '';
1069
-        $this->statut=0;
1069
+        $this->statut = 0;
1070 1070
 
1071 1071
         // Clear fields
1072 1072
         $this->user_author_id     = $user->id;
@@ -1076,10 +1076,10 @@  discard block
 block discarded – undo
1076 1076
         $this->ref_client         = '';
1077 1077
 
1078 1078
         // Create clone
1079
-        $result=$this->create($user);
1079
+        $result = $this->create($user);
1080 1080
         if ($result < 0) $error++;
1081 1081
 
1082
-        if (! $error)
1082
+        if (!$error)
1083 1083
         {
1084 1084
             // Add lines because it is not included into create function
1085 1085
             foreach ($this->lines as $line)
@@ -1090,14 +1090,14 @@  discard block
 block discarded – undo
1090 1090
         	// Hook of thirdparty module
1091 1091
             if (is_object($hookmanager))
1092 1092
             {
1093
-                $parameters=array('objFrom'=>$objFrom);
1094
-                $action='';
1095
-                $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1093
+                $parameters = array('objFrom'=>$objFrom);
1094
+                $action = '';
1095
+                $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1096 1096
                 if ($reshook < 0) $error++;
1097 1097
             }
1098 1098
 
1099 1099
             // Call trigger
1100
-            $result=$this->call_trigger('INTERVENTION_CLONE',$user);
1100
+            $result = $this->call_trigger('INTERVENTION_CLONE', $user);
1101 1101
             if ($result < 0) $error++;
1102 1102
             // End call triggers
1103 1103
         }
@@ -1105,7 +1105,7 @@  discard block
 block discarded – undo
1105 1105
         unset($this->context['createfromclone']);
1106 1106
 
1107 1107
         // End
1108
-        if (! $error)
1108
+        if (!$error)
1109 1109
         {
1110 1110
             $this->db->commit();
1111 1111
             return $this->id;
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
 	 *  @param		array	$array_options			Array option
1130 1130
 	 *	@return    	int             				>0 if ok, <0 if ko
1131 1131
 	 */
1132
-	function addline($user,$fichinterid, $desc, $date_intervention, $duration, $array_options='')
1132
+	function addline($user, $fichinterid, $desc, $date_intervention, $duration, $array_options = '')
1133 1133
 	{
1134 1134
 		dol_syslog(get_class($this)."::addline $fichinterid, $desc, $date_intervention, $duration");
1135 1135
 
@@ -1138,18 +1138,18 @@  discard block
 block discarded – undo
1138 1138
 			$this->db->begin();
1139 1139
 
1140 1140
 			// Insertion ligne
1141
-			$line=new FichinterLigne($this->db);
1141
+			$line = new FichinterLigne($this->db);
1142 1142
 
1143 1143
 			$line->fk_fichinter = $fichinterid;
1144 1144
 			$line->desc         = $desc;
1145 1145
 			$line->datei        = $date_intervention;
1146 1146
 			$line->duration     = $duration;
1147 1147
 
1148
-			if (is_array($array_options) && count($array_options)>0) {
1149
-				$line->array_options=$array_options;
1148
+			if (is_array($array_options) && count($array_options) > 0) {
1149
+				$line->array_options = $array_options;
1150 1150
 			}
1151 1151
 
1152
-			$result=$line->insert($user);
1152
+			$result = $line->insert($user);
1153 1153
 
1154 1154
 			if ($result >= 0)
1155 1155
 			{
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
 			}
1159 1159
 			else
1160 1160
 			{
1161
-				$this->error=$this->db->error();
1161
+				$this->error = $this->db->error();
1162 1162
 				$this->db->rollback();
1163 1163
 				return -1;
1164 1164
 			}
@@ -1175,32 +1175,32 @@  discard block
 block discarded – undo
1175 1175
 	 */
1176 1176
 	function initAsSpecimen()
1177 1177
 	{
1178
-		global $user,$langs,$conf;
1178
+		global $user, $langs, $conf;
1179 1179
 
1180
-		$now=dol_now();
1180
+		$now = dol_now();
1181 1181
 
1182 1182
 		// Initialise parametres
1183
-		$this->id=0;
1183
+		$this->id = 0;
1184 1184
 		$this->ref = 'SPECIMEN';
1185
-		$this->specimen=1;
1185
+		$this->specimen = 1;
1186 1186
 		$this->socid = 1;
1187 1187
 		$this->datec = $now;
1188
-		$this->note_private='Private note';
1189
-		$this->note_public='SPECIMEN';
1188
+		$this->note_private = 'Private note';
1189
+		$this->note_public = 'SPECIMEN';
1190 1190
 		$this->duration = 0;
1191 1191
 		$nbp = 25;
1192 1192
 		$xnbp = 0;
1193 1193
 		while ($xnbp < $nbp)
1194 1194
 		{
1195
-			$line=new FichinterLigne($this->db);
1196
-			$line->desc=$langs->trans("Description")." ".$xnbp;
1197
-			$line->datei=($now-3600*(1+$xnbp));
1198
-			$line->duration=600;
1199
-			$line->fk_fichinter=0;
1200
-			$this->lines[$xnbp]=$line;
1195
+			$line = new FichinterLigne($this->db);
1196
+			$line->desc = $langs->trans("Description")." ".$xnbp;
1197
+			$line->datei = ($now - 3600 * (1 + $xnbp));
1198
+			$line->duration = 600;
1199
+			$line->fk_fichinter = 0;
1200
+			$this->lines[$xnbp] = $line;
1201 1201
 			$xnbp++;
1202 1202
 
1203
-			$this->duration+=$line->duration;
1203
+			$this->duration += $line->duration;
1204 1204
 		}
1205 1205
 	}
1206 1206
 
@@ -1212,11 +1212,11 @@  discard block
 block discarded – undo
1212 1212
 	function fetch_lines()
1213 1213
 	{
1214 1214
 		$sql = 'SELECT rowid, description, duree, date, rang';
1215
-		$sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet';
1216
-		$sql.=' WHERE fk_fichinter = '.$this->id .' ORDER BY rang ASC, date ASC' ;
1215
+		$sql .= ' FROM '.MAIN_DB_PREFIX.'fichinterdet';
1216
+		$sql .= ' WHERE fk_fichinter = '.$this->id.' ORDER BY rang ASC, date ASC';
1217 1217
 
1218 1218
 		dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
1219
-		$resql=$this->db->query($sql);
1219
+		$resql = $this->db->query($sql);
1220 1220
 		if ($resql)
1221 1221
 		{
1222 1222
 			$num = $this->db->num_rows($resql);
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 				$line->desc = $objp->description;
1231 1231
 				$line->duration = $objp->duree;
1232 1232
 				//For invoicing we calculing hours
1233
-				$line->qty = round($objp->duree/3600,2);
1233
+				$line->qty = round($objp->duree / 3600, 2);
1234 1234
 				$line->date	= $this->db->jdate($objp->date);
1235 1235
 				$line->datei = $this->db->jdate($objp->date);
1236 1236
 				$line->rang	= $objp->rang;
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 		}
1247 1247
 		else
1248 1248
 		{
1249
-			$this->error=$this->db->error();
1249
+			$this->error = $this->db->error();
1250 1250
 			return -1;
1251 1251
 		}
1252 1252
 	}
@@ -1279,14 +1279,14 @@  discard block
 block discarded – undo
1279 1279
 
1280 1280
 	// From llx_fichinterdet
1281 1281
 	var $fk_fichinter;
1282
-	var $desc;          	// Description ligne
1283
-	var $datei;           // Date intervention
1284
-	var $duration;        // Duree de l'intervention
1282
+	var $desc; // Description ligne
1283
+	var $datei; // Date intervention
1284
+	var $duration; // Duree de l'intervention
1285 1285
 	var $rang = 0;
1286 1286
 
1287
-	public $element='fichinterdet';
1288
-	public $table_element='fichinterdet';
1289
-	public $fk_element='fk_fichinter';
1287
+	public $element = 'fichinterdet';
1288
+	public $table_element = 'fichinterdet';
1289
+	public $fk_element = 'fk_fichinter';
1290 1290
 
1291 1291
 	/**
1292 1292
 	 *	Constructor
@@ -1307,9 +1307,9 @@  discard block
 block discarded – undo
1307 1307
 	function fetch($rowid)
1308 1308
 	{
1309 1309
 		$sql = 'SELECT ft.rowid, ft.fk_fichinter, ft.description, ft.duree, ft.rang,';
1310
-		$sql.= ' ft.date as datei';
1311
-		$sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft';
1312
-		$sql.= ' WHERE ft.rowid = '.$rowid;
1310
+		$sql .= ' ft.date as datei';
1311
+		$sql .= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft';
1312
+		$sql .= ' WHERE ft.rowid = '.$rowid;
1313 1313
 
1314 1314
 		dol_syslog("FichinterLigne::fetch", LOG_DEBUG);
1315 1315
 		$result = $this->db->query($sql);
@@ -1317,9 +1317,9 @@  discard block
 block discarded – undo
1317 1317
 		{
1318 1318
 			$objp = $this->db->fetch_object($result);
1319 1319
 			$this->rowid          	= $objp->rowid;
1320
-			$this->id 				= $objp->rowid;
1320
+			$this->id = $objp->rowid;
1321 1321
 			$this->fk_fichinter   	= $objp->fk_fichinter;
1322
-			$this->datei			= $this->db->jdate($objp->datei);
1322
+			$this->datei = $this->db->jdate($objp->datei);
1323 1323
 			$this->desc           	= $objp->description;
1324 1324
 			$this->duration       	= $objp->duree;
1325 1325
 			$this->rang           	= $objp->rang;
@@ -1329,7 +1329,7 @@  discard block
 block discarded – undo
1329 1329
 		}
1330 1330
 		else
1331 1331
 		{
1332
-			$this->error=$this->db->error().' sql='.$sql;
1332
+			$this->error = $this->db->error().' sql='.$sql;
1333 1333
 			return -1;
1334 1334
 		}
1335 1335
 	}
@@ -1341,20 +1341,20 @@  discard block
 block discarded – undo
1341 1341
      *	@param		int		$notrigger	Disable all triggers
1342 1342
 	 *	@return		int		<0 if ko, >0 if ok
1343 1343
 	 */
1344
-	function insert($user, $notrigger=0)
1344
+	function insert($user, $notrigger = 0)
1345 1345
 	{
1346
-		global $langs,$conf;
1346
+		global $langs, $conf;
1347 1347
 
1348 1348
 		dol_syslog("FichinterLigne::insert rang=".$this->rang);
1349 1349
 
1350 1350
 		$this->db->begin();
1351 1351
 
1352
-		$rangToUse=$this->rang;
1352
+		$rangToUse = $this->rang;
1353 1353
 		if ($rangToUse == -1)
1354 1354
 		{
1355 1355
 			// Recupere rang max de la ligne d'intervention dans $rangmax
1356 1356
 			$sql = 'SELECT max(rang) as max FROM '.MAIN_DB_PREFIX.'fichinterdet';
1357
-			$sql.= ' WHERE fk_fichinter ='.$this->fk_fichinter;
1357
+			$sql .= ' WHERE fk_fichinter ='.$this->fk_fichinter;
1358 1358
 			$resql = $this->db->query($sql);
1359 1359
 			if ($resql)
1360 1360
 			{
@@ -1371,24 +1371,24 @@  discard block
 block discarded – undo
1371 1371
 
1372 1372
 		// Insertion dans base de la ligne
1373 1373
 		$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'fichinterdet';
1374
-		$sql.= ' (fk_fichinter, description, date, duree, rang)';
1375
-		$sql.= " VALUES (".$this->fk_fichinter.",";
1376
-		$sql.= " '".$this->db->escape($this->desc)."',";
1377
-		$sql.= " '".$this->db->idate($this->datei)."',";
1378
-		$sql.= " ".$this->duration.",";
1379
-		$sql.= ' '.$rangToUse;
1380
-		$sql.= ')';
1374
+		$sql .= ' (fk_fichinter, description, date, duree, rang)';
1375
+		$sql .= " VALUES (".$this->fk_fichinter.",";
1376
+		$sql .= " '".$this->db->escape($this->desc)."',";
1377
+		$sql .= " '".$this->db->idate($this->datei)."',";
1378
+		$sql .= " ".$this->duration.",";
1379
+		$sql .= ' '.$rangToUse;
1380
+		$sql .= ')';
1381 1381
 
1382 1382
 		dol_syslog("FichinterLigne::insert", LOG_DEBUG);
1383
-		$resql=$this->db->query($sql);
1383
+		$resql = $this->db->query($sql);
1384 1384
 		if ($resql)
1385 1385
 		{
1386
-			$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'fichinterdet');
1386
+			$this->rowid = $this->db->last_insert_id(MAIN_DB_PREFIX.'fichinterdet');
1387 1387
 
1388 1388
 			if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
1389 1389
             {
1390
-            	$this->id=$this->rowid;
1391
-            	$result=$this->insertExtraFields();
1390
+            	$this->id = $this->rowid;
1391
+            	$result = $this->insertExtraFields();
1392 1392
             	if ($result < 0)
1393 1393
             	{
1394 1394
             		$error++;
@@ -1396,16 +1396,16 @@  discard block
 block discarded – undo
1396 1396
             }
1397 1397
 
1398 1398
 
1399
-			$result=$this->update_total();
1399
+			$result = $this->update_total();
1400 1400
 
1401 1401
 			if ($result > 0)
1402 1402
 			{
1403
-				$this->rang=$rangToUse;
1403
+				$this->rang = $rangToUse;
1404 1404
 
1405
-				if (! $notrigger)
1405
+				if (!$notrigger)
1406 1406
 				{
1407 1407
                     // Call trigger
1408
-                    $result=$this->call_trigger('LINEFICHINTER_CREATE',$user);
1408
+                    $result = $this->call_trigger('LINEFICHINTER_CREATE', $user);
1409 1409
                     if ($result < 0) { $error++; }
1410 1410
                     // End call triggers
1411 1411
 				}
@@ -1423,7 +1423,7 @@  discard block
 block discarded – undo
1423 1423
 		}
1424 1424
 		else
1425 1425
 		{
1426
-			$this->error=$this->db->error()." sql=".$sql;
1426
+			$this->error = $this->db->error()." sql=".$sql;
1427 1427
 			$this->db->rollback();
1428 1428
 			return -1;
1429 1429
 		}
@@ -1437,43 +1437,43 @@  discard block
 block discarded – undo
1437 1437
      *	@param		int		$notrigger	Disable all triggers
1438 1438
 	 *	@return		int		<0 if ko, >0 if ok
1439 1439
 	 */
1440
-	function update($user,$notrigger=0)
1440
+	function update($user, $notrigger = 0)
1441 1441
 	{
1442
-		global $langs,$conf;
1442
+		global $langs, $conf;
1443 1443
 
1444 1444
 		$this->db->begin();
1445 1445
 
1446 1446
 		// Mise a jour ligne en base
1447 1447
 		$sql = "UPDATE ".MAIN_DB_PREFIX."fichinterdet SET";
1448
-		$sql.= " description='".$this->db->escape($this->desc)."'";
1449
-		$sql.= ",date='".$this->db->idate($this->datei)."'";
1450
-		$sql.= ",duree=".$this->duration;
1451
-		$sql.= ",rang='".$this->db->escape($this->rang)."'";
1452
-		$sql.= " WHERE rowid = ".$this->rowid;
1448
+		$sql .= " description='".$this->db->escape($this->desc)."'";
1449
+		$sql .= ",date='".$this->db->idate($this->datei)."'";
1450
+		$sql .= ",duree=".$this->duration;
1451
+		$sql .= ",rang='".$this->db->escape($this->rang)."'";
1452
+		$sql .= " WHERE rowid = ".$this->rowid;
1453 1453
 
1454 1454
 		dol_syslog("FichinterLigne::update", LOG_DEBUG);
1455
-		$resql=$this->db->query($sql);
1455
+		$resql = $this->db->query($sql);
1456 1456
 		if ($resql)
1457 1457
 		{
1458 1458
 
1459 1459
 			if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
1460 1460
         	{
1461
-        		$this->id=$this->rowid;
1462
-        		$result=$this->insertExtraFields();
1461
+        		$this->id = $this->rowid;
1462
+        		$result = $this->insertExtraFields();
1463 1463
         		if ($result < 0)
1464 1464
         		{
1465 1465
         			$error++;
1466 1466
         		}
1467 1467
         	}
1468 1468
 
1469
-			$result=$this->update_total();
1469
+			$result = $this->update_total();
1470 1470
 			if ($result > 0)
1471 1471
 			{
1472 1472
 
1473
-				if (! $notrigger)
1473
+				if (!$notrigger)
1474 1474
 				{
1475 1475
                     // Call trigger
1476
-                    $result=$this->call_trigger('LINEFICHINTER_UPDATE',$user);
1476
+                    $result = $this->call_trigger('LINEFICHINTER_UPDATE', $user);
1477 1477
                     if ($result < 0) { $error++; }
1478 1478
                     // End call triggers
1479 1479
 				}
@@ -1486,14 +1486,14 @@  discard block
 block discarded – undo
1486 1486
 			}
1487 1487
 			else
1488 1488
 			{
1489
-				$this->error=$this->db->lasterror();
1489
+				$this->error = $this->db->lasterror();
1490 1490
 				$this->db->rollback();
1491 1491
 				return -1;
1492 1492
 			}
1493 1493
 		}
1494 1494
 		else
1495 1495
 		{
1496
-			$this->error=$this->db->lasterror();
1496
+			$this->error = $this->db->lasterror();
1497 1497
 			$this->db->rollback();
1498 1498
 			return -1;
1499 1499
 		}
@@ -1511,26 +1511,26 @@  discard block
 block discarded – undo
1511 1511
 		$this->db->begin();
1512 1512
 
1513 1513
 		$sql = "SELECT SUM(duree) as total_duration, min(date) as dateo, max(date) as datee ";
1514
-		$sql.= " FROM ".MAIN_DB_PREFIX."fichinterdet";
1515
-		$sql.= " WHERE fk_fichinter=".$this->fk_fichinter;
1514
+		$sql .= " FROM ".MAIN_DB_PREFIX."fichinterdet";
1515
+		$sql .= " WHERE fk_fichinter=".$this->fk_fichinter;
1516 1516
 
1517 1517
 		dol_syslog("FichinterLigne::update_total", LOG_DEBUG);
1518
-		$resql=$this->db->query($sql);
1518
+		$resql = $this->db->query($sql);
1519 1519
 		if ($resql)
1520 1520
 		{
1521
-			$obj=$this->db->fetch_object($resql);
1522
-			$total_duration=0;
1521
+			$obj = $this->db->fetch_object($resql);
1522
+			$total_duration = 0;
1523 1523
 			if (!empty($obj->total_duration)) $total_duration = $obj->total_duration;
1524 1524
 
1525 1525
 			$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter";
1526
-			$sql.= " SET duree = ".$total_duration;
1527
-			$sql.= " , dateo = ".(! empty($obj->dateo)?"'".$this->db->idate($obj->dateo)."'":"null");
1528
-			$sql.= " , datee = ".(! empty($obj->datee)?"'".$this->db->idate($obj->datee)."'":"null");
1529
-			$sql.= " WHERE rowid = ".$this->fk_fichinter;
1530
-			$sql.= " AND entity = ".$conf->entity;
1526
+			$sql .= " SET duree = ".$total_duration;
1527
+			$sql .= " , dateo = ".(!empty($obj->dateo) ? "'".$this->db->idate($obj->dateo)."'" : "null");
1528
+			$sql .= " , datee = ".(!empty($obj->datee) ? "'".$this->db->idate($obj->datee)."'" : "null");
1529
+			$sql .= " WHERE rowid = ".$this->fk_fichinter;
1530
+			$sql .= " AND entity = ".$conf->entity;
1531 1531
 
1532 1532
 			dol_syslog("FichinterLigne::update_total", LOG_DEBUG);
1533
-			$resql=$this->db->query($sql);
1533
+			$resql = $this->db->query($sql);
1534 1534
 			if ($resql)
1535 1535
 			{
1536 1536
 				$this->db->commit();
@@ -1538,14 +1538,14 @@  discard block
 block discarded – undo
1538 1538
 			}
1539 1539
 			else
1540 1540
 			{
1541
-				$this->error=$this->db->error();
1541
+				$this->error = $this->db->error();
1542 1542
 				$this->db->rollback();
1543 1543
 				return -2;
1544 1544
 			}
1545 1545
 		}
1546 1546
 		else
1547 1547
 		{
1548
-			$this->error=$this->db->error();
1548
+			$this->error = $this->db->error();
1549 1549
 			$this->db->rollback();
1550 1550
 			return -1;
1551 1551
 		}
@@ -1558,9 +1558,9 @@  discard block
 block discarded – undo
1558 1558
      *	@param		int		$notrigger	Disable all triggers
1559 1559
 	 *	@return     int		>0 if ok, <0 if ko
1560 1560
 	 */
1561
-	function deleteline($user,$notrigger=0)
1561
+	function deleteline($user, $notrigger = 0)
1562 1562
 	{
1563
-		global $langs,$conf;
1563
+		global $langs, $conf;
1564 1564
 
1565 1565
 		if ($this->statut == 0)
1566 1566
 		{
@@ -1575,10 +1575,10 @@  discard block
 block discarded – undo
1575 1575
 				$result = $this->update_total();
1576 1576
 				if ($result > 0)
1577 1577
 				{
1578
-					if (! $notrigger)
1578
+					if (!$notrigger)
1579 1579
 					{
1580 1580
                         // Call trigger
1581
-                        $result=$this->call_trigger('LINEFICHINTER_DELETE',$user);
1581
+                        $result = $this->call_trigger('LINEFICHINTER_DELETE', $user);
1582 1582
                         if ($result < 0) { $error++; $this->db->rollback(); return -1; }
1583 1583
                         // End call triggers
1584 1584
 					}
@@ -1594,7 +1594,7 @@  discard block
 block discarded – undo
1594 1594
 			}
1595 1595
 			else
1596 1596
 			{
1597
-				$this->error=$this->db->error()." sql=".$sql;
1597
+				$this->error = $this->db->error()." sql=".$sql;
1598 1598
 				$this->db->rollback();
1599 1599
 				return -1;
1600 1600
 			}
Please login to merge, or discard this patch.
Braces   +123 added lines, -100 removed lines patch added patch discarded remove patch
@@ -139,8 +139,7 @@  discard block
 block discarded – undo
139 139
 			}
140 140
 			$this->db->free($resql);
141 141
 			return 1;
142
-		}
143
-		else
142
+		} else
144 143
 		{
145 144
 			dol_print_error($this->db);
146 145
 			$this->error=$this->db->error();
@@ -162,9 +161,12 @@  discard block
 block discarded – undo
162 161
 		dol_syslog(get_class($this)."::create ref=".$this->ref);
163 162
 
164 163
 		// Check parameters
165
-		if (! empty($this->ref))	// We check that ref is not already used
164
+		if (! empty($this->ref)) {
165
+			// We check that ref is not already used
166 166
 		{
167
-			$result=self::isExistingObject($this->element, 0, $this->ref);	// Check ref is not yet used
167
+			$result=self::isExistingObject($this->element, 0, $this->ref);
168
+		}
169
+		// Check ref is not yet used
168 170
 			if ($result > 0)
169 171
 			{
170 172
 				$this->error='ErrorRefAlreadyExists';
@@ -173,7 +175,9 @@  discard block
 block discarded – undo
173 175
 				return -1;
174 176
 			}
175 177
 		}
176
-		if (! is_numeric($this->duration)) $this->duration = 0;
178
+		if (! is_numeric($this->duration)) {
179
+			$this->duration = 0;
180
+		}
177 181
 
178 182
 		if ($this->socid <= 0)
179 183
 		{
@@ -233,12 +237,16 @@  discard block
 block discarded – undo
233 237
 
234 238
 				dol_syslog(get_class($this)."::create", LOG_DEBUG);
235 239
 				$resql=$this->db->query($sql);
236
-				if (! $resql) $error++;
240
+				if (! $resql) {
241
+					$error++;
242
+				}
237 243
 			}
238 244
 
239
-			if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
245
+			if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
246
+				// For avoid conflicts if trigger used
240 247
             {
241 248
             	$result=$this->insertExtraFields();
249
+			}
242 250
             	if ($result < 0)
243 251
             	{
244 252
             		$error++;
@@ -249,7 +257,9 @@  discard block
 block discarded – undo
249 257
 			if (! $error && $this->origin && $this->origin_id)
250 258
 			{
251 259
 				$ret = $this->add_object_linked();
252
-				if (! $ret)	dol_print_error($this->db);
260
+				if (! $ret) {
261
+					dol_print_error($this->db);
262
+				}
253 263
 			}
254 264
 
255 265
 
@@ -265,16 +275,14 @@  discard block
 block discarded – undo
265 275
 			{
266 276
 				$this->db->commit();
267 277
 				return $this->id;
268
-			}
269
-			else
278
+			} else
270 279
 			{
271 280
 				$this->db->rollback();
272 281
 				$this->error=join(',',$this->errors);
273 282
 				dol_syslog(get_class($this)."::create ".$this->error,LOG_ERR);
274 283
 				return -1;
275 284
 			}
276
-		}
277
-		else
285
+		} else
278 286
 		{
279 287
 			$this->error=$this->db->error();
280 288
 			$this->db->rollback();
@@ -324,8 +332,7 @@  discard block
 block discarded – undo
324 332
 
325 333
 			$this->db->commit();
326 334
 			return 1;
327
-		}
328
-		else
335
+		} else
329 336
 		{
330 337
 			$this->error=$this->db->error();
331 338
 			$this->db->rollback();
@@ -348,8 +355,11 @@  discard block
 block discarded – undo
348 355
 		$sql.= " f.tms as datem,";
349 356
 		$sql.= " f.duree, f.fk_projet, f.note_public, f.note_private, f.model_pdf, f.extraparams, fk_contrat";
350 357
 		$sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f";
351
-		if ($ref) $sql.= " WHERE f.ref='".$this->db->escape($ref)."'";
352
-		else $sql.= " WHERE f.rowid=".$rowid;
358
+		if ($ref) {
359
+			$sql.= " WHERE f.ref='".$this->db->escape($ref)."'";
360
+		} else {
361
+			$sql.= " WHERE f.rowid=".$rowid;
362
+		}
353 363
 
354 364
 		dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
355 365
 		$resql=$this->db->query($sql);
@@ -381,7 +391,9 @@  discard block
 block discarded – undo
381 391
 
382 392
 				$this->extraparams	= (array) json_decode($obj->extraparams, true);
383 393
 
384
-				if ($this->statut == 0) $this->brouillon = 1;
394
+				if ($this->statut == 0) {
395
+					$this->brouillon = 1;
396
+				}
385 397
 
386 398
 				require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
387 399
 				$extrafields=new ExtraFields($this->db);
@@ -399,8 +411,7 @@  discard block
 block discarded – undo
399 411
 				$this->db->free($resql);
400 412
 				return 1;
401 413
 			}
402
-		}
403
-		else
414
+		} else
404 415
 		{
405 416
 			$this->error=$this->db->lasterror();
406 417
 			return -1;
@@ -432,8 +443,7 @@  discard block
 block discarded – undo
432 443
 			{
433 444
 				$this->db->commit();
434 445
 				return 1;
435
-			}
436
-			else
446
+			} else
437 447
 			{
438 448
 				$this->db->rollback();
439 449
 				$this->error=$this->db->lasterror();
@@ -463,11 +473,12 @@  discard block
 block discarded – undo
463 473
 			$now=dol_now();
464 474
 
465 475
 			// Define new ref
466
-			if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
476
+			if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) {
477
+				// empty should not happened, but when it occurs, the test save life
467 478
 			{
468 479
 				$num = $this->getNextNumRef($this->thirdparty);
469 480
 			}
470
-			else
481
+			} else
471 482
 			{
472 483
 				$num = $this->ref;
473 484
 			}
@@ -546,8 +557,7 @@  discard block
 block discarded – undo
546 557
 			{
547 558
 				$this->db->commit();
548 559
 				return 1;
549
-			}
550
-			else
560
+			} else
551 561
 			{
552 562
 				$this->db->rollback();
553 563
 				dol_syslog(get_class($this)."::setValid ".$this->error,LOG_ERR);
@@ -634,20 +644,27 @@  discard block
 block discarded – undo
634 644
 	{
635 645
 		global $langs;
636 646
 
637
-		if ($mode == 0)
638
-			return $langs->trans($this->statuts[$statut]);
639
-		if ($mode == 1)
640
-			return $langs->trans($this->statuts_short[$statut]);
641
-		if ($mode == 2)
642
-			return img_picto($langs->trans($this->statuts_short[$statut]), $this->statuts_logo[$statut]).' '.$langs->trans($this->statuts_short[$statut]);
643
-		if ($mode == 3)
644
-			return img_picto($langs->trans($this->statuts_short[$statut]), $this->statuts_logo[$statut]);
645
-		if ($mode == 4)
646
-			return img_picto($langs->trans($this->statuts_short[$statut]),$this->statuts_logo[$statut]).' '.$langs->trans($this->statuts[$statut]);
647
-		if ($mode == 5)
648
-			return '<span class="hideonsmartphone">'.$langs->trans($this->statuts_short[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
649
-		if ($mode == 6)
650
-		    return '<span class="hideonsmartphone">'.$langs->trans($this->statuts[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
647
+		if ($mode == 0) {
648
+					return $langs->trans($this->statuts[$statut]);
649
+		}
650
+		if ($mode == 1) {
651
+					return $langs->trans($this->statuts_short[$statut]);
652
+		}
653
+		if ($mode == 2) {
654
+					return img_picto($langs->trans($this->statuts_short[$statut]), $this->statuts_logo[$statut]).' '.$langs->trans($this->statuts_short[$statut]);
655
+		}
656
+		if ($mode == 3) {
657
+					return img_picto($langs->trans($this->statuts_short[$statut]), $this->statuts_logo[$statut]);
658
+		}
659
+		if ($mode == 4) {
660
+					return img_picto($langs->trans($this->statuts_short[$statut]),$this->statuts_logo[$statut]).' '.$langs->trans($this->statuts[$statut]);
661
+		}
662
+		if ($mode == 5) {
663
+					return '<span class="hideonsmartphone">'.$langs->trans($this->statuts_short[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
664
+		}
665
+		if ($mode == 6) {
666
+				    return '<span class="hideonsmartphone">'.$langs->trans($this->statuts[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
667
+		}
651 668
 
652 669
 		return '';
653 670
 	}
@@ -668,8 +685,9 @@  discard block
 block discarded – undo
668 685
 		$result='';
669 686
 
670 687
         $label = '<u>' . $langs->trans("ShowIntervention") . '</u>';
671
-        if (! empty($this->ref))
672
-            $label .= '<br><b>' . $langs->trans('Ref') . ':</b> '.$this->ref;
688
+        if (! empty($this->ref)) {
689
+                    $label .= '<br><b>' . $langs->trans('Ref') . ':</b> '.$this->ref;
690
+        }
673 691
 
674 692
         $picto='intervention';
675 693
         $url = DOL_URL_ROOT.'/fichinter/card.php?id='.$this->id;
@@ -678,8 +696,12 @@  discard block
 block discarded – undo
678 696
         {
679 697
         	// Add param to save lastsearch_values or not
680 698
         	$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
681
-        	if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
682
-        	if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
699
+        	if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) {
700
+        		$add_save_lastsearch_values=1;
701
+        	}
702
+        	if ($add_save_lastsearch_values) {
703
+        		$url.='&save_lastsearch_values=1';
704
+        	}
683 705
        	}
684 706
 
685 707
 		$linkclose='';
@@ -698,9 +720,15 @@  discard block
 block discarded – undo
698 720
 		$linkstart.=$linkclose.'>';
699 721
 		$linkend='</a>';
700 722
 
701
-        if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
702
-		if ($withpicto && $withpicto != 2) $result.=' ';
703
-		if ($withpicto != 2) $result.=$linkstart.$this->ref.$linkend;
723
+        if ($withpicto) {
724
+        	$result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
725
+        }
726
+		if ($withpicto && $withpicto != 2) {
727
+			$result.=' ';
728
+		}
729
+		if ($withpicto != 2) {
730
+			$result.=$linkstart.$this->ref.$linkend;
731
+		}
704 732
 		return $result;
705 733
 	}
706 734
 
@@ -748,14 +776,12 @@  discard block
 block discarded – undo
748 776
 			if ( $numref != "")
749 777
 			{
750 778
 				return $numref;
751
-			}
752
-			else
779
+			} else
753 780
 			{
754 781
 				dol_print_error($db,"Fichinter::getNextNumRef ".$obj->error);
755 782
 				return "";
756 783
 			}
757
-		}
758
-		else
784
+		} else
759 785
 		{
760 786
 			$langs->load("errors");
761 787
 			print $langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined");
@@ -816,8 +842,7 @@  discard block
 block discarded – undo
816 842
 
817 843
 			}
818 844
 			$this->db->free($resql);
819
-		}
820
-		else
845
+		} else
821 846
 		{
822 847
 			dol_print_error($this->db);
823 848
 		}
@@ -841,7 +866,9 @@  discard block
 block discarded – undo
841 866
 
842 867
 		// Delete linked object
843 868
 		$res = $this->deleteObjectLinked();
844
-		if ($res < 0) $error++;
869
+		if ($res < 0) {
870
+			$error++;
871
+		}
845 872
 
846 873
 		// Delete linked contacts
847 874
 		$res = $this->delete_linked_contact();
@@ -881,9 +908,11 @@  discard block
 block discarded – undo
881 908
 					{
882 909
 						dol_delete_preview($this);
883 910
 
884
-						if (! dol_delete_file($file,0,0,0,$this)) // For triggers
911
+						if (! dol_delete_file($file,0,0,0,$this)) {
912
+							// For triggers
885 913
 						{
886 914
 							$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
915
+						}
887 916
 							return 0;
888 917
 						}
889 918
 					}
@@ -907,15 +936,13 @@  discard block
 block discarded – undo
907 936
 
908 937
 				$this->db->commit();
909 938
 				return 1;
910
-			}
911
-			else
939
+			} else
912 940
 			{
913 941
 				$this->error=$this->db->lasterror();
914 942
 				$this->db->rollback();
915 943
 				return -2;
916 944
 			}
917
-		}
918
-		else
945
+		} else
919 946
 		{
920 947
 			$this->error=$this->db->lasterror();
921 948
 			$this->db->rollback();
@@ -946,8 +973,7 @@  discard block
 block discarded – undo
946 973
 			{
947 974
 				$this->date_delivery = $date_delivery;
948 975
 				return 1;
949
-			}
950
-			else
976
+			} else
951 977
 			{
952 978
 				$this->error=$this->db->error();
953 979
 				dol_syslog("Fichinter::set_date_delivery Erreur SQL");
@@ -979,8 +1005,7 @@  discard block
 block discarded – undo
979 1005
 			{
980 1006
 				$this->description = $description;
981 1007
 				return 1;
982
-			}
983
-			else
1008
+			} else
984 1009
 			{
985 1010
 				$this->error=$this->db->error();
986 1011
 				dol_syslog("Fichinter::set_description Erreur SQL");
@@ -1012,8 +1037,7 @@  discard block
 block discarded – undo
1012 1037
 			{
1013 1038
 				$this->fk_contrat = $contractid;
1014 1039
 				return 1;
1015
-			}
1016
-			else
1040
+			} else
1017 1041
 			{
1018 1042
 				$this->error=$this->db->error();
1019 1043
 				return -1;
@@ -1041,8 +1065,9 @@  discard block
 block discarded – undo
1041 1065
         $this->db->begin();
1042 1066
 
1043 1067
 		// get extrafields so they will be clone
1044
-		foreach($this->lines as $line)
1045
-			$line->fetch_optionals($line->rowid);
1068
+		foreach($this->lines as $line) {
1069
+					$line->fetch_optionals($line->rowid);
1070
+		}
1046 1071
 
1047 1072
         // Load source object
1048 1073
         $objFrom = clone $this;
@@ -1077,7 +1102,9 @@  discard block
 block discarded – undo
1077 1102
 
1078 1103
         // Create clone
1079 1104
         $result=$this->create($user);
1080
-        if ($result < 0) $error++;
1105
+        if ($result < 0) {
1106
+        	$error++;
1107
+        }
1081 1108
 
1082 1109
         if (! $error)
1083 1110
         {
@@ -1093,12 +1120,16 @@  discard block
 block discarded – undo
1093 1120
                 $parameters=array('objFrom'=>$objFrom);
1094 1121
                 $action='';
1095 1122
                 $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1096
-                if ($reshook < 0) $error++;
1123
+                if ($reshook < 0) {
1124
+                	$error++;
1125
+                }
1097 1126
             }
1098 1127
 
1099 1128
             // Call trigger
1100 1129
             $result=$this->call_trigger('INTERVENTION_CLONE',$user);
1101
-            if ($result < 0) $error++;
1130
+            if ($result < 0) {
1131
+            	$error++;
1132
+            }
1102 1133
             // End call triggers
1103 1134
         }
1104 1135
 
@@ -1109,8 +1140,7 @@  discard block
 block discarded – undo
1109 1140
         {
1110 1141
             $this->db->commit();
1111 1142
             return $this->id;
1112
-        }
1113
-        else
1143
+        } else
1114 1144
         {
1115 1145
             $this->db->rollback();
1116 1146
             return -1;
@@ -1155,8 +1185,7 @@  discard block
 block discarded – undo
1155 1185
 			{
1156 1186
 				$this->db->commit();
1157 1187
 				return 1;
1158
-			}
1159
-			else
1188
+			} else
1160 1189
 			{
1161 1190
 				$this->error=$this->db->error();
1162 1191
 				$this->db->rollback();
@@ -1243,8 +1272,7 @@  discard block
 block discarded – undo
1243 1272
 			$this->db->free($resql);
1244 1273
 
1245 1274
 			return 1;
1246
-		}
1247
-		else
1275
+		} else
1248 1276
 		{
1249 1277
 			$this->error=$this->db->error();
1250 1278
 			return -1;
@@ -1326,8 +1354,7 @@  discard block
 block discarded – undo
1326 1354
 
1327 1355
 			$this->db->free($result);
1328 1356
 			return 1;
1329
-		}
1330
-		else
1357
+		} else
1331 1358
 		{
1332 1359
 			$this->error=$this->db->error().' sql='.$sql;
1333 1360
 			return -1;
@@ -1360,8 +1387,7 @@  discard block
 block discarded – undo
1360 1387
 			{
1361 1388
 				$obj = $this->db->fetch_object($resql);
1362 1389
 				$rangToUse = $obj->max + 1;
1363
-			}
1364
-			else
1390
+			} else
1365 1391
 			{
1366 1392
 				dol_print_error($this->db);
1367 1393
 				$this->db->rollback();
@@ -1385,9 +1411,11 @@  discard block
 block discarded – undo
1385 1411
 		{
1386 1412
 			$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'fichinterdet');
1387 1413
 
1388
-			if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
1414
+			if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
1415
+				// For avoid conflicts if trigger used
1389 1416
             {
1390 1417
             	$this->id=$this->rowid;
1418
+			}
1391 1419
             	$result=$this->insertExtraFields();
1392 1420
             	if ($result < 0)
1393 1421
             	{
@@ -1414,14 +1442,12 @@  discard block
 block discarded – undo
1414 1442
 			if (!$error) {
1415 1443
 				$this->db->commit();
1416 1444
 				return $result;
1417
-			}
1418
-			else
1445
+			} else
1419 1446
 			{
1420 1447
 				$this->db->rollback();
1421 1448
 				return -1;
1422 1449
 			}
1423
-		}
1424
-		else
1450
+		} else
1425 1451
 		{
1426 1452
 			$this->error=$this->db->error()." sql=".$sql;
1427 1453
 			$this->db->rollback();
@@ -1456,9 +1482,11 @@  discard block
 block discarded – undo
1456 1482
 		if ($resql)
1457 1483
 		{
1458 1484
 
1459
-			if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
1485
+			if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
1486
+				// For avoid conflicts if trigger used
1460 1487
         	{
1461 1488
         		$this->id=$this->rowid;
1489
+			}
1462 1490
         		$result=$this->insertExtraFields();
1463 1491
         		if ($result < 0)
1464 1492
         		{
@@ -1483,15 +1511,13 @@  discard block
 block discarded – undo
1483 1511
 			{
1484 1512
 				$this->db->commit();
1485 1513
 				return $result;
1486
-			}
1487
-			else
1514
+			} else
1488 1515
 			{
1489 1516
 				$this->error=$this->db->lasterror();
1490 1517
 				$this->db->rollback();
1491 1518
 				return -1;
1492 1519
 			}
1493
-		}
1494
-		else
1520
+		} else
1495 1521
 		{
1496 1522
 			$this->error=$this->db->lasterror();
1497 1523
 			$this->db->rollback();
@@ -1520,7 +1546,9 @@  discard block
 block discarded – undo
1520 1546
 		{
1521 1547
 			$obj=$this->db->fetch_object($resql);
1522 1548
 			$total_duration=0;
1523
-			if (!empty($obj->total_duration)) $total_duration = $obj->total_duration;
1549
+			if (!empty($obj->total_duration)) {
1550
+				$total_duration = $obj->total_duration;
1551
+			}
1524 1552
 
1525 1553
 			$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter";
1526 1554
 			$sql.= " SET duree = ".$total_duration;
@@ -1535,15 +1563,13 @@  discard block
 block discarded – undo
1535 1563
 			{
1536 1564
 				$this->db->commit();
1537 1565
 				return 1;
1538
-			}
1539
-			else
1566
+			} else
1540 1567
 			{
1541 1568
 				$this->error=$this->db->error();
1542 1569
 				$this->db->rollback();
1543 1570
 				return -2;
1544 1571
 			}
1545
-		}
1546
-		else
1572
+		} else
1547 1573
 		{
1548 1574
 			$this->error=$this->db->error();
1549 1575
 			$this->db->rollback();
@@ -1585,21 +1611,18 @@  discard block
 block discarded – undo
1585 1611
 
1586 1612
                     $this->db->commit();
1587 1613
                     return $result;
1588
-				}
1589
-				else
1614
+				} else
1590 1615
 				{
1591 1616
 					$this->db->rollback();
1592 1617
 					return -1;
1593 1618
 				}
1594
-			}
1595
-			else
1619
+			} else
1596 1620
 			{
1597 1621
 				$this->error=$this->db->error()." sql=".$sql;
1598 1622
 				$this->db->rollback();
1599 1623
 				return -1;
1600 1624
 			}
1601
-		}
1602
-		else
1625
+		} else
1603 1626
 		{
1604 1627
 			return -2;
1605 1628
 		}
Please login to merge, or discard this patch.
htdocs/core/lib/usergroups.lib.php 3 patches
Indentation   +410 added lines, -410 removed lines patch added patch discarded remove patch
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
 	$h = 0;
46 46
 	$head = array();
47 47
 
48
-    $head[$h][0] = DOL_URL_ROOT.'/user/card.php?id='.$object->id;
49
-    $head[$h][1] = $langs->trans("UserCard");
50
-    $head[$h][2] = 'user';
51
-    $h++;
48
+	$head[$h][0] = DOL_URL_ROOT.'/user/card.php?id='.$object->id;
49
+	$head[$h][1] = $langs->trans("UserCard");
50
+	$head[$h][2] = 'user';
51
+	$h++;
52 52
 
53 53
 	if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE))
54 54
 		&& (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin)))
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
 		$h++;
61 61
 	}
62 62
 
63
-    $head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$object->id;
64
-    $head[$h][1] = $langs->trans("UserGUISetup");
65
-    $head[$h][2] = 'guisetup';
66
-    $h++;
63
+	$head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$object->id;
64
+	$head[$h][1] = $langs->trans("UserGUISetup");
65
+	$head[$h][2] = 'guisetup';
66
+	$h++;
67 67
 
68 68
 	if ($canreadperms)
69 69
 	{
@@ -73,116 +73,116 @@  discard block
 block discarded – undo
73 73
 		$h++;
74 74
 	}
75 75
 
76
-    if (! empty($conf->agenda->enabled))
77
-    {
78
-        if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
79
-        $MAXAGENDA=$conf->global->AGENDA_EXT_NB;
80
-
81
-        $i=1;
82
-        $nbagenda = 0;
83
-        while ($i <= $MAXAGENDA)
84
-        {
85
-            $key=$i;
86
-            $name='AGENDA_EXT_NAME_'.$object->id.'_'.$key;
87
-            $src='AGENDA_EXT_SRC_'.$object->id.'_'.$key;
88
-            $offsettz='AGENDA_EXT_OFFSETTZ_'.$object->id.'_'.$key;
89
-            $color='AGENDA_EXT_COLOR_'.$object->id.'_'.$key;
90
-            $i++;
91
-
92
-            if (! empty($object->conf->$name)) $nbagenda++;
93
-        }
94
-
95
-	    $head[$h][0] = DOL_URL_ROOT.'/user/agenda_extsites.php?id='.$object->id;
96
-	    $head[$h][1] = $langs->trans("ExtSites").($nbagenda ? ' <span class="badge">'.$nbagenda.'</span>' : '');
97
-	    $head[$h][2] = 'extsites';
98
-	    $h++;
99
-    }
100
-
101
-    if (! empty($conf->clicktodial->enabled))
102
-    {
103
-        $head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$object->id;
104
-        $head[$h][1] = $langs->trans("ClickToDial");
105
-	    $head[$h][2] = 'clicktodial';
106
-        $h++;
107
-    }
108
-
109
-    // Notifications
110
-    if ($user->societe_id == 0 && ! empty($conf->notification->enabled))
111
-    {
112
-        $nbNote = 0;
113
-        $sql = "SELECT COUNT(n.rowid) as nb";
114
-        $sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n";
115
-        $sql.= " WHERE fk_user = ".$object->id;
116
-        $resql=$db->query($sql);
117
-        if ($resql)
118
-        {
119
-            $num = $db->num_rows($resql);
120
-            $i = 0;
121
-            while ($i < $num)
122
-            {
123
-                $obj = $db->fetch_object($resql);
124
-                $nbNote=$obj->nb;
125
-                $i++;
126
-            }
127
-        }
128
-        else {
129
-            dol_print_error($db);
130
-        }
131
-
132
-        $head[$h][0] = DOL_URL_ROOT.'/user/notify/card.php?id='.$object->id;
133
-        $head[$h][1] = $langs->trans("Notifications");
134
-        if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
135
-        $head[$h][2] = 'notify';
136
-        $h++;
137
-    }
138
-
139
-    // Show more tabs from modules
140
-    // Entries must be declared in modules descriptor with line
141
-    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
142
-    // $this->tabs = array('entity:-tabname);   												to remove a tab
143
-    complete_head_from_modules($conf,$langs,$object,$head,$h,'user');
144
-
145
-    if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
146
-       || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read)))
147
-    {
76
+	if (! empty($conf->agenda->enabled))
77
+	{
78
+		if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
79
+		$MAXAGENDA=$conf->global->AGENDA_EXT_NB;
80
+
81
+		$i=1;
82
+		$nbagenda = 0;
83
+		while ($i <= $MAXAGENDA)
84
+		{
85
+			$key=$i;
86
+			$name='AGENDA_EXT_NAME_'.$object->id.'_'.$key;
87
+			$src='AGENDA_EXT_SRC_'.$object->id.'_'.$key;
88
+			$offsettz='AGENDA_EXT_OFFSETTZ_'.$object->id.'_'.$key;
89
+			$color='AGENDA_EXT_COLOR_'.$object->id.'_'.$key;
90
+			$i++;
91
+
92
+			if (! empty($object->conf->$name)) $nbagenda++;
93
+		}
94
+
95
+		$head[$h][0] = DOL_URL_ROOT.'/user/agenda_extsites.php?id='.$object->id;
96
+		$head[$h][1] = $langs->trans("ExtSites").($nbagenda ? ' <span class="badge">'.$nbagenda.'</span>' : '');
97
+		$head[$h][2] = 'extsites';
98
+		$h++;
99
+	}
100
+
101
+	if (! empty($conf->clicktodial->enabled))
102
+	{
103
+		$head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$object->id;
104
+		$head[$h][1] = $langs->trans("ClickToDial");
105
+		$head[$h][2] = 'clicktodial';
106
+		$h++;
107
+	}
108
+
109
+	// Notifications
110
+	if ($user->societe_id == 0 && ! empty($conf->notification->enabled))
111
+	{
112
+		$nbNote = 0;
113
+		$sql = "SELECT COUNT(n.rowid) as nb";
114
+		$sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n";
115
+		$sql.= " WHERE fk_user = ".$object->id;
116
+		$resql=$db->query($sql);
117
+		if ($resql)
118
+		{
119
+			$num = $db->num_rows($resql);
120
+			$i = 0;
121
+			while ($i < $num)
122
+			{
123
+				$obj = $db->fetch_object($resql);
124
+				$nbNote=$obj->nb;
125
+				$i++;
126
+			}
127
+		}
128
+		else {
129
+			dol_print_error($db);
130
+		}
131
+
132
+		$head[$h][0] = DOL_URL_ROOT.'/user/notify/card.php?id='.$object->id;
133
+		$head[$h][1] = $langs->trans("Notifications");
134
+		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
135
+		$head[$h][2] = 'notify';
136
+		$h++;
137
+	}
138
+
139
+	// Show more tabs from modules
140
+	// Entries must be declared in modules descriptor with line
141
+	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
142
+	// $this->tabs = array('entity:-tabname);   												to remove a tab
143
+	complete_head_from_modules($conf,$langs,$object,$head,$h,'user');
144
+
145
+	if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
146
+	   || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read)))
147
+	{
148 148
 		// Bank
149
-    	$head[$h][0] = DOL_URL_ROOT.'/user/bank.php?id='.$object->id;
150
-    	$head[$h][1] = $langs->trans("HRAndBank");
151
-    	$head[$h][2] = 'bank';
152
-    	$h++;
149
+		$head[$h][0] = DOL_URL_ROOT.'/user/bank.php?id='.$object->id;
150
+		$head[$h][1] = $langs->trans("HRAndBank");
151
+		$head[$h][2] = 'bank';
152
+		$h++;
153 153
 	}
154 154
 
155
-    // Such info on users is visible only by internal user
156
-    if (empty($user->societe_id))
157
-    {
155
+	// Such info on users is visible only by internal user
156
+	if (empty($user->societe_id))
157
+	{
158 158
 		// Notes
159
-        $nbNote = 0;
160
-        if(!empty($object->note)) $nbNote++;
161
-        $head[$h][0] = DOL_URL_ROOT.'/user/note.php?id='.$object->id;
162
-        $head[$h][1] = $langs->trans("Note");
159
+		$nbNote = 0;
160
+		if(!empty($object->note)) $nbNote++;
161
+		$head[$h][0] = DOL_URL_ROOT.'/user/note.php?id='.$object->id;
162
+		$head[$h][1] = $langs->trans("Note");
163 163
 		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
164
-        $head[$h][2] = 'note';
165
-        $h++;
166
-
167
-        // Attached files
168
-        require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
169
-        require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
170
-        $upload_dir = $conf->user->dir_output . "/" . $object->id;
171
-        $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
172
-        $nbLinks=Link::count($db, $object->element, $object->id);
173
-        $head[$h][0] = DOL_URL_ROOT.'/user/document.php?userid='.$object->id;
174
-        $head[$h][1] = $langs->trans("Documents");
175
-        if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
176
-        $head[$h][2] = 'document';
177
-        $h++;
178
-
179
-    	$head[$h][0] = DOL_URL_ROOT.'/user/info.php?id='.$object->id;
180
-    	$head[$h][1] = $langs->trans("Info");
181
-    	$head[$h][2] = 'info';
182
-    	$h++;
183
-    }
184
-
185
-    complete_head_from_modules($conf,$langs,$object,$head,$h,'user','remove');
164
+		$head[$h][2] = 'note';
165
+		$h++;
166
+
167
+		// Attached files
168
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
169
+		require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
170
+		$upload_dir = $conf->user->dir_output . "/" . $object->id;
171
+		$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
172
+		$nbLinks=Link::count($db, $object->element, $object->id);
173
+		$head[$h][0] = DOL_URL_ROOT.'/user/document.php?userid='.$object->id;
174
+		$head[$h][1] = $langs->trans("Documents");
175
+		if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
176
+		$head[$h][2] = 'document';
177
+		$h++;
178
+
179
+		$head[$h][0] = DOL_URL_ROOT.'/user/info.php?id='.$object->id;
180
+		$head[$h][1] = $langs->trans("Info");
181
+		$head[$h][2] = 'info';
182
+		$h++;
183
+	}
184
+
185
+	complete_head_from_modules($conf,$langs,$object,$head,$h,'user','remove');
186 186
 
187 187
 	return $head;
188 188
 }
@@ -206,10 +206,10 @@  discard block
 block discarded – undo
206 206
 	$h = 0;
207 207
 	$head = array();
208 208
 
209
-    $head[$h][0] = DOL_URL_ROOT.'/user/group/card.php?id='.$object->id;
210
-    $head[$h][1] = $langs->trans("GroupCard");
211
-    $head[$h][2] = 'group';
212
-    $h++;
209
+	$head[$h][0] = DOL_URL_ROOT.'/user/group/card.php?id='.$object->id;
210
+	$head[$h][1] = $langs->trans("GroupCard");
211
+	$head[$h][2] = 'group';
212
+	$h++;
213 213
 
214 214
 	if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE))
215 215
 		&& (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin)))
@@ -229,15 +229,15 @@  discard block
 block discarded – undo
229 229
 		$h++;
230 230
 	}
231 231
 
232
-    // Show more tabs from modules
233
-    // Entries must be declared in modules descriptor with line
234
-    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
235
-    // $this->tabs = array('entity:-tabname);   												to remove a tab
236
-    complete_head_from_modules($conf,$langs,$object,$head,$h,'group');
232
+	// Show more tabs from modules
233
+	// Entries must be declared in modules descriptor with line
234
+	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
235
+	// $this->tabs = array('entity:-tabname);   												to remove a tab
236
+	complete_head_from_modules($conf,$langs,$object,$head,$h,'group');
237 237
 
238
-    complete_head_from_modules($conf,$langs,$object,$head,$h,'group','remove');
238
+	complete_head_from_modules($conf,$langs,$object,$head,$h,'group','remove');
239 239
 
240
-    return $head;
240
+	return $head;
241 241
 }
242 242
 
243 243
 /**
@@ -252,25 +252,25 @@  discard block
 block discarded – undo
252 252
 	$langs->load("users");
253 253
 	$h=0;
254 254
 
255
-    $head[$h][0] = DOL_URL_ROOT.'/admin/user.php';
256
-    $head[$h][1] = $langs->trans("Parameters");
257
-    $head[$h][2] = 'card';
258
-    $h++;
255
+	$head[$h][0] = DOL_URL_ROOT.'/admin/user.php';
256
+	$head[$h][1] = $langs->trans("Parameters");
257
+	$head[$h][2] = 'card';
258
+	$h++;
259 259
 
260
-    $head[$h][0] = DOL_URL_ROOT.'/admin/usergroup.php';
261
-    $head[$h][1] = $langs->trans("Group");
262
-    $head[$h][2] = 'usergroupcard';
263
-    $h++;
260
+	$head[$h][0] = DOL_URL_ROOT.'/admin/usergroup.php';
261
+	$head[$h][1] = $langs->trans("Group");
262
+	$head[$h][2] = 'usergroupcard';
263
+	$h++;
264 264
 
265
-    $head[$h][0] = DOL_URL_ROOT.'/user/admin/user_extrafields.php';
266
-    $head[$h][1] = $langs->trans("ExtraFields");
267
-    $head[$h][2] = 'attributes';
268
-    $h++;
265
+	$head[$h][0] = DOL_URL_ROOT.'/user/admin/user_extrafields.php';
266
+	$head[$h][1] = $langs->trans("ExtraFields");
267
+	$head[$h][2] = 'attributes';
268
+	$h++;
269 269
 
270 270
    $head[$h][0] = DOL_URL_ROOT.'/user/admin/group_extrafields.php';
271
-    $head[$h][1] = $langs->trans("ExtraFields")." ".$langs->trans("Groups");
272
-    $head[$h][2] = 'attributes_group';
273
-    $h++;
271
+	$head[$h][1] = $langs->trans("ExtraFields")." ".$langs->trans("Groups");
272
+	$head[$h][2] = 'attributes_group';
273
+	$h++;
274 274
 
275 275
 	// Show more tabs from modules
276 276
 	// Entries must be declared in modules descriptor with line
@@ -293,134 +293,134 @@  discard block
 block discarded – undo
293 293
  */
294 294
 function show_theme($fuser,$edit=0,$foruserprofile=false)
295 295
 {
296
-    global $conf,$langs,$db,$form;
297
-    global $bc;
296
+	global $conf,$langs,$db,$form;
297
+	global $bc;
298 298
 
299 299
 	require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
300 300
 
301
-    $formother = new FormOther($db);
302
-
303
-    $dirthemes=array('/theme');
304
-    if (! empty($conf->modules_parts['theme']))		// Using this feature slow down application
305
-    {
306
-    	foreach($conf->modules_parts['theme'] as $reldir)
307
-    	{
308
-	    	$dirthemes=array_merge($dirthemes,(array) ($reldir.'theme'));
309
-    	}
310
-    }
311
-    $dirthemes=array_unique($dirthemes);
301
+	$formother = new FormOther($db);
302
+
303
+	$dirthemes=array('/theme');
304
+	if (! empty($conf->modules_parts['theme']))		// Using this feature slow down application
305
+	{
306
+		foreach($conf->modules_parts['theme'] as $reldir)
307
+		{
308
+			$dirthemes=array_merge($dirthemes,(array) ($reldir.'theme'));
309
+		}
310
+	}
311
+	$dirthemes=array_unique($dirthemes);
312 312
 	// Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme')
313 313
 
314
-    $selected_theme='';
315
-    if (empty($foruserprofile)) $selected_theme=$conf->global->MAIN_THEME;
316
-    else $selected_theme=((is_object($fuser) && ! empty($fuser->conf->MAIN_THEME))?$fuser->conf->MAIN_THEME:'');
314
+	$selected_theme='';
315
+	if (empty($foruserprofile)) $selected_theme=$conf->global->MAIN_THEME;
316
+	else $selected_theme=((is_object($fuser) && ! empty($fuser->conf->MAIN_THEME))?$fuser->conf->MAIN_THEME:'');
317 317
 
318 318
 	$hoverdisabled='';
319
-    if (empty($foruserprofile)) $hoverdisabled=(isset($conf->global->THEME_ELDY_USE_HOVER) && $conf->global->THEME_ELDY_USE_HOVER == '0');
320
-    else $hoverdisabled=(is_object($fuser)?(empty($fuser->conf->THEME_ELDY_USE_HOVER) || $fuser->conf->THEME_ELDY_USE_HOVER == '0'):'');
321
-
322
-    $colspan=2;
323
-    if ($foruserprofile) $colspan=4;
324
-
325
-    $thumbsbyrow=6;
326
-    print '<table class="noborder" width="100%">';
327
-
328
-    // Title
329
-    if ($foruserprofile)
330
-    {
331
-    	print '<tr class="liste_titre"><th class="titlefield">'.$langs->trans("Parameter").'</th><th>'.$langs->trans("DefaultValue").'</th>';
332
-    	print '<th colspan="2">&nbsp;</th>';
333
-	    print '</tr>';
334
-
335
-	    print '<tr>';
336
-	    print '<td>'.$langs->trans("DefaultSkin").'</td>';
337
-	    print '<td>'.$conf->global->MAIN_THEME.'</td>';
338
-	    print '<td align="left" class="nowrap" width="20%"><input id="check_MAIN_THEME" name="check_MAIN_THEME"'.($edit?'':' disabled').' type="checkbox" '.($selected_theme?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>';
339
-	    print '<td>&nbsp;</td>';
340
-	    print '</tr>';
341
-    }
342
-    else
343
-    {
344
-    	print '<tr class="liste_titre"><th class="titlefield">'.$langs->trans("DefaultSkin").'</th>';
345
-    	print '<th align="right">';
346
-    	$url='https://www.dolistore.com/lang-en/4-skins';
347
-    	if (preg_match('/fr/i',$langs->defaultlang)) $url='https://www.dolistore.com/fr/4-themes';
348
-    	//if (preg_match('/es/i',$langs->defaultlang)) $url='http://www.dolistore.com/lang-es/4-themes';
349
-    	print '<a href="'.$url.'" target="_blank">';
350
-    	print $langs->trans('DownloadMoreSkins');
351
-    	print '</a>';
352
-    	print '</th></tr>';
353
-
354
-    	print '<tr>';
355
-    	print '<td>'.$langs->trans("ThemeDir").'</td>';
356
-    	print '<td>';
357
-    	foreach($dirthemes as $dirtheme)
358
-    	{
359
-    		echo '"'.$dirtheme.'" ';
360
-    	}
361
-    	print '</td>';
362
-    	print '</tr>';
363
-    }
364
-
365
-    print '<tr><td colspan="'.$colspan.'">';
366
-
367
-    print '<table class="nobordernopadding" width="100%"><tr><td><div align="center">';
368
-
369
-    $i=0;
370
-    foreach($dirthemes as $dir)
371
-    {
372
-    	//print $dirroot.$dir;exit;
373
-    	$dirtheme=dol_buildpath($dir,0);	// This include loop on $conf->file->dol_document_root
374
-    	$urltheme=dol_buildpath($dir,1);
375
-
376
-    	if (is_dir($dirtheme))
377
-    	{
378
-    		$handle=opendir($dirtheme);
379
-    		if (is_resource($handle))
380
-    		{
381
-    			while (($subdir = readdir($handle))!==false)
382
-    			{
383
-    				if (is_dir($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.'
384
-    						&& substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i',$subdir))
385
-    				{
386
-    					// Disable not stable themes (dir ends with _exp or _dev)
387
-    					if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i',$subdir)) continue;
388
-    					if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i',$subdir)) continue;
389
-
390
-    					print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
391
-    					$file=$dirtheme."/".$subdir."/thumb.png";
392
-    					$url=$urltheme."/".$subdir."/thumb.png";
393
-    					if (! file_exists($file)) $url=DOL_URL_ROOT.'/public/theme/common/nophoto.png';
394
-    					print '<a href="'.$_SERVER["PHP_SELF"].($edit?'?action=edit&theme=':'?theme=').$subdir.(GETPOST('optioncss','alpha',1)?'&optioncss='.GETPOST('optioncss','alpha',1):'').($fuser?'&id='.$fuser->id:'').'" style="font-weight: normal;" alt="'.$langs->trans("Preview").'">';
395
-    					if ($subdir == $conf->global->MAIN_THEME) $title=$langs->trans("ThemeCurrentlyActive");
396
-    					else $title=$langs->trans("ShowPreview");
397
-    					print '<img src="'.$url.'" border="0" width="80" height="60" alt="'.$title.'" title="'.$title.'" style="margin-bottom: 5px;">';
398
-    					print '</a><br>';
399
-    					if ($subdir == $selected_theme)
400
-    					{
401
-    						print '<input '.($edit?'':'disabled').' type="radio" class="themethumbs" style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>';
402
-    					}
403
-    					else
404
-    					{
405
-    						print '<input '.($edit?'':'disabled').' type="radio" class="themethumbs" style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir;
406
-    					}
319
+	if (empty($foruserprofile)) $hoverdisabled=(isset($conf->global->THEME_ELDY_USE_HOVER) && $conf->global->THEME_ELDY_USE_HOVER == '0');
320
+	else $hoverdisabled=(is_object($fuser)?(empty($fuser->conf->THEME_ELDY_USE_HOVER) || $fuser->conf->THEME_ELDY_USE_HOVER == '0'):'');
321
+
322
+	$colspan=2;
323
+	if ($foruserprofile) $colspan=4;
324
+
325
+	$thumbsbyrow=6;
326
+	print '<table class="noborder" width="100%">';
327
+
328
+	// Title
329
+	if ($foruserprofile)
330
+	{
331
+		print '<tr class="liste_titre"><th class="titlefield">'.$langs->trans("Parameter").'</th><th>'.$langs->trans("DefaultValue").'</th>';
332
+		print '<th colspan="2">&nbsp;</th>';
333
+		print '</tr>';
334
+
335
+		print '<tr>';
336
+		print '<td>'.$langs->trans("DefaultSkin").'</td>';
337
+		print '<td>'.$conf->global->MAIN_THEME.'</td>';
338
+		print '<td align="left" class="nowrap" width="20%"><input id="check_MAIN_THEME" name="check_MAIN_THEME"'.($edit?'':' disabled').' type="checkbox" '.($selected_theme?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>';
339
+		print '<td>&nbsp;</td>';
340
+		print '</tr>';
341
+	}
342
+	else
343
+	{
344
+		print '<tr class="liste_titre"><th class="titlefield">'.$langs->trans("DefaultSkin").'</th>';
345
+		print '<th align="right">';
346
+		$url='https://www.dolistore.com/lang-en/4-skins';
347
+		if (preg_match('/fr/i',$langs->defaultlang)) $url='https://www.dolistore.com/fr/4-themes';
348
+		//if (preg_match('/es/i',$langs->defaultlang)) $url='http://www.dolistore.com/lang-es/4-themes';
349
+		print '<a href="'.$url.'" target="_blank">';
350
+		print $langs->trans('DownloadMoreSkins');
351
+		print '</a>';
352
+		print '</th></tr>';
353
+
354
+		print '<tr>';
355
+		print '<td>'.$langs->trans("ThemeDir").'</td>';
356
+		print '<td>';
357
+		foreach($dirthemes as $dirtheme)
358
+		{
359
+			echo '"'.$dirtheme.'" ';
360
+		}
361
+		print '</td>';
362
+		print '</tr>';
363
+	}
364
+
365
+	print '<tr><td colspan="'.$colspan.'">';
366
+
367
+	print '<table class="nobordernopadding" width="100%"><tr><td><div align="center">';
368
+
369
+	$i=0;
370
+	foreach($dirthemes as $dir)
371
+	{
372
+		//print $dirroot.$dir;exit;
373
+		$dirtheme=dol_buildpath($dir,0);	// This include loop on $conf->file->dol_document_root
374
+		$urltheme=dol_buildpath($dir,1);
375
+
376
+		if (is_dir($dirtheme))
377
+		{
378
+			$handle=opendir($dirtheme);
379
+			if (is_resource($handle))
380
+			{
381
+				while (($subdir = readdir($handle))!==false)
382
+				{
383
+					if (is_dir($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.'
384
+							&& substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i',$subdir))
385
+					{
386
+						// Disable not stable themes (dir ends with _exp or _dev)
387
+						if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i',$subdir)) continue;
388
+						if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i',$subdir)) continue;
389
+
390
+						print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
391
+						$file=$dirtheme."/".$subdir."/thumb.png";
392
+						$url=$urltheme."/".$subdir."/thumb.png";
393
+						if (! file_exists($file)) $url=DOL_URL_ROOT.'/public/theme/common/nophoto.png';
394
+						print '<a href="'.$_SERVER["PHP_SELF"].($edit?'?action=edit&theme=':'?theme=').$subdir.(GETPOST('optioncss','alpha',1)?'&optioncss='.GETPOST('optioncss','alpha',1):'').($fuser?'&id='.$fuser->id:'').'" style="font-weight: normal;" alt="'.$langs->trans("Preview").'">';
395
+						if ($subdir == $conf->global->MAIN_THEME) $title=$langs->trans("ThemeCurrentlyActive");
396
+						else $title=$langs->trans("ShowPreview");
397
+						print '<img src="'.$url.'" border="0" width="80" height="60" alt="'.$title.'" title="'.$title.'" style="margin-bottom: 5px;">';
398
+						print '</a><br>';
399
+						if ($subdir == $selected_theme)
400
+						{
401
+							print '<input '.($edit?'':'disabled').' type="radio" class="themethumbs" style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>';
402
+						}
403
+						else
404
+						{
405
+							print '<input '.($edit?'':'disabled').' type="radio" class="themethumbs" style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir;
406
+						}
407 407
 						print '</div>';
408 408
 
409
-    					$i++;
410
-    				}
411
-    			}
412
-    		}
413
-    	}
414
-    }
409
+						$i++;
410
+					}
411
+				}
412
+			}
413
+		}
414
+	}
415 415
 
416
-    print '</div></td></tr></table>';
416
+	print '</div></td></tr></table>';
417 417
 
418
-    print '</td></tr>';
418
+	print '</td></tr>';
419 419
 
420
-    // TopMenuDisableImages
421
-    if ($foruserprofile)
422
-    {
423
-        /*
420
+	// TopMenuDisableImages
421
+	if ($foruserprofile)
422
+	{
423
+		/*
424 424
          print '<tr class="oddeven">';
425 425
          print '<td>'.$langs->trans("TopMenuDisableImages").'</td>';
426 426
          print '<td>'.($conf->global->THEME_TOPMENU_DISABLE_IMAGE?$conf->global->THEME_TOPMENU_DISABLE_IMAGE:$langs->trans("Default")).'</td>';
@@ -440,30 +440,30 @@  discard block
 block discarded – undo
440 440
          }
441 441
          if ($edit) print '<br>('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
442 442
          print '</td>';*/
443
-    }
444
-    else
445
-    {
446
-        $default=$langs->trans('No');
447
-        print '<tr class="oddeven">';
448
-        print '<td>'.$langs->trans("TopMenuDisableImages").'</td>';
449
-        print '<td colspan="'.($colspan-1).'">';
450
-        if ($edit)
451
-        {
452
-            print $form->selectyesno('THEME_TOPMENU_DISABLE_IMAGE', $conf->global->THEME_TOPMENU_DISABLE_IMAGE, 1);
453
-        }
454
-        else
455
-        {
456
-            print yn($conf->global->THEME_TOPMENU_DISABLE_IMAGE);
457
-        }
458
-        print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
459
-        print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
460
-        print '</td>';
461
-    }
443
+	}
444
+	else
445
+	{
446
+		$default=$langs->trans('No');
447
+		print '<tr class="oddeven">';
448
+		print '<td>'.$langs->trans("TopMenuDisableImages").'</td>';
449
+		print '<td colspan="'.($colspan-1).'">';
450
+		if ($edit)
451
+		{
452
+			print $form->selectyesno('THEME_TOPMENU_DISABLE_IMAGE', $conf->global->THEME_TOPMENU_DISABLE_IMAGE, 1);
453
+		}
454
+		else
455
+		{
456
+			print yn($conf->global->THEME_TOPMENU_DISABLE_IMAGE);
457
+		}
458
+		print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
459
+		print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
460
+		print '</td>';
461
+	}
462 462
 
463 463
 	// Background color THEME_ELDY_BACKBODY
464
-    if ($foruserprofile)
464
+	if ($foruserprofile)
465 465
 	{
466
-	    /*
466
+		/*
467 467
 	    print '<tr class="oddeven">';
468 468
 	    print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
469 469
         print '<td>'.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TOPMENU_BACK1:$langs->trans("Default")).'</td>';
@@ -486,29 +486,29 @@  discard block
 block discarded – undo
486 486
 	}
487 487
 	else
488 488
 	{
489
-	    print '<tr class="oddeven">';
490
-	    print '<td>'.$langs->trans("BackgroundColor").'</td>';
491
-	    print '<td colspan="'.($colspan-1).'">';
492
-	    //var_dump($conf->global->THEME_ELDY_BACKBODY);
493
-	    if ($edit)
494
-	    {
489
+		print '<tr class="oddeven">';
490
+		print '<td>'.$langs->trans("BackgroundColor").'</td>';
491
+		print '<td colspan="'.($colspan-1).'">';
492
+		//var_dump($conf->global->THEME_ELDY_BACKBODY);
493
+		if ($edit)
494
+		{
495 495
 			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKBODY,array()),''),'THEME_ELDY_BACKBODY','formcolor',1).' ';
496
-	    }
496
+		}
497 497
 	   	else
498 498
 	   	{
499 499
 	   		$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKBODY,array()),'');
500 500
 			if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
501 501
 			else print $langs->trans("Default");
502 502
 	   	}
503
-    	print ' &nbsp; ('.$langs->trans("Default").': <strong>ffffff</strong>) ';
504
-    	print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
505
-	    print '</td>';
503
+		print ' &nbsp; ('.$langs->trans("Default").': <strong>ffffff</strong>) ';
504
+		print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
505
+		print '</td>';
506 506
 	}
507 507
 
508 508
 	// TopMenuBackgroundColor
509
-    if ($foruserprofile)
509
+	if ($foruserprofile)
510 510
 	{
511
-	    /*
511
+		/*
512 512
 	    print '<tr class="oddeven">';
513 513
 	    print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
514 514
         print '<td>'.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TOPMENU_BACK1:$langs->trans("Default")).'</td>';
@@ -531,25 +531,25 @@  discard block
 block discarded – undo
531 531
 	}
532 532
 	else
533 533
 	{
534
-	    $default='5a6482';
535
-	    if ($conf->theme == 'md') $default='5a3278';
534
+		$default='5a6482';
535
+		if ($conf->theme == 'md') $default='5a3278';
536 536
 
537
-	    print '<tr class="oddeven">';
538
-	    print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
539
-	    print '<td colspan="'.($colspan-1).'">';
540
-	    if ($edit)
541
-	    {
537
+		print '<tr class="oddeven">';
538
+		print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
539
+		print '<td colspan="'.($colspan-1).'">';
540
+		if ($edit)
541
+		{
542 542
 			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1,array()),''),'THEME_ELDY_TOPMENU_BACK1','formcolor',1).' ';
543
-	    }
543
+		}
544 544
 	   	else
545 545
 	   	{
546 546
 	   		$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1,array()),'');
547 547
 			if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
548 548
 			else print $langs->trans("Default");
549 549
 	   	}
550
-    	print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
551
-    	print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
552
-	    print '</td>';
550
+		print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
551
+		print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
552
+		print '</td>';
553 553
 	}
554 554
 
555 555
 	// LeftMenuBackgroundColor
@@ -607,22 +607,22 @@  discard block
 block discarded – undo
607 607
 	}
608 608
 	else
609 609
 	{
610
-	    print '<tr class="oddeven">';
611
-	    print '<td>'.$langs->trans("BackgroundTableTitleColor").'</td>';
612
-	    print '<td colspan="'.($colspan-1).'">';
613
-	    if ($edit)
614
-	    {
610
+		print '<tr class="oddeven">';
611
+		print '<td>'.$langs->trans("BackgroundTableTitleColor").'</td>';
612
+		print '<td colspan="'.($colspan-1).'">';
613
+		if ($edit)
614
+		{
615 615
 			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKTITLE1,array()),''),'THEME_ELDY_BACKTITLE1','formcolor',1).' ';
616
-	    }
616
+		}
617 617
 	   	else
618 618
 	   	{
619 619
 	   		print $formother->showColor($conf->global->THEME_ELDY_BACKTITLE1, $langs->trans("Default"));
620 620
 	   	}
621
-    	print ' &nbsp; ('.$langs->trans("Default").': <strong>f0f0f0</strong>) ';  // $colorbacktitle1 in CSS
622
-    	print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
623
-	    print '</td>';
621
+		print ' &nbsp; ('.$langs->trans("Default").': <strong>f0f0f0</strong>) ';  // $colorbacktitle1 in CSS
622
+		print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
623
+		print '</td>';
624 624
 
625
-	    print '</tr>';
625
+		print '</tr>';
626 626
 	}
627 627
 
628 628
 	// BackgroundTableLineOddColor
@@ -632,25 +632,25 @@  discard block
 block discarded – undo
632 632
 	}
633 633
 	else
634 634
 	{
635
-	    $default='ffffff';
636
-	    if ($conf->theme == 'md') $default='ffffff';
635
+		$default='ffffff';
636
+		if ($conf->theme == 'md') $default='ffffff';
637 637
 
638
-	    print '<tr class="oddeven">';
639
-	    print '<td>'.$langs->trans("BackgroundTableLineOddColor").'</td>';
640
-	    print '<td colspan="'.($colspan-1).'">';
641
-	    if ($edit)
642
-	    {
643
-	        print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1,array()),''),'THEME_ELDY_LINEIMPAIR1','formcolor',1).' ';
644
-	    }
645
-	    else
646
-	    {
647
-	        $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1,array()),'');
648
-	        if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
649
-	        else print $langs->trans("Default");
650
-	    }
651
-	    print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
652
-	    print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
653
-	    print '</td>';
638
+		print '<tr class="oddeven">';
639
+		print '<td>'.$langs->trans("BackgroundTableLineOddColor").'</td>';
640
+		print '<td colspan="'.($colspan-1).'">';
641
+		if ($edit)
642
+		{
643
+			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1,array()),''),'THEME_ELDY_LINEIMPAIR1','formcolor',1).' ';
644
+		}
645
+		else
646
+		{
647
+			$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1,array()),'');
648
+			if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
649
+			else print $langs->trans("Default");
650
+		}
651
+		print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
652
+		print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
653
+		print '</td>';
654 654
 	}
655 655
 
656 656
 	// BackgroundTableLineEvenColor
@@ -660,25 +660,25 @@  discard block
 block discarded – undo
660 660
 	}
661 661
 	else
662 662
 	{
663
-	    $default='f8f8f8';
664
-	    if ($conf->theme == 'md') $default='f8f8f8';
663
+		$default='f8f8f8';
664
+		if ($conf->theme == 'md') $default='f8f8f8';
665 665
 
666
-	    print '<tr class="oddeven">';
667
-	    print '<td>'.$langs->trans("BackgroundTableLineEvenColor").'</td>';
668
-	    print '<td colspan="'.($colspan-1).'">';
669
-	    if ($edit)
670
-	    {
671
-	        print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1,array()),''),'THEME_ELDY_LINEPAIR1','formcolor',1).' ';
672
-	    }
673
-	    else
674
-	    {
675
-	        $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1,array()),'');
676
-	        if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
677
-	        else print $langs->trans("Default");
678
-	    }
679
-	    print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
680
-	    print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
681
-	    print '</td>';
666
+		print '<tr class="oddeven">';
667
+		print '<td>'.$langs->trans("BackgroundTableLineEvenColor").'</td>';
668
+		print '<td colspan="'.($colspan-1).'">';
669
+		if ($edit)
670
+		{
671
+			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1,array()),''),'THEME_ELDY_LINEPAIR1','formcolor',1).' ';
672
+		}
673
+		else
674
+		{
675
+			$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1,array()),'');
676
+			if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
677
+			else print $langs->trans("Default");
678
+		}
679
+		print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
680
+		print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
681
+		print '</td>';
682 682
 	}
683 683
 
684 684
 	// TextTitleColor
@@ -689,29 +689,29 @@  discard block
 block discarded – undo
689 689
 	}
690 690
 	else
691 691
 	{
692
-	    print '<tr class="oddeven">';
693
-	    print '<td>'.$langs->trans("TextTitleColor").'</td>';
694
-	    print '<td colspan="'.($colspan-1).'">';
695
-	    if ($edit)
696
-	    {
697
-	        print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTTITLENOTAB,array()),''),'THEME_ELDY_TEXTTITLENOTAB','formcolor',1).' ';
698
-	    }
699
-	    else
700
-	    {
701
-	        print $formother->showColor($conf->global->THEME_ELDY_TEXTTITLENOTAB, $langs->trans("Default"));
702
-	    }
703
-	    print ' &nbsp; ('.$langs->trans("Default").': <strong><span style="color: #3c3c14">3c3c14</span></strong>) ';
704
-    	print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
692
+		print '<tr class="oddeven">';
693
+		print '<td>'.$langs->trans("TextTitleColor").'</td>';
694
+		print '<td colspan="'.($colspan-1).'">';
695
+		if ($edit)
696
+		{
697
+			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTTITLENOTAB,array()),''),'THEME_ELDY_TEXTTITLENOTAB','formcolor',1).' ';
698
+		}
699
+		else
700
+		{
701
+			print $formother->showColor($conf->global->THEME_ELDY_TEXTTITLENOTAB, $langs->trans("Default"));
702
+		}
703
+		print ' &nbsp; ('.$langs->trans("Default").': <strong><span style="color: #3c3c14">3c3c14</span></strong>) ';
704
+		print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
705 705
 
706
-	    print '</td>';
706
+		print '</td>';
707 707
 
708
-	    print '</tr>';
708
+		print '</tr>';
709 709
 	}
710 710
 
711 711
 	// Text LinkColor
712 712
 	if ($foruserprofile)
713 713
 	{
714
-	    /*
714
+		/*
715 715
 	     print '<tr class="oddeven">';
716 716
 	     print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
717 717
 	     print '<td>'.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TEXTLINK:$langs->trans("Default")).'</td>';
@@ -734,33 +734,33 @@  discard block
 block discarded – undo
734 734
 	}
735 735
 	else
736 736
 	{
737
-	    print '<tr class="oddeven">';
738
-	    print '<td>'.$langs->trans("LinkColor").'</td>';
739
-	    print '<td colspan="'.($colspan-1).'">';
740
-	    if ($edit)
741
-	    {
742
-	        print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK,array()),''),'THEME_ELDY_TEXTLINK','formcolor',1).' ';
743
-	    }
744
-	    else
745
-	    {
746
-	        $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK,array()),'');
747
-	        if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
748
-	        else
749
-	        {
750
-	            //print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$defaultcolor.'" value="'.$langs->trans("Default").'">';
751
-	            //print '<span style="color: #000078">'.$langs->trans("Default").'</span>';
752
-	            print $langs->trans("Default");
753
-	        }
754
-	    }
755
-	    print ' &nbsp; ('.$langs->trans("Default").': <strong><span style="color: #000078">000078</span></strong>) ';
756
-    	print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
757
-	    print '</td>';
737
+		print '<tr class="oddeven">';
738
+		print '<td>'.$langs->trans("LinkColor").'</td>';
739
+		print '<td colspan="'.($colspan-1).'">';
740
+		if ($edit)
741
+		{
742
+			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK,array()),''),'THEME_ELDY_TEXTLINK','formcolor',1).' ';
743
+		}
744
+		else
745
+		{
746
+			$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK,array()),'');
747
+			if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
748
+			else
749
+			{
750
+				//print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$defaultcolor.'" value="'.$langs->trans("Default").'">';
751
+				//print '<span style="color: #000078">'.$langs->trans("Default").'</span>';
752
+				print $langs->trans("Default");
753
+			}
754
+		}
755
+		print ' &nbsp; ('.$langs->trans("Default").': <strong><span style="color: #000078">000078</span></strong>) ';
756
+		print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
757
+		print '</td>';
758 758
 	}
759 759
 
760 760
 	// Use Hover
761 761
 	if ($foruserprofile)
762 762
 	{
763
-	    /* Must first change option to choose color of highlight instead of yes or no.
763
+		/* Must first change option to choose color of highlight instead of yes or no.
764 764
 	     print '<tr class="oddeven">';
765 765
 	     print '<td>'.$langs->trans("HighlightLinesOnMouseHover").'</td>';
766 766
 	     print '<td><input '.$bc[$var].' name="check_THEME_ELDY_USE_HOVER" disabled="disabled" type="checkbox" '.($conf->global->THEME_ELDY_USE_HOVER?" checked":"").'></td>';
@@ -773,33 +773,33 @@  discard block
 block discarded – undo
773 773
 	}
774 774
 	else
775 775
 	{
776
-	    print '<tr class="oddeven">';
777
-	    print '<td>'.$langs->trans("HighlightLinesColor").'</td>';
778
-	    print '<td colspan="'.($colspan-1).'">';
779
-	    //print '<input '.$bc[$var].' name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled').' type="checkbox" '.($hoverdisabled?"":" checked").'>';
780
-	    //print ' &nbsp; ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
781
-	    if ($edit)
782
-	    {
783
-	        if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color='edf4fb';
784
-	        else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER,array()),'');
785
-	        print $formother->selectColor($color,'THEME_ELDY_USE_HOVER','formcolor',1).' ';
786
-	    }
787
-	    else
788
-	    {
789
-	        if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color='edf4fb';
790
-	        else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER,array()),'');
791
-	        if ($color)
792
-	        {
793
-	            if ($color != 'edf4fb') print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
794
-	            else print $langs->trans("Default");
795
-	        }
796
-	        else print $langs->trans("None");
797
-	    }
798
-	    print ' &nbsp; ('.$langs->trans("Default").': <strong>edf4fb</strong>) ';
799
-    	print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
800
-	    print '</td>';
801
-	    print '</tr>';
776
+		print '<tr class="oddeven">';
777
+		print '<td>'.$langs->trans("HighlightLinesColor").'</td>';
778
+		print '<td colspan="'.($colspan-1).'">';
779
+		//print '<input '.$bc[$var].' name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled').' type="checkbox" '.($hoverdisabled?"":" checked").'>';
780
+		//print ' &nbsp; ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
781
+		if ($edit)
782
+		{
783
+			if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color='edf4fb';
784
+			else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER,array()),'');
785
+			print $formother->selectColor($color,'THEME_ELDY_USE_HOVER','formcolor',1).' ';
786
+		}
787
+		else
788
+		{
789
+			if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color='edf4fb';
790
+			else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER,array()),'');
791
+			if ($color)
792
+			{
793
+				if ($color != 'edf4fb') print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
794
+				else print $langs->trans("Default");
795
+			}
796
+			else print $langs->trans("None");
797
+		}
798
+		print ' &nbsp; ('.$langs->trans("Default").': <strong>edf4fb</strong>) ';
799
+		print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
800
+		print '</td>';
801
+		print '</tr>';
802 802
 	}
803 803
 
804
-    print '</table>';
804
+	print '</table>';
805 805
 }
Please login to merge, or discard this patch.
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 
37 37
 	$langs->load("users");
38 38
 
39
-	$canreadperms=true;
40
-	if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
39
+	$canreadperms = true;
40
+	if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS))
41 41
 	{
42
-		$canreadperms=($user->admin || ($user->id != $object->id && $user->rights->user->user_advance->readperms) || ($user->id == $object->id && $user->rights->user->self_advance->readperms));
42
+		$canreadperms = ($user->admin || ($user->id != $object->id && $user->rights->user->user_advance->readperms) || ($user->id == $object->id && $user->rights->user->self_advance->readperms));
43 43
 	}
44 44
 
45 45
 	$h = 0;
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
     $head[$h][2] = 'user';
51 51
     $h++;
52 52
 
53
-	if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE))
54
-		&& (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin)))
53
+	if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_SYNCHRO_ACTIVE))
54
+		&& (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin)))
55 55
 	{
56 56
 		$langs->load("ldap");
57 57
 		$head[$h][0] = DOL_URL_ROOT.'/user/ldap.php?id='.$object->id;
@@ -68,28 +68,28 @@  discard block
 block discarded – undo
68 68
 	if ($canreadperms)
69 69
 	{
70 70
 		$head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$object->id;
71
-		$head[$h][1] = $langs->trans("UserRights"). ' <span class="badge">'.($object->nb_rights).'</span>';
71
+		$head[$h][1] = $langs->trans("UserRights").' <span class="badge">'.($object->nb_rights).'</span>';
72 72
 		$head[$h][2] = 'rights';
73 73
 		$h++;
74 74
 	}
75 75
 
76
-    if (! empty($conf->agenda->enabled))
76
+    if (!empty($conf->agenda->enabled))
77 77
     {
78
-        if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
79
-        $MAXAGENDA=$conf->global->AGENDA_EXT_NB;
78
+        if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5;
79
+        $MAXAGENDA = $conf->global->AGENDA_EXT_NB;
80 80
 
81
-        $i=1;
81
+        $i = 1;
82 82
         $nbagenda = 0;
83 83
         while ($i <= $MAXAGENDA)
84 84
         {
85
-            $key=$i;
86
-            $name='AGENDA_EXT_NAME_'.$object->id.'_'.$key;
87
-            $src='AGENDA_EXT_SRC_'.$object->id.'_'.$key;
88
-            $offsettz='AGENDA_EXT_OFFSETTZ_'.$object->id.'_'.$key;
89
-            $color='AGENDA_EXT_COLOR_'.$object->id.'_'.$key;
85
+            $key = $i;
86
+            $name = 'AGENDA_EXT_NAME_'.$object->id.'_'.$key;
87
+            $src = 'AGENDA_EXT_SRC_'.$object->id.'_'.$key;
88
+            $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$object->id.'_'.$key;
89
+            $color = 'AGENDA_EXT_COLOR_'.$object->id.'_'.$key;
90 90
             $i++;
91 91
 
92
-            if (! empty($object->conf->$name)) $nbagenda++;
92
+            if (!empty($object->conf->$name)) $nbagenda++;
93 93
         }
94 94
 
95 95
 	    $head[$h][0] = DOL_URL_ROOT.'/user/agenda_extsites.php?id='.$object->id;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	    $h++;
99 99
     }
100 100
 
101
-    if (! empty($conf->clicktodial->enabled))
101
+    if (!empty($conf->clicktodial->enabled))
102 102
     {
103 103
         $head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$object->id;
104 104
         $head[$h][1] = $langs->trans("ClickToDial");
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
     }
108 108
 
109 109
     // Notifications
110
-    if ($user->societe_id == 0 && ! empty($conf->notification->enabled))
110
+    if ($user->societe_id == 0 && !empty($conf->notification->enabled))
111 111
     {
112 112
         $nbNote = 0;
113 113
         $sql = "SELECT COUNT(n.rowid) as nb";
114
-        $sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n";
115
-        $sql.= " WHERE fk_user = ".$object->id;
116
-        $resql=$db->query($sql);
114
+        $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n";
115
+        $sql .= " WHERE fk_user = ".$object->id;
116
+        $resql = $db->query($sql);
117 117
         if ($resql)
118 118
         {
119 119
             $num = $db->num_rows($resql);
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
             while ($i < $num)
122 122
             {
123 123
                 $obj = $db->fetch_object($resql);
124
-                $nbNote=$obj->nb;
124
+                $nbNote = $obj->nb;
125 125
                 $i++;
126 126
             }
127 127
         }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
         $head[$h][0] = DOL_URL_ROOT.'/user/notify/card.php?id='.$object->id;
133 133
         $head[$h][1] = $langs->trans("Notifications");
134
-        if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
134
+        if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>';
135 135
         $head[$h][2] = 'notify';
136 136
         $h++;
137 137
     }
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
     // Entries must be declared in modules descriptor with line
141 141
     // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
142 142
     // $this->tabs = array('entity:-tabname);   												to remove a tab
143
-    complete_head_from_modules($conf,$langs,$object,$head,$h,'user');
143
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'user');
144 144
 
145
-    if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
146
-       || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read)))
145
+    if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read))
146
+       || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read)))
147 147
     {
148 148
 		// Bank
149 149
     	$head[$h][0] = DOL_URL_ROOT.'/user/bank.php?id='.$object->id;
@@ -157,22 +157,22 @@  discard block
 block discarded – undo
157 157
     {
158 158
 		// Notes
159 159
         $nbNote = 0;
160
-        if(!empty($object->note)) $nbNote++;
160
+        if (!empty($object->note)) $nbNote++;
161 161
         $head[$h][0] = DOL_URL_ROOT.'/user/note.php?id='.$object->id;
162 162
         $head[$h][1] = $langs->trans("Note");
163
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
163
+		if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>';
164 164
         $head[$h][2] = 'note';
165 165
         $h++;
166 166
 
167 167
         // Attached files
168 168
         require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
169 169
         require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
170
-        $upload_dir = $conf->user->dir_output . "/" . $object->id;
171
-        $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
172
-        $nbLinks=Link::count($db, $object->element, $object->id);
170
+        $upload_dir = $conf->user->dir_output."/".$object->id;
171
+        $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
172
+        $nbLinks = Link::count($db, $object->element, $object->id);
173 173
         $head[$h][0] = DOL_URL_ROOT.'/user/document.php?userid='.$object->id;
174 174
         $head[$h][1] = $langs->trans("Documents");
175
-        if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
175
+        if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>';
176 176
         $head[$h][2] = 'document';
177 177
         $h++;
178 178
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
     	$h++;
183 183
     }
184 184
 
185
-    complete_head_from_modules($conf,$langs,$object,$head,$h,'user','remove');
185
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'user', 'remove');
186 186
 
187 187
 	return $head;
188 188
 }
@@ -197,10 +197,10 @@  discard block
 block discarded – undo
197 197
 {
198 198
 	global $langs, $conf, $user;
199 199
 
200
-	$canreadperms=true;
201
-	if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
200
+	$canreadperms = true;
201
+	if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS))
202 202
 	{
203
-		$canreadperms=($user->admin || $user->rights->user->group_advance->readperms);
203
+		$canreadperms = ($user->admin || $user->rights->user->group_advance->readperms);
204 204
 	}
205 205
 
206 206
 	$h = 0;
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
     $head[$h][2] = 'group';
212 212
     $h++;
213 213
 
214
-	if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE))
215
-		&& (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin)))
214
+	if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_SYNCHRO_ACTIVE))
215
+		&& (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin)))
216 216
 	{
217 217
 		$langs->load("ldap");
218 218
 		$head[$h][0] = DOL_URL_ROOT.'/user/group/ldap.php?id='.$object->id;
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
     // Entries must be declared in modules descriptor with line
234 234
     // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
235 235
     // $this->tabs = array('entity:-tabname);   												to remove a tab
236
-    complete_head_from_modules($conf,$langs,$object,$head,$h,'group');
236
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'group');
237 237
 
238
-    complete_head_from_modules($conf,$langs,$object,$head,$h,'group','remove');
238
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'group', 'remove');
239 239
 
240 240
     return $head;
241 241
 }
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	global $langs, $conf, $user;
251 251
 
252 252
 	$langs->load("users");
253
-	$h=0;
253
+	$h = 0;
254 254
 
255 255
     $head[$h][0] = DOL_URL_ROOT.'/admin/user.php';
256 256
     $head[$h][1] = $langs->trans("Parameters");
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
 	// Entries must be declared in modules descriptor with line
277 277
 	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
278 278
 	// $this->tabs = array('entity:-tabname);   												to remove a tab
279
-	complete_head_from_modules($conf,$langs,null,$head,$h,'useradmin');
279
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'useradmin');
280 280
 
281
-	complete_head_from_modules($conf,$langs,null,$head,$h,'useradmin','remove');
281
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'useradmin', 'remove');
282 282
 
283 283
 	return $head;
284 284
 }
@@ -291,38 +291,38 @@  discard block
 block discarded – undo
291 291
  * 	@param	boolean		$foruserprofile		Show for user profile view
292 292
  * 	@return	void
293 293
  */
294
-function show_theme($fuser,$edit=0,$foruserprofile=false)
294
+function show_theme($fuser, $edit = 0, $foruserprofile = false)
295 295
 {
296
-    global $conf,$langs,$db,$form;
296
+    global $conf, $langs, $db, $form;
297 297
     global $bc;
298 298
 
299
-	require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
299
+	require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
300 300
 
301 301
     $formother = new FormOther($db);
302 302
 
303
-    $dirthemes=array('/theme');
304
-    if (! empty($conf->modules_parts['theme']))		// Using this feature slow down application
303
+    $dirthemes = array('/theme');
304
+    if (!empty($conf->modules_parts['theme']))		// Using this feature slow down application
305 305
     {
306
-    	foreach($conf->modules_parts['theme'] as $reldir)
306
+    	foreach ($conf->modules_parts['theme'] as $reldir)
307 307
     	{
308
-	    	$dirthemes=array_merge($dirthemes,(array) ($reldir.'theme'));
308
+	    	$dirthemes = array_merge($dirthemes, (array) ($reldir.'theme'));
309 309
     	}
310 310
     }
311
-    $dirthemes=array_unique($dirthemes);
311
+    $dirthemes = array_unique($dirthemes);
312 312
 	// Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme')
313 313
 
314
-    $selected_theme='';
315
-    if (empty($foruserprofile)) $selected_theme=$conf->global->MAIN_THEME;
316
-    else $selected_theme=((is_object($fuser) && ! empty($fuser->conf->MAIN_THEME))?$fuser->conf->MAIN_THEME:'');
314
+    $selected_theme = '';
315
+    if (empty($foruserprofile)) $selected_theme = $conf->global->MAIN_THEME;
316
+    else $selected_theme = ((is_object($fuser) && !empty($fuser->conf->MAIN_THEME)) ? $fuser->conf->MAIN_THEME : '');
317 317
 
318
-	$hoverdisabled='';
319
-    if (empty($foruserprofile)) $hoverdisabled=(isset($conf->global->THEME_ELDY_USE_HOVER) && $conf->global->THEME_ELDY_USE_HOVER == '0');
320
-    else $hoverdisabled=(is_object($fuser)?(empty($fuser->conf->THEME_ELDY_USE_HOVER) || $fuser->conf->THEME_ELDY_USE_HOVER == '0'):'');
318
+	$hoverdisabled = '';
319
+    if (empty($foruserprofile)) $hoverdisabled = (isset($conf->global->THEME_ELDY_USE_HOVER) && $conf->global->THEME_ELDY_USE_HOVER == '0');
320
+    else $hoverdisabled = (is_object($fuser) ? (empty($fuser->conf->THEME_ELDY_USE_HOVER) || $fuser->conf->THEME_ELDY_USE_HOVER == '0') : '');
321 321
 
322
-    $colspan=2;
323
-    if ($foruserprofile) $colspan=4;
322
+    $colspan = 2;
323
+    if ($foruserprofile) $colspan = 4;
324 324
 
325
-    $thumbsbyrow=6;
325
+    $thumbsbyrow = 6;
326 326
     print '<table class="noborder" width="100%">';
327 327
 
328 328
     // Title
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 	    print '<tr>';
336 336
 	    print '<td>'.$langs->trans("DefaultSkin").'</td>';
337 337
 	    print '<td>'.$conf->global->MAIN_THEME.'</td>';
338
-	    print '<td align="left" class="nowrap" width="20%"><input id="check_MAIN_THEME" name="check_MAIN_THEME"'.($edit?'':' disabled').' type="checkbox" '.($selected_theme?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>';
338
+	    print '<td align="left" class="nowrap" width="20%"><input id="check_MAIN_THEME" name="check_MAIN_THEME"'.($edit ? '' : ' disabled').' type="checkbox" '.($selected_theme ? " checked" : "").'> '.$langs->trans("UsePersonalValue").'</td>';
339 339
 	    print '<td>&nbsp;</td>';
340 340
 	    print '</tr>';
341 341
     }
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
     {
344 344
     	print '<tr class="liste_titre"><th class="titlefield">'.$langs->trans("DefaultSkin").'</th>';
345 345
     	print '<th align="right">';
346
-    	$url='https://www.dolistore.com/lang-en/4-skins';
347
-    	if (preg_match('/fr/i',$langs->defaultlang)) $url='https://www.dolistore.com/fr/4-themes';
346
+    	$url = 'https://www.dolistore.com/lang-en/4-skins';
347
+    	if (preg_match('/fr/i', $langs->defaultlang)) $url = 'https://www.dolistore.com/fr/4-themes';
348 348
     	//if (preg_match('/es/i',$langs->defaultlang)) $url='http://www.dolistore.com/lang-es/4-themes';
349 349
     	print '<a href="'.$url.'" target="_blank">';
350 350
     	print $langs->trans('DownloadMoreSkins');
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
     	print '<tr>';
355 355
     	print '<td>'.$langs->trans("ThemeDir").'</td>';
356 356
     	print '<td>';
357
-    	foreach($dirthemes as $dirtheme)
357
+    	foreach ($dirthemes as $dirtheme)
358 358
     	{
359 359
     		echo '"'.$dirtheme.'" ';
360 360
     	}
@@ -366,43 +366,43 @@  discard block
 block discarded – undo
366 366
 
367 367
     print '<table class="nobordernopadding" width="100%"><tr><td><div align="center">';
368 368
 
369
-    $i=0;
370
-    foreach($dirthemes as $dir)
369
+    $i = 0;
370
+    foreach ($dirthemes as $dir)
371 371
     {
372 372
     	//print $dirroot.$dir;exit;
373
-    	$dirtheme=dol_buildpath($dir,0);	// This include loop on $conf->file->dol_document_root
374
-    	$urltheme=dol_buildpath($dir,1);
373
+    	$dirtheme = dol_buildpath($dir, 0); // This include loop on $conf->file->dol_document_root
374
+    	$urltheme = dol_buildpath($dir, 1);
375 375
 
376 376
     	if (is_dir($dirtheme))
377 377
     	{
378
-    		$handle=opendir($dirtheme);
378
+    		$handle = opendir($dirtheme);
379 379
     		if (is_resource($handle))
380 380
     		{
381
-    			while (($subdir = readdir($handle))!==false)
381
+    			while (($subdir = readdir($handle)) !== false)
382 382
     			{
383 383
     				if (is_dir($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.'
384
-    						&& substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i',$subdir))
384
+    						&& substr($subdir, 0, 3) <> 'CVS' && !preg_match('/common|phones/i', $subdir))
385 385
     				{
386 386
     					// Disable not stable themes (dir ends with _exp or _dev)
387
-    					if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i',$subdir)) continue;
388
-    					if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i',$subdir)) continue;
387
+    					if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i', $subdir)) continue;
388
+    					if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i', $subdir)) continue;
389 389
 
390 390
     					print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
391
-    					$file=$dirtheme."/".$subdir."/thumb.png";
392
-    					$url=$urltheme."/".$subdir."/thumb.png";
393
-    					if (! file_exists($file)) $url=DOL_URL_ROOT.'/public/theme/common/nophoto.png';
394
-    					print '<a href="'.$_SERVER["PHP_SELF"].($edit?'?action=edit&theme=':'?theme=').$subdir.(GETPOST('optioncss','alpha',1)?'&optioncss='.GETPOST('optioncss','alpha',1):'').($fuser?'&id='.$fuser->id:'').'" style="font-weight: normal;" alt="'.$langs->trans("Preview").'">';
395
-    					if ($subdir == $conf->global->MAIN_THEME) $title=$langs->trans("ThemeCurrentlyActive");
396
-    					else $title=$langs->trans("ShowPreview");
391
+    					$file = $dirtheme."/".$subdir."/thumb.png";
392
+    					$url = $urltheme."/".$subdir."/thumb.png";
393
+    					if (!file_exists($file)) $url = DOL_URL_ROOT.'/public/theme/common/nophoto.png';
394
+    					print '<a href="'.$_SERVER["PHP_SELF"].($edit ? '?action=edit&theme=' : '?theme=').$subdir.(GETPOST('optioncss', 'alpha', 1) ? '&optioncss='.GETPOST('optioncss', 'alpha', 1) : '').($fuser ? '&id='.$fuser->id : '').'" style="font-weight: normal;" alt="'.$langs->trans("Preview").'">';
395
+    					if ($subdir == $conf->global->MAIN_THEME) $title = $langs->trans("ThemeCurrentlyActive");
396
+    					else $title = $langs->trans("ShowPreview");
397 397
     					print '<img src="'.$url.'" border="0" width="80" height="60" alt="'.$title.'" title="'.$title.'" style="margin-bottom: 5px;">';
398 398
     					print '</a><br>';
399 399
     					if ($subdir == $selected_theme)
400 400
     					{
401
-    						print '<input '.($edit?'':'disabled').' type="radio" class="themethumbs" style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>';
401
+    						print '<input '.($edit ? '' : 'disabled').' type="radio" class="themethumbs" style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>';
402 402
     					}
403 403
     					else
404 404
     					{
405
-    						print '<input '.($edit?'':'disabled').' type="radio" class="themethumbs" style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir;
405
+    						print '<input '.($edit ? '' : 'disabled').' type="radio" class="themethumbs" style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir;
406 406
     					}
407 407
 						print '</div>';
408 408
 
@@ -443,10 +443,10 @@  discard block
 block discarded – undo
443 443
     }
444 444
     else
445 445
     {
446
-        $default=$langs->trans('No');
446
+        $default = $langs->trans('No');
447 447
         print '<tr class="oddeven">';
448 448
         print '<td>'.$langs->trans("TopMenuDisableImages").'</td>';
449
-        print '<td colspan="'.($colspan-1).'">';
449
+        print '<td colspan="'.($colspan - 1).'">';
450 450
         if ($edit)
451 451
         {
452 452
             print $form->selectyesno('THEME_TOPMENU_DISABLE_IMAGE', $conf->global->THEME_TOPMENU_DISABLE_IMAGE, 1);
@@ -488,15 +488,15 @@  discard block
 block discarded – undo
488 488
 	{
489 489
 	    print '<tr class="oddeven">';
490 490
 	    print '<td>'.$langs->trans("BackgroundColor").'</td>';
491
-	    print '<td colspan="'.($colspan-1).'">';
491
+	    print '<td colspan="'.($colspan - 1).'">';
492 492
 	    //var_dump($conf->global->THEME_ELDY_BACKBODY);
493 493
 	    if ($edit)
494 494
 	    {
495
-			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKBODY,array()),''),'THEME_ELDY_BACKBODY','formcolor',1).' ';
495
+			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKBODY, array()), ''), 'THEME_ELDY_BACKBODY', 'formcolor', 1).' ';
496 496
 	    }
497 497
 	   	else
498 498
 	   	{
499
-	   		$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKBODY,array()),'');
499
+	   		$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKBODY, array()), '');
500 500
 			if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
501 501
 			else print $langs->trans("Default");
502 502
 	   	}
@@ -531,19 +531,19 @@  discard block
 block discarded – undo
531 531
 	}
532 532
 	else
533 533
 	{
534
-	    $default='5a6482';
535
-	    if ($conf->theme == 'md') $default='5a3278';
534
+	    $default = '5a6482';
535
+	    if ($conf->theme == 'md') $default = '5a3278';
536 536
 
537 537
 	    print '<tr class="oddeven">';
538 538
 	    print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
539
-	    print '<td colspan="'.($colspan-1).'">';
539
+	    print '<td colspan="'.($colspan - 1).'">';
540 540
 	    if ($edit)
541 541
 	    {
542
-			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1,array()),''),'THEME_ELDY_TOPMENU_BACK1','formcolor',1).' ';
542
+			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1, array()), ''), 'THEME_ELDY_TOPMENU_BACK1', 'formcolor', 1).' ';
543 543
 	    }
544 544
 	   	else
545 545
 	   	{
546
-	   		$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1,array()),'');
546
+	   		$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1, array()), '');
547 547
 			if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
548 548
 			else print $langs->trans("Default");
549 549
 	   	}
@@ -578,19 +578,19 @@  discard block
 block discarded – undo
578 578
 	}
579 579
 	else
580 580
 	{
581
-		$default='ffffff';
582
-		if ($conf->theme == 'md') $default='ffffff';
581
+		$default = 'ffffff';
582
+		if ($conf->theme == 'md') $default = 'ffffff';
583 583
 
584 584
 		print '<tr class="oddeven">';
585 585
 		print '<td>'.$langs->trans("LeftMenuBackgroundColor").'</td>';
586
-		print '<td colspan="'.($colspan-1).'">';
586
+		print '<td colspan="'.($colspan - 1).'">';
587 587
 		if ($edit)
588 588
 		{
589
-			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1,array()),''),'THEME_ELDY_VERMENU_BACK1','formcolor',1).' ';
589
+			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1, array()), ''), 'THEME_ELDY_VERMENU_BACK1', 'formcolor', 1).' ';
590 590
 		}
591 591
 		else
592 592
 		{
593
-			$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1,array()),'');
593
+			$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1, array()), '');
594 594
 			if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
595 595
 			else print $langs->trans("Default");
596 596
 		}
@@ -609,16 +609,16 @@  discard block
 block discarded – undo
609 609
 	{
610 610
 	    print '<tr class="oddeven">';
611 611
 	    print '<td>'.$langs->trans("BackgroundTableTitleColor").'</td>';
612
-	    print '<td colspan="'.($colspan-1).'">';
612
+	    print '<td colspan="'.($colspan - 1).'">';
613 613
 	    if ($edit)
614 614
 	    {
615
-			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKTITLE1,array()),''),'THEME_ELDY_BACKTITLE1','formcolor',1).' ';
615
+			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKTITLE1, array()), ''), 'THEME_ELDY_BACKTITLE1', 'formcolor', 1).' ';
616 616
 	    }
617 617
 	   	else
618 618
 	   	{
619 619
 	   		print $formother->showColor($conf->global->THEME_ELDY_BACKTITLE1, $langs->trans("Default"));
620 620
 	   	}
621
-    	print ' &nbsp; ('.$langs->trans("Default").': <strong>f0f0f0</strong>) ';  // $colorbacktitle1 in CSS
621
+    	print ' &nbsp; ('.$langs->trans("Default").': <strong>f0f0f0</strong>) '; // $colorbacktitle1 in CSS
622 622
     	print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
623 623
 	    print '</td>';
624 624
 
@@ -632,19 +632,19 @@  discard block
 block discarded – undo
632 632
 	}
633 633
 	else
634 634
 	{
635
-	    $default='ffffff';
636
-	    if ($conf->theme == 'md') $default='ffffff';
635
+	    $default = 'ffffff';
636
+	    if ($conf->theme == 'md') $default = 'ffffff';
637 637
 
638 638
 	    print '<tr class="oddeven">';
639 639
 	    print '<td>'.$langs->trans("BackgroundTableLineOddColor").'</td>';
640
-	    print '<td colspan="'.($colspan-1).'">';
640
+	    print '<td colspan="'.($colspan - 1).'">';
641 641
 	    if ($edit)
642 642
 	    {
643
-	        print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1,array()),''),'THEME_ELDY_LINEIMPAIR1','formcolor',1).' ';
643
+	        print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1, array()), ''), 'THEME_ELDY_LINEIMPAIR1', 'formcolor', 1).' ';
644 644
 	    }
645 645
 	    else
646 646
 	    {
647
-	        $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1,array()),'');
647
+	        $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1, array()), '');
648 648
 	        if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
649 649
 	        else print $langs->trans("Default");
650 650
 	    }
@@ -660,19 +660,19 @@  discard block
 block discarded – undo
660 660
 	}
661 661
 	else
662 662
 	{
663
-	    $default='f8f8f8';
664
-	    if ($conf->theme == 'md') $default='f8f8f8';
663
+	    $default = 'f8f8f8';
664
+	    if ($conf->theme == 'md') $default = 'f8f8f8';
665 665
 
666 666
 	    print '<tr class="oddeven">';
667 667
 	    print '<td>'.$langs->trans("BackgroundTableLineEvenColor").'</td>';
668
-	    print '<td colspan="'.($colspan-1).'">';
668
+	    print '<td colspan="'.($colspan - 1).'">';
669 669
 	    if ($edit)
670 670
 	    {
671
-	        print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1,array()),''),'THEME_ELDY_LINEPAIR1','formcolor',1).' ';
671
+	        print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1, array()), ''), 'THEME_ELDY_LINEPAIR1', 'formcolor', 1).' ';
672 672
 	    }
673 673
 	    else
674 674
 	    {
675
-	        $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1,array()),'');
675
+	        $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1, array()), '');
676 676
 	        if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
677 677
 	        else print $langs->trans("Default");
678 678
 	    }
@@ -691,10 +691,10 @@  discard block
 block discarded – undo
691 691
 	{
692 692
 	    print '<tr class="oddeven">';
693 693
 	    print '<td>'.$langs->trans("TextTitleColor").'</td>';
694
-	    print '<td colspan="'.($colspan-1).'">';
694
+	    print '<td colspan="'.($colspan - 1).'">';
695 695
 	    if ($edit)
696 696
 	    {
697
-	        print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTTITLENOTAB,array()),''),'THEME_ELDY_TEXTTITLENOTAB','formcolor',1).' ';
697
+	        print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTTITLENOTAB, array()), ''), 'THEME_ELDY_TEXTTITLENOTAB', 'formcolor', 1).' ';
698 698
 	    }
699 699
 	    else
700 700
 	    {
@@ -736,14 +736,14 @@  discard block
 block discarded – undo
736 736
 	{
737 737
 	    print '<tr class="oddeven">';
738 738
 	    print '<td>'.$langs->trans("LinkColor").'</td>';
739
-	    print '<td colspan="'.($colspan-1).'">';
739
+	    print '<td colspan="'.($colspan - 1).'">';
740 740
 	    if ($edit)
741 741
 	    {
742
-	        print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK,array()),''),'THEME_ELDY_TEXTLINK','formcolor',1).' ';
742
+	        print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK, array()), ''), 'THEME_ELDY_TEXTLINK', 'formcolor', 1).' ';
743 743
 	    }
744 744
 	    else
745 745
 	    {
746
-	        $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK,array()),'');
746
+	        $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK, array()), '');
747 747
 	        if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
748 748
 	        else
749 749
 	        {
@@ -775,19 +775,19 @@  discard block
 block discarded – undo
775 775
 	{
776 776
 	    print '<tr class="oddeven">';
777 777
 	    print '<td>'.$langs->trans("HighlightLinesColor").'</td>';
778
-	    print '<td colspan="'.($colspan-1).'">';
778
+	    print '<td colspan="'.($colspan - 1).'">';
779 779
 	    //print '<input '.$bc[$var].' name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled').' type="checkbox" '.($hoverdisabled?"":" checked").'>';
780 780
 	    //print ' &nbsp; ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
781 781
 	    if ($edit)
782 782
 	    {
783
-	        if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color='edf4fb';
784
-	        else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER,array()),'');
785
-	        print $formother->selectColor($color,'THEME_ELDY_USE_HOVER','formcolor',1).' ';
783
+	        if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color = 'edf4fb';
784
+	        else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER, array()), '');
785
+	        print $formother->selectColor($color, 'THEME_ELDY_USE_HOVER', 'formcolor', 1).' ';
786 786
 	    }
787 787
 	    else
788 788
 	    {
789
-	        if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color='edf4fb';
790
-	        else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER,array()),'');
789
+	        if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color = 'edf4fb';
790
+	        else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER, array()), '');
791 791
 	        if ($color)
792 792
 	        {
793 793
 	            if ($color != 'edf4fb') print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
Please login to merge, or discard this patch.
Braces   +131 added lines, -87 removed lines patch added patch discarded remove patch
@@ -75,7 +75,9 @@  discard block
 block discarded – undo
75 75
 
76 76
     if (! empty($conf->agenda->enabled))
77 77
     {
78
-        if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
78
+        if (empty($conf->global->AGENDA_EXT_NB)) {
79
+        	$conf->global->AGENDA_EXT_NB=5;
80
+        }
79 81
         $MAXAGENDA=$conf->global->AGENDA_EXT_NB;
80 82
 
81 83
         $i=1;
@@ -89,7 +91,9 @@  discard block
 block discarded – undo
89 91
             $color='AGENDA_EXT_COLOR_'.$object->id.'_'.$key;
90 92
             $i++;
91 93
 
92
-            if (! empty($object->conf->$name)) $nbagenda++;
94
+            if (! empty($object->conf->$name)) {
95
+            	$nbagenda++;
96
+            }
93 97
         }
94 98
 
95 99
 	    $head[$h][0] = DOL_URL_ROOT.'/user/agenda_extsites.php?id='.$object->id;
@@ -124,14 +128,15 @@  discard block
 block discarded – undo
124 128
                 $nbNote=$obj->nb;
125 129
                 $i++;
126 130
             }
127
-        }
128
-        else {
131
+        } else {
129 132
             dol_print_error($db);
130 133
         }
131 134
 
132 135
         $head[$h][0] = DOL_URL_ROOT.'/user/notify/card.php?id='.$object->id;
133 136
         $head[$h][1] = $langs->trans("Notifications");
134
-        if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
137
+        if ($nbNote > 0) {
138
+        	$head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
139
+        }
135 140
         $head[$h][2] = 'notify';
136 141
         $h++;
137 142
     }
@@ -157,10 +162,14 @@  discard block
 block discarded – undo
157 162
     {
158 163
 		// Notes
159 164
         $nbNote = 0;
160
-        if(!empty($object->note)) $nbNote++;
165
+        if(!empty($object->note)) {
166
+        	$nbNote++;
167
+        }
161 168
         $head[$h][0] = DOL_URL_ROOT.'/user/note.php?id='.$object->id;
162 169
         $head[$h][1] = $langs->trans("Note");
163
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
170
+		if ($nbNote > 0) {
171
+			$head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
172
+		}
164 173
         $head[$h][2] = 'note';
165 174
         $h++;
166 175
 
@@ -172,7 +181,9 @@  discard block
 block discarded – undo
172 181
         $nbLinks=Link::count($db, $object->element, $object->id);
173 182
         $head[$h][0] = DOL_URL_ROOT.'/user/document.php?userid='.$object->id;
174 183
         $head[$h][1] = $langs->trans("Documents");
175
-        if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
184
+        if (($nbFiles+$nbLinks) > 0) {
185
+        	$head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
186
+        }
176 187
         $head[$h][2] = 'document';
177 188
         $h++;
178 189
 
@@ -301,26 +312,36 @@  discard block
 block discarded – undo
301 312
     $formother = new FormOther($db);
302 313
 
303 314
     $dirthemes=array('/theme');
304
-    if (! empty($conf->modules_parts['theme']))		// Using this feature slow down application
315
+    if (! empty($conf->modules_parts['theme'])) {
316
+    	// Using this feature slow down application
305 317
     {
306 318
     	foreach($conf->modules_parts['theme'] as $reldir)
307 319
     	{
308 320
 	    	$dirthemes=array_merge($dirthemes,(array) ($reldir.'theme'));
321
+    }
309 322
     	}
310 323
     }
311 324
     $dirthemes=array_unique($dirthemes);
312 325
 	// Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme')
313 326
 
314 327
     $selected_theme='';
315
-    if (empty($foruserprofile)) $selected_theme=$conf->global->MAIN_THEME;
316
-    else $selected_theme=((is_object($fuser) && ! empty($fuser->conf->MAIN_THEME))?$fuser->conf->MAIN_THEME:'');
328
+    if (empty($foruserprofile)) {
329
+    	$selected_theme=$conf->global->MAIN_THEME;
330
+    } else {
331
+    	$selected_theme=((is_object($fuser) && ! empty($fuser->conf->MAIN_THEME))?$fuser->conf->MAIN_THEME:'');
332
+    }
317 333
 
318 334
 	$hoverdisabled='';
319
-    if (empty($foruserprofile)) $hoverdisabled=(isset($conf->global->THEME_ELDY_USE_HOVER) && $conf->global->THEME_ELDY_USE_HOVER == '0');
320
-    else $hoverdisabled=(is_object($fuser)?(empty($fuser->conf->THEME_ELDY_USE_HOVER) || $fuser->conf->THEME_ELDY_USE_HOVER == '0'):'');
335
+    if (empty($foruserprofile)) {
336
+    	$hoverdisabled=(isset($conf->global->THEME_ELDY_USE_HOVER) && $conf->global->THEME_ELDY_USE_HOVER == '0');
337
+    } else {
338
+    	$hoverdisabled=(is_object($fuser)?(empty($fuser->conf->THEME_ELDY_USE_HOVER) || $fuser->conf->THEME_ELDY_USE_HOVER == '0'):'');
339
+    }
321 340
 
322 341
     $colspan=2;
323
-    if ($foruserprofile) $colspan=4;
342
+    if ($foruserprofile) {
343
+    	$colspan=4;
344
+    }
324 345
 
325 346
     $thumbsbyrow=6;
326 347
     print '<table class="noborder" width="100%">';
@@ -338,13 +359,14 @@  discard block
 block discarded – undo
338 359
 	    print '<td align="left" class="nowrap" width="20%"><input id="check_MAIN_THEME" name="check_MAIN_THEME"'.($edit?'':' disabled').' type="checkbox" '.($selected_theme?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>';
339 360
 	    print '<td>&nbsp;</td>';
340 361
 	    print '</tr>';
341
-    }
342
-    else
362
+    } else
343 363
     {
344 364
     	print '<tr class="liste_titre"><th class="titlefield">'.$langs->trans("DefaultSkin").'</th>';
345 365
     	print '<th align="right">';
346 366
     	$url='https://www.dolistore.com/lang-en/4-skins';
347
-    	if (preg_match('/fr/i',$langs->defaultlang)) $url='https://www.dolistore.com/fr/4-themes';
367
+    	if (preg_match('/fr/i',$langs->defaultlang)) {
368
+    		$url='https://www.dolistore.com/fr/4-themes';
369
+    	}
348 370
     	//if (preg_match('/es/i',$langs->defaultlang)) $url='http://www.dolistore.com/lang-es/4-themes';
349 371
     	print '<a href="'.$url.'" target="_blank">';
350 372
     	print $langs->trans('DownloadMoreSkins');
@@ -384,23 +406,31 @@  discard block
 block discarded – undo
384 406
     						&& substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i',$subdir))
385 407
     				{
386 408
     					// Disable not stable themes (dir ends with _exp or _dev)
387
-    					if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i',$subdir)) continue;
388
-    					if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i',$subdir)) continue;
409
+    					if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i',$subdir)) {
410
+    						continue;
411
+    					}
412
+    					if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i',$subdir)) {
413
+    						continue;
414
+    					}
389 415
 
390 416
     					print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
391 417
     					$file=$dirtheme."/".$subdir."/thumb.png";
392 418
     					$url=$urltheme."/".$subdir."/thumb.png";
393
-    					if (! file_exists($file)) $url=DOL_URL_ROOT.'/public/theme/common/nophoto.png';
419
+    					if (! file_exists($file)) {
420
+    						$url=DOL_URL_ROOT.'/public/theme/common/nophoto.png';
421
+    					}
394 422
     					print '<a href="'.$_SERVER["PHP_SELF"].($edit?'?action=edit&theme=':'?theme=').$subdir.(GETPOST('optioncss','alpha',1)?'&optioncss='.GETPOST('optioncss','alpha',1):'').($fuser?'&id='.$fuser->id:'').'" style="font-weight: normal;" alt="'.$langs->trans("Preview").'">';
395
-    					if ($subdir == $conf->global->MAIN_THEME) $title=$langs->trans("ThemeCurrentlyActive");
396
-    					else $title=$langs->trans("ShowPreview");
423
+    					if ($subdir == $conf->global->MAIN_THEME) {
424
+    						$title=$langs->trans("ThemeCurrentlyActive");
425
+    					} else {
426
+    						$title=$langs->trans("ShowPreview");
427
+    					}
397 428
     					print '<img src="'.$url.'" border="0" width="80" height="60" alt="'.$title.'" title="'.$title.'" style="margin-bottom: 5px;">';
398 429
     					print '</a><br>';
399 430
     					if ($subdir == $selected_theme)
400 431
     					{
401 432
     						print '<input '.($edit?'':'disabled').' type="radio" class="themethumbs" style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>';
402
-    					}
403
-    					else
433
+    					} else
404 434
     					{
405 435
     						print '<input '.($edit?'':'disabled').' type="radio" class="themethumbs" style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir;
406 436
     					}
@@ -440,8 +470,7 @@  discard block
 block discarded – undo
440 470
          }
441 471
          if ($edit) print '<br>('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
442 472
          print '</td>';*/
443
-    }
444
-    else
473
+    } else
445 474
     {
446 475
         $default=$langs->trans('No');
447 476
         print '<tr class="oddeven">';
@@ -450,8 +479,7 @@  discard block
 block discarded – undo
450 479
         if ($edit)
451 480
         {
452 481
             print $form->selectyesno('THEME_TOPMENU_DISABLE_IMAGE', $conf->global->THEME_TOPMENU_DISABLE_IMAGE, 1);
453
-        }
454
-        else
482
+        } else
455 483
         {
456 484
             print yn($conf->global->THEME_TOPMENU_DISABLE_IMAGE);
457 485
         }
@@ -483,8 +511,7 @@  discard block
 block discarded – undo
483 511
 	   	}
484 512
     	if ($edit) print '<br>('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
485 513
 	    print '</td>';*/
486
-	}
487
-	else
514
+	} else
488 515
 	{
489 516
 	    print '<tr class="oddeven">';
490 517
 	    print '<td>'.$langs->trans("BackgroundColor").'</td>';
@@ -493,12 +520,14 @@  discard block
 block discarded – undo
493 520
 	    if ($edit)
494 521
 	    {
495 522
 			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKBODY,array()),''),'THEME_ELDY_BACKBODY','formcolor',1).' ';
496
-	    }
497
-	   	else
523
+	    } else
498 524
 	   	{
499 525
 	   		$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKBODY,array()),'');
500
-			if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
501
-			else print $langs->trans("Default");
526
+			if ($color) {
527
+				print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
528
+			} else {
529
+				print $langs->trans("Default");
530
+			}
502 531
 	   	}
503 532
     	print ' &nbsp; ('.$langs->trans("Default").': <strong>ffffff</strong>) ';
504 533
     	print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
@@ -528,11 +557,12 @@  discard block
 block discarded – undo
528 557
 	   	}
529 558
     	if ($edit) print '<br>('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
530 559
 	    print '</td>';*/
531
-	}
532
-	else
560
+	} else
533 561
 	{
534 562
 	    $default='5a6482';
535
-	    if ($conf->theme == 'md') $default='5a3278';
563
+	    if ($conf->theme == 'md') {
564
+	    	$default='5a3278';
565
+	    }
536 566
 
537 567
 	    print '<tr class="oddeven">';
538 568
 	    print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
@@ -540,12 +570,14 @@  discard block
 block discarded – undo
540 570
 	    if ($edit)
541 571
 	    {
542 572
 			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1,array()),''),'THEME_ELDY_TOPMENU_BACK1','formcolor',1).' ';
543
-	    }
544
-	   	else
573
+	    } else
545 574
 	   	{
546 575
 	   		$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1,array()),'');
547
-			if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
548
-			else print $langs->trans("Default");
576
+			if ($color) {
577
+				print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
578
+			} else {
579
+				print $langs->trans("Default");
580
+			}
549 581
 	   	}
550 582
     	print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
551 583
     	print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
@@ -575,11 +607,12 @@  discard block
 block discarded – undo
575 607
 		 }
576 608
 		 if ($edit) print '<br>('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
577 609
 		 print '</td>';*/
578
-	}
579
-	else
610
+	} else
580 611
 	{
581 612
 		$default='ffffff';
582
-		if ($conf->theme == 'md') $default='ffffff';
613
+		if ($conf->theme == 'md') {
614
+			$default='ffffff';
615
+		}
583 616
 
584 617
 		print '<tr class="oddeven">';
585 618
 		print '<td>'.$langs->trans("LeftMenuBackgroundColor").'</td>';
@@ -587,12 +620,14 @@  discard block
 block discarded – undo
587 620
 		if ($edit)
588 621
 		{
589 622
 			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1,array()),''),'THEME_ELDY_VERMENU_BACK1','formcolor',1).' ';
590
-		}
591
-		else
623
+		} else
592 624
 		{
593 625
 			$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1,array()),'');
594
-			if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
595
-			else print $langs->trans("Default");
626
+			if ($color) {
627
+				print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
628
+			} else {
629
+				print $langs->trans("Default");
630
+			}
596 631
 		}
597 632
 		print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
598 633
 		print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
@@ -604,8 +639,7 @@  discard block
 block discarded – undo
604 639
 	{
605 640
 
606 641
 
607
-	}
608
-	else
642
+	} else
609 643
 	{
610 644
 	    print '<tr class="oddeven">';
611 645
 	    print '<td>'.$langs->trans("BackgroundTableTitleColor").'</td>';
@@ -613,8 +647,7 @@  discard block
 block discarded – undo
613 647
 	    if ($edit)
614 648
 	    {
615 649
 			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKTITLE1,array()),''),'THEME_ELDY_BACKTITLE1','formcolor',1).' ';
616
-	    }
617
-	   	else
650
+	    } else
618 651
 	   	{
619 652
 	   		print $formother->showColor($conf->global->THEME_ELDY_BACKTITLE1, $langs->trans("Default"));
620 653
 	   	}
@@ -629,11 +662,12 @@  discard block
 block discarded – undo
629 662
 	if ($foruserprofile)
630 663
 	{
631 664
 
632
-	}
633
-	else
665
+	} else
634 666
 	{
635 667
 	    $default='ffffff';
636
-	    if ($conf->theme == 'md') $default='ffffff';
668
+	    if ($conf->theme == 'md') {
669
+	    	$default='ffffff';
670
+	    }
637 671
 
638 672
 	    print '<tr class="oddeven">';
639 673
 	    print '<td>'.$langs->trans("BackgroundTableLineOddColor").'</td>';
@@ -641,12 +675,14 @@  discard block
 block discarded – undo
641 675
 	    if ($edit)
642 676
 	    {
643 677
 	        print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1,array()),''),'THEME_ELDY_LINEIMPAIR1','formcolor',1).' ';
644
-	    }
645
-	    else
678
+	    } else
646 679
 	    {
647 680
 	        $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1,array()),'');
648
-	        if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
649
-	        else print $langs->trans("Default");
681
+	        if ($color) {
682
+	        	print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
683
+	        } else {
684
+	        	print $langs->trans("Default");
685
+	        }
650 686
 	    }
651 687
 	    print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
652 688
 	    print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
@@ -657,11 +693,12 @@  discard block
 block discarded – undo
657 693
 	if ($foruserprofile)
658 694
 	{
659 695
 
660
-	}
661
-	else
696
+	} else
662 697
 	{
663 698
 	    $default='f8f8f8';
664
-	    if ($conf->theme == 'md') $default='f8f8f8';
699
+	    if ($conf->theme == 'md') {
700
+	    	$default='f8f8f8';
701
+	    }
665 702
 
666 703
 	    print '<tr class="oddeven">';
667 704
 	    print '<td>'.$langs->trans("BackgroundTableLineEvenColor").'</td>';
@@ -669,12 +706,14 @@  discard block
 block discarded – undo
669 706
 	    if ($edit)
670 707
 	    {
671 708
 	        print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1,array()),''),'THEME_ELDY_LINEPAIR1','formcolor',1).' ';
672
-	    }
673
-	    else
709
+	    } else
674 710
 	    {
675 711
 	        $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1,array()),'');
676
-	        if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
677
-	        else print $langs->trans("Default");
712
+	        if ($color) {
713
+	        	print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
714
+	        } else {
715
+	        	print $langs->trans("Default");
716
+	        }
678 717
 	    }
679 718
 	    print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
680 719
 	    print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
@@ -686,8 +725,7 @@  discard block
 block discarded – undo
686 725
 	{
687 726
 
688 727
 
689
-	}
690
-	else
728
+	} else
691 729
 	{
692 730
 	    print '<tr class="oddeven">';
693 731
 	    print '<td>'.$langs->trans("TextTitleColor").'</td>';
@@ -695,8 +733,7 @@  discard block
 block discarded – undo
695 733
 	    if ($edit)
696 734
 	    {
697 735
 	        print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTTITLENOTAB,array()),''),'THEME_ELDY_TEXTTITLENOTAB','formcolor',1).' ';
698
-	    }
699
-	    else
736
+	    } else
700 737
 	    {
701 738
 	        print $formother->showColor($conf->global->THEME_ELDY_TEXTTITLENOTAB, $langs->trans("Default"));
702 739
 	    }
@@ -731,8 +768,7 @@  discard block
 block discarded – undo
731 768
 	     }
732 769
 	    	if ($edit) print '<br>('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
733 770
 	    	print '</td>';*/
734
-	}
735
-	else
771
+	} else
736 772
 	{
737 773
 	    print '<tr class="oddeven">';
738 774
 	    print '<td>'.$langs->trans("LinkColor").'</td>';
@@ -740,12 +776,12 @@  discard block
 block discarded – undo
740 776
 	    if ($edit)
741 777
 	    {
742 778
 	        print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK,array()),''),'THEME_ELDY_TEXTLINK','formcolor',1).' ';
743
-	    }
744
-	    else
779
+	    } else
745 780
 	    {
746 781
 	        $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK,array()),'');
747
-	        if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
748
-	        else
782
+	        if ($color) {
783
+	        	print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
784
+	        } else
749 785
 	        {
750 786
 	            //print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$defaultcolor.'" value="'.$langs->trans("Default").'">';
751 787
 	            //print '<span style="color: #000078">'.$langs->trans("Default").'</span>';
@@ -770,8 +806,7 @@  discard block
 block discarded – undo
770 806
 	     print '</td>';
771 807
 	     print '</tr>';
772 808
 	     */
773
-	}
774
-	else
809
+	} else
775 810
 	{
776 811
 	    print '<tr class="oddeven">';
777 812
 	    print '<td>'.$langs->trans("HighlightLinesColor").'</td>';
@@ -780,20 +815,29 @@  discard block
 block discarded – undo
780 815
 	    //print ' &nbsp; ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
781 816
 	    if ($edit)
782 817
 	    {
783
-	        if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color='edf4fb';
784
-	        else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER,array()),'');
818
+	        if ($conf->global->THEME_ELDY_USE_HOVER == '1') {
819
+	        	$color='edf4fb';
820
+	        } else {
821
+	        	$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER,array()),'');
822
+	        }
785 823
 	        print $formother->selectColor($color,'THEME_ELDY_USE_HOVER','formcolor',1).' ';
786
-	    }
787
-	    else
824
+	    } else
788 825
 	    {
789
-	        if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color='edf4fb';
790
-	        else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER,array()),'');
826
+	        if ($conf->global->THEME_ELDY_USE_HOVER == '1') {
827
+	        	$color='edf4fb';
828
+	        } else {
829
+	        	$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER,array()),'');
830
+	        }
791 831
 	        if ($color)
792 832
 	        {
793
-	            if ($color != 'edf4fb') print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
794
-	            else print $langs->trans("Default");
833
+	            if ($color != 'edf4fb') {
834
+	            	print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
835
+	            } else {
836
+	            	print $langs->trans("Default");
837
+	            }
838
+	        } else {
839
+	        	print $langs->trans("None");
795 840
 	        }
796
-	        else print $langs->trans("None");
797 841
 	    }
798 842
 	    print ' &nbsp; ('.$langs->trans("Default").': <strong>edf4fb</strong>) ';
799 843
     	print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
Please login to merge, or discard this patch.
htdocs/core/lib/security.lib.php 2 patches
Spacing   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
  */
36 36
 function dol_encode($chain)
37 37
 {
38
-    $strlength=dol_strlen($chain);
39
-	for ($i=0; $i < $strlength; $i++)
38
+    $strlength = dol_strlen($chain);
39
+	for ($i = 0; $i < $strlength; $i++)
40 40
 	{
41
-		$output_tab[$i] = chr(ord(substr($chain,$i,1))+17);
41
+		$output_tab[$i] = chr(ord(substr($chain, $i, 1)) + 17);
42 42
 	}
43 43
 
44
-	$string_coded = base64_encode(implode("",$output_tab));
44
+	$string_coded = base64_encode(implode("", $output_tab));
45 45
 	return $string_coded;
46 46
 }
47 47
 
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 {
58 58
 	$chain = base64_decode($chain);
59 59
 
60
-	$strlength=dol_strlen($chain);
61
-	for($i=0; $i < $strlength;$i++)
60
+	$strlength = dol_strlen($chain);
61
+	for ($i = 0; $i < $strlength; $i++)
62 62
 	{
63
-		$output_tab[$i] = chr(ord(substr($chain,$i,1))-17);
63
+		$output_tab[$i] = chr(ord(substr($chain, $i, 1)) - 17);
64 64
 	}
65 65
 
66
-	$string_decoded = implode("",$output_tab);
66
+	$string_decoded = implode("", $output_tab);
67 67
 	return $string_decoded;
68 68
 }
69 69
 
@@ -77,19 +77,19 @@  discard block
 block discarded – undo
77 77
  * 	@param		int			$type		Type of hash (0:auto, 1:sha1, 2:sha1+md5, 3:md5, 4:md5 for OpenLdap). Use 3 here, if hash is not needed for security purpose, for security need, prefer 0.
78 78
  * 	@return		string					Hash of string
79 79
  */
80
-function dol_hash($chain,$type=0)
80
+function dol_hash($chain, $type = 0)
81 81
 {
82 82
 	global $conf;
83 83
 
84 84
 	// Salt value
85
-	if (! empty($conf->global->MAIN_SECURITY_SALT)) $chain=$conf->global->MAIN_SECURITY_SALT.$chain;
85
+	if (!empty($conf->global->MAIN_SECURITY_SALT)) $chain = $conf->global->MAIN_SECURITY_SALT.$chain;
86 86
 
87 87
 	if ($type == 1) return sha1($chain);
88 88
 	else if ($type == 2) return sha1(md5($chain));
89 89
 	else if ($type == 3) return md5($chain);
90
-	else if ($type == 4) return '{md5}'.base64_encode(mhash(MHASH_MD5,$chain)); // For OpenLdap with md5 (based on an unencrypted password in base)
91
-	else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') return sha1($chain);
92
-	else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') return sha1(md5($chain));
90
+	else if ($type == 4) return '{md5}'.base64_encode(mhash(MHASH_MD5, $chain)); // For OpenLdap with md5 (based on an unencrypted password in base)
91
+	else if (!empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') return sha1($chain);
92
+	else if (!empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') return sha1(md5($chain));
93 93
 
94 94
 	// No particular enconding defined, use default
95 95
 	return md5($chain);
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
  * 	@return	int						Always 1, die process if not allowed
112 112
  *  @see dol_check_secure_access_document
113 113
  */
114
-function restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
114
+function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid', $objcanvas = null)
115 115
 {
116 116
     global $db, $conf;
117 117
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     // If we use canvas, we try to use function that overlod restrictarea if provided with canvas
124 124
     if (is_object($objcanvas))
125 125
     {
126
-        if (method_exists($objcanvas->control,'restrictedArea')) return $objcanvas->control->restrictedArea($user,$features,$objectid,$dbtablename,$feature2,$dbt_keyfield,$dbt_select);
126
+        if (method_exists($objcanvas->control, 'restrictedArea')) return $objcanvas->control->restrictedArea($user, $features, $objectid, $dbtablename, $feature2, $dbt_keyfield, $dbt_select);
127 127
     }
128 128
 
129 129
     if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'";
@@ -134,211 +134,211 @@  discard block
 block discarded – undo
134 134
     else if (preg_match('/\|/', $features)) $featuresarray = explode("|", $features);
135 135
 
136 136
     // More subfeatures to check
137
-    if (! empty($feature2)) $feature2 = explode("|", $feature2);
137
+    if (!empty($feature2)) $feature2 = explode("|", $feature2);
138 138
 
139 139
     // More parameters
140 140
     $params = explode('&', $tableandshare);
141
-    $dbtablename=(! empty($params[0]) ? $params[0] : '');
142
-    $sharedelement=(! empty($params[1]) ? $params[1] : $dbtablename);
141
+    $dbtablename = (!empty($params[0]) ? $params[0] : '');
142
+    $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename);
143 143
 
144
-	$listofmodules=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
144
+	$listofmodules = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
145 145
 
146 146
 	// Check read permission from module
147
-    $readok=1; $nbko=0;
147
+    $readok = 1; $nbko = 0;
148 148
     foreach ($featuresarray as $feature)	// first we check nb of test ko
149 149
     {
150
-        $featureforlistofmodule=$feature;
151
-        if ($featureforlistofmodule == 'produit') $featureforlistofmodule='product';
152
-        if (! empty($user->societe_id) && ! empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && ! in_array($featureforlistofmodule,$listofmodules))	// If limits on modules for external users, module must be into list of modules for external users
150
+        $featureforlistofmodule = $feature;
151
+        if ($featureforlistofmodule == 'produit') $featureforlistofmodule = 'product';
152
+        if (!empty($user->societe_id) && !empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && !in_array($featureforlistofmodule, $listofmodules))	// If limits on modules for external users, module must be into list of modules for external users
153 153
     	{
154
-    		$readok=0; $nbko++;
154
+    		$readok = 0; $nbko++;
155 155
     		continue;
156 156
     	}
157 157
 
158 158
         if ($feature == 'societe')
159 159
         {
160
-            if (! $user->rights->societe->lire && ! $user->rights->fournisseur->lire) { $readok=0; $nbko++; }
160
+            if (!$user->rights->societe->lire && !$user->rights->fournisseur->lire) { $readok = 0; $nbko++; }
161 161
         }
162 162
         else if ($feature == 'contact')
163 163
         {
164
-            if (! $user->rights->societe->contact->lire) { $readok=0; $nbko++; }
164
+            if (!$user->rights->societe->contact->lire) { $readok = 0; $nbko++; }
165 165
         }
166 166
         else if ($feature == 'produit|service')
167 167
         {
168
-            if (! $user->rights->produit->lire && ! $user->rights->service->lire) { $readok=0; $nbko++; }
168
+            if (!$user->rights->produit->lire && !$user->rights->service->lire) { $readok = 0; $nbko++; }
169 169
         }
170 170
         else if ($feature == 'prelevement')
171 171
         {
172
-            if (! $user->rights->prelevement->bons->lire) { $readok=0; $nbko++; }
172
+            if (!$user->rights->prelevement->bons->lire) { $readok = 0; $nbko++; }
173 173
         }
174 174
         else if ($feature == 'cheque')
175 175
         {
176
-            if (! $user->rights->banque->cheque) { $readok=0; $nbko++; }
176
+            if (!$user->rights->banque->cheque) { $readok = 0; $nbko++; }
177 177
         }
178 178
         else if ($feature == 'projet')
179 179
         {
180
-            if (! $user->rights->projet->lire && ! $user->rights->projet->all->lire) { $readok=0; $nbko++; }
180
+            if (!$user->rights->projet->lire && !$user->rights->projet->all->lire) { $readok = 0; $nbko++; }
181 181
         }
182
-        else if (! empty($feature2))	// This should be used for future changes
182
+        else if (!empty($feature2))	// This should be used for future changes
183 183
         {
184
-        	$tmpreadok=1;
185
-        	foreach($feature2 as $subfeature)
184
+        	$tmpreadok = 1;
185
+        	foreach ($feature2 as $subfeature)
186 186
         	{
187
-        		if (! empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok=0; }
188
-        		else if (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok=0; }
189
-        		else { $tmpreadok=1; break; } // Break is to bypass second test if the first is ok
187
+        		if (!empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok = 0; }
188
+        		else if (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok = 0; }
189
+        		else { $tmpreadok = 1; break; } // Break is to bypass second test if the first is ok
190 190
         	}
191
-        	if (! $tmpreadok)	// We found a test on feature that is ko
191
+        	if (!$tmpreadok)	// We found a test on feature that is ko
192 192
         	{
193
-        		$readok=0;	// All tests are ko (we manage here the and, the or will be managed later using $nbko).
193
+        		$readok = 0; // All tests are ko (we manage here the and, the or will be managed later using $nbko).
194 194
         		$nbko++;
195 195
         	}
196 196
         }
197
-        else if (! empty($feature) && ($feature!='user' && $feature!='usergroup'))		// This is for old permissions
197
+        else if (!empty($feature) && ($feature != 'user' && $feature != 'usergroup'))		// This is for old permissions
198 198
         {
199 199
             if (empty($user->rights->$feature->lire)
200 200
             && empty($user->rights->$feature->read)
201
-            && empty($user->rights->$feature->run)) { $readok=0; $nbko++; }
201
+            && empty($user->rights->$feature->run)) { $readok = 0; $nbko++; }
202 202
         }
203 203
     }
204 204
 
205 205
     // If a or and at least one ok
206
-    if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $readok=1;
206
+    if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $readok = 1;
207 207
 
208
-    if (! $readok) accessforbidden();
208
+    if (!$readok) accessforbidden();
209 209
     //print "Read access is ok";
210 210
 
211 211
     // Check write permission from module
212
-    $createok=1; $nbko=0;
213
-    if (GETPOST('action','aZ09')  == 'create')
212
+    $createok = 1; $nbko = 0;
213
+    if (GETPOST('action', 'aZ09') == 'create')
214 214
     {
215 215
         foreach ($featuresarray as $feature)
216 216
         {
217 217
             if ($feature == 'contact')
218 218
             {
219
-                if (! $user->rights->societe->contact->creer) { $createok=0; $nbko++; }
219
+                if (!$user->rights->societe->contact->creer) { $createok = 0; $nbko++; }
220 220
             }
221 221
             else if ($feature == 'produit|service')
222 222
             {
223
-                if (! $user->rights->produit->creer && ! $user->rights->service->creer) { $createok=0; $nbko++; }
223
+                if (!$user->rights->produit->creer && !$user->rights->service->creer) { $createok = 0; $nbko++; }
224 224
             }
225 225
             else if ($feature == 'prelevement')
226 226
             {
227
-                if (! $user->rights->prelevement->bons->creer) { $createok=0; $nbko++; }
227
+                if (!$user->rights->prelevement->bons->creer) { $createok = 0; $nbko++; }
228 228
             }
229 229
             else if ($feature == 'commande_fournisseur')
230 230
             {
231
-                if (! $user->rights->fournisseur->commande->creer) { $createok=0; $nbko++; }
231
+                if (!$user->rights->fournisseur->commande->creer) { $createok = 0; $nbko++; }
232 232
             }
233 233
             else if ($feature == 'banque')
234 234
             {
235
-                if (! $user->rights->banque->modifier) { $createok=0; $nbko++; }
235
+                if (!$user->rights->banque->modifier) { $createok = 0; $nbko++; }
236 236
             }
237 237
             else if ($feature == 'cheque')
238 238
             {
239
-                if (! $user->rights->banque->cheque) { $createok=0; $nbko++; }
239
+                if (!$user->rights->banque->cheque) { $createok = 0; $nbko++; }
240 240
             }
241
-            else if (! empty($feature2))	// This should be used
241
+            else if (!empty($feature2))	// This should be used
242 242
             {
243
-            	foreach($feature2 as $subfeature)
243
+            	foreach ($feature2 as $subfeature)
244 244
             	{
245 245
             		if (empty($user->rights->$feature->$subfeature->creer)
246 246
             		&& empty($user->rights->$feature->$subfeature->write)
247
-            		&& empty($user->rights->$feature->$subfeature->create)) { $createok=0; $nbko++; }
248
-            		else { $createok=1; break; } // Break to bypass second test if the first is ok
247
+            		&& empty($user->rights->$feature->$subfeature->create)) { $createok = 0; $nbko++; }
248
+            		else { $createok = 1; break; } // Break to bypass second test if the first is ok
249 249
             	}
250 250
             }
251
-            else if (! empty($feature))		// This is for old permissions ('creer' or 'write')
251
+            else if (!empty($feature))		// This is for old permissions ('creer' or 'write')
252 252
             {
253 253
                 //print '<br>feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write;
254 254
                 if (empty($user->rights->$feature->creer)
255 255
                 && empty($user->rights->$feature->write)
256
-                && empty($user->rights->$feature->create)) { $createok=0; $nbko++; }
256
+                && empty($user->rights->$feature->create)) { $createok = 0; $nbko++; }
257 257
             }
258 258
         }
259 259
 
260 260
 	    // If a or and at least one ok
261
-	    if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok=1;
261
+	    if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok = 1;
262 262
 
263
-        if (! $createok) accessforbidden();
263
+        if (!$createok) accessforbidden();
264 264
         //print "Write access is ok";
265 265
     }
266 266
 
267 267
     // Check create user permission
268
-    $createuserok=1;
269
-    if (GETPOST('action','aZ09') == 'confirm_create_user' && GETPOST("confirm") == 'yes')
268
+    $createuserok = 1;
269
+    if (GETPOST('action', 'aZ09') == 'confirm_create_user' && GETPOST("confirm") == 'yes')
270 270
     {
271
-        if (! $user->rights->user->user->creer) $createuserok=0;
271
+        if (!$user->rights->user->user->creer) $createuserok = 0;
272 272
 
273
-        if (! $createuserok) accessforbidden();
273
+        if (!$createuserok) accessforbidden();
274 274
         //print "Create user access is ok";
275 275
     }
276 276
 
277 277
     // Check delete permission from module
278
-    $deleteok=1; $nbko=0;
279
-    if ((GETPOST('action','aZ09')  == 'confirm_delete' && GETPOST("confirm") == 'yes') || GETPOST('action','aZ09')  == 'delete')
278
+    $deleteok = 1; $nbko = 0;
279
+    if ((GETPOST('action', 'aZ09') == 'confirm_delete' && GETPOST("confirm") == 'yes') || GETPOST('action', 'aZ09') == 'delete')
280 280
     {
281 281
         foreach ($featuresarray as $feature)
282 282
         {
283 283
             if ($feature == 'contact')
284 284
             {
285
-                if (! $user->rights->societe->contact->supprimer) $deleteok=0;
285
+                if (!$user->rights->societe->contact->supprimer) $deleteok = 0;
286 286
             }
287 287
             else if ($feature == 'produit|service')
288 288
             {
289
-                if (! $user->rights->produit->supprimer && ! $user->rights->service->supprimer) $deleteok=0;
289
+                if (!$user->rights->produit->supprimer && !$user->rights->service->supprimer) $deleteok = 0;
290 290
             }
291 291
             else if ($feature == 'commande_fournisseur')
292 292
             {
293
-                if (! $user->rights->fournisseur->commande->supprimer) $deleteok=0;
293
+                if (!$user->rights->fournisseur->commande->supprimer) $deleteok = 0;
294 294
             }
295 295
             else if ($feature == 'banque')
296 296
             {
297
-                if (! $user->rights->banque->modifier) $deleteok=0;
297
+                if (!$user->rights->banque->modifier) $deleteok = 0;
298 298
             }
299 299
             else if ($feature == 'cheque')
300 300
             {
301
-                if (! $user->rights->banque->cheque) $deleteok=0;
301
+                if (!$user->rights->banque->cheque) $deleteok = 0;
302 302
             }
303 303
             else if ($feature == 'ecm')
304 304
             {
305
-                if (! $user->rights->ecm->upload) $deleteok=0;
305
+                if (!$user->rights->ecm->upload) $deleteok = 0;
306 306
             }
307 307
             else if ($feature == 'ftp')
308 308
             {
309
-                if (! $user->rights->ftp->write) $deleteok=0;
309
+                if (!$user->rights->ftp->write) $deleteok = 0;
310 310
             }
311 311
             else if ($feature == 'salaries')
312 312
             {
313
-                if (! $user->rights->salaries->delete) $deleteok=0;
313
+                if (!$user->rights->salaries->delete) $deleteok = 0;
314 314
             }
315
-            else if (! empty($feature2))	// This should be used for future changes
315
+            else if (!empty($feature2))	// This should be used for future changes
316 316
             {
317
-            	foreach($feature2 as $subfeature)
317
+            	foreach ($feature2 as $subfeature)
318 318
             	{
319
-            		if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok=0;
320
-            		else { $deleteok=1; break; } // For bypass the second test if the first is ok
319
+            		if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok = 0;
320
+            		else { $deleteok = 1; break; } // For bypass the second test if the first is ok
321 321
             	}
322 322
             }
323
-            else if (! empty($feature))		// This is for old permissions
323
+            else if (!empty($feature))		// This is for old permissions
324 324
             {
325 325
                 //print '<br>feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete;
326 326
                 if (empty($user->rights->$feature->supprimer)
327 327
                 && empty($user->rights->$feature->delete)
328
-                && empty($user->rights->$feature->run)) $deleteok=0;
328
+                && empty($user->rights->$feature->run)) $deleteok = 0;
329 329
             }
330 330
         }
331 331
 
332 332
 	    // If a or and at least one ok
333
-	    if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $deleteok=1;
333
+	    if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $deleteok = 1;
334 334
 
335
-        if (! $deleteok) accessforbidden();
335
+        if (!$deleteok) accessforbidden();
336 336
         //print "Delete access is ok";
337 337
     }
338 338
 
339 339
     // If we have a particular object to check permissions on, we check this object
340 340
     // is linked to a company allowed to $user.
341
-    if (! empty($objectid) && $objectid > 0)
341
+    if (!empty($objectid) && $objectid > 0)
342 342
     {
343 343
     	$ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select);
344 344
 		return $ok ? 1 : accessforbidden();
@@ -361,51 +361,51 @@  discard block
 block discarded – undo
361 361
  * @return	bool		True if user has access, False otherwise
362 362
  * @see restrictedArea
363 363
  */
364
-function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='', $dbt_select='rowid')
364
+function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableandshare = '', $feature2 = '', $dbt_keyfield = '', $dbt_select = 'rowid')
365 365
 {
366 366
 	global $db, $conf;
367 367
 
368 368
 	// More parameters
369 369
 	$params = explode('&', $tableandshare);
370
-	$dbtablename=(! empty($params[0]) ? $params[0] : '');
371
-	$sharedelement=(! empty($params[1]) ? $params[1] : $dbtablename);
370
+	$dbtablename = (!empty($params[0]) ? $params[0] : '');
371
+	$sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename);
372 372
 
373 373
 	foreach ($featuresarray as $feature)
374 374
 	{
375
-		$sql='';
375
+		$sql = '';
376 376
 
377 377
 		// For backward compatibility
378
-		if ($feature == 'member') $feature='adherent';
379
-		if ($feature == 'project') $feature='projet';
380
-		if ($feature == 'task') $feature='projet_task';
381
-
382
-		$check = array('adherent','banque','user','usergroup','produit','service','produit|service','categorie'); // Test on entity only (Objects with no link to company)
383
-		$checksoc = array('societe');	 // Test for societe object
384
-		$checkother = array('contact','agenda');	 // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...).
385
-		$checkproject = array('projet','project'); // Test for project object
378
+		if ($feature == 'member') $feature = 'adherent';
379
+		if ($feature == 'project') $feature = 'projet';
380
+		if ($feature == 'task') $feature = 'projet_task';
381
+
382
+		$check = array('adherent', 'banque', 'user', 'usergroup', 'produit', 'service', 'produit|service', 'categorie'); // Test on entity only (Objects with no link to company)
383
+		$checksoc = array('societe'); // Test for societe object
384
+		$checkother = array('contact', 'agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...).
385
+		$checkproject = array('projet', 'project'); // Test for project object
386 386
 		$checktask = array('projet_task');
387
-		$nocheck = array('barcode','stock','fournisseur');	// No test
387
+		$nocheck = array('barcode', 'stock', 'fournisseur'); // No test
388 388
 		$checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...).
389 389
 
390 390
 		// If dbtable not defined, we use same name for table than module name
391 391
 		if (empty($dbtablename)) $dbtablename = $feature;
392 392
 
393 393
 		// Check permission for object with entity
394
-		if (in_array($feature,$check))
394
+		if (in_array($feature, $check))
395 395
 		{
396 396
 			$sql = "SELECT dbt.".$dbt_select;
397
-			$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
398
-			$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
399
-			if (($feature == 'user' || $feature == 'usergroup') && ! empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && ! $user->entity)
397
+			$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
398
+			$sql .= " WHERE dbt.".$dbt_select." = ".$objectid;
399
+			if (($feature == 'user' || $feature == 'usergroup') && !empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity)
400 400
 			{
401
-				$sql.= " AND dbt.entity IS NOT NULL";
401
+				$sql .= " AND dbt.entity IS NOT NULL";
402 402
 			}
403 403
 			else
404 404
 			{
405
-				$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
405
+				$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
406 406
 			}
407 407
 		}
408
-		else if (in_array($feature,$checksoc))	// We check feature = checksoc
408
+		else if (in_array($feature, $checksoc))	// We check feature = checksoc
409 409
 		{
410 410
 			// If external user: Check permission for external users
411 411
 			if ($user->socid > 0)
@@ -413,132 +413,132 @@  discard block
 block discarded – undo
413 413
 				if ($user->socid <> $objectid) return false;
414 414
 			}
415 415
 			// If internal user: Check permission for internal users that are restricted on their objects
416
-			else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir))
416
+			else if (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir))
417 417
 			{
418 418
 				$sql = "SELECT sc.fk_soc";
419
-				$sql.= " FROM (".MAIN_DB_PREFIX."societe_commerciaux as sc";
420
-				$sql.= ", ".MAIN_DB_PREFIX."societe as s)";
421
-				$sql.= " WHERE sc.fk_soc = ".$objectid;
422
-				$sql.= " AND sc.fk_user = ".$user->id;
423
-				$sql.= " AND sc.fk_soc = s.rowid";
424
-				$sql.= " AND s.entity IN (".getEntity($sharedelement, 1).")";
419
+				$sql .= " FROM (".MAIN_DB_PREFIX."societe_commerciaux as sc";
420
+				$sql .= ", ".MAIN_DB_PREFIX."societe as s)";
421
+				$sql .= " WHERE sc.fk_soc = ".$objectid;
422
+				$sql .= " AND sc.fk_user = ".$user->id;
423
+				$sql .= " AND sc.fk_soc = s.rowid";
424
+				$sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")";
425 425
 			}
426 426
 			// If multicompany and internal users with all permissions, check user is in correct entity
427
-			else if (! empty($conf->multicompany->enabled))
427
+			else if (!empty($conf->multicompany->enabled))
428 428
 			{
429 429
 				$sql = "SELECT s.rowid";
430
-				$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
431
-				$sql.= " WHERE s.rowid = ".$objectid;
432
-				$sql.= " AND s.entity IN (".getEntity($sharedelement, 1).")";
430
+				$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
431
+				$sql .= " WHERE s.rowid = ".$objectid;
432
+				$sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")";
433 433
 			}
434 434
 		}
435
-		else if (in_array($feature,$checkother))	// Test on entity and link to societe. Allowed if link is empty (Ex: contacts...).
435
+		else if (in_array($feature, $checkother))	// Test on entity and link to societe. Allowed if link is empty (Ex: contacts...).
436 436
 		{
437 437
 			// If external user: Check permission for external users
438 438
 			if ($user->societe_id > 0)
439 439
 			{
440 440
 				$sql = "SELECT dbt.".$dbt_select;
441
-				$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
442
-				$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
443
-				$sql.= " AND dbt.fk_soc = ".$user->societe_id;
441
+				$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
442
+				$sql .= " WHERE dbt.".$dbt_select." = ".$objectid;
443
+				$sql .= " AND dbt.fk_soc = ".$user->societe_id;
444 444
 			}
445 445
 			// If internal user: Check permission for internal users that are restricted on their objects
446
-			else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir))
446
+			else if (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir))
447 447
 			{
448 448
 				$sql = "SELECT dbt.".$dbt_select;
449
-				$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
450
-				$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = '".$user->id."'";
451
-				$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
452
-				$sql.= " AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)";	// Contact not linked to a company or to a company of user
453
-				$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
449
+				$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
450
+				$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = '".$user->id."'";
451
+				$sql .= " WHERE dbt.".$dbt_select." = ".$objectid;
452
+				$sql .= " AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)"; // Contact not linked to a company or to a company of user
453
+				$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
454 454
 			}
455 455
 			// If multicompany and internal users with all permissions, check user is in correct entity
456
-			else if (! empty($conf->multicompany->enabled))
456
+			else if (!empty($conf->multicompany->enabled))
457 457
 			{
458 458
 				$sql = "SELECT dbt.".$dbt_select;
459
-				$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
460
-				$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
461
-				$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
459
+				$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
460
+				$sql .= " WHERE dbt.".$dbt_select." = ".$objectid;
461
+				$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
462 462
 			}
463 463
 		}
464
-		else if (in_array($feature,$checkproject))
464
+		else if (in_array($feature, $checkproject))
465 465
 		{
466
-			if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire))
466
+			if (!empty($conf->projet->enabled) && empty($user->rights->projet->all->lire))
467 467
 			{
468 468
 				include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
469
-				$projectstatic=new Project($db);
470
-				$tmps=$projectstatic->getProjectsAuthorizedForUser($user,0,1,0);
471
-				$tmparray=explode(',',$tmps);
472
-				if (! in_array($objectid,$tmparray)) return false;
469
+				$projectstatic = new Project($db);
470
+				$tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
471
+				$tmparray = explode(',', $tmps);
472
+				if (!in_array($objectid, $tmparray)) return false;
473 473
 			}
474 474
 			else
475 475
 			{
476 476
 				$sql = "SELECT dbt.".$dbt_select;
477
-				$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
478
-				$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
479
-				$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
477
+				$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
478
+				$sql .= " WHERE dbt.".$dbt_select." = ".$objectid;
479
+				$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
480 480
 			}
481 481
 		}
482
-		else if (in_array($feature,$checktask))
482
+		else if (in_array($feature, $checktask))
483 483
 		{
484
-			if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire))
484
+			if (!empty($conf->projet->enabled) && empty($user->rights->projet->all->lire))
485 485
 			{
486 486
 			    $task = new Task($db);
487 487
 			    $task->fetch($objectid);
488 488
 
489 489
 				include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
490
-				$projectstatic=new Project($db);
491
-				$tmps=$projectstatic->getProjectsAuthorizedForUser($user,0,1,0);
492
-				$tmparray=explode(',',$tmps);
493
-				if (! in_array($task->fk_project,$tmparray)) return false;
490
+				$projectstatic = new Project($db);
491
+				$tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
492
+				$tmparray = explode(',', $tmps);
493
+				if (!in_array($task->fk_project, $tmparray)) return false;
494 494
 			}
495 495
 			else
496 496
 			{
497 497
 				$sql = "SELECT dbt.".$dbt_select;
498
-				$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
499
-				$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
500
-				$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
498
+				$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
499
+				$sql .= " WHERE dbt.".$dbt_select." = ".$objectid;
500
+				$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
501 501
 			}
502 502
 		}
503
-		else if (! in_array($feature,$nocheck))	// By default we check with link to third party
503
+		else if (!in_array($feature, $nocheck))	// By default we check with link to third party
504 504
 		{
505 505
 			// If external user: Check permission for external users
506 506
 			if ($user->societe_id > 0)
507 507
 			{
508
-				if (empty($dbt_keyfield)) dol_print_error('','Param dbt_keyfield is required but not defined');
508
+				if (empty($dbt_keyfield)) dol_print_error('', 'Param dbt_keyfield is required but not defined');
509 509
 				$sql = "SELECT dbt.".$dbt_keyfield;
510
-				$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
511
-				$sql.= " WHERE dbt.rowid = ".$objectid;
512
-				$sql.= " AND dbt.".$dbt_keyfield." = ".$user->societe_id;
510
+				$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
511
+				$sql .= " WHERE dbt.rowid = ".$objectid;
512
+				$sql .= " AND dbt.".$dbt_keyfield." = ".$user->societe_id;
513 513
 			}
514 514
 			// If internal user: Check permission for internal users that are restricted on their objects
515
-			else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir))
515
+			else if (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir))
516 516
 			{
517
-				if (empty($dbt_keyfield)) dol_print_error('','Param dbt_keyfield is required but not defined');
517
+				if (empty($dbt_keyfield)) dol_print_error('', 'Param dbt_keyfield is required but not defined');
518 518
 				$sql = "SELECT sc.fk_soc";
519
-				$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
520
-				$sql.= ", ".MAIN_DB_PREFIX."societe as s";
521
-				$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
522
-				$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
523
-				$sql.= " AND sc.fk_soc = dbt.".$dbt_keyfield;
524
-				$sql.= " AND dbt.".$dbt_keyfield." = s.rowid";
525
-				$sql.= " AND s.entity IN (".getEntity($sharedelement, 1).")";
526
-				$sql.= " AND sc.fk_user = ".$user->id;
519
+				$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
520
+				$sql .= ", ".MAIN_DB_PREFIX."societe as s";
521
+				$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
522
+				$sql .= " WHERE dbt.".$dbt_select." = ".$objectid;
523
+				$sql .= " AND sc.fk_soc = dbt.".$dbt_keyfield;
524
+				$sql .= " AND dbt.".$dbt_keyfield." = s.rowid";
525
+				$sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")";
526
+				$sql .= " AND sc.fk_user = ".$user->id;
527 527
 			}
528 528
 			// If multicompany and internal users with all permissions, check user is in correct entity
529
-			else if (! empty($conf->multicompany->enabled))
529
+			else if (!empty($conf->multicompany->enabled))
530 530
 			{
531 531
 				$sql = "SELECT dbt.".$dbt_select;
532
-				$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
533
-				$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
534
-				$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
532
+				$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
533
+				$sql .= " WHERE dbt.".$dbt_select." = ".$objectid;
534
+				$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
535 535
 			}
536 536
 		}
537 537
 
538 538
 		//print "sql=".$sql."<br>";
539 539
 		if ($sql)
540 540
 		{
541
-			$resql=$db->query($sql);
541
+			$resql = $db->query($sql);
542 542
 			if ($resql)
543 543
 			{
544 544
 				if ($db->num_rows($resql) == 0)	return false;
@@ -562,13 +562,13 @@  discard block
 block discarded – undo
562 562
  *  @param  int		$showonlymessage     Show only message parameter. Otherwise add more information.
563 563
  *  @return	void
564 564
  */
565
-function accessforbidden($message='',$printheader=1,$printfooter=1,$showonlymessage=0)
565
+function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0)
566 566
 {
567 567
     global $conf, $db, $user, $langs;
568
-    if (! is_object($langs))
568
+    if (!is_object($langs))
569 569
     {
570 570
         include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
571
-        $langs=new Translate('',$conf);
571
+        $langs = new Translate('', $conf);
572 572
     }
573 573
 
574 574
     $langs->load("errors");
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
         else if (function_exists("llxHeaderVierge")) llxHeaderVierge('');
580 580
     }
581 581
     print '<div class="error">';
582
-    if (! $message) print $langs->trans("ErrorForbidden");
582
+    if (!$message) print $langs->trans("ErrorForbidden");
583 583
     else print $message;
584 584
     print '</div>';
585 585
     print '<br>';
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
         if ($user->login)
589 589
         {
590 590
             print $langs->trans("CurrentLogin").': <font class="error">'.$user->login.'</font><br>';
591
-            print $langs->trans("ErrorForbidden2",$langs->trans("Home"),$langs->trans("Users"));
591
+            print $langs->trans("ErrorForbidden2", $langs->trans("Home"), $langs->trans("Users"));
592 592
         }
593 593
         else
594 594
         {
Please login to merge, or discard this patch.
Braces   +191 added lines, -121 removed lines patch added patch discarded remove patch
@@ -82,14 +82,25 @@  discard block
 block discarded – undo
82 82
 	global $conf;
83 83
 
84 84
 	// Salt value
85
-	if (! empty($conf->global->MAIN_SECURITY_SALT)) $chain=$conf->global->MAIN_SECURITY_SALT.$chain;
85
+	if (! empty($conf->global->MAIN_SECURITY_SALT)) {
86
+		$chain=$conf->global->MAIN_SECURITY_SALT.$chain;
87
+	}
86 88
 
87
-	if ($type == 1) return sha1($chain);
88
-	else if ($type == 2) return sha1(md5($chain));
89
-	else if ($type == 3) return md5($chain);
90
-	else if ($type == 4) return '{md5}'.base64_encode(mhash(MHASH_MD5,$chain)); // For OpenLdap with md5 (based on an unencrypted password in base)
91
-	else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') return sha1($chain);
92
-	else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') return sha1(md5($chain));
89
+	if ($type == 1) {
90
+		return sha1($chain);
91
+	} else if ($type == 2) {
92
+		return sha1(md5($chain));
93
+	} else if ($type == 3) {
94
+		return md5($chain);
95
+	} else if ($type == 4) {
96
+		return '{md5}'.base64_encode(mhash(MHASH_MD5,$chain));
97
+	}
98
+	// For OpenLdap with md5 (based on an unencrypted password in base)
99
+	else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') {
100
+		return sha1($chain);
101
+	} else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') {
102
+		return sha1(md5($chain));
103
+	}
93 104
 
94 105
 	// No particular enconding defined, use default
95 106
 	return md5($chain);
@@ -123,18 +134,27 @@  discard block
 block discarded – undo
123 134
     // If we use canvas, we try to use function that overlod restrictarea if provided with canvas
124 135
     if (is_object($objcanvas))
125 136
     {
126
-        if (method_exists($objcanvas->control,'restrictedArea')) return $objcanvas->control->restrictedArea($user,$features,$objectid,$dbtablename,$feature2,$dbt_keyfield,$dbt_select);
137
+        if (method_exists($objcanvas->control,'restrictedArea')) {
138
+        	return $objcanvas->control->restrictedArea($user,$features,$objectid,$dbtablename,$feature2,$dbt_keyfield,$dbt_select);
139
+        }
127 140
     }
128 141
 
129
-    if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'";
142
+    if ($dbt_select != 'rowid' && $dbt_select != 'id') {
143
+    	$objectid = "'".$objectid."'";
144
+    }
130 145
 
131 146
     // Features/modules to check
132 147
     $featuresarray = array($features);
133
-    if (preg_match('/&/', $features)) $featuresarray = explode("&", $features);
134
-    else if (preg_match('/\|/', $features)) $featuresarray = explode("|", $features);
148
+    if (preg_match('/&/', $features)) {
149
+    	$featuresarray = explode("&", $features);
150
+    } else if (preg_match('/\|/', $features)) {
151
+    	$featuresarray = explode("|", $features);
152
+    }
135 153
 
136 154
     // More subfeatures to check
137
-    if (! empty($feature2)) $feature2 = explode("|", $feature2);
155
+    if (! empty($feature2)) {
156
+    	$feature2 = explode("|", $feature2);
157
+    }
138 158
 
139 159
     // More parameters
140 160
     $params = explode('&', $tableandshare);
@@ -145,67 +165,77 @@  discard block
 block discarded – undo
145 165
 
146 166
 	// Check read permission from module
147 167
     $readok=1; $nbko=0;
148
-    foreach ($featuresarray as $feature)	// first we check nb of test ko
168
+    foreach ($featuresarray as $feature) {
169
+    	// first we check nb of test ko
149 170
     {
150 171
         $featureforlistofmodule=$feature;
151
-        if ($featureforlistofmodule == 'produit') $featureforlistofmodule='product';
152
-        if (! empty($user->societe_id) && ! empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && ! in_array($featureforlistofmodule,$listofmodules))	// If limits on modules for external users, module must be into list of modules for external users
172
+    }
173
+        if ($featureforlistofmodule == 'produit') {
174
+        	$featureforlistofmodule='product';
175
+        }
176
+        if (! empty($user->societe_id) && ! empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && ! in_array($featureforlistofmodule,$listofmodules)) {
177
+        	// If limits on modules for external users, module must be into list of modules for external users
153 178
     	{
154
-    		$readok=0; $nbko++;
179
+    		$readok=0;
180
+        }
181
+        $nbko++;
155 182
     		continue;
156 183
     	}
157 184
 
158 185
         if ($feature == 'societe')
159 186
         {
160 187
             if (! $user->rights->societe->lire && ! $user->rights->fournisseur->lire) { $readok=0; $nbko++; }
161
-        }
162
-        else if ($feature == 'contact')
188
+        } else if ($feature == 'contact')
163 189
         {
164 190
             if (! $user->rights->societe->contact->lire) { $readok=0; $nbko++; }
165
-        }
166
-        else if ($feature == 'produit|service')
191
+        } else if ($feature == 'produit|service')
167 192
         {
168 193
             if (! $user->rights->produit->lire && ! $user->rights->service->lire) { $readok=0; $nbko++; }
169
-        }
170
-        else if ($feature == 'prelevement')
194
+        } else if ($feature == 'prelevement')
171 195
         {
172 196
             if (! $user->rights->prelevement->bons->lire) { $readok=0; $nbko++; }
173
-        }
174
-        else if ($feature == 'cheque')
197
+        } else if ($feature == 'cheque')
175 198
         {
176 199
             if (! $user->rights->banque->cheque) { $readok=0; $nbko++; }
177
-        }
178
-        else if ($feature == 'projet')
200
+        } else if ($feature == 'projet')
179 201
         {
180 202
             if (! $user->rights->projet->lire && ! $user->rights->projet->all->lire) { $readok=0; $nbko++; }
181
-        }
182
-        else if (! empty($feature2))	// This should be used for future changes
203
+        } else if (! empty($feature2)) {
204
+        	// This should be used for future changes
183 205
         {
184 206
         	$tmpreadok=1;
207
+        }
185 208
         	foreach($feature2 as $subfeature)
186 209
         	{
187
-        		if (! empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok=0; }
188
-        		else if (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok=0; }
189
-        		else { $tmpreadok=1; break; } // Break is to bypass second test if the first is ok
210
+        		if (! empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok=0; } else if (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok=0; } else { $tmpreadok=1; break; } // Break is to bypass second test if the first is ok
190 211
         	}
191
-        	if (! $tmpreadok)	// We found a test on feature that is ko
212
+        	if (! $tmpreadok) {
213
+        		// We found a test on feature that is ko
192 214
         	{
193
-        		$readok=0;	// All tests are ko (we manage here the and, the or will be managed later using $nbko).
215
+        		$readok=0;
216
+        	}
217
+        	// All tests are ko (we manage here the and, the or will be managed later using $nbko).
194 218
         		$nbko++;
195 219
         	}
196
-        }
197
-        else if (! empty($feature) && ($feature!='user' && $feature!='usergroup'))		// This is for old permissions
220
+        } else if (! empty($feature) && ($feature!='user' && $feature!='usergroup')) {
221
+        	// This is for old permissions
198 222
         {
199 223
             if (empty($user->rights->$feature->lire)
200 224
             && empty($user->rights->$feature->read)
201
-            && empty($user->rights->$feature->run)) { $readok=0; $nbko++; }
225
+            && empty($user->rights->$feature->run)) { $readok=0;
226
+        }
227
+        $nbko++; }
202 228
         }
203 229
     }
204 230
 
205 231
     // If a or and at least one ok
206
-    if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $readok=1;
232
+    if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) {
233
+    	$readok=1;
234
+    }
207 235
 
208
-    if (! $readok) accessforbidden();
236
+    if (! $readok) {
237
+    	accessforbidden();
238
+    }
209 239
     //print "Read access is ok";
210 240
 
211 241
     // Check write permission from module
@@ -217,50 +247,52 @@  discard block
 block discarded – undo
217 247
             if ($feature == 'contact')
218 248
             {
219 249
                 if (! $user->rights->societe->contact->creer) { $createok=0; $nbko++; }
220
-            }
221
-            else if ($feature == 'produit|service')
250
+            } else if ($feature == 'produit|service')
222 251
             {
223 252
                 if (! $user->rights->produit->creer && ! $user->rights->service->creer) { $createok=0; $nbko++; }
224
-            }
225
-            else if ($feature == 'prelevement')
253
+            } else if ($feature == 'prelevement')
226 254
             {
227 255
                 if (! $user->rights->prelevement->bons->creer) { $createok=0; $nbko++; }
228
-            }
229
-            else if ($feature == 'commande_fournisseur')
256
+            } else if ($feature == 'commande_fournisseur')
230 257
             {
231 258
                 if (! $user->rights->fournisseur->commande->creer) { $createok=0; $nbko++; }
232
-            }
233
-            else if ($feature == 'banque')
259
+            } else if ($feature == 'banque')
234 260
             {
235 261
                 if (! $user->rights->banque->modifier) { $createok=0; $nbko++; }
236
-            }
237
-            else if ($feature == 'cheque')
262
+            } else if ($feature == 'cheque')
238 263
             {
239 264
                 if (! $user->rights->banque->cheque) { $createok=0; $nbko++; }
240
-            }
241
-            else if (! empty($feature2))	// This should be used
265
+            } else if (! empty($feature2)) {
266
+            	// This should be used
242 267
             {
243 268
             	foreach($feature2 as $subfeature)
244 269
             	{
245 270
             		if (empty($user->rights->$feature->$subfeature->creer)
246 271
             		&& empty($user->rights->$feature->$subfeature->write)
247
-            		&& empty($user->rights->$feature->$subfeature->create)) { $createok=0; $nbko++; }
248
-            		else { $createok=1; break; } // Break to bypass second test if the first is ok
249
-            	}
272
+            		&& empty($user->rights->$feature->$subfeature->create)) { $createok=0;
250 273
             }
251
-            else if (! empty($feature))		// This is for old permissions ('creer' or 'write')
274
+            $nbko++; } else { $createok=1; break; } // Break to bypass second test if the first is ok
275
+            	}
276
+            } else if (! empty($feature)) {
277
+            	// This is for old permissions ('creer' or 'write')
252 278
             {
253 279
                 //print '<br>feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write;
254 280
                 if (empty($user->rights->$feature->creer)
255 281
                 && empty($user->rights->$feature->write)
256
-                && empty($user->rights->$feature->create)) { $createok=0; $nbko++; }
282
+                && empty($user->rights->$feature->create)) { $createok=0;
283
+            }
284
+            $nbko++; }
257 285
             }
258 286
         }
259 287
 
260 288
 	    // If a or and at least one ok
261
-	    if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok=1;
289
+	    if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) {
290
+	    	$createok=1;
291
+	    }
262 292
 
263
-        if (! $createok) accessforbidden();
293
+        if (! $createok) {
294
+        	accessforbidden();
295
+        }
264 296
         //print "Write access is ok";
265 297
     }
266 298
 
@@ -268,9 +300,13 @@  discard block
 block discarded – undo
268 300
     $createuserok=1;
269 301
     if (GETPOST('action','aZ09') == 'confirm_create_user' && GETPOST("confirm") == 'yes')
270 302
     {
271
-        if (! $user->rights->user->user->creer) $createuserok=0;
303
+        if (! $user->rights->user->user->creer) {
304
+        	$createuserok=0;
305
+        }
272 306
 
273
-        if (! $createuserok) accessforbidden();
307
+        if (! $createuserok) {
308
+        	accessforbidden();
309
+        }
274 310
         //print "Create user access is ok";
275 311
     }
276 312
 
@@ -282,57 +318,71 @@  discard block
 block discarded – undo
282 318
         {
283 319
             if ($feature == 'contact')
284 320
             {
285
-                if (! $user->rights->societe->contact->supprimer) $deleteok=0;
286
-            }
287
-            else if ($feature == 'produit|service')
321
+                if (! $user->rights->societe->contact->supprimer) {
322
+                	$deleteok=0;
323
+                }
324
+            } else if ($feature == 'produit|service')
288 325
             {
289
-                if (! $user->rights->produit->supprimer && ! $user->rights->service->supprimer) $deleteok=0;
290
-            }
291
-            else if ($feature == 'commande_fournisseur')
326
+                if (! $user->rights->produit->supprimer && ! $user->rights->service->supprimer) {
327
+                	$deleteok=0;
328
+                }
329
+            } else if ($feature == 'commande_fournisseur')
292 330
             {
293
-                if (! $user->rights->fournisseur->commande->supprimer) $deleteok=0;
294
-            }
295
-            else if ($feature == 'banque')
331
+                if (! $user->rights->fournisseur->commande->supprimer) {
332
+                	$deleteok=0;
333
+                }
334
+            } else if ($feature == 'banque')
296 335
             {
297
-                if (! $user->rights->banque->modifier) $deleteok=0;
298
-            }
299
-            else if ($feature == 'cheque')
336
+                if (! $user->rights->banque->modifier) {
337
+                	$deleteok=0;
338
+                }
339
+            } else if ($feature == 'cheque')
300 340
             {
301
-                if (! $user->rights->banque->cheque) $deleteok=0;
302
-            }
303
-            else if ($feature == 'ecm')
341
+                if (! $user->rights->banque->cheque) {
342
+                	$deleteok=0;
343
+                }
344
+            } else if ($feature == 'ecm')
304 345
             {
305
-                if (! $user->rights->ecm->upload) $deleteok=0;
306
-            }
307
-            else if ($feature == 'ftp')
346
+                if (! $user->rights->ecm->upload) {
347
+                	$deleteok=0;
348
+                }
349
+            } else if ($feature == 'ftp')
308 350
             {
309
-                if (! $user->rights->ftp->write) $deleteok=0;
310
-            }
311
-            else if ($feature == 'salaries')
351
+                if (! $user->rights->ftp->write) {
352
+                	$deleteok=0;
353
+                }
354
+            } else if ($feature == 'salaries')
312 355
             {
313
-                if (! $user->rights->salaries->delete) $deleteok=0;
314
-            }
315
-            else if (! empty($feature2))	// This should be used for future changes
356
+                if (! $user->rights->salaries->delete) {
357
+                	$deleteok=0;
358
+                }
359
+            } else if (! empty($feature2)) {
360
+            	// This should be used for future changes
316 361
             {
317 362
             	foreach($feature2 as $subfeature)
318 363
             	{
319 364
             		if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok=0;
320
-            		else { $deleteok=1; break; } // For bypass the second test if the first is ok
365
+            } else { $deleteok=1; break; } // For bypass the second test if the first is ok
321 366
             	}
322
-            }
323
-            else if (! empty($feature))		// This is for old permissions
367
+            } else if (! empty($feature)) {
368
+            	// This is for old permissions
324 369
             {
325 370
                 //print '<br>feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete;
326 371
                 if (empty($user->rights->$feature->supprimer)
327 372
                 && empty($user->rights->$feature->delete)
328 373
                 && empty($user->rights->$feature->run)) $deleteok=0;
329 374
             }
375
+            }
330 376
         }
331 377
 
332 378
 	    // If a or and at least one ok
333
-	    if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $deleteok=1;
379
+	    if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) {
380
+	    	$deleteok=1;
381
+	    }
334 382
 
335
-        if (! $deleteok) accessforbidden();
383
+        if (! $deleteok) {
384
+        	accessforbidden();
385
+        }
336 386
         //print "Delete access is ok";
337 387
     }
338 388
 
@@ -375,9 +425,15 @@  discard block
 block discarded – undo
375 425
 		$sql='';
376 426
 
377 427
 		// For backward compatibility
378
-		if ($feature == 'member') $feature='adherent';
379
-		if ($feature == 'project') $feature='projet';
380
-		if ($feature == 'task') $feature='projet_task';
428
+		if ($feature == 'member') {
429
+			$feature='adherent';
430
+		}
431
+		if ($feature == 'project') {
432
+			$feature='projet';
433
+		}
434
+		if ($feature == 'task') {
435
+			$feature='projet_task';
436
+		}
381 437
 
382 438
 		$check = array('adherent','banque','user','usergroup','produit','service','produit|service','categorie'); // Test on entity only (Objects with no link to company)
383 439
 		$checksoc = array('societe');	 // Test for societe object
@@ -388,7 +444,9 @@  discard block
 block discarded – undo
388 444
 		$checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...).
389 445
 
390 446
 		// If dbtable not defined, we use same name for table than module name
391
-		if (empty($dbtablename)) $dbtablename = $feature;
447
+		if (empty($dbtablename)) {
448
+			$dbtablename = $feature;
449
+		}
392 450
 
393 451
 		// Check permission for object with entity
394 452
 		if (in_array($feature,$check))
@@ -399,18 +457,18 @@  discard block
 block discarded – undo
399 457
 			if (($feature == 'user' || $feature == 'usergroup') && ! empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && ! $user->entity)
400 458
 			{
401 459
 				$sql.= " AND dbt.entity IS NOT NULL";
402
-			}
403
-			else
460
+			} else
404 461
 			{
405 462
 				$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
406 463
 			}
407
-		}
408
-		else if (in_array($feature,$checksoc))	// We check feature = checksoc
464
+		} else if (in_array($feature,$checksoc)) {
465
+			// We check feature = checksoc
409 466
 		{
410 467
 			// If external user: Check permission for external users
411 468
 			if ($user->socid > 0)
412 469
 			{
413 470
 				if ($user->socid <> $objectid) return false;
471
+		}
414 472
 			}
415 473
 			// If internal user: Check permission for internal users that are restricted on their objects
416 474
 			else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir))
@@ -431,13 +489,14 @@  discard block
 block discarded – undo
431 489
 				$sql.= " WHERE s.rowid = ".$objectid;
432 490
 				$sql.= " AND s.entity IN (".getEntity($sharedelement, 1).")";
433 491
 			}
434
-		}
435
-		else if (in_array($feature,$checkother))	// Test on entity and link to societe. Allowed if link is empty (Ex: contacts...).
492
+		} else if (in_array($feature,$checkother)) {
493
+			// Test on entity and link to societe. Allowed if link is empty (Ex: contacts...).
436 494
 		{
437 495
 			// If external user: Check permission for external users
438 496
 			if ($user->societe_id > 0)
439 497
 			{
440 498
 				$sql = "SELECT dbt.".$dbt_select;
499
+		}
441 500
 				$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
442 501
 				$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
443 502
 				$sql.= " AND dbt.fk_soc = ".$user->societe_id;
@@ -460,8 +519,7 @@  discard block
 block discarded – undo
460 519
 				$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
461 520
 				$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
462 521
 			}
463
-		}
464
-		else if (in_array($feature,$checkproject))
522
+		} else if (in_array($feature,$checkproject))
465 523
 		{
466 524
 			if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire))
467 525
 			{
@@ -469,17 +527,17 @@  discard block
 block discarded – undo
469 527
 				$projectstatic=new Project($db);
470 528
 				$tmps=$projectstatic->getProjectsAuthorizedForUser($user,0,1,0);
471 529
 				$tmparray=explode(',',$tmps);
472
-				if (! in_array($objectid,$tmparray)) return false;
473
-			}
474
-			else
530
+				if (! in_array($objectid,$tmparray)) {
531
+					return false;
532
+				}
533
+			} else
475 534
 			{
476 535
 				$sql = "SELECT dbt.".$dbt_select;
477 536
 				$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
478 537
 				$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
479 538
 				$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
480 539
 			}
481
-		}
482
-		else if (in_array($feature,$checktask))
540
+		} else if (in_array($feature,$checktask))
483 541
 		{
484 542
 			if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire))
485 543
 			{
@@ -490,22 +548,24 @@  discard block
 block discarded – undo
490 548
 				$projectstatic=new Project($db);
491 549
 				$tmps=$projectstatic->getProjectsAuthorizedForUser($user,0,1,0);
492 550
 				$tmparray=explode(',',$tmps);
493
-				if (! in_array($task->fk_project,$tmparray)) return false;
494
-			}
495
-			else
551
+				if (! in_array($task->fk_project,$tmparray)) {
552
+					return false;
553
+				}
554
+			} else
496 555
 			{
497 556
 				$sql = "SELECT dbt.".$dbt_select;
498 557
 				$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
499 558
 				$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
500 559
 				$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
501 560
 			}
502
-		}
503
-		else if (! in_array($feature,$nocheck))	// By default we check with link to third party
561
+		} else if (! in_array($feature,$nocheck)) {
562
+			// By default we check with link to third party
504 563
 		{
505 564
 			// If external user: Check permission for external users
506 565
 			if ($user->societe_id > 0)
507 566
 			{
508 567
 				if (empty($dbt_keyfield)) dol_print_error('','Param dbt_keyfield is required but not defined');
568
+		}
509 569
 				$sql = "SELECT dbt.".$dbt_keyfield;
510 570
 				$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
511 571
 				$sql.= " WHERE dbt.rowid = ".$objectid;
@@ -514,7 +574,9 @@  discard block
 block discarded – undo
514 574
 			// If internal user: Check permission for internal users that are restricted on their objects
515 575
 			else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir))
516 576
 			{
517
-				if (empty($dbt_keyfield)) dol_print_error('','Param dbt_keyfield is required but not defined');
577
+				if (empty($dbt_keyfield)) {
578
+					dol_print_error('','Param dbt_keyfield is required but not defined');
579
+				}
518 580
 				$sql = "SELECT sc.fk_soc";
519 581
 				$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
520 582
 				$sql.= ", ".MAIN_DB_PREFIX."societe as s";
@@ -541,9 +603,10 @@  discard block
 block discarded – undo
541 603
 			$resql=$db->query($sql);
542 604
 			if ($resql)
543 605
 			{
544
-				if ($db->num_rows($resql) == 0)	return false;
545
-			}
546
-			else
606
+				if ($db->num_rows($resql) == 0) {
607
+					return false;
608
+				}
609
+			} else
547 610
 			{
548 611
 				return false;
549 612
 			}
@@ -575,12 +638,18 @@  discard block
 block discarded – undo
575 638
 
576 639
     if ($printheader)
577 640
     {
578
-        if (function_exists("llxHeader")) llxHeader('');
579
-        else if (function_exists("llxHeaderVierge")) llxHeaderVierge('');
641
+        if (function_exists("llxHeader")) {
642
+        	llxHeader('');
643
+        } else if (function_exists("llxHeaderVierge")) {
644
+        	llxHeaderVierge('');
645
+        }
580 646
     }
581 647
     print '<div class="error">';
582
-    if (! $message) print $langs->trans("ErrorForbidden");
583
-    else print $message;
648
+    if (! $message) {
649
+    	print $langs->trans("ErrorForbidden");
650
+    } else {
651
+    	print $message;
652
+    }
584 653
     print '</div>';
585 654
     print '<br>';
586 655
     if (empty($showonlymessage))
@@ -589,13 +658,14 @@  discard block
 block discarded – undo
589 658
         {
590 659
             print $langs->trans("CurrentLogin").': <font class="error">'.$user->login.'</font><br>';
591 660
             print $langs->trans("ErrorForbidden2",$langs->trans("Home"),$langs->trans("Users"));
592
-        }
593
-        else
661
+        } else
594 662
         {
595 663
             print $langs->trans("ErrorForbidden3");
596 664
         }
597 665
     }
598
-    if ($printfooter && function_exists("llxFooter")) llxFooter();
666
+    if ($printfooter && function_exists("llxFooter")) {
667
+    	llxFooter();
668
+    }
599 669
     exit(0);
600 670
 }
601 671
 
Please login to merge, or discard this patch.
htdocs/core/lib/files.lib.php 3 patches
Indentation   +705 added lines, -705 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function dol_basename($pathfile)
36 36
 {
37
-    return preg_replace('/^.*\/([^\/]+)$/','$1',rtrim($pathfile,'/'));
37
+	return preg_replace('/^.*\/([^\/]+)$/','$1',rtrim($pathfile,'/'));
38 38
 }
39 39
 
40 40
 /**
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 
76 76
 	if (is_object($hookmanager) && ! $nohook)
77 77
 	{
78
-	    $hookmanager->resArray=array();
78
+		$hookmanager->resArray=array();
79 79
 
80
-	    $hookmanager->initHooks(array('fileslib'));
80
+		$hookmanager->initHooks(array('fileslib'));
81 81
 
82 82
 		$parameters=array(
83 83
 				'path' => $newpath,
@@ -221,66 +221,66 @@  discard block
 block discarded – undo
221 221
  */
222 222
 function dol_dir_list_in_database($path, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0)
223 223
 {
224
-    global $conf, $db;
225
-
226
-    $sql=" SELECT rowid, label, entity, filename, filepath, fullpath_orig, keywords, cover, gen_or_uploaded, extraparams, date_c, date_m, fk_user_c, fk_user_m, acl, position";
227
-    if ($mode) $sql.=", description";
228
-    $sql.=" FROM ".MAIN_DB_PREFIX."ecm_files";
229
-    $sql.=" WHERE filepath = '".$db->escape($path)."'";
230
-    $sql.=" AND entity = ".$conf->entity;
231
-
232
-    $resql = $db->query($sql);
233
-    if ($resql)
234
-    {
235
-        $file_list=array();
236
-        $num = $db->num_rows($resql);
237
-        $i = 0;
238
-        while ($i < $num)
239
-        {
240
-            $obj = $db->fetch_object($resql);
241
-            if ($obj)
242
-            {
243
-                preg_match('/([^\/]+)\/[^\/]+$/',DOL_DATA_ROOT.'/'.$obj->filepath.'/'.$obj->filename,$reg);
244
-                $level1name=(isset($reg[1])?$reg[1]:'');
245
-                $file_list[] = array(
246
-                    "rowid" => $obj->rowid,
247
-                    "label" => $obj->label,         // md5
248
-    				"name" => $obj->filename,
249
-    				"path" => DOL_DATA_ROOT.'/'.$obj->filepath,
250
-                    "level1name" => $level1name,
251
-    				"fullname" => DOL_DATA_ROOT.'/'.$obj->filepath.'/'.$obj->filename,
252
-    				"fullpath_orig" => $obj->fullpath_orig,
253
-                    "date_c" => $db->jdate($obj->date_c),
254
-                    "date_m" => $db->jdate($obj->date_m),
255
-    				"type" => 'file',
256
-                    "keywords" => $obj->keywords,
257
-                    "cover" => $obj->cover,
258
-                    "position" => (int) $obj->position,
259
-                    "acl" => $obj->acl
260
-                );
261
-            }
262
-            $i++;
263
-        }
264
-
265
-        // Obtain a list of columns
266
-        if (! empty($sortcriteria))
267
-        {
268
-            $myarray=array();
269
-            foreach ($file_list as $key => $row)
270
-            {
271
-                $myarray[$key] = (isset($row[$sortcriteria])?$row[$sortcriteria]:'');
272
-            }
273
-            // Sort the data
274
-            if ($sortorder) array_multisort($myarray, $sortorder, $file_list);
275
-        }
276
-
277
-        return $file_list;
278
-    }
279
-    else
280
-    {
281
-        dol_print_error($db);
282
-        return array();
283
-    }
224
+	global $conf, $db;
225
+
226
+	$sql=" SELECT rowid, label, entity, filename, filepath, fullpath_orig, keywords, cover, gen_or_uploaded, extraparams, date_c, date_m, fk_user_c, fk_user_m, acl, position";
227
+	if ($mode) $sql.=", description";
228
+	$sql.=" FROM ".MAIN_DB_PREFIX."ecm_files";
229
+	$sql.=" WHERE filepath = '".$db->escape($path)."'";
230
+	$sql.=" AND entity = ".$conf->entity;
231
+
232
+	$resql = $db->query($sql);
233
+	if ($resql)
234
+	{
235
+		$file_list=array();
236
+		$num = $db->num_rows($resql);
237
+		$i = 0;
238
+		while ($i < $num)
239
+		{
240
+			$obj = $db->fetch_object($resql);
241
+			if ($obj)
242
+			{
243
+				preg_match('/([^\/]+)\/[^\/]+$/',DOL_DATA_ROOT.'/'.$obj->filepath.'/'.$obj->filename,$reg);
244
+				$level1name=(isset($reg[1])?$reg[1]:'');
245
+				$file_list[] = array(
246
+					"rowid" => $obj->rowid,
247
+					"label" => $obj->label,         // md5
248
+					"name" => $obj->filename,
249
+					"path" => DOL_DATA_ROOT.'/'.$obj->filepath,
250
+					"level1name" => $level1name,
251
+					"fullname" => DOL_DATA_ROOT.'/'.$obj->filepath.'/'.$obj->filename,
252
+					"fullpath_orig" => $obj->fullpath_orig,
253
+					"date_c" => $db->jdate($obj->date_c),
254
+					"date_m" => $db->jdate($obj->date_m),
255
+					"type" => 'file',
256
+					"keywords" => $obj->keywords,
257
+					"cover" => $obj->cover,
258
+					"position" => (int) $obj->position,
259
+					"acl" => $obj->acl
260
+				);
261
+			}
262
+			$i++;
263
+		}
264
+
265
+		// Obtain a list of columns
266
+		if (! empty($sortcriteria))
267
+		{
268
+			$myarray=array();
269
+			foreach ($file_list as $key => $row)
270
+			{
271
+				$myarray[$key] = (isset($row[$sortcriteria])?$row[$sortcriteria]:'');
272
+			}
273
+			// Sort the data
274
+			if ($sortorder) array_multisort($myarray, $sortorder, $file_list);
275
+		}
276
+
277
+		return $file_list;
278
+	}
279
+	else
280
+	{
281
+		dol_print_error($db);
282
+		return array();
283
+	}
284 284
 }
285 285
 
286 286
 
@@ -411,9 +411,9 @@  discard block
 block discarded – undo
411 411
  */
412 412
 function dol_is_dir($folder)
413 413
 {
414
-    $newfolder=dol_osencode($folder);
415
-    if (is_dir($newfolder)) return true;
416
-    else return false;
414
+	$newfolder=dol_osencode($folder);
415
+	if (is_dir($newfolder)) return true;
416
+	else return false;
417 417
 }
418 418
 
419 419
 /**
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
  */
425 425
 function dol_is_file($pathoffile)
426 426
 {
427
-    $newpathoffile=dol_osencode($pathoffile);
428
-    return is_file($newpathoffile);
427
+	$newpathoffile=dol_osencode($pathoffile);
428
+	return is_file($newpathoffile);
429 429
 }
430 430
 
431 431
 /**
@@ -436,12 +436,12 @@  discard block
 block discarded – undo
436 436
  */
437 437
 function dol_is_url($url)
438 438
 {
439
-    $tmpprot=array('file','http','https','ftp','zlib','data','ssh','ssh2','ogg','expect');
440
-    foreach($tmpprot as $prot)
441
-    {
442
-        if (preg_match('/^'.$prot.':/i',$url)) return true;
443
-    }
444
-    return false;
439
+	$tmpprot=array('file','http','https','ftp','zlib','data','ssh','ssh2','ogg','expect');
440
+	foreach($tmpprot as $prot)
441
+	{
442
+		if (preg_match('/^'.$prot.':/i',$url)) return true;
443
+	}
444
+	return false;
445 445
 }
446 446
 
447 447
 /**
@@ -456,14 +456,14 @@  discard block
 block discarded – undo
456 456
 	if (is_dir($newfolder))
457 457
 	{
458 458
 		$handle = opendir($newfolder);
459
-        $folder_content = '';
459
+		$folder_content = '';
460 460
 		while ((gettype($name = readdir($handle)) != "boolean"))
461 461
 		{
462 462
 			$name_array[] = $name;
463 463
 		}
464 464
 		foreach($name_array as $temp) $folder_content .= $temp;
465 465
 
466
-        closedir($handle);
466
+		closedir($handle);
467 467
 
468 468
 		if ($folder_content == "...") return true;
469 469
 		else return false;
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 		while (!feof($fp))
492 492
 		{
493 493
 			$line=fgets($fp);
494
-            // We increase count only if read was success. We need test because feof return true only after fgets so we do n+1 fgets for a file with n lines.
494
+			// We increase count only if read was success. We need test because feof return true only after fgets so we do n+1 fgets for a file with n lines.
495 495
 			if (! $line === false) $nb++;
496 496
 		}
497 497
 		fclose($fp);
@@ -542,61 +542,61 @@  discard block
 block discarded – undo
542 542
  */
543 543
 function dolReplaceInFile($srcfile, $arrayreplacement, $destfile='', $newmask=0, $indexdatabase=0)
544 544
 {
545
-    global $conf;
545
+	global $conf;
546 546
 
547
-    dol_syslog("files.lib.php::dolReplaceInFile srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." indexdatabase=".$indexdatabase);
547
+	dol_syslog("files.lib.php::dolReplaceInFile srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." indexdatabase=".$indexdatabase);
548 548
 
549
-    if (empty($srcfile)) return -1;
550
-    if (empty($destfile)) $destfile=$srcfile;
549
+	if (empty($srcfile)) return -1;
550
+	if (empty($destfile)) $destfile=$srcfile;
551 551
 
552
-    $destexists=dol_is_file($destfile);
553
-    if (($destfile != $srcfile) && $destexists) return 0;
552
+	$destexists=dol_is_file($destfile);
553
+	if (($destfile != $srcfile) && $destexists) return 0;
554 554
 
555
-    $tmpdestfile=$destfile.'.tmp';
555
+	$tmpdestfile=$destfile.'.tmp';
556 556
 
557
-    $newpathofsrcfile=dol_osencode($srcfile);
558
-    $newpathoftmpdestfile=dol_osencode($tmpdestfile);
559
-    $newpathofdestfile=dol_osencode($destfile);
560
-    $newdirdestfile=dirname($newpathofdestfile);
557
+	$newpathofsrcfile=dol_osencode($srcfile);
558
+	$newpathoftmpdestfile=dol_osencode($tmpdestfile);
559
+	$newpathofdestfile=dol_osencode($destfile);
560
+	$newdirdestfile=dirname($newpathofdestfile);
561 561
 
562
-    if ($destexists && ! is_writable($newpathofdestfile))
563
-    {
564
-        dol_syslog("files.lib.php::dolReplaceInFile failed Permission denied to overwrite target file", LOG_WARNING);
565
-        return -1;
566
-    }
567
-    if (! is_writable($newdirdestfile))
568
-    {
569
-        dol_syslog("files.lib.php::dolReplaceInFile failed Permission denied to write into target directory ".$newdirdestfile, LOG_WARNING);
570
-        return -2;
571
-    }
562
+	if ($destexists && ! is_writable($newpathofdestfile))
563
+	{
564
+		dol_syslog("files.lib.php::dolReplaceInFile failed Permission denied to overwrite target file", LOG_WARNING);
565
+		return -1;
566
+	}
567
+	if (! is_writable($newdirdestfile))
568
+	{
569
+		dol_syslog("files.lib.php::dolReplaceInFile failed Permission denied to write into target directory ".$newdirdestfile, LOG_WARNING);
570
+		return -2;
571
+	}
572 572
 
573
-    dol_delete_file($tmpdestfile);
573
+	dol_delete_file($tmpdestfile);
574 574
 
575
-    // Create $newpathoftmpdestfile from $newpathofsrcfile
576
-    $content=file_get_contents($newpathofsrcfile, 'r');
575
+	// Create $newpathoftmpdestfile from $newpathofsrcfile
576
+	$content=file_get_contents($newpathofsrcfile, 'r');
577 577
 
578
-    $content = make_substitutions($content, $arrayreplacement, null);
578
+	$content = make_substitutions($content, $arrayreplacement, null);
579 579
 
580
-    file_put_contents($newpathoftmpdestfile, $content);
581
-    @chmod($newpathoftmpdestfile, octdec($newmask));
580
+	file_put_contents($newpathoftmpdestfile, $content);
581
+	@chmod($newpathoftmpdestfile, octdec($newmask));
582 582
 
583
-    // Rename
584
-    $result=dol_move($newpathoftmpdestfile, $newpathofdestfile, $newmask, (($destfile == $srcfile)?1:0), 0, $indexdatabase);
585
-    if (! $result)
586
-    {
587
-        dol_syslog("files.lib.php::dolReplaceInFile failed to move tmp file to final dest", LOG_WARNING);
588
-        return -3;
589
-    }
590
-    if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
591
-    if (empty($newmask))	// This should no happen
592
-    {
593
-        dol_syslog("Warning: dolReplaceInFile called with empty value for newmask and no default value defined", LOG_WARNING);
594
-        $newmask='0664';
595
-    }
583
+	// Rename
584
+	$result=dol_move($newpathoftmpdestfile, $newpathofdestfile, $newmask, (($destfile == $srcfile)?1:0), 0, $indexdatabase);
585
+	if (! $result)
586
+	{
587
+		dol_syslog("files.lib.php::dolReplaceInFile failed to move tmp file to final dest", LOG_WARNING);
588
+		return -3;
589
+	}
590
+	if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
591
+	if (empty($newmask))	// This should no happen
592
+	{
593
+		dol_syslog("Warning: dolReplaceInFile called with empty value for newmask and no default value defined", LOG_WARNING);
594
+		$newmask='0664';
595
+	}
596 596
 
597
-    @chmod($newpathofdestfile, octdec($newmask));
597
+	@chmod($newpathofdestfile, octdec($newmask));
598 598
 
599
-    return 1;
599
+	return 1;
600 600
 }
601 601
 
602 602
 /**
@@ -638,26 +638,26 @@  discard block
 block discarded – undo
638 638
 	if (! $overwriteifexists && $destexists) return 0;
639 639
 
640 640
 	$newpathofsrcfile=dol_osencode($srcfile);
641
-    $newpathofdestfile=dol_osencode($destfile);
642
-    $newdirdestfile=dirname($newpathofdestfile);
643
-
644
-    if ($destexists && ! is_writable($newpathofdestfile))
645
-    {
646
-        dol_syslog("files.lib.php::dol_copy failed Permission denied to overwrite target file", LOG_WARNING);
647
-        return -1;
648
-    }
649
-    if (! is_writable($newdirdestfile))
650
-    {
651
-        dol_syslog("files.lib.php::dol_copy failed Permission denied to write into target directory ".$newdirdestfile, LOG_WARNING);
652
-        return -2;
653
-    }
654
-    // Copy with overwriting if exists
655
-    $result=@copy($newpathofsrcfile, $newpathofdestfile);
641
+	$newpathofdestfile=dol_osencode($destfile);
642
+	$newdirdestfile=dirname($newpathofdestfile);
643
+
644
+	if ($destexists && ! is_writable($newpathofdestfile))
645
+	{
646
+		dol_syslog("files.lib.php::dol_copy failed Permission denied to overwrite target file", LOG_WARNING);
647
+		return -1;
648
+	}
649
+	if (! is_writable($newdirdestfile))
650
+	{
651
+		dol_syslog("files.lib.php::dol_copy failed Permission denied to write into target directory ".$newdirdestfile, LOG_WARNING);
652
+		return -2;
653
+	}
654
+	// Copy with overwriting if exists
655
+	$result=@copy($newpathofsrcfile, $newpathofdestfile);
656 656
 	//$result=copy($newpathofsrcfile, $newpathofdestfile);	// To see errors, remove @
657 657
 	if (! $result)
658 658
 	{
659
-	    dol_syslog("files.lib.php::dol_copy failed to copy", LOG_WARNING);
660
-	    return -3;
659
+		dol_syslog("files.lib.php::dol_copy failed to copy", LOG_WARNING);
660
+		return -3;
661 661
 	}
662 662
 	if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
663 663
 	if (empty($newmask))	// This should no happen
@@ -695,33 +695,33 @@  discard block
 block discarded – undo
695 695
 	$destexists=dol_is_dir($destfile);
696 696
 	//if (! $overwriteifexists && $destexists) return 0;	// The overwriteifexists is for files only, so propagated to dol_copy only.
697 697
 
698
-    if (! $destexists)
699
-    {
700
-        // We must set mask just before creating dir, becaause it can be set differently by dol_copy
701
-        umask(0);
702
-        $dirmaskdec=octdec($newmask);
703
-        if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK);
704
-        $dirmaskdec |= octdec('0200');  // Set w bit required to be able to create content for recursive subdirs files
705
-        dol_mkdir($destfile, '', decoct($dirmaskdec));
706
-    }
698
+	if (! $destexists)
699
+	{
700
+		// We must set mask just before creating dir, becaause it can be set differently by dol_copy
701
+		umask(0);
702
+		$dirmaskdec=octdec($newmask);
703
+		if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK);
704
+		$dirmaskdec |= octdec('0200');  // Set w bit required to be able to create content for recursive subdirs files
705
+		dol_mkdir($destfile, '', decoct($dirmaskdec));
706
+	}
707 707
 
708 708
 	$ossrcfile=dol_osencode($srcfile);
709 709
 	$osdestfile=dol_osencode($destfile);
710 710
 
711
-    // Recursive function to copy all subdirectories and contents:
711
+	// Recursive function to copy all subdirectories and contents:
712 712
 	if (is_dir($ossrcfile))
713 713
 	{
714
-        $dir_handle=opendir($ossrcfile);
715
-        while ($file=readdir($dir_handle))
716
-        {
717
-            if ($file != "." && $file != ".." && ! is_link($ossrcfile."/".$file))
718
-            {
719
-                if (is_dir($ossrcfile."/".$file))
720
-                {
721
-                    //var_dump("xxx dolCopyDir $srcfile/$file, $destfile/$file, $newmask, $overwriteifexists");
722
-                    $tmpresult=dolCopyDir($srcfile."/".$file, $destfile."/".$file, $newmask, $overwriteifexists, $arrayreplacement);
723
-                }
724
-                else
714
+		$dir_handle=opendir($ossrcfile);
715
+		while ($file=readdir($dir_handle))
716
+		{
717
+			if ($file != "." && $file != ".." && ! is_link($ossrcfile."/".$file))
718
+			{
719
+				if (is_dir($ossrcfile."/".$file))
720
+				{
721
+					//var_dump("xxx dolCopyDir $srcfile/$file, $destfile/$file, $newmask, $overwriteifexists");
722
+					$tmpresult=dolCopyDir($srcfile."/".$file, $destfile."/".$file, $newmask, $overwriteifexists, $arrayreplacement);
723
+				}
724
+				else
725 725
 				{
726 726
 					$newfile = $file;
727 727
 					// Replace destination filename with a new one
@@ -732,30 +732,30 @@  discard block
 block discarded – undo
732 732
 							$newfile = str_replace($key, $val, $newfile);
733 733
 						}
734 734
 					}
735
-                    $tmpresult=dol_copy($srcfile."/".$file, $destfile."/".$newfile, $newmask, $overwriteifexists);
736
-                }
737
-                // Set result
738
-                if ($result > 0 && $tmpresult >= 0)
739
-                {
740
-                    // Do nothing, so we don't set result to 0 if tmpresult is 0 and result was success in a previous pass
741
-                }
742
-                else
743
-                {
744
-                    $result=$tmpresult;
745
-                }
746
-                if ($result < 0) break;
735
+					$tmpresult=dol_copy($srcfile."/".$file, $destfile."/".$newfile, $newmask, $overwriteifexists);
736
+				}
737
+				// Set result
738
+				if ($result > 0 && $tmpresult >= 0)
739
+				{
740
+					// Do nothing, so we don't set result to 0 if tmpresult is 0 and result was success in a previous pass
741
+				}
742
+				else
743
+				{
744
+					$result=$tmpresult;
745
+				}
746
+				if ($result < 0) break;
747 747
 
748
-            }
749
-        }
750
-        closedir($dir_handle);
751
-    }
752
-    else
748
+			}
749
+		}
750
+		closedir($dir_handle);
751
+	}
752
+	else
753 753
 	{
754 754
 		// Source directory does not exists
755
-        $result = -2;
756
-    }
755
+		$result = -2;
756
+	}
757 757
 
758
-    return $result;
758
+	return $result;
759 759
 }
760 760
 
761 761
 
@@ -777,123 +777,123 @@  discard block
 block discarded – undo
777 777
  */
778 778
 function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvirus=0, $indexdatabase=1)
779 779
 {
780
-    global $user, $db, $conf;
781
-    $result=false;
782
-
783
-    dol_syslog("files.lib.php::dol_move srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwritifexists=".$overwriteifexists);
784
-    $srcexists=dol_is_file($srcfile);
785
-    $destexists=dol_is_file($destfile);
786
-
787
-    if (! $srcexists)
788
-    {
789
-        dol_syslog("files.lib.php::dol_move srcfile does not exists. we ignore the move request.");
790
-        return false;
791
-    }
792
-
793
-    if ($overwriteifexists || ! $destexists)
794
-    {
795
-        $newpathofsrcfile=dol_osencode($srcfile);
796
-        $newpathofdestfile=dol_osencode($destfile);
797
-
798
-        // Check virus
799
-        $testvirusarray=array();
800
-        if ($testvirus)
801
-        {
802
-            $testvirusarray=dolCheckVirus($newpathofsrcfile);
803
-            if (count($testvirusarray))
804
-            {
805
-                dol_syslog("files.lib.php::dol_move canceled because a virus was found into source file. we ignore the move request.", LOG_WARNING);
806
-                return false;
807
-            }
808
-        }
809
-
810
-        $result=@rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @
811
-        if (! $result)
812
-        {
813
-        	if ($destexists)
814
-        	{
815
-        		dol_syslog("files.lib.php::dol_move Failed. We try to delete target first and move after.", LOG_WARNING);
816
-        		// We force delete and try again. Rename function sometimes fails to replace dest file with some windows NTFS partitions.
817
-        		dol_delete_file($destfile);
818
-        		$result=@rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @
819
-        	}
820
-        	else dol_syslog("files.lib.php::dol_move Failed.", LOG_WARNING);
821
-        }
822
-
823
-        // Move ok
824
-        if ($result && $indexdatabase)
825
-        {
826
-            // Rename entry into ecm database
827
-            $rel_filetorenamebefore = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $srcfile);
828
-            $rel_filetorenameafter = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $destfile);
829
-            if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter))     // If not a tmp file
830
-            {
831
-                $rel_filetorenamebefore = preg_replace('/^[\\/]/', '', $rel_filetorenamebefore);
832
-                $rel_filetorenameafter = preg_replace('/^[\\/]/', '', $rel_filetorenameafter);
833
-                //var_dump($rel_filetorenamebefore.' - '.$rel_filetorenameafter);
834
-
835
-                dol_syslog("Try to rename also entries in database for full relative path before = ".$rel_filetorenamebefore." after = ".$rel_filetorenameafter, LOG_DEBUG);
836
-                include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
837
-
838
-                $ecmfiletarget=new EcmFiles($db);
839
-                $resultecmtarget = $ecmfiletarget->fetch(0, '', $rel_filetorenameafter);
840
-                if ($resultecmtarget > 0)   // An entry for target name already exists for target, we delete it, a new one will be created.
841
-                {
842
-                    $ecmfiletarget->delete($user);
843
-                }
844
-
845
-                $ecmfile=new EcmFiles($db);
846
-                $resultecm = $ecmfile->fetch(0, '', $rel_filetorenamebefore);
847
-                if ($resultecm > 0)   // If an entry was found for src file, we use it to move entry
848
-                {
849
-                    $filename = basename($rel_filetorenameafter);
850
-                    $rel_dir = dirname($rel_filetorenameafter);
851
-                    $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
852
-                    $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
853
-
854
-                    $ecmfile->filepath = $rel_dir;
855
-                    $ecmfile->filename = $filename;
856
-                    $resultecm = $ecmfile->update($user);
857
-                }
858
-                elseif ($resultecm == 0)   // If no entry were found for src files, create/update target file
859
-                {
860
-                    $filename = basename($rel_filetorenameafter);
861
-                    $rel_dir = dirname($rel_filetorenameafter);
862
-                    $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
863
-                    $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
864
-
865
-                    $ecmfile->filepath = $rel_dir;
866
-                    $ecmfile->filename = $filename;
867
-                    $ecmfile->label = md5_file(dol_osencode($destfile));        // $destfile is a full path to file
868
-                    $ecmfile->fullpath_orig = $srcfile;
869
-                    $ecmfile->gen_or_uploaded = 'unknown';
870
-                    $ecmfile->description = '';    // indexed content
871
-                    $ecmfile->keyword = '';        // keyword content
872
-                    $resultecm = $ecmfile->create($user);
873
-                    if ($resultecm < 0)
874
-                    {
875
-                        setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
876
-                    }
877
-                }
878
-                elseif ($resultecm < 0)
879
-                {
880
-                    setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
881
-                }
882
-
883
-                if ($resultecm > 0) $result=true;
884
-                else $result = false;
885
-            }
886
-        }
780
+	global $user, $db, $conf;
781
+	$result=false;
887 782
 
888
-        if (empty($newmask)) $newmask=empty($conf->global->MAIN_UMASK)?'0755':$conf->global->MAIN_UMASK;
889
-        $newmaskdec=octdec($newmask);
890
-        // Currently method is restricted to files (dol_delete_files previously used is for files, and mask usage if for files too)
891
-        // to allow mask usage for dir, we shoul introduce a new param "isdir" to 1 to complete newmask like this
892
-        // if ($isdir) $newmaskdec |= octdec('0111');  // Set x bit required for directories
893
-        @chmod($newpathofdestfile, $newmaskdec);
894
-    }
783
+	dol_syslog("files.lib.php::dol_move srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwritifexists=".$overwriteifexists);
784
+	$srcexists=dol_is_file($srcfile);
785
+	$destexists=dol_is_file($destfile);
786
+
787
+	if (! $srcexists)
788
+	{
789
+		dol_syslog("files.lib.php::dol_move srcfile does not exists. we ignore the move request.");
790
+		return false;
791
+	}
792
+
793
+	if ($overwriteifexists || ! $destexists)
794
+	{
795
+		$newpathofsrcfile=dol_osencode($srcfile);
796
+		$newpathofdestfile=dol_osencode($destfile);
797
+
798
+		// Check virus
799
+		$testvirusarray=array();
800
+		if ($testvirus)
801
+		{
802
+			$testvirusarray=dolCheckVirus($newpathofsrcfile);
803
+			if (count($testvirusarray))
804
+			{
805
+				dol_syslog("files.lib.php::dol_move canceled because a virus was found into source file. we ignore the move request.", LOG_WARNING);
806
+				return false;
807
+			}
808
+		}
809
+
810
+		$result=@rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @
811
+		if (! $result)
812
+		{
813
+			if ($destexists)
814
+			{
815
+				dol_syslog("files.lib.php::dol_move Failed. We try to delete target first and move after.", LOG_WARNING);
816
+				// We force delete and try again. Rename function sometimes fails to replace dest file with some windows NTFS partitions.
817
+				dol_delete_file($destfile);
818
+				$result=@rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @
819
+			}
820
+			else dol_syslog("files.lib.php::dol_move Failed.", LOG_WARNING);
821
+		}
822
+
823
+		// Move ok
824
+		if ($result && $indexdatabase)
825
+		{
826
+			// Rename entry into ecm database
827
+			$rel_filetorenamebefore = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $srcfile);
828
+			$rel_filetorenameafter = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $destfile);
829
+			if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter))     // If not a tmp file
830
+			{
831
+				$rel_filetorenamebefore = preg_replace('/^[\\/]/', '', $rel_filetorenamebefore);
832
+				$rel_filetorenameafter = preg_replace('/^[\\/]/', '', $rel_filetorenameafter);
833
+				//var_dump($rel_filetorenamebefore.' - '.$rel_filetorenameafter);
834
+
835
+				dol_syslog("Try to rename also entries in database for full relative path before = ".$rel_filetorenamebefore." after = ".$rel_filetorenameafter, LOG_DEBUG);
836
+				include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
837
+
838
+				$ecmfiletarget=new EcmFiles($db);
839
+				$resultecmtarget = $ecmfiletarget->fetch(0, '', $rel_filetorenameafter);
840
+				if ($resultecmtarget > 0)   // An entry for target name already exists for target, we delete it, a new one will be created.
841
+				{
842
+					$ecmfiletarget->delete($user);
843
+				}
844
+
845
+				$ecmfile=new EcmFiles($db);
846
+				$resultecm = $ecmfile->fetch(0, '', $rel_filetorenamebefore);
847
+				if ($resultecm > 0)   // If an entry was found for src file, we use it to move entry
848
+				{
849
+					$filename = basename($rel_filetorenameafter);
850
+					$rel_dir = dirname($rel_filetorenameafter);
851
+					$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
852
+					$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
853
+
854
+					$ecmfile->filepath = $rel_dir;
855
+					$ecmfile->filename = $filename;
856
+					$resultecm = $ecmfile->update($user);
857
+				}
858
+				elseif ($resultecm == 0)   // If no entry were found for src files, create/update target file
859
+				{
860
+					$filename = basename($rel_filetorenameafter);
861
+					$rel_dir = dirname($rel_filetorenameafter);
862
+					$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
863
+					$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
864
+
865
+					$ecmfile->filepath = $rel_dir;
866
+					$ecmfile->filename = $filename;
867
+					$ecmfile->label = md5_file(dol_osencode($destfile));        // $destfile is a full path to file
868
+					$ecmfile->fullpath_orig = $srcfile;
869
+					$ecmfile->gen_or_uploaded = 'unknown';
870
+					$ecmfile->description = '';    // indexed content
871
+					$ecmfile->keyword = '';        // keyword content
872
+					$resultecm = $ecmfile->create($user);
873
+					if ($resultecm < 0)
874
+					{
875
+						setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
876
+					}
877
+				}
878
+				elseif ($resultecm < 0)
879
+				{
880
+					setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
881
+				}
882
+
883
+				if ($resultecm > 0) $result=true;
884
+				else $result = false;
885
+			}
886
+		}
895 887
 
896
-    return $result;
888
+		if (empty($newmask)) $newmask=empty($conf->global->MAIN_UMASK)?'0755':$conf->global->MAIN_UMASK;
889
+		$newmaskdec=octdec($newmask);
890
+		// Currently method is restricted to files (dol_delete_files previously used is for files, and mask usage if for files too)
891
+		// to allow mask usage for dir, we shoul introduce a new param "isdir" to 1 to complete newmask like this
892
+		// if ($isdir) $newmaskdec |= octdec('0111');  // Set x bit required for directories
893
+		@chmod($newpathofdestfile, $newmaskdec);
894
+	}
895
+
896
+	return $result;
897 897
 }
898 898
 
899 899
 /**
@@ -920,22 +920,22 @@  discard block
 block discarded – undo
920 920
  */
921 921
 function dolCheckVirus($src_file)
922 922
 {
923
-    global $conf;
924
-
925
-    if (! empty($conf->global->MAIN_ANTIVIRUS_COMMAND))
926
-    {
927
-        if (! class_exists('AntiVir')) {
928
-            require_once DOL_DOCUMENT_ROOT.'/core/class/antivir.class.php';
929
-        }
930
-        $antivir=new AntiVir($db);
931
-        $result = $antivir->dol_avscan_file($src_file);
932
-        if ($result < 0)	// If virus or error, we stop here
933
-        {
934
-            $reterrors=$antivir->errors;
935
-            return $reterrors;
936
-        }
937
-    }
938
-    return array();
923
+	global $conf;
924
+
925
+	if (! empty($conf->global->MAIN_ANTIVIRUS_COMMAND))
926
+	{
927
+		if (! class_exists('AntiVir')) {
928
+			require_once DOL_DOCUMENT_ROOT.'/core/class/antivir.class.php';
929
+		}
930
+		$antivir=new AntiVir($db);
931
+		$result = $antivir->dol_avscan_file($src_file);
932
+		if ($result < 0)	// If virus or error, we stop here
933
+		{
934
+			$reterrors=$antivir->errors;
935
+			return $reterrors;
936
+		}
937
+	}
938
+	return array();
939 939
 }
940 940
 
941 941
 
@@ -975,68 +975,68 @@  discard block
 block discarded – undo
975 975
 
976 976
 	if (empty($reshook))
977 977
 	{
978
-    	// If an upload error has been reported
979
-    	if ($uploaderrorcode)
980
-    	{
981
-    	    switch($uploaderrorcode)
982
-    	    {
983
-    	        case UPLOAD_ERR_INI_SIZE:	// 1
984
-    	            return 'ErrorFileSizeTooLarge';
985
-    	            break;
986
-    	        case UPLOAD_ERR_FORM_SIZE:	// 2
987
-    	            return 'ErrorFileSizeTooLarge';
988
-    	            break;
989
-    	        case UPLOAD_ERR_PARTIAL:	// 3
990
-    	            return 'ErrorPartialFile';
991
-    	            break;
992
-    	        case UPLOAD_ERR_NO_TMP_DIR:	//
993
-    	            return 'ErrorNoTmpDir';
994
-    	            break;
995
-    	        case UPLOAD_ERR_CANT_WRITE:
996
-    	            return 'ErrorFailedToWriteInDir';
997
-    	            break;
998
-    	        case UPLOAD_ERR_EXTENSION:
999
-    	            return 'ErrorUploadBlockedByAddon';
1000
-    	            break;
1001
-    	        default:
1002
-    	            break;
1003
-    	    }
1004
-    	}
1005
-
1006
-    	// If we need to make a virus scan
1007
-    	if (empty($disablevirusscan) && file_exists($src_file))
1008
-    	{
1009
-    	    $checkvirusarray=dolCheckVirus($src_file);
1010
-    	    if (count($checkvirusarray))
1011
-    	    {
1012
-    	       dol_syslog('Files.lib::dol_move_uploaded_file File "'.$src_file.'" (target name "'.$dest_file.'") KO with antivirus: result='.$result.' errors='.join(',',$checkvirusarray), LOG_WARNING);
1013
-    	       return 'ErrorFileIsInfectedWithAVirus: '.join(',',$checkvirusarray);
1014
-    	    }
1015
-    	}
1016
-
1017
-    	// Security:
1018
-    	// Disallow file with some extensions. We rename them.
1019
-    	// Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code.
1020
-    	if (preg_match('/\.htm|\.html|\.php|\.pl|\.cgi$/i',$dest_file) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED))
1021
-    	{
1022
-    	    $file_name.= '.noexe';
1023
-    	}
1024
-
1025
-    	// Security:
1026
-    	// We refuse cache files/dirs, upload using .. and pipes into filenames.
1027
-    	if (preg_match('/^\./',$src_file) || preg_match('/\.\./',$src_file) || preg_match('/[<>|]/',$src_file))
1028
-    	{
1029
-    	    dol_syslog("Refused to deliver file ".$src_file, LOG_WARNING);
1030
-    	    return -1;
1031
-    	}
1032
-
1033
-    	// Security:
1034
-    	// On interdit fichiers caches, remontees de repertoire ainsi que les pipe dans les noms de fichiers.
1035
-    	if (preg_match('/^\./',$dest_file) || preg_match('/\.\./',$dest_file) || preg_match('/[<>|]/',$dest_file))
1036
-    	{
1037
-    	    dol_syslog("Refused to deliver file ".$dest_file, LOG_WARNING);
1038
-    	    return -2;
1039
-    	}
978
+		// If an upload error has been reported
979
+		if ($uploaderrorcode)
980
+		{
981
+			switch($uploaderrorcode)
982
+			{
983
+				case UPLOAD_ERR_INI_SIZE:	// 1
984
+					return 'ErrorFileSizeTooLarge';
985
+					break;
986
+				case UPLOAD_ERR_FORM_SIZE:	// 2
987
+					return 'ErrorFileSizeTooLarge';
988
+					break;
989
+				case UPLOAD_ERR_PARTIAL:	// 3
990
+					return 'ErrorPartialFile';
991
+					break;
992
+				case UPLOAD_ERR_NO_TMP_DIR:	//
993
+					return 'ErrorNoTmpDir';
994
+					break;
995
+				case UPLOAD_ERR_CANT_WRITE:
996
+					return 'ErrorFailedToWriteInDir';
997
+					break;
998
+				case UPLOAD_ERR_EXTENSION:
999
+					return 'ErrorUploadBlockedByAddon';
1000
+					break;
1001
+				default:
1002
+					break;
1003
+			}
1004
+		}
1005
+
1006
+		// If we need to make a virus scan
1007
+		if (empty($disablevirusscan) && file_exists($src_file))
1008
+		{
1009
+			$checkvirusarray=dolCheckVirus($src_file);
1010
+			if (count($checkvirusarray))
1011
+			{
1012
+			   dol_syslog('Files.lib::dol_move_uploaded_file File "'.$src_file.'" (target name "'.$dest_file.'") KO with antivirus: result='.$result.' errors='.join(',',$checkvirusarray), LOG_WARNING);
1013
+			   return 'ErrorFileIsInfectedWithAVirus: '.join(',',$checkvirusarray);
1014
+			}
1015
+		}
1016
+
1017
+		// Security:
1018
+		// Disallow file with some extensions. We rename them.
1019
+		// Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code.
1020
+		if (preg_match('/\.htm|\.html|\.php|\.pl|\.cgi$/i',$dest_file) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED))
1021
+		{
1022
+			$file_name.= '.noexe';
1023
+		}
1024
+
1025
+		// Security:
1026
+		// We refuse cache files/dirs, upload using .. and pipes into filenames.
1027
+		if (preg_match('/^\./',$src_file) || preg_match('/\.\./',$src_file) || preg_match('/[<>|]/',$src_file))
1028
+		{
1029
+			dol_syslog("Refused to deliver file ".$src_file, LOG_WARNING);
1030
+			return -1;
1031
+		}
1032
+
1033
+		// Security:
1034
+		// On interdit fichiers caches, remontees de repertoire ainsi que les pipe dans les noms de fichiers.
1035
+		if (preg_match('/^\./',$dest_file) || preg_match('/\.\./',$dest_file) || preg_match('/[<>|]/',$dest_file))
1036
+		{
1037
+			dol_syslog("Refused to deliver file ".$dest_file, LOG_WARNING);
1038
+			return -2;
1039
+		}
1040 1040
 	}
1041 1041
 
1042 1042
 	if ($reshook < 0)	// At least one blocking error returned by one hook
@@ -1108,8 +1108,8 @@  discard block
 block discarded – undo
1108 1108
 	// We refuse transversal using .. and pipes into filenames.
1109 1109
 	if (preg_match('/\.\./',$file) || preg_match('/[<>|]/',$file))
1110 1110
 	{
1111
-        dol_syslog("Refused to delete file ".$file, LOG_WARNING);
1112
-	    return False;
1111
+		dol_syslog("Refused to delete file ".$file, LOG_WARNING);
1112
+		return False;
1113 1113
 	}
1114 1114
 
1115 1115
 	if (empty($nohook))
@@ -1150,27 +1150,27 @@  discard block
 block discarded – undo
1150 1150
 					else $ok=unlink($filename);
1151 1151
 					if ($ok)
1152 1152
 					{
1153
-					    dol_syslog("Removed file ".$filename, LOG_DEBUG);
1154
-
1155
-	                    // Delete entry into ecm database
1156
-    				    $rel_filetodelete = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filename);
1157
-    				    if (! preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $rel_filetodelete))     // If not a tmp file
1158
-    				    {
1159
-    				        $rel_filetodelete = preg_replace('/^[\\/]/', '', $rel_filetodelete);
1160
-
1161
-    				        dol_syslog("Try to remove also entries in database for full relative path = ".$rel_filetodelete, LOG_DEBUG);
1162
-        				    include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
1163
-        				    $ecmfile=new EcmFiles($db);
1164
-        				    $result = $ecmfile->fetch(0, '', $rel_filetodelete);
1165
-        				    if ($result >= 0 && $ecmfile->id > 0)
1166
-        				    {
1167
-        				        $result = $ecmfile->delete($user);
1168
-        				    }
1169
-        				    if ($result < 0)
1170
-        				    {
1171
-        				        setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
1172
-        				    }
1173
-    				    }
1153
+						dol_syslog("Removed file ".$filename, LOG_DEBUG);
1154
+
1155
+						// Delete entry into ecm database
1156
+						$rel_filetodelete = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filename);
1157
+						if (! preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $rel_filetodelete))     // If not a tmp file
1158
+						{
1159
+							$rel_filetodelete = preg_replace('/^[\\/]/', '', $rel_filetodelete);
1160
+
1161
+							dol_syslog("Try to remove also entries in database for full relative path = ".$rel_filetodelete, LOG_DEBUG);
1162
+							include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
1163
+							$ecmfile=new EcmFiles($db);
1164
+							$result = $ecmfile->fetch(0, '', $rel_filetodelete);
1165
+							if ($result >= 0 && $ecmfile->id > 0)
1166
+							{
1167
+								$result = $ecmfile->delete($user);
1168
+							}
1169
+							if ($result < 0)
1170
+							{
1171
+								setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
1172
+							}
1173
+						}
1174 1174
 					}
1175 1175
 					else dol_syslog("Failed to remove file ".$filename, LOG_WARNING);
1176 1176
 					// TODO Failure to remove can be because file was already removed or because of permission
@@ -1207,12 +1207,12 @@  discard block
 block discarded – undo
1207 1207
 	// We refuse transversal using .. and pipes into filenames.
1208 1208
 	if (preg_match('/\.\./',$dir) || preg_match('/[<>|]/',$dir))
1209 1209
 	{
1210
-        dol_syslog("Refused to delete dir ".$dir, LOG_WARNING);
1211
-	    return False;
1210
+		dol_syslog("Refused to delete dir ".$dir, LOG_WARNING);
1211
+		return False;
1212 1212
 	}
1213 1213
 
1214
-    $dir_osencoded=dol_osencode($dir);
1215
-    return ($nophperrors?@rmdir($dir_osencoded):rmdir($dir_osencoded));
1214
+	$dir_osencoded=dol_osencode($dir);
1215
+	return ($nophperrors?@rmdir($dir_osencoded):rmdir($dir_osencoded));
1216 1216
 }
1217 1217
 
1218 1218
 /**
@@ -1227,42 +1227,42 @@  discard block
 block discarded – undo
1227 1227
  */
1228 1228
 function dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0)
1229 1229
 {
1230
-    dol_syslog("functions.lib:dol_delete_dir_recursive ".$dir,LOG_DEBUG);
1231
-    if (dol_is_dir($dir))
1232
-    {
1233
-        $dir_osencoded=dol_osencode($dir);
1234
-        if ($handle = opendir("$dir_osencoded"))
1235
-        {
1236
-            while (false !== ($item = readdir($handle)))
1237
-            {
1238
-                if (! utf8_check($item)) $item=utf8_encode($item);  // should be useless
1239
-
1240
-                if ($item != "." && $item != "..")
1241
-                {
1242
-                    if (is_dir(dol_osencode("$dir/$item")) && ! is_link(dol_osencode("$dir/$item")))
1243
-                    {
1244
-                        $count=dol_delete_dir_recursive("$dir/$item", $count, $nophperrors, 0, $countdeleted);
1245
-                    }
1246
-                    else
1247
-                    {
1248
-                        $result=dol_delete_file("$dir/$item", 1, $nophperrors);
1249
-                        $count++;
1250
-                        if ($result) $countdeleted++;
1251
-                    }
1252
-                }
1253
-            }
1254
-            closedir($handle);
1230
+	dol_syslog("functions.lib:dol_delete_dir_recursive ".$dir,LOG_DEBUG);
1231
+	if (dol_is_dir($dir))
1232
+	{
1233
+		$dir_osencoded=dol_osencode($dir);
1234
+		if ($handle = opendir("$dir_osencoded"))
1235
+		{
1236
+			while (false !== ($item = readdir($handle)))
1237
+			{
1238
+				if (! utf8_check($item)) $item=utf8_encode($item);  // should be useless
1255 1239
 
1256
-            if (empty($onlysub))
1257
-            {
1258
-	            $result=dol_delete_dir($dir, $nophperrors);
1259
-	            $count++;
1260
-    	        if ($result) $countdeleted++;
1261
-            }
1262
-        }
1263
-    }
1240
+				if ($item != "." && $item != "..")
1241
+				{
1242
+					if (is_dir(dol_osencode("$dir/$item")) && ! is_link(dol_osencode("$dir/$item")))
1243
+					{
1244
+						$count=dol_delete_dir_recursive("$dir/$item", $count, $nophperrors, 0, $countdeleted);
1245
+					}
1246
+					else
1247
+					{
1248
+						$result=dol_delete_file("$dir/$item", 1, $nophperrors);
1249
+						$count++;
1250
+						if ($result) $countdeleted++;
1251
+					}
1252
+				}
1253
+			}
1254
+			closedir($handle);
1264 1255
 
1265
-    return $count;
1256
+			if (empty($onlysub))
1257
+			{
1258
+				$result=dol_delete_dir($dir, $nophperrors);
1259
+				$count++;
1260
+				if ($result) $countdeleted++;
1261
+			}
1262
+		}
1263
+	}
1264
+
1265
+	return $count;
1266 1266
 }
1267 1267
 
1268 1268
 
@@ -1279,15 +1279,15 @@  discard block
 block discarded – undo
1279 1279
 	// Define parent dir of elements
1280 1280
 	$element = $object->element;
1281 1281
 
1282
-    if ($object->element == 'order_supplier')		$dir = $conf->fournisseur->commande->dir_output;
1283
-    elseif ($object->element == 'invoice_supplier')	$dir = $conf->fournisseur->facture->dir_output;
1284
-    elseif ($object->element == 'project')			$dir = $conf->projet->dir_output;
1285
-    elseif ($object->element == 'shipping')			$dir = $conf->expedition->dir_output.'/sending';
1286
-    elseif ($object->element == 'delivery')			$dir = $conf->expedition->dir_output.'/receipt';
1287
-    elseif ($object->element == 'fichinter')		$dir = $conf->ficheinter->dir_output;
1288
-    else $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output;
1282
+	if ($object->element == 'order_supplier')		$dir = $conf->fournisseur->commande->dir_output;
1283
+	elseif ($object->element == 'invoice_supplier')	$dir = $conf->fournisseur->facture->dir_output;
1284
+	elseif ($object->element == 'project')			$dir = $conf->projet->dir_output;
1285
+	elseif ($object->element == 'shipping')			$dir = $conf->expedition->dir_output.'/sending';
1286
+	elseif ($object->element == 'delivery')			$dir = $conf->expedition->dir_output.'/receipt';
1287
+	elseif ($object->element == 'fichinter')		$dir = $conf->ficheinter->dir_output;
1288
+	else $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output;
1289 1289
 
1290
-    if (empty($dir)) return 'ErrorObjectNoSupportedByFunction';
1290
+	if (empty($dir)) return 'ErrorObjectNoSupportedByFunction';
1291 1291
 
1292 1292
 	$refsan = dol_sanitizeFileName($object->ref);
1293 1293
 	$dir = $dir . "/" . $refsan ;
@@ -1425,7 +1425,7 @@  discard block
 block discarded – undo
1425 1425
 			$listofmimes[]=dol_mimetype($val['name']);
1426 1426
 		}
1427 1427
 	}
1428
-    $keytoavoidconflict = empty($trackid)?'':'-'.$trackid;
1428
+	$keytoavoidconflict = empty($trackid)?'':'-'.$trackid;
1429 1429
 	$_SESSION["listofpaths".$keytoavoidconflict]=join(';',$listofpaths);
1430 1430
 	$_SESSION["listofnames".$keytoavoidconflict]=join(';',$listofnames);
1431 1431
 	$_SESSION["listofmimes".$keytoavoidconflict]=join(';',$listofmimes);
@@ -1500,14 +1500,14 @@  discard block
 block discarded – undo
1500 1500
 					{
1501 1501
 						if (image_format_supported($destfull) == 1)
1502 1502
 						{
1503
-						    // Create thumbs
1504
-						    // We can't use $object->addThumbs here because there is no $object known
1505
-
1506
-						    // Used on logon for example
1507
-						    $imgThumbSmall = vignette($destfull, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs");
1508
-						    // Create mini thumbs for image (Ratio is near 16/9)
1509
-						    // Used on menu or for setup page for example
1510
-						    $imgThumbMini = vignette($destfull, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs");
1503
+							// Create thumbs
1504
+							// We can't use $object->addThumbs here because there is no $object known
1505
+
1506
+							// Used on logon for example
1507
+							$imgThumbSmall = vignette($destfull, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs");
1508
+							// Create mini thumbs for image (Ratio is near 16/9)
1509
+							// Used on menu or for setup page for example
1510
+							$imgThumbMini = vignette($destfull, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs");
1511 1511
 						}
1512 1512
 					}
1513 1513
 
@@ -1523,29 +1523,29 @@  discard block
 block discarded – undo
1523 1523
 					// Update table of files
1524 1524
 					if ($donotupdatesession)
1525 1525
 					{
1526
-					    $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir);
1527
-
1528
-					    if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir))     // If not a tmp dir
1529
-					    {
1530
-					        $filename = basename($destfile);
1531
-					        $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
1532
-					        $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
1533
-
1534
-    					    include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
1535
-    					    $ecmfile=new EcmFiles($db);
1536
-    					    $ecmfile->filepath = $rel_dir;
1537
-    					    $ecmfile->filename = $filename;
1538
-    					    $ecmfile->label = md5_file(dol_osencode($destfull));	// MD5 of file content
1539
-    					    $ecmfile->fullpath_orig = $TFile['name'][$i];
1540
-    					    $ecmfile->gen_or_uploaded = 'uploaded';
1541
-    					    $ecmfile->description = '';    // indexed content
1542
-    					    $ecmfile->keyword = '';        // keyword content
1543
-    					    $result = $ecmfile->create($user);
1544
-                            if ($result < 0)
1545
-                            {
1546
-                                setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
1547
-                            }
1548
-					    }
1526
+						$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir);
1527
+
1528
+						if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir))     // If not a tmp dir
1529
+						{
1530
+							$filename = basename($destfile);
1531
+							$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
1532
+							$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
1533
+
1534
+							include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
1535
+							$ecmfile=new EcmFiles($db);
1536
+							$ecmfile->filepath = $rel_dir;
1537
+							$ecmfile->filename = $filename;
1538
+							$ecmfile->label = md5_file(dol_osencode($destfull));	// MD5 of file content
1539
+							$ecmfile->fullpath_orig = $TFile['name'][$i];
1540
+							$ecmfile->gen_or_uploaded = 'uploaded';
1541
+							$ecmfile->description = '';    // indexed content
1542
+							$ecmfile->keyword = '';        // keyword content
1543
+							$result = $ecmfile->create($user);
1544
+							if ($result < 0)
1545
+							{
1546
+								setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
1547
+							}
1548
+						}
1549 1549
 					}
1550 1550
 
1551 1551
 					$res = 1;
@@ -1616,7 +1616,7 @@  discard block
 block discarded – undo
1616 1616
 	$listofpaths=array();
1617 1617
 	$listofnames=array();
1618 1618
 	$listofmimes=array();
1619
-    $keytoavoidconflict = empty($trackid)?'':'-'.$trackid;
1619
+	$keytoavoidconflict = empty($trackid)?'':'-'.$trackid;
1620 1620
 	if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
1621 1621
 	if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
1622 1622
 	if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
@@ -1706,48 +1706,48 @@  discard block
 block discarded – undo
1706 1706
  */
1707 1707
 function dol_compress_file($inputfile, $outputfile, $mode="gz")
1708 1708
 {
1709
-    $foundhandler=0;
1710
-
1711
-    try
1712
-    {
1713
-        $data = implode("", file(dol_osencode($inputfile)));
1714
-        if ($mode == 'gz')     { $foundhandler=1; $compressdata = gzencode($data, 9); }
1715
-        elseif ($mode == 'bz') { $foundhandler=1; $compressdata = bzcompress($data, 9); }
1716
-        elseif ($mode == 'zip')
1717
-        {
1718
-            if (defined('ODTPHP_PATHTOPCLZIP'))
1719
-            {
1720
-                $foundhandler=1;
1709
+	$foundhandler=0;
1721 1710
 
1722
-                include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php';
1723
-                $archive = new PclZip($outputfile);
1724
-                $archive->add($inputfile, PCLZIP_OPT_REMOVE_PATH, dirname($inputfile));
1725
-                //$archive->add($inputfile);
1726
-                return 1;
1727
-            }
1728
-        }
1729
-
1730
-        if ($foundhandler)
1731
-        {
1732
-            $fp = fopen($outputfile, "w");
1733
-            fwrite($fp, $compressdata);
1734
-            fclose($fp);
1735
-            return 1;
1736
-        }
1737
-        else
1738
-        {
1739
-            dol_syslog("Try to zip with format ".$mode." with no handler for this format",LOG_ERR);
1740
-            return -2;
1741
-        }
1742
-    }
1743
-    catch (Exception $e)
1744
-    {
1745
-        global $langs, $errormsg;
1746
-        $langs->load("errors");
1747
-        dol_syslog("Failed to open file ".$outputfile,LOG_ERR);
1748
-        $errormsg=$langs->trans("ErrorFailedToWriteInDir");
1749
-        return -1;
1750
-    }
1711
+	try
1712
+	{
1713
+		$data = implode("", file(dol_osencode($inputfile)));
1714
+		if ($mode == 'gz')     { $foundhandler=1; $compressdata = gzencode($data, 9); }
1715
+		elseif ($mode == 'bz') { $foundhandler=1; $compressdata = bzcompress($data, 9); }
1716
+		elseif ($mode == 'zip')
1717
+		{
1718
+			if (defined('ODTPHP_PATHTOPCLZIP'))
1719
+			{
1720
+				$foundhandler=1;
1721
+
1722
+				include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php';
1723
+				$archive = new PclZip($outputfile);
1724
+				$archive->add($inputfile, PCLZIP_OPT_REMOVE_PATH, dirname($inputfile));
1725
+				//$archive->add($inputfile);
1726
+				return 1;
1727
+			}
1728
+		}
1729
+
1730
+		if ($foundhandler)
1731
+		{
1732
+			$fp = fopen($outputfile, "w");
1733
+			fwrite($fp, $compressdata);
1734
+			fclose($fp);
1735
+			return 1;
1736
+		}
1737
+		else
1738
+		{
1739
+			dol_syslog("Try to zip with format ".$mode." with no handler for this format",LOG_ERR);
1740
+			return -2;
1741
+		}
1742
+	}
1743
+	catch (Exception $e)
1744
+	{
1745
+		global $langs, $errormsg;
1746
+		$langs->load("errors");
1747
+		dol_syslog("Failed to open file ".$outputfile,LOG_ERR);
1748
+		$errormsg=$langs->trans("ErrorFailedToWriteInDir");
1749
+		return -1;
1750
+	}
1751 1751
 }
1752 1752
 
1753 1753
 /**
@@ -1759,17 +1759,17 @@  discard block
 block discarded – undo
1759 1759
  */
1760 1760
 function dol_uncompress($inputfile,$outputdir)
1761 1761
 {
1762
-    global $langs;
1763
-
1764
-    if (defined('ODTPHP_PATHTOPCLZIP'))
1765
-    {
1766
-    	dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".ODTPHP_PATHTOPCLZIP.", so we use Pclzip to unzip into ".$outputdir);
1767
-        include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php';
1768
-        $archive = new PclZip($inputfile);
1769
-        $result=$archive->extract(PCLZIP_OPT_PATH, $outputdir);
1770
-        //var_dump($result);
1771
-        if (! is_array($result) && $result <= 0) return array('error'=>$archive->errorInfo(true));
1772
-        else
1762
+	global $langs;
1763
+
1764
+	if (defined('ODTPHP_PATHTOPCLZIP'))
1765
+	{
1766
+		dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".ODTPHP_PATHTOPCLZIP.", so we use Pclzip to unzip into ".$outputdir);
1767
+		include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php';
1768
+		$archive = new PclZip($inputfile);
1769
+		$result=$archive->extract(PCLZIP_OPT_PATH, $outputdir);
1770
+		//var_dump($result);
1771
+		if (! is_array($result) && $result <= 0) return array('error'=>$archive->errorInfo(true));
1772
+		else
1773 1773
 		{
1774 1774
 			$ok=1; $errmsg='';
1775 1775
 			// Loop on each file to check result for unzipping file
@@ -1787,26 +1787,26 @@  discard block
 block discarded – undo
1787 1787
 			if ($ok) return array();
1788 1788
 			else return array('error'=>$errmsg);
1789 1789
 		}
1790
-    }
1791
-
1792
-    if (class_exists('ZipArchive'))
1793
-    {
1794
-    	dol_syslog("Class ZipArchive is set so we unzip using ZipArchive to unzip into ".$outputdir);
1795
-    	$zip = new ZipArchive;
1796
-        $res = $zip->open($inputfile);
1797
-        if ($res === TRUE)
1798
-        {
1799
-            $zip->extractTo($outputdir.'/');
1800
-            $zip->close();
1801
-            return array();
1802
-        }
1803
-        else
1804
-        {
1805
-            return array('error'=>'ErrUnzipFails');
1806
-        }
1807
-    }
1808
-
1809
-    return array('error'=>'ErrNoZipEngine');
1790
+	}
1791
+
1792
+	if (class_exists('ZipArchive'))
1793
+	{
1794
+		dol_syslog("Class ZipArchive is set so we unzip using ZipArchive to unzip into ".$outputdir);
1795
+		$zip = new ZipArchive;
1796
+		$res = $zip->open($inputfile);
1797
+		if ($res === TRUE)
1798
+		{
1799
+			$zip->extractTo($outputdir.'/');
1800
+			$zip->close();
1801
+			return array();
1802
+		}
1803
+		else
1804
+		{
1805
+			return array('error'=>'ErrUnzipFails');
1806
+		}
1807
+	}
1808
+
1809
+	return array('error'=>'ErrNoZipEngine');
1810 1810
 }
1811 1811
 
1812 1812
 
@@ -1820,25 +1820,25 @@  discard block
 block discarded – undo
1820 1820
  */
1821 1821
 function dol_compress_dir($inputdir, $outputfile, $mode="zip")
1822 1822
 {
1823
-    $foundhandler=0;
1823
+	$foundhandler=0;
1824 1824
 
1825
-    dol_syslog("Try to zip dir ".$inputdir." into ".$outputdir." mode=".$mode);
1825
+	dol_syslog("Try to zip dir ".$inputdir." into ".$outputdir." mode=".$mode);
1826 1826
 
1827
-    if (! dol_is_dir(dirname($outputfile)) || ! is_writable(dirname($outputfile)))
1828
-    {
1829
-    	global $langs, $errormsg;
1830
-    	$langs->load("errors");
1831
-    	$errormsg=$langs->trans("ErrorFailedToWriteInDir",$outputfile);
1827
+	if (! dol_is_dir(dirname($outputfile)) || ! is_writable(dirname($outputfile)))
1828
+	{
1829
+		global $langs, $errormsg;
1830
+		$langs->load("errors");
1831
+		$errormsg=$langs->trans("ErrorFailedToWriteInDir",$outputfile);
1832 1832
 		return -3;
1833
-    }
1834
-
1835
-    try
1836
-    {
1837
-        if ($mode == 'gz')     { $foundhandler=0; }
1838
-        elseif ($mode == 'bz') { $foundhandler=0; }
1839
-        elseif ($mode == 'zip')
1840
-        {
1841
-            /*if (defined('ODTPHP_PATHTOPCLZIP'))
1833
+	}
1834
+
1835
+	try
1836
+	{
1837
+		if ($mode == 'gz')     { $foundhandler=0; }
1838
+		elseif ($mode == 'bz') { $foundhandler=0; }
1839
+		elseif ($mode == 'zip')
1840
+		{
1841
+			/*if (defined('ODTPHP_PATHTOPCLZIP'))
1842 1842
             {
1843 1843
                 $foundhandler=0;        // TODO implement this
1844 1844
 
@@ -1849,61 +1849,61 @@  discard block
 block discarded – undo
1849 1849
                 return 1;
1850 1850
             }
1851 1851
             else*/
1852
-            if (class_exists('ZipArchive'))
1853
-            {
1854
-                $foundhandler=1;
1855
-
1856
-                // Initialize archive object
1857
-                $zip = new ZipArchive();
1858
-                $result = $zip->open($outputfile, ZipArchive::CREATE | ZipArchive::OVERWRITE);
1859
-
1860
-                // Create recursive directory iterator
1861
-                /** @var SplFileInfo[] $files */
1862
-                $files = new RecursiveIteratorIterator(
1863
-                    new RecursiveDirectoryIterator($inputdir),
1864
-                    RecursiveIteratorIterator::LEAVES_ONLY
1865
-                    );
1866
-
1867
-                foreach ($files as $name => $file)
1868
-                {
1869
-                    // Skip directories (they would be added automatically)
1870
-                    if (!$file->isDir())
1871
-                    {
1872
-                        // Get real and relative path for current file
1873
-                        $filePath = $file->getRealPath();
1874
-                        $relativePath = substr($filePath, strlen($inputdir) + 1);
1875
-
1876
-                        // Add current file to archive
1877
-                        $zip->addFile($filePath, $relativePath);
1878
-                    }
1879
-                }
1880
-
1881
-                // Zip archive will be created only after closing object
1882
-                $zip->close();
1852
+			if (class_exists('ZipArchive'))
1853
+			{
1854
+				$foundhandler=1;
1883 1855
 
1884
-                return 1;
1885
-            }
1886
-        }
1887
-
1888
-        if (! $foundhandler)
1889
-        {
1890
-            dol_syslog("Try to zip with format ".$mode." with no handler for this format",LOG_ERR);
1891
-            return -2;
1892
-        }
1893
-        else
1894
-        {
1895
-        	return 0;
1896
-        }
1897
-    }
1898
-    catch (Exception $e)
1899
-    {
1900
-        global $langs, $errormsg;
1901
-        $langs->load("errors");
1902
-        dol_syslog("Failed to open file ".$outputfile, LOG_ERR);
1903
-        dol_syslog($e->getMessage(), LOG_ERR);
1904
-        $errormsg=$langs->trans("ErrorFailedToWriteInDir",$outputfile);
1905
-        return -1;
1906
-    }
1856
+				// Initialize archive object
1857
+				$zip = new ZipArchive();
1858
+				$result = $zip->open($outputfile, ZipArchive::CREATE | ZipArchive::OVERWRITE);
1859
+
1860
+				// Create recursive directory iterator
1861
+				/** @var SplFileInfo[] $files */
1862
+				$files = new RecursiveIteratorIterator(
1863
+					new RecursiveDirectoryIterator($inputdir),
1864
+					RecursiveIteratorIterator::LEAVES_ONLY
1865
+					);
1866
+
1867
+				foreach ($files as $name => $file)
1868
+				{
1869
+					// Skip directories (they would be added automatically)
1870
+					if (!$file->isDir())
1871
+					{
1872
+						// Get real and relative path for current file
1873
+						$filePath = $file->getRealPath();
1874
+						$relativePath = substr($filePath, strlen($inputdir) + 1);
1875
+
1876
+						// Add current file to archive
1877
+						$zip->addFile($filePath, $relativePath);
1878
+					}
1879
+				}
1880
+
1881
+				// Zip archive will be created only after closing object
1882
+				$zip->close();
1883
+
1884
+				return 1;
1885
+			}
1886
+		}
1887
+
1888
+		if (! $foundhandler)
1889
+		{
1890
+			dol_syslog("Try to zip with format ".$mode." with no handler for this format",LOG_ERR);
1891
+			return -2;
1892
+		}
1893
+		else
1894
+		{
1895
+			return 0;
1896
+		}
1897
+	}
1898
+	catch (Exception $e)
1899
+	{
1900
+		global $langs, $errormsg;
1901
+		$langs->load("errors");
1902
+		dol_syslog("Failed to open file ".$outputfile, LOG_ERR);
1903
+		dol_syslog($e->getMessage(), LOG_ERR);
1904
+		$errormsg=$langs->trans("ErrorFailedToWriteInDir",$outputfile);
1905
+		return -1;
1906
+	}
1907 1907
 }
1908 1908
 
1909 1909
 
@@ -1920,8 +1920,8 @@  discard block
 block discarded – undo
1920 1920
  */
1921 1921
 function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('(\.meta|_preview.*\.png)$','^\.'),$nohook=false,$mode='')
1922 1922
 {
1923
-    $tmparray=dol_dir_list($dir,'files',0,$regexfilter,$excludefilter,'date',SORT_DESC,$mode,$nohook);
1924
-    return $tmparray[0];
1923
+	$tmparray=dol_dir_list($dir,'files',0,$regexfilter,$excludefilter,'date',SORT_DESC,$mode,$nohook);
1924
+	return $tmparray[0];
1925 1925
 }
1926 1926
 
1927 1927
 /**
@@ -1951,7 +1951,7 @@  discard block
 block discarded – undo
1951 1951
 	$sqlprotectagainstexternals='';
1952 1952
 	$ret=array();
1953 1953
 
1954
-    // Find the subdirectory name as the reference. For exemple original_file='10/myfile.pdf' -> refname='10'
1954
+	// Find the subdirectory name as the reference. For exemple original_file='10/myfile.pdf' -> refname='10'
1955 1955
 	if (empty($refname)) $refname=basename(dirname($original_file)."/");
1956 1956
 
1957 1957
 	$relative_original_file = $original_file;
@@ -1960,20 +1960,20 @@  discard block
 block discarded – undo
1960 1960
 	$lire='lire'; $read='read'; $download='download';
1961 1961
 	if ($mode == 'write')
1962 1962
 	{
1963
-	    $lire='creer'; $read='write'; $download='upload';
1963
+		$lire='creer'; $read='write'; $download='upload';
1964 1964
 	}
1965 1965
 
1966 1966
 	// Wrapping for miscellaneous medias files
1967 1967
 	if ($modulepart == 'medias' && !empty($dolibarr_main_data_root))
1968 1968
 	{
1969
-	    $accessallowed=1;
1970
-	    $original_file=$conf->medias->multidir_output[$entity].'/'.$original_file;
1969
+		$accessallowed=1;
1970
+		$original_file=$conf->medias->multidir_output[$entity].'/'.$original_file;
1971 1971
 	}
1972 1972
 	// Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log
1973 1973
 	elseif ($modulepart == 'logs' && !empty($dolibarr_main_data_root))
1974 1974
 	{
1975
-	    $accessallowed=($user->admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file)));
1976
-	    $original_file=$dolibarr_main_data_root.'/'.$original_file;
1975
+		$accessallowed=($user->admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file)));
1976
+		$original_file=$dolibarr_main_data_root.'/'.$original_file;
1977 1977
 	}
1978 1978
 	// Wrapping for *.zip files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip
1979 1979
 	elseif ($modulepart == 'packages' && !empty($dolibarr_main_data_root))
@@ -1982,8 +1982,8 @@  discard block
 block discarded – undo
1982 1982
 		$tmp=explode(',', $dolibarr_main_document_root_alt);
1983 1983
 		$dirins = $tmp[0];
1984 1984
 
1985
-	    $accessallowed=($user->admin && preg_match('/^module_.*\.zip$/', basename($original_file)));
1986
-	    $original_file=$dirins.'/'.$original_file;
1985
+		$accessallowed=($user->admin && preg_match('/^module_.*\.zip$/', basename($original_file)));
1986
+		$original_file=$dirins.'/'.$original_file;
1987 1987
 	}
1988 1988
 	// Wrapping for some images
1989 1989
 	elseif (($modulepart == 'mycompany' || $modulepart == 'companylogo') && !empty($conf->mycompany->dir_output))
@@ -2024,38 +2024,38 @@  discard block
 block discarded – undo
2024 2024
 	// Wrapping pour les apercu intervention
2025 2025
 	elseif (($modulepart == 'apercufichinter' || $modulepart == 'apercuficheinter') && !empty($conf->ficheinter->dir_output))
2026 2026
 	{
2027
-	    if ($fuser->rights->ficheinter->{$lire}) $accessallowed=1;
2028
-	    $original_file=$conf->ficheinter->dir_output.'/'.$original_file;
2027
+		if ($fuser->rights->ficheinter->{$lire}) $accessallowed=1;
2028
+		$original_file=$conf->ficheinter->dir_output.'/'.$original_file;
2029 2029
 	}
2030 2030
 	// Wrapping pour les apercu conat
2031 2031
 	elseif (($modulepart == 'apercucontract') && !empty($conf->contrat->dir_output))
2032 2032
 	{
2033
-	    if ($fuser->rights->contrat->{$lire}) $accessallowed=1;
2034
-	    $original_file=$conf->contrat->dir_output.'/'.$original_file;
2033
+		if ($fuser->rights->contrat->{$lire}) $accessallowed=1;
2034
+		$original_file=$conf->contrat->dir_output.'/'.$original_file;
2035 2035
 	}
2036 2036
 	// Wrapping pour les apercu supplier proposal
2037 2037
 	elseif (($modulepart == 'apercusupplier_proposal' || $modulepart == 'apercusupplier_proposal') && !empty($conf->supplier_proposal->dir_output))
2038 2038
 	{
2039
-	    if ($fuser->rights->supplier_proposal->{$lire}) $accessallowed=1;
2040
-	    $original_file=$conf->supplier_proposal->dir_output.'/'.$original_file;
2039
+		if ($fuser->rights->supplier_proposal->{$lire}) $accessallowed=1;
2040
+		$original_file=$conf->supplier_proposal->dir_output.'/'.$original_file;
2041 2041
 	}
2042 2042
 	// Wrapping pour les apercu supplier order
2043 2043
 	elseif (($modulepart == 'apercusupplier_order' || $modulepart == 'apercusupplier_order') && !empty($conf->fournisseur->commande->dir_output))
2044 2044
 	{
2045
-	    if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed=1;
2046
-	    $original_file=$conf->fournisseur->commande->dir_output.'/'.$original_file;
2045
+		if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed=1;
2046
+		$original_file=$conf->fournisseur->commande->dir_output.'/'.$original_file;
2047 2047
 	}
2048 2048
 	// Wrapping pour les apercu supplier invoice
2049 2049
 	elseif (($modulepart == 'apercusupplier_invoice' || $modulepart == 'apercusupplier_invoice') && !empty($conf->fournisseur->facture->dir_output))
2050 2050
 	{
2051
-	    if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed=1;
2052
-	    $original_file=$conf->fournisseur->facture->dir_output.'/'.$original_file;
2051
+		if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed=1;
2052
+		$original_file=$conf->fournisseur->facture->dir_output.'/'.$original_file;
2053 2053
 	}
2054 2054
 	// Wrapping pour les apercu supplier invoice
2055 2055
 	elseif (($modulepart == 'apercuexpensereport') && !empty($conf->expensereport->dir_output))
2056 2056
 	{
2057
-	    if ($fuser->rights->expensereport->{$lire}) $accessallowed=1;
2058
-	    $original_file=$conf->expensereport->dir_output.'/'.$original_file;
2057
+		if ($fuser->rights->expensereport->{$lire}) $accessallowed=1;
2058
+		$original_file=$conf->expensereport->dir_output.'/'.$original_file;
2059 2059
 	}
2060 2060
 	// Wrapping pour les images des stats propales
2061 2061
 	elseif ($modulepart == 'propalstats' && !empty($conf->propal->dir_temp))
@@ -2181,13 +2181,13 @@  discard block
 block discarded – undo
2181 2181
 	// Wrapping for users
2182 2182
 	else if ($modulepart == 'user' && !empty($conf->user->dir_output))
2183 2183
 	{
2184
-        $canreaduser=(! empty($fuser->admin) || $fuser->rights->user->user->{$lire});
2185
-        if ($fuser->id == (int) $refname) { $canreaduser=1; } // A user can always read its own card
2186
-        if ($canreaduser || preg_match('/^specimen/i',$original_file))
2187
-	    {
2188
-	        $accessallowed=1;
2189
-	    }
2190
-	    $original_file=$conf->user->dir_output.'/'.$original_file;
2184
+		$canreaduser=(! empty($fuser->admin) || $fuser->rights->user->user->{$lire});
2185
+		if ($fuser->id == (int) $refname) { $canreaduser=1; } // A user can always read its own card
2186
+		if ($canreaduser || preg_match('/^specimen/i',$original_file))
2187
+		{
2188
+			$accessallowed=1;
2189
+		}
2190
+		$original_file=$conf->user->dir_output.'/'.$original_file;
2191 2191
 	}
2192 2192
 
2193 2193
 	// Wrapping for third parties
@@ -2224,67 +2224,67 @@  discard block
 block discarded – undo
2224 2224
 	// Wrapping for mass actions
2225 2225
 	else if ($modulepart == 'massfilesarea_proposals' && !empty($conf->propal->dir_output))
2226 2226
 	{
2227
-	    if ($fuser->rights->propal->{$lire} || preg_match('/^specimen/i',$original_file))
2228
-	    {
2229
-	        $accessallowed=1;
2230
-	    }
2231
-	    $original_file=$conf->propal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2227
+		if ($fuser->rights->propal->{$lire} || preg_match('/^specimen/i',$original_file))
2228
+		{
2229
+			$accessallowed=1;
2230
+		}
2231
+		$original_file=$conf->propal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2232 2232
 	}
2233 2233
 	else if ($modulepart == 'massfilesarea_orders')
2234 2234
 	{
2235
-	    if ($fuser->rights->commande->{$lire} || preg_match('/^specimen/i',$original_file))
2236
-	    {
2237
-	        $accessallowed=1;
2238
-	    }
2239
-	    $original_file=$conf->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2235
+		if ($fuser->rights->commande->{$lire} || preg_match('/^specimen/i',$original_file))
2236
+		{
2237
+			$accessallowed=1;
2238
+		}
2239
+		$original_file=$conf->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2240 2240
 	}
2241 2241
 	else if ($modulepart == 'massfilesarea_invoices')
2242 2242
 	{
2243
-	    if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2244
-	    {
2245
-	        $accessallowed=1;
2246
-	    }
2247
-	    $original_file=$conf->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2243
+		if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2244
+		{
2245
+			$accessallowed=1;
2246
+		}
2247
+		$original_file=$conf->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2248 2248
 	}
2249 2249
 	else if ($modulepart == 'massfilesarea_expensereport')
2250 2250
 	{
2251
-	    if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2252
-	    {
2253
-	        $accessallowed=1;
2254
-	    }
2255
-	    $original_file=$conf->expensereport->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2251
+		if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2252
+		{
2253
+			$accessallowed=1;
2254
+		}
2255
+		$original_file=$conf->expensereport->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2256 2256
 	}
2257 2257
 	else if ($modulepart == 'massfilesarea_interventions')
2258 2258
 	{
2259
-	    if ($fuser->rights->ficheinter->{$lire} || preg_match('/^specimen/i',$original_file))
2260
-	    {
2261
-	        $accessallowed=1;
2262
-	    }
2263
-	    $original_file=$conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2259
+		if ($fuser->rights->ficheinter->{$lire} || preg_match('/^specimen/i',$original_file))
2260
+		{
2261
+			$accessallowed=1;
2262
+		}
2263
+		$original_file=$conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2264 2264
 	}
2265 2265
 	else if ($modulepart == 'massfilesarea_supplier_proposal' && !empty($conf->propal->dir_output))
2266 2266
 	{
2267
-	    if ($fuser->rights->supplier_proposal->{$lire} || preg_match('/^specimen/i',$original_file))
2268
-	    {
2269
-	        $accessallowed=1;
2270
-	    }
2271
-	    $original_file=$conf->supplier_proposal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2267
+		if ($fuser->rights->supplier_proposal->{$lire} || preg_match('/^specimen/i',$original_file))
2268
+		{
2269
+			$accessallowed=1;
2270
+		}
2271
+		$original_file=$conf->supplier_proposal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2272 2272
 	}
2273 2273
 	else if ($modulepart == 'massfilesarea_supplier_order')
2274 2274
 	{
2275
-	    if ($fuser->rights->fournisseur->commande->{$lire} || preg_match('/^specimen/i',$original_file))
2276
-	    {
2277
-	        $accessallowed=1;
2278
-	    }
2279
-	    $original_file=$conf->fournisseur->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2275
+		if ($fuser->rights->fournisseur->commande->{$lire} || preg_match('/^specimen/i',$original_file))
2276
+		{
2277
+			$accessallowed=1;
2278
+		}
2279
+		$original_file=$conf->fournisseur->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2280 2280
 	}
2281 2281
 	else if ($modulepart == 'massfilesarea_supplier_invoice')
2282 2282
 	{
2283
-	    if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2284
-	    {
2285
-	        $accessallowed=1;
2286
-	    }
2287
-	    $original_file=$conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2283
+		if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2284
+		{
2285
+			$accessallowed=1;
2286
+		}
2287
+		$original_file=$conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2288 2288
 	}
2289 2289
 	else if ($modulepart == 'massfilesarea_contract' && !empty($conf->contrat->dir_output))
2290 2290
 	{
@@ -2577,15 +2577,15 @@  discard block
 block discarded – undo
2577 2577
 		$original_file=$conf->scanner->dir_temp.'/'.$fuser->id.'/'.$original_file;
2578 2578
 	}
2579 2579
 
2580
-    // GENERIC Wrapping
2581
-    // If modulepart=module_user_temp	Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/temp/iduser
2582
-    // If modulepart=module_temp		Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/temp
2583
-    // If modulepart=module_user		Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/iduser
2584
-    // If modulepart=module				Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart
2585
-    else
2580
+	// GENERIC Wrapping
2581
+	// If modulepart=module_user_temp	Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/temp/iduser
2582
+	// If modulepart=module_temp		Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/temp
2583
+	// If modulepart=module_user		Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/iduser
2584
+	// If modulepart=module				Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart
2585
+	else
2586 2586
 	{
2587
-	    if (preg_match('/^specimen/i',$original_file))	$accessallowed=1;    // If link to a file called specimen. Test must be done before changing $original_file int full path.
2588
-	    if ($fuser->admin) $accessallowed=1;    // If user is admin
2587
+		if (preg_match('/^specimen/i',$original_file))	$accessallowed=1;    // If link to a file called specimen. Test must be done before changing $original_file int full path.
2588
+		if ($fuser->admin) $accessallowed=1;    // If user is admin
2589 2589
 
2590 2590
 		// Define $accessallowed
2591 2591
 		if (preg_match('/^([a-z]+)_user_temp$/i',$modulepart,$reg))
@@ -2595,7 +2595,7 @@  discard block
 block discarded – undo
2595 2595
 				dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
2596 2596
 				exit;
2597 2597
 			}
2598
-		    if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1;
2598
+			if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1;
2599 2599
 			$original_file=$conf->{$reg[1]}->dir_temp.'/'.$fuser->id.'/'.$original_file;
2600 2600
 		}
2601 2601
 		else if (preg_match('/^([a-z]+)_temp$/i',$modulepart,$reg))
@@ -2605,7 +2605,7 @@  discard block
 block discarded – undo
2605 2605
 				dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
2606 2606
 				exit;
2607 2607
 			}
2608
-		    if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1;
2608
+			if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1;
2609 2609
 			$original_file=$conf->{$reg[1]}->dir_temp.'/'.$original_file;
2610 2610
 		}
2611 2611
 		else if (preg_match('/^([a-z]+)_user$/i',$modulepart,$reg))
@@ -2615,7 +2615,7 @@  discard block
 block discarded – undo
2615 2615
 				dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
2616 2616
 				exit;
2617 2617
 			}
2618
-		    if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1;
2618
+			if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1;
2619 2619
 			$original_file=$conf->{$reg[1]}->dir_output.'/'.$fuser->id.'/'.$original_file;
2620 2620
 		}
2621 2621
 		else
@@ -2679,10 +2679,10 @@  discard block
 block discarded – undo
2679 2679
  */
2680 2680
 function dol_filecache($directory, $filename, $object)
2681 2681
 {
2682
-    if (! dol_is_dir($directory)) dol_mkdir($directory);
2683
-    $cachefile = $directory . $filename;
2684
-    file_put_contents($cachefile, serialize($object), LOCK_EX);
2685
-    @chmod($cachefile, 0644);
2682
+	if (! dol_is_dir($directory)) dol_mkdir($directory);
2683
+	$cachefile = $directory . $filename;
2684
+	file_put_contents($cachefile, serialize($object), LOCK_EX);
2685
+	@chmod($cachefile, 0644);
2686 2686
 }
2687 2687
 
2688 2688
 /**
@@ -2695,10 +2695,10 @@  discard block
 block discarded – undo
2695 2695
  */
2696 2696
 function dol_cache_refresh($directory, $filename, $cachetime)
2697 2697
 {
2698
-    $now = dol_now();
2699
-    $cachefile = $directory . $filename;
2700
-    $refresh = !file_exists($cachefile) || ($now-$cachetime) > dol_filemtime($cachefile);
2701
-    return $refresh;
2698
+	$now = dol_now();
2699
+	$cachefile = $directory . $filename;
2700
+	$refresh = !file_exists($cachefile) || ($now-$cachetime) > dol_filemtime($cachefile);
2701
+	return $refresh;
2702 2702
 }
2703 2703
 
2704 2704
 /**
@@ -2710,7 +2710,7 @@  discard block
 block discarded – undo
2710 2710
  */
2711 2711
 function dol_readcachefile($directory, $filename)
2712 2712
 {
2713
-    $cachefile = $directory . $filename;
2714
-    $object = unserialize(file_get_contents($cachefile));
2715
-    return $object;
2713
+	$cachefile = $directory . $filename;
2714
+	$object = unserialize(file_get_contents($cachefile));
2715
+	return $object;
2716 2716
 }
Please login to merge, or discard this patch.
Spacing   +558 added lines, -558 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function dol_basename($pathfile)
36 36
 {
37
-    return preg_replace('/^.*\/([^\/]+)$/','$1',rtrim($pathfile,'/'));
37
+    return preg_replace('/^.*\/([^\/]+)$/', '$1', rtrim($pathfile, '/'));
38 38
 }
39 39
 
40 40
 /**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
  *  @return	array						Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...)
56 56
  *  @see dol_dir_list_indatabase
57 57
  */
58
-function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="")
58
+function dol_dir_list($path, $types = "all", $recursive = 0, $filter = "", $excludefilter = "", $sortcriteria = "name", $sortorder = SORT_ASC, $mode = 0, $nohook = 0, $relativename = "")
59 59
 {
60 60
 	global $db, $hookmanager;
61 61
 	global $object;
@@ -63,23 +63,23 @@  discard block
 block discarded – undo
63 63
 	dol_syslog("files.lib.php::dol_dir_list path=".$path." types=".$types." recursive=".$recursive." filter=".$filter." excludefilter=".json_encode($excludefilter));
64 64
 	//print 'xxx'."files.lib.php::dol_dir_list path=".$path." types=".$types." recursive=".$recursive." filter=".$filter." excludefilter=".json_encode($excludefilter);
65 65
 
66
-	$loaddate=($mode==1||$mode==2)?true:false;
67
-	$loadsize=($mode==1||$mode==3)?true:false;
66
+	$loaddate = ($mode == 1 || $mode == 2) ?true:false;
67
+	$loadsize = ($mode == 1 || $mode == 3) ?true:false;
68 68
 
69 69
 	// Clean parameters
70
-	$path=preg_replace('/([\\/]+)$/i','',$path);
71
-	$newpath=dol_osencode($path);
70
+	$path = preg_replace('/([\\/]+)$/i', '', $path);
71
+	$newpath = dol_osencode($path);
72 72
 
73 73
 	$reshook = 0;
74 74
 	$file_list = array();
75 75
 
76
-	if (is_object($hookmanager) && ! $nohook)
76
+	if (is_object($hookmanager) && !$nohook)
77 77
 	{
78
-	    $hookmanager->resArray=array();
78
+	    $hookmanager->resArray = array();
79 79
 
80 80
 	    $hookmanager->initHooks(array('fileslib'));
81 81
 
82
-		$parameters=array(
82
+		$parameters = array(
83 83
 				'path' => $newpath,
84 84
 				'types'=> $types,
85 85
 				'recursive' => $recursive,
@@ -91,61 +91,61 @@  discard block
 block discarded – undo
91 91
 				'loadsize' => $loadsize,
92 92
 				'mode' => $mode
93 93
 		);
94
-		$reshook=$hookmanager->executeHooks('getDirList', $parameters, $object);
94
+		$reshook = $hookmanager->executeHooks('getDirList', $parameters, $object);
95 95
 	}
96 96
 
97 97
 	// $hookmanager->resArray may contain array stacked by other modules
98 98
 	if (empty($reshook))
99 99
 	{
100
-		if (! is_dir($newpath)) return array();
100
+		if (!is_dir($newpath)) return array();
101 101
 
102 102
 		if ($dir = opendir($newpath))
103 103
 		{
104
-			$filedate='';
105
-			$filesize='';
104
+			$filedate = '';
105
+			$filesize = '';
106 106
 
107 107
 			while (false !== ($file = readdir($dir)))        // $file is always a basename (into directory $newpath)
108 108
 			{
109
-				if (! utf8_check($file)) $file=utf8_encode($file);	// To be sure data is stored in utf8 in memory
109
+				if (!utf8_check($file)) $file = utf8_encode($file); // To be sure data is stored in utf8 in memory
110 110
 
111
-				$qualified=1;
111
+				$qualified = 1;
112 112
 
113 113
 				// Define excludefilterarray
114
-				$excludefilterarray=array('^\.');
114
+				$excludefilterarray = array('^\.');
115 115
 				if (is_array($excludefilter))
116 116
 				{
117
-					$excludefilterarray=array_merge($excludefilterarray,$excludefilter);
117
+					$excludefilterarray = array_merge($excludefilterarray, $excludefilter);
118 118
 				}
119
-				else if ($excludefilter) $excludefilterarray[]=$excludefilter;
119
+				else if ($excludefilter) $excludefilterarray[] = $excludefilter;
120 120
 				// Check if file is qualified
121
-				foreach($excludefilterarray as $filt)
121
+				foreach ($excludefilterarray as $filt)
122 122
 				{
123
-					if (preg_match('/'.$filt.'/i',$file)) {
124
-						$qualified=0; break;
123
+					if (preg_match('/'.$filt.'/i', $file)) {
124
+						$qualified = 0; break;
125 125
 					}
126 126
 				}
127 127
 
128 128
 				if ($qualified)
129 129
 				{
130
-					$isdir=is_dir(dol_osencode($path."/".$file));
130
+					$isdir = is_dir(dol_osencode($path."/".$file));
131 131
 					// Check whether this is a file or directory and whether we're interested in that type
132
-					if ($isdir && (($types=="directories") || ($types=="all") || $recursive))
132
+					if ($isdir && (($types == "directories") || ($types == "all") || $recursive))
133 133
 					{
134 134
 						// Add entry into file_list array
135
-						if (($types=="directories") || ($types=="all"))
135
+						if (($types == "directories") || ($types == "all"))
136 136
 						{
137
-							if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file);
138
-							if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file);
137
+							if ($loaddate || $sortcriteria == 'date') $filedate = dol_filemtime($path."/".$file);
138
+							if ($loadsize || $sortcriteria == 'size') $filesize = dol_filesize($path."/".$file);
139 139
 
140
-							if (! $filter || preg_match('/'.$filter.'/i',$file))	// We do not search key $filter into all $path, only into $file part
140
+							if (!$filter || preg_match('/'.$filter.'/i', $file))	// We do not search key $filter into all $path, only into $file part
141 141
 							{
142
-								preg_match('/([^\/]+)\/[^\/]+$/',$path.'/'.$file,$reg);
143
-								$level1name=(isset($reg[1])?$reg[1]:'');
142
+								preg_match('/([^\/]+)\/[^\/]+$/', $path.'/'.$file, $reg);
143
+								$level1name = (isset($reg[1]) ? $reg[1] : '');
144 144
 								$file_list[] = array(
145 145
 										"name" => $file,
146 146
 										"path" => $path,
147 147
 										"level1name" => $level1name,
148
-										"relativename" => ($relativename?$relativename.'/':'').$file,
148
+										"relativename" => ($relativename ? $relativename.'/' : '').$file,
149 149
 										"fullname" => $path.'/'.$file,
150 150
 										"date" => $filedate,
151 151
 										"size" => $filesize,
@@ -157,24 +157,24 @@  discard block
 block discarded – undo
157 157
 						// if we're in a directory and we want recursive behavior, call this function again
158 158
 						if ($recursive)
159 159
 						{
160
-							$file_list = array_merge($file_list, dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode, $nohook, ($relativename?$relativename.'/':'').$file));
160
+							$file_list = array_merge($file_list, dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode, $nohook, ($relativename ? $relativename.'/' : '').$file));
161 161
 						}
162 162
 					}
163
-					else if (! $isdir && (($types == "files") || ($types == "all")))
163
+					else if (!$isdir && (($types == "files") || ($types == "all")))
164 164
 					{
165 165
 						// Add file into file_list array
166
-						if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file);
167
-						if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file);
166
+						if ($loaddate || $sortcriteria == 'date') $filedate = dol_filemtime($path."/".$file);
167
+						if ($loadsize || $sortcriteria == 'size') $filesize = dol_filesize($path."/".$file);
168 168
 
169
-						if (! $filter || preg_match('/'.$filter.'/i',$file))	// We do not search key $filter into $path, only into $file
169
+						if (!$filter || preg_match('/'.$filter.'/i', $file))	// We do not search key $filter into $path, only into $file
170 170
 						{
171
-							preg_match('/([^\/]+)\/[^\/]+$/',$path.'/'.$file,$reg);
172
-							$level1name=(isset($reg[1])?$reg[1]:'');
171
+							preg_match('/([^\/]+)\/[^\/]+$/', $path.'/'.$file, $reg);
172
+							$level1name = (isset($reg[1]) ? $reg[1] : '');
173 173
 							$file_list[] = array(
174 174
 									"name" => $file,
175 175
 									"path" => $path,
176 176
 									"level1name" => $level1name,
177
-									"relativename" => ($relativename?$relativename.'/':'').$file,
177
+									"relativename" => ($relativename ? $relativename.'/' : '').$file,
178 178
 									"fullname" => $path.'/'.$file,
179 179
 									"date" => $filedate,
180 180
 									"size" => $filesize,
@@ -187,12 +187,12 @@  discard block
 block discarded – undo
187 187
 			closedir($dir);
188 188
 
189 189
 			// Obtain a list of columns
190
-			if (! empty($sortcriteria))
190
+			if (!empty($sortcriteria))
191 191
 			{
192
-				$myarray=array();
192
+				$myarray = array();
193 193
 				foreach ($file_list as $key => $row)
194 194
 				{
195
-					$myarray[$key] = (isset($row[$sortcriteria])?$row[$sortcriteria]:'');
195
+					$myarray[$key] = (isset($row[$sortcriteria]) ? $row[$sortcriteria] : '');
196 196
 				}
197 197
 				// Sort the data
198 198
 				if ($sortorder) array_multisort($myarray, $sortorder, $file_list);
@@ -219,20 +219,20 @@  discard block
 block discarded – undo
219 219
  *  @return	array						Array of array('name'=>'xxx','fullname'=>'/abc/xxx','type'=>'dir|file',...)
220 220
  *  @see dol_dir_list
221 221
  */
222
-function dol_dir_list_in_database($path, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0)
222
+function dol_dir_list_in_database($path, $filter = "", $excludefilter = null, $sortcriteria = "name", $sortorder = SORT_ASC, $mode = 0)
223 223
 {
224 224
     global $conf, $db;
225 225
 
226
-    $sql=" SELECT rowid, label, entity, filename, filepath, fullpath_orig, keywords, cover, gen_or_uploaded, extraparams, date_c, date_m, fk_user_c, fk_user_m, acl, position";
227
-    if ($mode) $sql.=", description";
228
-    $sql.=" FROM ".MAIN_DB_PREFIX."ecm_files";
229
-    $sql.=" WHERE filepath = '".$db->escape($path)."'";
230
-    $sql.=" AND entity = ".$conf->entity;
226
+    $sql = " SELECT rowid, label, entity, filename, filepath, fullpath_orig, keywords, cover, gen_or_uploaded, extraparams, date_c, date_m, fk_user_c, fk_user_m, acl, position";
227
+    if ($mode) $sql .= ", description";
228
+    $sql .= " FROM ".MAIN_DB_PREFIX."ecm_files";
229
+    $sql .= " WHERE filepath = '".$db->escape($path)."'";
230
+    $sql .= " AND entity = ".$conf->entity;
231 231
 
232 232
     $resql = $db->query($sql);
233 233
     if ($resql)
234 234
     {
235
-        $file_list=array();
235
+        $file_list = array();
236 236
         $num = $db->num_rows($resql);
237 237
         $i = 0;
238 238
         while ($i < $num)
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
             $obj = $db->fetch_object($resql);
241 241
             if ($obj)
242 242
             {
243
-                preg_match('/([^\/]+)\/[^\/]+$/',DOL_DATA_ROOT.'/'.$obj->filepath.'/'.$obj->filename,$reg);
244
-                $level1name=(isset($reg[1])?$reg[1]:'');
243
+                preg_match('/([^\/]+)\/[^\/]+$/', DOL_DATA_ROOT.'/'.$obj->filepath.'/'.$obj->filename, $reg);
244
+                $level1name = (isset($reg[1]) ? $reg[1] : '');
245 245
                 $file_list[] = array(
246 246
                     "rowid" => $obj->rowid,
247
-                    "label" => $obj->label,         // md5
247
+                    "label" => $obj->label, // md5
248 248
     				"name" => $obj->filename,
249 249
     				"path" => DOL_DATA_ROOT.'/'.$obj->filepath,
250 250
                     "level1name" => $level1name,
@@ -263,12 +263,12 @@  discard block
 block discarded – undo
263 263
         }
264 264
 
265 265
         // Obtain a list of columns
266
-        if (! empty($sortcriteria))
266
+        if (!empty($sortcriteria))
267 267
         {
268
-            $myarray=array();
268
+            $myarray = array();
269 269
             foreach ($file_list as $key => $row)
270 270
             {
271
-                $myarray[$key] = (isset($row[$sortcriteria])?$row[$sortcriteria]:'');
271
+                $myarray[$key] = (isset($row[$sortcriteria]) ? $row[$sortcriteria] : '');
272 272
             }
273 273
             // Sort the data
274 274
             if ($sortorder) array_multisort($myarray, $sortorder, $file_list);
@@ -302,37 +302,37 @@  discard block
 block discarded – undo
302 302
 	//var_dump($filearrayindatabase);
303 303
 
304 304
 	// Complete filearray with properties found into $filearrayindatabase
305
-	foreach($filearray as $key => $val)
305
+	foreach ($filearray as $key => $val)
306 306
 	{
307
-		$found=0;
307
+		$found = 0;
308 308
 		// Search if it exists into $filearrayindatabase
309
-		foreach($filearrayindatabase as $key2 => $val2)
309
+		foreach ($filearrayindatabase as $key2 => $val2)
310 310
 		{
311 311
 			if ($filearrayindatabase[$key2]['name'] == $filearray[$key]['name'])
312 312
 			{
313
-				$filearray[$key]['position_name']=($filearrayindatabase[$key2]['position']?$filearrayindatabase[$key2]['position']:'0').'_'.$filearrayindatabase[$key2]['name'];
314
-				$filearray[$key]['position']=$filearrayindatabase[$key2]['position'];
315
-				$filearray[$key]['cover']=$filearrayindatabase[$key2]['cover'];
316
-				$filearray[$key]['acl']=$filearrayindatabase[$key2]['acl'];
317
-				$filearray[$key]['rowid']=$filearrayindatabase[$key2]['rowid'];
318
-				$filearray[$key]['label']=$filearrayindatabase[$key2]['label'];
319
-				$found=1;
313
+				$filearray[$key]['position_name'] = ($filearrayindatabase[$key2]['position'] ? $filearrayindatabase[$key2]['position'] : '0').'_'.$filearrayindatabase[$key2]['name'];
314
+				$filearray[$key]['position'] = $filearrayindatabase[$key2]['position'];
315
+				$filearray[$key]['cover'] = $filearrayindatabase[$key2]['cover'];
316
+				$filearray[$key]['acl'] = $filearrayindatabase[$key2]['acl'];
317
+				$filearray[$key]['rowid'] = $filearrayindatabase[$key2]['rowid'];
318
+				$filearray[$key]['label'] = $filearrayindatabase[$key2]['label'];
319
+				$found = 1;
320 320
 				break;
321 321
 			}
322 322
 		}
323 323
 
324
-		if (! $found)    // This happen in transition toward version 6, or if files were added manually into os dir.
324
+		if (!$found)    // This happen in transition toward version 6, or if files were added manually into os dir.
325 325
 		{
326
-			$filearray[$key]['position']='999999';     // File not indexed are at end. So if we add a file, it will not replace an existing position
327
-			$filearray[$key]['cover']=0;
328
-			$filearray[$key]['acl']='';
326
+			$filearray[$key]['position'] = '999999'; // File not indexed are at end. So if we add a file, it will not replace an existing position
327
+			$filearray[$key]['cover'] = 0;
328
+			$filearray[$key]['acl'] = '';
329 329
 
330
-			$rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filearray[$key]['fullname']);
331
-			if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter))     // If not a tmp file
330
+			$rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filearray[$key]['fullname']);
331
+			if (!preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter))     // If not a tmp file
332 332
 			{
333 333
 				dol_syslog("list_of_documents We found a file called '".$filearray[$key]['name']."' not indexed into database. We add it");
334 334
 				include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
335
-				$ecmfile=new EcmFiles($db);
335
+				$ecmfile = new EcmFiles($db);
336 336
 
337 337
 				// Add entry into database
338 338
 				$filename = basename($rel_filename);
@@ -342,11 +342,11 @@  discard block
 block discarded – undo
342 342
 
343 343
 				$ecmfile->filepath = $rel_dir;
344 344
 				$ecmfile->filename = $filename;
345
-				$ecmfile->label = md5_file(dol_osencode($filearray[$key]['fullname']));        // $destfile is a full path to file
345
+				$ecmfile->label = md5_file(dol_osencode($filearray[$key]['fullname'])); // $destfile is a full path to file
346 346
 				$ecmfile->fullpath_orig = $filearray[$key]['fullname'];
347 347
 				$ecmfile->gen_or_uploaded = 'unknown';
348
-				$ecmfile->description = '';    // indexed content
349
-				$ecmfile->keyword = '';        // keyword content
348
+				$ecmfile->description = ''; // indexed content
349
+				$ecmfile->keyword = ''; // keyword content
350 350
 				$result = $ecmfile->create($user);
351 351
 				if ($result < 0)
352 352
 				{
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 				}
355 355
 				else
356 356
 				{
357
-					$filearray[$key]['rowid']=$result;
357
+					$filearray[$key]['rowid'] = $result;
358 358
 				}
359 359
 			}
360 360
 			else
361 361
 			{
362
-				$filearray[$key]['rowid']=0;     // Should not happened
362
+				$filearray[$key]['rowid'] = 0; // Should not happened
363 363
 			}
364 364
 		}
365 365
 	}
@@ -380,10 +380,10 @@  discard block
 block discarded – undo
380 380
 	global $sortorder;
381 381
 	global $sortfield;
382 382
 
383
-	$sortorder=strtoupper($sortorder);
383
+	$sortorder = strtoupper($sortorder);
384 384
 
385
-	if ($sortorder == 'ASC') { $retup=-1; $retdown=1; }
386
-	else { $retup=1; $retdown=-1; }
385
+	if ($sortorder == 'ASC') { $retup = -1; $retdown = 1; }
386
+	else { $retup = 1; $retdown = -1; }
387 387
 
388 388
 	if ($sortfield == 'name')
389 389
 	{
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
  */
412 412
 function dol_is_dir($folder)
413 413
 {
414
-    $newfolder=dol_osencode($folder);
414
+    $newfolder = dol_osencode($folder);
415 415
     if (is_dir($newfolder)) return true;
416 416
     else return false;
417 417
 }
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
  */
425 425
 function dol_is_file($pathoffile)
426 426
 {
427
-    $newpathoffile=dol_osencode($pathoffile);
427
+    $newpathoffile = dol_osencode($pathoffile);
428 428
     return is_file($newpathoffile);
429 429
 }
430 430
 
@@ -436,10 +436,10 @@  discard block
 block discarded – undo
436 436
  */
437 437
 function dol_is_url($url)
438 438
 {
439
-    $tmpprot=array('file','http','https','ftp','zlib','data','ssh','ssh2','ogg','expect');
440
-    foreach($tmpprot as $prot)
439
+    $tmpprot = array('file', 'http', 'https', 'ftp', 'zlib', 'data', 'ssh', 'ssh2', 'ogg', 'expect');
440
+    foreach ($tmpprot as $prot)
441 441
     {
442
-        if (preg_match('/^'.$prot.':/i',$url)) return true;
442
+        if (preg_match('/^'.$prot.':/i', $url)) return true;
443 443
     }
444 444
     return false;
445 445
 }
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
  */
453 453
 function dol_dir_is_emtpy($folder)
454 454
 {
455
-	$newfolder=dol_osencode($folder);
455
+	$newfolder = dol_osencode($folder);
456 456
 	if (is_dir($newfolder))
457 457
 	{
458 458
 		$handle = opendir($newfolder);
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 		{
462 462
 			$name_array[] = $name;
463 463
 		}
464
-		foreach($name_array as $temp) $folder_content .= $temp;
464
+		foreach ($name_array as $temp) $folder_content .= $temp;
465 465
 
466 466
         closedir($handle);
467 467
 
@@ -481,24 +481,24 @@  discard block
 block discarded – undo
481 481
  */
482 482
 function dol_count_nb_of_line($file)
483 483
 {
484
-	$nb=0;
484
+	$nb = 0;
485 485
 
486
-	$newfile=dol_osencode($file);
486
+	$newfile = dol_osencode($file);
487 487
 	//print 'x'.$file;
488
-	$fp=fopen($newfile,'r');
488
+	$fp = fopen($newfile, 'r');
489 489
 	if ($fp)
490 490
 	{
491 491
 		while (!feof($fp))
492 492
 		{
493
-			$line=fgets($fp);
493
+			$line = fgets($fp);
494 494
             // We increase count only if read was success. We need test because feof return true only after fgets so we do n+1 fgets for a file with n lines.
495
-			if (! $line === false) $nb++;
495
+			if (!$line === false) $nb++;
496 496
 		}
497 497
 		fclose($fp);
498 498
 	}
499 499
 	else
500 500
 	{
501
-		$nb=-1;
501
+		$nb = -1;
502 502
 	}
503 503
 
504 504
 	return $nb;
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
  */
514 514
 function dol_filesize($pathoffile)
515 515
 {
516
-	$newpathoffile=dol_osencode($pathoffile);
516
+	$newpathoffile = dol_osencode($pathoffile);
517 517
 	return filesize($newpathoffile);
518 518
 }
519 519
 
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
  */
526 526
 function dol_filemtime($pathoffile)
527 527
 {
528
-	$newpathoffile=dol_osencode($pathoffile);
528
+	$newpathoffile = dol_osencode($pathoffile);
529 529
 	return @filemtime($newpathoffile); // @Is to avoid errors if files does not exists
530 530
 }
531 531
 
@@ -540,31 +540,31 @@  discard block
 block discarded – undo
540 540
  * @return	int							<0 if error, 0 if nothing done (dest file already exists), >0 if OK
541 541
  * @see		dolCopyr dolReplaceRegExInFile
542 542
  */
543
-function dolReplaceInFile($srcfile, $arrayreplacement, $destfile='', $newmask=0, $indexdatabase=0)
543
+function dolReplaceInFile($srcfile, $arrayreplacement, $destfile = '', $newmask = 0, $indexdatabase = 0)
544 544
 {
545 545
     global $conf;
546 546
 
547 547
     dol_syslog("files.lib.php::dolReplaceInFile srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." indexdatabase=".$indexdatabase);
548 548
 
549 549
     if (empty($srcfile)) return -1;
550
-    if (empty($destfile)) $destfile=$srcfile;
550
+    if (empty($destfile)) $destfile = $srcfile;
551 551
 
552
-    $destexists=dol_is_file($destfile);
552
+    $destexists = dol_is_file($destfile);
553 553
     if (($destfile != $srcfile) && $destexists) return 0;
554 554
 
555
-    $tmpdestfile=$destfile.'.tmp';
555
+    $tmpdestfile = $destfile.'.tmp';
556 556
 
557
-    $newpathofsrcfile=dol_osencode($srcfile);
558
-    $newpathoftmpdestfile=dol_osencode($tmpdestfile);
559
-    $newpathofdestfile=dol_osencode($destfile);
560
-    $newdirdestfile=dirname($newpathofdestfile);
557
+    $newpathofsrcfile = dol_osencode($srcfile);
558
+    $newpathoftmpdestfile = dol_osencode($tmpdestfile);
559
+    $newpathofdestfile = dol_osencode($destfile);
560
+    $newdirdestfile = dirname($newpathofdestfile);
561 561
 
562
-    if ($destexists && ! is_writable($newpathofdestfile))
562
+    if ($destexists && !is_writable($newpathofdestfile))
563 563
     {
564 564
         dol_syslog("files.lib.php::dolReplaceInFile failed Permission denied to overwrite target file", LOG_WARNING);
565 565
         return -1;
566 566
     }
567
-    if (! is_writable($newdirdestfile))
567
+    if (!is_writable($newdirdestfile))
568 568
     {
569 569
         dol_syslog("files.lib.php::dolReplaceInFile failed Permission denied to write into target directory ".$newdirdestfile, LOG_WARNING);
570 570
         return -2;
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
     dol_delete_file($tmpdestfile);
574 574
 
575 575
     // Create $newpathoftmpdestfile from $newpathofsrcfile
576
-    $content=file_get_contents($newpathofsrcfile, 'r');
576
+    $content = file_get_contents($newpathofsrcfile, 'r');
577 577
 
578 578
     $content = make_substitutions($content, $arrayreplacement, null);
579 579
 
@@ -581,17 +581,17 @@  discard block
 block discarded – undo
581 581
     @chmod($newpathoftmpdestfile, octdec($newmask));
582 582
 
583 583
     // Rename
584
-    $result=dol_move($newpathoftmpdestfile, $newpathofdestfile, $newmask, (($destfile == $srcfile)?1:0), 0, $indexdatabase);
585
-    if (! $result)
584
+    $result = dol_move($newpathoftmpdestfile, $newpathofdestfile, $newmask, (($destfile == $srcfile) ? 1 : 0), 0, $indexdatabase);
585
+    if (!$result)
586 586
     {
587 587
         dol_syslog("files.lib.php::dolReplaceInFile failed to move tmp file to final dest", LOG_WARNING);
588 588
         return -3;
589 589
     }
590
-    if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
590
+    if (empty($newmask) && !empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK;
591 591
     if (empty($newmask))	// This should no happen
592 592
     {
593 593
         dol_syslog("Warning: dolReplaceInFile called with empty value for newmask and no default value defined", LOG_WARNING);
594
-        $newmask='0664';
594
+        $newmask = '0664';
595 595
     }
596 596
 
597 597
     @chmod($newpathofdestfile, octdec($newmask));
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
  * @return	int							<0 if error, 0 if nothing done (dest file already exists), >0 if OK
611 611
  * @see		dolCopyr dolReplaceInFile
612 612
  */
613
-function dolReplaceRegExInFile($srcfile, $arrayreplacement, $destfile='', $newmask=0, $indexdatabase=0)
613
+function dolReplaceRegExInFile($srcfile, $arrayreplacement, $destfile = '', $newmask = 0, $indexdatabase = 0)
614 614
 {
615 615
 	// TODO
616 616
 
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
  * @return	int							<0 if error, 0 if nothing done (dest file already exists and overwriteifexists=0), >0 if OK
627 627
  * @see		dolCopyr
628 628
  */
629
-function dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
629
+function dol_copy($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1)
630 630
 {
631 631
 	global $conf;
632 632
 
@@ -634,36 +634,36 @@  discard block
 block discarded – undo
634 634
 
635 635
 	if (empty($srcfile) || empty($destfile)) return -1;
636 636
 
637
-	$destexists=dol_is_file($destfile);
638
-	if (! $overwriteifexists && $destexists) return 0;
637
+	$destexists = dol_is_file($destfile);
638
+	if (!$overwriteifexists && $destexists) return 0;
639 639
 
640
-	$newpathofsrcfile=dol_osencode($srcfile);
641
-    $newpathofdestfile=dol_osencode($destfile);
642
-    $newdirdestfile=dirname($newpathofdestfile);
640
+	$newpathofsrcfile = dol_osencode($srcfile);
641
+    $newpathofdestfile = dol_osencode($destfile);
642
+    $newdirdestfile = dirname($newpathofdestfile);
643 643
 
644
-    if ($destexists && ! is_writable($newpathofdestfile))
644
+    if ($destexists && !is_writable($newpathofdestfile))
645 645
     {
646 646
         dol_syslog("files.lib.php::dol_copy failed Permission denied to overwrite target file", LOG_WARNING);
647 647
         return -1;
648 648
     }
649
-    if (! is_writable($newdirdestfile))
649
+    if (!is_writable($newdirdestfile))
650 650
     {
651 651
         dol_syslog("files.lib.php::dol_copy failed Permission denied to write into target directory ".$newdirdestfile, LOG_WARNING);
652 652
         return -2;
653 653
     }
654 654
     // Copy with overwriting if exists
655
-    $result=@copy($newpathofsrcfile, $newpathofdestfile);
655
+    $result = @copy($newpathofsrcfile, $newpathofdestfile);
656 656
 	//$result=copy($newpathofsrcfile, $newpathofdestfile);	// To see errors, remove @
657
-	if (! $result)
657
+	if (!$result)
658 658
 	{
659 659
 	    dol_syslog("files.lib.php::dol_copy failed to copy", LOG_WARNING);
660 660
 	    return -3;
661 661
 	}
662
-	if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
662
+	if (empty($newmask) && !empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK;
663 663
 	if (empty($newmask))	// This should no happen
664 664
 	{
665 665
 		dol_syslog("Warning: dol_copy called with empty value for newmask and no default value defined", LOG_WARNING);
666
-		$newmask='0664';
666
+		$newmask = '0664';
667 667
 	}
668 668
 
669 669
 	@chmod($newpathofdestfile, octdec($newmask));
@@ -682,44 +682,44 @@  discard block
 block discarded – undo
682 682
  * @return	int							<0 if error, 0 if nothing done (all files already exists and overwriteifexists=0), >0 if OK
683 683
  * @see		dol_copy
684 684
  */
685
-function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement=null)
685
+function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement = null)
686 686
 {
687 687
 	global $conf;
688 688
 
689
-	$result=0;
689
+	$result = 0;
690 690
 
691 691
 	dol_syslog("files.lib.php::dolCopyDir srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwriteifexists=".$overwriteifexists);
692 692
 
693 693
 	if (empty($srcfile) || empty($destfile)) return -1;
694 694
 
695
-	$destexists=dol_is_dir($destfile);
695
+	$destexists = dol_is_dir($destfile);
696 696
 	//if (! $overwriteifexists && $destexists) return 0;	// The overwriteifexists is for files only, so propagated to dol_copy only.
697 697
 
698
-    if (! $destexists)
698
+    if (!$destexists)
699 699
     {
700 700
         // We must set mask just before creating dir, becaause it can be set differently by dol_copy
701 701
         umask(0);
702
-        $dirmaskdec=octdec($newmask);
703
-        if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK);
704
-        $dirmaskdec |= octdec('0200');  // Set w bit required to be able to create content for recursive subdirs files
702
+        $dirmaskdec = octdec($newmask);
703
+        if (empty($newmask) && !empty($conf->global->MAIN_UMASK)) $dirmaskdec = octdec($conf->global->MAIN_UMASK);
704
+        $dirmaskdec |= octdec('0200'); // Set w bit required to be able to create content for recursive subdirs files
705 705
         dol_mkdir($destfile, '', decoct($dirmaskdec));
706 706
     }
707 707
 
708
-	$ossrcfile=dol_osencode($srcfile);
709
-	$osdestfile=dol_osencode($destfile);
708
+	$ossrcfile = dol_osencode($srcfile);
709
+	$osdestfile = dol_osencode($destfile);
710 710
 
711 711
     // Recursive function to copy all subdirectories and contents:
712 712
 	if (is_dir($ossrcfile))
713 713
 	{
714
-        $dir_handle=opendir($ossrcfile);
715
-        while ($file=readdir($dir_handle))
714
+        $dir_handle = opendir($ossrcfile);
715
+        while ($file = readdir($dir_handle))
716 716
         {
717
-            if ($file != "." && $file != ".." && ! is_link($ossrcfile."/".$file))
717
+            if ($file != "." && $file != ".." && !is_link($ossrcfile."/".$file))
718 718
             {
719 719
                 if (is_dir($ossrcfile."/".$file))
720 720
                 {
721 721
                     //var_dump("xxx dolCopyDir $srcfile/$file, $destfile/$file, $newmask, $overwriteifexists");
722
-                    $tmpresult=dolCopyDir($srcfile."/".$file, $destfile."/".$file, $newmask, $overwriteifexists, $arrayreplacement);
722
+                    $tmpresult = dolCopyDir($srcfile."/".$file, $destfile."/".$file, $newmask, $overwriteifexists, $arrayreplacement);
723 723
                 }
724 724
                 else
725 725
 				{
@@ -727,12 +727,12 @@  discard block
 block discarded – undo
727 727
 					// Replace destination filename with a new one
728 728
 					if (is_array($arrayreplacement))
729 729
 					{
730
-						foreach($arrayreplacement as $key => $val)
730
+						foreach ($arrayreplacement as $key => $val)
731 731
 						{
732 732
 							$newfile = str_replace($key, $val, $newfile);
733 733
 						}
734 734
 					}
735
-                    $tmpresult=dol_copy($srcfile."/".$file, $destfile."/".$newfile, $newmask, $overwriteifexists);
735
+                    $tmpresult = dol_copy($srcfile."/".$file, $destfile."/".$newfile, $newmask, $overwriteifexists);
736 736
                 }
737 737
                 // Set result
738 738
                 if ($result > 0 && $tmpresult >= 0)
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
                 }
742 742
                 else
743 743
                 {
744
-                    $result=$tmpresult;
744
+                    $result = $tmpresult;
745 745
                 }
746 746
                 if ($result < 0) break;
747 747
 
@@ -775,31 +775,31 @@  discard block
 block discarded – undo
775 775
  * @return  boolean 		            True if OK, false if KO
776 776
  * @see dol_move_uploaded_file
777 777
  */
778
-function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvirus=0, $indexdatabase=1)
778
+function dol_move($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1, $testvirus = 0, $indexdatabase = 1)
779 779
 {
780 780
     global $user, $db, $conf;
781
-    $result=false;
781
+    $result = false;
782 782
 
783 783
     dol_syslog("files.lib.php::dol_move srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwritifexists=".$overwriteifexists);
784
-    $srcexists=dol_is_file($srcfile);
785
-    $destexists=dol_is_file($destfile);
784
+    $srcexists = dol_is_file($srcfile);
785
+    $destexists = dol_is_file($destfile);
786 786
 
787
-    if (! $srcexists)
787
+    if (!$srcexists)
788 788
     {
789 789
         dol_syslog("files.lib.php::dol_move srcfile does not exists. we ignore the move request.");
790 790
         return false;
791 791
     }
792 792
 
793
-    if ($overwriteifexists || ! $destexists)
793
+    if ($overwriteifexists || !$destexists)
794 794
     {
795
-        $newpathofsrcfile=dol_osencode($srcfile);
796
-        $newpathofdestfile=dol_osencode($destfile);
795
+        $newpathofsrcfile = dol_osencode($srcfile);
796
+        $newpathofdestfile = dol_osencode($destfile);
797 797
 
798 798
         // Check virus
799
-        $testvirusarray=array();
799
+        $testvirusarray = array();
800 800
         if ($testvirus)
801 801
         {
802
-            $testvirusarray=dolCheckVirus($newpathofsrcfile);
802
+            $testvirusarray = dolCheckVirus($newpathofsrcfile);
803 803
             if (count($testvirusarray))
804 804
             {
805 805
                 dol_syslog("files.lib.php::dol_move canceled because a virus was found into source file. we ignore the move request.", LOG_WARNING);
@@ -807,15 +807,15 @@  discard block
 block discarded – undo
807 807
             }
808 808
         }
809 809
 
810
-        $result=@rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @
811
-        if (! $result)
810
+        $result = @rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @
811
+        if (!$result)
812 812
         {
813 813
         	if ($destexists)
814 814
         	{
815 815
         		dol_syslog("files.lib.php::dol_move Failed. We try to delete target first and move after.", LOG_WARNING);
816 816
         		// We force delete and try again. Rename function sometimes fails to replace dest file with some windows NTFS partitions.
817 817
         		dol_delete_file($destfile);
818
-        		$result=@rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @
818
+        		$result = @rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @
819 819
         	}
820 820
         	else dol_syslog("files.lib.php::dol_move Failed.", LOG_WARNING);
821 821
         }
@@ -824,9 +824,9 @@  discard block
 block discarded – undo
824 824
         if ($result && $indexdatabase)
825 825
         {
826 826
             // Rename entry into ecm database
827
-            $rel_filetorenamebefore = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $srcfile);
828
-            $rel_filetorenameafter = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $destfile);
829
-            if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter))     // If not a tmp file
827
+            $rel_filetorenamebefore = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $srcfile);
828
+            $rel_filetorenameafter = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $destfile);
829
+            if (!preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter))     // If not a tmp file
830 830
             {
831 831
                 $rel_filetorenamebefore = preg_replace('/^[\\/]/', '', $rel_filetorenamebefore);
832 832
                 $rel_filetorenameafter = preg_replace('/^[\\/]/', '', $rel_filetorenameafter);
@@ -835,14 +835,14 @@  discard block
 block discarded – undo
835 835
                 dol_syslog("Try to rename also entries in database for full relative path before = ".$rel_filetorenamebefore." after = ".$rel_filetorenameafter, LOG_DEBUG);
836 836
                 include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
837 837
 
838
-                $ecmfiletarget=new EcmFiles($db);
838
+                $ecmfiletarget = new EcmFiles($db);
839 839
                 $resultecmtarget = $ecmfiletarget->fetch(0, '', $rel_filetorenameafter);
840 840
                 if ($resultecmtarget > 0)   // An entry for target name already exists for target, we delete it, a new one will be created.
841 841
                 {
842 842
                     $ecmfiletarget->delete($user);
843 843
                 }
844 844
 
845
-                $ecmfile=new EcmFiles($db);
845
+                $ecmfile = new EcmFiles($db);
846 846
                 $resultecm = $ecmfile->fetch(0, '', $rel_filetorenamebefore);
847 847
                 if ($resultecm > 0)   // If an entry was found for src file, we use it to move entry
848 848
                 {
@@ -864,11 +864,11 @@  discard block
 block discarded – undo
864 864
 
865 865
                     $ecmfile->filepath = $rel_dir;
866 866
                     $ecmfile->filename = $filename;
867
-                    $ecmfile->label = md5_file(dol_osencode($destfile));        // $destfile is a full path to file
867
+                    $ecmfile->label = md5_file(dol_osencode($destfile)); // $destfile is a full path to file
868 868
                     $ecmfile->fullpath_orig = $srcfile;
869 869
                     $ecmfile->gen_or_uploaded = 'unknown';
870
-                    $ecmfile->description = '';    // indexed content
871
-                    $ecmfile->keyword = '';        // keyword content
870
+                    $ecmfile->description = ''; // indexed content
871
+                    $ecmfile->keyword = ''; // keyword content
872 872
                     $resultecm = $ecmfile->create($user);
873 873
                     if ($resultecm < 0)
874 874
                     {
@@ -880,13 +880,13 @@  discard block
 block discarded – undo
880 880
                     setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
881 881
                 }
882 882
 
883
-                if ($resultecm > 0) $result=true;
883
+                if ($resultecm > 0) $result = true;
884 884
                 else $result = false;
885 885
             }
886 886
         }
887 887
 
888
-        if (empty($newmask)) $newmask=empty($conf->global->MAIN_UMASK)?'0755':$conf->global->MAIN_UMASK;
889
-        $newmaskdec=octdec($newmask);
888
+        if (empty($newmask)) $newmask = empty($conf->global->MAIN_UMASK) ? '0755' : $conf->global->MAIN_UMASK;
889
+        $newmaskdec = octdec($newmask);
890 890
         // Currently method is restricted to files (dol_delete_files previously used is for files, and mask usage if for files too)
891 891
         // to allow mask usage for dir, we shoul introduce a new param "isdir" to 1 to complete newmask like this
892 892
         // if ($isdir) $newmaskdec |= octdec('0111');  // Set x bit required for directories
@@ -922,16 +922,16 @@  discard block
 block discarded – undo
922 922
 {
923 923
     global $conf;
924 924
 
925
-    if (! empty($conf->global->MAIN_ANTIVIRUS_COMMAND))
925
+    if (!empty($conf->global->MAIN_ANTIVIRUS_COMMAND))
926 926
     {
927
-        if (! class_exists('AntiVir')) {
927
+        if (!class_exists('AntiVir')) {
928 928
             require_once DOL_DOCUMENT_ROOT.'/core/class/antivir.class.php';
929 929
         }
930
-        $antivir=new AntiVir($db);
930
+        $antivir = new AntiVir($db);
931 931
         $result = $antivir->dol_avscan_file($src_file);
932 932
         if ($result < 0)	// If virus or error, we stop here
933 933
         {
934
-            $reterrors=$antivir->errors;
934
+            $reterrors = $antivir->errors;
935 935
             return $reterrors;
936 936
         }
937 937
     }
@@ -957,20 +957,20 @@  discard block
 block discarded – undo
957 957
  *	@return int       			  		>0 if OK, <0 or string if KO
958 958
  *  @see    dol_move
959 959
  */
960
-function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile')
960
+function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan = 0, $uploaderrorcode = 0, $nohook = 0, $varfiles = 'addedfile')
961 961
 {
962 962
 	global $conf, $db, $user, $langs;
963 963
 	global $object, $hookmanager;
964 964
 
965
-	$reshook=0;
965
+	$reshook = 0;
966 966
 	$file_name = $dest_file;
967 967
 
968 968
 	if (empty($nohook))
969 969
 	{
970
-		$reshook=$hookmanager->initHooks(array('fileslib'));
970
+		$reshook = $hookmanager->initHooks(array('fileslib'));
971 971
 
972
-		$parameters=array('dest_file' => $dest_file, 'src_file' => $src_file, 'file_name' => $file_name, 'varfiles' => $varfiles, 'allowoverwrite' => $allowoverwrite);
973
-		$reshook=$hookmanager->executeHooks('moveUploadedFile', $parameters, $object);
972
+		$parameters = array('dest_file' => $dest_file, 'src_file' => $src_file, 'file_name' => $file_name, 'varfiles' => $varfiles, 'allowoverwrite' => $allowoverwrite);
973
+		$reshook = $hookmanager->executeHooks('moveUploadedFile', $parameters, $object);
974 974
 	}
975 975
 
976 976
 	if (empty($reshook))
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
     	// If an upload error has been reported
979 979
     	if ($uploaderrorcode)
980 980
     	{
981
-    	    switch($uploaderrorcode)
981
+    	    switch ($uploaderrorcode)
982 982
     	    {
983 983
     	        case UPLOAD_ERR_INI_SIZE:	// 1
984 984
     	            return 'ErrorFileSizeTooLarge';
@@ -1006,25 +1006,25 @@  discard block
 block discarded – undo
1006 1006
     	// If we need to make a virus scan
1007 1007
     	if (empty($disablevirusscan) && file_exists($src_file))
1008 1008
     	{
1009
-    	    $checkvirusarray=dolCheckVirus($src_file);
1009
+    	    $checkvirusarray = dolCheckVirus($src_file);
1010 1010
     	    if (count($checkvirusarray))
1011 1011
     	    {
1012
-    	       dol_syslog('Files.lib::dol_move_uploaded_file File "'.$src_file.'" (target name "'.$dest_file.'") KO with antivirus: result='.$result.' errors='.join(',',$checkvirusarray), LOG_WARNING);
1013
-    	       return 'ErrorFileIsInfectedWithAVirus: '.join(',',$checkvirusarray);
1012
+    	       dol_syslog('Files.lib::dol_move_uploaded_file File "'.$src_file.'" (target name "'.$dest_file.'") KO with antivirus: result='.$result.' errors='.join(',', $checkvirusarray), LOG_WARNING);
1013
+    	       return 'ErrorFileIsInfectedWithAVirus: '.join(',', $checkvirusarray);
1014 1014
     	    }
1015 1015
     	}
1016 1016
 
1017 1017
     	// Security:
1018 1018
     	// Disallow file with some extensions. We rename them.
1019 1019
     	// Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code.
1020
-    	if (preg_match('/\.htm|\.html|\.php|\.pl|\.cgi$/i',$dest_file) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED))
1020
+    	if (preg_match('/\.htm|\.html|\.php|\.pl|\.cgi$/i', $dest_file) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED))
1021 1021
     	{
1022
-    	    $file_name.= '.noexe';
1022
+    	    $file_name .= '.noexe';
1023 1023
     	}
1024 1024
 
1025 1025
     	// Security:
1026 1026
     	// We refuse cache files/dirs, upload using .. and pipes into filenames.
1027
-    	if (preg_match('/^\./',$src_file) || preg_match('/\.\./',$src_file) || preg_match('/[<>|]/',$src_file))
1027
+    	if (preg_match('/^\./', $src_file) || preg_match('/\.\./', $src_file) || preg_match('/[<>|]/', $src_file))
1028 1028
     	{
1029 1029
     	    dol_syslog("Refused to deliver file ".$src_file, LOG_WARNING);
1030 1030
     	    return -1;
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
 
1033 1033
     	// Security:
1034 1034
     	// On interdit fichiers caches, remontees de repertoire ainsi que les pipe dans les noms de fichiers.
1035
-    	if (preg_match('/^\./',$dest_file) || preg_match('/\.\./',$dest_file) || preg_match('/[<>|]/',$dest_file))
1035
+    	if (preg_match('/^\./', $dest_file) || preg_match('/\.\./', $dest_file) || preg_match('/[<>|]/', $dest_file))
1036 1036
     	{
1037 1037
     	    dol_syslog("Refused to deliver file ".$dest_file, LOG_WARNING);
1038 1038
     	    return -2;
@@ -1042,20 +1042,20 @@  discard block
 block discarded – undo
1042 1042
 	if ($reshook < 0)	// At least one blocking error returned by one hook
1043 1043
 	{
1044 1044
 		$errmsg = join(',', $hookmanager->errors);
1045
-		if (empty($errmsg)) $errmsg = 'ErrorReturnedBySomeHooks';	// Should not occurs. Added if hook is bugged and does not set ->errors when there is error.
1045
+		if (empty($errmsg)) $errmsg = 'ErrorReturnedBySomeHooks'; // Should not occurs. Added if hook is bugged and does not set ->errors when there is error.
1046 1046
 		return $errmsg;
1047 1047
 	}
1048 1048
 	elseif (empty($reshook))
1049 1049
 	{
1050 1050
 		// The file functions must be in OS filesystem encoding.
1051
-		$src_file_osencoded=dol_osencode($src_file);
1052
-		$file_name_osencoded=dol_osencode($file_name);
1051
+		$src_file_osencoded = dol_osencode($src_file);
1052
+		$file_name_osencoded = dol_osencode($file_name);
1053 1053
 
1054 1054
 		// Check if destination dir is writable
1055 1055
 		// TODO
1056 1056
 
1057 1057
 		// Check if destination file already exists
1058
-		if (! $allowoverwrite)
1058
+		if (!$allowoverwrite)
1059 1059
 		{
1060 1060
 			if (file_exists($file_name_osencoded))
1061 1061
 			{
@@ -1065,21 +1065,21 @@  discard block
 block discarded – undo
1065 1065
 		}
1066 1066
 
1067 1067
 		// Move file
1068
-		$return=move_uploaded_file($src_file_osencoded, $file_name_osencoded);
1068
+		$return = move_uploaded_file($src_file_osencoded, $file_name_osencoded);
1069 1069
 		if ($return)
1070 1070
 		{
1071
-			if (! empty($conf->global->MAIN_UMASK)) @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK));
1071
+			if (!empty($conf->global->MAIN_UMASK)) @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK));
1072 1072
 			dol_syslog("Files.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=".$conf->global->MAIN_UMASK, LOG_DEBUG);
1073
-			return 1;	// Success
1073
+			return 1; // Success
1074 1074
 		}
1075 1075
 		else
1076 1076
 		{
1077 1077
 			dol_syslog("Files.lib::dol_move_uploaded_file Failed to move ".$src_file." to ".$file_name, LOG_ERR);
1078
-			return -3;	// Unknown error
1078
+			return -3; // Unknown error
1079 1079
 		}
1080 1080
 	}
1081 1081
 
1082
-	return 1;	// Success
1082
+	return 1; // Success
1083 1083
 }
1084 1084
 
1085 1085
 /**
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
  *  @return boolean         		True if no error (file is deleted or if glob is used and there's nothing to delete), False if error
1095 1095
  *  @see dol_delete_dir
1096 1096
  */
1097
-function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=null)
1097
+function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, $object = null)
1098 1098
 {
1099 1099
 	global $db, $conf, $user, $langs;
1100 1100
 	global $hookmanager;
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 
1107 1107
 	// Security:
1108 1108
 	// We refuse transversal using .. and pipes into filenames.
1109
-	if (preg_match('/\.\./',$file) || preg_match('/[<>|]/',$file))
1109
+	if (preg_match('/\.\./', $file) || preg_match('/[<>|]/', $file))
1110 1110
 	{
1111 1111
         dol_syslog("Refused to delete file ".$file, LOG_WARNING);
1112 1112
 	    return False;
@@ -1116,13 +1116,13 @@  discard block
 block discarded – undo
1116 1116
 	{
1117 1117
 		$hookmanager->initHooks(array('fileslib'));
1118 1118
 
1119
-		$parameters=array(
1119
+		$parameters = array(
1120 1120
 				'GET' => $_GET,
1121 1121
 				'file' => $file,
1122 1122
 				'disableglob'=> $disableglob,
1123 1123
 				'nophperrors' => $nophperrors
1124 1124
 		);
1125
-		$reshook=$hookmanager->executeHooks('deleteFile', $parameters, $object);
1125
+		$reshook = $hookmanager->executeHooks('deleteFile', $parameters, $object);
1126 1126
 	}
1127 1127
 
1128 1128
 	if (empty($nohook) && $reshook != 0) // reshook = 0 to do standard actions, 1 = ok, -1 = ko
@@ -1132,35 +1132,35 @@  discard block
 block discarded – undo
1132 1132
 	}
1133 1133
 	else
1134 1134
 	{
1135
-		$error=0;
1135
+		$error = 0;
1136 1136
 
1137 1137
 		//print "x".$file." ".$disableglob;exit;
1138
-		$file_osencoded=dol_osencode($file);    // New filename encoded in OS filesystem encoding charset
1139
-		if (empty($disableglob) && ! empty($file_osencoded))
1138
+		$file_osencoded = dol_osencode($file); // New filename encoded in OS filesystem encoding charset
1139
+		if (empty($disableglob) && !empty($file_osencoded))
1140 1140
 		{
1141
-			$ok=true;
1142
-			$globencoded=str_replace('[','\[',$file_osencoded);
1143
-			$globencoded=str_replace(']','\]',$globencoded);
1144
-			$listofdir=glob($globencoded);
1145
-			if (! empty($listofdir) && is_array($listofdir))
1141
+			$ok = true;
1142
+			$globencoded = str_replace('[', '\[', $file_osencoded);
1143
+			$globencoded = str_replace(']', '\]', $globencoded);
1144
+			$listofdir = glob($globencoded);
1145
+			if (!empty($listofdir) && is_array($listofdir))
1146 1146
 			{
1147 1147
 				foreach ($listofdir as $filename)
1148 1148
 				{
1149
-					if ($nophperrors) $ok=@unlink($filename);
1150
-					else $ok=unlink($filename);
1149
+					if ($nophperrors) $ok = @unlink($filename);
1150
+					else $ok = unlink($filename);
1151 1151
 					if ($ok)
1152 1152
 					{
1153 1153
 					    dol_syslog("Removed file ".$filename, LOG_DEBUG);
1154 1154
 
1155 1155
 	                    // Delete entry into ecm database
1156
-    				    $rel_filetodelete = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filename);
1157
-    				    if (! preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $rel_filetodelete))     // If not a tmp file
1156
+    				    $rel_filetodelete = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filename);
1157
+    				    if (!preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $rel_filetodelete))     // If not a tmp file
1158 1158
     				    {
1159 1159
     				        $rel_filetodelete = preg_replace('/^[\\/]/', '', $rel_filetodelete);
1160 1160
 
1161 1161
     				        dol_syslog("Try to remove also entries in database for full relative path = ".$rel_filetodelete, LOG_DEBUG);
1162 1162
         				    include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
1163
-        				    $ecmfile=new EcmFiles($db);
1163
+        				    $ecmfile = new EcmFiles($db);
1164 1164
         				    $result = $ecmfile->fetch(0, '', $rel_filetodelete);
1165 1165
         				    if ($result >= 0 && $ecmfile->id > 0)
1166 1166
         				    {
@@ -1181,9 +1181,9 @@  discard block
 block discarded – undo
1181 1181
 		}
1182 1182
 		else
1183 1183
 		{
1184
-			$ok=false;
1185
-			if ($nophperrors) $ok=@unlink($file_osencoded);
1186
-			else $ok=unlink($file_osencoded);
1184
+			$ok = false;
1185
+			if ($nophperrors) $ok = @unlink($file_osencoded);
1186
+			else $ok = unlink($file_osencoded);
1187 1187
 			if ($ok) dol_syslog("Removed file ".$file_osencoded, LOG_DEBUG);
1188 1188
 			else dol_syslog("Failed to remove file ".$file_osencoded, LOG_WARNING);
1189 1189
 		}
@@ -1201,18 +1201,18 @@  discard block
 block discarded – undo
1201 1201
  *  @return boolean         		True if success, false if error
1202 1202
  *  @see dol_delete_file
1203 1203
  */
1204
-function dol_delete_dir($dir,$nophperrors=0)
1204
+function dol_delete_dir($dir, $nophperrors = 0)
1205 1205
 {
1206 1206
 	// Security:
1207 1207
 	// We refuse transversal using .. and pipes into filenames.
1208
-	if (preg_match('/\.\./',$dir) || preg_match('/[<>|]/',$dir))
1208
+	if (preg_match('/\.\./', $dir) || preg_match('/[<>|]/', $dir))
1209 1209
 	{
1210 1210
         dol_syslog("Refused to delete dir ".$dir, LOG_WARNING);
1211 1211
 	    return False;
1212 1212
 	}
1213 1213
 
1214
-    $dir_osencoded=dol_osencode($dir);
1215
-    return ($nophperrors?@rmdir($dir_osencoded):rmdir($dir_osencoded));
1214
+    $dir_osencoded = dol_osencode($dir);
1215
+    return ($nophperrors ? @rmdir($dir_osencoded) : rmdir($dir_osencoded));
1216 1216
 }
1217 1217
 
1218 1218
 /**
@@ -1225,27 +1225,27 @@  discard block
 block discarded – undo
1225 1225
  *  @param  int		$countdeleted   Counter to count nb of elements found really deleted
1226 1226
  *  @return int             		Number of files and directory we try to remove. NB really removed is returned into $countdeleted.
1227 1227
  */
1228
-function dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0)
1228
+function dol_delete_dir_recursive($dir, $count = 0, $nophperrors = 0, $onlysub = 0, &$countdeleted = 0)
1229 1229
 {
1230
-    dol_syslog("functions.lib:dol_delete_dir_recursive ".$dir,LOG_DEBUG);
1230
+    dol_syslog("functions.lib:dol_delete_dir_recursive ".$dir, LOG_DEBUG);
1231 1231
     if (dol_is_dir($dir))
1232 1232
     {
1233
-        $dir_osencoded=dol_osencode($dir);
1233
+        $dir_osencoded = dol_osencode($dir);
1234 1234
         if ($handle = opendir("$dir_osencoded"))
1235 1235
         {
1236 1236
             while (false !== ($item = readdir($handle)))
1237 1237
             {
1238
-                if (! utf8_check($item)) $item=utf8_encode($item);  // should be useless
1238
+                if (!utf8_check($item)) $item = utf8_encode($item); // should be useless
1239 1239
 
1240 1240
                 if ($item != "." && $item != "..")
1241 1241
                 {
1242
-                    if (is_dir(dol_osencode("$dir/$item")) && ! is_link(dol_osencode("$dir/$item")))
1242
+                    if (is_dir(dol_osencode("$dir/$item")) && !is_link(dol_osencode("$dir/$item")))
1243 1243
                     {
1244
-                        $count=dol_delete_dir_recursive("$dir/$item", $count, $nophperrors, 0, $countdeleted);
1244
+                        $count = dol_delete_dir_recursive("$dir/$item", $count, $nophperrors, 0, $countdeleted);
1245 1245
                     }
1246 1246
                     else
1247 1247
                     {
1248
-                        $result=dol_delete_file("$dir/$item", 1, $nophperrors);
1248
+                        $result = dol_delete_file("$dir/$item", 1, $nophperrors);
1249 1249
                         $count++;
1250 1250
                         if ($result) $countdeleted++;
1251 1251
                     }
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
 
1256 1256
             if (empty($onlysub))
1257 1257
             {
1258
-	            $result=dol_delete_dir($dir, $nophperrors);
1258
+	            $result = dol_delete_dir($dir, $nophperrors);
1259 1259
 	            $count++;
1260 1260
     	        if ($result) $countdeleted++;
1261 1261
             }
@@ -1274,7 +1274,7 @@  discard block
 block discarded – undo
1274 1274
  */
1275 1275
 function dol_delete_preview($object)
1276 1276
 {
1277
-	global $langs,$conf;
1277
+	global $langs, $conf;
1278 1278
 
1279 1279
 	// Define parent dir of elements
1280 1280
 	$element = $object->element;
@@ -1285,20 +1285,20 @@  discard block
 block discarded – undo
1285 1285
     elseif ($object->element == 'shipping')			$dir = $conf->expedition->dir_output.'/sending';
1286 1286
     elseif ($object->element == 'delivery')			$dir = $conf->expedition->dir_output.'/receipt';
1287 1287
     elseif ($object->element == 'fichinter')		$dir = $conf->ficheinter->dir_output;
1288
-    else $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output;
1288
+    else $dir = empty($conf->$element->dir_output) ? '' : $conf->$element->dir_output;
1289 1289
 
1290 1290
     if (empty($dir)) return 'ErrorObjectNoSupportedByFunction';
1291 1291
 
1292 1292
 	$refsan = dol_sanitizeFileName($object->ref);
1293
-	$dir = $dir . "/" . $refsan ;
1294
-	$file = $dir . "/" . $refsan . ".pdf.png";
1295
-	$multiple = $file . ".";
1293
+	$dir = $dir."/".$refsan;
1294
+	$file = $dir."/".$refsan.".pdf.png";
1295
+	$multiple = $file.".";
1296 1296
 
1297 1297
 	if (file_exists($file) && is_writable($file))
1298 1298
 	{
1299
-		if (! dol_delete_file($file,1))
1299
+		if (!dol_delete_file($file, 1))
1300 1300
 		{
1301
-			$object->error=$langs->trans("ErrorFailedToDeleteFile",$file);
1301
+			$object->error = $langs->trans("ErrorFailedToDeleteFile", $file);
1302 1302
 			return 0;
1303 1303
 		}
1304 1304
 	}
@@ -1310,9 +1310,9 @@  discard block
 block discarded – undo
1310 1310
 
1311 1311
 			if (file_exists($preview) && is_writable($preview))
1312 1312
 			{
1313
-				if ( ! dol_delete_file($preview,1) )
1313
+				if (!dol_delete_file($preview, 1))
1314 1314
 				{
1315
-					$object->error=$langs->trans("ErrorFailedToOpenFile",$preview);
1315
+					$object->error = $langs->trans("ErrorFailedToOpenFile", $preview);
1316 1316
 					return 0;
1317 1317
 				}
1318 1318
 			}
@@ -1335,10 +1335,10 @@  discard block
 block discarded – undo
1335 1335
 	global $conf;
1336 1336
 
1337 1337
 	// Create meta file
1338
-	if (empty($conf->global->MAIN_DOC_CREATE_METAFILE)) return 0;	// By default, no metafile.
1338
+	if (empty($conf->global->MAIN_DOC_CREATE_METAFILE)) return 0; // By default, no metafile.
1339 1339
 
1340 1340
 	// Define parent dir of elements
1341
-	$element=$object->element;
1341
+	$element = $object->element;
1342 1342
 
1343 1343
 	if ($object->element == 'order_supplier')		$dir = $conf->fournisseur->dir_output.'/commande';
1344 1344
 	elseif ($object->element == 'invoice_supplier')	$dir = $conf->fournisseur->dir_output.'/facture';
@@ -1346,17 +1346,17 @@  discard block
 block discarded – undo
1346 1346
 	elseif ($object->element == 'shipping')			$dir = $conf->expedition->dir_output.'/sending';
1347 1347
 	elseif ($object->element == 'delivery')			$dir = $conf->expedition->dir_output.'/receipt';
1348 1348
 	elseif ($object->element == 'fichinter')		$dir = $conf->ficheinter->dir_output;
1349
-	else $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output;
1349
+	else $dir = empty($conf->$element->dir_output) ? '' : $conf->$element->dir_output;
1350 1350
 
1351 1351
 	if ($dir)
1352 1352
 	{
1353 1353
 		$object->fetch_thirdparty();
1354 1354
 
1355 1355
 		$objectref = dol_sanitizeFileName($object->ref);
1356
-		$dir = $dir . "/" . $objectref;
1357
-		$file = $dir . "/" . $objectref . ".meta";
1356
+		$dir = $dir."/".$objectref;
1357
+		$file = $dir."/".$objectref.".meta";
1358 1358
 
1359
-		if (! is_dir($dir))
1359
+		if (!is_dir($dir))
1360 1360
 		{
1361 1361
 			dol_mkdir($dir);
1362 1362
 		}
@@ -1364,29 +1364,29 @@  discard block
 block discarded – undo
1364 1364
 		if (is_dir($dir))
1365 1365
 		{
1366 1366
 			$nblignes = count($object->lines);
1367
-			$client = $object->thirdparty->name . " " . $object->thirdparty->address . " " . $object->thirdparty->zip . " " . $object->thirdparty->town;
1368
-			$meta = "REFERENCE=\"" . $object->ref . "\"
1369
-			DATE=\"" . dol_print_date($object->date,'') . "\"
1370
-			NB_ITEMS=\"" . $nblignes . "\"
1371
-			CLIENT=\"" . $client . "\"
1372
-			AMOUNT_EXCL_TAX=\"" . $object->total_ht . "\"
1373
-			AMOUNT=\"" . $object->total_ttc . "\"\n";
1374
-
1375
-			for ($i = 0 ; $i < $nblignes ; $i++)
1367
+			$client = $object->thirdparty->name." ".$object->thirdparty->address." ".$object->thirdparty->zip." ".$object->thirdparty->town;
1368
+			$meta = "REFERENCE=\"".$object->ref."\"
1369
+			DATE=\"" . dol_print_date($object->date, '')."\"
1370
+			NB_ITEMS=\"" . $nblignes."\"
1371
+			CLIENT=\"" . $client."\"
1372
+			AMOUNT_EXCL_TAX=\"" . $object->total_ht."\"
1373
+			AMOUNT=\"" . $object->total_ttc."\"\n";
1374
+
1375
+			for ($i = 0; $i < $nblignes; $i++)
1376 1376
 			{
1377 1377
 				//Pour les articles
1378
-				$meta .= "ITEM_" . $i . "_QUANTITY=\"" . $object->lines[$i]->qty . "\"
1379
-				ITEM_" . $i . "_AMOUNT_WO_TAX=\"" . $object->lines[$i]->total_ht . "\"
1380
-				ITEM_" . $i . "_VAT=\"" .$object->lines[$i]->tva_tx . "\"
1381
-				ITEM_" . $i . "_DESCRIPTION=\"" . str_replace("\r\n","",nl2br($object->lines[$i]->desc)) . "\"
1378
+				$meta .= "ITEM_".$i."_QUANTITY=\"".$object->lines[$i]->qty."\"
1379
+				ITEM_" . $i."_AMOUNT_WO_TAX=\"".$object->lines[$i]->total_ht."\"
1380
+				ITEM_" . $i."_VAT=\"".$object->lines[$i]->tva_tx."\"
1381
+				ITEM_" . $i."_DESCRIPTION=\"".str_replace("\r\n", "", nl2br($object->lines[$i]->desc))."\"
1382 1382
 				";
1383 1383
 			}
1384 1384
 		}
1385 1385
 
1386
-		$fp = fopen($file,"w");
1387
-		fputs($fp,$meta);
1386
+		$fp = fopen($file, "w");
1387
+		fputs($fp, $meta);
1388 1388
 		fclose($fp);
1389
-		if (! empty($conf->global->MAIN_UMASK))
1389
+		if (!empty($conf->global->MAIN_UMASK))
1390 1390
 		@chmod($file, octdec($conf->global->MAIN_UMASK));
1391 1391
 
1392 1392
 		return 1;
@@ -1409,26 +1409,26 @@  discard block
 block discarded – undo
1409 1409
  * @param   string  $trackid                Track id (used to prefix name of session vars to avoid conflict)
1410 1410
  * @return	void
1411 1411
  */
1412
-function dol_init_file_process($pathtoscan='', $trackid='')
1412
+function dol_init_file_process($pathtoscan = '', $trackid = '')
1413 1413
 {
1414
-	$listofpaths=array();
1415
-	$listofnames=array();
1416
-	$listofmimes=array();
1414
+	$listofpaths = array();
1415
+	$listofnames = array();
1416
+	$listofmimes = array();
1417 1417
 
1418 1418
 	if ($pathtoscan)
1419 1419
 	{
1420
-		$listoffiles=dol_dir_list($pathtoscan,'files');
1421
-		foreach($listoffiles as $key => $val)
1420
+		$listoffiles = dol_dir_list($pathtoscan, 'files');
1421
+		foreach ($listoffiles as $key => $val)
1422 1422
 		{
1423
-			$listofpaths[]=$val['fullname'];
1424
-			$listofnames[]=$val['name'];
1425
-			$listofmimes[]=dol_mimetype($val['name']);
1423
+			$listofpaths[] = $val['fullname'];
1424
+			$listofnames[] = $val['name'];
1425
+			$listofmimes[] = dol_mimetype($val['name']);
1426 1426
 		}
1427 1427
 	}
1428
-    $keytoavoidconflict = empty($trackid)?'':'-'.$trackid;
1429
-	$_SESSION["listofpaths".$keytoavoidconflict]=join(';',$listofpaths);
1430
-	$_SESSION["listofnames".$keytoavoidconflict]=join(';',$listofnames);
1431
-	$_SESSION["listofmimes".$keytoavoidconflict]=join(';',$listofmimes);
1428
+    $keytoavoidconflict = empty($trackid) ? '' : '-'.$trackid;
1429
+	$_SESSION["listofpaths".$keytoavoidconflict] = join(';', $listofpaths);
1430
+	$_SESSION["listofnames".$keytoavoidconflict] = join(';', $listofnames);
1431
+	$_SESSION["listofmimes".$keytoavoidconflict] = join(';', $listofmimes);
1432 1432
 }
1433 1433
 
1434 1434
 
@@ -1447,13 +1447,13 @@  discard block
 block discarded – undo
1447 1447
  * @param	int		$generatethumbs			1=Generate also thumbs for uploaded image files
1448 1448
  * @return	int                             <=0 if KO, >0 if OK
1449 1449
  */
1450
-function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesession=0, $varfiles='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1)
1450
+function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesession = 0, $varfiles = 'addedfile', $savingdocmask = '', $link = null, $trackid = '', $generatethumbs = 1)
1451 1451
 {
1452
-	global $db,$user,$conf,$langs;
1452
+	global $db, $user, $conf, $langs;
1453 1453
 
1454 1454
 	$res = 0;
1455 1455
 
1456
-	if (! empty($_FILES[$varfiles])) // For view $_FILES[$varfiles]['error']
1456
+	if (!empty($_FILES[$varfiles])) // For view $_FILES[$varfiles]['error']
1457 1457
 	{
1458 1458
 		dol_syslog('dol_add_file_process upload_dir='.$upload_dir.' allowoverwrite='.$allowoverwrite.' donotupdatesession='.$donotupdatesession.' savingdocmask='.$savingdocmask, LOG_DEBUG);
1459 1459
 		if (dol_mkdir($upload_dir) >= 0)
@@ -1472,13 +1472,13 @@  discard block
 block discarded – undo
1472 1472
 			for ($i = 0; $i < $nbfile; $i++)
1473 1473
 			{
1474 1474
 				// Define $destfull (path to file including filename) and $destfile (only filename)
1475
-				$destfull=$upload_dir . "/" . $TFile['name'][$i];
1476
-				$destfile=$TFile['name'][$i];
1475
+				$destfull = $upload_dir."/".$TFile['name'][$i];
1476
+				$destfile = $TFile['name'][$i];
1477 1477
 
1478 1478
 				if ($savingdocmask)
1479 1479
 				{
1480
-					$destfull=$upload_dir . "/" . preg_replace('/__file__/',$TFile['name'][$i],$savingdocmask);
1481
-					$destfile=preg_replace('/__file__/',$TFile['name'][$i],$savingdocmask);
1480
+					$destfull = $upload_dir."/".preg_replace('/__file__/', $TFile['name'][$i], $savingdocmask);
1481
+					$destfile = preg_replace('/__file__/', $TFile['name'][$i], $savingdocmask);
1482 1482
 				}
1483 1483
 
1484 1484
 				// dol_sanitizeFileName the file name and lowercase extension
@@ -1523,23 +1523,23 @@  discard block
 block discarded – undo
1523 1523
 					// Update table of files
1524 1524
 					if ($donotupdatesession)
1525 1525
 					{
1526
-					    $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir);
1526
+					    $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir);
1527 1527
 
1528
-					    if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir))     // If not a tmp dir
1528
+					    if (!preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir))     // If not a tmp dir
1529 1529
 					    {
1530 1530
 					        $filename = basename($destfile);
1531 1531
 					        $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
1532 1532
 					        $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
1533 1533
 
1534 1534
     					    include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
1535
-    					    $ecmfile=new EcmFiles($db);
1535
+    					    $ecmfile = new EcmFiles($db);
1536 1536
     					    $ecmfile->filepath = $rel_dir;
1537 1537
     					    $ecmfile->filename = $filename;
1538
-    					    $ecmfile->label = md5_file(dol_osencode($destfull));	// MD5 of file content
1538
+    					    $ecmfile->label = md5_file(dol_osencode($destfull)); // MD5 of file content
1539 1539
     					    $ecmfile->fullpath_orig = $TFile['name'][$i];
1540 1540
     					    $ecmfile->gen_or_uploaded = 'uploaded';
1541
-    					    $ecmfile->description = '';    // indexed content
1542
-    					    $ecmfile->keyword = '';        // keyword content
1541
+    					    $ecmfile->description = ''; // indexed content
1542
+    					    $ecmfile->keyword = ''; // keyword content
1543 1543
     					    $result = $ecmfile->create($user);
1544 1544
                             if ($result < 0)
1545 1545
                             {
@@ -1558,7 +1558,7 @@  discard block
 block discarded – undo
1558 1558
 					{
1559 1559
 						setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors');
1560 1560
 					}
1561
-					else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload))	// Files infected by a virus
1561
+					else if (preg_match('/ErrorFileIsInfectedWithAVirus/', $resupload))	// Files infected by a virus
1562 1562
 					{
1563 1563
 						setEventMessages($langs->trans("ErrorFileIsInfectedWithAVirus"), null, 'errors');
1564 1564
 					}
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
 
1572 1572
 		}
1573 1573
 	} elseif ($link) {
1574
-		require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
1574
+		require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
1575 1575
 		$linkObject = new Link($db);
1576 1576
 		$linkObject->entity = $conf->entity;
1577 1577
 		$linkObject->url = $link;
@@ -1606,33 +1606,33 @@  discard block
 block discarded – undo
1606 1606
  * @param   string  $trackid                Track id (used to prefix name of session vars to avoid conflict)
1607 1607
  * @return	void
1608 1608
  */
1609
-function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile=1,$trackid='')
1609
+function dol_remove_file_process($filenb, $donotupdatesession = 0, $donotdeletefile = 1, $trackid = '')
1610 1610
 {
1611
-	global $db,$user,$conf,$langs,$_FILES;
1611
+	global $db, $user, $conf, $langs, $_FILES;
1612 1612
 
1613
-	$keytodelete=$filenb;
1613
+	$keytodelete = $filenb;
1614 1614
 	$keytodelete--;
1615 1615
 
1616
-	$listofpaths=array();
1617
-	$listofnames=array();
1618
-	$listofmimes=array();
1619
-    $keytoavoidconflict = empty($trackid)?'':'-'.$trackid;
1620
-	if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
1621
-	if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
1622
-	if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
1616
+	$listofpaths = array();
1617
+	$listofnames = array();
1618
+	$listofmimes = array();
1619
+    $keytoavoidconflict = empty($trackid) ? '' : '-'.$trackid;
1620
+	if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
1621
+	if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
1622
+	if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
1623 1623
 
1624 1624
 	if ($keytodelete >= 0)
1625 1625
 	{
1626
-		$pathtodelete=$listofpaths[$keytodelete];
1627
-		$filetodelete=$listofnames[$keytodelete];
1628
-		if (empty($donotdeletefile)) $result = dol_delete_file($pathtodelete,1);  // The delete of ecm database is inside the function dol_delete_file
1629
-		else $result=0;
1626
+		$pathtodelete = $listofpaths[$keytodelete];
1627
+		$filetodelete = $listofnames[$keytodelete];
1628
+		if (empty($donotdeletefile)) $result = dol_delete_file($pathtodelete, 1); // The delete of ecm database is inside the function dol_delete_file
1629
+		else $result = 0;
1630 1630
 		if ($result >= 0)
1631 1631
 		{
1632 1632
 			if (empty($donotdeletefile))
1633 1633
 			{
1634 1634
 				$langs->load("other");
1635
-				setEventMessages($langs->trans("FileWasRemoved",$filetodelete), null, 'mesgs');
1635
+				setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs');
1636 1636
 			}
1637 1637
 			if (empty($donotupdatesession))
1638 1638
 			{
@@ -1654,16 +1654,16 @@  discard block
 block discarded – undo
1654 1654
  *  @param	string	$fileoutput	Output filename
1655 1655
  *  @return	int					<0 if KO, 0=Nothing done, >0 if OK
1656 1656
  */
1657
-function dol_convert_file($fileinput, $ext='png', $fileoutput='')
1657
+function dol_convert_file($fileinput, $ext = 'png', $fileoutput = '')
1658 1658
 {
1659 1659
 	global $langs;
1660 1660
 
1661 1661
 	if (class_exists('Imagick'))
1662 1662
 	{
1663
-		$image=new Imagick();
1663
+		$image = new Imagick();
1664 1664
 		try {
1665 1665
 			$ret = $image->readImage($fileinput);
1666
-		} catch(Exception $e) {
1666
+		} catch (Exception $e) {
1667 1667
 			dol_syslog("Failed to read image using Imagick. Try to install package 'apt-get install ghostscript'.", LOG_WARNING);
1668 1668
 			return 0;
1669 1669
 		}
@@ -1672,7 +1672,7 @@  discard block
 block discarded – undo
1672 1672
 			$ret = $image->setImageFormat($ext);
1673 1673
 			if ($ret)
1674 1674
 			{
1675
-				if (empty($fileoutput)) $fileoutput=$fileinput.".".$ext;
1675
+				if (empty($fileoutput)) $fileoutput = $fileinput.".".$ext;
1676 1676
 
1677 1677
 				$count = $image->getNumberImages();
1678 1678
 				$ret = $image->writeImages($fileoutput, true);
@@ -1704,20 +1704,20 @@  discard block
 block discarded – undo
1704 1704
  * @param 	string	$mode			'gz' or 'bz' or 'zip'
1705 1705
  * @return	int						<0 if KO, >0 if OK
1706 1706
  */
1707
-function dol_compress_file($inputfile, $outputfile, $mode="gz")
1707
+function dol_compress_file($inputfile, $outputfile, $mode = "gz")
1708 1708
 {
1709
-    $foundhandler=0;
1709
+    $foundhandler = 0;
1710 1710
 
1711 1711
     try
1712 1712
     {
1713 1713
         $data = implode("", file(dol_osencode($inputfile)));
1714
-        if ($mode == 'gz')     { $foundhandler=1; $compressdata = gzencode($data, 9); }
1715
-        elseif ($mode == 'bz') { $foundhandler=1; $compressdata = bzcompress($data, 9); }
1714
+        if ($mode == 'gz') { $foundhandler = 1; $compressdata = gzencode($data, 9); }
1715
+        elseif ($mode == 'bz') { $foundhandler = 1; $compressdata = bzcompress($data, 9); }
1716 1716
         elseif ($mode == 'zip')
1717 1717
         {
1718 1718
             if (defined('ODTPHP_PATHTOPCLZIP'))
1719 1719
             {
1720
-                $foundhandler=1;
1720
+                $foundhandler = 1;
1721 1721
 
1722 1722
                 include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php';
1723 1723
                 $archive = new PclZip($outputfile);
@@ -1736,7 +1736,7 @@  discard block
 block discarded – undo
1736 1736
         }
1737 1737
         else
1738 1738
         {
1739
-            dol_syslog("Try to zip with format ".$mode." with no handler for this format",LOG_ERR);
1739
+            dol_syslog("Try to zip with format ".$mode." with no handler for this format", LOG_ERR);
1740 1740
             return -2;
1741 1741
         }
1742 1742
     }
@@ -1744,8 +1744,8 @@  discard block
 block discarded – undo
1744 1744
     {
1745 1745
         global $langs, $errormsg;
1746 1746
         $langs->load("errors");
1747
-        dol_syslog("Failed to open file ".$outputfile,LOG_ERR);
1748
-        $errormsg=$langs->trans("ErrorFailedToWriteInDir");
1747
+        dol_syslog("Failed to open file ".$outputfile, LOG_ERR);
1748
+        $errormsg = $langs->trans("ErrorFailedToWriteInDir");
1749 1749
         return -1;
1750 1750
     }
1751 1751
 }
@@ -1757,7 +1757,7 @@  discard block
 block discarded – undo
1757 1757
  * @param 	string	$outputdir		Target dir name
1758 1758
  * @return 	array					array('error'=>'Error code') or array() if no error
1759 1759
  */
1760
-function dol_uncompress($inputfile,$outputdir)
1760
+function dol_uncompress($inputfile, $outputdir)
1761 1761
 {
1762 1762
     global $langs;
1763 1763
 
@@ -1766,20 +1766,20 @@  discard block
 block discarded – undo
1766 1766
     	dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".ODTPHP_PATHTOPCLZIP.", so we use Pclzip to unzip into ".$outputdir);
1767 1767
         include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php';
1768 1768
         $archive = new PclZip($inputfile);
1769
-        $result=$archive->extract(PCLZIP_OPT_PATH, $outputdir);
1769
+        $result = $archive->extract(PCLZIP_OPT_PATH, $outputdir);
1770 1770
         //var_dump($result);
1771
-        if (! is_array($result) && $result <= 0) return array('error'=>$archive->errorInfo(true));
1771
+        if (!is_array($result) && $result <= 0) return array('error'=>$archive->errorInfo(true));
1772 1772
         else
1773 1773
 		{
1774
-			$ok=1; $errmsg='';
1774
+			$ok = 1; $errmsg = '';
1775 1775
 			// Loop on each file to check result for unzipping file
1776
-			foreach($result as $key => $val)
1776
+			foreach ($result as $key => $val)
1777 1777
 			{
1778 1778
 				if ($val['status'] == 'path_creation_fail')
1779 1779
 				{
1780 1780
 					$langs->load("errors");
1781
-					$ok=0;
1782
-					$errmsg=$langs->trans("ErrorFailToCreateDir", $val['filename']);
1781
+					$ok = 0;
1782
+					$errmsg = $langs->trans("ErrorFailToCreateDir", $val['filename']);
1783 1783
 					break;
1784 1784
 				}
1785 1785
 			}
@@ -1818,24 +1818,24 @@  discard block
 block discarded – undo
1818 1818
  * @param 	string	$mode			'zip'
1819 1819
  * @return	int						<0 if KO, >0 if OK
1820 1820
  */
1821
-function dol_compress_dir($inputdir, $outputfile, $mode="zip")
1821
+function dol_compress_dir($inputdir, $outputfile, $mode = "zip")
1822 1822
 {
1823
-    $foundhandler=0;
1823
+    $foundhandler = 0;
1824 1824
 
1825 1825
     dol_syslog("Try to zip dir ".$inputdir." into ".$outputdir." mode=".$mode);
1826 1826
 
1827
-    if (! dol_is_dir(dirname($outputfile)) || ! is_writable(dirname($outputfile)))
1827
+    if (!dol_is_dir(dirname($outputfile)) || !is_writable(dirname($outputfile)))
1828 1828
     {
1829 1829
     	global $langs, $errormsg;
1830 1830
     	$langs->load("errors");
1831
-    	$errormsg=$langs->trans("ErrorFailedToWriteInDir",$outputfile);
1831
+    	$errormsg = $langs->trans("ErrorFailedToWriteInDir", $outputfile);
1832 1832
 		return -3;
1833 1833
     }
1834 1834
 
1835 1835
     try
1836 1836
     {
1837
-        if ($mode == 'gz')     { $foundhandler=0; }
1838
-        elseif ($mode == 'bz') { $foundhandler=0; }
1837
+        if ($mode == 'gz') { $foundhandler = 0; }
1838
+        elseif ($mode == 'bz') { $foundhandler = 0; }
1839 1839
         elseif ($mode == 'zip')
1840 1840
         {
1841 1841
             /*if (defined('ODTPHP_PATHTOPCLZIP'))
@@ -1851,7 +1851,7 @@  discard block
 block discarded – undo
1851 1851
             else*/
1852 1852
             if (class_exists('ZipArchive'))
1853 1853
             {
1854
-                $foundhandler=1;
1854
+                $foundhandler = 1;
1855 1855
 
1856 1856
                 // Initialize archive object
1857 1857
                 $zip = new ZipArchive();
@@ -1885,9 +1885,9 @@  discard block
 block discarded – undo
1885 1885
             }
1886 1886
         }
1887 1887
 
1888
-        if (! $foundhandler)
1888
+        if (!$foundhandler)
1889 1889
         {
1890
-            dol_syslog("Try to zip with format ".$mode." with no handler for this format",LOG_ERR);
1890
+            dol_syslog("Try to zip with format ".$mode." with no handler for this format", LOG_ERR);
1891 1891
             return -2;
1892 1892
         }
1893 1893
         else
@@ -1901,7 +1901,7 @@  discard block
 block discarded – undo
1901 1901
         $langs->load("errors");
1902 1902
         dol_syslog("Failed to open file ".$outputfile, LOG_ERR);
1903 1903
         dol_syslog($e->getMessage(), LOG_ERR);
1904
-        $errormsg=$langs->trans("ErrorFailedToWriteInDir",$outputfile);
1904
+        $errormsg = $langs->trans("ErrorFailedToWriteInDir", $outputfile);
1905 1905
         return -1;
1906 1906
     }
1907 1907
 }
@@ -1918,9 +1918,9 @@  discard block
 block discarded – undo
1918 1918
  * @param	int			$mode			0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only
1919 1919
  * @return	string						Full path to most recent file
1920 1920
  */
1921
-function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('(\.meta|_preview.*\.png)$','^\.'),$nohook=false,$mode='')
1921
+function dol_most_recent_file($dir, $regexfilter = '', $excludefilter = array('(\.meta|_preview.*\.png)$', '^\.'), $nohook = false, $mode = '')
1922 1922
 {
1923
-    $tmparray=dol_dir_list($dir,'files',0,$regexfilter,$excludefilter,'date',SORT_DESC,$mode,$nohook);
1923
+    $tmparray = dol_dir_list($dir, 'files', 0, $regexfilter, $excludefilter, 'date', SORT_DESC, $mode, $nohook);
1924 1924
     return $tmparray[0];
1925 1925
 }
1926 1926
 
@@ -1936,268 +1936,268 @@  discard block
 block discarded – undo
1936 1936
  * @return	mixed						Array with access information : 'accessallowed' & 'sqlprotectagainstexternals' & 'original_file' (as a full path name)
1937 1937
  * @see restrictedArea
1938 1938
  */
1939
-function dol_check_secure_access_document($modulepart, $original_file, $entity, $fuser='', $refname='', $mode='read')
1939
+function dol_check_secure_access_document($modulepart, $original_file, $entity, $fuser = '', $refname = '', $mode = 'read')
1940 1940
 {
1941 1941
 	global $user, $conf, $db;
1942 1942
 	global $dolibarr_main_data_root, $dolibarr_main_document_root_alt;
1943 1943
 
1944
-	if (! is_object($fuser)) $fuser=$user;
1944
+	if (!is_object($fuser)) $fuser = $user;
1945 1945
 
1946 1946
 	if (empty($modulepart)) return 'ErrorBadParameter';
1947
-	if (empty($entity)) $entity=0;
1947
+	if (empty($entity)) $entity = 0;
1948 1948
 	dol_syslog('modulepart='.$modulepart.' original_file='.$original_file);
1949 1949
 	// We define $accessallowed and $sqlprotectagainstexternals
1950
-	$accessallowed=0;
1951
-	$sqlprotectagainstexternals='';
1952
-	$ret=array();
1950
+	$accessallowed = 0;
1951
+	$sqlprotectagainstexternals = '';
1952
+	$ret = array();
1953 1953
 
1954 1954
     // Find the subdirectory name as the reference. For exemple original_file='10/myfile.pdf' -> refname='10'
1955
-	if (empty($refname)) $refname=basename(dirname($original_file)."/");
1955
+	if (empty($refname)) $refname = basename(dirname($original_file)."/");
1956 1956
 
1957 1957
 	$relative_original_file = $original_file;
1958 1958
 
1959 1959
 	// Define possible keys to use for permission check
1960
-	$lire='lire'; $read='read'; $download='download';
1960
+	$lire = 'lire'; $read = 'read'; $download = 'download';
1961 1961
 	if ($mode == 'write')
1962 1962
 	{
1963
-	    $lire='creer'; $read='write'; $download='upload';
1963
+	    $lire = 'creer'; $read = 'write'; $download = 'upload';
1964 1964
 	}
1965 1965
 
1966 1966
 	// Wrapping for miscellaneous medias files
1967 1967
 	if ($modulepart == 'medias' && !empty($dolibarr_main_data_root))
1968 1968
 	{
1969
-	    $accessallowed=1;
1970
-	    $original_file=$conf->medias->multidir_output[$entity].'/'.$original_file;
1969
+	    $accessallowed = 1;
1970
+	    $original_file = $conf->medias->multidir_output[$entity].'/'.$original_file;
1971 1971
 	}
1972 1972
 	// Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log
1973 1973
 	elseif ($modulepart == 'logs' && !empty($dolibarr_main_data_root))
1974 1974
 	{
1975
-	    $accessallowed=($user->admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file)));
1976
-	    $original_file=$dolibarr_main_data_root.'/'.$original_file;
1975
+	    $accessallowed = ($user->admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file)));
1976
+	    $original_file = $dolibarr_main_data_root.'/'.$original_file;
1977 1977
 	}
1978 1978
 	// Wrapping for *.zip files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip
1979 1979
 	elseif ($modulepart == 'packages' && !empty($dolibarr_main_data_root))
1980 1980
 	{
1981 1981
 		// Dir for custom dirs
1982
-		$tmp=explode(',', $dolibarr_main_document_root_alt);
1982
+		$tmp = explode(',', $dolibarr_main_document_root_alt);
1983 1983
 		$dirins = $tmp[0];
1984 1984
 
1985
-	    $accessallowed=($user->admin && preg_match('/^module_.*\.zip$/', basename($original_file)));
1986
-	    $original_file=$dirins.'/'.$original_file;
1985
+	    $accessallowed = ($user->admin && preg_match('/^module_.*\.zip$/', basename($original_file)));
1986
+	    $original_file = $dirins.'/'.$original_file;
1987 1987
 	}
1988 1988
 	// Wrapping for some images
1989 1989
 	elseif (($modulepart == 'mycompany' || $modulepart == 'companylogo') && !empty($conf->mycompany->dir_output))
1990 1990
 	{
1991
-		$accessallowed=1;
1992
-		$original_file=$conf->mycompany->dir_output.'/logos/'.$original_file;
1991
+		$accessallowed = 1;
1992
+		$original_file = $conf->mycompany->dir_output.'/logos/'.$original_file;
1993 1993
 	}
1994 1994
 	// Wrapping for users photos
1995 1995
 	elseif ($modulepart == 'userphoto' && !empty($conf->user->dir_output))
1996 1996
 	{
1997
-		$accessallowed=1;
1998
-		$original_file=$conf->user->dir_output.'/'.$original_file;
1997
+		$accessallowed = 1;
1998
+		$original_file = $conf->user->dir_output.'/'.$original_file;
1999 1999
 	}
2000 2000
 	// Wrapping for members photos
2001 2001
 	elseif ($modulepart == 'memberphoto' && !empty($conf->adherent->dir_output))
2002 2002
 	{
2003
-		$accessallowed=1;
2004
-		$original_file=$conf->adherent->dir_output.'/'.$original_file;
2003
+		$accessallowed = 1;
2004
+		$original_file = $conf->adherent->dir_output.'/'.$original_file;
2005 2005
 	}
2006 2006
 	// Wrapping pour les apercu factures
2007 2007
 	elseif ($modulepart == 'apercufacture' && !empty($conf->facture->dir_output))
2008 2008
 	{
2009
-		if ($fuser->rights->facture->{$lire}) $accessallowed=1;
2010
-		$original_file=$conf->facture->dir_output.'/'.$original_file;
2009
+		if ($fuser->rights->facture->{$lire}) $accessallowed = 1;
2010
+		$original_file = $conf->facture->dir_output.'/'.$original_file;
2011 2011
 	}
2012 2012
 	// Wrapping pour les apercu propal
2013 2013
 	elseif ($modulepart == 'apercupropal' && !empty($conf->propal->dir_output))
2014 2014
 	{
2015
-		if ($fuser->rights->propale->{$lire}) $accessallowed=1;
2016
-		$original_file=$conf->propal->dir_output.'/'.$original_file;
2015
+		if ($fuser->rights->propale->{$lire}) $accessallowed = 1;
2016
+		$original_file = $conf->propal->dir_output.'/'.$original_file;
2017 2017
 	}
2018 2018
 	// Wrapping pour les apercu commande
2019 2019
 	elseif ($modulepart == 'apercucommande' && !empty($conf->commande->dir_output))
2020 2020
 	{
2021
-		if ($fuser->rights->commande->{$lire}) $accessallowed=1;
2022
-		$original_file=$conf->commande->dir_output.'/'.$original_file;
2021
+		if ($fuser->rights->commande->{$lire}) $accessallowed = 1;
2022
+		$original_file = $conf->commande->dir_output.'/'.$original_file;
2023 2023
 	}
2024 2024
 	// Wrapping pour les apercu intervention
2025 2025
 	elseif (($modulepart == 'apercufichinter' || $modulepart == 'apercuficheinter') && !empty($conf->ficheinter->dir_output))
2026 2026
 	{
2027
-	    if ($fuser->rights->ficheinter->{$lire}) $accessallowed=1;
2028
-	    $original_file=$conf->ficheinter->dir_output.'/'.$original_file;
2027
+	    if ($fuser->rights->ficheinter->{$lire}) $accessallowed = 1;
2028
+	    $original_file = $conf->ficheinter->dir_output.'/'.$original_file;
2029 2029
 	}
2030 2030
 	// Wrapping pour les apercu conat
2031 2031
 	elseif (($modulepart == 'apercucontract') && !empty($conf->contrat->dir_output))
2032 2032
 	{
2033
-	    if ($fuser->rights->contrat->{$lire}) $accessallowed=1;
2034
-	    $original_file=$conf->contrat->dir_output.'/'.$original_file;
2033
+	    if ($fuser->rights->contrat->{$lire}) $accessallowed = 1;
2034
+	    $original_file = $conf->contrat->dir_output.'/'.$original_file;
2035 2035
 	}
2036 2036
 	// Wrapping pour les apercu supplier proposal
2037 2037
 	elseif (($modulepart == 'apercusupplier_proposal' || $modulepart == 'apercusupplier_proposal') && !empty($conf->supplier_proposal->dir_output))
2038 2038
 	{
2039
-	    if ($fuser->rights->supplier_proposal->{$lire}) $accessallowed=1;
2040
-	    $original_file=$conf->supplier_proposal->dir_output.'/'.$original_file;
2039
+	    if ($fuser->rights->supplier_proposal->{$lire}) $accessallowed = 1;
2040
+	    $original_file = $conf->supplier_proposal->dir_output.'/'.$original_file;
2041 2041
 	}
2042 2042
 	// Wrapping pour les apercu supplier order
2043 2043
 	elseif (($modulepart == 'apercusupplier_order' || $modulepart == 'apercusupplier_order') && !empty($conf->fournisseur->commande->dir_output))
2044 2044
 	{
2045
-	    if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed=1;
2046
-	    $original_file=$conf->fournisseur->commande->dir_output.'/'.$original_file;
2045
+	    if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed = 1;
2046
+	    $original_file = $conf->fournisseur->commande->dir_output.'/'.$original_file;
2047 2047
 	}
2048 2048
 	// Wrapping pour les apercu supplier invoice
2049 2049
 	elseif (($modulepart == 'apercusupplier_invoice' || $modulepart == 'apercusupplier_invoice') && !empty($conf->fournisseur->facture->dir_output))
2050 2050
 	{
2051
-	    if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed=1;
2052
-	    $original_file=$conf->fournisseur->facture->dir_output.'/'.$original_file;
2051
+	    if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed = 1;
2052
+	    $original_file = $conf->fournisseur->facture->dir_output.'/'.$original_file;
2053 2053
 	}
2054 2054
 	// Wrapping pour les apercu supplier invoice
2055 2055
 	elseif (($modulepart == 'apercuexpensereport') && !empty($conf->expensereport->dir_output))
2056 2056
 	{
2057
-	    if ($fuser->rights->expensereport->{$lire}) $accessallowed=1;
2058
-	    $original_file=$conf->expensereport->dir_output.'/'.$original_file;
2057
+	    if ($fuser->rights->expensereport->{$lire}) $accessallowed = 1;
2058
+	    $original_file = $conf->expensereport->dir_output.'/'.$original_file;
2059 2059
 	}
2060 2060
 	// Wrapping pour les images des stats propales
2061 2061
 	elseif ($modulepart == 'propalstats' && !empty($conf->propal->dir_temp))
2062 2062
 	{
2063
-		if ($fuser->rights->propale->{$lire}) $accessallowed=1;
2064
-		$original_file=$conf->propal->dir_temp.'/'.$original_file;
2063
+		if ($fuser->rights->propale->{$lire}) $accessallowed = 1;
2064
+		$original_file = $conf->propal->dir_temp.'/'.$original_file;
2065 2065
 	}
2066 2066
 	// Wrapping pour les images des stats commandes
2067 2067
 	elseif ($modulepart == 'orderstats' && !empty($conf->commande->dir_temp))
2068 2068
 	{
2069
-		if ($fuser->rights->commande->{$lire}) $accessallowed=1;
2070
-		$original_file=$conf->commande->dir_temp.'/'.$original_file;
2069
+		if ($fuser->rights->commande->{$lire}) $accessallowed = 1;
2070
+		$original_file = $conf->commande->dir_temp.'/'.$original_file;
2071 2071
 	}
2072 2072
 	elseif ($modulepart == 'orderstatssupplier' && !empty($conf->fournisseur->dir_output))
2073 2073
 	{
2074
-		if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed=1;
2075
-		$original_file=$conf->fournisseur->commande->dir_temp.'/'.$original_file;
2074
+		if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed = 1;
2075
+		$original_file = $conf->fournisseur->commande->dir_temp.'/'.$original_file;
2076 2076
 	}
2077 2077
 	// Wrapping pour les images des stats factures
2078 2078
 	elseif ($modulepart == 'billstats' && !empty($conf->facture->dir_temp))
2079 2079
 	{
2080
-		if ($fuser->rights->facture->{$lire}) $accessallowed=1;
2081
-		$original_file=$conf->facture->dir_temp.'/'.$original_file;
2080
+		if ($fuser->rights->facture->{$lire}) $accessallowed = 1;
2081
+		$original_file = $conf->facture->dir_temp.'/'.$original_file;
2082 2082
 	}
2083 2083
 	elseif ($modulepart == 'billstatssupplier' && !empty($conf->fournisseur->dir_output))
2084 2084
 	{
2085
-		if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed=1;
2086
-		$original_file=$conf->fournisseur->facture->dir_temp.'/'.$original_file;
2085
+		if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed = 1;
2086
+		$original_file = $conf->fournisseur->facture->dir_temp.'/'.$original_file;
2087 2087
 	}
2088 2088
 	// Wrapping pour les images des stats expeditions
2089 2089
 	elseif ($modulepart == 'expeditionstats' && !empty($conf->expedition->dir_temp))
2090 2090
 	{
2091
-		if ($fuser->rights->expedition->{$lire}) $accessallowed=1;
2092
-		$original_file=$conf->expedition->dir_temp.'/'.$original_file;
2091
+		if ($fuser->rights->expedition->{$lire}) $accessallowed = 1;
2092
+		$original_file = $conf->expedition->dir_temp.'/'.$original_file;
2093 2093
 	}
2094 2094
 	// Wrapping pour les images des stats expeditions
2095 2095
 	elseif ($modulepart == 'tripsexpensesstats' && !empty($conf->deplacement->dir_temp))
2096 2096
 	{
2097
-		if ($fuser->rights->deplacement->{$lire}) $accessallowed=1;
2098
-		$original_file=$conf->deplacement->dir_temp.'/'.$original_file;
2097
+		if ($fuser->rights->deplacement->{$lire}) $accessallowed = 1;
2098
+		$original_file = $conf->deplacement->dir_temp.'/'.$original_file;
2099 2099
 	}
2100 2100
 	// Wrapping pour les images des stats expeditions
2101 2101
 	elseif ($modulepart == 'memberstats' && !empty($conf->adherent->dir_temp))
2102 2102
 	{
2103
-		if ($fuser->rights->adherent->{$lire}) $accessallowed=1;
2104
-		$original_file=$conf->adherent->dir_temp.'/'.$original_file;
2103
+		if ($fuser->rights->adherent->{$lire}) $accessallowed = 1;
2104
+		$original_file = $conf->adherent->dir_temp.'/'.$original_file;
2105 2105
 	}
2106 2106
 	// Wrapping pour les images des stats produits
2107
-	elseif (preg_match('/^productstats_/i',$modulepart) && !empty($conf->product->dir_temp))
2107
+	elseif (preg_match('/^productstats_/i', $modulepart) && !empty($conf->product->dir_temp))
2108 2108
 	{
2109
-		if ($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) $accessallowed=1;
2110
-		$original_file=(!empty($conf->product->multidir_temp[$entity])?$conf->product->multidir_temp[$entity]:$conf->service->multidir_temp[$entity]).'/'.$original_file;
2109
+		if ($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) $accessallowed = 1;
2110
+		$original_file = (!empty($conf->product->multidir_temp[$entity]) ? $conf->product->multidir_temp[$entity] : $conf->service->multidir_temp[$entity]).'/'.$original_file;
2111 2111
 	}
2112 2112
 	// Wrapping for taxes
2113 2113
 	elseif ($modulepart == 'tax' && !empty($conf->tax->dir_output))
2114 2114
 	{
2115
-		if ($fuser->rights->tax->charges->{$lire}) $accessallowed=1;
2116
-		$original_file=$conf->tax->dir_output.'/'.$original_file;
2115
+		if ($fuser->rights->tax->charges->{$lire}) $accessallowed = 1;
2116
+		$original_file = $conf->tax->dir_output.'/'.$original_file;
2117 2117
 	}
2118 2118
 	// Wrapping for events
2119 2119
 	elseif ($modulepart == 'actions' && !empty($conf->agenda->dir_output))
2120 2120
 	{
2121
-		if ($fuser->rights->agenda->myactions->{$read}) $accessallowed=1;
2122
-		$original_file=$conf->agenda->dir_output.'/'.$original_file;
2121
+		if ($fuser->rights->agenda->myactions->{$read}) $accessallowed = 1;
2122
+		$original_file = $conf->agenda->dir_output.'/'.$original_file;
2123 2123
 	}
2124 2124
 	// Wrapping for categories
2125 2125
 	elseif ($modulepart == 'category' && !empty($conf->categorie->dir_output))
2126 2126
 	{
2127
-		if ($fuser->rights->categorie->{$lire}) $accessallowed=1;
2128
-		$original_file=$conf->categorie->multidir_output[$entity].'/'.$original_file;
2127
+		if ($fuser->rights->categorie->{$lire}) $accessallowed = 1;
2128
+		$original_file = $conf->categorie->multidir_output[$entity].'/'.$original_file;
2129 2129
 	}
2130 2130
 	// Wrapping pour les prelevements
2131 2131
 	elseif ($modulepart == 'prelevement' && !empty($conf->prelevement->dir_output))
2132 2132
 	{
2133
-		if ($fuser->rights->prelevement->bons->{$lire} || preg_match('/^specimen/i',$original_file)) $accessallowed=1;
2134
-		$original_file=$conf->prelevement->dir_output.'/'.$original_file;
2133
+		if ($fuser->rights->prelevement->bons->{$lire} || preg_match('/^specimen/i', $original_file)) $accessallowed = 1;
2134
+		$original_file = $conf->prelevement->dir_output.'/'.$original_file;
2135 2135
 	}
2136 2136
 	// Wrapping pour les graph energie
2137 2137
 	elseif ($modulepart == 'graph_stock' && !empty($conf->stock->dir_temp))
2138 2138
 	{
2139
-		$accessallowed=1;
2140
-		$original_file=$conf->stock->dir_temp.'/'.$original_file;
2139
+		$accessallowed = 1;
2140
+		$original_file = $conf->stock->dir_temp.'/'.$original_file;
2141 2141
 	}
2142 2142
 	// Wrapping pour les graph fournisseurs
2143 2143
 	elseif ($modulepart == 'graph_fourn' && !empty($conf->fournisseur->dir_temp))
2144 2144
 	{
2145
-		$accessallowed=1;
2146
-		$original_file=$conf->fournisseur->dir_temp.'/'.$original_file;
2145
+		$accessallowed = 1;
2146
+		$original_file = $conf->fournisseur->dir_temp.'/'.$original_file;
2147 2147
 	}
2148 2148
 	// Wrapping pour les graph des produits
2149 2149
 	elseif ($modulepart == 'graph_product' && !empty($conf->product->dir_temp))
2150 2150
 	{
2151
-		$accessallowed=1;
2152
-		$original_file=$conf->product->multidir_temp[$entity].'/'.$original_file;
2151
+		$accessallowed = 1;
2152
+		$original_file = $conf->product->multidir_temp[$entity].'/'.$original_file;
2153 2153
 	}
2154 2154
 	// Wrapping pour les code barre
2155 2155
 	elseif ($modulepart == 'barcode')
2156 2156
 	{
2157
-		$accessallowed=1;
2157
+		$accessallowed = 1;
2158 2158
 		// If viewimage is called for barcode, we try to output an image on the fly, with no build of file on disk.
2159 2159
 		//$original_file=$conf->barcode->dir_temp.'/'.$original_file;
2160
-		$original_file='';
2160
+		$original_file = '';
2161 2161
 	}
2162 2162
 	// Wrapping pour les icones de background des mailings
2163 2163
 	elseif ($modulepart == 'iconmailing' && !empty($conf->mailing->dir_temp))
2164 2164
 	{
2165
-		$accessallowed=1;
2166
-		$original_file=$conf->mailing->dir_temp.'/'.$original_file;
2165
+		$accessallowed = 1;
2166
+		$original_file = $conf->mailing->dir_temp.'/'.$original_file;
2167 2167
 	}
2168 2168
 	// Wrapping pour le scanner
2169 2169
 	elseif ($modulepart == 'scanner_user_temp' && !empty($conf->scanner->dir_temp))
2170 2170
 	{
2171
-		$accessallowed=1;
2172
-		$original_file=$conf->scanner->dir_temp.'/'.$fuser->id.'/'.$original_file;
2171
+		$accessallowed = 1;
2172
+		$original_file = $conf->scanner->dir_temp.'/'.$fuser->id.'/'.$original_file;
2173 2173
 	}
2174 2174
 	// Wrapping pour les images fckeditor
2175 2175
 	elseif ($modulepart == 'fckeditor' && !empty($conf->fckeditor->dir_output))
2176 2176
 	{
2177
-		$accessallowed=1;
2178
-		$original_file=$conf->fckeditor->dir_output.'/'.$original_file;
2177
+		$accessallowed = 1;
2178
+		$original_file = $conf->fckeditor->dir_output.'/'.$original_file;
2179 2179
 	}
2180 2180
 
2181 2181
 	// Wrapping for users
2182 2182
 	else if ($modulepart == 'user' && !empty($conf->user->dir_output))
2183 2183
 	{
2184
-        $canreaduser=(! empty($fuser->admin) || $fuser->rights->user->user->{$lire});
2185
-        if ($fuser->id == (int) $refname) { $canreaduser=1; } // A user can always read its own card
2186
-        if ($canreaduser || preg_match('/^specimen/i',$original_file))
2184
+        $canreaduser = (!empty($fuser->admin) || $fuser->rights->user->user->{$lire});
2185
+        if ($fuser->id == (int) $refname) { $canreaduser = 1; } // A user can always read its own card
2186
+        if ($canreaduser || preg_match('/^specimen/i', $original_file))
2187 2187
 	    {
2188
-	        $accessallowed=1;
2188
+	        $accessallowed = 1;
2189 2189
 	    }
2190
-	    $original_file=$conf->user->dir_output.'/'.$original_file;
2190
+	    $original_file = $conf->user->dir_output.'/'.$original_file;
2191 2191
 	}
2192 2192
 
2193 2193
 	// Wrapping for third parties
2194 2194
 	else if (($modulepart == 'company' || $modulepart == 'societe') && !empty($conf->societe->dir_output))
2195 2195
 	{
2196
-		if ($fuser->rights->societe->{$lire} || preg_match('/^specimen/i',$original_file))
2196
+		if ($fuser->rights->societe->{$lire} || preg_match('/^specimen/i', $original_file))
2197 2197
 		{
2198
-			$accessallowed=1;
2198
+			$accessallowed = 1;
2199 2199
 		}
2200
-		$original_file=$conf->societe->multidir_output[$entity].'/'.$original_file;
2200
+		$original_file = $conf->societe->multidir_output[$entity].'/'.$original_file;
2201 2201
 		$sqlprotectagainstexternals = "SELECT rowid as fk_soc FROM ".MAIN_DB_PREFIX."societe WHERE rowid='".$db->escape($refname)."' AND entity IN (".getEntity('societe').")";
2202 2202
 	}
2203 2203
 
@@ -2206,247 +2206,247 @@  discard block
 block discarded – undo
2206 2206
 	{
2207 2207
 		if ($fuser->rights->societe->{$lire})
2208 2208
 		{
2209
-			$accessallowed=1;
2209
+			$accessallowed = 1;
2210 2210
 		}
2211
-		$original_file=$conf->societe->multidir_output[$entity].'/contact/'.$original_file;
2211
+		$original_file = $conf->societe->multidir_output[$entity].'/contact/'.$original_file;
2212 2212
 	}
2213 2213
 
2214 2214
 	// Wrapping for invoices
2215 2215
 	else if (($modulepart == 'facture' || $modulepart == 'invoice') && !empty($conf->facture->dir_output))
2216 2216
 	{
2217
-		if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2217
+		if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i', $original_file))
2218 2218
 		{
2219
-			$accessallowed=1;
2219
+			$accessallowed = 1;
2220 2220
 		}
2221
-		$original_file=$conf->facture->dir_output.'/'.$original_file;
2221
+		$original_file = $conf->facture->dir_output.'/'.$original_file;
2222 2222
 		$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
2223 2223
 	}
2224 2224
 	// Wrapping for mass actions
2225 2225
 	else if ($modulepart == 'massfilesarea_proposals' && !empty($conf->propal->dir_output))
2226 2226
 	{
2227
-	    if ($fuser->rights->propal->{$lire} || preg_match('/^specimen/i',$original_file))
2227
+	    if ($fuser->rights->propal->{$lire} || preg_match('/^specimen/i', $original_file))
2228 2228
 	    {
2229
-	        $accessallowed=1;
2229
+	        $accessallowed = 1;
2230 2230
 	    }
2231
-	    $original_file=$conf->propal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2231
+	    $original_file = $conf->propal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2232 2232
 	}
2233 2233
 	else if ($modulepart == 'massfilesarea_orders')
2234 2234
 	{
2235
-	    if ($fuser->rights->commande->{$lire} || preg_match('/^specimen/i',$original_file))
2235
+	    if ($fuser->rights->commande->{$lire} || preg_match('/^specimen/i', $original_file))
2236 2236
 	    {
2237
-	        $accessallowed=1;
2237
+	        $accessallowed = 1;
2238 2238
 	    }
2239
-	    $original_file=$conf->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2239
+	    $original_file = $conf->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2240 2240
 	}
2241 2241
 	else if ($modulepart == 'massfilesarea_invoices')
2242 2242
 	{
2243
-	    if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2243
+	    if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i', $original_file))
2244 2244
 	    {
2245
-	        $accessallowed=1;
2245
+	        $accessallowed = 1;
2246 2246
 	    }
2247
-	    $original_file=$conf->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2247
+	    $original_file = $conf->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2248 2248
 	}
2249 2249
 	else if ($modulepart == 'massfilesarea_expensereport')
2250 2250
 	{
2251
-	    if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2251
+	    if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i', $original_file))
2252 2252
 	    {
2253
-	        $accessallowed=1;
2253
+	        $accessallowed = 1;
2254 2254
 	    }
2255
-	    $original_file=$conf->expensereport->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2255
+	    $original_file = $conf->expensereport->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2256 2256
 	}
2257 2257
 	else if ($modulepart == 'massfilesarea_interventions')
2258 2258
 	{
2259
-	    if ($fuser->rights->ficheinter->{$lire} || preg_match('/^specimen/i',$original_file))
2259
+	    if ($fuser->rights->ficheinter->{$lire} || preg_match('/^specimen/i', $original_file))
2260 2260
 	    {
2261
-	        $accessallowed=1;
2261
+	        $accessallowed = 1;
2262 2262
 	    }
2263
-	    $original_file=$conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2263
+	    $original_file = $conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2264 2264
 	}
2265 2265
 	else if ($modulepart == 'massfilesarea_supplier_proposal' && !empty($conf->propal->dir_output))
2266 2266
 	{
2267
-	    if ($fuser->rights->supplier_proposal->{$lire} || preg_match('/^specimen/i',$original_file))
2267
+	    if ($fuser->rights->supplier_proposal->{$lire} || preg_match('/^specimen/i', $original_file))
2268 2268
 	    {
2269
-	        $accessallowed=1;
2269
+	        $accessallowed = 1;
2270 2270
 	    }
2271
-	    $original_file=$conf->supplier_proposal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2271
+	    $original_file = $conf->supplier_proposal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2272 2272
 	}
2273 2273
 	else if ($modulepart == 'massfilesarea_supplier_order')
2274 2274
 	{
2275
-	    if ($fuser->rights->fournisseur->commande->{$lire} || preg_match('/^specimen/i',$original_file))
2275
+	    if ($fuser->rights->fournisseur->commande->{$lire} || preg_match('/^specimen/i', $original_file))
2276 2276
 	    {
2277
-	        $accessallowed=1;
2277
+	        $accessallowed = 1;
2278 2278
 	    }
2279
-	    $original_file=$conf->fournisseur->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2279
+	    $original_file = $conf->fournisseur->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2280 2280
 	}
2281 2281
 	else if ($modulepart == 'massfilesarea_supplier_invoice')
2282 2282
 	{
2283
-	    if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2283
+	    if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i', $original_file))
2284 2284
 	    {
2285
-	        $accessallowed=1;
2285
+	        $accessallowed = 1;
2286 2286
 	    }
2287
-	    $original_file=$conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2287
+	    $original_file = $conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2288 2288
 	}
2289 2289
 	else if ($modulepart == 'massfilesarea_contract' && !empty($conf->contrat->dir_output))
2290 2290
 	{
2291
-		if ($fuser->rights->contrat->{$lire} || preg_match('/^specimen/i',$original_file))
2291
+		if ($fuser->rights->contrat->{$lire} || preg_match('/^specimen/i', $original_file))
2292 2292
 		{
2293
-			$accessallowed=1;
2293
+			$accessallowed = 1;
2294 2294
 		}
2295
-		$original_file=$conf->contrat->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2295
+		$original_file = $conf->contrat->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2296 2296
 	}
2297 2297
 
2298 2298
 	// Wrapping for interventions
2299 2299
 	else if (($modulepart == 'fichinter' || $modulepart == 'ficheinter') && !empty($conf->ficheinter->dir_output))
2300 2300
 	{
2301
-		if ($fuser->rights->ficheinter->{$lire} || preg_match('/^specimen/i',$original_file))
2301
+		if ($fuser->rights->ficheinter->{$lire} || preg_match('/^specimen/i', $original_file))
2302 2302
 		{
2303
-			$accessallowed=1;
2303
+			$accessallowed = 1;
2304 2304
 		}
2305
-		$original_file=$conf->ficheinter->dir_output.'/'.$original_file;
2305
+		$original_file = $conf->ficheinter->dir_output.'/'.$original_file;
2306 2306
 		$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."fichinter WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
2307 2307
 	}
2308 2308
 
2309 2309
 	// Wrapping pour les deplacements et notes de frais
2310 2310
 	else if ($modulepart == 'deplacement' && !empty($conf->deplacement->dir_output))
2311 2311
 	{
2312
-		if ($fuser->rights->deplacement->{$lire} || preg_match('/^specimen/i',$original_file))
2312
+		if ($fuser->rights->deplacement->{$lire} || preg_match('/^specimen/i', $original_file))
2313 2313
 		{
2314
-			$accessallowed=1;
2314
+			$accessallowed = 1;
2315 2315
 		}
2316
-		$original_file=$conf->deplacement->dir_output.'/'.$original_file;
2316
+		$original_file = $conf->deplacement->dir_output.'/'.$original_file;
2317 2317
 		//$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."fichinter WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
2318 2318
 	}
2319 2319
 	// Wrapping pour les propales
2320 2320
 	else if ($modulepart == 'propal' && !empty($conf->propal->dir_output))
2321 2321
 	{
2322
-		if ($fuser->rights->propale->{$lire} || preg_match('/^specimen/i',$original_file))
2322
+		if ($fuser->rights->propale->{$lire} || preg_match('/^specimen/i', $original_file))
2323 2323
 		{
2324
-			$accessallowed=1;
2324
+			$accessallowed = 1;
2325 2325
 		}
2326 2326
 
2327
-		$original_file=$conf->propal->dir_output.'/'.$original_file;
2327
+		$original_file = $conf->propal->dir_output.'/'.$original_file;
2328 2328
 		$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."propal WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
2329 2329
 	}
2330 2330
 
2331 2331
 	// Wrapping pour les commandes
2332 2332
 	else if (($modulepart == 'commande' || $modulepart == 'order') && !empty($conf->commande->dir_output))
2333 2333
 	{
2334
-		if ($fuser->rights->commande->{$lire} || preg_match('/^specimen/i',$original_file))
2334
+		if ($fuser->rights->commande->{$lire} || preg_match('/^specimen/i', $original_file))
2335 2335
 		{
2336
-			$accessallowed=1;
2336
+			$accessallowed = 1;
2337 2337
 		}
2338
-		$original_file=$conf->commande->dir_output.'/'.$original_file;
2338
+		$original_file = $conf->commande->dir_output.'/'.$original_file;
2339 2339
 		$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."commande WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
2340 2340
 	}
2341 2341
 
2342 2342
 	// Wrapping pour les projets
2343 2343
 	else if ($modulepart == 'project' && !empty($conf->projet->dir_output))
2344 2344
 	{
2345
-		if ($fuser->rights->projet->{$lire} || preg_match('/^specimen/i',$original_file))
2345
+		if ($fuser->rights->projet->{$lire} || preg_match('/^specimen/i', $original_file))
2346 2346
 		{
2347
-			$accessallowed=1;
2347
+			$accessallowed = 1;
2348 2348
 		}
2349
-		$original_file=$conf->projet->dir_output.'/'.$original_file;
2349
+		$original_file = $conf->projet->dir_output.'/'.$original_file;
2350 2350
 		$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project').")";
2351 2351
 	}
2352 2352
 	else if ($modulepart == 'project_task' && !empty($conf->projet->dir_output))
2353 2353
 	{
2354
-		if ($fuser->rights->projet->{$lire} || preg_match('/^specimen/i',$original_file))
2354
+		if ($fuser->rights->projet->{$lire} || preg_match('/^specimen/i', $original_file))
2355 2355
 		{
2356
-			$accessallowed=1;
2356
+			$accessallowed = 1;
2357 2357
 		}
2358
-		$original_file=$conf->projet->dir_output.'/'.$original_file;
2358
+		$original_file = $conf->projet->dir_output.'/'.$original_file;
2359 2359
 		$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project').")";
2360 2360
 	}
2361 2361
 
2362 2362
 	// Wrapping pour les commandes fournisseurs
2363 2363
 	else if (($modulepart == 'commande_fournisseur' || $modulepart == 'order_supplier') && !empty($conf->fournisseur->commande->dir_output))
2364 2364
 	{
2365
-		if ($fuser->rights->fournisseur->commande->{$lire} || preg_match('/^specimen/i',$original_file))
2365
+		if ($fuser->rights->fournisseur->commande->{$lire} || preg_match('/^specimen/i', $original_file))
2366 2366
 		{
2367
-			$accessallowed=1;
2367
+			$accessallowed = 1;
2368 2368
 		}
2369
-		$original_file=$conf->fournisseur->commande->dir_output.'/'.$original_file;
2369
+		$original_file = $conf->fournisseur->commande->dir_output.'/'.$original_file;
2370 2370
 		$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."commande_fournisseur WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
2371 2371
 	}
2372 2372
 
2373 2373
 	// Wrapping pour les factures fournisseurs
2374 2374
 	else if (($modulepart == 'facture_fournisseur' || $modulepart == 'invoice_supplier') && !empty($conf->fournisseur->facture->dir_output))
2375 2375
 	{
2376
-		if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2376
+		if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i', $original_file))
2377 2377
 		{
2378
-			$accessallowed=1;
2378
+			$accessallowed = 1;
2379 2379
 		}
2380
-		$original_file=$conf->fournisseur->facture->dir_output.'/'.$original_file;
2380
+		$original_file = $conf->fournisseur->facture->dir_output.'/'.$original_file;
2381 2381
 		$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture_fourn WHERE facnumber='".$db->escape($refname)."' AND entity=".$conf->entity;
2382 2382
 	}
2383 2383
 	// Wrapping pour les rapport de paiements
2384 2384
 	else if ($modulepart == 'supplier_payment')
2385 2385
 	{
2386
-		if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2386
+		if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i', $original_file))
2387 2387
 		{
2388
-			$accessallowed=1;
2388
+			$accessallowed = 1;
2389 2389
 		}
2390
-		$original_file=$conf->fournisseur->payment->dir_output.'/'.$original_file;
2390
+		$original_file = $conf->fournisseur->payment->dir_output.'/'.$original_file;
2391 2391
 		$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."paiementfournisseur WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
2392 2392
 	}
2393 2393
 
2394 2394
 	// Wrapping pour les rapport de paiements
2395 2395
 	else if ($modulepart == 'facture_paiement' && !empty($conf->facture->dir_output))
2396 2396
 	{
2397
-		if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2397
+		if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i', $original_file))
2398 2398
 		{
2399
-			$accessallowed=1;
2399
+			$accessallowed = 1;
2400 2400
 		}
2401
-		if ($fuser->societe_id > 0) $original_file=$conf->facture->dir_output.'/payments/private/'.$fuser->id.'/'.$original_file;
2402
-		else $original_file=$conf->facture->dir_output.'/payments/'.$original_file;
2401
+		if ($fuser->societe_id > 0) $original_file = $conf->facture->dir_output.'/payments/private/'.$fuser->id.'/'.$original_file;
2402
+		else $original_file = $conf->facture->dir_output.'/payments/'.$original_file;
2403 2403
 	}
2404 2404
 
2405 2405
 	// Wrapping for accounting exports
2406 2406
 	else if ($modulepart == 'export_compta' && !empty($conf->accounting->dir_output))
2407 2407
 	{
2408
-		if ($fuser->rights->accounting->bind->write || preg_match('/^specimen/i',$original_file))
2408
+		if ($fuser->rights->accounting->bind->write || preg_match('/^specimen/i', $original_file))
2409 2409
 		{
2410
-			$accessallowed=1;
2410
+			$accessallowed = 1;
2411 2411
 		}
2412
-		$original_file=$conf->accounting->dir_output.'/'.$original_file;
2412
+		$original_file = $conf->accounting->dir_output.'/'.$original_file;
2413 2413
 	}
2414 2414
 
2415 2415
 	// Wrapping pour les expedition
2416 2416
 	else if ($modulepart == 'expedition' && !empty($conf->expedition->dir_output))
2417 2417
 	{
2418
-		if ($fuser->rights->expedition->{$lire} || preg_match('/^specimen/i',$original_file))
2418
+		if ($fuser->rights->expedition->{$lire} || preg_match('/^specimen/i', $original_file))
2419 2419
 		{
2420
-			$accessallowed=1;
2420
+			$accessallowed = 1;
2421 2421
 		}
2422
-		$original_file=$conf->expedition->dir_output."/sending/".$original_file;
2422
+		$original_file = $conf->expedition->dir_output."/sending/".$original_file;
2423 2423
 	}
2424 2424
 	// Wrapping pour les bons de livraison
2425 2425
 	else if ($modulepart == 'livraison' && !empty($conf->expedition->dir_output))
2426 2426
 	{
2427
-		if ($fuser->rights->expedition->livraison->{$lire} || preg_match('/^specimen/i',$original_file))
2427
+		if ($fuser->rights->expedition->livraison->{$lire} || preg_match('/^specimen/i', $original_file))
2428 2428
 		{
2429
-			$accessallowed=1;
2429
+			$accessallowed = 1;
2430 2430
 		}
2431
-		$original_file=$conf->expedition->dir_output."/receipt/".$original_file;
2431
+		$original_file = $conf->expedition->dir_output."/receipt/".$original_file;
2432 2432
 	}
2433 2433
 
2434 2434
 	// Wrapping pour les actions
2435 2435
 	else if ($modulepart == 'actions' && !empty($conf->agenda->dir_output))
2436 2436
 	{
2437
-		if ($fuser->rights->agenda->myactions->{$read} || preg_match('/^specimen/i',$original_file))
2437
+		if ($fuser->rights->agenda->myactions->{$read} || preg_match('/^specimen/i', $original_file))
2438 2438
 		{
2439
-			$accessallowed=1;
2439
+			$accessallowed = 1;
2440 2440
 		}
2441
-		$original_file=$conf->agenda->dir_output.'/'.$original_file;
2441
+		$original_file = $conf->agenda->dir_output.'/'.$original_file;
2442 2442
 	}
2443 2443
 
2444 2444
 	// Wrapping pour les actions
2445 2445
 	else if ($modulepart == 'actionsreport' && !empty($conf->agenda->dir_temp))
2446 2446
 	{
2447
-		if ($fuser->rights->agenda->allactions->{$read} || preg_match('/^specimen/i',$original_file))
2447
+		if ($fuser->rights->agenda->allactions->{$read} || preg_match('/^specimen/i', $original_file))
2448 2448
 		{
2449
-			$accessallowed=1;
2449
+			$accessallowed = 1;
2450 2450
 		}
2451 2451
 		$original_file = $conf->agenda->dir_temp."/".$original_file;
2452 2452
 	}
@@ -2454,54 +2454,54 @@  discard block
 block discarded – undo
2454 2454
 	// Wrapping pour les produits et services
2455 2455
 	else if ($modulepart == 'product' || $modulepart == 'produit' || $modulepart == 'service' || $modulepart == 'produit|service')
2456 2456
 	{
2457
-		if (($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) || preg_match('/^specimen/i',$original_file))
2457
+		if (($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) || preg_match('/^specimen/i', $original_file))
2458 2458
 		{
2459
-			$accessallowed=1;
2459
+			$accessallowed = 1;
2460 2460
 		}
2461
-		if (! empty($conf->product->enabled)) $original_file=$conf->product->multidir_output[$entity].'/'.$original_file;
2462
-		elseif (! empty($conf->service->enabled)) $original_file=$conf->service->multidir_output[$entity].'/'.$original_file;
2461
+		if (!empty($conf->product->enabled)) $original_file = $conf->product->multidir_output[$entity].'/'.$original_file;
2462
+		elseif (!empty($conf->service->enabled)) $original_file = $conf->service->multidir_output[$entity].'/'.$original_file;
2463 2463
 	}
2464 2464
 
2465 2465
 	// Wrapping pour les contrats
2466 2466
 	else if ($modulepart == 'contract' && !empty($conf->contrat->dir_output))
2467 2467
 	{
2468
-		if ($fuser->rights->contrat->{$lire} || preg_match('/^specimen/i',$original_file))
2468
+		if ($fuser->rights->contrat->{$lire} || preg_match('/^specimen/i', $original_file))
2469 2469
 		{
2470
-			$accessallowed=1;
2470
+			$accessallowed = 1;
2471 2471
 		}
2472
-		$original_file=$conf->contrat->dir_output.'/'.$original_file;
2472
+		$original_file = $conf->contrat->dir_output.'/'.$original_file;
2473 2473
 		$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."contrat WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('contract').")";
2474 2474
 	}
2475 2475
 
2476 2476
 	// Wrapping pour les dons
2477 2477
 	else if ($modulepart == 'donation' && !empty($conf->don->dir_output))
2478 2478
 	{
2479
-		if ($fuser->rights->don->{$lire} || preg_match('/^specimen/i',$original_file))
2479
+		if ($fuser->rights->don->{$lire} || preg_match('/^specimen/i', $original_file))
2480 2480
 		{
2481
-			$accessallowed=1;
2481
+			$accessallowed = 1;
2482 2482
 		}
2483
-		$original_file=$conf->don->dir_output.'/'.$original_file;
2483
+		$original_file = $conf->don->dir_output.'/'.$original_file;
2484 2484
 	}
2485 2485
 
2486 2486
 	// Wrapping pour les dons
2487 2487
 	else if ($modulepart == 'dolresource' && !empty($conf->resource->dir_output))
2488 2488
 	{
2489
-		if ($fuser->rights->resource->{$read} || preg_match('/^specimen/i',$original_file))
2489
+		if ($fuser->rights->resource->{$read} || preg_match('/^specimen/i', $original_file))
2490 2490
 		{
2491
-			$accessallowed=1;
2491
+			$accessallowed = 1;
2492 2492
 		}
2493
-		$original_file=$conf->resource->dir_output.'/'.$original_file;
2493
+		$original_file = $conf->resource->dir_output.'/'.$original_file;
2494 2494
 	}
2495 2495
 
2496 2496
 	// Wrapping pour les remises de cheques
2497 2497
 	else if ($modulepart == 'remisecheque' && !empty($conf->banque->dir_output))
2498 2498
 	{
2499
-		if ($fuser->rights->banque->{$lire} || preg_match('/^specimen/i',$original_file))
2499
+		if ($fuser->rights->banque->{$lire} || preg_match('/^specimen/i', $original_file))
2500 2500
 		{
2501
-			$accessallowed=1;
2501
+			$accessallowed = 1;
2502 2502
 		}
2503 2503
 
2504
-		$original_file=$conf->bank->dir_output.'/checkdeposits/'.$original_file;		// original_file should contains relative path so include the get_exdir result
2504
+		$original_file = $conf->bank->dir_output.'/checkdeposits/'.$original_file; // original_file should contains relative path so include the get_exdir result
2505 2505
 	}
2506 2506
 
2507 2507
 	// Wrapping for bank
@@ -2509,9 +2509,9 @@  discard block
 block discarded – undo
2509 2509
 	{
2510 2510
 		if ($fuser->rights->banque->{$lire})
2511 2511
 		{
2512
-			$accessallowed=1;
2512
+			$accessallowed = 1;
2513 2513
 		}
2514
-		$original_file=$conf->bank->dir_output.'/'.$original_file;
2514
+		$original_file = $conf->bank->dir_output.'/'.$original_file;
2515 2515
 	}
2516 2516
 
2517 2517
 	// Wrapping for export module
@@ -2519,62 +2519,62 @@  discard block
 block discarded – undo
2519 2519
 	{
2520 2520
 		// Aucun test necessaire car on force le rep de download sur
2521 2521
 		// le rep export qui est propre a l'utilisateur
2522
-		$accessallowed=1;
2523
-		$original_file=$conf->export->dir_temp.'/'.$fuser->id.'/'.$original_file;
2522
+		$accessallowed = 1;
2523
+		$original_file = $conf->export->dir_temp.'/'.$fuser->id.'/'.$original_file;
2524 2524
 	}
2525 2525
 
2526 2526
 	// Wrapping for import module
2527 2527
 	else if ($modulepart == 'import' && !empty($conf->import->dir_temp))
2528 2528
 	{
2529
-		$accessallowed=1;
2530
-		$original_file=$conf->import->dir_temp.'/'.$original_file;
2529
+		$accessallowed = 1;
2530
+		$original_file = $conf->import->dir_temp.'/'.$original_file;
2531 2531
 	}
2532 2532
 
2533 2533
 	// Wrapping pour l'editeur wysiwyg
2534 2534
 	else if ($modulepart == 'editor' && !empty($conf->fckeditor->dir_output))
2535 2535
 	{
2536
-		$accessallowed=1;
2537
-		$original_file=$conf->fckeditor->dir_output.'/'.$original_file;
2536
+		$accessallowed = 1;
2537
+		$original_file = $conf->fckeditor->dir_output.'/'.$original_file;
2538 2538
 	}
2539 2539
 
2540 2540
 	// Wrapping for backups
2541 2541
 	else if ($modulepart == 'systemtools' && !empty($conf->admin->dir_output))
2542 2542
 	{
2543
-		if ($fuser->admin) $accessallowed=1;
2544
-		$original_file=$conf->admin->dir_output.'/'.$original_file;
2543
+		if ($fuser->admin) $accessallowed = 1;
2544
+		$original_file = $conf->admin->dir_output.'/'.$original_file;
2545 2545
 	}
2546 2546
 
2547 2547
 	// Wrapping for upload file test
2548 2548
 	else if ($modulepart == 'admin_temp' && !empty($conf->admin->dir_temp))
2549 2549
 	{
2550
-		if ($fuser->admin) $accessallowed=1;
2551
-		$original_file=$conf->admin->dir_temp.'/'.$original_file;
2550
+		if ($fuser->admin) $accessallowed = 1;
2551
+		$original_file = $conf->admin->dir_temp.'/'.$original_file;
2552 2552
 	}
2553 2553
 
2554 2554
 	// Wrapping pour BitTorrent
2555 2555
 	else if ($modulepart == 'bittorrent' && !empty($conf->bittorrent->dir_output))
2556 2556
 	{
2557
-		$accessallowed=1;
2558
-		$dir='files';
2559
-		if (dol_mimetype($original_file) == 'application/x-bittorrent') $dir='torrents';
2560
-		$original_file=$conf->bittorrent->dir_output.'/'.$dir.'/'.$original_file;
2557
+		$accessallowed = 1;
2558
+		$dir = 'files';
2559
+		if (dol_mimetype($original_file) == 'application/x-bittorrent') $dir = 'torrents';
2560
+		$original_file = $conf->bittorrent->dir_output.'/'.$dir.'/'.$original_file;
2561 2561
 	}
2562 2562
 
2563 2563
 	// Wrapping pour Foundation module
2564 2564
 	else if ($modulepart == 'member' && !empty($conf->adherent->dir_output))
2565 2565
 	{
2566
-		if ($fuser->rights->adherent->{$lire} || preg_match('/^specimen/i',$original_file))
2566
+		if ($fuser->rights->adherent->{$lire} || preg_match('/^specimen/i', $original_file))
2567 2567
 		{
2568
-			$accessallowed=1;
2568
+			$accessallowed = 1;
2569 2569
 		}
2570
-		$original_file=$conf->adherent->dir_output.'/'.$original_file;
2570
+		$original_file = $conf->adherent->dir_output.'/'.$original_file;
2571 2571
 	}
2572 2572
 
2573 2573
 	// Wrapping for Scanner
2574 2574
 	else if ($modulepart == 'scanner_user_temp' && !empty($conf->scanner->dir_temp))
2575 2575
 	{
2576
-		$accessallowed=1;
2577
-		$original_file=$conf->scanner->dir_temp.'/'.$fuser->id.'/'.$original_file;
2576
+		$accessallowed = 1;
2577
+		$original_file = $conf->scanner->dir_temp.'/'.$fuser->id.'/'.$original_file;
2578 2578
 	}
2579 2579
 
2580 2580
     // GENERIC Wrapping
@@ -2584,76 +2584,76 @@  discard block
 block discarded – undo
2584 2584
     // If modulepart=module				Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart
2585 2585
     else
2586 2586
 	{
2587
-	    if (preg_match('/^specimen/i',$original_file))	$accessallowed=1;    // If link to a file called specimen. Test must be done before changing $original_file int full path.
2588
-	    if ($fuser->admin) $accessallowed=1;    // If user is admin
2587
+	    if (preg_match('/^specimen/i', $original_file))	$accessallowed = 1; // If link to a file called specimen. Test must be done before changing $original_file int full path.
2588
+	    if ($fuser->admin) $accessallowed = 1; // If user is admin
2589 2589
 
2590 2590
 		// Define $accessallowed
2591
-		if (preg_match('/^([a-z]+)_user_temp$/i',$modulepart,$reg))
2591
+		if (preg_match('/^([a-z]+)_user_temp$/i', $modulepart, $reg))
2592 2592
 		{
2593 2593
 			if (empty($conf->{$reg[1]}->dir_temp))	// modulepart not supported
2594 2594
 			{
2595
-				dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
2595
+				dol_print_error('', 'Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
2596 2596
 				exit;
2597 2597
 			}
2598
-		    if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1;
2599
-			$original_file=$conf->{$reg[1]}->dir_temp.'/'.$fuser->id.'/'.$original_file;
2598
+		    if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed = 1;
2599
+			$original_file = $conf->{$reg[1]}->dir_temp.'/'.$fuser->id.'/'.$original_file;
2600 2600
 		}
2601
-		else if (preg_match('/^([a-z]+)_temp$/i',$modulepart,$reg))
2601
+		else if (preg_match('/^([a-z]+)_temp$/i', $modulepart, $reg))
2602 2602
 		{
2603 2603
 			if (empty($conf->{$reg[1]}->dir_temp))	// modulepart not supported
2604 2604
 			{
2605
-				dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
2605
+				dol_print_error('', 'Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
2606 2606
 				exit;
2607 2607
 			}
2608
-		    if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1;
2609
-			$original_file=$conf->{$reg[1]}->dir_temp.'/'.$original_file;
2608
+		    if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed = 1;
2609
+			$original_file = $conf->{$reg[1]}->dir_temp.'/'.$original_file;
2610 2610
 		}
2611
-		else if (preg_match('/^([a-z]+)_user$/i',$modulepart,$reg))
2611
+		else if (preg_match('/^([a-z]+)_user$/i', $modulepart, $reg))
2612 2612
 		{
2613 2613
 			if (empty($conf->{$reg[1]}->dir_output))	// modulepart not supported
2614 2614
 			{
2615
-				dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
2615
+				dol_print_error('', 'Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
2616 2616
 				exit;
2617 2617
 			}
2618
-		    if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1;
2619
-			$original_file=$conf->{$reg[1]}->dir_output.'/'.$fuser->id.'/'.$original_file;
2618
+		    if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed = 1;
2619
+			$original_file = $conf->{$reg[1]}->dir_output.'/'.$fuser->id.'/'.$original_file;
2620 2620
 		}
2621 2621
 		else
2622 2622
 		{
2623 2623
 			if (empty($conf->$modulepart->dir_output))	// modulepart not supported
2624 2624
 			{
2625
-				dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
2625
+				dol_print_error('', 'Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
2626 2626
 				exit;
2627 2627
 			}
2628 2628
 
2629
-			$perm=GETPOST('perm');
2630
-			$subperm=GETPOST('subperm');
2629
+			$perm = GETPOST('perm');
2630
+			$subperm = GETPOST('subperm');
2631 2631
 			if ($perm || $subperm)
2632 2632
 			{
2633
-				if (($perm && ! $subperm && $fuser->rights->$modulepart->$perm) || ($perm && $subperm && $fuser->rights->$modulepart->$perm->$subperm)) $accessallowed=1;
2634
-				$original_file=$conf->$modulepart->dir_output.'/'.$original_file;
2633
+				if (($perm && !$subperm && $fuser->rights->$modulepart->$perm) || ($perm && $subperm && $fuser->rights->$modulepart->$perm->$subperm)) $accessallowed = 1;
2634
+				$original_file = $conf->$modulepart->dir_output.'/'.$original_file;
2635 2635
 			}
2636 2636
 			else
2637 2637
 			{
2638
-				if ($fuser->rights->$modulepart->{$lire} || $fuser->rights->$modulepart->{$read}) $accessallowed=1;
2639
-				$original_file=$conf->$modulepart->dir_output.'/'.$original_file;
2638
+				if ($fuser->rights->$modulepart->{$lire} || $fuser->rights->$modulepart->{$read}) $accessallowed = 1;
2639
+				$original_file = $conf->$modulepart->dir_output.'/'.$original_file;
2640 2640
 			}
2641 2641
 		}
2642 2642
 
2643 2643
 		// For modules who wants to manage different levels of permissions for documents
2644 2644
 		$subPermCategoryConstName = strtoupper($modulepart).'_SUBPERMCATEGORY_FOR_DOCUMENTS';
2645
-		if (! empty($conf->global->$subPermCategoryConstName))
2645
+		if (!empty($conf->global->$subPermCategoryConstName))
2646 2646
 		{
2647 2647
 			$subPermCategory = $conf->global->$subPermCategoryConstName;
2648
-			if (! empty($subPermCategory) && (($fuser->rights->$modulepart->$subPermCategory->{$lire}) || ($fuser->rights->$modulepart->$subPermCategory->{$read}) || ($fuser->rights->$modulepart->$subPermCategory->{$download})))
2648
+			if (!empty($subPermCategory) && (($fuser->rights->$modulepart->$subPermCategory->{$lire}) || ($fuser->rights->$modulepart->$subPermCategory->{$read}) || ($fuser->rights->$modulepart->$subPermCategory->{$download})))
2649 2649
 			{
2650
-				$accessallowed=1;
2650
+				$accessallowed = 1;
2651 2651
 			}
2652 2652
 		}
2653 2653
 
2654 2654
 		// Define $sqlprotectagainstexternals for modules who want to protect access using a SQL query.
2655 2655
 		$sqlProtectConstName = strtoupper($modulepart).'_SQLPROTECTAGAINSTEXTERNALS_FOR_DOCUMENTS';
2656
-		if (! empty($conf->global->$sqlProtectConstName))	// If module want to define its own $sqlprotectagainstexternals
2656
+		if (!empty($conf->global->$sqlProtectConstName))	// If module want to define its own $sqlprotectagainstexternals
2657 2657
 		{
2658 2658
 			// Example: mymodule__SQLPROTECTAGAINSTEXTERNALS_FOR_DOCUMENTS = "SELECT fk_soc FROM ".MAIN_DB_PREFIX.$modulepart." WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
2659 2659
 			eval('$sqlprotectagainstexternals = "'.$conf->global->$sqlProtectConstName.'";');
@@ -2679,8 +2679,8 @@  discard block
 block discarded – undo
2679 2679
  */
2680 2680
 function dol_filecache($directory, $filename, $object)
2681 2681
 {
2682
-    if (! dol_is_dir($directory)) dol_mkdir($directory);
2683
-    $cachefile = $directory . $filename;
2682
+    if (!dol_is_dir($directory)) dol_mkdir($directory);
2683
+    $cachefile = $directory.$filename;
2684 2684
     file_put_contents($cachefile, serialize($object), LOCK_EX);
2685 2685
     @chmod($cachefile, 0644);
2686 2686
 }
@@ -2696,8 +2696,8 @@  discard block
 block discarded – undo
2696 2696
 function dol_cache_refresh($directory, $filename, $cachetime)
2697 2697
 {
2698 2698
     $now = dol_now();
2699
-    $cachefile = $directory . $filename;
2700
-    $refresh = !file_exists($cachefile) || ($now-$cachetime) > dol_filemtime($cachefile);
2699
+    $cachefile = $directory.$filename;
2700
+    $refresh = !file_exists($cachefile) || ($now - $cachetime) > dol_filemtime($cachefile);
2701 2701
     return $refresh;
2702 2702
 }
2703 2703
 
@@ -2710,7 +2710,7 @@  discard block
 block discarded – undo
2710 2710
  */
2711 2711
 function dol_readcachefile($directory, $filename)
2712 2712
 {
2713
-    $cachefile = $directory . $filename;
2713
+    $cachefile = $directory.$filename;
2714 2714
     $object = unserialize(file_get_contents($cachefile));
2715 2715
     return $object;
2716 2716
 }
Please login to merge, or discard this patch.
Braces   +454 added lines, -240 removed lines patch added patch discarded remove patch
@@ -97,16 +97,21 @@  discard block
 block discarded – undo
97 97
 	// $hookmanager->resArray may contain array stacked by other modules
98 98
 	if (empty($reshook))
99 99
 	{
100
-		if (! is_dir($newpath)) return array();
100
+		if (! is_dir($newpath)) {
101
+			return array();
102
+		}
101 103
 
102 104
 		if ($dir = opendir($newpath))
103 105
 		{
104 106
 			$filedate='';
105 107
 			$filesize='';
106 108
 
107
-			while (false !== ($file = readdir($dir)))        // $file is always a basename (into directory $newpath)
109
+			while (false !== ($file = readdir($dir))) {
110
+				// $file is always a basename (into directory $newpath)
108 111
 			{
109
-				if (! utf8_check($file)) $file=utf8_encode($file);	// To be sure data is stored in utf8 in memory
112
+				if (! utf8_check($file)) $file=utf8_encode($file);
113
+			}
114
+			// To be sure data is stored in utf8 in memory
110 115
 
111 116
 				$qualified=1;
112 117
 
@@ -115,8 +120,9 @@  discard block
 block discarded – undo
115 120
 				if (is_array($excludefilter))
116 121
 				{
117 122
 					$excludefilterarray=array_merge($excludefilterarray,$excludefilter);
123
+				} else if ($excludefilter) {
124
+					$excludefilterarray[]=$excludefilter;
118 125
 				}
119
-				else if ($excludefilter) $excludefilterarray[]=$excludefilter;
120 126
 				// Check if file is qualified
121 127
 				foreach($excludefilterarray as $filt)
122 128
 				{
@@ -134,12 +140,18 @@  discard block
 block discarded – undo
134 140
 						// Add entry into file_list array
135 141
 						if (($types=="directories") || ($types=="all"))
136 142
 						{
137
-							if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file);
138
-							if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file);
143
+							if ($loaddate || $sortcriteria == 'date') {
144
+								$filedate=dol_filemtime($path."/".$file);
145
+							}
146
+							if ($loadsize || $sortcriteria == 'size') {
147
+								$filesize=dol_filesize($path."/".$file);
148
+							}
139 149
 
140
-							if (! $filter || preg_match('/'.$filter.'/i',$file))	// We do not search key $filter into all $path, only into $file part
150
+							if (! $filter || preg_match('/'.$filter.'/i',$file)) {
151
+								// We do not search key $filter into all $path, only into $file part
141 152
 							{
142 153
 								preg_match('/([^\/]+)\/[^\/]+$/',$path.'/'.$file,$reg);
154
+							}
143 155
 								$level1name=(isset($reg[1])?$reg[1]:'');
144 156
 								$file_list[] = array(
145 157
 										"name" => $file,
@@ -159,16 +171,21 @@  discard block
 block discarded – undo
159 171
 						{
160 172
 							$file_list = array_merge($file_list, dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode, $nohook, ($relativename?$relativename.'/':'').$file));
161 173
 						}
162
-					}
163
-					else if (! $isdir && (($types == "files") || ($types == "all")))
174
+					} else if (! $isdir && (($types == "files") || ($types == "all")))
164 175
 					{
165 176
 						// Add file into file_list array
166
-						if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file);
167
-						if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file);
177
+						if ($loaddate || $sortcriteria == 'date') {
178
+							$filedate=dol_filemtime($path."/".$file);
179
+						}
180
+						if ($loadsize || $sortcriteria == 'size') {
181
+							$filesize=dol_filesize($path."/".$file);
182
+						}
168 183
 
169
-						if (! $filter || preg_match('/'.$filter.'/i',$file))	// We do not search key $filter into $path, only into $file
184
+						if (! $filter || preg_match('/'.$filter.'/i',$file)) {
185
+							// We do not search key $filter into $path, only into $file
170 186
 						{
171 187
 							preg_match('/([^\/]+)\/[^\/]+$/',$path.'/'.$file,$reg);
188
+						}
172 189
 							$level1name=(isset($reg[1])?$reg[1]:'');
173 190
 							$file_list[] = array(
174 191
 									"name" => $file,
@@ -195,12 +212,16 @@  discard block
 block discarded – undo
195 212
 					$myarray[$key] = (isset($row[$sortcriteria])?$row[$sortcriteria]:'');
196 213
 				}
197 214
 				// Sort the data
198
-				if ($sortorder) array_multisort($myarray, $sortorder, $file_list);
215
+				if ($sortorder) {
216
+					array_multisort($myarray, $sortorder, $file_list);
217
+				}
199 218
 			}
200 219
 		}
201 220
 	}
202 221
 
203
-	if (is_object($hookmanager) && is_array($hookmanager->resArray)) $file_list = array_merge($file_list, $hookmanager->resArray);
222
+	if (is_object($hookmanager) && is_array($hookmanager->resArray)) {
223
+		$file_list = array_merge($file_list, $hookmanager->resArray);
224
+	}
204 225
 
205 226
 	return $file_list;
206 227
 }
@@ -224,7 +245,9 @@  discard block
 block discarded – undo
224 245
     global $conf, $db;
225 246
 
226 247
     $sql=" SELECT rowid, label, entity, filename, filepath, fullpath_orig, keywords, cover, gen_or_uploaded, extraparams, date_c, date_m, fk_user_c, fk_user_m, acl, position";
227
-    if ($mode) $sql.=", description";
248
+    if ($mode) {
249
+    	$sql.=", description";
250
+    }
228 251
     $sql.=" FROM ".MAIN_DB_PREFIX."ecm_files";
229 252
     $sql.=" WHERE filepath = '".$db->escape($path)."'";
230 253
     $sql.=" AND entity = ".$conf->entity;
@@ -271,12 +294,13 @@  discard block
 block discarded – undo
271 294
                 $myarray[$key] = (isset($row[$sortcriteria])?$row[$sortcriteria]:'');
272 295
             }
273 296
             // Sort the data
274
-            if ($sortorder) array_multisort($myarray, $sortorder, $file_list);
297
+            if ($sortorder) {
298
+            	array_multisort($myarray, $sortorder, $file_list);
299
+            }
275 300
         }
276 301
 
277 302
         return $file_list;
278
-    }
279
-    else
303
+    } else
280 304
     {
281 305
         dol_print_error($db);
282 306
         return array();
@@ -321,16 +345,21 @@  discard block
 block discarded – undo
321 345
 			}
322 346
 		}
323 347
 
324
-		if (! $found)    // This happen in transition toward version 6, or if files were added manually into os dir.
348
+		if (! $found) {
349
+			// This happen in transition toward version 6, or if files were added manually into os dir.
325 350
 		{
326
-			$filearray[$key]['position']='999999';     // File not indexed are at end. So if we add a file, it will not replace an existing position
351
+			$filearray[$key]['position']='999999';
352
+		}
353
+		// File not indexed are at end. So if we add a file, it will not replace an existing position
327 354
 			$filearray[$key]['cover']=0;
328 355
 			$filearray[$key]['acl']='';
329 356
 
330 357
 			$rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filearray[$key]['fullname']);
331
-			if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter))     // If not a tmp file
358
+			if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) {
359
+				// If not a tmp file
332 360
 			{
333 361
 				dol_syslog("list_of_documents We found a file called '".$filearray[$key]['name']."' not indexed into database. We add it");
362
+			}
334 363
 				include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
335 364
 				$ecmfile=new EcmFiles($db);
336 365
 
@@ -351,13 +380,11 @@  discard block
 block discarded – undo
351 380
 				if ($result < 0)
352 381
 				{
353 382
 					setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
354
-				}
355
-				else
383
+				} else
356 384
 				{
357 385
 					$filearray[$key]['rowid']=$result;
358 386
 				}
359
-			}
360
-			else
387
+			} else
361 388
 			{
362 389
 				$filearray[$key]['rowid']=0;     // Should not happened
363 390
 			}
@@ -382,22 +409,27 @@  discard block
 block discarded – undo
382 409
 
383 410
 	$sortorder=strtoupper($sortorder);
384 411
 
385
-	if ($sortorder == 'ASC') { $retup=-1; $retdown=1; }
386
-	else { $retup=1; $retdown=-1; }
412
+	if ($sortorder == 'ASC') { $retup=-1; $retdown=1; } else { $retup=1; $retdown=-1; }
387 413
 
388 414
 	if ($sortfield == 'name')
389 415
 	{
390
-		if ($a->name == $b->name) return 0;
416
+		if ($a->name == $b->name) {
417
+			return 0;
418
+		}
391 419
 		return ($a->name < $b->name) ? $retup : $retdown;
392 420
 	}
393 421
 	if ($sortfield == 'date')
394 422
 	{
395
-		if ($a->date == $b->date) return 0;
423
+		if ($a->date == $b->date) {
424
+			return 0;
425
+		}
396 426
 		return ($a->date < $b->date) ? $retup : $retdown;
397 427
 	}
398 428
 	if ($sortfield == 'size')
399 429
 	{
400
-		if ($a->size == $b->size) return 0;
430
+		if ($a->size == $b->size) {
431
+			return 0;
432
+		}
401 433
 		return ($a->size < $b->size) ? $retup : $retdown;
402 434
 	}
403 435
 }
@@ -412,9 +444,12 @@  discard block
 block discarded – undo
412 444
 function dol_is_dir($folder)
413 445
 {
414 446
     $newfolder=dol_osencode($folder);
415
-    if (is_dir($newfolder)) return true;
416
-    else return false;
417
-}
447
+    if (is_dir($newfolder)) {
448
+    	return true;
449
+    } else {
450
+    	return false;
451
+    }
452
+    }
418 453
 
419 454
 /**
420 455
  * Return if path is a file
@@ -439,7 +474,9 @@  discard block
 block discarded – undo
439 474
     $tmpprot=array('file','http','https','ftp','zlib','data','ssh','ssh2','ogg','expect');
440 475
     foreach($tmpprot as $prot)
441 476
     {
442
-        if (preg_match('/^'.$prot.':/i',$url)) return true;
477
+        if (preg_match('/^'.$prot.':/i',$url)) {
478
+        	return true;
479
+        }
443 480
     }
444 481
     return false;
445 482
 }
@@ -461,15 +498,21 @@  discard block
 block discarded – undo
461 498
 		{
462 499
 			$name_array[] = $name;
463 500
 		}
464
-		foreach($name_array as $temp) $folder_content .= $temp;
501
+		foreach($name_array as $temp) {
502
+			$folder_content .= $temp;
503
+		}
465 504
 
466 505
         closedir($handle);
467 506
 
468
-		if ($folder_content == "...") return true;
469
-		else return false;
507
+		if ($folder_content == "...") {
508
+			return true;
509
+		} else {
510
+			return false;
511
+		}
512
+	} else {
513
+		return true;
470 514
 	}
471
-	else
472
-	return true; // Dir does not exists
515
+	// Dir does not exists
473 516
 }
474 517
 
475 518
 /**
@@ -492,11 +535,12 @@  discard block
 block discarded – undo
492 535
 		{
493 536
 			$line=fgets($fp);
494 537
             // We increase count only if read was success. We need test because feof return true only after fgets so we do n+1 fgets for a file with n lines.
495
-			if (! $line === false) $nb++;
538
+			if (! $line === false) {
539
+				$nb++;
540
+			}
496 541
 		}
497 542
 		fclose($fp);
498
-	}
499
-	else
543
+	} else
500 544
 	{
501 545
 		$nb=-1;
502 546
 	}
@@ -546,11 +590,17 @@  discard block
 block discarded – undo
546 590
 
547 591
     dol_syslog("files.lib.php::dolReplaceInFile srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." indexdatabase=".$indexdatabase);
548 592
 
549
-    if (empty($srcfile)) return -1;
550
-    if (empty($destfile)) $destfile=$srcfile;
593
+    if (empty($srcfile)) {
594
+    	return -1;
595
+    }
596
+    if (empty($destfile)) {
597
+    	$destfile=$srcfile;
598
+    }
551 599
 
552 600
     $destexists=dol_is_file($destfile);
553
-    if (($destfile != $srcfile) && $destexists) return 0;
601
+    if (($destfile != $srcfile) && $destexists) {
602
+    	return 0;
603
+    }
554 604
 
555 605
     $tmpdestfile=$destfile.'.tmp';
556 606
 
@@ -587,10 +637,14 @@  discard block
 block discarded – undo
587 637
         dol_syslog("files.lib.php::dolReplaceInFile failed to move tmp file to final dest", LOG_WARNING);
588 638
         return -3;
589 639
     }
590
-    if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
591
-    if (empty($newmask))	// This should no happen
640
+    if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) {
641
+    	$newmask=$conf->global->MAIN_UMASK;
642
+    }
643
+    if (empty($newmask)) {
644
+    	// This should no happen
592 645
     {
593 646
         dol_syslog("Warning: dolReplaceInFile called with empty value for newmask and no default value defined", LOG_WARNING);
647
+    }
594 648
         $newmask='0664';
595 649
     }
596 650
 
@@ -632,10 +686,14 @@  discard block
 block discarded – undo
632 686
 
633 687
 	dol_syslog("files.lib.php::dol_copy srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwriteifexists=".$overwriteifexists);
634 688
 
635
-	if (empty($srcfile) || empty($destfile)) return -1;
689
+	if (empty($srcfile) || empty($destfile)) {
690
+		return -1;
691
+	}
636 692
 
637 693
 	$destexists=dol_is_file($destfile);
638
-	if (! $overwriteifexists && $destexists) return 0;
694
+	if (! $overwriteifexists && $destexists) {
695
+		return 0;
696
+	}
639 697
 
640 698
 	$newpathofsrcfile=dol_osencode($srcfile);
641 699
     $newpathofdestfile=dol_osencode($destfile);
@@ -659,10 +717,14 @@  discard block
 block discarded – undo
659 717
 	    dol_syslog("files.lib.php::dol_copy failed to copy", LOG_WARNING);
660 718
 	    return -3;
661 719
 	}
662
-	if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
663
-	if (empty($newmask))	// This should no happen
720
+	if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) {
721
+		$newmask=$conf->global->MAIN_UMASK;
722
+	}
723
+	if (empty($newmask)) {
724
+		// This should no happen
664 725
 	{
665 726
 		dol_syslog("Warning: dol_copy called with empty value for newmask and no default value defined", LOG_WARNING);
727
+	}
666 728
 		$newmask='0664';
667 729
 	}
668 730
 
@@ -690,7 +752,9 @@  discard block
 block discarded – undo
690 752
 
691 753
 	dol_syslog("files.lib.php::dolCopyDir srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwriteifexists=".$overwriteifexists);
692 754
 
693
-	if (empty($srcfile) || empty($destfile)) return -1;
755
+	if (empty($srcfile) || empty($destfile)) {
756
+		return -1;
757
+	}
694 758
 
695 759
 	$destexists=dol_is_dir($destfile);
696 760
 	//if (! $overwriteifexists && $destexists) return 0;	// The overwriteifexists is for files only, so propagated to dol_copy only.
@@ -700,7 +764,9 @@  discard block
 block discarded – undo
700 764
         // We must set mask just before creating dir, becaause it can be set differently by dol_copy
701 765
         umask(0);
702 766
         $dirmaskdec=octdec($newmask);
703
-        if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK);
767
+        if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) {
768
+        	$dirmaskdec=octdec($conf->global->MAIN_UMASK);
769
+        }
704 770
         $dirmaskdec |= octdec('0200');  // Set w bit required to be able to create content for recursive subdirs files
705 771
         dol_mkdir($destfile, '', decoct($dirmaskdec));
706 772
     }
@@ -720,8 +786,7 @@  discard block
 block discarded – undo
720 786
                 {
721 787
                     //var_dump("xxx dolCopyDir $srcfile/$file, $destfile/$file, $newmask, $overwriteifexists");
722 788
                     $tmpresult=dolCopyDir($srcfile."/".$file, $destfile."/".$file, $newmask, $overwriteifexists, $arrayreplacement);
723
-                }
724
-                else
789
+                } else
725 790
 				{
726 791
 					$newfile = $file;
727 792
 					// Replace destination filename with a new one
@@ -738,18 +803,18 @@  discard block
 block discarded – undo
738 803
                 if ($result > 0 && $tmpresult >= 0)
739 804
                 {
740 805
                     // Do nothing, so we don't set result to 0 if tmpresult is 0 and result was success in a previous pass
741
-                }
742
-                else
806
+                } else
743 807
                 {
744 808
                     $result=$tmpresult;
745 809
                 }
746
-                if ($result < 0) break;
810
+                if ($result < 0) {
811
+                	break;
812
+                }
747 813
 
748 814
             }
749 815
         }
750 816
         closedir($dir_handle);
751
-    }
752
-    else
817
+    } else
753 818
 	{
754 819
 		// Source directory does not exists
755 820
         $result = -2;
@@ -816,8 +881,9 @@  discard block
 block discarded – undo
816 881
         		// We force delete and try again. Rename function sometimes fails to replace dest file with some windows NTFS partitions.
817 882
         		dol_delete_file($destfile);
818 883
         		$result=@rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @
884
+        	} else {
885
+        		dol_syslog("files.lib.php::dol_move Failed.", LOG_WARNING);
819 886
         	}
820
-        	else dol_syslog("files.lib.php::dol_move Failed.", LOG_WARNING);
821 887
         }
822 888
 
823 889
         // Move ok
@@ -826,9 +892,11 @@  discard block
 block discarded – undo
826 892
             // Rename entry into ecm database
827 893
             $rel_filetorenamebefore = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $srcfile);
828 894
             $rel_filetorenameafter = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $destfile);
829
-            if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter))     // If not a tmp file
895
+            if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) {
896
+            	// If not a tmp file
830 897
             {
831 898
                 $rel_filetorenamebefore = preg_replace('/^[\\/]/', '', $rel_filetorenamebefore);
899
+            }
832 900
                 $rel_filetorenameafter = preg_replace('/^[\\/]/', '', $rel_filetorenameafter);
833 901
                 //var_dump($rel_filetorenamebefore.' - '.$rel_filetorenameafter);
834 902
 
@@ -837,16 +905,20 @@  discard block
 block discarded – undo
837 905
 
838 906
                 $ecmfiletarget=new EcmFiles($db);
839 907
                 $resultecmtarget = $ecmfiletarget->fetch(0, '', $rel_filetorenameafter);
840
-                if ($resultecmtarget > 0)   // An entry for target name already exists for target, we delete it, a new one will be created.
908
+                if ($resultecmtarget > 0) {
909
+                	// An entry for target name already exists for target, we delete it, a new one will be created.
841 910
                 {
842 911
                     $ecmfiletarget->delete($user);
843 912
                 }
913
+                }
844 914
 
845 915
                 $ecmfile=new EcmFiles($db);
846 916
                 $resultecm = $ecmfile->fetch(0, '', $rel_filetorenamebefore);
847
-                if ($resultecm > 0)   // If an entry was found for src file, we use it to move entry
917
+                if ($resultecm > 0) {
918
+                	// If an entry was found for src file, we use it to move entry
848 919
                 {
849 920
                     $filename = basename($rel_filetorenameafter);
921
+                }
850 922
                     $rel_dir = dirname($rel_filetorenameafter);
851 923
                     $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
852 924
                     $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
@@ -854,10 +926,11 @@  discard block
 block discarded – undo
854 926
                     $ecmfile->filepath = $rel_dir;
855 927
                     $ecmfile->filename = $filename;
856 928
                     $resultecm = $ecmfile->update($user);
857
-                }
858
-                elseif ($resultecm == 0)   // If no entry were found for src files, create/update target file
929
+                } elseif ($resultecm == 0) {
930
+                	// If no entry were found for src files, create/update target file
859 931
                 {
860 932
                     $filename = basename($rel_filetorenameafter);
933
+                }
861 934
                     $rel_dir = dirname($rel_filetorenameafter);
862 935
                     $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
863 936
                     $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
@@ -874,18 +947,22 @@  discard block
 block discarded – undo
874 947
                     {
875 948
                         setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
876 949
                     }
877
-                }
878
-                elseif ($resultecm < 0)
950
+                } elseif ($resultecm < 0)
879 951
                 {
880 952
                     setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
881 953
                 }
882 954
 
883
-                if ($resultecm > 0) $result=true;
884
-                else $result = false;
955
+                if ($resultecm > 0) {
956
+                	$result=true;
957
+                } else {
958
+                	$result = false;
959
+                }
885 960
             }
886 961
         }
887 962
 
888
-        if (empty($newmask)) $newmask=empty($conf->global->MAIN_UMASK)?'0755':$conf->global->MAIN_UMASK;
963
+        if (empty($newmask)) {
964
+        	$newmask=empty($conf->global->MAIN_UMASK)?'0755':$conf->global->MAIN_UMASK;
965
+        }
889 966
         $newmaskdec=octdec($newmask);
890 967
         // Currently method is restricted to files (dol_delete_files previously used is for files, and mask usage if for files too)
891 968
         // to allow mask usage for dir, we shoul introduce a new param "isdir" to 1 to complete newmask like this
@@ -929,9 +1006,11 @@  discard block
 block discarded – undo
929 1006
         }
930 1007
         $antivir=new AntiVir($db);
931 1008
         $result = $antivir->dol_avscan_file($src_file);
932
-        if ($result < 0)	// If virus or error, we stop here
1009
+        if ($result < 0) {
1010
+        	// If virus or error, we stop here
933 1011
         {
934 1012
             $reterrors=$antivir->errors;
1013
+        }
935 1014
             return $reterrors;
936 1015
         }
937 1016
     }
@@ -1039,13 +1118,17 @@  discard block
 block discarded – undo
1039 1118
     	}
1040 1119
 	}
1041 1120
 
1042
-	if ($reshook < 0)	// At least one blocking error returned by one hook
1121
+	if ($reshook < 0) {
1122
+		// At least one blocking error returned by one hook
1043 1123
 	{
1044 1124
 		$errmsg = join(',', $hookmanager->errors);
1045
-		if (empty($errmsg)) $errmsg = 'ErrorReturnedBySomeHooks';	// Should not occurs. Added if hook is bugged and does not set ->errors when there is error.
1046
-		return $errmsg;
1047 1125
 	}
1048
-	elseif (empty($reshook))
1126
+		if (empty($errmsg)) {
1127
+			$errmsg = 'ErrorReturnedBySomeHooks';
1128
+		}
1129
+		// Should not occurs. Added if hook is bugged and does not set ->errors when there is error.
1130
+		return $errmsg;
1131
+	} elseif (empty($reshook))
1049 1132
 	{
1050 1133
 		// The file functions must be in OS filesystem encoding.
1051 1134
 		$src_file_osencoded=dol_osencode($src_file);
@@ -1068,11 +1151,12 @@  discard block
 block discarded – undo
1068 1151
 		$return=move_uploaded_file($src_file_osencoded, $file_name_osencoded);
1069 1152
 		if ($return)
1070 1153
 		{
1071
-			if (! empty($conf->global->MAIN_UMASK)) @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK));
1154
+			if (! empty($conf->global->MAIN_UMASK)) {
1155
+				@chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK));
1156
+			}
1072 1157
 			dol_syslog("Files.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=".$conf->global->MAIN_UMASK, LOG_DEBUG);
1073 1158
 			return 1;	// Success
1074
-		}
1075
-		else
1159
+		} else
1076 1160
 		{
1077 1161
 			dol_syslog("Files.lib::dol_move_uploaded_file Failed to move ".$src_file." to ".$file_name, LOG_ERR);
1078 1162
 			return -3;	// Unknown error
@@ -1125,12 +1209,13 @@  discard block
 block discarded – undo
1125 1209
 		$reshook=$hookmanager->executeHooks('deleteFile', $parameters, $object);
1126 1210
 	}
1127 1211
 
1128
-	if (empty($nohook) && $reshook != 0) // reshook = 0 to do standard actions, 1 = ok, -1 = ko
1212
+	if (empty($nohook) && $reshook != 0) {
1213
+		// reshook = 0 to do standard actions, 1 = ok, -1 = ko
1129 1214
 	{
1130 1215
 		if ($reshook < 0) return false;
1131
-		return true;
1132 1216
 	}
1133
-	else
1217
+		return true;
1218
+	} else
1134 1219
 	{
1135 1220
 		$error=0;
1136 1221
 
@@ -1146,17 +1231,22 @@  discard block
 block discarded – undo
1146 1231
 			{
1147 1232
 				foreach ($listofdir as $filename)
1148 1233
 				{
1149
-					if ($nophperrors) $ok=@unlink($filename);
1150
-					else $ok=unlink($filename);
1234
+					if ($nophperrors) {
1235
+						$ok=@unlink($filename);
1236
+					} else {
1237
+						$ok=unlink($filename);
1238
+					}
1151 1239
 					if ($ok)
1152 1240
 					{
1153 1241
 					    dol_syslog("Removed file ".$filename, LOG_DEBUG);
1154 1242
 
1155 1243
 	                    // Delete entry into ecm database
1156 1244
     				    $rel_filetodelete = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filename);
1157
-    				    if (! preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $rel_filetodelete))     // If not a tmp file
1245
+    				    if (! preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $rel_filetodelete)) {
1246
+    				    	// If not a tmp file
1158 1247
     				    {
1159 1248
     				        $rel_filetodelete = preg_replace('/^[\\/]/', '', $rel_filetodelete);
1249
+    				    }
1160 1250
 
1161 1251
     				        dol_syslog("Try to remove also entries in database for full relative path = ".$rel_filetodelete, LOG_DEBUG);
1162 1252
         				    include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
@@ -1171,21 +1261,28 @@  discard block
 block discarded – undo
1171 1261
         				        setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
1172 1262
         				    }
1173 1263
     				    }
1264
+					} else {
1265
+						dol_syslog("Failed to remove file ".$filename, LOG_WARNING);
1174 1266
 					}
1175
-					else dol_syslog("Failed to remove file ".$filename, LOG_WARNING);
1176 1267
 					// TODO Failure to remove can be because file was already removed or because of permission
1177 1268
 					// If error because of not exists, we must should return true and we should return false if this is a permission problem
1178 1269
 				}
1270
+			} else {
1271
+				dol_syslog("No files to delete found", LOG_DEBUG);
1179 1272
 			}
1180
-			else dol_syslog("No files to delete found", LOG_DEBUG);
1181
-		}
1182
-		else
1273
+		} else
1183 1274
 		{
1184 1275
 			$ok=false;
1185
-			if ($nophperrors) $ok=@unlink($file_osencoded);
1186
-			else $ok=unlink($file_osencoded);
1187
-			if ($ok) dol_syslog("Removed file ".$file_osencoded, LOG_DEBUG);
1188
-			else dol_syslog("Failed to remove file ".$file_osencoded, LOG_WARNING);
1276
+			if ($nophperrors) {
1277
+				$ok=@unlink($file_osencoded);
1278
+			} else {
1279
+				$ok=unlink($file_osencoded);
1280
+			}
1281
+			if ($ok) {
1282
+				dol_syslog("Removed file ".$file_osencoded, LOG_DEBUG);
1283
+			} else {
1284
+				dol_syslog("Failed to remove file ".$file_osencoded, LOG_WARNING);
1285
+			}
1189 1286
 		}
1190 1287
 
1191 1288
 		return $ok;
@@ -1235,19 +1332,23 @@  discard block
 block discarded – undo
1235 1332
         {
1236 1333
             while (false !== ($item = readdir($handle)))
1237 1334
             {
1238
-                if (! utf8_check($item)) $item=utf8_encode($item);  // should be useless
1335
+                if (! utf8_check($item)) {
1336
+                	$item=utf8_encode($item);
1337
+                }
1338
+                // should be useless
1239 1339
 
1240 1340
                 if ($item != "." && $item != "..")
1241 1341
                 {
1242 1342
                     if (is_dir(dol_osencode("$dir/$item")) && ! is_link(dol_osencode("$dir/$item")))
1243 1343
                     {
1244 1344
                         $count=dol_delete_dir_recursive("$dir/$item", $count, $nophperrors, 0, $countdeleted);
1245
-                    }
1246
-                    else
1345
+                    } else
1247 1346
                     {
1248 1347
                         $result=dol_delete_file("$dir/$item", 1, $nophperrors);
1249 1348
                         $count++;
1250
-                        if ($result) $countdeleted++;
1349
+                        if ($result) {
1350
+                        	$countdeleted++;
1351
+                        }
1251 1352
                     }
1252 1353
                 }
1253 1354
             }
@@ -1257,7 +1358,9 @@  discard block
 block discarded – undo
1257 1358
             {
1258 1359
 	            $result=dol_delete_dir($dir, $nophperrors);
1259 1360
 	            $count++;
1260
-    	        if ($result) $countdeleted++;
1361
+    	        if ($result) {
1362
+    	        	$countdeleted++;
1363
+    	        }
1261 1364
             }
1262 1365
         }
1263 1366
     }
@@ -1279,15 +1382,25 @@  discard block
 block discarded – undo
1279 1382
 	// Define parent dir of elements
1280 1383
 	$element = $object->element;
1281 1384
 
1282
-    if ($object->element == 'order_supplier')		$dir = $conf->fournisseur->commande->dir_output;
1283
-    elseif ($object->element == 'invoice_supplier')	$dir = $conf->fournisseur->facture->dir_output;
1284
-    elseif ($object->element == 'project')			$dir = $conf->projet->dir_output;
1285
-    elseif ($object->element == 'shipping')			$dir = $conf->expedition->dir_output.'/sending';
1286
-    elseif ($object->element == 'delivery')			$dir = $conf->expedition->dir_output.'/receipt';
1287
-    elseif ($object->element == 'fichinter')		$dir = $conf->ficheinter->dir_output;
1288
-    else $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output;
1385
+    if ($object->element == 'order_supplier') {
1386
+    	$dir = $conf->fournisseur->commande->dir_output;
1387
+    } elseif ($object->element == 'invoice_supplier') {
1388
+    	$dir = $conf->fournisseur->facture->dir_output;
1389
+    } elseif ($object->element == 'project') {
1390
+    	$dir = $conf->projet->dir_output;
1391
+    } elseif ($object->element == 'shipping') {
1392
+    	$dir = $conf->expedition->dir_output.'/sending';
1393
+    } elseif ($object->element == 'delivery') {
1394
+    	$dir = $conf->expedition->dir_output.'/receipt';
1395
+    } elseif ($object->element == 'fichinter') {
1396
+    	$dir = $conf->ficheinter->dir_output;
1397
+    } else {
1398
+    	$dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output;
1399
+    }
1289 1400
 
1290
-    if (empty($dir)) return 'ErrorObjectNoSupportedByFunction';
1401
+    if (empty($dir)) {
1402
+    	return 'ErrorObjectNoSupportedByFunction';
1403
+    }
1291 1404
 
1292 1405
 	$refsan = dol_sanitizeFileName($object->ref);
1293 1406
 	$dir = $dir . "/" . $refsan ;
@@ -1301,8 +1414,7 @@  discard block
 block discarded – undo
1301 1414
 			$object->error=$langs->trans("ErrorFailedToDeleteFile",$file);
1302 1415
 			return 0;
1303 1416
 		}
1304
-	}
1305
-	else
1417
+	} else
1306 1418
 	{
1307 1419
 		for ($i = 0; $i < 20; $i++)
1308 1420
 		{
@@ -1335,18 +1447,29 @@  discard block
 block discarded – undo
1335 1447
 	global $conf;
1336 1448
 
1337 1449
 	// Create meta file
1338
-	if (empty($conf->global->MAIN_DOC_CREATE_METAFILE)) return 0;	// By default, no metafile.
1450
+	if (empty($conf->global->MAIN_DOC_CREATE_METAFILE)) {
1451
+		return 0;
1452
+	}
1453
+	// By default, no metafile.
1339 1454
 
1340 1455
 	// Define parent dir of elements
1341 1456
 	$element=$object->element;
1342 1457
 
1343
-	if ($object->element == 'order_supplier')		$dir = $conf->fournisseur->dir_output.'/commande';
1344
-	elseif ($object->element == 'invoice_supplier')	$dir = $conf->fournisseur->dir_output.'/facture';
1345
-	elseif ($object->element == 'project')			$dir = $conf->projet->dir_output;
1346
-	elseif ($object->element == 'shipping')			$dir = $conf->expedition->dir_output.'/sending';
1347
-	elseif ($object->element == 'delivery')			$dir = $conf->expedition->dir_output.'/receipt';
1348
-	elseif ($object->element == 'fichinter')		$dir = $conf->ficheinter->dir_output;
1349
-	else $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output;
1458
+	if ($object->element == 'order_supplier') {
1459
+		$dir = $conf->fournisseur->dir_output.'/commande';
1460
+	} elseif ($object->element == 'invoice_supplier') {
1461
+		$dir = $conf->fournisseur->dir_output.'/facture';
1462
+	} elseif ($object->element == 'project') {
1463
+		$dir = $conf->projet->dir_output;
1464
+	} elseif ($object->element == 'shipping') {
1465
+		$dir = $conf->expedition->dir_output.'/sending';
1466
+	} elseif ($object->element == 'delivery') {
1467
+		$dir = $conf->expedition->dir_output.'/receipt';
1468
+	} elseif ($object->element == 'fichinter') {
1469
+		$dir = $conf->ficheinter->dir_output;
1470
+	} else {
1471
+		$dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output;
1472
+	}
1350 1473
 
1351 1474
 	if ($dir)
1352 1475
 	{
@@ -1386,12 +1509,12 @@  discard block
 block discarded – undo
1386 1509
 		$fp = fopen($file,"w");
1387 1510
 		fputs($fp,$meta);
1388 1511
 		fclose($fp);
1389
-		if (! empty($conf->global->MAIN_UMASK))
1390
-		@chmod($file, octdec($conf->global->MAIN_UMASK));
1512
+		if (! empty($conf->global->MAIN_UMASK)) {
1513
+				@chmod($file, octdec($conf->global->MAIN_UMASK));
1514
+		}
1391 1515
 
1392 1516
 		return 1;
1393
-	}
1394
-	else
1517
+	} else
1395 1518
 	{
1396 1519
 		dol_syslog('FailedToDetectDirInDolMetaCreateFor'.$object->element, LOG_WARNING);
1397 1520
 	}
@@ -1453,9 +1576,11 @@  discard block
 block discarded – undo
1453 1576
 
1454 1577
 	$res = 0;
1455 1578
 
1456
-	if (! empty($_FILES[$varfiles])) // For view $_FILES[$varfiles]['error']
1579
+	if (! empty($_FILES[$varfiles])) {
1580
+		// For view $_FILES[$varfiles]['error']
1457 1581
 	{
1458 1582
 		dol_syslog('dol_add_file_process upload_dir='.$upload_dir.' allowoverwrite='.$allowoverwrite.' donotupdatesession='.$donotupdatesession.' savingdocmask='.$savingdocmask, LOG_DEBUG);
1583
+	}
1459 1584
 		if (dol_mkdir($upload_dir) >= 0)
1460 1585
 		{
1461 1586
 			$TFile = $_FILES[$varfiles];
@@ -1489,9 +1614,11 @@  discard block
 block discarded – undo
1489 1614
 
1490 1615
 				$resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destfull, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles);
1491 1616
 
1492
-				if (is_numeric($resupload) && $resupload > 0)   // $resupload can be 'ErrorFileAlreadyExists'
1617
+				if (is_numeric($resupload) && $resupload > 0) {
1618
+					// $resupload can be 'ErrorFileAlreadyExists'
1493 1619
 				{
1494 1620
 					global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini;
1621
+				}
1495 1622
 
1496 1623
 					include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
1497 1624
 
@@ -1525,9 +1652,11 @@  discard block
 block discarded – undo
1525 1652
 					{
1526 1653
 					    $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir);
1527 1654
 
1528
-					    if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir))     // If not a tmp dir
1655
+					    if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) {
1656
+					    	// If not a tmp dir
1529 1657
 					    {
1530 1658
 					        $filename = basename($destfile);
1659
+					    }
1531 1660
 					        $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
1532 1661
 					        $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
1533 1662
 
@@ -1550,19 +1679,20 @@  discard block
 block discarded – undo
1550 1679
 
1551 1680
 					$res = 1;
1552 1681
 					setEventMessages($langs->trans("FileTransferComplete"), null, 'mesgs');
1553
-				}
1554
-				else
1682
+				} else
1555 1683
 				{
1556 1684
 					$langs->load("errors");
1557
-					if ($resupload < 0)	// Unknown error
1685
+					if ($resupload < 0) {
1686
+						// Unknown error
1558 1687
 					{
1559 1688
 						setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors');
1560 1689
 					}
1561
-					else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload))	// Files infected by a virus
1690
+					} else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) {
1691
+						// Files infected by a virus
1562 1692
 					{
1563 1693
 						setEventMessages($langs->trans("ErrorFileIsInfectedWithAVirus"), null, 'errors');
1564 1694
 					}
1565
-					else	// Known error
1695
+					} else	// Known error
1566 1696
 					{
1567 1697
 						setEventMessages($langs->trans($resupload), null, 'errors');
1568 1698
 					}
@@ -1585,8 +1715,7 @@  discard block
 block discarded – undo
1585 1715
 		} else {
1586 1716
 			setEventMessages($langs->trans("ErrorFileNotLinked"), null, 'errors');
1587 1717
 		}
1588
-	}
1589
-	else
1718
+	} else
1590 1719
 	{
1591 1720
 		$langs->load("errors");
1592 1721
 		setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("File")), null, 'errors');
@@ -1617,16 +1746,27 @@  discard block
 block discarded – undo
1617 1746
 	$listofnames=array();
1618 1747
 	$listofmimes=array();
1619 1748
     $keytoavoidconflict = empty($trackid)?'':'-'.$trackid;
1620
-	if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
1621
-	if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
1622
-	if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
1749
+	if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) {
1750
+		$listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
1751
+	}
1752
+	if (! empty($_SESSION["listofnames".$keytoavoidconflict])) {
1753
+		$listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
1754
+	}
1755
+	if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) {
1756
+		$listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
1757
+	}
1623 1758
 
1624 1759
 	if ($keytodelete >= 0)
1625 1760
 	{
1626 1761
 		$pathtodelete=$listofpaths[$keytodelete];
1627 1762
 		$filetodelete=$listofnames[$keytodelete];
1628
-		if (empty($donotdeletefile)) $result = dol_delete_file($pathtodelete,1);  // The delete of ecm database is inside the function dol_delete_file
1629
-		else $result=0;
1763
+		if (empty($donotdeletefile)) {
1764
+			$result = dol_delete_file($pathtodelete,1);
1765
+		}
1766
+		// The delete of ecm database is inside the function dol_delete_file
1767
+		else {
1768
+			$result=0;
1769
+		}
1630 1770
 		if ($result >= 0)
1631 1771
 		{
1632 1772
 			if (empty($donotdeletefile))
@@ -1672,24 +1812,26 @@  discard block
 block discarded – undo
1672 1812
 			$ret = $image->setImageFormat($ext);
1673 1813
 			if ($ret)
1674 1814
 			{
1675
-				if (empty($fileoutput)) $fileoutput=$fileinput.".".$ext;
1815
+				if (empty($fileoutput)) {
1816
+					$fileoutput=$fileinput.".".$ext;
1817
+				}
1676 1818
 
1677 1819
 				$count = $image->getNumberImages();
1678 1820
 				$ret = $image->writeImages($fileoutput, true);
1679
-				if ($ret) return $count;
1680
-				else return -3;
1681
-			}
1682
-			else
1821
+				if ($ret) {
1822
+					return $count;
1823
+				} else {
1824
+					return -3;
1825
+				}
1826
+			} else
1683 1827
 			{
1684 1828
 				return -2;
1685 1829
 			}
1686
-		}
1687
-		else
1830
+		} else
1688 1831
 		{
1689 1832
 			return -1;
1690 1833
 		}
1691
-	}
1692
-	else
1834
+	} else
1693 1835
 	{
1694 1836
 		return 0;
1695 1837
 	}
@@ -1711,9 +1853,7 @@  discard block
 block discarded – undo
1711 1853
     try
1712 1854
     {
1713 1855
         $data = implode("", file(dol_osencode($inputfile)));
1714
-        if ($mode == 'gz')     { $foundhandler=1; $compressdata = gzencode($data, 9); }
1715
-        elseif ($mode == 'bz') { $foundhandler=1; $compressdata = bzcompress($data, 9); }
1716
-        elseif ($mode == 'zip')
1856
+        if ($mode == 'gz')     { $foundhandler=1; $compressdata = gzencode($data, 9); } elseif ($mode == 'bz') { $foundhandler=1; $compressdata = bzcompress($data, 9); } elseif ($mode == 'zip')
1717 1857
         {
1718 1858
             if (defined('ODTPHP_PATHTOPCLZIP'))
1719 1859
             {
@@ -1733,14 +1873,12 @@  discard block
 block discarded – undo
1733 1873
             fwrite($fp, $compressdata);
1734 1874
             fclose($fp);
1735 1875
             return 1;
1736
-        }
1737
-        else
1876
+        } else
1738 1877
         {
1739 1878
             dol_syslog("Try to zip with format ".$mode." with no handler for this format",LOG_ERR);
1740 1879
             return -2;
1741 1880
         }
1742
-    }
1743
-    catch (Exception $e)
1881
+    } catch (Exception $e)
1744 1882
     {
1745 1883
         global $langs, $errormsg;
1746 1884
         $langs->load("errors");
@@ -1768,8 +1906,9 @@  discard block
 block discarded – undo
1768 1906
         $archive = new PclZip($inputfile);
1769 1907
         $result=$archive->extract(PCLZIP_OPT_PATH, $outputdir);
1770 1908
         //var_dump($result);
1771
-        if (! is_array($result) && $result <= 0) return array('error'=>$archive->errorInfo(true));
1772
-        else
1909
+        if (! is_array($result) && $result <= 0) {
1910
+        	return array('error'=>$archive->errorInfo(true));
1911
+        } else
1773 1912
 		{
1774 1913
 			$ok=1; $errmsg='';
1775 1914
 			// Loop on each file to check result for unzipping file
@@ -1784,8 +1923,11 @@  discard block
 block discarded – undo
1784 1923
 				}
1785 1924
 			}
1786 1925
 
1787
-			if ($ok) return array();
1788
-			else return array('error'=>$errmsg);
1926
+			if ($ok) {
1927
+				return array();
1928
+			} else {
1929
+				return array('error'=>$errmsg);
1930
+			}
1789 1931
 		}
1790 1932
     }
1791 1933
 
@@ -1799,8 +1941,7 @@  discard block
 block discarded – undo
1799 1941
             $zip->extractTo($outputdir.'/');
1800 1942
             $zip->close();
1801 1943
             return array();
1802
-        }
1803
-        else
1944
+        } else
1804 1945
         {
1805 1946
             return array('error'=>'ErrUnzipFails');
1806 1947
         }
@@ -1834,9 +1975,7 @@  discard block
 block discarded – undo
1834 1975
 
1835 1976
     try
1836 1977
     {
1837
-        if ($mode == 'gz')     { $foundhandler=0; }
1838
-        elseif ($mode == 'bz') { $foundhandler=0; }
1839
-        elseif ($mode == 'zip')
1978
+        if ($mode == 'gz')     { $foundhandler=0; } elseif ($mode == 'bz') { $foundhandler=0; } elseif ($mode == 'zip')
1840 1979
         {
1841 1980
             /*if (defined('ODTPHP_PATHTOPCLZIP'))
1842 1981
             {
@@ -1889,13 +2028,11 @@  discard block
 block discarded – undo
1889 2028
         {
1890 2029
             dol_syslog("Try to zip with format ".$mode." with no handler for this format",LOG_ERR);
1891 2030
             return -2;
1892
-        }
1893
-        else
2031
+        } else
1894 2032
         {
1895 2033
         	return 0;
1896 2034
         }
1897
-    }
1898
-    catch (Exception $e)
2035
+    } catch (Exception $e)
1899 2036
     {
1900 2037
         global $langs, $errormsg;
1901 2038
         $langs->load("errors");
@@ -1941,10 +2078,16 @@  discard block
 block discarded – undo
1941 2078
 	global $user, $conf, $db;
1942 2079
 	global $dolibarr_main_data_root, $dolibarr_main_document_root_alt;
1943 2080
 
1944
-	if (! is_object($fuser)) $fuser=$user;
2081
+	if (! is_object($fuser)) {
2082
+		$fuser=$user;
2083
+	}
1945 2084
 
1946
-	if (empty($modulepart)) return 'ErrorBadParameter';
1947
-	if (empty($entity)) $entity=0;
2085
+	if (empty($modulepart)) {
2086
+		return 'ErrorBadParameter';
2087
+	}
2088
+	if (empty($entity)) {
2089
+		$entity=0;
2090
+	}
1948 2091
 	dol_syslog('modulepart='.$modulepart.' original_file='.$original_file);
1949 2092
 	// We define $accessallowed and $sqlprotectagainstexternals
1950 2093
 	$accessallowed=0;
@@ -1952,7 +2095,9 @@  discard block
 block discarded – undo
1952 2095
 	$ret=array();
1953 2096
 
1954 2097
     // Find the subdirectory name as the reference. For exemple original_file='10/myfile.pdf' -> refname='10'
1955
-	if (empty($refname)) $refname=basename(dirname($original_file)."/");
2098
+	if (empty($refname)) {
2099
+		$refname=basename(dirname($original_file)."/");
2100
+	}
1956 2101
 
1957 2102
 	$relative_original_file = $original_file;
1958 2103
 
@@ -2006,131 +2151,173 @@  discard block
 block discarded – undo
2006 2151
 	// Wrapping pour les apercu factures
2007 2152
 	elseif ($modulepart == 'apercufacture' && !empty($conf->facture->dir_output))
2008 2153
 	{
2009
-		if ($fuser->rights->facture->{$lire}) $accessallowed=1;
2154
+		if ($fuser->rights->facture->{$lire}) {
2155
+			$accessallowed=1;
2156
+		}
2010 2157
 		$original_file=$conf->facture->dir_output.'/'.$original_file;
2011 2158
 	}
2012 2159
 	// Wrapping pour les apercu propal
2013 2160
 	elseif ($modulepart == 'apercupropal' && !empty($conf->propal->dir_output))
2014 2161
 	{
2015
-		if ($fuser->rights->propale->{$lire}) $accessallowed=1;
2162
+		if ($fuser->rights->propale->{$lire}) {
2163
+			$accessallowed=1;
2164
+		}
2016 2165
 		$original_file=$conf->propal->dir_output.'/'.$original_file;
2017 2166
 	}
2018 2167
 	// Wrapping pour les apercu commande
2019 2168
 	elseif ($modulepart == 'apercucommande' && !empty($conf->commande->dir_output))
2020 2169
 	{
2021
-		if ($fuser->rights->commande->{$lire}) $accessallowed=1;
2170
+		if ($fuser->rights->commande->{$lire}) {
2171
+			$accessallowed=1;
2172
+		}
2022 2173
 		$original_file=$conf->commande->dir_output.'/'.$original_file;
2023 2174
 	}
2024 2175
 	// Wrapping pour les apercu intervention
2025 2176
 	elseif (($modulepart == 'apercufichinter' || $modulepart == 'apercuficheinter') && !empty($conf->ficheinter->dir_output))
2026 2177
 	{
2027
-	    if ($fuser->rights->ficheinter->{$lire}) $accessallowed=1;
2178
+	    if ($fuser->rights->ficheinter->{$lire}) {
2179
+	    	$accessallowed=1;
2180
+	    }
2028 2181
 	    $original_file=$conf->ficheinter->dir_output.'/'.$original_file;
2029 2182
 	}
2030 2183
 	// Wrapping pour les apercu conat
2031 2184
 	elseif (($modulepart == 'apercucontract') && !empty($conf->contrat->dir_output))
2032 2185
 	{
2033
-	    if ($fuser->rights->contrat->{$lire}) $accessallowed=1;
2186
+	    if ($fuser->rights->contrat->{$lire}) {
2187
+	    	$accessallowed=1;
2188
+	    }
2034 2189
 	    $original_file=$conf->contrat->dir_output.'/'.$original_file;
2035 2190
 	}
2036 2191
 	// Wrapping pour les apercu supplier proposal
2037 2192
 	elseif (($modulepart == 'apercusupplier_proposal' || $modulepart == 'apercusupplier_proposal') && !empty($conf->supplier_proposal->dir_output))
2038 2193
 	{
2039
-	    if ($fuser->rights->supplier_proposal->{$lire}) $accessallowed=1;
2194
+	    if ($fuser->rights->supplier_proposal->{$lire}) {
2195
+	    	$accessallowed=1;
2196
+	    }
2040 2197
 	    $original_file=$conf->supplier_proposal->dir_output.'/'.$original_file;
2041 2198
 	}
2042 2199
 	// Wrapping pour les apercu supplier order
2043 2200
 	elseif (($modulepart == 'apercusupplier_order' || $modulepart == 'apercusupplier_order') && !empty($conf->fournisseur->commande->dir_output))
2044 2201
 	{
2045
-	    if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed=1;
2202
+	    if ($fuser->rights->fournisseur->commande->{$lire}) {
2203
+	    	$accessallowed=1;
2204
+	    }
2046 2205
 	    $original_file=$conf->fournisseur->commande->dir_output.'/'.$original_file;
2047 2206
 	}
2048 2207
 	// Wrapping pour les apercu supplier invoice
2049 2208
 	elseif (($modulepart == 'apercusupplier_invoice' || $modulepart == 'apercusupplier_invoice') && !empty($conf->fournisseur->facture->dir_output))
2050 2209
 	{
2051
-	    if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed=1;
2210
+	    if ($fuser->rights->fournisseur->facture->{$lire}) {
2211
+	    	$accessallowed=1;
2212
+	    }
2052 2213
 	    $original_file=$conf->fournisseur->facture->dir_output.'/'.$original_file;
2053 2214
 	}
2054 2215
 	// Wrapping pour les apercu supplier invoice
2055 2216
 	elseif (($modulepart == 'apercuexpensereport') && !empty($conf->expensereport->dir_output))
2056 2217
 	{
2057
-	    if ($fuser->rights->expensereport->{$lire}) $accessallowed=1;
2218
+	    if ($fuser->rights->expensereport->{$lire}) {
2219
+	    	$accessallowed=1;
2220
+	    }
2058 2221
 	    $original_file=$conf->expensereport->dir_output.'/'.$original_file;
2059 2222
 	}
2060 2223
 	// Wrapping pour les images des stats propales
2061 2224
 	elseif ($modulepart == 'propalstats' && !empty($conf->propal->dir_temp))
2062 2225
 	{
2063
-		if ($fuser->rights->propale->{$lire}) $accessallowed=1;
2226
+		if ($fuser->rights->propale->{$lire}) {
2227
+			$accessallowed=1;
2228
+		}
2064 2229
 		$original_file=$conf->propal->dir_temp.'/'.$original_file;
2065 2230
 	}
2066 2231
 	// Wrapping pour les images des stats commandes
2067 2232
 	elseif ($modulepart == 'orderstats' && !empty($conf->commande->dir_temp))
2068 2233
 	{
2069
-		if ($fuser->rights->commande->{$lire}) $accessallowed=1;
2234
+		if ($fuser->rights->commande->{$lire}) {
2235
+			$accessallowed=1;
2236
+		}
2070 2237
 		$original_file=$conf->commande->dir_temp.'/'.$original_file;
2071
-	}
2072
-	elseif ($modulepart == 'orderstatssupplier' && !empty($conf->fournisseur->dir_output))
2238
+	} elseif ($modulepart == 'orderstatssupplier' && !empty($conf->fournisseur->dir_output))
2073 2239
 	{
2074
-		if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed=1;
2240
+		if ($fuser->rights->fournisseur->commande->{$lire}) {
2241
+			$accessallowed=1;
2242
+		}
2075 2243
 		$original_file=$conf->fournisseur->commande->dir_temp.'/'.$original_file;
2076 2244
 	}
2077 2245
 	// Wrapping pour les images des stats factures
2078 2246
 	elseif ($modulepart == 'billstats' && !empty($conf->facture->dir_temp))
2079 2247
 	{
2080
-		if ($fuser->rights->facture->{$lire}) $accessallowed=1;
2248
+		if ($fuser->rights->facture->{$lire}) {
2249
+			$accessallowed=1;
2250
+		}
2081 2251
 		$original_file=$conf->facture->dir_temp.'/'.$original_file;
2082
-	}
2083
-	elseif ($modulepart == 'billstatssupplier' && !empty($conf->fournisseur->dir_output))
2252
+	} elseif ($modulepart == 'billstatssupplier' && !empty($conf->fournisseur->dir_output))
2084 2253
 	{
2085
-		if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed=1;
2254
+		if ($fuser->rights->fournisseur->facture->{$lire}) {
2255
+			$accessallowed=1;
2256
+		}
2086 2257
 		$original_file=$conf->fournisseur->facture->dir_temp.'/'.$original_file;
2087 2258
 	}
2088 2259
 	// Wrapping pour les images des stats expeditions
2089 2260
 	elseif ($modulepart == 'expeditionstats' && !empty($conf->expedition->dir_temp))
2090 2261
 	{
2091
-		if ($fuser->rights->expedition->{$lire}) $accessallowed=1;
2262
+		if ($fuser->rights->expedition->{$lire}) {
2263
+			$accessallowed=1;
2264
+		}
2092 2265
 		$original_file=$conf->expedition->dir_temp.'/'.$original_file;
2093 2266
 	}
2094 2267
 	// Wrapping pour les images des stats expeditions
2095 2268
 	elseif ($modulepart == 'tripsexpensesstats' && !empty($conf->deplacement->dir_temp))
2096 2269
 	{
2097
-		if ($fuser->rights->deplacement->{$lire}) $accessallowed=1;
2270
+		if ($fuser->rights->deplacement->{$lire}) {
2271
+			$accessallowed=1;
2272
+		}
2098 2273
 		$original_file=$conf->deplacement->dir_temp.'/'.$original_file;
2099 2274
 	}
2100 2275
 	// Wrapping pour les images des stats expeditions
2101 2276
 	elseif ($modulepart == 'memberstats' && !empty($conf->adherent->dir_temp))
2102 2277
 	{
2103
-		if ($fuser->rights->adherent->{$lire}) $accessallowed=1;
2278
+		if ($fuser->rights->adherent->{$lire}) {
2279
+			$accessallowed=1;
2280
+		}
2104 2281
 		$original_file=$conf->adherent->dir_temp.'/'.$original_file;
2105 2282
 	}
2106 2283
 	// Wrapping pour les images des stats produits
2107 2284
 	elseif (preg_match('/^productstats_/i',$modulepart) && !empty($conf->product->dir_temp))
2108 2285
 	{
2109
-		if ($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) $accessallowed=1;
2286
+		if ($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) {
2287
+			$accessallowed=1;
2288
+		}
2110 2289
 		$original_file=(!empty($conf->product->multidir_temp[$entity])?$conf->product->multidir_temp[$entity]:$conf->service->multidir_temp[$entity]).'/'.$original_file;
2111 2290
 	}
2112 2291
 	// Wrapping for taxes
2113 2292
 	elseif ($modulepart == 'tax' && !empty($conf->tax->dir_output))
2114 2293
 	{
2115
-		if ($fuser->rights->tax->charges->{$lire}) $accessallowed=1;
2294
+		if ($fuser->rights->tax->charges->{$lire}) {
2295
+			$accessallowed=1;
2296
+		}
2116 2297
 		$original_file=$conf->tax->dir_output.'/'.$original_file;
2117 2298
 	}
2118 2299
 	// Wrapping for events
2119 2300
 	elseif ($modulepart == 'actions' && !empty($conf->agenda->dir_output))
2120 2301
 	{
2121
-		if ($fuser->rights->agenda->myactions->{$read}) $accessallowed=1;
2302
+		if ($fuser->rights->agenda->myactions->{$read}) {
2303
+			$accessallowed=1;
2304
+		}
2122 2305
 		$original_file=$conf->agenda->dir_output.'/'.$original_file;
2123 2306
 	}
2124 2307
 	// Wrapping for categories
2125 2308
 	elseif ($modulepart == 'category' && !empty($conf->categorie->dir_output))
2126 2309
 	{
2127
-		if ($fuser->rights->categorie->{$lire}) $accessallowed=1;
2310
+		if ($fuser->rights->categorie->{$lire}) {
2311
+			$accessallowed=1;
2312
+		}
2128 2313
 		$original_file=$conf->categorie->multidir_output[$entity].'/'.$original_file;
2129 2314
 	}
2130 2315
 	// Wrapping pour les prelevements
2131 2316
 	elseif ($modulepart == 'prelevement' && !empty($conf->prelevement->dir_output))
2132 2317
 	{
2133
-		if ($fuser->rights->prelevement->bons->{$lire} || preg_match('/^specimen/i',$original_file)) $accessallowed=1;
2318
+		if ($fuser->rights->prelevement->bons->{$lire} || preg_match('/^specimen/i',$original_file)) {
2319
+			$accessallowed=1;
2320
+		}
2134 2321
 		$original_file=$conf->prelevement->dir_output.'/'.$original_file;
2135 2322
 	}
2136 2323
 	// Wrapping pour les graph energie
@@ -2229,64 +2416,56 @@  discard block
 block discarded – undo
2229 2416
 	        $accessallowed=1;
2230 2417
 	    }
2231 2418
 	    $original_file=$conf->propal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2232
-	}
2233
-	else if ($modulepart == 'massfilesarea_orders')
2419
+	} else if ($modulepart == 'massfilesarea_orders')
2234 2420
 	{
2235 2421
 	    if ($fuser->rights->commande->{$lire} || preg_match('/^specimen/i',$original_file))
2236 2422
 	    {
2237 2423
 	        $accessallowed=1;
2238 2424
 	    }
2239 2425
 	    $original_file=$conf->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2240
-	}
2241
-	else if ($modulepart == 'massfilesarea_invoices')
2426
+	} else if ($modulepart == 'massfilesarea_invoices')
2242 2427
 	{
2243 2428
 	    if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2244 2429
 	    {
2245 2430
 	        $accessallowed=1;
2246 2431
 	    }
2247 2432
 	    $original_file=$conf->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2248
-	}
2249
-	else if ($modulepart == 'massfilesarea_expensereport')
2433
+	} else if ($modulepart == 'massfilesarea_expensereport')
2250 2434
 	{
2251 2435
 	    if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2252 2436
 	    {
2253 2437
 	        $accessallowed=1;
2254 2438
 	    }
2255 2439
 	    $original_file=$conf->expensereport->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2256
-	}
2257
-	else if ($modulepart == 'massfilesarea_interventions')
2440
+	} else if ($modulepart == 'massfilesarea_interventions')
2258 2441
 	{
2259 2442
 	    if ($fuser->rights->ficheinter->{$lire} || preg_match('/^specimen/i',$original_file))
2260 2443
 	    {
2261 2444
 	        $accessallowed=1;
2262 2445
 	    }
2263 2446
 	    $original_file=$conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2264
-	}
2265
-	else if ($modulepart == 'massfilesarea_supplier_proposal' && !empty($conf->propal->dir_output))
2447
+	} else if ($modulepart == 'massfilesarea_supplier_proposal' && !empty($conf->propal->dir_output))
2266 2448
 	{
2267 2449
 	    if ($fuser->rights->supplier_proposal->{$lire} || preg_match('/^specimen/i',$original_file))
2268 2450
 	    {
2269 2451
 	        $accessallowed=1;
2270 2452
 	    }
2271 2453
 	    $original_file=$conf->supplier_proposal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2272
-	}
2273
-	else if ($modulepart == 'massfilesarea_supplier_order')
2454
+	} else if ($modulepart == 'massfilesarea_supplier_order')
2274 2455
 	{
2275 2456
 	    if ($fuser->rights->fournisseur->commande->{$lire} || preg_match('/^specimen/i',$original_file))
2276 2457
 	    {
2277 2458
 	        $accessallowed=1;
2278 2459
 	    }
2279 2460
 	    $original_file=$conf->fournisseur->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2280
-	}
2281
-	else if ($modulepart == 'massfilesarea_supplier_invoice')
2461
+	} else if ($modulepart == 'massfilesarea_supplier_invoice')
2282 2462
 	{
2283 2463
 	    if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2284 2464
 	    {
2285 2465
 	        $accessallowed=1;
2286 2466
 	    }
2287 2467
 	    $original_file=$conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2288
-	}
2289
-	else if ($modulepart == 'massfilesarea_contract' && !empty($conf->contrat->dir_output))
2468
+	} else if ($modulepart == 'massfilesarea_contract' && !empty($conf->contrat->dir_output))
2290 2469
 	{
2291 2470
 		if ($fuser->rights->contrat->{$lire} || preg_match('/^specimen/i',$original_file))
2292 2471
 		{
@@ -2348,8 +2527,7 @@  discard block
 block discarded – undo
2348 2527
 		}
2349 2528
 		$original_file=$conf->projet->dir_output.'/'.$original_file;
2350 2529
 		$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project').")";
2351
-	}
2352
-	else if ($modulepart == 'project_task' && !empty($conf->projet->dir_output))
2530
+	} else if ($modulepart == 'project_task' && !empty($conf->projet->dir_output))
2353 2531
 	{
2354 2532
 		if ($fuser->rights->projet->{$lire} || preg_match('/^specimen/i',$original_file))
2355 2533
 		{
@@ -2398,8 +2576,11 @@  discard block
 block discarded – undo
2398 2576
 		{
2399 2577
 			$accessallowed=1;
2400 2578
 		}
2401
-		if ($fuser->societe_id > 0) $original_file=$conf->facture->dir_output.'/payments/private/'.$fuser->id.'/'.$original_file;
2402
-		else $original_file=$conf->facture->dir_output.'/payments/'.$original_file;
2579
+		if ($fuser->societe_id > 0) {
2580
+			$original_file=$conf->facture->dir_output.'/payments/private/'.$fuser->id.'/'.$original_file;
2581
+		} else {
2582
+			$original_file=$conf->facture->dir_output.'/payments/'.$original_file;
2583
+		}
2403 2584
 	}
2404 2585
 
2405 2586
 	// Wrapping for accounting exports
@@ -2458,8 +2639,11 @@  discard block
 block discarded – undo
2458 2639
 		{
2459 2640
 			$accessallowed=1;
2460 2641
 		}
2461
-		if (! empty($conf->product->enabled)) $original_file=$conf->product->multidir_output[$entity].'/'.$original_file;
2462
-		elseif (! empty($conf->service->enabled)) $original_file=$conf->service->multidir_output[$entity].'/'.$original_file;
2642
+		if (! empty($conf->product->enabled)) {
2643
+			$original_file=$conf->product->multidir_output[$entity].'/'.$original_file;
2644
+		} elseif (! empty($conf->service->enabled)) {
2645
+			$original_file=$conf->service->multidir_output[$entity].'/'.$original_file;
2646
+		}
2463 2647
 	}
2464 2648
 
2465 2649
 	// Wrapping pour les contrats
@@ -2540,14 +2724,18 @@  discard block
 block discarded – undo
2540 2724
 	// Wrapping for backups
2541 2725
 	else if ($modulepart == 'systemtools' && !empty($conf->admin->dir_output))
2542 2726
 	{
2543
-		if ($fuser->admin) $accessallowed=1;
2727
+		if ($fuser->admin) {
2728
+			$accessallowed=1;
2729
+		}
2544 2730
 		$original_file=$conf->admin->dir_output.'/'.$original_file;
2545 2731
 	}
2546 2732
 
2547 2733
 	// Wrapping for upload file test
2548 2734
 	else if ($modulepart == 'admin_temp' && !empty($conf->admin->dir_temp))
2549 2735
 	{
2550
-		if ($fuser->admin) $accessallowed=1;
2736
+		if ($fuser->admin) {
2737
+			$accessallowed=1;
2738
+		}
2551 2739
 		$original_file=$conf->admin->dir_temp.'/'.$original_file;
2552 2740
 	}
2553 2741
 
@@ -2556,7 +2744,9 @@  discard block
 block discarded – undo
2556 2744
 	{
2557 2745
 		$accessallowed=1;
2558 2746
 		$dir='files';
2559
-		if (dol_mimetype($original_file) == 'application/x-bittorrent') $dir='torrents';
2747
+		if (dol_mimetype($original_file) == 'application/x-bittorrent') {
2748
+			$dir='torrents';
2749
+		}
2560 2750
 		$original_file=$conf->bittorrent->dir_output.'/'.$dir.'/'.$original_file;
2561 2751
 	}
2562 2752
 
@@ -2584,45 +2774,62 @@  discard block
 block discarded – undo
2584 2774
     // If modulepart=module				Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart
2585 2775
     else
2586 2776
 	{
2587
-	    if (preg_match('/^specimen/i',$original_file))	$accessallowed=1;    // If link to a file called specimen. Test must be done before changing $original_file int full path.
2588
-	    if ($fuser->admin) $accessallowed=1;    // If user is admin
2777
+	    if (preg_match('/^specimen/i',$original_file)) {
2778
+	    	$accessallowed=1;
2779
+	    }
2780
+	    // If link to a file called specimen. Test must be done before changing $original_file int full path.
2781
+	    if ($fuser->admin) {
2782
+	    	$accessallowed=1;
2783
+	    }
2784
+	    // If user is admin
2589 2785
 
2590 2786
 		// Define $accessallowed
2591 2787
 		if (preg_match('/^([a-z]+)_user_temp$/i',$modulepart,$reg))
2592 2788
 		{
2593
-			if (empty($conf->{$reg[1]}->dir_temp))	// modulepart not supported
2789
+			if (empty($conf->{$reg[1]}->dir_temp)) {
2790
+				// modulepart not supported
2594 2791
 			{
2595 2792
 				dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
2793
+			}
2596 2794
 				exit;
2597 2795
 			}
2598
-		    if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1;
2796
+		    if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) {
2797
+		    	$accessallowed=1;
2798
+		    }
2599 2799
 			$original_file=$conf->{$reg[1]}->dir_temp.'/'.$fuser->id.'/'.$original_file;
2600
-		}
2601
-		else if (preg_match('/^([a-z]+)_temp$/i',$modulepart,$reg))
2800
+		} else if (preg_match('/^([a-z]+)_temp$/i',$modulepart,$reg))
2602 2801
 		{
2603
-			if (empty($conf->{$reg[1]}->dir_temp))	// modulepart not supported
2802
+			if (empty($conf->{$reg[1]}->dir_temp)) {
2803
+				// modulepart not supported
2604 2804
 			{
2605 2805
 				dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
2806
+			}
2606 2807
 				exit;
2607 2808
 			}
2608
-		    if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1;
2809
+		    if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) {
2810
+		    	$accessallowed=1;
2811
+		    }
2609 2812
 			$original_file=$conf->{$reg[1]}->dir_temp.'/'.$original_file;
2610
-		}
2611
-		else if (preg_match('/^([a-z]+)_user$/i',$modulepart,$reg))
2813
+		} else if (preg_match('/^([a-z]+)_user$/i',$modulepart,$reg))
2612 2814
 		{
2613
-			if (empty($conf->{$reg[1]}->dir_output))	// modulepart not supported
2815
+			if (empty($conf->{$reg[1]}->dir_output)) {
2816
+				// modulepart not supported
2614 2817
 			{
2615 2818
 				dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
2819
+			}
2616 2820
 				exit;
2617 2821
 			}
2618
-		    if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1;
2822
+		    if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) {
2823
+		    	$accessallowed=1;
2824
+		    }
2619 2825
 			$original_file=$conf->{$reg[1]}->dir_output.'/'.$fuser->id.'/'.$original_file;
2620
-		}
2621
-		else
2826
+		} else
2622 2827
 		{
2623
-			if (empty($conf->$modulepart->dir_output))	// modulepart not supported
2828
+			if (empty($conf->$modulepart->dir_output)) {
2829
+				// modulepart not supported
2624 2830
 			{
2625 2831
 				dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
2832
+			}
2626 2833
 				exit;
2627 2834
 			}
2628 2835
 
@@ -2630,12 +2837,15 @@  discard block
 block discarded – undo
2630 2837
 			$subperm=GETPOST('subperm');
2631 2838
 			if ($perm || $subperm)
2632 2839
 			{
2633
-				if (($perm && ! $subperm && $fuser->rights->$modulepart->$perm) || ($perm && $subperm && $fuser->rights->$modulepart->$perm->$subperm)) $accessallowed=1;
2840
+				if (($perm && ! $subperm && $fuser->rights->$modulepart->$perm) || ($perm && $subperm && $fuser->rights->$modulepart->$perm->$subperm)) {
2841
+					$accessallowed=1;
2842
+				}
2634 2843
 				$original_file=$conf->$modulepart->dir_output.'/'.$original_file;
2635
-			}
2636
-			else
2844
+			} else
2637 2845
 			{
2638
-				if ($fuser->rights->$modulepart->{$lire} || $fuser->rights->$modulepart->{$read}) $accessallowed=1;
2846
+				if ($fuser->rights->$modulepart->{$lire} || $fuser->rights->$modulepart->{$read}) {
2847
+					$accessallowed=1;
2848
+				}
2639 2849
 				$original_file=$conf->$modulepart->dir_output.'/'.$original_file;
2640 2850
 			}
2641 2851
 		}
@@ -2653,11 +2863,13 @@  discard block
 block discarded – undo
2653 2863
 
2654 2864
 		// Define $sqlprotectagainstexternals for modules who want to protect access using a SQL query.
2655 2865
 		$sqlProtectConstName = strtoupper($modulepart).'_SQLPROTECTAGAINSTEXTERNALS_FOR_DOCUMENTS';
2656
-		if (! empty($conf->global->$sqlProtectConstName))	// If module want to define its own $sqlprotectagainstexternals
2866
+		if (! empty($conf->global->$sqlProtectConstName)) {
2867
+			// If module want to define its own $sqlprotectagainstexternals
2657 2868
 		{
2658 2869
 			// Example: mymodule__SQLPROTECTAGAINSTEXTERNALS_FOR_DOCUMENTS = "SELECT fk_soc FROM ".MAIN_DB_PREFIX.$modulepart." WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
2659 2870
 			eval('$sqlprotectagainstexternals = "'.$conf->global->$sqlProtectConstName.'";');
2660 2871
 		}
2872
+		}
2661 2873
 	}
2662 2874
 
2663 2875
 	$ret = array(
@@ -2679,7 +2891,9 @@  discard block
 block discarded – undo
2679 2891
  */
2680 2892
 function dol_filecache($directory, $filename, $object)
2681 2893
 {
2682
-    if (! dol_is_dir($directory)) dol_mkdir($directory);
2894
+    if (! dol_is_dir($directory)) {
2895
+    	dol_mkdir($directory);
2896
+    }
2683 2897
     $cachefile = $directory . $filename;
2684 2898
     file_put_contents($cachefile, serialize($object), LOCK_EX);
2685 2899
     @chmod($cachefile, 0644);
Please login to merge, or discard this patch.
htdocs/core/lib/project.lib.php 2 patches
Indentation   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	$head[$h][2] = 'project';
45 45
 	$h++;
46 46
 
47
-    $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
47
+	$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
48 48
 	$head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$object->id;
49 49
 	$head[$h][1] = $langs->trans("ProjectContact");
50 50
 	if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
@@ -69,22 +69,22 @@  discard block
 block discarded – undo
69 69
 
70 70
 
71 71
 	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
72
-    {
73
-    	$nbNote = 0;
74
-        if(!empty($object->note_private)) $nbNote++;
72
+	{
73
+		$nbNote = 0;
74
+		if(!empty($object->note_private)) $nbNote++;
75 75
 		if(!empty($object->note_public)) $nbNote++;
76 76
 		$head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id;
77 77
 		$head[$h][1] = $langs->trans('Notes');
78 78
 		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
79 79
 		$head[$h][2] = 'notes';
80 80
 		$h++;
81
-    }
81
+	}
82 82
 
83 83
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
84
-    require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
84
+	require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
85 85
 	$upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
86 86
 	$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
87
-    $nbLinks=Link::count($db, $object->element, $object->id);
87
+	$nbLinks=Link::count($db, $object->element, $object->id);
88 88
 	$head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id;
89 89
 	$head[$h][1] = $langs->trans('Documents');
90 90
 	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
 	}
124 124
 
125 125
 	$head[$h][0] = DOL_URL_ROOT.'/projet/info.php?id='.$object->id;
126
-    $head[$h][1].= $langs->trans("Events");
127
-    if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
128
-    {
129
-        $head[$h][1].= '/';
130
-        $head[$h][1].= $langs->trans("Agenda");
131
-    }
126
+	$head[$h][1].= $langs->trans("Events");
127
+	if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
128
+	{
129
+		$head[$h][1].= '/';
130
+		$head[$h][1].= $langs->trans("Agenda");
131
+	}
132 132
 	$head[$h][2] = 'agenda';
133 133
 	$h++;
134 134
 
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	$resql = $db->query($sql);
172 172
 	if ($resql)
173 173
 	{
174
-	    $obj = $db->fetch_object($resql);
175
-	    if ($obj) $nbTimeSpent=1;
174
+		$obj = $db->fetch_object($resql);
175
+		if ($obj) $nbTimeSpent=1;
176 176
 	}
177 177
 	else dol_print_error($db);
178 178
 
@@ -189,23 +189,23 @@  discard block
 block discarded – undo
189 189
 	complete_head_from_modules($conf,$langs,$object,$head,$h,'task');
190 190
 
191 191
 	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
192
-    {
193
-    	$nbNote = 0;
194
-        if(!empty($object->note_private)) $nbNote++;
192
+	{
193
+		$nbNote = 0;
194
+		if(!empty($object->note_private)) $nbNote++;
195 195
 		if(!empty($object->note_public)) $nbNote++;
196 196
 		$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
197 197
 		$head[$h][1] = $langs->trans('Notes');
198 198
 		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
199 199
 		$head[$h][2] = 'task_notes';
200 200
 		$h++;
201
-    }
201
+	}
202 202
 
203 203
 	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
204 204
 	$filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->project->ref) . '/' .dol_sanitizeFileName($object->ref);
205 205
 	include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
206 206
 	include_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
207 207
 	$nbFiles = count(dol_dir_list($filesdir,'files',0,'','(\.meta|_preview.*\.png)$'));
208
-    $nbLinks=Link::count($db, $object->element, $object->id);
208
+	$nbLinks=Link::count($db, $object->element, $object->id);
209 209
 	$head[$h][1] = $langs->trans('Documents');
210 210
 	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
211 211
 	$head[$h][2] = 'task_document';
@@ -467,11 +467,11 @@  discard block
 block discarded – undo
467 467
 				// Date end
468 468
 				print '<td align="center">';
469 469
 				$taskstatic->projectstatus = $lines[$i]->projectstatus;
470
-	            $taskstatic->progress = $lines[$i]->progress;
471
-	            $taskstatic->fk_statut = $lines[$i]->status;
472
-	            $taskstatic->datee = $lines[$i]->date_end;
473
-	            print dol_print_date($lines[$i]->date_end,'dayhour');
474
-	            if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late"));
470
+				$taskstatic->progress = $lines[$i]->progress;
471
+				$taskstatic->fk_statut = $lines[$i]->status;
472
+				$taskstatic->datee = $lines[$i]->date_end;
473
+				print dol_print_date($lines[$i]->date_end,'dayhour');
474
+				if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late"));
475 475
 				print '</td>';
476 476
 
477 477
 				$plannedworkloadoutputformat='allhourmin';
@@ -531,9 +531,9 @@  discard block
 block discarded – undo
531 531
 
532 532
 				if ($level >= 0)    // Call sublevels
533 533
 				{
534
-    				$level++;
535
-    				if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick);
536
-    				$level--;
534
+					$level++;
535
+					if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick);
536
+					$level--;
537 537
 				}
538 538
 
539 539
 				$total_projectlinesa_spent += $lines[$i]->duration;
@@ -605,13 +605,13 @@  discard block
 block discarded – undo
605 605
 	// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
606 606
 	if ($parent == 0) // Always and only if at first level
607 607
 	{
608
-	    for ($i = 0 ; $i < $numlines ; $i++)
609
-	    {
610
-	        if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
611
-	    }
608
+		for ($i = 0 ; $i < $numlines ; $i++)
609
+		{
610
+			if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
611
+		}
612 612
 	}
613 613
 
614
-    //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
614
+	//dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
615 615
 	for ($i = 0 ; $i < $numlines ; $i++)
616 616
 	{
617 617
 		if ($parent == 0) $level = 0;
@@ -621,26 +621,26 @@  discard block
 block discarded – undo
621 621
 			// If we want all or we have a role on task, we show it
622 622
 			if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
623 623
 			{
624
-                //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
624
+				//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
625 625
 
626 626
 				// Break on a new project
627
-        		if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
628
-        		{
629
-        			$lastprojectid=$lines[$i]->fk_project;
630
-        			if ($preselectedday)
631
-        			{
632
-        				$projectstatic->id = $lines[$i]->fk_project;
633
-        			}
634
-        		}
635
-
636
-			    if (empty($workloadforid[$projectstatic->id]))
637
-			    {
638
-    				if ($preselectedday)
639
-    				{
640
-    			        $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id);	// Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
641
-	       		        $workloadforid[$projectstatic->id]=1;
642
-    				}
643
-			    }
627
+				if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
628
+				{
629
+					$lastprojectid=$lines[$i]->fk_project;
630
+					if ($preselectedday)
631
+					{
632
+						$projectstatic->id = $lines[$i]->fk_project;
633
+					}
634
+				}
635
+
636
+				if (empty($workloadforid[$projectstatic->id]))
637
+				{
638
+					if ($preselectedday)
639
+					{
640
+						$projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id);	// Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
641
+		   				$workloadforid[$projectstatic->id]=1;
642
+					}
643
+				}
644 644
 
645 645
 				$projectstatic->id=$lines[$i]->fk_project;
646 646
 				$projectstatic->ref=$lines[$i]->projectref;
@@ -665,12 +665,12 @@  discard block
 block discarded – undo
665 665
 
666 666
 				if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY))
667 667
 				{
668
-				    // Thirdparty
669
-				    print '<td class="tdoverflowmax100">';
670
-				    $thirdpartystatic->id=$lines[$i]->socid;
671
-				    $thirdpartystatic->name=$lines[$i]->thirdparty_name;
672
-				    print $thirdpartystatic->getNomUrl(1, 'project', 10);
673
-				    print '</td>';
668
+					// Thirdparty
669
+					print '<td class="tdoverflowmax100">';
670
+					$thirdpartystatic->id=$lines[$i]->socid;
671
+					$thirdpartystatic->name=$lines[$i]->thirdparty_name;
672
+					print $thirdpartystatic->getNomUrl(1, 'project', 10);
673
+					print '</td>';
674 674
 				}
675 675
 
676 676
 				// Ref
@@ -753,14 +753,14 @@  discard block
 block discarded – undo
753 753
 				print '<td align="center" class="duration'.($cssonholiday?' '.$cssonholiday:'').'">';
754 754
 
755 755
 				$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
756
-		        $alreadyspent='';
757
-		        if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
756
+				$alreadyspent='';
757
+				if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
758 758
 
759
-		        $idw = 0;
759
+				$idw = 0;
760 760
 
761 761
 				$tableCell='';
762 762
 				$tableCell.='<span class="timesheetalreadyrecorded"><input type="text" class="center" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
763
-                $tableCell.='<span class="hideonsmartphone"> + </span>';
763
+				$tableCell.='<span class="hideonsmartphone"> + </span>';
764 764
 				//$tableCell.='&nbsp;&nbsp;&nbsp;';
765 765
 				$tableCell.=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1);
766 766
 				//$tableCell.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled':'').' value="'.$langs->trans("Add").'">';
@@ -800,8 +800,8 @@  discard block
 block discarded – undo
800 800
 			$level++;
801 801
 			if ($lines[$i]->id > 0)
802 802
 			{
803
-			    if ($parent == 0) projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable);
804
-			    else projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable);
803
+				if ($parent == 0) projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable);
804
+				else projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable);
805 805
 			}
806 806
 			$level--;
807 807
 		}
@@ -845,13 +845,13 @@  discard block
 block discarded – undo
845 845
 	// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
846 846
 	if ($parent == 0) // Always and only if at first level
847 847
 	{
848
-	    for ($i = 0 ; $i < $numlines ; $i++)
849
-	    {
850
-	       if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
851
-	    }
848
+		for ($i = 0 ; $i < $numlines ; $i++)
849
+		{
850
+		   if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
851
+		}
852 852
 	}
853 853
 
854
-    //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
854
+	//dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
855 855
 
856 856
 	for ($i = 0 ; $i < $numlines ; $i++)
857 857
 	{
@@ -862,20 +862,20 @@  discard block
 block discarded – undo
862 862
 			// If we want all or we have a role on task, we show it
863 863
 			if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
864 864
 			{
865
-			    //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
865
+				//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
866 866
 
867
-			    // Break on a new project
868
-    			if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
869
-    			{
870
-    				$lastprojectid=$lines[$i]->fk_project;
871
-    				$projectstatic->id = $lines[$i]->fk_project;
872
-    			}
867
+				// Break on a new project
868
+				if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
869
+				{
870
+					$lastprojectid=$lines[$i]->fk_project;
871
+					$projectstatic->id = $lines[$i]->fk_project;
872
+				}
873 873
 
874
-			    if (empty($workloadforid[$projectstatic->id]))
875
-			    {
876
-				    $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id);	// Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
877
-                    $workloadforid[$projectstatic->id]=1;
878
-			    }
874
+				if (empty($workloadforid[$projectstatic->id]))
875
+				{
876
+					$projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id);	// Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
877
+					$workloadforid[$projectstatic->id]=1;
878
+				}
879 879
 
880 880
 				$projectstatic->id=$lines[$i]->fk_project;
881 881
 				$projectstatic->ref=$lines[$i]->projectref;
@@ -899,12 +899,12 @@  discard block
 block discarded – undo
899 899
 
900 900
 				if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY))
901 901
 				{
902
-				    // Thirdparty
903
-				    print '<td class="tdoverflowmax100">';
904
-				    $thirdpartystatic->id=$lines[$i]->thirdparty_id;
905
-				    $thirdpartystatic->name=$lines[$i]->thirdparty_name;
906
-				    print $thirdpartystatic->getNomUrl(1, 'project');
907
-				    print '</td>';
902
+					// Thirdparty
903
+					print '<td class="tdoverflowmax100">';
904
+					$thirdpartystatic->id=$lines[$i]->thirdparty_id;
905
+					$thirdpartystatic->name=$lines[$i]->thirdparty_name;
906
+					print $thirdpartystatic->getNomUrl(1, 'project');
907
+					print '</td>';
908 908
 				}
909 909
 
910 910
 				// Ref
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 				// Fields to show current time
980 980
 				$tableCell=''; $modeinput='hours';
981 981
 				for ($idw = 0; $idw < 7; $idw++)
982
-		        {
982
+				{
983 983
 					$tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd');
984 984
 
985 985
 					$cssonholiday='';
@@ -988,28 +988,28 @@  discard block
 block discarded – undo
988 988
 					elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon ';
989 989
 
990 990
 					$tmparray=dol_getdate($tmpday);
991
-		        	$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id];
992
-		        	$alreadyspent='';
993
-		        	if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
994
-                    $alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']);
995
-
996
-                    $tableCell ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').'">';
997
-                    if ($alreadyspent)
998
-                    {
999
-                        $tableCell.='<span class="timesheetalreadyrecorded"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
1000
-                        //$placeholder=' placeholder="00:00"';
1001
-                        $placeholder='';
1002
-                     	//$tableCell.='+';
1003
-                    }
1004
-                  	$tableCell.='<input type="text" alt="'.($disabledtask?'':$alttitle).'" title="'.($disabledtask?'':$alttitle).'" '.($disabledtask?'disabled':$placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2"  maxlength="5"';
1005
-	        		$tableCell.=' onkeypress="return regexEvent(this,event,\'timeChar\')"';
1006
-                   	$tableCell.=' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"';
1007
-                   	$tableCell.=' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />';
1008
-                   	$tableCell.='</td>';
1009
-                    print $tableCell;
1010
-		        }
1011
-
1012
-		        // Warning
991
+					$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id];
992
+					$alreadyspent='';
993
+					if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
994
+					$alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']);
995
+
996
+					$tableCell ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').'">';
997
+					if ($alreadyspent)
998
+					{
999
+						$tableCell.='<span class="timesheetalreadyrecorded"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
1000
+						//$placeholder=' placeholder="00:00"';
1001
+						$placeholder='';
1002
+					 	//$tableCell.='+';
1003
+					}
1004
+				  	$tableCell.='<input type="text" alt="'.($disabledtask?'':$alttitle).'" title="'.($disabledtask?'':$alttitle).'" '.($disabledtask?'disabled':$placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2"  maxlength="5"';
1005
+					$tableCell.=' onkeypress="return regexEvent(this,event,\'timeChar\')"';
1006
+				   	$tableCell.=' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"';
1007
+				   	$tableCell.=' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />';
1008
+				   	$tableCell.='</td>';
1009
+					print $tableCell;
1010
+				}
1011
+
1012
+				// Warning
1013 1013
 				print '<td align="right">';
1014 1014
    				if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
1015 1015
    				else if ($disabledtask)
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
    				}
1022 1022
 				print '</td>';
1023 1023
 
1024
-		        print "</tr>\n";
1024
+				print "</tr>\n";
1025 1025
 			}
1026 1026
 
1027 1027
 			// Call to show task with a lower level (task under the current task)
@@ -1029,8 +1029,8 @@  discard block
 block discarded – undo
1029 1029
 			$level++;
1030 1030
 			if ($lines[$i]->id > 0)
1031 1031
 			{
1032
-			    if ($parent == 0) projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable);
1033
-			    else projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable);
1032
+				if ($parent == 0) projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable);
1033
+				else projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable);
1034 1034
 			}
1035 1035
 			$level--;
1036 1036
 		}
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 	require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
1101 1101
 
1102 1102
 	$projectstatic=new Project($db);
1103
-    $thirdpartystatic=new Societe($db);
1103
+	$thirdpartystatic=new Societe($db);
1104 1104
 
1105 1105
 	$sortfield='';
1106 1106
 	$sortorder='';
@@ -1161,12 +1161,12 @@  discard block
 block discarded – undo
1161 1161
 	$resql = $db->query($sql1);
1162 1162
 	if ($resql)
1163 1163
 	{
1164
-	    $i=0;
1164
+		$i=0;
1165 1165
 		$num = $db->num_rows($resql);
1166 1166
 		while ($i < $num)
1167 1167
 		{
1168 1168
 			$objp = $db->fetch_object($resql);
1169
-            $arrayidofprojects[$objp->projectid]=$objp->projectid;
1169
+			$arrayidofprojects[$objp->projectid]=$objp->projectid;
1170 1170
 			$i++;
1171 1171
 		}
1172 1172
 	}
@@ -1194,22 +1194,22 @@  discard block
 block discarded – undo
1194 1194
 		$num = $db->num_rows($resql);
1195 1195
 		$i = 0;
1196 1196
 
1197
-    	print '<tr class="liste_titre">';
1198
-    	print_liste_field_titre($title.' <span class="badge">'.$num.'</span>',$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
1199
-    	print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
1200
-    	if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1201
-    	{
1202
-    		print_liste_field_titre("OpportunityAmount","","","","",'align="right"',$sortfield,$sortorder);
1203
-    		print_liste_field_titre("OpportunityStatus","","","","",'align="right"',$sortfield,$sortorder);
1204
-    	}
1205
-    	if (empty($conf->global->PROJECT_HIDE_TASKS))
1206
-    	{
1207
-            print_liste_field_titre("Tasks","","","","",'align="right"',$sortfield,$sortorder);
1208
-            if (! in_array('plannedworkload', $hiddenfields))  print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder);
1209
-            if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder);
1210
-    	}
1211
-    	print_liste_field_titre("Status","","","","",'align="right"',$sortfield,$sortorder);
1212
-    	print "</tr>\n";
1197
+		print '<tr class="liste_titre">';
1198
+		print_liste_field_titre($title.' <span class="badge">'.$num.'</span>',$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
1199
+		print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
1200
+		if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1201
+		{
1202
+			print_liste_field_titre("OpportunityAmount","","","","",'align="right"',$sortfield,$sortorder);
1203
+			print_liste_field_titre("OpportunityStatus","","","","",'align="right"',$sortfield,$sortorder);
1204
+		}
1205
+		if (empty($conf->global->PROJECT_HIDE_TASKS))
1206
+		{
1207
+			print_liste_field_titre("Tasks","","","","",'align="right"',$sortfield,$sortorder);
1208
+			if (! in_array('plannedworkload', $hiddenfields))  print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder);
1209
+			if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder);
1210
+		}
1211
+		print_liste_field_titre("Status","","","","",'align="right"',$sortfield,$sortorder);
1212
+		print "</tr>\n";
1213 1213
 
1214 1214
 		while ($i < $num)
1215 1215
 		{
@@ -1223,11 +1223,11 @@  discard block
 block discarded – undo
1223 1223
 			$userAccess = $projectstatic->restrictedProjectArea($user);
1224 1224
 			if ($userAccess >= 0)
1225 1225
 			{
1226
-			    $projectstatic->ref=$objp->ref;
1227
-			    $projectstatic->statut = $objp->status;
1228
-			    $projectstatic->title = $objp->title;
1229
-			    $projectstatic->datee = $db->jdate($objp->datee);
1230
-			    $projectstatic->dateo = $db->jdate($objp->dateo);
1226
+				$projectstatic->ref=$objp->ref;
1227
+				$projectstatic->statut = $objp->status;
1228
+				$projectstatic->title = $objp->title;
1229
+				$projectstatic->datee = $db->jdate($objp->datee);
1230
+				$projectstatic->dateo = $db->jdate($objp->dateo);
1231 1231
 
1232 1232
 
1233 1233
 				print '<tr class="oddeven">';
@@ -1238,41 +1238,41 @@  discard block
 block discarded – undo
1238 1238
 				print '<td>';
1239 1239
 				if ($objp->fk_soc > 0)
1240 1240
 				{
1241
-    				$thirdpartystatic->id=$objp->fk_soc;
1242
-    				$thirdpartystatic->ref=$objp->socname;
1243
-    				$thirdpartystatic->name=$objp->socname;
1244
-    				print $thirdpartystatic->getNomUrl(1);
1241
+					$thirdpartystatic->id=$objp->fk_soc;
1242
+					$thirdpartystatic->ref=$objp->socname;
1243
+					$thirdpartystatic->name=$objp->socname;
1244
+					print $thirdpartystatic->getNomUrl(1);
1245 1245
 				}
1246 1246
 				print '</td>';
1247 1247
 				if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1248 1248
 				{
1249 1249
 					print '<td align="right">';
1250
-        			if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency);
1250
+					if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency);
1251 1251
 					print '</td>';
1252 1252
 					print '<td align="right">';
1253 1253
 					$code = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code');
1254
-        			if ($code) print $langs->trans("OppStatus".$code);
1254
+					if ($code) print $langs->trans("OppStatus".$code);
1255 1255
 					print '</td>';
1256 1256
 				}
1257 1257
 				if (empty($conf->global->PROJECT_HIDE_TASKS))
1258 1258
 				{
1259
-				    print '<td align="right">'.$objp->nb.'</td>';
1260
-
1261
-    				$plannedworkload=$objp->planned_workload;
1262
-    				$total_plannedworkload+=$plannedworkload;
1263
-    				if (! in_array('plannedworkload', $hiddenfields))
1264
-    				{
1265
-    				    print '<td align="right">'.($plannedworkload?convertSecondToTime($plannedworkload):'').'</td>';
1266
-    				}
1267
-    				if (! in_array('declaredprogress', $hiddenfields))
1268
-    				{
1269
-    				    $declaredprogressworkload=$objp->declared_progess_workload;
1270
-        				$total_declaredprogressworkload+=$declaredprogressworkload;
1271
-        				print '<td align="right">';
1272
-        				//print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>";
1273
-        				print ($plannedworkload?round(100*$declaredprogressworkload/$plannedworkload,0).'%':'');
1274
-        				print '</td>';
1275
-    				}
1259
+					print '<td align="right">'.$objp->nb.'</td>';
1260
+
1261
+					$plannedworkload=$objp->planned_workload;
1262
+					$total_plannedworkload+=$plannedworkload;
1263
+					if (! in_array('plannedworkload', $hiddenfields))
1264
+					{
1265
+						print '<td align="right">'.($plannedworkload?convertSecondToTime($plannedworkload):'').'</td>';
1266
+					}
1267
+					if (! in_array('declaredprogress', $hiddenfields))
1268
+					{
1269
+						$declaredprogressworkload=$objp->declared_progess_workload;
1270
+						$total_declaredprogressworkload+=$declaredprogressworkload;
1271
+						print '<td align="right">';
1272
+						//print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>";
1273
+						print ($plannedworkload?round(100*$declaredprogressworkload/$plannedworkload,0).'%':'');
1274
+						print '</td>';
1275
+					}
1276 1276
 				}
1277 1277
 
1278 1278
 				print '<td align="right">'.$projectstatic->getLibStatut(3).'</td>';
@@ -1295,12 +1295,12 @@  discard block
 block discarded – undo
1295 1295
 		}
1296 1296
 		if (empty($conf->global->PROJECT_HIDE_TASKS))
1297 1297
 		{
1298
-            print '<td class="liste_total" align="right">'.$total_task.'</td>';
1299
-            if (! in_array('plannedworkload', $hiddenfields))  print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>';
1300
-            if (! in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>';
1298
+			print '<td class="liste_total" align="right">'.$total_task.'</td>';
1299
+			if (! in_array('plannedworkload', $hiddenfields))  print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>';
1300
+			if (! in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>';
1301 1301
 		}
1302 1302
 		print '<td class="liste_total"></td>';
1303
-        print '</tr>';
1303
+		print '</tr>';
1304 1304
 
1305 1305
 		$db->free($resql);
1306 1306
 	}
Please login to merge, or discard this patch.
Spacing   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
 	$head[$h][2] = 'project';
45 45
 	$h++;
46 46
 
47
-    $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
47
+    $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
48 48
 	$head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$object->id;
49 49
 	$head[$h][1] = $langs->trans("ProjectContact");
50
-	if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
50
+	if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>';
51 51
 	$head[$h][2] = 'contact';
52 52
 	$h++;
53 53
 
54
-	if (! empty($conf->fournisseur->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled)
55
-	|| ! empty($conf->facture->enabled) || ! empty($conf->contrat->enabled)
56
-	|| ! empty($conf->ficheinter->enabled) || ! empty($conf->agenda->enabled) || ! empty($conf->deplacement->enabled))
54
+	if (!empty($conf->fournisseur->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled)
55
+	|| !empty($conf->facture->enabled) || !empty($conf->contrat->enabled)
56
+	|| !empty($conf->ficheinter->enabled) || !empty($conf->agenda->enabled) || !empty($conf->deplacement->enabled))
57 57
 	{
58 58
 		$head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$object->id;
59 59
 		$head[$h][1] = $langs->trans("ProjectOverview");
@@ -65,29 +65,29 @@  discard block
 block discarded – undo
65 65
 	// Entries must be declared in modules descriptor with line
66 66
 	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
67 67
 	// $this->tabs = array('entity:-tabname);   												to remove a tab
68
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'project');
68
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'project');
69 69
 
70 70
 
71 71
 	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
72 72
     {
73 73
     	$nbNote = 0;
74
-        if(!empty($object->note_private)) $nbNote++;
75
-		if(!empty($object->note_public)) $nbNote++;
74
+        if (!empty($object->note_private)) $nbNote++;
75
+		if (!empty($object->note_public)) $nbNote++;
76 76
 		$head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id;
77 77
 		$head[$h][1] = $langs->trans('Notes');
78
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
78
+		if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>';
79 79
 		$head[$h][2] = 'notes';
80 80
 		$h++;
81 81
     }
82 82
 
83 83
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
84 84
     require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
85
-	$upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
86
-	$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
87
-    $nbLinks=Link::count($db, $object->element, $object->id);
85
+	$upload_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($object->ref);
86
+	$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
87
+    $nbLinks = Link::count($db, $object->element, $object->id);
88 88
 	$head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id;
89 89
 	$head[$h][1] = $langs->trans('Documents');
90
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
90
+	if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>';
91 91
 	$head[$h][2] = 'document';
92 92
 	$h++;
93 93
 
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
 		$head[$h][1] = $langs->trans("Tasks");
99 99
 
100 100
 		require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
101
-		$taskstatic=new Task($db);
102
-		$nbTasks=count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0));
103
-		if ($nbTasks > 0) $head[$h][1].= ' <span class="badge">'.($nbTasks).'</span>';
101
+		$taskstatic = new Task($db);
102
+		$nbTasks = count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0));
103
+		if ($nbTasks > 0) $head[$h][1] .= ' <span class="badge">'.($nbTasks).'</span>';
104 104
 		$head[$h][2] = 'tasks';
105 105
 		$h++;
106 106
 
107 107
 		$head[$h][0] = DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id;
108 108
 		$head[$h][1] = $langs->trans("Gantt");
109
-		if ($nbTasks > 0) $head[$h][1].= ' <span class="badge">'.($nbTasks).'</span>';
109
+		if ($nbTasks > 0) $head[$h][1] .= ' <span class="badge">'.($nbTasks).'</span>';
110 110
 		$head[$h][2] = 'gantt';
111 111
 		$h++;
112 112
 	}
@@ -117,22 +117,22 @@  discard block
 block discarded – undo
117 117
 		$nbComments = $object->getNbComments();
118 118
 		$head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$object->id;
119 119
 		$head[$h][1] = $langs->trans("CommentLink");
120
-		if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>';
120
+		if ($nbComments > 0) $head[$h][1] .= ' <span class="badge">'.$nbComments.'</span>';
121 121
 		$head[$h][2] = 'project_comment';
122 122
 		$h++;
123 123
 	}
124 124
 
125 125
 	$head[$h][0] = DOL_URL_ROOT.'/projet/info.php?id='.$object->id;
126
-    $head[$h][1].= $langs->trans("Events");
127
-    if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
126
+    $head[$h][1] .= $langs->trans("Events");
127
+    if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
128 128
     {
129
-        $head[$h][1].= '/';
130
-        $head[$h][1].= $langs->trans("Agenda");
129
+        $head[$h][1] .= '/';
130
+        $head[$h][1] .= $langs->trans("Agenda");
131 131
     }
132 132
 	$head[$h][2] = 'agenda';
133 133
 	$h++;
134 134
 
135
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'project','remove');
135
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'project', 'remove');
136 136
 
137 137
 	return $head;
138 138
 }
@@ -150,20 +150,20 @@  discard block
 block discarded – undo
150 150
 	$h = 0;
151 151
 	$head = array();
152 152
 
153
-	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
153
+	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
154 154
 	$head[$h][1] = $langs->trans("Card");
155 155
 	$head[$h][2] = 'task_task';
156 156
 	$h++;
157 157
 
158
-	$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
159
-	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
158
+	$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
159
+	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
160 160
 	$head[$h][1] = $langs->trans("TaskRessourceLinks");
161
-	if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
161
+	if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>';
162 162
 	$head[$h][2] = 'task_contact';
163 163
 	$h++;
164 164
 
165 165
 	// Is there timespent ?
166
-	$nbTimeSpent=0;
166
+	$nbTimeSpent = 0;
167 167
 	$sql = "SELECT t.rowid";
168 168
 	$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u";
169 169
 	$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid";
@@ -172,13 +172,13 @@  discard block
 block discarded – undo
172 172
 	if ($resql)
173 173
 	{
174 174
 	    $obj = $db->fetch_object($resql);
175
-	    if ($obj) $nbTimeSpent=1;
175
+	    if ($obj) $nbTimeSpent = 1;
176 176
 	}
177 177
 	else dol_print_error($db);
178 178
 
179
-	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
179
+	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
180 180
 	$head[$h][1] = $langs->trans("TimeSpent");
181
-	if ($nbTimeSpent > 0) $head[$h][1].= ' <span class="badge">...</span>';
181
+	if ($nbTimeSpent > 0) $head[$h][1] .= ' <span class="badge">...</span>';
182 182
 	$head[$h][2] = 'task_time';
183 183
 	$h++;
184 184
 
@@ -186,28 +186,28 @@  discard block
 block discarded – undo
186 186
 	// Entries must be declared in modules descriptor with line
187 187
 	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
188 188
 	// $this->tabs = array('entity:-tabname);   												to remove a tab
189
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'task');
189
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'task');
190 190
 
191 191
 	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
192 192
     {
193 193
     	$nbNote = 0;
194
-        if(!empty($object->note_private)) $nbNote++;
195
-		if(!empty($object->note_public)) $nbNote++;
196
-		$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
194
+        if (!empty($object->note_private)) $nbNote++;
195
+		if (!empty($object->note_public)) $nbNote++;
196
+		$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
197 197
 		$head[$h][1] = $langs->trans('Notes');
198
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
198
+		if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>';
199 199
 		$head[$h][2] = 'task_notes';
200 200
 		$h++;
201 201
     }
202 202
 
203
-	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
204
-	$filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->project->ref) . '/' .dol_sanitizeFileName($object->ref);
203
+	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
204
+	$filesdir = $conf->projet->dir_output."/".dol_sanitizeFileName($object->project->ref).'/'.dol_sanitizeFileName($object->ref);
205 205
 	include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
206 206
 	include_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
207
-	$nbFiles = count(dol_dir_list($filesdir,'files',0,'','(\.meta|_preview.*\.png)$'));
208
-    $nbLinks=Link::count($db, $object->element, $object->id);
207
+	$nbFiles = count(dol_dir_list($filesdir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
208
+    $nbLinks = Link::count($db, $object->element, $object->id);
209 209
 	$head[$h][1] = $langs->trans('Documents');
210
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
210
+	if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>';
211 211
 	$head[$h][2] = 'task_document';
212 212
 	$h++;
213 213
 
@@ -215,14 +215,14 @@  discard block
 block discarded – undo
215 215
 	if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK))
216 216
 	{
217 217
 		$nbComments = $object->getNbComments();
218
-		$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
218
+		$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
219 219
 		$head[$h][1] = $langs->trans("CommentLink");
220
-		if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>';
220
+		if ($nbComments > 0) $head[$h][1] .= ' <span class="badge">'.$nbComments.'</span>';
221 221
 		$head[$h][2] = 'task_comment';
222 222
 		$h++;
223 223
 	}
224 224
 
225
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'task','remove');
225
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'task', 'remove');
226 226
 
227 227
 	return $head;
228 228
 }
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
  * @param   string  $fuser      Filter on user
235 235
  * @return  array				Array of tabs to show
236 236
  */
237
-function project_timesheet_prepare_head($mode, $fuser=null)
237
+function project_timesheet_prepare_head($mode, $fuser = null)
238 238
 {
239 239
 	global $langs, $conf, $user;
240 240
 	$h = 0;
@@ -242,13 +242,13 @@  discard block
 block discarded – undo
242 242
 
243 243
 	$h = 0;
244 244
 
245
-	$param='';
246
-	$param.=($mode?'&mode='.$mode:'');
247
-	if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param.='&search_usertoprocessid='.$fuser->id;
245
+	$param = '';
246
+	$param .= ($mode ? '&mode='.$mode : '');
247
+	if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param .= '&search_usertoprocessid='.$fuser->id;
248 248
 
249 249
 	if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK))
250 250
 	{
251
-		$head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param?'?'.$param:'');
251
+		$head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param ? '?'.$param : '');
252 252
 		$head[$h][1] = $langs->trans("InputPerWeek");
253 253
 		$head[$h][2] = 'inputperweek';
254 254
 		$h++;
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 
257 257
 	if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME))
258 258
 	{
259
-		$head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param?'?'.$param:'');
259
+		$head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param ? '?'.$param : '');
260 260
 		$head[$h][1] = $langs->trans("InputPerDay");
261 261
 		$head[$h][2] = 'inputperday';
262 262
 		$h++;
@@ -270,9 +270,9 @@  discard block
 block discarded – undo
270 270
 		$h++;
271 271
 	}*/
272 272
 
273
-	complete_head_from_modules($conf,$langs,null,$head,$h,'project_timesheet');
273
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'project_timesheet');
274 274
 
275
-	complete_head_from_modules($conf,$langs,null,$head,$h,'project_timesheet','remove');
275
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'project_timesheet', 'remove');
276 276
 
277 277
 	return $head;
278 278
 }
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 	$head[$h][2] = 'project';
297 297
 	$h++;
298 298
 
299
-	complete_head_from_modules($conf,$langs,null,$head,$h,'project_admin');
299
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'project_admin');
300 300
 
301 301
 	$head[$h][0] = DOL_URL_ROOT."/projet/admin/project_extrafields.php";
302 302
 	$head[$h][1] = $langs->trans("ExtraFieldsProject");
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	$head[$h][2] = 'attributes_task';
309 309
 	$h++;
310 310
 
311
-	complete_head_from_modules($conf,$langs,null,$head,$h,'project_admin','remove');
311
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'project_admin', 'remove');
312 312
 
313 313
 	return $head;
314 314
 }
@@ -329,29 +329,29 @@  discard block
 block discarded – undo
329 329
  * @param   int         $projectidfortotallink     0 or Id of project to use on total line (link to see all time consumed for project)
330 330
  * @return	void
331 331
  */
332
-function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId='', $addordertick=0, $projectidfortotallink=0)
332
+function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId = '', $addordertick = 0, $projectidfortotallink = 0)
333 333
 {
334 334
 	global $user, $bc, $langs;
335 335
 	global $projectstatic, $taskstatic;
336 336
 
337
-	$lastprojectid=0;
337
+	$lastprojectid = 0;
338 338
 
339
-	$projectsArrayId=explode(',',$projectsListId);
339
+	$projectsArrayId = explode(',', $projectsListId);
340 340
 
341
-	$numlines=count($lines);
341
+	$numlines = count($lines);
342 342
 
343 343
 	// We declare counter as global because we want to edit them into recursive call
344
-	global $total_projectlinesa_spent,$total_projectlinesa_planned,$total_projectlinesa_spent_if_planned;
344
+	global $total_projectlinesa_spent, $total_projectlinesa_planned, $total_projectlinesa_spent_if_planned;
345 345
 	if ($level == 0)
346 346
 	{
347
-		$total_projectlinesa_spent=0;
348
-		$total_projectlinesa_planned=0;
349
-		$total_projectlinesa_spent_if_planned=0;
347
+		$total_projectlinesa_spent = 0;
348
+		$total_projectlinesa_planned = 0;
349
+		$total_projectlinesa_spent_if_planned = 0;
350 350
 	}
351 351
 
352
-	for ($i = 0 ; $i < $numlines ; $i++)
352
+	for ($i = 0; $i < $numlines; $i++)
353 353
 	{
354
-		if ($parent == 0 && $level >= 0) $level = 0;              // if $level = -1, we dont' use sublevel recursion, we show all lines
354
+		if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines
355 355
 
356 356
 		// Process line
357 357
 		// print "i:".$i."-".$lines[$i]->fk_project.'<br>';
@@ -359,26 +359,26 @@  discard block
 block discarded – undo
359 359
 		if ($lines[$i]->fk_parent == $parent || $level < 0)       // if $level = -1, we dont' use sublevel recursion, we show all lines
360 360
 		{
361 361
 			// Show task line.
362
-			$showline=1;
363
-			$showlineingray=0;
362
+			$showline = 1;
363
+			$showlineingray = 0;
364 364
 
365 365
 			// If there is filters to use
366 366
 			if (is_array($taskrole))
367 367
 			{
368 368
 				// If task not legitimate to show, search if a legitimate task exists later in tree
369
-				if (! isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent)
369
+				if (!isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent)
370 370
 				{
371 371
 					// So search if task has a subtask legitimate to show
372
-					$foundtaskforuserdeeper=0;
373
-					searchTaskInChild($foundtaskforuserdeeper,$lines[$i]->id,$lines,$taskrole);
372
+					$foundtaskforuserdeeper = 0;
373
+					searchTaskInChild($foundtaskforuserdeeper, $lines[$i]->id, $lines, $taskrole);
374 374
 					//print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'<br>';
375 375
 					if ($foundtaskforuserdeeper > 0)
376 376
 					{
377
-						$showlineingray=1;		// We will show line but in gray
377
+						$showlineingray = 1; // We will show line but in gray
378 378
 					}
379 379
 					else
380 380
 					{
381
-						$showline=0;			// No reason to show line
381
+						$showline = 0; // No reason to show line
382 382
 					}
383 383
 				}
384 384
 			}
@@ -389,12 +389,12 @@  discard block
 block discarded – undo
389 389
 				if (empty($user->rights->projet->all->lire))
390 390
 				{
391 391
 					// User is not allowed on this project and project is not public, so we hide line
392
-					if (! in_array($lines[$i]->fk_project, $projectsArrayId))
392
+					if (!in_array($lines[$i]->fk_project, $projectsArrayId))
393 393
 					{
394 394
 						// Note that having a user assigned to a task into a project user has no permission on, should not be possible
395 395
 						// because assignement on task can be done only on contact of project.
396 396
 						// If assignement was done and after, was removed from contact of project, then we can hide the line.
397
-						$showline=0;
397
+						$showline = 0;
398 398
 					}
399 399
 				}
400 400
 			}
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 				if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
406 406
 				{
407 407
 					$var = !$var;
408
-					$lastprojectid=$lines[$i]->fk_project;
408
+					$lastprojectid = $lines[$i]->fk_project;
409 409
 				}
410 410
 
411 411
 				print '<tr '.$bc[$var].' id="row-'.$lines[$i]->id.'">'."\n";
@@ -415,18 +415,18 @@  discard block
 block discarded – undo
415 415
 					// Project ref
416 416
 					print "<td>";
417 417
 					//if ($showlineingray) print '<i>';
418
-					$projectstatic->id=$lines[$i]->fk_project;
419
-					$projectstatic->ref=$lines[$i]->projectref;
420
-					$projectstatic->public=$lines[$i]->public;
421
-					$projectstatic->title=$lines[$i]->projectlabel;
422
-					if ($lines[$i]->public || in_array($lines[$i]->fk_project,$projectsArrayId) || ! empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1);
423
-					else print $projectstatic->getNomUrl(1,'nolink');
418
+					$projectstatic->id = $lines[$i]->fk_project;
419
+					$projectstatic->ref = $lines[$i]->projectref;
420
+					$projectstatic->public = $lines[$i]->public;
421
+					$projectstatic->title = $lines[$i]->projectlabel;
422
+					if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1);
423
+					else print $projectstatic->getNomUrl(1, 'nolink');
424 424
 					//if ($showlineingray) print '</i>';
425 425
 					print "</td>";
426 426
 
427 427
 					// Project status
428 428
 					print '<td>';
429
-					$projectstatic->statut=$lines[$i]->projectstatus;
429
+					$projectstatic->statut = $lines[$i]->projectstatus;
430 430
 					print $projectstatic->getLibStatut(2);
431 431
 					print "</td>";
432 432
 				}
@@ -435,14 +435,14 @@  discard block
 block discarded – undo
435 435
 				print '<td>';
436 436
 				if ($showlineingray)
437 437
 				{
438
-					print '<i>'.img_object('','projecttask').' '.$lines[$i]->ref.'</i>';
438
+					print '<i>'.img_object('', 'projecttask').' '.$lines[$i]->ref.'</i>';
439 439
 				}
440 440
 				else
441 441
 				{
442
-					$taskstatic->id=$lines[$i]->id;
443
-					$taskstatic->ref=$lines[$i]->ref;
444
-					$taskstatic->label=($taskrole[$lines[$i]->id]?$langs->trans("YourRole").': '.$taskrole[$lines[$i]->id]:'');
445
-					print $taskstatic->getNomUrl(1,'withproject');
442
+					$taskstatic->id = $lines[$i]->id;
443
+					$taskstatic->ref = $lines[$i]->ref;
444
+					$taskstatic->label = ($taskrole[$lines[$i]->id] ? $langs->trans("YourRole").': '.$taskrole[$lines[$i]->id] : '');
445
+					print $taskstatic->getNomUrl(1, 'withproject');
446 446
 				}
447 447
 				print '</td>';
448 448
 
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 				print "<td>";
451 451
 				if ($showlineingray) print '<i>';
452 452
 				//else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$lines[$i]->id.'&withproject=1">';
453
-				for ($k = 0 ; $k < $level ; $k++)
453
+				for ($k = 0; $k < $level; $k++)
454 454
 				{
455 455
 					print "&nbsp; &nbsp; &nbsp;";
456 456
 				}
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 
462 462
 				// Date start
463 463
 				print '<td align="center">';
464
-				print dol_print_date($lines[$i]->date_start,'dayhour');
464
+				print dol_print_date($lines[$i]->date_start, 'dayhour');
465 465
 				print '</td>';
466 466
 
467 467
 				// Date end
@@ -470,19 +470,19 @@  discard block
 block discarded – undo
470 470
 	            $taskstatic->progress = $lines[$i]->progress;
471 471
 	            $taskstatic->fk_statut = $lines[$i]->status;
472 472
 	            $taskstatic->datee = $lines[$i]->date_end;
473
-	            print dol_print_date($lines[$i]->date_end,'dayhour');
473
+	            print dol_print_date($lines[$i]->date_end, 'dayhour');
474 474
 	            if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late"));
475 475
 				print '</td>';
476 476
 
477
-				$plannedworkloadoutputformat='allhourmin';
478
-				$timespentoutputformat='allhourmin';
479
-				if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
480
-				if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT;
477
+				$plannedworkloadoutputformat = 'allhourmin';
478
+				$timespentoutputformat = 'allhourmin';
479
+				if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
480
+				if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT;
481 481
 
482 482
 				// Planned Workload (in working hours)
483 483
 				print '<td align="right">';
484
-				$fullhour=convertSecondToTime($lines[$i]->planned_workload,$plannedworkloadoutputformat);
485
-				$workingdelay=convertSecondToTime($lines[$i]->planned_workload,'all',86400,7);	// TODO Replace 86400 and 7 to take account working hours per day and working day per weeks
484
+				$fullhour = convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat);
485
+				$workingdelay = convertSecondToTime($lines[$i]->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks
486 486
 				if ($lines[$i]->planned_workload != '')
487 487
 				{
488 488
 					print $fullhour;
@@ -495,8 +495,8 @@  discard block
 block discarded – undo
495 495
 				// Time spent
496 496
 				print '<td align="right">';
497 497
 				if ($showlineingray) print '<i>';
498
-				else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">';
499
-				if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,$timespentoutputformat);
498
+				else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject ? '' : '&withproject=1').'">';
499
+				if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration, $timespentoutputformat);
500 500
 				else print '--:--';
501 501
 				if ($showlineingray) print '</i>';
502 502
 				else print '</a>';
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
 				print '<td align="right">';
507 507
 				if ($lines[$i]->planned_workload || $lines[$i]->duration)
508 508
 				{
509
-					if ($lines[$i]->planned_workload) print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload,2).' %';
509
+					if ($lines[$i]->planned_workload) print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2).' %';
510 510
 					else print '<span class="opacitymedium">'.$langs->trans('WorkloadNotDefined').'</span>';
511 511
 				}
512 512
 				print '</td>';
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 
528 528
 				print "</tr>\n";
529 529
 
530
-				if (! $showlineingray) $inc++;
530
+				if (!$showlineingray) $inc++;
531 531
 
532 532
 				if ($level >= 0)    // Call sublevels
533 533
 				{
@@ -559,12 +559,12 @@  discard block
 block discarded – undo
559 559
 		print convertSecondToTime($total_projectlinesa_planned, 'allhourmin');
560 560
 		print '</td>';
561 561
 		print '<td align="right" class="nowrap liste_total">';
562
-		if ($projectidfortotallink > 0) print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject?'':'&withproject=1').'">';
562
+		if ($projectidfortotallink > 0) print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject ? '' : '&withproject=1').'">';
563 563
 		print convertSecondToTime($total_projectlinesa_spent, 'allhourmin');
564 564
 		if ($projectidfortotallink > 0) print '</a>';
565 565
 		print '</td>';
566 566
 		print '<td align="right" class="nowrap liste_total">';
567
-		if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned,2).' %';
567
+		if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned, 2).' %';
568 568
 		print '</td>';
569 569
 		print '<td></td>';
570 570
 		if ($addordertick) print '<td class="hideonsmartphone"></td>';
@@ -596,37 +596,37 @@  discard block
 block discarded – undo
596 596
 	global $conf, $db, $user, $bc, $langs;
597 597
 	global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
598 598
 
599
-	$lastprojectid=0;
600
-	$workloadforid=array();
601
-	$lineswithoutlevel0=array();
599
+	$lastprojectid = 0;
600
+	$workloadforid = array();
601
+	$lineswithoutlevel0 = array();
602 602
 
603
-	$numlines=count($lines);
603
+	$numlines = count($lines);
604 604
 
605 605
 	// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
606 606
 	if ($parent == 0) // Always and only if at first level
607 607
 	{
608
-	    for ($i = 0 ; $i < $numlines ; $i++)
608
+	    for ($i = 0; $i < $numlines; $i++)
609 609
 	    {
610
-	        if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
610
+	        if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i];
611 611
 	    }
612 612
 	}
613 613
 
614 614
     //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
615
-	for ($i = 0 ; $i < $numlines ; $i++)
615
+	for ($i = 0; $i < $numlines; $i++)
616 616
 	{
617 617
 		if ($parent == 0) $level = 0;
618 618
 
619 619
 		if ($lines[$i]->fk_task_parent == $parent)
620 620
 		{
621 621
 			// If we want all or we have a role on task, we show it
622
-			if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
622
+			if (empty($mine) || !empty($tasksrole[$lines[$i]->id]))
623 623
 			{
624 624
                 //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
625 625
 
626 626
 				// Break on a new project
627 627
         		if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
628 628
         		{
629
-        			$lastprojectid=$lines[$i]->fk_project;
629
+        			$lastprojectid = $lines[$i]->fk_project;
630 630
         			if ($preselectedday)
631 631
         			{
632 632
         				$projectstatic->id = $lines[$i]->fk_project;
@@ -637,17 +637,17 @@  discard block
 block discarded – undo
637 637
 			    {
638 638
     				if ($preselectedday)
639 639
     				{
640
-    			        $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id);	// Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
641
-	       		        $workloadforid[$projectstatic->id]=1;
640
+    			        $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
641
+	       		        $workloadforid[$projectstatic->id] = 1;
642 642
     				}
643 643
 			    }
644 644
 
645
-				$projectstatic->id=$lines[$i]->fk_project;
646
-				$projectstatic->ref=$lines[$i]->projectref;
647
-				$projectstatic->title=$lines[$i]->projectlabel;
648
-				$projectstatic->public=$lines[$i]->public;
645
+				$projectstatic->id = $lines[$i]->fk_project;
646
+				$projectstatic->ref = $lines[$i]->projectref;
647
+				$projectstatic->title = $lines[$i]->projectlabel;
648
+				$projectstatic->public = $lines[$i]->public;
649 649
 
650
-				$taskstatic->id=$lines[$i]->id;
650
+				$taskstatic->id = $lines[$i]->id;
651 651
 
652 652
 				print '<tr class="oddeven">'."\n";
653 653
 
@@ -660,32 +660,32 @@  discard block
 block discarded – undo
660 660
 
661 661
 				// Project
662 662
 				print "<td>";
663
-				print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
663
+				print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
664 664
 				print "</td>";
665 665
 
666
-				if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY))
666
+				if (!empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY))
667 667
 				{
668 668
 				    // Thirdparty
669 669
 				    print '<td class="tdoverflowmax100">';
670
-				    $thirdpartystatic->id=$lines[$i]->socid;
671
-				    $thirdpartystatic->name=$lines[$i]->thirdparty_name;
670
+				    $thirdpartystatic->id = $lines[$i]->socid;
671
+				    $thirdpartystatic->name = $lines[$i]->thirdparty_name;
672 672
 				    print $thirdpartystatic->getNomUrl(1, 'project', 10);
673 673
 				    print '</td>';
674 674
 				}
675 675
 
676 676
 				// Ref
677 677
 				print '<td>';
678
-				$taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id);
678
+				$taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
679 679
 				print $taskstatic->getNomUrl(1, 'withproject', 'time');
680 680
 				print '</td>';
681 681
 
682 682
 				// Label task
683 683
 				print "<td>";
684
-				for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
685
-				$taskstatic->id=$lines[$i]->id;
686
-				$taskstatic->ref=$lines[$i]->label;
687
-				$taskstatic->date_start=$lines[$i]->date_start;
688
-				$taskstatic->date_end=$lines[$i]->date_end;
684
+				for ($k = 0; $k < $level; $k++) print "&nbsp;&nbsp;&nbsp;";
685
+				$taskstatic->id = $lines[$i]->id;
686
+				$taskstatic->ref = $lines[$i]->label;
687
+				$taskstatic->date_start = $lines[$i]->date_start;
688
+				$taskstatic->date_end = $lines[$i]->date_end;
689 689
 				print $taskstatic->getNomUrl(0, 'withproject', 'time');
690 690
 				//print "<br>";
691 691
 				//for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
@@ -694,13 +694,13 @@  discard block
 block discarded – undo
694 694
 
695 695
 				// Planned Workload
696 696
 				print '<td align="right">';
697
-				if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
697
+				if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
698 698
 				else print '--:--';
699 699
 				print '</td>';
700 700
 
701 701
 				// Progress declared %
702 702
 				print '<td align="right">';
703
-				print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress');
703
+				print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
704 704
 				print '</td>';
705 705
 
706 706
 				// Time spent by everybody
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 				if ($lines[$i]->duration)
710 710
 				{
711 711
 					print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
712
-					print convertSecondToTime($lines[$i]->duration,'allhourmin');
712
+					print convertSecondToTime($lines[$i]->duration, 'allhourmin');
713 713
 					print '</a>';
714 714
 				}
715 715
 				else print '--:--';
@@ -717,56 +717,56 @@  discard block
 block discarded – undo
717 717
 
718 718
 				// Time spent by user
719 719
 				print '<td align="right">';
720
-				$tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id);
721
-				if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
720
+				$tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
721
+				if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
722 722
 				else print '--:--';
723 723
 				print "</td>\n";
724 724
 
725
-				$disabledproject=1;$disabledtask=1;
725
+				$disabledproject = 1; $disabledtask = 1;
726 726
 				//print "x".$lines[$i]->fk_project;
727 727
 				//var_dump($lines[$i]);
728 728
 				//var_dump($projectsrole[$lines[$i]->fk_project]);
729 729
 				// If at least one role for project
730
-				if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
730
+				if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
731 731
 				{
732
-					$disabledproject=0;
733
-					$disabledtask=0;
732
+					$disabledproject = 0;
733
+					$disabledtask = 0;
734 734
 				}
735 735
 				// If $restricteditformytask is on and I have no role on task, i disable edit
736 736
 				if ($restricteditformytask && empty($tasksrole[$lines[$i]->id]))
737 737
 				{
738
-					$disabledtask=1;
738
+					$disabledtask = 1;
739 739
 				}
740 740
 
741 741
 				// Form to add new time
742 742
 				print '<td class="nowrap" align="center">';
743
-				$tableCell=$form->select_date($preselectedday,$lines[$i]->id,1,1,2,"addtime",0,0,1,$disabledtask);
743
+				$tableCell = $form->select_date($preselectedday, $lines[$i]->id, 1, 1, 2, "addtime", 0, 0, 1, $disabledtask);
744 744
 				print $tableCell;
745 745
 				print '</td>';
746 746
 
747
-				$cssonholiday='';
748
-				if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon'])   $cssonholiday.='onholidayallday ';
749
-				elseif (! $isavailable[$preselectedday]['morning'])   $cssonholiday.='onholidaymorning ';
750
-				elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon ';
747
+				$cssonholiday = '';
748
+				if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon'])   $cssonholiday .= 'onholidayallday ';
749
+				elseif (!$isavailable[$preselectedday]['morning'])   $cssonholiday .= 'onholidaymorning ';
750
+				elseif (!$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayafternoon ';
751 751
 
752 752
 				// Duration
753
-				print '<td align="center" class="duration'.($cssonholiday?' '.$cssonholiday:'').'">';
753
+				print '<td align="center" class="duration'.($cssonholiday ? ' '.$cssonholiday : '').'">';
754 754
 
755 755
 				$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
756
-		        $alreadyspent='';
757
-		        if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
756
+		        $alreadyspent = '';
757
+		        if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin');
758 758
 
759 759
 		        $idw = 0;
760 760
 
761
-				$tableCell='';
762
-				$tableCell.='<span class="timesheetalreadyrecorded"><input type="text" class="center" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
763
-                $tableCell.='<span class="hideonsmartphone"> + </span>';
761
+				$tableCell = '';
762
+				$tableCell .= '<span class="timesheetalreadyrecorded"><input type="text" class="center" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
763
+                $tableCell .= '<span class="hideonsmartphone"> + </span>';
764 764
 				//$tableCell.='&nbsp;&nbsp;&nbsp;';
765
-				$tableCell.=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1);
765
+				$tableCell .= $form->select_duration($lines[$i]->id.'duration', '', $disabledtask, 'text', 0, 1);
766 766
 				//$tableCell.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled':'').' value="'.$langs->trans("Add").'">';
767 767
 				print $tableCell;
768 768
 
769
-				$modeinput='hours';
769
+				$modeinput = 'hours';
770 770
 
771 771
 				print '<script type="text/javascript">';
772 772
 				print "jQuery(document).ready(function () {\n";
@@ -777,19 +777,19 @@  discard block
 block discarded – undo
777 777
 				print '</td>';
778 778
 
779 779
 				print '<td align="right">';
780
-				print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask?' disabled="disabled"':'').'>';
780
+				print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask ? ' disabled="disabled"' : '').'>';
781 781
 				print '</textarea>';
782 782
 				print '</td>';
783 783
 
784 784
 				// Warning
785 785
 				print '<td align="right">';
786
-   				if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
786
+   				if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
787 787
    				else if ($disabledtask)
788 788
    				{
789 789
    					$titleassigntask = $langs->trans("AssignTaskToMe");
790 790
    					if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
791 791
 
792
-   					print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
792
+   					print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
793 793
    				}
794 794
 				print '</td>';
795 795
 
@@ -836,52 +836,52 @@  discard block
 block discarded – undo
836 836
 	global $conf, $db, $user, $bc, $langs;
837 837
 	global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
838 838
 
839
-	$numlines=count($lines);
839
+	$numlines = count($lines);
840 840
 
841
-	$lastprojectid=0;
842
-	$workloadforid=array();
843
-	$lineswithoutlevel0=array();
841
+	$lastprojectid = 0;
842
+	$workloadforid = array();
843
+	$lineswithoutlevel0 = array();
844 844
 
845 845
 	// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
846 846
 	if ($parent == 0) // Always and only if at first level
847 847
 	{
848
-	    for ($i = 0 ; $i < $numlines ; $i++)
848
+	    for ($i = 0; $i < $numlines; $i++)
849 849
 	    {
850
-	       if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
850
+	       if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i];
851 851
 	    }
852 852
 	}
853 853
 
854 854
     //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
855 855
 
856
-	for ($i = 0 ; $i < $numlines ; $i++)
856
+	for ($i = 0; $i < $numlines; $i++)
857 857
 	{
858 858
 		if ($parent == 0) $level = 0;
859 859
 
860 860
 		if ($lines[$i]->fk_task_parent == $parent)
861 861
 		{
862 862
 			// If we want all or we have a role on task, we show it
863
-			if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
863
+			if (empty($mine) || !empty($tasksrole[$lines[$i]->id]))
864 864
 			{
865 865
 			    //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
866 866
 
867 867
 			    // Break on a new project
868 868
     			if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
869 869
     			{
870
-    				$lastprojectid=$lines[$i]->fk_project;
870
+    				$lastprojectid = $lines[$i]->fk_project;
871 871
     				$projectstatic->id = $lines[$i]->fk_project;
872 872
     			}
873 873
 
874 874
 			    if (empty($workloadforid[$projectstatic->id]))
875 875
 			    {
876
-				    $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id);	// Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
877
-                    $workloadforid[$projectstatic->id]=1;
876
+				    $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
877
+                    $workloadforid[$projectstatic->id] = 1;
878 878
 			    }
879 879
 
880
-				$projectstatic->id=$lines[$i]->fk_project;
881
-				$projectstatic->ref=$lines[$i]->projectref;
882
-				$projectstatic->title=$lines[$i]->projectlabel;
883
-				$projectstatic->public=$lines[$i]->public;
884
-				$projectstatic->thirdparty_name=$lines[$i]->thirdparty_name;
880
+				$projectstatic->id = $lines[$i]->fk_project;
881
+				$projectstatic->ref = $lines[$i]->projectref;
882
+				$projectstatic->title = $lines[$i]->projectlabel;
883
+				$projectstatic->public = $lines[$i]->public;
884
+				$projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
885 885
 
886 886
 				print '<tr class="oddeven">'."\n";
887 887
 
@@ -894,34 +894,34 @@  discard block
 block discarded – undo
894 894
 
895 895
 				// Project
896 896
 				print '<td class="nowrap">';
897
-				print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
897
+				print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
898 898
 				print "</td>";
899 899
 
900
-				if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY))
900
+				if (!empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY))
901 901
 				{
902 902
 				    // Thirdparty
903 903
 				    print '<td class="tdoverflowmax100">';
904
-				    $thirdpartystatic->id=$lines[$i]->thirdparty_id;
905
-				    $thirdpartystatic->name=$lines[$i]->thirdparty_name;
904
+				    $thirdpartystatic->id = $lines[$i]->thirdparty_id;
905
+				    $thirdpartystatic->name = $lines[$i]->thirdparty_name;
906 906
 				    print $thirdpartystatic->getNomUrl(1, 'project');
907 907
 				    print '</td>';
908 908
 				}
909 909
 
910 910
 				// Ref
911 911
 				print '<td class="nowrap">';
912
-				$taskstatic->id=$lines[$i]->id;
913
-				$taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id);
912
+				$taskstatic->id = $lines[$i]->id;
913
+				$taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
914 914
 				print $taskstatic->getNomUrl(1, 'withproject', 'time');
915 915
 				print '</td>';
916 916
 
917 917
 				// Label task
918 918
 				print "<td>";
919 919
 				print '<!-- Task id = '.$lines[$i]->id.' -->';
920
-				for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
921
-				$taskstatic->id=$lines[$i]->id;
922
-				$taskstatic->ref=$lines[$i]->label;
923
-				$taskstatic->date_start=$lines[$i]->date_start;
924
-				$taskstatic->date_end=$lines[$i]->date_end;
920
+				for ($k = 0; $k < $level; $k++) print "&nbsp;&nbsp;&nbsp;";
921
+				$taskstatic->id = $lines[$i]->id;
922
+				$taskstatic->ref = $lines[$i]->label;
923
+				$taskstatic->date_start = $lines[$i]->date_start;
924
+				$taskstatic->date_end = $lines[$i]->date_end;
925 925
 				print $taskstatic->getNomUrl(0, 'withproject', 'time');
926 926
 				//print "<br>";
927 927
 				//for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
@@ -930,13 +930,13 @@  discard block
 block discarded – undo
930 930
 
931 931
 				// Planned Workload
932 932
 				print '<td align="right">';
933
-				if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
933
+				if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
934 934
 				else print '--:--';
935 935
 				print '</td>';
936 936
 
937 937
 				// Progress declared %
938 938
 				print '<td align="right">';
939
-				print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress');
939
+				print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
940 940
 				print '</td>';
941 941
 
942 942
 				// Time spent by everybody
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
 				if ($lines[$i]->duration)
946 946
 				{
947 947
 					print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
948
-					print convertSecondToTime($lines[$i]->duration,'allhourmin');
948
+					print convertSecondToTime($lines[$i]->duration, 'allhourmin');
949 949
 					print '</a>';
950 950
 				}
951 951
 				else print '--:--';
@@ -953,71 +953,71 @@  discard block
 block discarded – undo
953 953
 
954 954
 				// Time spent by user
955 955
 				print '<td align="right">';
956
-				$tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id);
957
-				if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
956
+				$tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
957
+				if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
958 958
 				else print '--:--';
959 959
 				print "</td>\n";
960 960
 
961
-				$disabledproject=1;$disabledtask=1;
961
+				$disabledproject = 1; $disabledtask = 1;
962 962
 				//print "x".$lines[$i]->fk_project;
963 963
 				//var_dump($lines[$i]);
964 964
 				//var_dump($projectsrole[$lines[$i]->fk_project]);
965 965
 				// If at least one role for project
966
-				if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
966
+				if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
967 967
 				{
968
-					$disabledproject=0;
969
-					$disabledtask=0;
968
+					$disabledproject = 0;
969
+					$disabledtask = 0;
970 970
 				}
971 971
 				// If $restricteditformytask is on and I have no role on task, i disable edit
972 972
 				if ($restricteditformytask && empty($tasksrole[$lines[$i]->id]))
973 973
 				{
974
-					$disabledtask=1;
974
+					$disabledtask = 1;
975 975
 				}
976 976
 
977 977
 				//var_dump($projectstatic->weekWorkLoadPerTask);
978 978
 
979 979
 				// Fields to show current time
980
-				$tableCell=''; $modeinput='hours';
980
+				$tableCell = ''; $modeinput = 'hours';
981 981
 				for ($idw = 0; $idw < 7; $idw++)
982 982
 		        {
983
-					$tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd');
983
+					$tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
984 984
 
985
-					$cssonholiday='';
986
-					if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon'])   $cssonholiday.='onholidayallday ';
987
-					elseif (! $isavailable[$tmpday]['morning'])   $cssonholiday.='onholidaymorning ';
988
-					elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon ';
985
+					$cssonholiday = '';
986
+					if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon'])   $cssonholiday .= 'onholidayallday ';
987
+					elseif (!$isavailable[$tmpday]['morning'])   $cssonholiday .= 'onholidaymorning ';
988
+					elseif (!$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayafternoon ';
989 989
 
990
-					$tmparray=dol_getdate($tmpday);
990
+					$tmparray = dol_getdate($tmpday);
991 991
 		        	$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id];
992
-		        	$alreadyspent='';
993
-		        	if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
994
-                    $alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']);
992
+		        	$alreadyspent = '';
993
+		        	if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin');
994
+                    $alttitle = $langs->trans("AddHereTimeSpentForDay", $tmparray['day'], $tmparray['mon']);
995 995
 
996
-                    $tableCell ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').'">';
996
+                    $tableCell = '<td align="center" class="hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').'">';
997 997
                     if ($alreadyspent)
998 998
                     {
999
-                        $tableCell.='<span class="timesheetalreadyrecorded"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
999
+                        $tableCell .= '<span class="timesheetalreadyrecorded"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
1000 1000
                         //$placeholder=' placeholder="00:00"';
1001
-                        $placeholder='';
1001
+                        $placeholder = '';
1002 1002
                      	//$tableCell.='+';
1003 1003
                     }
1004
-                  	$tableCell.='<input type="text" alt="'.($disabledtask?'':$alttitle).'" title="'.($disabledtask?'':$alttitle).'" '.($disabledtask?'disabled':$placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2"  maxlength="5"';
1005
-	        		$tableCell.=' onkeypress="return regexEvent(this,event,\'timeChar\')"';
1006
-                   	$tableCell.=' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"';
1007
-                   	$tableCell.=' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />';
1008
-                   	$tableCell.='</td>';
1004
+                  	$tableCell .= '<input type="text" alt="'.($disabledtask ? '' : $alttitle).'" title="'.($disabledtask ? '' : $alttitle).'" '.($disabledtask ? 'disabled' : $placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2"  maxlength="5"';
1005
+	        		$tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"';
1006
+                   	$tableCell .= ' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"';
1007
+                   	$tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />';
1008
+                   	$tableCell .= '</td>';
1009 1009
                     print $tableCell;
1010 1010
 		        }
1011 1011
 
1012 1012
 		        // Warning
1013 1013
 				print '<td align="right">';
1014
-   				if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
1014
+   				if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
1015 1015
    				else if ($disabledtask)
1016 1016
    				{
1017 1017
    					$titleassigntask = $langs->trans("AssignTaskToMe");
1018 1018
    					if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
1019 1019
 
1020
-   					print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
1020
+   					print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
1021 1021
    				}
1022 1022
 				print '</td>';
1023 1023
 
@@ -1056,8 +1056,8 @@  discard block
 block discarded – undo
1056 1056
 function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
1057 1057
 {
1058 1058
 	//print 'Search in line with parent id = '.$parent.'<br>';
1059
-	$numlines=count($lines);
1060
-	for ($i = 0 ; $i < $numlines ; $i++)
1059
+	$numlines = count($lines);
1060
+	for ($i = 0; $i < $numlines; $i++)
1061 1061
 	{
1062 1062
 		// Process line $lines[$i]
1063 1063
 		if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent)
@@ -1093,51 +1093,51 @@  discard block
 block discarded – undo
1093 1093
  * @param   array   $hiddenfields       List of info to not show ('projectlabel', 'declaredprogress', '...', )
1094 1094
  * @return	void
1095 1095
  */
1096
-function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=0, $statut=-1, $listofoppstatus=array(),$hiddenfields=array())
1096
+function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $statut = -1, $listofoppstatus = array(), $hiddenfields = array())
1097 1097
 {
1098
-	global $langs,$conf,$user,$bc;
1098
+	global $langs, $conf, $user, $bc;
1099 1099
 
1100 1100
 	require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
1101 1101
 
1102
-	$projectstatic=new Project($db);
1103
-    $thirdpartystatic=new Societe($db);
1102
+	$projectstatic = new Project($db);
1103
+    $thirdpartystatic = new Societe($db);
1104 1104
 
1105
-	$sortfield='';
1106
-	$sortorder='';
1107
-	$project_year_filter=0;
1105
+	$sortfield = '';
1106
+	$sortorder = '';
1107
+	$project_year_filter = 0;
1108 1108
 
1109
-	$title=$langs->trans("Projects");
1110
-	if (strcmp($statut, '') && $statut >= 0) $title=$langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]);
1109
+	$title = $langs->trans("Projects");
1110
+	if (strcmp($statut, '') && $statut >= 0) $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]);
1111 1111
 
1112
-	$arrayidtypeofcontact=array();
1112
+	$arrayidtypeofcontact = array();
1113 1113
 
1114 1114
 	print '<table class="noborder" width="100%">';
1115 1115
 
1116
-	$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
1116
+	$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
1117 1117
 	if ($mytasks)
1118 1118
 	{
1119
-		$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
1120
-		$sql.= ", ".MAIN_DB_PREFIX."element_contact as ec";
1121
-		$sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc";
1119
+		$sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
1120
+		$sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
1121
+		$sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc";
1122 1122
 	}
1123 1123
 	else
1124 1124
 	{
1125
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
1125
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
1126 1126
 	}
1127
-	$sql.= " WHERE p.entity = ".$conf->entity;
1128
-	$sql.= " AND p.rowid IN (".$projectsListId.")";
1129
-	if ($socid) $sql.= "  AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
1127
+	$sql .= " WHERE p.entity = ".$conf->entity;
1128
+	$sql .= " AND p.rowid IN (".$projectsListId.")";
1129
+	if ($socid) $sql .= "  AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
1130 1130
 	if ($mytasks)
1131 1131
 	{
1132
-		$sql.= " AND p.rowid = t.fk_projet";
1133
-		$sql.= " AND ec.element_id = t.rowid";
1134
-		$sql.= " AND ec.fk_socpeople = ".$user->id;
1135
-		$sql.= " AND ec.fk_c_type_contact = ctc.rowid";   // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact
1136
-		$sql.= " AND ctc.element = 'project_task'";
1132
+		$sql .= " AND p.rowid = t.fk_projet";
1133
+		$sql .= " AND ec.element_id = t.rowid";
1134
+		$sql .= " AND ec.fk_socpeople = ".$user->id;
1135
+		$sql .= " AND ec.fk_c_type_contact = ctc.rowid"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact
1136
+		$sql .= " AND ctc.element = 'project_task'";
1137 1137
 	}
1138 1138
 	if ($statut >= 0)
1139 1139
 	{
1140
-		$sql.= " AND p.fk_statut = ".$statut;
1140
+		$sql .= " AND p.fk_statut = ".$statut;
1141 1141
 	}
1142 1142
 	if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE))
1143 1143
 	{
@@ -1149,40 +1149,40 @@  discard block
 block discarded – undo
1149 1149
 			{
1150 1150
 				$project_year_filter = date("Y");
1151 1151
 			}
1152
-			$sql.= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter,12,false)).")";
1153
-			$sql.= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter,1,false)).")";
1152
+			$sql .= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")";
1153
+			$sql .= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter, 1, false)).")";
1154 1154
 		}
1155 1155
 	}
1156 1156
 
1157 1157
 	// Get id of project we must show tasks
1158
-	$arrayidofprojects=array();
1158
+	$arrayidofprojects = array();
1159 1159
 	$sql1 = "SELECT p.rowid as projectid";
1160
-	$sql1.= $sql;
1160
+	$sql1 .= $sql;
1161 1161
 	$resql = $db->query($sql1);
1162 1162
 	if ($resql)
1163 1163
 	{
1164
-	    $i=0;
1164
+	    $i = 0;
1165 1165
 		$num = $db->num_rows($resql);
1166 1166
 		while ($i < $num)
1167 1167
 		{
1168 1168
 			$objp = $db->fetch_object($resql);
1169
-            $arrayidofprojects[$objp->projectid]=$objp->projectid;
1169
+            $arrayidofprojects[$objp->projectid] = $objp->projectid;
1170 1170
 			$i++;
1171 1171
 		}
1172 1172
 	}
1173 1173
 	else dol_print_error($db);
1174
-	if (empty($arrayidofprojects)) $arrayidofprojects[0]=-1;
1174
+	if (empty($arrayidofprojects)) $arrayidofprojects[0] = -1;
1175 1175
 
1176 1176
 	// Get list of project with calculation on tasks
1177 1177
 	$sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount,";
1178
-	$sql2.= " p.dateo, p.datee,";
1179
-	$sql2.= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload";
1180
-	$sql2.= " FROM ".MAIN_DB_PREFIX."projet as p";
1181
-	$sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
1182
-	$sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
1183
-	$sql2.= " WHERE p.rowid IN (".join(',',$arrayidofprojects).")";
1184
-	$sql2.= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount, p.dateo, p.datee";
1185
-	$sql2.= " ORDER BY p.title, p.ref";
1178
+	$sql2 .= " p.dateo, p.datee,";
1179
+	$sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload";
1180
+	$sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p";
1181
+	$sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
1182
+	$sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
1183
+	$sql2 .= " WHERE p.rowid IN (".join(',', $arrayidofprojects).")";
1184
+	$sql2 .= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount, p.dateo, p.datee";
1185
+	$sql2 .= " ORDER BY p.title, p.ref";
1186 1186
 
1187 1187
 	$resql = $db->query($sql2);
1188 1188
 	if ($resql)
@@ -1195,20 +1195,20 @@  discard block
 block discarded – undo
1195 1195
 		$i = 0;
1196 1196
 
1197 1197
     	print '<tr class="liste_titre">';
1198
-    	print_liste_field_titre($title.' <span class="badge">'.$num.'</span>',$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
1199
-    	print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
1200
-    	if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1198
+    	print_liste_field_titre($title.' <span class="badge">'.$num.'</span>', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
1199
+    	print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
1200
+    	if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1201 1201
     	{
1202
-    		print_liste_field_titre("OpportunityAmount","","","","",'align="right"',$sortfield,$sortorder);
1203
-    		print_liste_field_titre("OpportunityStatus","","","","",'align="right"',$sortfield,$sortorder);
1202
+    		print_liste_field_titre("OpportunityAmount", "", "", "", "", 'align="right"', $sortfield, $sortorder);
1203
+    		print_liste_field_titre("OpportunityStatus", "", "", "", "", 'align="right"', $sortfield, $sortorder);
1204 1204
     	}
1205 1205
     	if (empty($conf->global->PROJECT_HIDE_TASKS))
1206 1206
     	{
1207
-            print_liste_field_titre("Tasks","","","","",'align="right"',$sortfield,$sortorder);
1208
-            if (! in_array('plannedworkload', $hiddenfields))  print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder);
1209
-            if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder);
1207
+            print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder);
1208
+            if (!in_array('plannedworkload', $hiddenfields))  print_liste_field_titre("PlannedWorkload", "", "", "", "", 'align="right"', $sortfield, $sortorder);
1209
+            if (!in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared", "", "", "", "", 'align="right"', $sortfield, $sortorder);
1210 1210
     	}
1211
-    	print_liste_field_titre("Status","","","","",'align="right"',$sortfield,$sortorder);
1211
+    	print_liste_field_titre("Status", "", "", "", "", 'align="right"', $sortfield, $sortorder);
1212 1212
     	print "</tr>\n";
1213 1213
 
1214 1214
 		while ($i < $num)
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
 			$userAccess = $projectstatic->restrictedProjectArea($user);
1224 1224
 			if ($userAccess >= 0)
1225 1225
 			{
1226
-			    $projectstatic->ref=$objp->ref;
1226
+			    $projectstatic->ref = $objp->ref;
1227 1227
 			    $projectstatic->statut = $objp->status;
1228 1228
 			    $projectstatic->title = $objp->title;
1229 1229
 			    $projectstatic->datee = $db->jdate($objp->datee);
@@ -1233,18 +1233,18 @@  discard block
 block discarded – undo
1233 1233
 				print '<tr class="oddeven">';
1234 1234
 				print '<td>';
1235 1235
 				print $projectstatic->getNomUrl(1);
1236
-				if (! in_array('projectlabel', $hiddenfields)) print '<br>'.dol_trunc($objp->title,24);
1236
+				if (!in_array('projectlabel', $hiddenfields)) print '<br>'.dol_trunc($objp->title, 24);
1237 1237
 				print '</td>';
1238 1238
 				print '<td>';
1239 1239
 				if ($objp->fk_soc > 0)
1240 1240
 				{
1241
-    				$thirdpartystatic->id=$objp->fk_soc;
1242
-    				$thirdpartystatic->ref=$objp->socname;
1243
-    				$thirdpartystatic->name=$objp->socname;
1241
+    				$thirdpartystatic->id = $objp->fk_soc;
1242
+    				$thirdpartystatic->ref = $objp->socname;
1243
+    				$thirdpartystatic->name = $objp->socname;
1244 1244
     				print $thirdpartystatic->getNomUrl(1);
1245 1245
 				}
1246 1246
 				print '</td>';
1247
-				if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1247
+				if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1248 1248
 				{
1249 1249
 					print '<td align="right">';
1250 1250
         			if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency);
@@ -1258,19 +1258,19 @@  discard block
 block discarded – undo
1258 1258
 				{
1259 1259
 				    print '<td align="right">'.$objp->nb.'</td>';
1260 1260
 
1261
-    				$plannedworkload=$objp->planned_workload;
1262
-    				$total_plannedworkload+=$plannedworkload;
1263
-    				if (! in_array('plannedworkload', $hiddenfields))
1261
+    				$plannedworkload = $objp->planned_workload;
1262
+    				$total_plannedworkload += $plannedworkload;
1263
+    				if (!in_array('plannedworkload', $hiddenfields))
1264 1264
     				{
1265
-    				    print '<td align="right">'.($plannedworkload?convertSecondToTime($plannedworkload):'').'</td>';
1265
+    				    print '<td align="right">'.($plannedworkload ?convertSecondToTime($plannedworkload) : '').'</td>';
1266 1266
     				}
1267
-    				if (! in_array('declaredprogress', $hiddenfields))
1267
+    				if (!in_array('declaredprogress', $hiddenfields))
1268 1268
     				{
1269
-    				    $declaredprogressworkload=$objp->declared_progess_workload;
1270
-        				$total_declaredprogressworkload+=$declaredprogressworkload;
1269
+    				    $declaredprogressworkload = $objp->declared_progess_workload;
1270
+        				$total_declaredprogressworkload += $declaredprogressworkload;
1271 1271
         				print '<td align="right">';
1272 1272
         				//print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>";
1273
-        				print ($plannedworkload?round(100*$declaredprogressworkload/$plannedworkload,0).'%':'');
1273
+        				print ($plannedworkload ?round(100 * $declaredprogressworkload / $plannedworkload, 0).'%' : '');
1274 1274
         				print '</td>';
1275 1275
     				}
1276 1276
 				}
@@ -1288,7 +1288,7 @@  discard block
 block discarded – undo
1288 1288
 
1289 1289
 		print '<tr class="liste_total">';
1290 1290
 		print '<td colspan="2">'.$langs->trans("Total")."</td>";
1291
-		if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1291
+		if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1292 1292
 		{
1293 1293
 			print '<td class="liste_total" align="right">'.price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency).'</td>';
1294 1294
 			print '<td class="liste_total" align="right">'.$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1).'</td>';
@@ -1296,8 +1296,8 @@  discard block
 block discarded – undo
1296 1296
 		if (empty($conf->global->PROJECT_HIDE_TASKS))
1297 1297
 		{
1298 1298
             print '<td class="liste_total" align="right">'.$total_task.'</td>';
1299
-            if (! in_array('plannedworkload', $hiddenfields))  print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>';
1300
-            if (! in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>';
1299
+            if (!in_array('plannedworkload', $hiddenfields))  print '<td class="liste_total" align="right">'.($total_plannedworkload ?convertSecondToTime($total_plannedworkload) : '').'</td>';
1300
+            if (!in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).'%' : '').'</td>';
1301 1301
 		}
1302 1302
 		print '<td class="liste_total"></td>';
1303 1303
         print '</tr>';
Please login to merge, or discard this patch.