@@ -35,8 +35,8 @@ |
||
35 | 35 | // Security check |
36 | 36 | if (empty($conf->clicktodial->enabled)) |
37 | 37 | { |
38 | - print "Error: Module Click to dial is not enabled.\n"; |
|
39 | - exit; |
|
38 | + print "Error: Module Click to dial is not enabled.\n"; |
|
39 | + exit; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | // Check parameters |
@@ -52,15 +52,15 @@ |
||
52 | 52 | */ |
53 | 53 | public $fk_prod_attr_val; |
54 | 54 | |
55 | - /** |
|
56 | - * Constructor |
|
57 | - * |
|
58 | - * @param DoliDB $db Database handler |
|
59 | - */ |
|
60 | - public function __construct(DoliDB $db) |
|
61 | - { |
|
62 | - $this->db = $db; |
|
63 | - } |
|
55 | + /** |
|
56 | + * Constructor |
|
57 | + * |
|
58 | + * @param DoliDB $db Database handler |
|
59 | + */ |
|
60 | + public function __construct(DoliDB $db) |
|
61 | + { |
|
62 | + $this->db = $db; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Translates this class to a human-readable string |
@@ -92,10 +92,18 @@ |
||
92 | 92 | global $langs; |
93 | 93 | $langs->load("admin"); |
94 | 94 | |
95 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
96 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
97 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
98 | - if ($this->version) return $this->version; |
|
95 | + if ($this->version == 'development') { |
|
96 | + return $langs->trans("VersionDevelopment"); |
|
97 | + } |
|
98 | + if ($this->version == 'experimental') { |
|
99 | + return $langs->trans("VersionExperimental"); |
|
100 | + } |
|
101 | + if ($this->version == 'dolibarr') { |
|
102 | + return DOL_VERSION; |
|
103 | + } |
|
104 | + if ($this->version) { |
|
105 | + return $this->version; |
|
106 | + } |
|
99 | 107 | return $langs->trans("NotAvailable"); |
100 | 108 | } |
101 | 109 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | print '<div name="topofform"></div><br>'; |
98 | 98 | print load_fiche_titre($langs->trans('NewAttribute')); |
99 | 99 | |
100 | - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; |
|
100 | + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /* ************************************************************************** */ |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | print '<div name="topofform"></div><br>'; |
111 | 111 | print load_fiche_titre($langs->trans("FieldEdition", $attrname)); |
112 | 112 | |
113 | - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; |
|
113 | + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | // End of page |
@@ -37,13 +37,17 @@ |
||
37 | 37 | // List of supported format |
38 | 38 | $tmptype2label = ExtraFields::$type2label; |
39 | 39 | $type2label = array(''); |
40 | -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); |
|
40 | +foreach ($tmptype2label as $key => $val) { |
|
41 | + $type2label[$key] = $langs->transnoentitiesnoconv($val); |
|
42 | +} |
|
41 | 43 | |
42 | 44 | $action = GETPOST('action', 'aZ09'); |
43 | 45 | $attrname = GETPOST('attrname', 'alpha'); |
44 | 46 | $elementtype = 'adherent'; //Must be the $table_element of the class that manage extrafield |
45 | 47 | |
46 | -if (!$user->admin) accessforbidden(); |
|
48 | +if (!$user->admin) { |
|
49 | + accessforbidden(); |
|
50 | +} |
|
47 | 51 | |
48 | 52 | |
49 | 53 | /* |
@@ -33,10 +33,10 @@ |
||
33 | 33 | |
34 | 34 | if (empty($conf->holiday->enabled)) |
35 | 35 | { |
36 | - llxHeader('', $langs->trans('CPTitreMenu')); |
|
37 | - print '<div class="tabBar">'; |
|
38 | - print '<span style="color: #FF0000;">'.$langs->trans('NotActiveModCP').'</span>'; |
|
39 | - print '</div>'; |
|
40 | - llxFooter(); |
|
41 | - exit(); |
|
36 | + llxHeader('', $langs->trans('CPTitreMenu')); |
|
37 | + print '<div class="tabBar">'; |
|
38 | + print '<span style="color: #FF0000;">'.$langs->trans('NotActiveModCP').'</span>'; |
|
39 | + print '</div>'; |
|
40 | + llxFooter(); |
|
41 | + exit(); |
|
42 | 42 | } |
@@ -29,14 +29,14 @@ |
||
29 | 29 | $idcontact = GETPOST('idc'); |
30 | 30 | |
31 | 31 | if (!empty($idcontact)) { |
32 | - $contact = new Contact($db); |
|
33 | - $contact->fetch($idcontact); |
|
34 | - DataPolicy::sendMailDataPolicyContact($contact); |
|
32 | + $contact = new Contact($db); |
|
33 | + $contact->fetch($idcontact); |
|
34 | + DataPolicy::sendMailDataPolicyContact($contact); |
|
35 | 35 | } else { |
36 | 36 | |
37 | - $contacts = new DataPolicy($db); |
|
38 | - $contacts->getAllContactNotInformed(); |
|
39 | - $contacts->getAllCompaniesNotInformed(); |
|
40 | - $contacts->getAllAdherentsNotInformed(); |
|
41 | - echo $langs->trans('AllAgreementSend'); |
|
37 | + $contacts = new DataPolicy($db); |
|
38 | + $contacts->getAllContactNotInformed(); |
|
39 | + $contacts->getAllCompaniesNotInformed(); |
|
40 | + $contacts->getAllAdherentsNotInformed(); |
|
41 | + echo $langs->trans('AllAgreementSend'); |
|
42 | 42 | } |
@@ -68,22 +68,22 @@ discard block |
||
68 | 68 | * @param string $url Root URL for the shop |
69 | 69 | * @param string $key Authentification key |
70 | 70 | * @param mixed $debug Debug mode Activated (true) or deactivated (false) |
71 | - */ |
|
72 | - public function __construct($url, $key, $debug = true) |
|
73 | - { |
|
71 | + */ |
|
72 | + public function __construct($url, $key, $debug = true) |
|
73 | + { |
|
74 | 74 | if (!extension_loaded('curl')) |
75 | 75 | throw new PrestaShopWebserviceException('Please activate the PHP extension \'curl\' to allow use of PrestaShop webservice library'); |
76 | 76 | $this->url = $url; |
77 | 77 | $this->key = $key; |
78 | 78 | $this->debug = $debug; |
79 | 79 | $this->version = 'unknown'; |
80 | - } |
|
80 | + } |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Take the status code and throw an exception if the server didn't return 200 or 201 code |
84 | 84 | * |
85 | 85 | * @param int $status_code Status code of an HTTP return |
86 | - * @return void |
|
86 | + * @return void |
|
87 | 87 | */ |
88 | 88 | protected function checkStatusCode($status_code) |
89 | 89 | { |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
274 | - * Retrieve (GET) a resource |
|
274 | + * Retrieve (GET) a resource |
|
275 | 275 | * <p>Unique parameter must take : <br><br> |
276 | 276 | * 'url' => Full URL for a GET request of Webservice (ex: http://mystore.com/api/customers/1/)<br> |
277 | 277 | * OR<br> |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
329 | - * Head method (HEAD) a resource |
|
329 | + * Head method (HEAD) a resource |
|
330 | 330 | * |
331 | 331 | * @param array $options Array representing resource for head request. |
332 | 332 | * @return SimpleXMLElement status_code, response |
@@ -71,8 +71,9 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function __construct($url, $key, $debug = true) |
73 | 73 | { |
74 | - if (!extension_loaded('curl')) |
|
75 | - throw new PrestaShopWebserviceException('Please activate the PHP extension \'curl\' to allow use of PrestaShop webservice library'); |
|
74 | + if (!extension_loaded('curl')) { |
|
75 | + throw new PrestaShopWebserviceException('Please activate the PHP extension \'curl\' to allow use of PrestaShop webservice library'); |
|
76 | + } |
|
76 | 77 | $this->url = $url; |
77 | 78 | $this->key = $key; |
78 | 79 | $this->debug = $debug; |
@@ -134,23 +135,25 @@ discard block |
||
134 | 135 | $curl_options = array(); |
135 | 136 | foreach ($defaultParams as $defkey => $defval) |
136 | 137 | { |
137 | - if (isset($curl_params[$defkey])) |
|
138 | - $curl_options[$defkey] = $curl_params[$defkey]; |
|
139 | - else { |
|
138 | + if (isset($curl_params[$defkey])) { |
|
139 | + $curl_options[$defkey] = $curl_params[$defkey]; |
|
140 | + } else { |
|
140 | 141 | $curl_options[$defkey] = $defaultParams[$defkey]; |
141 | 142 | } |
142 | 143 | } |
143 | - foreach ($curl_params as $defkey => $defval) |
|
144 | - if (!isset($curl_options[$defkey])) |
|
144 | + foreach ($curl_params as $defkey => $defval) { |
|
145 | + if (!isset($curl_options[$defkey])) |
|
145 | 146 | $curl_options[$defkey] = $curl_params[$defkey]; |
147 | + } |
|
146 | 148 | |
147 | 149 | dol_syslog("curl curl_options = ".var_export($curl_options, true)); |
148 | 150 | curl_setopt_array($session, $curl_options); |
149 | 151 | $response = curl_exec($session); |
150 | 152 | |
151 | 153 | $index = strpos($response, "\r\n\r\n"); |
152 | - if ($index === false && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') |
|
153 | - throw new PrestaShopWebserviceException('Bad HTTP response'); |
|
154 | + if ($index === false && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') { |
|
155 | + throw new PrestaShopWebserviceException('Bad HTTP response'); |
|
156 | + } |
|
154 | 157 | |
155 | 158 | $header = substr($response, 0, $index); |
156 | 159 | $body = substr($response, $index + 4); |
@@ -162,8 +165,9 @@ discard block |
||
162 | 165 | { |
163 | 166 | $tmp = explode(':', $headerItem); |
164 | 167 | $tmp = array_map('trim', $tmp); |
165 | - if (count($tmp) == 2) |
|
166 | - $headerArray[$tmp[0]] = $tmp[1]; |
|
168 | + if (count($tmp) == 2) { |
|
169 | + $headerArray[$tmp[0]] = $tmp[1]; |
|
170 | + } |
|
167 | 171 | } |
168 | 172 | |
169 | 173 | if (array_key_exists('PSWS-Version', $headerArray)) |
@@ -172,8 +176,9 @@ discard block |
||
172 | 176 | if ( |
173 | 177 | version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMIN, $headerArray['PSWS-Version']) == 1 || |
174 | 178 | version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMAX, $headerArray['PSWS-Version']) == -1 |
175 | - ) |
|
176 | - throw new PrestaShopWebserviceException('This library is not compatible with this version of PrestaShop. Please upgrade/downgrade this library'); |
|
179 | + ) { |
|
180 | + throw new PrestaShopWebserviceException('This library is not compatible with this version of PrestaShop. Please upgrade/downgrade this library'); |
|
181 | + } |
|
177 | 182 | } |
178 | 183 | |
179 | 184 | if ($this->debug) |
@@ -182,15 +187,18 @@ discard block |
||
182 | 187 | $this->printDebug('HTTP RESPONSE HEADER', $header); |
183 | 188 | } |
184 | 189 | $status_code = curl_getinfo($session, CURLINFO_HTTP_CODE); |
185 | - if ($status_code === 0) |
|
186 | - throw new PrestaShopWebserviceException('CURL Error: '.curl_error($session)); |
|
190 | + if ($status_code === 0) { |
|
191 | + throw new PrestaShopWebserviceException('CURL Error: '.curl_error($session)); |
|
192 | + } |
|
187 | 193 | curl_close($session); |
188 | 194 | if ($this->debug) |
189 | 195 | { |
190 | - if ($curl_params[CURLOPT_CUSTOMREQUEST] == 'PUT' || $curl_params[CURLOPT_CUSTOMREQUEST] == 'POST') |
|
191 | - $this->printDebug('XML SENT', urldecode($curl_params[CURLOPT_POSTFIELDS])); |
|
192 | - if ($curl_params[CURLOPT_CUSTOMREQUEST] != 'DELETE' && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') |
|
193 | - $this->printDebug('RETURN HTTP BODY', $body); |
|
196 | + if ($curl_params[CURLOPT_CUSTOMREQUEST] == 'PUT' || $curl_params[CURLOPT_CUSTOMREQUEST] == 'POST') { |
|
197 | + $this->printDebug('XML SENT', urldecode($curl_params[CURLOPT_POSTFIELDS])); |
|
198 | + } |
|
199 | + if ($curl_params[CURLOPT_CUSTOMREQUEST] != 'DELETE' && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') { |
|
200 | + $this->printDebug('RETURN HTTP BODY', $body); |
|
201 | + } |
|
194 | 202 | } |
195 | 203 | return array('status_code' => $status_code, 'response' => $body, 'header' => $header); |
196 | 204 | } |
@@ -261,10 +269,12 @@ discard block |
||
261 | 269 | { |
262 | 270 | $url = (isset($options['resource']) ? $this->url.'/api/'.$options['resource'] : $options['url']); |
263 | 271 | $xml = $options['postXml']; |
264 | - if (isset($options['id_shop'])) |
|
265 | - $url .= '&id_shop='.$options['id_shop']; |
|
266 | - if (isset($options['id_group_shop'])) |
|
267 | - $url .= '&id_group_shop='.$options['id_group_shop']; |
|
272 | + if (isset($options['id_shop'])) { |
|
273 | + $url .= '&id_shop='.$options['id_shop']; |
|
274 | + } |
|
275 | + if (isset($options['id_group_shop'])) { |
|
276 | + $url .= '&id_group_shop='.$options['id_group_shop']; |
|
277 | + } |
|
268 | 278 | } else { |
269 | 279 | throw new PrestaShopWebserviceException('Bad parameters given'); |
270 | 280 | } |
@@ -304,24 +314,27 @@ discard block |
||
304 | 314 | */ |
305 | 315 | public function get($options) |
306 | 316 | { |
307 | - if (isset($options['url'])) |
|
308 | - $url = $options['url']; |
|
309 | - elseif (isset($options['resource'])) |
|
317 | + if (isset($options['url'])) { |
|
318 | + $url = $options['url']; |
|
319 | + } elseif (isset($options['resource'])) |
|
310 | 320 | { |
311 | 321 | $url = $this->url.'/api/'.$options['resource']; |
312 | 322 | $url_params = array(); |
313 | - if (isset($options['id'])) |
|
314 | - $url .= '/'.$options['id']; |
|
323 | + if (isset($options['id'])) { |
|
324 | + $url .= '/'.$options['id']; |
|
325 | + } |
|
315 | 326 | |
316 | 327 | // @CHANGE LDR |
317 | 328 | //$params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop'); |
318 | 329 | $params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop', 'date'); |
319 | - foreach ($params as $p) |
|
320 | - foreach ($options as $k => $o) |
|
330 | + foreach ($params as $p) { |
|
331 | + foreach ($options as $k => $o) |
|
321 | 332 | if (strpos($k, $p) !== false) |
322 | 333 | $url_params[$k] = $options[$k]; |
323 | - if (count($url_params) > 0) |
|
324 | - $url .= '?'.http_build_query($url_params); |
|
334 | + } |
|
335 | + if (count($url_params) > 0) { |
|
336 | + $url .= '?'.http_build_query($url_params); |
|
337 | + } |
|
325 | 338 | } else { |
326 | 339 | throw new PrestaShopWebserviceException('Bad parameters given '); |
327 | 340 | } |
@@ -339,22 +352,25 @@ discard block |
||
339 | 352 | */ |
340 | 353 | public function head($options) |
341 | 354 | { |
342 | - if (isset($options['url'])) |
|
343 | - $url = $options['url']; |
|
344 | - elseif (isset($options['resource'])) |
|
355 | + if (isset($options['url'])) { |
|
356 | + $url = $options['url']; |
|
357 | + } elseif (isset($options['resource'])) |
|
345 | 358 | { |
346 | 359 | $url = $this->url.'/api/'.$options['resource']; |
347 | 360 | $url_params = array(); |
348 | - if (isset($options['id'])) |
|
349 | - $url .= '/'.$options['id']; |
|
361 | + if (isset($options['id'])) { |
|
362 | + $url .= '/'.$options['id']; |
|
363 | + } |
|
350 | 364 | |
351 | 365 | $params = array('filter', 'display', 'sort', 'limit'); |
352 | - foreach ($params as $p) |
|
353 | - foreach ($options as $k => $o) |
|
366 | + foreach ($params as $p) { |
|
367 | + foreach ($options as $k => $o) |
|
354 | 368 | if (strpos($k, $p) !== false) |
355 | 369 | $url_params[$k] = $options[$k]; |
356 | - if (count($url_params) > 0) |
|
357 | - $url .= '?'.http_build_query($url_params); |
|
370 | + } |
|
371 | + if (count($url_params) > 0) { |
|
372 | + $url .= '?'.http_build_query($url_params); |
|
373 | + } |
|
358 | 374 | } else { |
359 | 375 | throw new PrestaShopWebserviceException('Bad parameters given'); |
360 | 376 | } |
@@ -376,16 +392,18 @@ discard block |
||
376 | 392 | public function edit($options) |
377 | 393 | { |
378 | 394 | $xml = ''; |
379 | - if (isset($options['url'])) |
|
380 | - $url = $options['url']; |
|
381 | - elseif ((isset($options['resource'], $options['id']) || isset($options['url'])) && $options['putXml']) |
|
395 | + if (isset($options['url'])) { |
|
396 | + $url = $options['url']; |
|
397 | + } elseif ((isset($options['resource'], $options['id']) || isset($options['url'])) && $options['putXml']) |
|
382 | 398 | { |
383 | 399 | $url = (isset($options['url']) ? $options['url'] : $this->url.'/api/'.$options['resource'].'/'.$options['id']); |
384 | 400 | $xml = $options['putXml']; |
385 | - if (isset($options['id_shop'])) |
|
386 | - $url .= '&id_shop='.$options['id_shop']; |
|
387 | - if (isset($options['id_group_shop'])) |
|
388 | - $url .= '&id_group_shop='.$options['id_group_shop']; |
|
401 | + if (isset($options['id_shop'])) { |
|
402 | + $url .= '&id_shop='.$options['id_shop']; |
|
403 | + } |
|
404 | + if (isset($options['id_group_shop'])) { |
|
405 | + $url .= '&id_group_shop='.$options['id_group_shop']; |
|
406 | + } |
|
389 | 407 | } else { |
390 | 408 | throw new PrestaShopWebserviceException('Bad parameters given'); |
391 | 409 | } |
@@ -24,25 +24,25 @@ |
||
24 | 24 | */ |
25 | 25 | class ProjectStats extends Stats |
26 | 26 | { |
27 | - private $project; |
|
28 | - public $userid; |
|
29 | - public $socid; |
|
30 | - public $year; |
|
31 | - |
|
32 | - /** |
|
33 | - * Constructor |
|
34 | - * |
|
35 | - * @param DoliDB $db Database handler |
|
36 | - */ |
|
37 | - public function __construct($db) |
|
38 | - { |
|
39 | - global $conf, $user; |
|
40 | - |
|
41 | - $this->db = $db; |
|
42 | - |
|
43 | - require_once 'project.class.php'; |
|
44 | - $this->project = new Project($this->db); |
|
45 | - } |
|
27 | + private $project; |
|
28 | + public $userid; |
|
29 | + public $socid; |
|
30 | + public $year; |
|
31 | + |
|
32 | + /** |
|
33 | + * Constructor |
|
34 | + * |
|
35 | + * @param DoliDB $db Database handler |
|
36 | + */ |
|
37 | + public function __construct($db) |
|
38 | + { |
|
39 | + global $conf, $user; |
|
40 | + |
|
41 | + $this->db = $db; |
|
42 | + |
|
43 | + require_once 'project.class.php'; |
|
44 | + $this->project = new Project($this->db); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | 48 | /** |
@@ -92,14 +92,17 @@ discard block |
||
92 | 92 | $label.' ('.price(price2num($row[0], 'MT'), 1, $langs, 1, -1, -1, $conf->currency).')', |
93 | 93 | $row[0] |
94 | 94 | ); |
95 | - } else $other += $row[1]; |
|
95 | + } else { |
|
96 | + $other += $row[1]; |
|
97 | + } |
|
96 | 98 | $i++; |
97 | 99 | } |
98 | - if ($num > $limit) |
|
99 | - $result[$i] = array( |
|
100 | + if ($num > $limit) { |
|
101 | + $result[$i] = array( |
|
100 | 102 | $langs->transnoentitiesnoconv("Other"), |
101 | 103 | $other |
102 | 104 | ); |
105 | + } |
|
103 | 106 | $this->db->free($resql); |
104 | 107 | } else { |
105 | 108 | $this->error = "Error ".$this->db->lasterror(); |
@@ -156,25 +159,35 @@ discard block |
||
156 | 159 | // Get list of project id allowed to user (in a string list separated by coma) |
157 | 160 | $object = new Project($this->db); |
158 | 161 | $projectsListId = ''; |
159 | - if (!$user->rights->projet->all->lire) $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $user->socid); |
|
162 | + if (!$user->rights->projet->all->lire) { |
|
163 | + $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $user->socid); |
|
164 | + } |
|
160 | 165 | |
161 | 166 | $sqlwhere[] = ' t.entity IN ('.getEntity('project').')'; |
162 | 167 | |
163 | - if (!empty($this->userid)) |
|
164 | - $sqlwhere[] = ' t.fk_user_resp='.$this->userid; |
|
168 | + if (!empty($this->userid)) { |
|
169 | + $sqlwhere[] = ' t.fk_user_resp='.$this->userid; |
|
170 | + } |
|
165 | 171 | |
166 | 172 | // Forced filter on socid is similar to forced filter on project. TODO Use project assignement to allow to not use filter on project |
167 | - if (!empty($this->socid)) |
|
168 | - $sqlwhere[] = ' t.fk_soc='.$this->socid; |
|
169 | - if (!empty($this->year) && empty($this->yearmonth)) |
|
170 | - $sqlwhere[] = " date_format(t.datec,'%Y')='".$this->db->escape($this->year)."'"; |
|
171 | - if (!empty($this->yearmonth)) |
|
172 | - $sqlwhere[] = " t.datec BETWEEN '".$this->db->idate(dol_get_first_day($this->yearmonth))."' AND '".$this->db->idate(dol_get_last_day($this->yearmonth))."'"; |
|
173 | + if (!empty($this->socid)) { |
|
174 | + $sqlwhere[] = ' t.fk_soc='.$this->socid; |
|
175 | + } |
|
176 | + if (!empty($this->year) && empty($this->yearmonth)) { |
|
177 | + $sqlwhere[] = " date_format(t.datec,'%Y')='".$this->db->escape($this->year)."'"; |
|
178 | + } |
|
179 | + if (!empty($this->yearmonth)) { |
|
180 | + $sqlwhere[] = " t.datec BETWEEN '".$this->db->idate(dol_get_first_day($this->yearmonth))."' AND '".$this->db->idate(dol_get_last_day($this->yearmonth))."'"; |
|
181 | + } |
|
173 | 182 | |
174 | - if (!empty($this->status)) |
|
175 | - $sqlwhere[] = " t.fk_opp_status IN (".$this->status.")"; |
|
183 | + if (!empty($this->status)) { |
|
184 | + $sqlwhere[] = " t.fk_opp_status IN (".$this->status.")"; |
|
185 | + } |
|
176 | 186 | |
177 | - if (!$user->rights->projet->all->lire) $sqlwhere[] = " t.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users |
|
187 | + if (!$user->rights->projet->all->lire) { |
|
188 | + $sqlwhere[] = " t.rowid IN (".$projectsListId.")"; |
|
189 | + } |
|
190 | + // public and assigned to, or restricted to company for external users |
|
178 | 191 | |
179 | 192 | if (count($sqlwhere) > 0) { |
180 | 193 | $sqlwhere_str = ' WHERE '.implode(' AND ', $sqlwhere); |
@@ -254,7 +267,9 @@ discard block |
||
254 | 267 | { |
255 | 268 | global $conf, $user, $langs; |
256 | 269 | |
257 | - if ($startyear > $endyear) return -1; |
|
270 | + if ($startyear > $endyear) { |
|
271 | + return -1; |
|
272 | + } |
|
258 | 273 | |
259 | 274 | $datay = array(); |
260 | 275 | |
@@ -285,9 +300,11 @@ discard block |
||
285 | 300 | } |
286 | 301 | |
287 | 302 | // Load file into $data |
288 | - if ($foundintocache) // Cache file found and is not too old |
|
303 | + if ($foundintocache) { |
|
304 | + // Cache file found and is not too old |
|
289 | 305 | { |
290 | 306 | dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate."."); |
307 | + } |
|
291 | 308 | $data = json_decode(file_get_contents($newpathofdestfile), true); |
292 | 309 | } else { |
293 | 310 | $year = $startyear; |
@@ -315,15 +332,21 @@ discard block |
||
315 | 332 | if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == -1)) |
316 | 333 | { |
317 | 334 | dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk."); |
318 | - if (!dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp); |
|
335 | + if (!dol_is_dir($conf->user->dir_temp)) { |
|
336 | + dol_mkdir($conf->user->dir_temp); |
|
337 | + } |
|
319 | 338 | $fp = fopen($newpathofdestfile, 'w'); |
320 | 339 | if ($fp) |
321 | 340 | { |
322 | 341 | fwrite($fp, json_encode($data)); |
323 | 342 | fclose($fp); |
324 | - if (!empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK; |
|
343 | + if (!empty($conf->global->MAIN_UMASK)) { |
|
344 | + $newmask = $conf->global->MAIN_UMASK; |
|
345 | + } |
|
325 | 346 | @chmod($newpathofdestfile, octdec($newmask)); |
326 | - } else dol_syslog("Failed to write cache file", LOG_ERR); |
|
347 | + } else { |
|
348 | + dol_syslog("Failed to write cache file", LOG_ERR); |
|
349 | + } |
|
327 | 350 | $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt; |
328 | 351 | } |
329 | 352 | |
@@ -371,7 +394,9 @@ discard block |
||
371 | 394 | { |
372 | 395 | global $conf, $user, $langs; |
373 | 396 | |
374 | - if ($startyear > $endyear) return -1; |
|
397 | + if ($startyear > $endyear) { |
|
398 | + return -1; |
|
399 | + } |
|
375 | 400 | |
376 | 401 | $datay = array(); |
377 | 402 | |
@@ -400,9 +425,11 @@ discard block |
||
400 | 425 | } |
401 | 426 | |
402 | 427 | // Load file into $data |
403 | - if ($foundintocache) // Cache file found and is not too old |
|
428 | + if ($foundintocache) { |
|
429 | + // Cache file found and is not too old |
|
404 | 430 | { |
405 | 431 | dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate."."); |
432 | + } |
|
406 | 433 | $data = json_decode(file_get_contents($newpathofdestfile), true); |
407 | 434 | } else { |
408 | 435 | $year = $startyear; |
@@ -426,13 +453,15 @@ discard block |
||
426 | 453 | // Save cache file |
427 | 454 | if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == - 1)) { |
428 | 455 | dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk."); |
429 | - if (!dol_is_dir($conf->user->dir_temp)) |
|
430 | - dol_mkdir($conf->user->dir_temp); |
|
456 | + if (!dol_is_dir($conf->user->dir_temp)) { |
|
457 | + dol_mkdir($conf->user->dir_temp); |
|
458 | + } |
|
431 | 459 | $fp = fopen($newpathofdestfile, 'w'); |
432 | 460 | fwrite($fp, json_encode($data)); |
433 | 461 | fclose($fp); |
434 | - if (!empty($conf->global->MAIN_UMASK)) |
|
435 | - $newmask = $conf->global->MAIN_UMASK; |
|
462 | + if (!empty($conf->global->MAIN_UMASK)) { |
|
463 | + $newmask = $conf->global->MAIN_UMASK; |
|
464 | + } |
|
436 | 465 | @chmod($newpathofdestfile, octdec($newmask)); |
437 | 466 | |
438 | 467 | $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt; |
@@ -27,10 +27,10 @@ |
||
27 | 27 | */ |
28 | 28 | class DolException extends Exception |
29 | 29 | { |
30 | - /** |
|
31 | - * Constructor |
|
32 | - */ |
|
33 | - public function __construct() |
|
34 | - { |
|
35 | - } |
|
30 | + /** |
|
31 | + * Constructor |
|
32 | + */ |
|
33 | + public function __construct() |
|
34 | + { |
|
35 | + } |
|
36 | 36 | } |