@@ -82,8 +82,7 @@ discard block |
||
82 | 82 | { |
83 | 83 | $options = $this->options_cache[$usecache]; |
84 | 84 | $selected=$selectid; |
85 | - } |
|
86 | - else |
|
85 | + } else |
|
87 | 86 | { |
88 | 87 | $sql = "SELECT rowid, code, label, nature, entity, active"; |
89 | 88 | $sql.= " FROM " . MAIN_DB_PREFIX . "accounting_journal"; |
@@ -168,17 +167,20 @@ discard block |
||
168 | 167 | $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; |
169 | 168 | $sql.= " WHERE c.active = 1"; |
170 | 169 | $sql.= " AND c.category_type = 0"; |
171 | - if (empty($allcountries)) $sql.= " AND c.fk_country = ".$mysoc->country_id; |
|
170 | + if (empty($allcountries)) { |
|
171 | + $sql.= " AND c.fk_country = ".$mysoc->country_id; |
|
172 | + } |
|
172 | 173 | $sql.= " ORDER BY c.label ASC"; |
173 | - } |
|
174 | - else |
|
174 | + } else |
|
175 | 175 | { |
176 | 176 | $sql = "SELECT c.rowid, c.label as type, c.range_account"; |
177 | 177 | $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c, ".MAIN_DB_PREFIX."c_country as co"; |
178 | 178 | $sql.= " WHERE c.active = 1"; |
179 | 179 | $sql.= " AND c.category_type = 0"; |
180 | 180 | $sql.= " AND c.fk_country = co.rowid"; |
181 | - if (empty($allcountries)) $sql.= " AND co.code = '".$mysoc->country_code."'"; |
|
181 | + if (empty($allcountries)) { |
|
182 | + $sql.= " AND co.code = '".$mysoc->country_code."'"; |
|
183 | + } |
|
182 | 184 | $sql.= " ORDER BY c.label ASC"; |
183 | 185 | } |
184 | 186 | |
@@ -192,25 +194,27 @@ discard block |
||
192 | 194 | $out = '<select class="flat minwidth200" id="'.$htmlname.'" name="'.$htmlname.'">'; |
193 | 195 | $i = 0; |
194 | 196 | |
195 | - if ($useempty) $out.= '<option value="0"> </option>'; |
|
197 | + if ($useempty) { |
|
198 | + $out.= '<option value="0"> </option>'; |
|
199 | + } |
|
196 | 200 | while ($i < $num) |
197 | 201 | { |
198 | 202 | $obj = $db->fetch_object($resql); |
199 | 203 | $out .= '<option value="'.$obj->rowid.'"'; |
200 | - if ($obj->rowid == $selected) $out .= ' selected'; |
|
204 | + if ($obj->rowid == $selected) { |
|
205 | + $out .= ' selected'; |
|
206 | + } |
|
201 | 207 | $out .= '>'.($maxlen ? dol_trunc($obj->type,$maxlen) : $obj->type); |
202 | 208 | $out .= ' ('.$obj->range_account.')'; |
203 | 209 | $i++; |
204 | 210 | } |
205 | 211 | $out .= '</select>'; |
206 | 212 | //if ($user->admin && $help) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
207 | - } |
|
208 | - else |
|
213 | + } else |
|
209 | 214 | { |
210 | 215 | $out .= $langs->trans("ErrorNoAccountingCategoryForThisCountry",$mysoc->country_code); |
211 | 216 | } |
212 | - } |
|
213 | - else |
|
217 | + } else |
|
214 | 218 | { |
215 | 219 | dol_print_error($db,$db->lasterror()); |
216 | 220 | } |
@@ -281,8 +285,7 @@ discard block |
||
281 | 285 | { |
282 | 286 | $options = $this->options_cache[$usecache]; |
283 | 287 | $selected=$selectid; |
284 | - } |
|
285 | - else |
|
288 | + } else |
|
286 | 289 | { |
287 | 290 | $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT) ? 50 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT; |
288 | 291 |
@@ -73,7 +73,9 @@ discard block |
||
73 | 73 | $newline .= $c; |
74 | 74 | } // end of for |
75 | 75 | $output .= $newline; |
76 | - if ($j<count($lines)-1) $output .= $linebreak; |
|
76 | + if ($j<count($lines)-1) { |
|
77 | + $output .= $linebreak; |
|
78 | + } |
|
77 | 79 | } |
78 | 80 | return trim($output); |
79 | 81 | } |
@@ -102,7 +104,9 @@ discard block |
||
102 | 104 | { |
103 | 105 | // type may be PREF | WORK | HOME | VOICE | FAX | MSG | CELL | PAGER | BBS | CAR | MODEM | ISDN | VIDEO or any senseful combination, e.g. "PREF;WORK;VOICE" |
104 | 106 | $key = "TEL"; |
105 | - if ($type!="") $key .= ";".$type; |
|
107 | + if ($type!="") { |
|
108 | + $key .= ";".$type; |
|
109 | + } |
|
106 | 110 | $key.= ";CHARSET=".$this->encoding; |
107 | 111 | $this->properties[$key] = encode($number); |
108 | 112 | } |
@@ -146,7 +150,9 @@ discard block |
||
146 | 150 | { |
147 | 151 | $this->properties["N;CHARSET=".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix); |
148 | 152 | $this->filename = "$first%20$family.vcf"; |
149 | - if (empty($this->properties["FN"])) $this->setFormattedName(trim("$prefix $first $additional $family $suffix")); |
|
153 | + if (empty($this->properties["FN"])) { |
|
154 | + $this->setFormattedName(trim("$prefix $first $additional $family $suffix")); |
|
155 | + } |
|
150 | 156 | } |
151 | 157 | |
152 | 158 | /** |
@@ -178,7 +184,9 @@ discard block |
||
178 | 184 | { |
179 | 185 | // $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL" |
180 | 186 | $key = "ADR"; |
181 | - if ($type!="") $key.= ";$type"; |
|
187 | + if ($type!="") { |
|
188 | + $key.= ";$type"; |
|
189 | + } |
|
182 | 190 | $key.= ";CHARSET=".$this->encoding; |
183 | 191 | $this->properties[$key] = ";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country); |
184 | 192 | |
@@ -204,13 +212,27 @@ discard block |
||
204 | 212 | function setLabel($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME;POSTAL") |
205 | 213 | { |
206 | 214 | $label = ""; |
207 | - if ($postoffice!="") $label.= "$postoffice\r\n"; |
|
208 | - if ($extended!="") $label.= "$extended\r\n"; |
|
209 | - if ($street!="") $label.= "$street\r\n"; |
|
210 | - if ($zip!="") $label.= "$zip "; |
|
211 | - if ($city!="") $label.= "$city\r\n"; |
|
212 | - if ($region!="") $label.= "$region\r\n"; |
|
213 | - if ($country!="") $country.= "$country\r\n"; |
|
215 | + if ($postoffice!="") { |
|
216 | + $label.= "$postoffice\r\n"; |
|
217 | + } |
|
218 | + if ($extended!="") { |
|
219 | + $label.= "$extended\r\n"; |
|
220 | + } |
|
221 | + if ($street!="") { |
|
222 | + $label.= "$street\r\n"; |
|
223 | + } |
|
224 | + if ($zip!="") { |
|
225 | + $label.= "$zip "; |
|
226 | + } |
|
227 | + if ($city!="") { |
|
228 | + $label.= "$city\r\n"; |
|
229 | + } |
|
230 | + if ($region!="") { |
|
231 | + $label.= "$region\r\n"; |
|
232 | + } |
|
233 | + if ($country!="") { |
|
234 | + $country.= "$country\r\n"; |
|
235 | + } |
|
214 | 236 | |
215 | 237 | $this->properties["LABEL;$type;CHARSET=".$this->encoding] = encode($label); |
216 | 238 | } |
@@ -297,7 +319,9 @@ discard block |
||
297 | 319 | { |
298 | 320 | // $type may be WORK | HOME |
299 | 321 | $key = "URL"; |
300 | - if ($type!="") $key.= ";$type"; |
|
322 | + if ($type!="") { |
|
323 | + $key.= ";$type"; |
|
324 | + } |
|
301 | 325 | $this->properties[$key] = $url; |
302 | 326 | } |
303 | 327 |
@@ -160,8 +160,7 @@ |
||
160 | 160 | $hauteur=abs($y1-$y2); |
161 | 161 | if($length>$hauteur) { |
162 | 162 | $Pointilles=($length/$nbPointilles)/2; // taille des pointilles |
163 | - } |
|
164 | - else { |
|
163 | + } else { |
|
165 | 164 | $Pointilles=($hauteur/$nbPointilles)/2; |
166 | 165 | } |
167 | 166 | for($i=$x1;$i<=$x2;$i+=$Pointilles+$Pointilles) { |
@@ -79,8 +79,7 @@ discard block |
||
79 | 79 | $sql.= " WHERE c.active = 1"; |
80 | 80 | $sql.= " AND c.fk_pays = ".$mysoc->country_id; |
81 | 81 | $sql.= " ORDER BY c.libelle ASC"; |
82 | - } |
|
83 | - else |
|
82 | + } else |
|
84 | 83 | { |
85 | 84 | $sql = "SELECT c.id, c.libelle as type"; |
86 | 85 | $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."c_country as co"; |
@@ -99,25 +98,31 @@ discard block |
||
99 | 98 | print '<select class="'.($morecss?$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'">'; |
100 | 99 | $i = 0; |
101 | 100 | |
102 | - if ($useempty) print '<option value="0"> </option>'; |
|
101 | + if ($useempty) { |
|
102 | + print '<option value="0"> </option>'; |
|
103 | + } |
|
103 | 104 | while ($i < $num) |
104 | 105 | { |
105 | 106 | $obj = $db->fetch_object($resql); |
106 | 107 | print '<option value="'.$obj->id.'"'; |
107 | - if ($obj->id == $selected) print ' selected'; |
|
108 | + if ($obj->id == $selected) { |
|
109 | + print ' selected'; |
|
110 | + } |
|
108 | 111 | print '>'.dol_trunc($obj->type,$maxlen); |
109 | 112 | $i++; |
110 | 113 | } |
111 | 114 | print '</select>'; |
112 | - if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
113 | - if (! empty($conf->use_javascript_ajax)) print ajax_combobox($htmlname); |
|
114 | - } |
|
115 | - else |
|
115 | + if ($user->admin && $help) { |
|
116 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
117 | + } |
|
118 | + if (! empty($conf->use_javascript_ajax)) { |
|
119 | + print ajax_combobox($htmlname); |
|
120 | + } |
|
121 | + } else |
|
116 | 122 | { |
117 | 123 | print $langs->trans("ErrorNoSocialContributionForSellerCountry",$mysoc->country_code); |
118 | 124 | } |
119 | - } |
|
120 | - else |
|
125 | + } else |
|
121 | 126 | { |
122 | 127 | dol_print_error($db,$db->lasterror()); |
123 | 128 | } |
@@ -92,10 +92,18 @@ discard block |
||
92 | 92 | $error=0; |
93 | 93 | |
94 | 94 | // Clean parameters |
95 | - if (isset($this->code)) $this->code=trim($this->code); |
|
96 | - if (isset($this->code_iso)) $this->code_iso=trim($this->code_iso); |
|
97 | - if (isset($this->label)) $this->label=trim($this->label); |
|
98 | - if (isset($this->active)) $this->active=trim($this->active); |
|
95 | + if (isset($this->code)) { |
|
96 | + $this->code=trim($this->code); |
|
97 | + } |
|
98 | + if (isset($this->code_iso)) { |
|
99 | + $this->code_iso=trim($this->code_iso); |
|
100 | + } |
|
101 | + if (isset($this->label)) { |
|
102 | + $this->label=trim($this->label); |
|
103 | + } |
|
104 | + if (isset($this->active)) { |
|
105 | + $this->active=trim($this->active); |
|
106 | + } |
|
99 | 107 | |
100 | 108 | // Check parameters |
101 | 109 | // Put here code to add control on parameters values |
@@ -149,8 +157,7 @@ discard block |
||
149 | 157 | } |
150 | 158 | $this->db->rollback(); |
151 | 159 | return -1*$error; |
152 | - } |
|
153 | - else |
|
160 | + } else |
|
154 | 161 | { |
155 | 162 | $this->db->commit(); |
156 | 163 | return $this->id; |
@@ -175,8 +182,11 @@ discard block |
||
175 | 182 | $sql.= " t.label,"; |
176 | 183 | $sql.= " t.active"; |
177 | 184 | $sql.= " FROM ".MAIN_DB_PREFIX."c_country as t"; |
178 | - if ($id) $sql.= " WHERE t.rowid = ".$id; |
|
179 | - elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; |
|
185 | + if ($id) { |
|
186 | + $sql.= " WHERE t.rowid = ".$id; |
|
187 | + } elseif ($code) { |
|
188 | + $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; |
|
189 | + } |
|
180 | 190 | |
181 | 191 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
182 | 192 | $resql=$this->db->query($sql); |
@@ -194,12 +204,10 @@ discard block |
||
194 | 204 | |
195 | 205 | $this->db->free($resql); |
196 | 206 | return 1; |
197 | - } |
|
198 | - else { |
|
207 | + } else { |
|
199 | 208 | return 0; |
200 | 209 | } |
201 | - } |
|
202 | - else |
|
210 | + } else |
|
203 | 211 | { |
204 | 212 | $this->error="Error ".$this->db->lasterror(); |
205 | 213 | return -1; |
@@ -220,10 +228,18 @@ discard block |
||
220 | 228 | $error=0; |
221 | 229 | |
222 | 230 | // Clean parameters |
223 | - if (isset($this->code)) $this->code=trim($this->code); |
|
224 | - if (isset($this->code_iso)) $this->code_iso=trim($this->code_iso); |
|
225 | - if (isset($this->label)) $this->label=trim($this->label); |
|
226 | - if (isset($this->active)) $this->active=trim($this->active); |
|
231 | + if (isset($this->code)) { |
|
232 | + $this->code=trim($this->code); |
|
233 | + } |
|
234 | + if (isset($this->code_iso)) { |
|
235 | + $this->code_iso=trim($this->code_iso); |
|
236 | + } |
|
237 | + if (isset($this->label)) { |
|
238 | + $this->label=trim($this->label); |
|
239 | + } |
|
240 | + if (isset($this->active)) { |
|
241 | + $this->active=trim($this->active); |
|
242 | + } |
|
227 | 243 | |
228 | 244 | |
229 | 245 | // Check parameters |
@@ -269,8 +285,7 @@ discard block |
||
269 | 285 | } |
270 | 286 | $this->db->rollback(); |
271 | 287 | return -1*$error; |
272 | - } |
|
273 | - else |
|
288 | + } else |
|
274 | 289 | { |
275 | 290 | $this->db->commit(); |
276 | 291 | return 1; |
@@ -325,8 +340,7 @@ discard block |
||
325 | 340 | } |
326 | 341 | $this->db->rollback(); |
327 | 342 | return -1*$error; |
328 | - } |
|
329 | - else |
|
343 | + } else |
|
330 | 344 | { |
331 | 345 | $this->db->commit(); |
332 | 346 | return 1; |
@@ -229,8 +229,7 @@ discard block |
||
229 | 229 | if($extrafields->attribute_type[$key] == 'price') |
230 | 230 | { |
231 | 231 | $object->array_options['options_'.$key] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); |
232 | - } |
|
233 | - else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
232 | + } else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
234 | 233 | { |
235 | 234 | $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
236 | 235 | } |
@@ -303,8 +302,7 @@ discard block |
||
303 | 302 | if ($extrafields->attribute_type[$key] == 'price') |
304 | 303 | { |
305 | 304 | $object->array_options['options_' . $key] = price($object->array_options ['options_' . $key], 0, $outputlangs, 0, 0, - 1, $conf->currency); |
306 | - } |
|
307 | - elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
305 | + } elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
308 | 306 | { |
309 | 307 | $object->array_options['options_' . $key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_' . $key]]; |
310 | 308 | } |
@@ -343,8 +341,11 @@ discard block |
||
343 | 341 | |
344 | 342 | foreach($conf->global as $key => $val) |
345 | 343 | { |
346 | - if (preg_match('/(_pass|password|secret|_key|key$)/i', $key)) $newval = '*****forbidden*****'; |
|
347 | - else $newval = $val; |
|
344 | + if (preg_match('/(_pass|password|secret|_key|key$)/i', $key)) { |
|
345 | + $newval = '*****forbidden*****'; |
|
346 | + } else { |
|
347 | + $newval = $val; |
|
348 | + } |
|
348 | 349 | $array_other['__['.$key.']__'] = $newval; |
349 | 350 | } |
350 | 351 | |
@@ -475,12 +476,16 @@ discard block |
||
475 | 476 | foreach ($object->lines as $line) |
476 | 477 | { |
477 | 478 | // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility |
478 | - if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
479 | + if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) { |
|
480 | + $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
481 | + } |
|
479 | 482 | $resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
480 | 483 | $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); |
481 | 484 | // $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example) |
482 | 485 | $vatformated=vatrate($line->tva_tx); |
483 | - if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0; |
|
486 | + if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) { |
|
487 | + $resarray[$array_key.'_total_vat_'.$vatformated]=0; |
|
488 | + } |
|
484 | 489 | $resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva; |
485 | 490 | $resarray[$array_key.'_total_vat_locale_'.$vatformated]=price($resarray[$array_key.'_total_vat_'.$vatformated]); |
486 | 491 | } |
@@ -572,8 +577,9 @@ discard block |
||
572 | 577 | { |
573 | 578 | $tmpproduct = new Product($this->db); |
574 | 579 | $result = $tmpproduct->fetch($line->fk_product); |
575 | - foreach($tmpproduct->array_options as $key=>$label) |
|
576 | - $resarray["line_product_".$key] = $label; |
|
580 | + foreach($tmpproduct->array_options as $key=>$label) { |
|
581 | + $resarray["line_product_".$key] = $label; |
|
582 | + } |
|
577 | 583 | } |
578 | 584 | |
579 | 585 | return $resarray; |
@@ -623,7 +629,9 @@ discard block |
||
623 | 629 | // Add vat by rates |
624 | 630 | foreach ($object->lines as $line) |
625 | 631 | { |
626 | - if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
632 | + if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) { |
|
633 | + $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
634 | + } |
|
627 | 635 | $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
628 | 636 | } |
629 | 637 | |
@@ -742,12 +750,10 @@ discard block |
||
742 | 750 | $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); |
743 | 751 | //Add value to store price with currency |
744 | 752 | $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); |
745 | - } |
|
746 | - else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
753 | + } else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
747 | 754 | { |
748 | 755 | $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
749 | - } |
|
750 | - else if($extrafields->attribute_type[$key] == 'date') |
|
756 | + } else if($extrafields->attribute_type[$key] == 'date') |
|
751 | 757 | { |
752 | 758 | if (strlen($object->array_options['options_'.$key])>0) |
753 | 759 | { |
@@ -755,8 +761,7 @@ discard block |
||
755 | 761 | $object->array_options['options_'.$key] = dol_print_date($date,'day'); // using company output language |
756 | 762 | $object->array_options['options_'.$key.'_locale'] = dol_print_date($date,'day','tzserver',$outputlangs); // using output language format |
757 | 763 | $object->array_options['options_'.$key.'_rfc'] = dol_print_date($date,'dayrfc'); // international format |
758 | - } |
|
759 | - else |
|
764 | + } else |
|
760 | 765 | { |
761 | 766 | $object->array_options['options_'.$key] = ''; |
762 | 767 | $object->array_options['options_'.$key.'_locale'] = ''; |
@@ -764,8 +769,7 @@ discard block |
||
764 | 769 | } |
765 | 770 | $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); |
766 | 771 | $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); |
767 | - } |
|
768 | - else if($extrafields->attribute_type[$key] == 'datetime') |
|
772 | + } else if($extrafields->attribute_type[$key] == 'datetime') |
|
769 | 773 | { |
770 | 774 | $datetime = $object->array_options['options_'.$key]; |
771 | 775 | $object->array_options['options_'.$key] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhour'):''); // using company output language |
@@ -773,8 +777,7 @@ discard block |
||
773 | 777 | $object->array_options['options_'.$key.'_rfc'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhourrfc'):''); // international format |
774 | 778 | $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); |
775 | 779 | $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); |
776 | - } |
|
777 | - else if($extrafields->attribute_type[$key] == 'link') |
|
780 | + } else if($extrafields->attribute_type[$key] == 'link') |
|
778 | 781 | { |
779 | 782 | $id = $object->array_options['options_'.$key]; |
780 | 783 | if ($id != "") |
@@ -819,9 +822,13 @@ discard block |
||
819 | 822 | */ |
820 | 823 | function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
821 | 824 | { |
822 | - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
825 | + if (empty($hidetop) || $hidetop==-1) { |
|
826 | + $pdf->line($x, $y, $x+$l, $y); |
|
827 | + } |
|
823 | 828 | $pdf->line($x+$l, $y, $x+$l, $y+$h); |
824 | - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
829 | + if (empty($hidebottom)) { |
|
830 | + $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
831 | + } |
|
825 | 832 | $pdf->line($x, $y+$h, $x, $y); |
826 | 833 | } |
827 | 834 | |
@@ -874,7 +881,10 @@ discard block |
||
874 | 881 | $countFlexCol = 0; |
875 | 882 | foreach ($this->cols as $colKey =>& $colDef) |
876 | 883 | { |
877 | - if(!$this->getColumnStatus($colKey)) continue; // continue if desable |
|
884 | + if(!$this->getColumnStatus($colKey)) { |
|
885 | + continue; |
|
886 | + } |
|
887 | + // continue if desable |
|
878 | 888 | |
879 | 889 | if(!empty($colDef['scale'])){ |
880 | 890 | // In case of column widht is defined by percentage |
@@ -883,8 +893,7 @@ discard block |
||
883 | 893 | |
884 | 894 | if(empty($colDef['width'])){ |
885 | 895 | $countFlexCol++; |
886 | - } |
|
887 | - else{ |
|
896 | + } else{ |
|
888 | 897 | $totalDefinedColWidth += $colDef['width']; |
889 | 898 | } |
890 | 899 | } |
@@ -894,16 +903,14 @@ discard block |
||
894 | 903 | // setting empty conf with default |
895 | 904 | if(!empty($colDef['title'])){ |
896 | 905 | $colDef['title'] = array_replace($this->defaultTitlesFieldsStyle, $colDef['title']); |
897 | - } |
|
898 | - else{ |
|
906 | + } else{ |
|
899 | 907 | $colDef['title'] = $this->defaultTitlesFieldsStyle; |
900 | 908 | } |
901 | 909 | |
902 | 910 | // setting empty conf with default |
903 | 911 | if(!empty($colDef['content'])){ |
904 | 912 | $colDef['content'] = array_replace($this->defaultContentsFieldsStyle, $colDef['content']); |
905 | - } |
|
906 | - else{ |
|
913 | + } else{ |
|
907 | 914 | $colDef['content'] = $this->defaultContentsFieldsStyle; |
908 | 915 | } |
909 | 916 | |
@@ -956,7 +963,9 @@ discard block |
||
956 | 963 | */ |
957 | 964 | function getColumnRank($colKey) |
958 | 965 | { |
959 | - if(!isset($this->cols[$colKey]['rank'])) return -1; |
|
966 | + if(!isset($this->cols[$colKey]['rank'])) { |
|
967 | + return -1; |
|
968 | + } |
|
960 | 969 | return $this->cols[$colKey]['rank']; |
961 | 970 | } |
962 | 971 | |
@@ -1022,10 +1031,14 @@ discard block |
||
1022 | 1031 | 'colKey' => $colKey |
1023 | 1032 | ); |
1024 | 1033 | $reshook=$hookmanager->executeHooks('printStdColumnContent',$parameters,$this); // Note that $action and $object may have been modified by hook |
1025 | - if ($reshook < 0) setEventMessages($hookmanager->error,$hookmanager->errors,'errors'); |
|
1034 | + if ($reshook < 0) { |
|
1035 | + setEventMessages($hookmanager->error,$hookmanager->errors,'errors'); |
|
1036 | + } |
|
1026 | 1037 | if (!$reshook) |
1027 | 1038 | { |
1028 | - if(empty($columnText)) return; |
|
1039 | + if(empty($columnText)) { |
|
1040 | + return; |
|
1041 | + } |
|
1029 | 1042 | $pdf->SetXY($this->getColumnContentXStart($colKey),$curY); // Set curent position |
1030 | 1043 | $colDef = $this->cols[$colKey]; |
1031 | 1044 | $pdf->writeHTMLCell( $this->getColumnContentWidth($colKey),2,$this->getColumnContentXStart($colKey),$curY, $columnText,0,0,0,true,$colDef['content']['align']); |
@@ -1043,7 +1056,8 @@ discard block |
||
1043 | 1056 | { |
1044 | 1057 | if( !empty($this->cols[$colKey]['status'])){ |
1045 | 1058 | return true; |
1059 | + } else { |
|
1060 | + return false; |
|
1046 | 1061 | } |
1047 | - else return false; |
|
1048 | 1062 | } |
1049 | 1063 | } |
@@ -76,9 +76,15 @@ discard block |
||
76 | 76 | private function _cleanaction($action) |
77 | 77 | { |
78 | 78 | $newaction = $action; |
79 | - if ($newaction == 'add') $newaction='create'; |
|
80 | - if ($newaction == 'update') $newaction='edit'; |
|
81 | - if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction='view'; |
|
79 | + if ($newaction == 'add') { |
|
80 | + $newaction='create'; |
|
81 | + } |
|
82 | + if ($newaction == 'update') { |
|
83 | + $newaction='edit'; |
|
84 | + } |
|
85 | + if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') { |
|
86 | + $newaction='view'; |
|
87 | + } |
|
82 | 88 | return $newaction; |
83 | 89 | } |
84 | 90 | |
@@ -145,7 +151,9 @@ discard block |
||
145 | 151 | function assign_values(&$action='view', $id=0, $ref='') |
146 | 152 | { |
147 | 153 | // phpcs:enable |
148 | - if (method_exists($this->control,'assign_values')) $this->control->assign_values($action, $id, $ref); |
|
154 | + if (method_exists($this->control,'assign_values')) { |
|
155 | + $this->control->assign_values($action, $id, $ref); |
|
156 | + } |
|
149 | 157 | } |
150 | 158 | |
151 | 159 | /** |
@@ -156,10 +164,15 @@ discard block |
||
156 | 164 | */ |
157 | 165 | function displayCanvasExists($action) |
158 | 166 | { |
159 | - if (empty($this->template_dir)) return 0; |
|
167 | + if (empty($this->template_dir)) { |
|
168 | + return 0; |
|
169 | + } |
|
160 | 170 | |
161 | - if (file_exists($this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1; |
|
162 | - else return 0; |
|
171 | + if (file_exists($this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) { |
|
172 | + return 1; |
|
173 | + } else { |
|
174 | + return 0; |
|
175 | + } |
|
163 | 176 | } |
164 | 177 | |
165 | 178 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -59,19 +59,24 @@ discard block |
||
59 | 59 | { |
60 | 60 | foreach ($this->fields as $field=>$info) |
61 | 61 | { |
62 | - if ($this->isDate($info)) $this->{$field} = time(); |
|
63 | - elseif ($this->isArray($info)) $this->{$field} = array(); |
|
64 | - elseif ($this->isInt($info)) $this->{$field} = (int) 0; |
|
65 | - elseif ($this->isFloat($info)) $this->{$field} = (double) 0; |
|
66 | - else $this->{$field} = ''; |
|
62 | + if ($this->isDate($info)) { |
|
63 | + $this->{$field} = time(); |
|
64 | + } elseif ($this->isArray($info)) { |
|
65 | + $this->{$field} = array(); |
|
66 | + } elseif ($this->isInt($info)) { |
|
67 | + $this->{$field} = (int) 0; |
|
68 | + } elseif ($this->isFloat($info)) { |
|
69 | + $this->{$field} = (double) 0; |
|
70 | + } else { |
|
71 | + $this->{$field} = ''; |
|
72 | + } |
|
67 | 73 | } |
68 | 74 | |
69 | 75 | $this->to_delete=false; |
70 | 76 | $this->is_clone=false; |
71 | 77 | |
72 | 78 | return true; |
73 | - } |
|
74 | - else |
|
79 | + } else |
|
75 | 80 | { |
76 | 81 | return false; |
77 | 82 | } |
@@ -89,8 +94,7 @@ discard block |
||
89 | 94 | if (isset($this->fields[$field]) && method_exists($this, 'is_'.$type)) |
90 | 95 | { |
91 | 96 | return $this->{'is_'.$type}($this->fields[$field]); |
92 | - } |
|
93 | - else |
|
97 | + } else |
|
94 | 98 | { |
95 | 99 | return false; |
96 | 100 | } |
@@ -107,7 +111,9 @@ discard block |
||
107 | 111 | { |
108 | 112 | $res = $this->fetchCommon($id); |
109 | 113 | if($res>0) { |
110 | - if ($loadChild) $this->fetchChild(); |
|
114 | + if ($loadChild) { |
|
115 | + $this->fetchChild(); |
|
116 | + } |
|
111 | 117 | } |
112 | 118 | |
113 | 119 | return $res; |
@@ -129,7 +135,9 @@ discard block |
||
129 | 135 | { |
130 | 136 | foreach($this->{$tabName} as $k=>&$object) |
131 | 137 | { |
132 | - if($object->{$key} === $id) return $k; |
|
138 | + if($object->{$key} === $id) { |
|
139 | + return $k; |
|
140 | + } |
|
133 | 141 | } |
134 | 142 | } |
135 | 143 | |
@@ -195,8 +203,7 @@ discard block |
||
195 | 203 | |
196 | 204 | $this->{$className}[] = $o; |
197 | 205 | } |
198 | - } |
|
199 | - else |
|
206 | + } else |
|
200 | 207 | { |
201 | 208 | $this->errors[] = $this->db->lasterror(); |
202 | 209 | } |
@@ -224,7 +231,9 @@ discard block |
||
224 | 231 | $object->{$this->fk_element} = $this->id; |
225 | 232 | |
226 | 233 | $object->update($user); |
227 | - if($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete==true) unset($this->{$className}[$i]); |
|
234 | + if($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete==true) { |
|
235 | + unset($this->{$className}[$i]); |
|
236 | + } |
|
228 | 237 | } |
229 | 238 | } |
230 | 239 | } |
@@ -240,8 +249,13 @@ discard block |
||
240 | 249 | */ |
241 | 250 | public function update(User &$user) |
242 | 251 | { |
243 | - if (empty($this->id)) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed |
|
244 | - elseif (isset($this->to_delete) && $this->to_delete==true) return $this->delete($user); |
|
252 | + if (empty($this->id)) { |
|
253 | + return $this->create($user); |
|
254 | + } |
|
255 | + // To test, with that, no need to test on high level object, the core decide it, update just needed |
|
256 | + elseif (isset($this->to_delete) && $this->to_delete==true) { |
|
257 | + return $this->delete($user); |
|
258 | + } |
|
245 | 259 | |
246 | 260 | $error = 0; |
247 | 261 | $this->db->begin(); |
@@ -250,10 +264,12 @@ discard block |
||
250 | 264 | if ($res) |
251 | 265 | { |
252 | 266 | $result = $this->call_trigger(strtoupper($this->element). '_UPDATE', $user); |
253 | - if ($result < 0) $error++; |
|
254 | - else $this->saveChild($user); |
|
255 | - } |
|
256 | - else |
|
267 | + if ($result < 0) { |
|
268 | + $error++; |
|
269 | + } else { |
|
270 | + $this->saveChild($user); |
|
271 | + } |
|
272 | + } else |
|
257 | 273 | { |
258 | 274 | $error++; |
259 | 275 | $this->error = $this->db->lasterror(); |
@@ -264,8 +280,7 @@ discard block |
||
264 | 280 | { |
265 | 281 | $this->db->commit(); |
266 | 282 | return $this->id; |
267 | - } |
|
268 | - else |
|
283 | + } else |
|
269 | 284 | { |
270 | 285 | $this->db->rollback(); |
271 | 286 | return -1; |
@@ -280,7 +295,9 @@ discard block |
||
280 | 295 | */ |
281 | 296 | public function create(User &$user) |
282 | 297 | { |
283 | - if($this->id > 0) return $this->update($user); |
|
298 | + if($this->id > 0) { |
|
299 | + return $this->update($user); |
|
300 | + } |
|
284 | 301 | |
285 | 302 | $error = 0; |
286 | 303 | $this->db->begin(); |
@@ -291,10 +308,12 @@ discard block |
||
291 | 308 | $this->id = $this->db->last_insert_id($this->table_element); |
292 | 309 | |
293 | 310 | $result = $this->call_trigger(strtoupper($this->element). '_CREATE', $user); |
294 | - if ($result < 0) $error++; |
|
295 | - else $this->saveChild($user); |
|
296 | - } |
|
297 | - else |
|
311 | + if ($result < 0) { |
|
312 | + $error++; |
|
313 | + } else { |
|
314 | + $this->saveChild($user); |
|
315 | + } |
|
316 | + } else |
|
298 | 317 | { |
299 | 318 | $error++; |
300 | 319 | $this->error = $this->db->lasterror(); |
@@ -305,8 +324,7 @@ discard block |
||
305 | 324 | { |
306 | 325 | $this->db->commit(); |
307 | 326 | return $this->id; |
308 | - } |
|
309 | - else |
|
327 | + } else |
|
310 | 328 | { |
311 | 329 | $this->db->rollback(); |
312 | 330 | return -1; |
@@ -321,13 +339,17 @@ discard block |
||
321 | 339 | */ |
322 | 340 | public function delete(User &$user) |
323 | 341 | { |
324 | - if ($this->id <= 0) return 0; |
|
342 | + if ($this->id <= 0) { |
|
343 | + return 0; |
|
344 | + } |
|
325 | 345 | |
326 | 346 | $error = 0; |
327 | 347 | $this->db->begin(); |
328 | 348 | |
329 | 349 | $result = $this->call_trigger(strtoupper($this->element). '_DELETE', $user); |
330 | - if ($result < 0) $error++; |
|
350 | + if ($result < 0) { |
|
351 | + $error++; |
|
352 | + } |
|
331 | 353 | |
332 | 354 | if (!$error) |
333 | 355 | { |
@@ -352,8 +374,7 @@ discard block |
||
352 | 374 | { |
353 | 375 | $this->db->commit(); |
354 | 376 | return 1; |
355 | - } |
|
356 | - else |
|
377 | + } else |
|
357 | 378 | { |
358 | 379 | $this->error = $this->db->lasterror(); |
359 | 380 | $this->errors[] = $this->error; |
@@ -372,8 +393,9 @@ discard block |
||
372 | 393 | */ |
373 | 394 | public function getDate($field, $format='') |
374 | 395 | { |
375 | - if(empty($this->{$field})) return ''; |
|
376 | - else |
|
396 | + if(empty($this->{$field})) { |
|
397 | + return ''; |
|
398 | + } else |
|
377 | 399 | { |
378 | 400 | return dol_print_date($this->{$field}, $format); |
379 | 401 | } |
@@ -391,8 +413,7 @@ discard block |
||
391 | 413 | if (empty($date)) |
392 | 414 | { |
393 | 415 | $this->{$field} = 0; |
394 | - } |
|
395 | - else |
|
416 | + } else |
|
396 | 417 | { |
397 | 418 | require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
398 | 419 | $this->{$field} = dol_stringtotime($date); |
@@ -415,19 +436,15 @@ discard block |
||
415 | 436 | if($this->checkFieldType($key, 'date')) |
416 | 437 | { |
417 | 438 | $this->setDate($key, $value); |
418 | - } |
|
419 | - else if( $this->checkFieldType($key, 'array')) |
|
439 | + } else if( $this->checkFieldType($key, 'array')) |
|
420 | 440 | { |
421 | 441 | $this->{$key} = $value; |
422 | - } |
|
423 | - else if( $this->checkFieldType($key, 'float') ) |
|
442 | + } else if( $this->checkFieldType($key, 'float') ) |
|
424 | 443 | { |
425 | 444 | $this->{$key} = (double) price2num($value); |
426 | - } |
|
427 | - else if( $this->checkFieldType($key, 'int') ) { |
|
445 | + } else if( $this->checkFieldType($key, 'int') ) { |
|
428 | 446 | $this->{$key} = (int) price2num($value); |
429 | - } |
|
430 | - else |
|
447 | + } else |
|
431 | 448 | { |
432 | 449 | $this->{$key} = $value; |
433 | 450 | } |
@@ -98,9 +98,15 @@ discard block |
||
98 | 98 | $error=0; |
99 | 99 | |
100 | 100 | // Clean parameters |
101 | - if (isset($this->code_departement)) $this->code_departement=trim($this->code_departement); |
|
102 | - if (isset($this->nom)) $this->nom=trim($this->nom); |
|
103 | - if (isset($this->active)) $this->active=trim($this->active); |
|
101 | + if (isset($this->code_departement)) { |
|
102 | + $this->code_departement=trim($this->code_departement); |
|
103 | + } |
|
104 | + if (isset($this->nom)) { |
|
105 | + $this->nom=trim($this->nom); |
|
106 | + } |
|
107 | + if (isset($this->active)) { |
|
108 | + $this->active=trim($this->active); |
|
109 | + } |
|
104 | 110 | |
105 | 111 | // Check parameters |
106 | 112 | // Put here code to add control on parameters values |
@@ -152,8 +158,7 @@ discard block |
||
152 | 158 | } |
153 | 159 | $this->db->rollback(); |
154 | 160 | return -1*$error; |
155 | - } |
|
156 | - else |
|
161 | + } else |
|
157 | 162 | { |
158 | 163 | $this->db->commit(); |
159 | 164 | return $this->id; |
@@ -177,8 +182,11 @@ discard block |
||
177 | 182 | $sql.= " t.nom,"; |
178 | 183 | $sql.= " t.active"; |
179 | 184 | $sql.= " FROM ".MAIN_DB_PREFIX."c_departements as t"; |
180 | - if ($id) $sql.= " WHERE t.rowid = ".$id; |
|
181 | - elseif ($code) $sql.= " WHERE t.code_departement = '".$this->db->escape($code)."'"; |
|
185 | + if ($id) { |
|
186 | + $sql.= " WHERE t.rowid = ".$id; |
|
187 | + } elseif ($code) { |
|
188 | + $sql.= " WHERE t.code_departement = '".$this->db->escape($code)."'"; |
|
189 | + } |
|
182 | 190 | |
183 | 191 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
184 | 192 | $resql=$this->db->query($sql); |
@@ -196,8 +204,7 @@ discard block |
||
196 | 204 | $this->db->free($resql); |
197 | 205 | |
198 | 206 | return 1; |
199 | - } |
|
200 | - else |
|
207 | + } else |
|
201 | 208 | { |
202 | 209 | $this->error="Error ".$this->db->lasterror(); |
203 | 210 | return -1; |
@@ -218,9 +225,15 @@ discard block |
||
218 | 225 | $error=0; |
219 | 226 | |
220 | 227 | // Clean parameters |
221 | - if (isset($this->code_departement)) $this->code_departement=trim($this->code_departement); |
|
222 | - if (isset($this->nom)) $this->nom=trim($this->nom); |
|
223 | - if (isset($this->active)) $this->active=trim($this->active); |
|
228 | + if (isset($this->code_departement)) { |
|
229 | + $this->code_departement=trim($this->code_departement); |
|
230 | + } |
|
231 | + if (isset($this->nom)) { |
|
232 | + $this->nom=trim($this->nom); |
|
233 | + } |
|
234 | + if (isset($this->active)) { |
|
235 | + $this->active=trim($this->active); |
|
236 | + } |
|
224 | 237 | |
225 | 238 | |
226 | 239 | // Check parameters |
@@ -265,8 +278,7 @@ discard block |
||
265 | 278 | } |
266 | 279 | $this->db->rollback(); |
267 | 280 | return -1*$error; |
268 | - } |
|
269 | - else |
|
281 | + } else |
|
270 | 282 | { |
271 | 283 | $this->db->commit(); |
272 | 284 | return 1; |
@@ -321,8 +333,7 @@ discard block |
||
321 | 333 | } |
322 | 334 | $this->db->rollback(); |
323 | 335 | return -1*$error; |
324 | - } |
|
325 | - else |
|
336 | + } else |
|
326 | 337 | { |
327 | 338 | $this->db->commit(); |
328 | 339 | return 1; |