@@ -128,9 +128,13 @@ discard block |
||
128 | 128 | if (! empty($conf->use_javascript_ajax) || $onlyselect) |
129 | 129 | { |
130 | 130 | //var_dump($selected); |
131 | - if ($selected == 'done') $selected='100'; |
|
131 | + if ($selected == 'done') { |
|
132 | + $selected='100'; |
|
133 | + } |
|
132 | 134 | print '<select '.($canedit?'':'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss?' '.$morecss:'').'">'; |
133 | - if ($showempty) print '<option value=""'.($selected == ''?' selected':'').'></option>'; |
|
135 | + if ($showempty) { |
|
136 | + print '<option value=""'.($selected == ''?' selected':'').'></option>'; |
|
137 | + } |
|
134 | 138 | foreach($listofstatus as $key => $val) |
135 | 139 | { |
136 | 140 | print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>'.$val.'</option>'; |
@@ -140,15 +144,16 @@ discard block |
||
140 | 144 | } |
141 | 145 | } |
142 | 146 | print '</select>'; |
143 | - if ($selected == 0 || $selected == 100) $canedit=0; |
|
147 | + if ($selected == 0 || $selected == 100) { |
|
148 | + $canedit=0; |
|
149 | + } |
|
144 | 150 | |
145 | 151 | if (empty($onlyselect)) |
146 | 152 | { |
147 | 153 | print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit&&($selected>=0)?'':' disabled').'>'; |
148 | 154 | print '<span class="hideonsmartphone hideifna">%</span>'; |
149 | 155 | } |
150 | - } |
|
151 | - else |
|
156 | + } else |
|
152 | 157 | { |
153 | 158 | print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit?'':' disabled').'>%'; |
154 | 159 | } |
@@ -179,28 +184,45 @@ discard block |
||
179 | 184 | $sortorder='DESC,DESC'; |
180 | 185 | |
181 | 186 | $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max?($max+1):0)); |
182 | - if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions'); |
|
187 | + if (! is_array($listofactions)) { |
|
188 | + dol_print_error($this->db,'FailedToGetActions'); |
|
189 | + } |
|
183 | 190 | |
184 | 191 | $num = count($listofactions); |
185 | 192 | if ($num || $forceshowtitle) |
186 | 193 | { |
187 | - if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill'); |
|
188 | - elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill'); |
|
189 | - elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal'); |
|
190 | - elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal'); |
|
191 | - elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); |
|
192 | - elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); |
|
193 | - elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); |
|
194 | - elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); |
|
195 | - elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
196 | - elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
197 | - elseif ($typeelement == 'member') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
198 | - else $title=$langs->trans("LatestLinkedEvents", $max?$max:''); |
|
194 | + if ($typeelement == 'invoice') { |
|
195 | + $title=$langs->trans('ActionsOnBill'); |
|
196 | + } elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') { |
|
197 | + $title=$langs->trans('ActionsOnBill'); |
|
198 | + } elseif ($typeelement == 'propal') { |
|
199 | + $title=$langs->trans('ActionsOnPropal'); |
|
200 | + } elseif ($typeelement == 'supplier_proposal') { |
|
201 | + $title=$langs->trans('ActionsOnSupplierProposal'); |
|
202 | + } elseif ($typeelement == 'order') { |
|
203 | + $title=$langs->trans('ActionsOnOrder'); |
|
204 | + } elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') { |
|
205 | + $title=$langs->trans('ActionsOnOrder'); |
|
206 | + } elseif ($typeelement == 'shipping') { |
|
207 | + $title=$langs->trans('ActionsOnShipping'); |
|
208 | + } elseif ($typeelement == 'fichinter') { |
|
209 | + $title=$langs->trans('ActionsOnFicheInter'); |
|
210 | + } elseif ($typeelement == 'project') { |
|
211 | + $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
212 | + } elseif ($typeelement == 'task') { |
|
213 | + $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
214 | + } elseif ($typeelement == 'member') { |
|
215 | + $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
216 | + } else { |
|
217 | + $title=$langs->trans("LatestLinkedEvents", $max?$max:''); |
|
218 | + } |
|
199 | 219 | |
200 | 220 | $urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:''); |
201 | 221 | |
202 | 222 | $projectid = $object->fk_project; |
203 | - if ($typeelement == 'project') $projectid = $object->id; |
|
223 | + if ($typeelement == 'project') { |
|
224 | + $projectid = $object->id; |
|
225 | + } |
|
204 | 226 | |
205 | 227 | $newcardbutton=''; |
206 | 228 | if (! empty($conf->agenda->enabled)) |
@@ -236,7 +258,9 @@ discard block |
||
236 | 258 | $cursorevent = 0; |
237 | 259 | foreach($listofactions as $action) |
238 | 260 | { |
239 | - if ($max && $cursorevent >= $max) break; |
|
261 | + if ($max && $cursorevent >= $max) { |
|
262 | + break; |
|
263 | + } |
|
240 | 264 | |
241 | 265 | $ref=$action->getNomUrl(1,-1); |
242 | 266 | $label=$action->getNomUrl(0,38); |
@@ -257,14 +281,22 @@ discard block |
||
257 | 281 | $imgpicto=''; |
258 | 282 | if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
259 | 283 | { |
260 | - if ($action->type_picto) $imgpicto=img_picto('', $action->type_picto); |
|
261 | - else { |
|
262 | - if ($action->type_code == 'AC_RDV') $imgpicto=img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; |
|
263 | - elseif ($action->type_code == 'AC_TEL') $imgpicto=img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; |
|
264 | - elseif ($action->type_code == 'AC_FAX') $imgpicto=img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; |
|
265 | - elseif ($action->type_code == 'AC_EMAIL') $imgpicto=img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; |
|
266 | - elseif ($action->type_code == 'AC_INT') $imgpicto=img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; |
|
267 | - elseif (! preg_match('/_AUTO/', $action->type_code)) $imgpicto=img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; |
|
284 | + if ($action->type_picto) { |
|
285 | + $imgpicto=img_picto('', $action->type_picto); |
|
286 | + } else { |
|
287 | + if ($action->type_code == 'AC_RDV') { |
|
288 | + $imgpicto=img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; |
|
289 | + } elseif ($action->type_code == 'AC_TEL') { |
|
290 | + $imgpicto=img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; |
|
291 | + } elseif ($action->type_code == 'AC_FAX') { |
|
292 | + $imgpicto=img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; |
|
293 | + } elseif ($action->type_code == 'AC_EMAIL') { |
|
294 | + $imgpicto=img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; |
|
295 | + } elseif ($action->type_code == 'AC_INT') { |
|
296 | + $imgpicto=img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; |
|
297 | + } elseif (! preg_match('/_AUTO/', $action->type_code)) { |
|
298 | + $imgpicto=img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; |
|
299 | + } |
|
268 | 300 | } |
269 | 301 | } |
270 | 302 | print $imgpicto; |
@@ -280,9 +312,12 @@ discard block |
||
280 | 312 | $tmpb=dol_getdate($action->datef); |
281 | 313 | if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) |
282 | 314 | { |
283 | - if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel'); |
|
315 | + if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) { |
|
316 | + print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel'); |
|
317 | + } |
|
318 | + } else { |
|
319 | + print '-'.dol_print_date($action->datef, 'dayhour', 'tzuserrel'); |
|
284 | 320 | } |
285 | - else print '-'.dol_print_date($action->datef, 'dayhour', 'tzuserrel'); |
|
286 | 321 | } |
287 | 322 | print '</td>'; |
288 | 323 | print '<td align="right">'; |
@@ -295,8 +330,7 @@ discard block |
||
295 | 330 | |
296 | 331 | $cursorevent++; |
297 | 332 | } |
298 | - } |
|
299 | - else |
|
333 | + } else |
|
300 | 334 | { |
301 | 335 | print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; |
302 | 336 | } |
@@ -332,7 +366,9 @@ discard block |
||
332 | 366 | // phpcs:enable |
333 | 367 | global $langs,$user,$form,$conf; |
334 | 368 | |
335 | - if (! is_object($form)) $form=new Form($this->db); |
|
369 | + if (! is_object($form)) { |
|
370 | + $form=new Form($this->db); |
|
371 | + } |
|
336 | 372 | |
337 | 373 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; |
338 | 374 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
@@ -343,19 +379,26 @@ discard block |
||
343 | 379 | array_unshift($arraylist,' '); // Add empty line at start |
344 | 380 | //asort($arraylist); |
345 | 381 | |
346 | - if ($selected == 'manual') $selected='AC_OTH'; |
|
347 | - if ($selected == 'auto') $selected='AC_OTH_AUTO'; |
|
382 | + if ($selected == 'manual') { |
|
383 | + $selected='AC_OTH'; |
|
384 | + } |
|
385 | + if ($selected == 'auto') { |
|
386 | + $selected='AC_OTH_AUTO'; |
|
387 | + } |
|
348 | 388 | |
349 | - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); |
|
389 | + if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) { |
|
390 | + unset($arraylist['AC_OTH_AUTO']); |
|
391 | + } |
|
350 | 392 | |
351 | 393 | $out=''; |
352 | 394 | |
353 | 395 | if (! empty($multiselect)) |
354 | 396 | { |
355 | - if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); |
|
397 | + if (!is_array($selected) && !empty($selected)) { |
|
398 | + $selected = explode(',', $selected); |
|
399 | + } |
|
356 | 400 | $out.=$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); |
357 | - } |
|
358 | - else |
|
401 | + } else |
|
359 | 402 | { |
360 | 403 | $out.=$form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); |
361 | 404 | } |
@@ -365,8 +408,11 @@ discard block |
||
365 | 408 | $out.=info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''),1); |
366 | 409 | } |
367 | 410 | |
368 | - if ($nooutput) return $out; |
|
369 | - else print $out; |
|
411 | + if ($nooutput) { |
|
412 | + return $out; |
|
413 | + } else { |
|
414 | + print $out; |
|
415 | + } |
|
370 | 416 | return ''; |
371 | 417 | } |
372 | 418 | } |
@@ -76,7 +76,7 @@ |
||
76 | 76 | $out.= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>'; |
77 | 77 | $out.='</SELECT>'; |
78 | 78 | } |
79 | - }else { |
|
79 | + } else { |
|
80 | 80 | |
81 | 81 | $out='<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />'; |
82 | 82 |
@@ -70,8 +70,12 @@ discard block |
||
70 | 70 | |
71 | 71 | dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname); |
72 | 72 | |
73 | - if (! $rows) $rows=round($height/20); |
|
74 | - if (! $cols) $cols=($width?round($width/6):80); |
|
73 | + if (! $rows) { |
|
74 | + $rows=round($height/20); |
|
75 | + } |
|
76 | + if (! $cols) { |
|
77 | + $cols=($width?round($width/6):80); |
|
78 | + } |
|
75 | 79 | $shorttoolbarname=preg_replace('/_encoded$/','',$toolbarname); |
76 | 80 | |
77 | 81 | // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor') |
@@ -81,8 +85,12 @@ discard block |
||
81 | 85 | $this->readonly=$readonly; |
82 | 86 | |
83 | 87 | // Check if extended editor is ok. If not we force textarea |
84 | - if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea'; |
|
85 | - if ($okforextendededitor === 'ace') $this->tool='ace'; |
|
88 | + if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) { |
|
89 | + $this->tool = 'textarea'; |
|
90 | + } |
|
91 | + if ($okforextendededitor === 'ace') { |
|
92 | + $this->tool='ace'; |
|
93 | + } |
|
86 | 94 | //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile |
87 | 95 | |
88 | 96 | // Define content and some properties |
@@ -100,7 +108,9 @@ discard block |
||
100 | 108 | $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/' ; |
101 | 109 | $this->editor->Value = $content; |
102 | 110 | $this->editor->Height = $height; |
103 | - if (! empty($width)) $this->editor->Width = $width; |
|
111 | + if (! empty($width)) { |
|
112 | + $this->editor->Width = $width; |
|
113 | + } |
|
104 | 114 | $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js |
105 | 115 | $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) |
106 | 116 | $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In'; |
@@ -163,9 +173,11 @@ discard block |
||
163 | 173 | $found=0; |
164 | 174 | $out=''; |
165 | 175 | |
166 | - if ($this->tool == 'fckeditor') // not used anymore |
|
176 | + if ($this->tool == 'fckeditor') { |
|
177 | + // not used anymore |
|
167 | 178 | { |
168 | 179 | $found=1; |
180 | + } |
|
169 | 181 | $this->editor->Create(); |
170 | 182 | } |
171 | 183 | if (in_array($this->tool,array('textarea','ckeditor'))) |
@@ -179,7 +191,9 @@ discard block |
||
179 | 191 | |
180 | 192 | if ($this->tool == 'ckeditor' && ! empty($conf->use_javascript_ajax)) |
181 | 193 | { |
182 | - if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR','1'); |
|
194 | + if (! defined('REQUIRE_CKEDITOR')) { |
|
195 | + define('REQUIRE_CKEDITOR','1'); |
|
196 | + } |
|
183 | 197 | |
184 | 198 | if (! empty($conf->global->FCKEDITOR_SKIN)) { |
185 | 199 | $skin = $conf->global->FCKEDITOR_SKIN; |
@@ -343,7 +357,10 @@ discard block |
||
343 | 357 | $out.= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; |
344 | 358 | } |
345 | 359 | |
346 | - if ($noprint) return $out; |
|
347 | - else print $out; |
|
360 | + if ($noprint) { |
|
361 | + return $out; |
|
362 | + } else { |
|
363 | + print $out; |
|
364 | + } |
|
348 | 365 | } |
349 | 366 | } |
@@ -70,7 +70,9 @@ discard block |
||
70 | 70 | $sql = "SELECT id, code, libelle"; |
71 | 71 | $sql.= " FROM ".MAIN_DB_PREFIX."c_typent"; |
72 | 72 | $sql.= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = ".(empty($mysoc->country_id)?'0':$mysoc->country_id).")"; |
73 | - if ($filter) $sql.=" ".$filter; |
|
73 | + if ($filter) { |
|
74 | + $sql.=" ".$filter; |
|
75 | + } |
|
74 | 76 | $sql.= " ORDER by position, id"; |
75 | 77 | dol_syslog(get_class($this).'::typent_array', LOG_DEBUG); |
76 | 78 | $resql=$this->db->query($sql); |
@@ -82,11 +84,19 @@ discard block |
||
82 | 84 | while ($i < $num) |
83 | 85 | { |
84 | 86 | $objp = $this->db->fetch_object($resql); |
85 | - if (! $mode) $key=$objp->id; |
|
86 | - else $key=$objp->code; |
|
87 | - if ($langs->trans($objp->code) != $objp->code) $effs[$key] = $langs->trans($objp->code); |
|
88 | - else $effs[$key] = $objp->libelle; |
|
89 | - if ($effs[$key]=='-') $effs[$key]=''; |
|
87 | + if (! $mode) { |
|
88 | + $key=$objp->id; |
|
89 | + } else { |
|
90 | + $key=$objp->code; |
|
91 | + } |
|
92 | + if ($langs->trans($objp->code) != $objp->code) { |
|
93 | + $effs[$key] = $langs->trans($objp->code); |
|
94 | + } else { |
|
95 | + $effs[$key] = $objp->libelle; |
|
96 | + } |
|
97 | + if ($effs[$key]=='-') { |
|
98 | + $effs[$key]=''; |
|
99 | + } |
|
90 | 100 | $i++; |
91 | 101 | } |
92 | 102 | $this->db->free($resql); |
@@ -111,7 +121,9 @@ discard block |
||
111 | 121 | $sql = "SELECT id, code, libelle"; |
112 | 122 | $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif"; |
113 | 123 | $sql.= " WHERE active = 1"; |
114 | - if ($filter) $sql.=" ".$filter; |
|
124 | + if ($filter) { |
|
125 | + $sql.=" ".$filter; |
|
126 | + } |
|
115 | 127 | $sql .= " ORDER BY id ASC"; |
116 | 128 | dol_syslog(get_class($this).'::effectif_array', LOG_DEBUG); |
117 | 129 | $resql=$this->db->query($sql); |
@@ -123,8 +135,11 @@ discard block |
||
123 | 135 | while ($i < $num) |
124 | 136 | { |
125 | 137 | $objp = $this->db->fetch_object($resql); |
126 | - if (! $mode) $key=$objp->id; |
|
127 | - else $key=$objp->code; |
|
138 | + if (! $mode) { |
|
139 | + $key=$objp->id; |
|
140 | + } else { |
|
141 | + $key=$objp->code; |
|
142 | + } |
|
128 | 143 | |
129 | 144 | $effs[$key] = $objp->libelle!='-'?$objp->libelle:''; |
130 | 145 | $i++; |
@@ -179,9 +194,12 @@ discard block |
||
179 | 194 | } |
180 | 195 | |
181 | 196 | print Form::selectarray($htmlname, $options, $selected); |
197 | + } else { |
|
198 | + dol_print_error($this->db); |
|
199 | + } |
|
200 | + if (! empty($htmlname) && $user->admin) { |
|
201 | + print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
182 | 202 | } |
183 | - else dol_print_error($this->db); |
|
184 | - if (! empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
185 | 203 | print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
186 | 204 | print '</form>'; |
187 | 205 | } |
@@ -235,15 +253,23 @@ discard block |
||
235 | 253 | $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; |
236 | 254 | $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid"; |
237 | 255 | $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; |
238 | - if ($country_codeid && is_numeric($country_codeid)) $sql .= " AND c.rowid = '".$this->db->escape($country_codeid)."'"; |
|
239 | - if ($country_codeid && ! is_numeric($country_codeid)) $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; |
|
256 | + if ($country_codeid && is_numeric($country_codeid)) { |
|
257 | + $sql .= " AND c.rowid = '".$this->db->escape($country_codeid)."'"; |
|
258 | + } |
|
259 | + if ($country_codeid && ! is_numeric($country_codeid)) { |
|
260 | + $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; |
|
261 | + } |
|
240 | 262 | $sql .= " ORDER BY c.code, d.code_departement"; |
241 | 263 | |
242 | 264 | $result=$this->db->query($sql); |
243 | 265 | if ($result) |
244 | 266 | { |
245 | - if (!empty($htmlname)) $out.= '<select id="'.$htmlname.'" class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'">'; |
|
246 | - if ($country_codeid) $out.= '<option value="0"> </option>'; |
|
267 | + if (!empty($htmlname)) { |
|
268 | + $out.= '<select id="'.$htmlname.'" class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'">'; |
|
269 | + } |
|
270 | + if ($country_codeid) { |
|
271 | + $out.= '<option value="0"> </option>'; |
|
272 | + } |
|
247 | 273 | $num = $this->db->num_rows($result); |
248 | 274 | $i = 0; |
249 | 275 | dol_syslog(get_class($this)."::select_departement num=".$num,LOG_DEBUG); |
@@ -253,11 +279,12 @@ discard block |
||
253 | 279 | while ($i < $num) |
254 | 280 | { |
255 | 281 | $obj = $this->db->fetch_object($result); |
256 | - if ($obj->code == '0') // Le code peut etre une chaine |
|
282 | + if ($obj->code == '0') { |
|
283 | + // Le code peut etre une chaine |
|
257 | 284 | { |
258 | 285 | $out.= '<option value="0"> </option>'; |
259 | 286 | } |
260 | - else { |
|
287 | + } else { |
|
261 | 288 | if (! $country || $country != $obj->country) |
262 | 289 | { |
263 | 290 | // Affiche la rupture si on est en mode liste multipays |
@@ -272,8 +299,7 @@ discard block |
||
272 | 299 | || (empty($selected) && ! empty($conf->global->MAIN_FORCE_DEFAULT_STATE_ID) && $conf->global->MAIN_FORCE_DEFAULT_STATE_ID == $obj->rowid)) |
273 | 300 | { |
274 | 301 | $out.= '<option value="'.$obj->rowid.'" selected>'; |
275 | - } |
|
276 | - else |
|
302 | + } else |
|
277 | 303 | { |
278 | 304 | $out.= '<option value="'.$obj->rowid.'">'; |
279 | 305 | } |
@@ -283,16 +309,13 @@ discard block |
||
283 | 309 | ($conf->global->MAIN_SHOW_STATE_CODE == 1 || $conf->global->MAIN_SHOW_STATE_CODE == 2 || $conf->global->MAIN_SHOW_STATE_CODE === 'all')) { |
284 | 310 | if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
285 | 311 | $out.= $obj->region_name . ' - ' . $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
286 | - } |
|
287 | - else { |
|
312 | + } else { |
|
288 | 313 | $out.= $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
289 | 314 | } |
290 | - } |
|
291 | - else { |
|
315 | + } else { |
|
292 | 316 | if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
293 | 317 | $out.= $obj->region_name . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
294 | - } |
|
295 | - else { |
|
318 | + } else { |
|
296 | 319 | $out.= ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
297 | 320 | } |
298 | 321 | } |
@@ -302,10 +325,13 @@ discard block |
||
302 | 325 | $i++; |
303 | 326 | } |
304 | 327 | } |
305 | - if (! empty($htmlname)) $out.= '</select>'; |
|
306 | - if (! empty($htmlname) && $user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
307 | - } |
|
308 | - else |
|
328 | + if (! empty($htmlname)) { |
|
329 | + $out.= '</select>'; |
|
330 | + } |
|
331 | + if (! empty($htmlname) && $user->admin) { |
|
332 | + $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
333 | + } |
|
334 | + } else |
|
309 | 335 | { |
310 | 336 | dol_print_error($this->db); |
311 | 337 | } |
@@ -358,8 +384,7 @@ discard block |
||
358 | 384 | $obj = $this->db->fetch_object($resql); |
359 | 385 | if ($obj->code == 0) { |
360 | 386 | print '<option value="0"> </option>'; |
361 | - } |
|
362 | - else { |
|
387 | + } else { |
|
363 | 388 | if ($country == '' || $country != $obj->country) |
364 | 389 | { |
365 | 390 | // Show break |
@@ -372,8 +397,7 @@ discard block |
||
372 | 397 | if ($selected > 0 && $selected == $obj->code) |
373 | 398 | { |
374 | 399 | print '<option value="'.$obj->code.'" selected>'.$obj->label.'</option>'; |
375 | - } |
|
376 | - else |
|
400 | + } else |
|
377 | 401 | { |
378 | 402 | print '<option value="'.$obj->code.'">'.$obj->label.'</option>'; |
379 | 403 | } |
@@ -382,8 +406,7 @@ discard block |
||
382 | 406 | } |
383 | 407 | } |
384 | 408 | print '</select>'; |
385 | - } |
|
386 | - else |
|
409 | + } else |
|
387 | 410 | { |
388 | 411 | dol_print_error($this->db); |
389 | 412 | } |
@@ -425,8 +448,7 @@ discard block |
||
425 | 448 | if ($selected == $obj->code) |
426 | 449 | { |
427 | 450 | $out.= '<option value="'.$obj->code.'" selected>'; |
428 | - } |
|
429 | - else |
|
451 | + } else |
|
430 | 452 | { |
431 | 453 | $out.= '<option value="'.$obj->code.'">'; |
432 | 454 | } |
@@ -437,9 +459,10 @@ discard block |
||
437 | 459 | } |
438 | 460 | } |
439 | 461 | $out.= '</select>'; |
440 | - if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
441 | - } |
|
442 | - else |
|
462 | + if ($user->admin) { |
|
463 | + $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
464 | + } |
|
465 | + } else |
|
443 | 466 | { |
444 | 467 | dol_print_error($this->db); |
445 | 468 | } |
@@ -489,8 +512,12 @@ discard block |
||
489 | 512 | $sql .= " FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_country as c"; |
490 | 513 | $sql .= " WHERE f.fk_pays=c.rowid"; |
491 | 514 | $sql .= " AND f.active = 1 AND c.active = 1"; |
492 | - if ($country_codeid) $sql .= " AND c.code = '".$country_codeid."'"; |
|
493 | - if ($filter) $sql .= " ".$filter; |
|
515 | + if ($country_codeid) { |
|
516 | + $sql .= " AND c.code = '".$country_codeid."'"; |
|
517 | + } |
|
518 | + if ($filter) { |
|
519 | + $sql .= " ".$filter; |
|
520 | + } |
|
494 | 521 | $sql .= " ORDER BY c.code"; |
495 | 522 | |
496 | 523 | dol_syslog(get_class($this)."::select_juridicalstatus", LOG_DEBUG); |
@@ -499,7 +526,10 @@ discard block |
||
499 | 526 | { |
500 | 527 | $out.= '<div id="particulier2" class="visible">'; |
501 | 528 | $out.= '<select class="flat minwidth200" name="'.$htmlname.'" id="'.$htmlname.'">'; |
502 | - if ($country_codeid) $out.= '<option value="0"> </option>'; // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select. |
|
529 | + if ($country_codeid) { |
|
530 | + $out.= '<option value="0"> </option>'; |
|
531 | + } |
|
532 | + // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select. |
|
503 | 533 | |
504 | 534 | $num = $this->db->num_rows($resql); |
505 | 535 | if ($num) |
@@ -510,9 +540,11 @@ discard block |
||
510 | 540 | { |
511 | 541 | $obj = $this->db->fetch_object($resql); |
512 | 542 | |
513 | - if ($obj->code) // We exclude empty line, we will add it later |
|
543 | + if ($obj->code) { |
|
544 | + // We exclude empty line, we will add it later |
|
514 | 545 | { |
515 | 546 | $labelcountry=(($langs->trans("Country".$obj->country_code)!="Country".$obj->country_code) ? $langs->trans("Country".$obj->country_code) : $obj->country); |
547 | + } |
|
516 | 548 | $labeljs=(($langs->trans("JuridicalStatus".$obj->code)!="JuridicalStatus".$obj->code) ? $langs->trans("JuridicalStatus".$obj->code) : ($obj->label!='-'?$obj->label:'')); // $obj->label is already in output charset (converted by database driver) |
517 | 549 | $arraydata[$obj->code]=array('code'=>$obj->code, 'label'=>$labeljs, 'label_sort'=>$labelcountry.'_'.$labeljs, 'country_code'=>$obj->country_code, 'country'=>$labelcountry); |
518 | 550 | } |
@@ -520,10 +552,12 @@ discard block |
||
520 | 552 | } |
521 | 553 | |
522 | 554 | $arraydata=dol_sort_array($arraydata, 'label_sort', 'ASC'); |
523 | - if (empty($country_codeid)) // Introduce empty value (if $country_codeid not empty, empty value was already added) |
|
555 | + if (empty($country_codeid)) { |
|
556 | + // Introduce empty value (if $country_codeid not empty, empty value was already added) |
|
524 | 557 | { |
525 | 558 | $arraydata[0]=array('code'=>0, 'label'=>'', 'label_sort'=>'_', 'country_code'=>'', 'country'=>''); |
526 | 559 | } |
560 | + } |
|
527 | 561 | |
528 | 562 | foreach($arraydata as $key => $val) |
529 | 563 | { |
@@ -540,8 +574,7 @@ discard block |
||
540 | 574 | if ($selected > 0 && $selected == $val['code']) |
541 | 575 | { |
542 | 576 | $out.= '<option value="'.$val['code'].'" selected>'; |
543 | - } |
|
544 | - else |
|
577 | + } else |
|
545 | 578 | { |
546 | 579 | $out.= '<option value="'.$val['code'].'">'; |
547 | 580 | } |
@@ -551,15 +584,16 @@ discard block |
||
551 | 584 | } |
552 | 585 | } |
553 | 586 | $out.= '</select>'; |
554 | - if ($user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
587 | + if ($user->admin) { |
|
588 | + $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
589 | + } |
|
555 | 590 | |
556 | 591 | // Make select dynamic |
557 | 592 | include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
558 | 593 | $out .= ajax_combobox($htmlname); |
559 | 594 | |
560 | 595 | $out.= '</div>'; |
561 | - } |
|
562 | - else |
|
596 | + } else |
|
563 | 597 | { |
564 | 598 | dol_print_error($this->db); |
565 | 599 | } |
@@ -611,7 +645,8 @@ discard block |
||
611 | 645 | // To refresh contacts list on thirdparty list change |
612 | 646 | $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); |
613 | 647 | |
614 | - if (count($events)) // If there is some ajax events to run once selection is done, we add code here to run events |
|
648 | + if (count($events)) { |
|
649 | + // If there is some ajax events to run once selection is done, we add code here to run events |
|
615 | 650 | { |
616 | 651 | print '<script type="text/javascript"> |
617 | 652 | jQuery(document).ready(function() { |
@@ -662,13 +697,13 @@ discard block |
||
662 | 697 | }); |
663 | 698 | </script>'; |
664 | 699 | } |
700 | + } |
|
665 | 701 | |
666 | 702 | print "\n".'<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->'."\n"; |
667 | 703 | print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="'.$name.'" />'; |
668 | 704 | print ajax_autocompleter(($socid?$socid:-1), $htmlname, DOL_URL_ROOT.'/societe/ajaxcompanies.php', '', $minLength, 0); |
669 | 705 | return $socid; |
670 | - } |
|
671 | - else |
|
706 | + } else |
|
672 | 707 | { |
673 | 708 | // Search to list thirdparties |
674 | 709 | $sql = "SELECT s.rowid, s.nom as name FROM"; |
@@ -698,20 +733,27 @@ discard block |
||
698 | 733 | while ($i < $num) |
699 | 734 | { |
700 | 735 | $obj = $this->db->fetch_object($resql); |
701 | - if ($i == 0) $firstCompany = $obj->rowid; |
|
736 | + if ($i == 0) { |
|
737 | + $firstCompany = $obj->rowid; |
|
738 | + } |
|
702 | 739 | $disabled=0; |
703 | - if (is_array($limitto) && count($limitto) && ! in_array($obj->rowid,$limitto)) $disabled=1; |
|
740 | + if (is_array($limitto) && count($limitto) && ! in_array($obj->rowid,$limitto)) { |
|
741 | + $disabled=1; |
|
742 | + } |
|
704 | 743 | if ($selected > 0 && $selected == $obj->rowid) |
705 | 744 | { |
706 | 745 | print '<option value="'.$obj->rowid.'"'; |
707 | - if ($disabled) print ' disabled'; |
|
746 | + if ($disabled) { |
|
747 | + print ' disabled'; |
|
748 | + } |
|
708 | 749 | print ' selected>'.dol_trunc($obj->name,24).'</option>'; |
709 | 750 | $firstCompany = $obj->rowid; |
710 | - } |
|
711 | - else |
|
751 | + } else |
|
712 | 752 | { |
713 | 753 | print '<option value="'.$obj->rowid.'"'; |
714 | - if ($disabled) print ' disabled'; |
|
754 | + if ($disabled) { |
|
755 | + print ' disabled'; |
|
756 | + } |
|
715 | 757 | print '>'.dol_trunc($obj->name,24).'</option>'; |
716 | 758 | } |
717 | 759 | $i ++; |
@@ -719,8 +761,7 @@ discard block |
||
719 | 761 | } |
720 | 762 | print "</select>\n"; |
721 | 763 | return $firstCompany; |
722 | - } |
|
723 | - else |
|
764 | + } else |
|
724 | 765 | { |
725 | 766 | dol_print_error($this->db); |
726 | 767 | print 'Error sql'; |
@@ -748,15 +789,21 @@ discard block |
||
748 | 789 | { |
749 | 790 | $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1); |
750 | 791 | print '<select class="flat valignmiddle'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
751 | - if ($showempty) print '<option value="0"></option>'; |
|
792 | + if ($showempty) { |
|
793 | + print '<option value="0"></option>'; |
|
794 | + } |
|
752 | 795 | foreach($lesTypes as $key=>$value) |
753 | 796 | { |
754 | 797 | print '<option value="'.$key.'"'; |
755 | - if ($key == $selected) print ' selected'; |
|
798 | + if ($key == $selected) { |
|
799 | + print ' selected'; |
|
800 | + } |
|
756 | 801 | print '>'.$value.'</option>'; |
757 | 802 | } |
758 | 803 | print "</select>"; |
759 | - if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
804 | + if ($user->admin) { |
|
805 | + print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
806 | + } |
|
760 | 807 | print "\n"; |
761 | 808 | } |
762 | 809 | } |
@@ -782,7 +829,9 @@ discard block |
||
782 | 829 | $out=''; |
783 | 830 | |
784 | 831 | $size=''; |
785 | - if (!empty($fieldsize)) $size='size="'.$fieldsize.'"'; |
|
832 | + if (!empty($fieldsize)) { |
|
833 | + $size='size="'.$fieldsize.'"'; |
|
834 | + } |
|
786 | 835 | |
787 | 836 | if ($conf->use_javascript_ajax && empty($disableautocomplete)) |
788 | 837 | { |
@@ -815,27 +864,51 @@ discard block |
||
815 | 864 | if ($country_code == 'FR') |
816 | 865 | { |
817 | 866 | if (isset($idprof)) { |
818 | - if ($idprof==1) $formlength=9; |
|
819 | - else if ($idprof==2) $formlength=14; |
|
820 | - else if ($idprof==3) $formlength=5; // 4 chiffres et 1 lettre depuis janvier |
|
821 | - else if ($idprof==4) $formlength=32; // No maximum as we need to include a town name in this id |
|
867 | + if ($idprof==1) { |
|
868 | + $formlength=9; |
|
869 | + } else if ($idprof==2) { |
|
870 | + $formlength=14; |
|
871 | + } else if ($idprof==3) { |
|
872 | + $formlength=5; |
|
873 | + } |
|
874 | + // 4 chiffres et 1 lettre depuis janvier |
|
875 | + else if ($idprof==4) { |
|
876 | + $formlength=32; |
|
877 | + } |
|
878 | + // No maximum as we need to include a town name in this id |
|
822 | 879 | } |
823 | - } |
|
824 | - else if ($country_code == 'ES') |
|
880 | + } else if ($country_code == 'ES') |
|
825 | 881 | { |
826 | - if ($idprof==1) $formlength=9; //CIF/NIF/NIE 9 digits |
|
827 | - if ($idprof==2) $formlength=12; //NASS 12 digits without / |
|
828 | - if ($idprof==3) $formlength=5; //CNAE 5 digits |
|
829 | - if ($idprof==4) $formlength=32; //depend of college |
|
882 | + if ($idprof==1) { |
|
883 | + $formlength=9; |
|
884 | + } |
|
885 | + //CIF/NIF/NIE 9 digits |
|
886 | + if ($idprof==2) { |
|
887 | + $formlength=12; |
|
888 | + } |
|
889 | + //NASS 12 digits without / |
|
890 | + if ($idprof==3) { |
|
891 | + $formlength=5; |
|
892 | + } |
|
893 | + //CNAE 5 digits |
|
894 | + if ($idprof==4) { |
|
895 | + $formlength=32; |
|
896 | + } |
|
897 | + //depend of college |
|
830 | 898 | } |
831 | 899 | } |
832 | 900 | |
833 | 901 | $selected=$preselected; |
834 | 902 | if (! $selected && isset($idprof)) { |
835 | - if ($idprof==1 && ! empty($this->idprof1)) $selected=$this->idprof1; |
|
836 | - else if ($idprof==2 && ! empty($this->idprof2)) $selected=$this->idprof2; |
|
837 | - else if ($idprof==3 && ! empty($this->idprof3)) $selected=$this->idprof3; |
|
838 | - else if ($idprof==4 && ! empty($this->idprof4)) $selected=$this->idprof4; |
|
903 | + if ($idprof==1 && ! empty($this->idprof1)) { |
|
904 | + $selected=$this->idprof1; |
|
905 | + } else if ($idprof==2 && ! empty($this->idprof2)) { |
|
906 | + $selected=$this->idprof2; |
|
907 | + } else if ($idprof==3 && ! empty($this->idprof3)) { |
|
908 | + $selected=$this->idprof3; |
|
909 | + } else if ($idprof==4 && ! empty($this->idprof4)) { |
|
910 | + $selected=$this->idprof4; |
|
911 | + } |
|
839 | 912 | } |
840 | 913 | |
841 | 914 | $maxlength=$formlength; |
@@ -875,8 +948,7 @@ discard block |
||
875 | 948 | if ($selected == $valors[$i]) |
876 | 949 | { |
877 | 950 | print '<option value="'.$valors[$i].'" selected>'; |
878 | - } |
|
879 | - else |
|
951 | + } else |
|
880 | 952 | { |
881 | 953 | print '<option value="'.$valors[$i].'">'; |
882 | 954 | } |
@@ -545,8 +545,7 @@ |
||
545 | 545 | $ret = $this->InitPrinter($printerid); |
546 | 546 | if ($ret>0) { |
547 | 547 | setEventMessages($this->error, $this->errors, 'errors'); |
548 | - } |
|
549 | - else |
|
548 | + } else |
|
550 | 549 | { |
551 | 550 | $nboflines = count($vals); |
552 | 551 | for ($line=0; $line < $nboflines; $line++) |
@@ -300,8 +300,9 @@ discard block |
||
300 | 300 | */ |
301 | 301 | function setErrorsTo($_strErrorsTo) |
302 | 302 | { |
303 | - if ( $_strErrorsTo ) |
|
304 | - $this->_errorsTo = $this->_strip_email($_strErrorsTo); |
|
303 | + if ( $_strErrorsTo ) { |
|
304 | + $this->_errorsTo = $this->_strip_email($_strErrorsTo); |
|
305 | + } |
|
305 | 306 | } |
306 | 307 | |
307 | 308 | /** |
@@ -314,10 +315,11 @@ discard block |
||
314 | 315 | { |
315 | 316 | $_retValue = ''; |
316 | 317 | |
317 | - if ( $_part === true ) |
|
318 | - $_retValue = $this->_errorsTo; |
|
319 | - else |
|
320 | - $_retValue = $this->_errorsTo[$_part]; |
|
318 | + if ( $_part === true ) { |
|
319 | + $_retValue = $this->_errorsTo; |
|
320 | + } else { |
|
321 | + $_retValue = $this->_errorsTo[$_part]; |
|
322 | + } |
|
321 | 323 | |
322 | 324 | return $_retValue; |
323 | 325 | } |
@@ -373,8 +375,7 @@ discard block |
||
373 | 375 | { |
374 | 376 | $this->_setErr(99, $host . ' is either offline or is an invalid host name.'); |
375 | 377 | $_retVal = false; |
376 | - } |
|
377 | - else |
|
378 | + } else |
|
378 | 379 | { |
379 | 380 | //See if we can connect to the SMTP server |
380 | 381 | if ($this->socket = @fsockopen( |
@@ -383,23 +384,28 @@ discard block |
||
383 | 384 | $this->errno, // actual system level error |
384 | 385 | $this->errstr, // and any text that goes with the error |
385 | 386 | $this->_smtpTimeout |
386 | - )) // timeout for reading/writing data over the socket |
|
387 | + )) { |
|
388 | + // timeout for reading/writing data over the socket |
|
387 | 389 | { |
388 | 390 | // Fix from PHP SMTP class by 'Chris Ryan' |
389 | 391 | // Sometimes the SMTP server takes a little longer to respond |
390 | 392 | // so we will give it a longer timeout for the first read |
391 | 393 | // Windows still does not have support for this timeout function |
392 | 394 | if (function_exists('stream_set_timeout')) stream_set_timeout($this->socket, $this->_smtpTimeout, 0); |
395 | + } |
|
393 | 396 | |
394 | 397 | // Check response from Server |
395 | - if ( $_retVal = $this->server_parse($this->socket, "220") ) |
|
396 | - $_retVal = $this->socket; |
|
398 | + if ( $_retVal = $this->server_parse($this->socket, "220") ) { |
|
399 | + $_retVal = $this->socket; |
|
400 | + } |
|
397 | 401 | } |
398 | 402 | // This connection attempt failed. |
399 | 403 | else |
400 | 404 | { |
401 | 405 | // @CHANGE LDR |
402 | - if (empty($this->errstr)) $this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort(); |
|
406 | + if (empty($this->errstr)) { |
|
407 | + $this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort(); |
|
408 | + } |
|
403 | 409 | $this->_setErr($this->errno, $this->errstr); |
404 | 410 | $_retVal = false; |
405 | 411 | } |
@@ -429,7 +435,9 @@ discard block |
||
429 | 435 | $host=preg_replace('@ssl://@i','',$host); // Remove prefix |
430 | 436 | $host=preg_replace('@tls://@i','',$host); // Remove prefix |
431 | 437 | |
432 | - if ($usetls) $host='tls://'.$host; |
|
438 | + if ($usetls) { |
|
439 | + $host='tls://'.$host; |
|
440 | + } |
|
433 | 441 | |
434 | 442 | $hosth = $host; |
435 | 443 | |
@@ -506,10 +514,10 @@ discard block |
||
506 | 514 | |
507 | 515 | // The error here just means the ID/password combo doesn't work. |
508 | 516 | // There is not a method to determine which is the problem, ID or password |
509 | - if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') ) |
|
510 | - $this->_setErr(130, 'Invalid Authentication Credentials.'); |
|
511 | - } |
|
512 | - else |
|
517 | + if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') ) { |
|
518 | + $this->_setErr(130, 'Invalid Authentication Credentials.'); |
|
519 | + } |
|
520 | + } else |
|
513 | 521 | { |
514 | 522 | $this->_setErr(126, '"' . $host . '" does not support authenticated connections.'); |
515 | 523 | } |
@@ -672,14 +680,17 @@ discard block |
||
672 | 680 | { |
673 | 681 | // Set these properties ONLY if they are set in the php.ini file. |
674 | 682 | // Otherwise the default values will be used. |
675 | - if ( $_host = ini_get('SMTPs') ) |
|
676 | - $this->setHost($_host); |
|
683 | + if ( $_host = ini_get('SMTPs') ) { |
|
684 | + $this->setHost($_host); |
|
685 | + } |
|
677 | 686 | |
678 | - if ( $_port = ini_get('smtp_port') ) |
|
679 | - $this->setPort($_port); |
|
687 | + if ( $_port = ini_get('smtp_port') ) { |
|
688 | + $this->setPort($_port); |
|
689 | + } |
|
680 | 690 | |
681 | - if ( $_from = ini_get('sendmail_from') ) |
|
682 | - $this->setFrom($_from); |
|
691 | + if ( $_from = ini_get('sendmail_from') ) { |
|
692 | + $this->setFrom($_from); |
|
693 | + } |
|
683 | 694 | } |
684 | 695 | |
685 | 696 | // Send back what we have |
@@ -698,8 +709,9 @@ discard block |
||
698 | 709 | function setTransportType($_type = 0) |
699 | 710 | { |
700 | 711 | if ( ( is_numeric($_type) ) && |
701 | - ( ( $_type >= 0 ) && ( $_type <= 3 ) ) ) |
|
702 | - $this->_transportType = $_type; |
|
712 | + ( ( $_type >= 0 ) && ( $_type <= 3 ) ) ) { |
|
713 | + $this->_transportType = $_type; |
|
714 | + } |
|
703 | 715 | } |
704 | 716 | |
705 | 717 | /** |
@@ -740,8 +752,9 @@ discard block |
||
740 | 752 | */ |
741 | 753 | function setHost($_strHost) |
742 | 754 | { |
743 | - if ( $_strHost ) |
|
744 | - $this->_smtpsHost = $_strHost; |
|
755 | + if ( $_strHost ) { |
|
756 | + $this->_smtpsHost = $_strHost; |
|
757 | + } |
|
745 | 758 | } |
746 | 759 | |
747 | 760 | /** |
@@ -766,8 +779,9 @@ discard block |
||
766 | 779 | function setPort($_intPort) |
767 | 780 | { |
768 | 781 | if ( ( is_numeric($_intPort) ) && |
769 | - ( ( $_intPort >= 1 ) && ( $_intPort <= 65536 ) ) ) |
|
770 | - $this->_smtpsPort = $_intPort; |
|
782 | + ( ( $_intPort >= 1 ) && ( $_intPort <= 65536 ) ) ) { |
|
783 | + $this->_smtpsPort = $_intPort; |
|
784 | + } |
|
771 | 785 | } |
772 | 786 | |
773 | 787 | /** |
@@ -832,8 +846,9 @@ discard block |
||
832 | 846 | */ |
833 | 847 | function setCharSet($_strCharSet) |
834 | 848 | { |
835 | - if ( $_strCharSet ) |
|
836 | - $this->_smtpsCharSet = $_strCharSet; |
|
849 | + if ( $_strCharSet ) { |
|
850 | + $this->_smtpsCharSet = $_strCharSet; |
|
851 | + } |
|
837 | 852 | } |
838 | 853 | |
839 | 854 | /** |
@@ -863,8 +878,9 @@ discard block |
||
863 | 878 | */ |
864 | 879 | function setTransEncode($_strTransEncode) |
865 | 880 | { |
866 | - if (array_search($_strTransEncode, $this->_smtpsTransEncodeTypes)) |
|
867 | - $this->_smtpsTransEncode = $_strTransEncode; |
|
881 | + if (array_search($_strTransEncode, $this->_smtpsTransEncodeTypes)) { |
|
882 | + $this->_smtpsTransEncode = $_strTransEncode; |
|
883 | + } |
|
868 | 884 | } |
869 | 885 | |
870 | 886 | /** |
@@ -895,8 +911,9 @@ discard block |
||
895 | 911 | */ |
896 | 912 | function setTransEncodeType($_strTransEncodeType) |
897 | 913 | { |
898 | - if (array_search($_strTransEncodeType, $this->_smtpsTransEncodeTypes)) |
|
899 | - $this->_smtpsTransEncodeType = $_strTransEncodeType; |
|
914 | + if (array_search($_strTransEncodeType, $this->_smtpsTransEncodeTypes)) { |
|
915 | + $this->_smtpsTransEncodeType = $_strTransEncodeType; |
|
916 | + } |
|
900 | 917 | } |
901 | 918 | |
902 | 919 | /** |
@@ -920,8 +937,9 @@ discard block |
||
920 | 937 | */ |
921 | 938 | function setFrom($_strFrom) |
922 | 939 | { |
923 | - if ( $_strFrom ) |
|
924 | - $this->_msgFrom = $this->_strip_email($_strFrom); |
|
940 | + if ( $_strFrom ) { |
|
941 | + $this->_msgFrom = $this->_strip_email($_strFrom); |
|
942 | + } |
|
925 | 943 | } |
926 | 944 | |
927 | 945 | /** |
@@ -934,10 +952,11 @@ discard block |
||
934 | 952 | { |
935 | 953 | $_retValue = ''; |
936 | 954 | |
937 | - if ( $_part === true ) |
|
938 | - $_retValue = $this->_msgFrom; |
|
939 | - else |
|
940 | - $_retValue = $this->_msgFrom[$_part]; |
|
955 | + if ( $_part === true ) { |
|
956 | + $_retValue = $this->_msgFrom; |
|
957 | + } else { |
|
958 | + $_retValue = $this->_msgFrom[$_part]; |
|
959 | + } |
|
941 | 960 | |
942 | 961 | return $_retValue; |
943 | 962 | } |
@@ -950,8 +969,9 @@ discard block |
||
950 | 969 | */ |
951 | 970 | function setReplyTo($_strReplyTo) |
952 | 971 | { |
953 | - if ( $_strReplyTo ) |
|
954 | - $this->_msgReplyTo = $this->_strip_email($_strReplyTo); |
|
972 | + if ( $_strReplyTo ) { |
|
973 | + $this->_msgReplyTo = $this->_strip_email($_strReplyTo); |
|
974 | + } |
|
955 | 975 | } |
956 | 976 | |
957 | 977 | /** |
@@ -964,10 +984,11 @@ discard block |
||
964 | 984 | { |
965 | 985 | $_retValue = ''; |
966 | 986 | |
967 | - if ( $_part === true ) |
|
968 | - $_retValue = $this->_msgReplyTo; |
|
969 | - else |
|
970 | - $_retValue = $this->_msgReplyTo[$_part]; |
|
987 | + if ( $_part === true ) { |
|
988 | + $_retValue = $this->_msgReplyTo; |
|
989 | + } else { |
|
990 | + $_retValue = $this->_msgReplyTo[$_part]; |
|
991 | + } |
|
971 | 992 | |
972 | 993 | return $_retValue; |
973 | 994 | } |
@@ -996,13 +1017,15 @@ discard block |
||
996 | 1017 | if ( is_string($_addrList) ) |
997 | 1018 | { |
998 | 1019 | // This could be a COMMA delimited string |
999 | - if ( strstr($_addrList, ',') ) |
|
1000 | - // "explode "list" into an array |
|
1020 | + if ( strstr($_addrList, ',') ) { |
|
1021 | + // "explode "list" into an array |
|
1001 | 1022 | $_addrList = explode(',', $_addrList); |
1023 | + } |
|
1002 | 1024 | |
1003 | 1025 | // Stick it in an array |
1004 | - else |
|
1005 | - $_addrList = array($_addrList); |
|
1026 | + else { |
|
1027 | + $_addrList = array($_addrList); |
|
1028 | + } |
|
1006 | 1029 | } |
1007 | 1030 | |
1008 | 1031 | // take the array of addresses and split them further |
@@ -1076,13 +1099,14 @@ discard block |
||
1076 | 1099 | if ( count($_tmpAry) == 2 ) |
1077 | 1100 | { |
1078 | 1101 | // We may not really have a "Real Name" |
1079 | - if ( $_tmpAry[0]) |
|
1080 | - $_aryEmail['real'] = trim($_tmpAry[0], ' ">'); |
|
1102 | + if ( $_tmpAry[0]) { |
|
1103 | + $_aryEmail['real'] = trim($_tmpAry[0], ' ">'); |
|
1104 | + } |
|
1081 | 1105 | |
1082 | 1106 | $_aryEmail['addr'] = $_tmpAry[1]; |
1107 | + } else { |
|
1108 | + $_aryEmail['addr'] = $_tmpAry[0]; |
|
1083 | 1109 | } |
1084 | - else |
|
1085 | - $_aryEmail['addr'] = $_tmpAry[0]; |
|
1086 | 1110 | |
1087 | 1111 | // Pull User Name and Host.tld apart |
1088 | 1112 | list($_aryEmail['user'], $_aryEmail['host'] ) = explode('@', $_aryEmail['addr']); |
@@ -1149,12 +1173,13 @@ discard block |
||
1149 | 1173 | { |
1150 | 1174 | foreach ( $this->_msgRecipients[$_host][$_which] as $_addr => $_realName ) |
1151 | 1175 | { |
1152 | - if ( $_realName ) // @CHANGE LDR |
|
1176 | + if ( $_realName ) { |
|
1177 | + // @CHANGE LDR |
|
1153 | 1178 | { |
1154 | 1179 | $_realName = '"' . $_realName . '"'; |
1155 | - $_RCPT_list[] = $_realName . ' <' . $_addr . '@' . $_host . '>'; |
|
1156 | 1180 | } |
1157 | - else |
|
1181 | + $_RCPT_list[] = $_realName . ' <' . $_addr . '@' . $_host . '>'; |
|
1182 | + } else |
|
1158 | 1183 | { |
1159 | 1184 | $_RCPT_list[] = $_addr . '@' . $_host; |
1160 | 1185 | } |
@@ -1163,14 +1188,12 @@ discard block |
||
1163 | 1188 | } |
1164 | 1189 | |
1165 | 1190 | return implode(', ', $_RCPT_list); |
1166 | - } |
|
1167 | - else |
|
1191 | + } else |
|
1168 | 1192 | { |
1169 | 1193 | $this->_setErr(101, 'No eMail Address for message to be sent to.'); |
1170 | 1194 | return false; |
1171 | 1195 | } |
1172 | - } |
|
1173 | - else |
|
1196 | + } else |
|
1174 | 1197 | { |
1175 | 1198 | $this->_setErr(102, 'eMail type not defined.'); |
1176 | 1199 | return false; |
@@ -1185,8 +1208,9 @@ discard block |
||
1185 | 1208 | */ |
1186 | 1209 | function setTO($_addrTo) |
1187 | 1210 | { |
1188 | - if ( $_addrTo ) |
|
1189 | - $this->_buildAddrList('to', $_addrTo); |
|
1211 | + if ( $_addrTo ) { |
|
1212 | + $this->_buildAddrList('to', $_addrTo); |
|
1213 | + } |
|
1190 | 1214 | } |
1191 | 1215 | |
1192 | 1216 | /** |
@@ -1207,8 +1231,9 @@ discard block |
||
1207 | 1231 | */ |
1208 | 1232 | function setCC($_strCC) |
1209 | 1233 | { |
1210 | - if ( $_strCC ) |
|
1211 | - $this->_buildAddrList('cc', $_strCC); |
|
1234 | + if ( $_strCC ) { |
|
1235 | + $this->_buildAddrList('cc', $_strCC); |
|
1236 | + } |
|
1212 | 1237 | } |
1213 | 1238 | |
1214 | 1239 | /** |
@@ -1229,8 +1254,9 @@ discard block |
||
1229 | 1254 | */ |
1230 | 1255 | function setBCC($_strBCC) |
1231 | 1256 | { |
1232 | - if ( $_strBCC ) |
|
1233 | - $this->_buildAddrList('bcc', $_strBCC); |
|
1257 | + if ( $_strBCC ) { |
|
1258 | + $this->_buildAddrList('bcc', $_strBCC); |
|
1259 | + } |
|
1234 | 1260 | } |
1235 | 1261 | |
1236 | 1262 | /** |
@@ -1251,8 +1277,9 @@ discard block |
||
1251 | 1277 | */ |
1252 | 1278 | function setSubject($_strSubject = '') |
1253 | 1279 | { |
1254 | - if ( $_strSubject ) |
|
1255 | - $this->_msgSubject = $_strSubject; |
|
1280 | + if ( $_strSubject ) { |
|
1281 | + $this->_msgSubject = $_strSubject; |
|
1282 | + } |
|
1256 | 1283 | } |
1257 | 1284 | |
1258 | 1285 | /** |
@@ -1277,8 +1304,9 @@ discard block |
||
1277 | 1304 | $_header = 'From: ' . $this->getFrom('org') . "\r\n" |
1278 | 1305 | . 'To: ' . $this->getTO() . "\r\n"; |
1279 | 1306 | |
1280 | - if ( $this->getCC() ) |
|
1281 | - $_header .= 'Cc: ' . $this->getCC() . "\r\n"; |
|
1307 | + if ( $this->getCC() ) { |
|
1308 | + $_header .= 'Cc: ' . $this->getCC() . "\r\n"; |
|
1309 | + } |
|
1282 | 1310 | |
1283 | 1311 | /* Note: |
1284 | 1312 | * BCC email addresses must be listed in the RCPT TO command list, |
@@ -1311,33 +1339,41 @@ discard block |
||
1311 | 1339 | $_header .= 'Message-ID: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n"; |
1312 | 1340 | $_header .= 'References: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n"; |
1313 | 1341 | $_header .= 'X-Dolibarr-TRACKID: ' . $trackid . '@' . $host . "\r\n"; |
1314 | - } |
|
1315 | - else |
|
1342 | + } else |
|
1316 | 1343 | { |
1317 | 1344 | $_header .= 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n"; |
1318 | 1345 | } |
1319 | - if (! empty($_SERVER['REMOTE_ADDR'])) $_header .= "X-RemoteAddr: " . $_SERVER['REMOTE_ADDR']. "\r\n"; |
|
1320 | - if ( $this->getMoreInHeader() ) |
|
1321 | - $_header .= $this->getMoreInHeader(); // Value must include the "\r\n"; |
|
1346 | + if (! empty($_SERVER['REMOTE_ADDR'])) { |
|
1347 | + $_header .= "X-RemoteAddr: " . $_SERVER['REMOTE_ADDR']. "\r\n"; |
|
1348 | + } |
|
1349 | + if ( $this->getMoreInHeader() ) { |
|
1350 | + $_header .= $this->getMoreInHeader(); |
|
1351 | + } |
|
1352 | + // Value must include the "\r\n"; |
|
1322 | 1353 | |
1323 | 1354 | //$_header .= |
1324 | 1355 | // 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n" |
1325 | 1356 | // 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"; |
1326 | 1357 | |
1327 | - if ( $this->getSensitivity() ) |
|
1328 | - $_header .= 'Sensitivity: ' . $this->getSensitivity() . "\r\n"; |
|
1358 | + if ( $this->getSensitivity() ) { |
|
1359 | + $_header .= 'Sensitivity: ' . $this->getSensitivity() . "\r\n"; |
|
1360 | + } |
|
1329 | 1361 | |
1330 | - if ( $this->_msgPriority != 3 ) |
|
1331 | - $_header .= $this->getPriority(); |
|
1362 | + if ( $this->_msgPriority != 3 ) { |
|
1363 | + $_header .= $this->getPriority(); |
|
1364 | + } |
|
1332 | 1365 | |
1333 | 1366 | |
1334 | 1367 | // @CHANGE LDR |
1335 | - if ( $this->getDeliveryReceipt() ) |
|
1336 | - $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n"; |
|
1337 | - if ( $this->getErrorsTo() ) |
|
1338 | - $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n"; |
|
1339 | - if ( $this->getReplyTo() ) |
|
1340 | - $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n"; |
|
1368 | + if ( $this->getDeliveryReceipt() ) { |
|
1369 | + $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n"; |
|
1370 | + } |
|
1371 | + if ( $this->getErrorsTo() ) { |
|
1372 | + $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n"; |
|
1373 | + } |
|
1374 | + if ( $this->getReplyTo() ) { |
|
1375 | + $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n"; |
|
1376 | + } |
|
1341 | 1377 | |
1342 | 1378 | $_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n"; |
1343 | 1379 | $_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART?'MAIN_MAIL_USE_MULTI_PART':'No MAIN_MAIL_USE_MULTI_PART') . "\r\n"; |
@@ -1358,10 +1394,11 @@ discard block |
||
1358 | 1394 | { |
1359 | 1395 | //if ( $strContent ) |
1360 | 1396 | //{ |
1361 | - if ( $strType == 'html' ) |
|
1362 | - $strMimeType = 'text/html'; |
|
1363 | - else |
|
1364 | - $strMimeType = 'text/plain'; |
|
1397 | + if ( $strType == 'html' ) { |
|
1398 | + $strMimeType = 'text/html'; |
|
1399 | + } else { |
|
1400 | + $strMimeType = 'text/plain'; |
|
1401 | + } |
|
1365 | 1402 | |
1366 | 1403 | // Make RFC821 Compliant, replace bare linefeeds |
1367 | 1404 | $strContent = preg_replace("/(?<!\r)\n/si", "\r\n", $strContent); |
@@ -1385,8 +1422,9 @@ discard block |
||
1385 | 1422 | $this->_msgContent[$strType]['data'] = $strContent; |
1386 | 1423 | $this->_msgContent[$strType]['dataText'] = $strContentAltText; |
1387 | 1424 | |
1388 | - if ( $this->getMD5flag() ) |
|
1389 | - $this->_msgContent[$strType]['md5'] = dol_hash($strContent, 3); |
|
1425 | + if ( $this->getMD5flag() ) { |
|
1426 | + $this->_msgContent[$strType]['md5'] = dol_hash($strContent, 3); |
|
1427 | + } |
|
1390 | 1428 | //} |
1391 | 1429 | } |
1392 | 1430 | |
@@ -1409,8 +1447,9 @@ discard block |
||
1409 | 1447 | $keyCount = count($_types); |
1410 | 1448 | |
1411 | 1449 | // If we have ZERO, we have a problem |
1412 | - if( $keyCount === 0 ) |
|
1413 | - die ("Sorry, no content"); |
|
1450 | + if( $keyCount === 0 ) { |
|
1451 | + die ("Sorry, no content"); |
|
1452 | + } |
|
1414 | 1453 | |
1415 | 1454 | // If we have ONE, we can use the simple format |
1416 | 1455 | else if( $keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) |
@@ -1423,8 +1462,9 @@ discard block |
||
1423 | 1462 | . 'Content-Disposition: inline' . "\r\n" |
1424 | 1463 | . 'Content-Description: Message' . "\r\n"; |
1425 | 1464 | |
1426 | - if ( $this->getMD5flag() ) |
|
1427 | - $content .= 'Content-MD5: ' . $_msgData['md5'] . "\r\n"; |
|
1465 | + if ( $this->getMD5flag() ) { |
|
1466 | + $content .= 'Content-MD5: ' . $_msgData['md5'] . "\r\n"; |
|
1467 | + } |
|
1428 | 1468 | |
1429 | 1469 | $content .= "\r\n" |
1430 | 1470 | . $_msgData['data'] . "\r\n"; |
@@ -1447,9 +1487,11 @@ discard block |
||
1447 | 1487 | |
1448 | 1488 | $content .= "--" . $this->_getBoundary('mixed') . "\r\n"; |
1449 | 1489 | |
1450 | - if (key_exists('image', $this->_msgContent)) // If inline image found |
|
1490 | + if (key_exists('image', $this->_msgContent)) { |
|
1491 | + // If inline image found |
|
1451 | 1492 | { |
1452 | 1493 | $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; |
1494 | + } |
|
1453 | 1495 | $content .= "\r\n"; |
1454 | 1496 | $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; |
1455 | 1497 | } |
@@ -1472,8 +1514,9 @@ discard block |
||
1472 | 1514 | . 'Content-Transfer-Encoding: base64' . "\r\n" |
1473 | 1515 | . 'Content-Description: ' . $_data['fileName'] ."\r\n"; |
1474 | 1516 | |
1475 | - if ( $this->getMD5flag() ) |
|
1476 | - $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; |
|
1517 | + if ( $this->getMD5flag() ) { |
|
1518 | + $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; |
|
1519 | + } |
|
1477 | 1520 | |
1478 | 1521 | $content .= "\r\n" . $_data['data'] . "\r\n\r\n"; |
1479 | 1522 | } |
@@ -1491,8 +1534,9 @@ discard block |
||
1491 | 1534 | . 'Content-Disposition: inline; filename="' . $_data['imageName'] . '"' . "\r\n" |
1492 | 1535 | . 'Content-ID: <' . $_data['cid'] . '> ' . "\r\n"; |
1493 | 1536 | |
1494 | - if ( $this->getMD5flag() ) |
|
1495 | - $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; |
|
1537 | + if ( $this->getMD5flag() ) { |
|
1538 | + $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; |
|
1539 | + } |
|
1496 | 1540 | |
1497 | 1541 | $content .= "\r\n" |
1498 | 1542 | . $_data['data'] . "\r\n"; |
@@ -1502,8 +1546,7 @@ discard block |
||
1502 | 1546 | $content.= "--" . $this->_getBoundary('related') . "--" . "\r\n"; |
1503 | 1547 | $content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n"; |
1504 | 1548 | $content.= "\r\n"; |
1505 | - } |
|
1506 | - else |
|
1549 | + } else |
|
1507 | 1550 | { |
1508 | 1551 | if (key_exists('image', $this->_msgContent)) |
1509 | 1552 | { |
@@ -1515,9 +1558,11 @@ discard block |
||
1515 | 1558 | $content.= "--" . $this->_getBoundary('related') . "\r\n"; |
1516 | 1559 | } |
1517 | 1560 | |
1518 | - if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part |
|
1561 | + if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) { |
|
1562 | + // Add plain text message part before html part |
|
1519 | 1563 | { |
1520 | 1564 | $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; |
1565 | + } |
|
1521 | 1566 | $content .= "\r\n"; |
1522 | 1567 | $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; |
1523 | 1568 | |
@@ -1538,15 +1583,18 @@ discard block |
||
1538 | 1583 | // . 'Content-Disposition: inline' . "\r\n" |
1539 | 1584 | // . 'Content-Description: ' . $type . ' message' . "\r\n"; |
1540 | 1585 | |
1541 | - if ( $this->getMD5flag() ) |
|
1542 | - $content .= 'Content-MD5: ' . $_content['md5'] . "\r\n"; |
|
1586 | + if ( $this->getMD5flag() ) { |
|
1587 | + $content .= 'Content-MD5: ' . $_content['md5'] . "\r\n"; |
|
1588 | + } |
|
1543 | 1589 | |
1544 | 1590 | $content .= "\r\n" . $_content['data'] . "\r\n"; |
1545 | 1591 | |
1546 | - if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part |
|
1592 | + if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) { |
|
1593 | + // Add plain text message part after html part |
|
1547 | 1594 | { |
1548 | 1595 | $content.= "--" . $this->_getBoundary('alternative') . "--". "\r\n"; |
1549 | 1596 | } |
1597 | + } |
|
1550 | 1598 | |
1551 | 1599 | $content .= "\r\n"; |
1552 | 1600 | } |
@@ -1579,8 +1627,9 @@ discard block |
||
1579 | 1627 | $this->_msgContent['attachment'][$strFileName]['fileName'] = $strFileName; |
1580 | 1628 | $this->_msgContent['attachment'][$strFileName]['data'] = $strContent; |
1581 | 1629 | |
1582 | - if ( $this->getMD5flag() ) |
|
1583 | - $this->_msgContent['attachment'][$strFileName]['md5'] = dol_hash($strContent, 3); |
|
1630 | + if ( $this->getMD5flag() ) { |
|
1631 | + $this->_msgContent['attachment'][$strFileName]['md5'] = dol_hash($strContent, 3); |
|
1632 | + } |
|
1584 | 1633 | } |
1585 | 1634 | } |
1586 | 1635 | |
@@ -1606,8 +1655,9 @@ discard block |
||
1606 | 1655 | $this->_msgContent['image'][$strImageName]['cid'] = $strImageCid; |
1607 | 1656 | $this->_msgContent['image'][$strImageName]['data'] = $strContent; |
1608 | 1657 | |
1609 | - if ( $this->getMD5flag() ) |
|
1610 | - $this->_msgContent['image'][$strImageName]['md5'] = dol_hash($strContent, 3); |
|
1658 | + if ( $this->getMD5flag() ) { |
|
1659 | + $this->_msgContent['image'][$strImageName]['md5'] = dol_hash($strContent, 3); |
|
1660 | + } |
|
1611 | 1661 | } |
1612 | 1662 | } |
1613 | 1663 | // END @CHANGE LDR |
@@ -1627,8 +1677,9 @@ discard block |
||
1627 | 1677 | function setSensitivity($_value = 0) |
1628 | 1678 | { |
1629 | 1679 | if ( ( is_numeric($_value) ) && |
1630 | - ( ( $_value >= 0 ) && ( $_value <= 3 ) ) ) |
|
1631 | - $this->_msgSensitivity = $_value; |
|
1680 | + ( ( $_value >= 0 ) && ( $_value <= 3 ) ) ) { |
|
1681 | + $this->_msgSensitivity = $_value; |
|
1682 | + } |
|
1632 | 1683 | } |
1633 | 1684 | |
1634 | 1685 | /** |
@@ -1662,8 +1713,9 @@ discard block |
||
1662 | 1713 | function setPriority( $_value = 3 ) |
1663 | 1714 | { |
1664 | 1715 | if ( ( is_numeric($_value) ) && |
1665 | - ( ( $_value >= 0 ) && ( $_value <= 5 ) ) ) |
|
1666 | - $this->_msgPriority = $_value; |
|
1716 | + ( ( $_value >= 0 ) && ( $_value <= 5 ) ) ) { |
|
1717 | + $this->_msgPriority = $_value; |
|
1718 | + } |
|
1667 | 1719 | } |
1668 | 1720 | |
1669 | 1721 | /** |
@@ -1716,8 +1768,9 @@ discard block |
||
1716 | 1768 | */ |
1717 | 1769 | function setXheader($strXdata) |
1718 | 1770 | { |
1719 | - if ( $strXdata ) |
|
1720 | - $this->_msgXheader[] = $strXdata; |
|
1771 | + if ( $strXdata ) { |
|
1772 | + $this->_msgXheader[] = $strXdata; |
|
1773 | + } |
|
1721 | 1774 | } |
1722 | 1775 | |
1723 | 1776 | /** |
@@ -1750,9 +1803,13 @@ discard block |
||
1750 | 1803 | */ |
1751 | 1804 | function _getBoundary($type='mixed') |
1752 | 1805 | { |
1753 | - if ($type == 'mixed') return $this->_smtpsBoundary; |
|
1754 | - else if ($type == 'related') return $this->_smtpsRelatedBoundary; |
|
1755 | - else if ($type == 'alternative') return $this->_smtpsAlternativeBoundary; |
|
1806 | + if ($type == 'mixed') { |
|
1807 | + return $this->_smtpsBoundary; |
|
1808 | + } else if ($type == 'related') { |
|
1809 | + return $this->_smtpsRelatedBoundary; |
|
1810 | + } else if ($type == 'alternative') { |
|
1811 | + return $this->_smtpsAlternativeBoundary; |
|
1812 | + } |
|
1756 | 1813 | } |
1757 | 1814 | |
1758 | 1815 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -1810,12 +1867,18 @@ discard block |
||
1810 | 1867 | function socket_send_str( $_strSend, $_returnCode = null, $CRLF = "\r\n" ) |
1811 | 1868 | { |
1812 | 1869 | // phpcs:enable |
1813 | - if ($this->_debug) $this->log.=$_strSend; // @CHANGE LDR for log |
|
1870 | + if ($this->_debug) { |
|
1871 | + $this->log.=$_strSend; |
|
1872 | + } |
|
1873 | + // @CHANGE LDR for log |
|
1814 | 1874 | fputs($this->socket, $_strSend . $CRLF); |
1815 | - if ($this->_debug) $this->log.=' ('.$_returnCode.')' . $CRLF; |
|
1875 | + if ($this->_debug) { |
|
1876 | + $this->log.=' ('.$_returnCode.')' . $CRLF; |
|
1877 | + } |
|
1816 | 1878 | |
1817 | - if ( $_returnCode ) |
|
1818 | - return $this->server_parse($this->socket, $_returnCode); |
|
1879 | + if ( $_returnCode ) { |
|
1880 | + return $this->server_parse($this->socket, $_returnCode); |
|
1881 | + } |
|
1819 | 1882 | } |
1820 | 1883 | |
1821 | 1884 | // ============================================================= |
@@ -82,8 +82,7 @@ |
||
82 | 82 | $label = $res[$label_type]; |
83 | 83 | $this->db->free($resql); |
84 | 84 | return $label; |
85 | - } |
|
86 | - else |
|
85 | + } else |
|
87 | 86 | { |
88 | 87 | $this->error=$this->db->error().' sql='.$sql; |
89 | 88 | dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR); |
@@ -137,15 +137,13 @@ discard block |
||
137 | 137 | { |
138 | 138 | $this->db->commit(); |
139 | 139 | return $this->id; |
140 | - } |
|
141 | - else |
|
140 | + } else |
|
142 | 141 | { |
143 | 142 | $this->error=$this->db->lasterror(); |
144 | 143 | $this->db->rollback(); |
145 | 144 | return $result; |
146 | 145 | } |
147 | - } |
|
148 | - else |
|
146 | + } else |
|
149 | 147 | { |
150 | 148 | $this->error=$this->db->lasterror()." sql=".$sql; |
151 | 149 | $this->db->rollback(); |
@@ -187,8 +185,7 @@ discard block |
||
187 | 185 | { |
188 | 186 | $this->db->commit(); |
189 | 187 | return 1; |
190 | - } |
|
191 | - else |
|
188 | + } else |
|
192 | 189 | { |
193 | 190 | $this->error=$this->db->lasterror(); |
194 | 191 | dol_syslog($this->error, LOG_ERR); |
@@ -223,8 +220,7 @@ discard block |
||
223 | 220 | $this->statut = $obj->statut; |
224 | 221 | |
225 | 222 | return 1; |
226 | - } |
|
227 | - else |
|
223 | + } else |
|
228 | 224 | { |
229 | 225 | $this->error=$this->db->lasterror(); |
230 | 226 | return -1; |
@@ -249,8 +245,7 @@ discard block |
||
249 | 245 | { |
250 | 246 | $this->db->commit(); |
251 | 247 | return 1; |
252 | - } |
|
253 | - else |
|
248 | + } else |
|
254 | 249 | { |
255 | 250 | $this->error=$this->db->lasterror(); |
256 | 251 | $this->db->rollback(); |
@@ -285,30 +280,37 @@ discard block |
||
285 | 280 | if ($mode == 0) |
286 | 281 | { |
287 | 282 | return $langs->trans($this->statuts[$statut]); |
288 | - } |
|
289 | - elseif ($mode == 1) |
|
283 | + } elseif ($mode == 1) |
|
290 | 284 | { |
291 | 285 | return $langs->trans($this->statuts_short[$statut]); |
292 | - } |
|
293 | - elseif ($mode == 2) |
|
286 | + } elseif ($mode == 2) |
|
294 | 287 | { |
295 | - if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]); |
|
296 | - elseif ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts_short[$statut]); |
|
297 | - } |
|
298 | - elseif ($mode == 3) |
|
288 | + if ($statut==0) { |
|
289 | + return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]); |
|
290 | + } elseif ($statut==1) { |
|
291 | + return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts_short[$statut]); |
|
292 | + } |
|
293 | + } elseif ($mode == 3) |
|
299 | 294 | { |
300 | - if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4'); |
|
301 | - elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8'); |
|
302 | - } |
|
303 | - elseif ($mode == 4) |
|
295 | + if ($statut==0 && ! empty($this->statuts_short[$statut])) { |
|
296 | + return img_picto($langs->trans($this->statuts_short[$statut]),'statut4'); |
|
297 | + } elseif ($statut==1 && ! empty($this->statuts_short[$statut])) { |
|
298 | + return img_picto($langs->trans($this->statuts_short[$statut]),'statut8'); |
|
299 | + } |
|
300 | + } elseif ($mode == 4) |
|
304 | 301 | { |
305 | - if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); |
|
306 | - elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts[$statut]); |
|
307 | - } |
|
308 | - elseif ($mode == 5) |
|
302 | + if ($statut==0 && ! empty($this->statuts_short[$statut])) { |
|
303 | + return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); |
|
304 | + } elseif ($statut==1 && ! empty($this->statuts_short[$statut])) { |
|
305 | + return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts[$statut]); |
|
306 | + } |
|
307 | + } elseif ($mode == 5) |
|
309 | 308 | { |
310 | - if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4'); |
|
311 | - elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6'); |
|
309 | + if ($statut==0 && ! empty($this->statuts_short[$statut])) { |
|
310 | + return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4'); |
|
311 | + } elseif ($statut==1 && ! empty($this->statuts_short[$statut])) { |
|
312 | + return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6'); |
|
313 | + } |
|
312 | 314 | } |
313 | 315 | } |
314 | 316 | |
@@ -350,8 +352,7 @@ discard block |
||
350 | 352 | $this->date_modification = $this->db->jdate($obj->tms); |
351 | 353 | } |
352 | 354 | $this->db->free($result); |
353 | - } |
|
354 | - else |
|
355 | + } else |
|
355 | 356 | { |
356 | 357 | dol_print_error($this->db); |
357 | 358 | } |
@@ -377,8 +378,9 @@ discard block |
||
377 | 378 | { |
378 | 379 | $obj = $this->db->fetch_object($resql); |
379 | 380 | $nb = $obj->nb; |
381 | + } else { |
|
382 | + dol_print_error($this->db); |
|
380 | 383 | } |
381 | - else dol_print_error($this->db); |
|
382 | 384 | |
383 | 385 | return $nb; |
384 | 386 | } |
@@ -403,8 +405,9 @@ discard block |
||
403 | 405 | { |
404 | 406 | $obj = $this->db->fetch_object($resql); |
405 | 407 | $nb = $obj->nb; |
408 | + } else { |
|
409 | + dol_print_error($this->db); |
|
406 | 410 | } |
407 | - else dol_print_error($this->db); |
|
408 | 411 | |
409 | 412 | return $nb; |
410 | 413 | } |
@@ -83,11 +83,21 @@ discard block |
||
83 | 83 | |
84 | 84 | // Clean parameters |
85 | 85 | |
86 | - if (isset($this->id)) $this->id=trim($this->id); |
|
87 | - if (isset($this->code)) $this->code=trim($this->code); |
|
88 | - if (isset($this->libelle)) $this->libelle=trim($this->libelle); |
|
89 | - if (isset($this->active)) $this->active=trim($this->active); |
|
90 | - if (isset($this->module)) $this->module=trim($this->module); |
|
86 | + if (isset($this->id)) { |
|
87 | + $this->id=trim($this->id); |
|
88 | + } |
|
89 | + if (isset($this->code)) { |
|
90 | + $this->code=trim($this->code); |
|
91 | + } |
|
92 | + if (isset($this->libelle)) { |
|
93 | + $this->libelle=trim($this->libelle); |
|
94 | + } |
|
95 | + if (isset($this->active)) { |
|
96 | + $this->active=trim($this->active); |
|
97 | + } |
|
98 | + if (isset($this->module)) { |
|
99 | + $this->module=trim($this->module); |
|
100 | + } |
|
91 | 101 | |
92 | 102 | |
93 | 103 | |
@@ -149,8 +159,7 @@ discard block |
||
149 | 159 | } |
150 | 160 | $this->db->rollback(); |
151 | 161 | return -1*$error; |
152 | - } |
|
153 | - else |
|
162 | + } else |
|
154 | 163 | { |
155 | 164 | $this->db->commit(); |
156 | 165 | return $this->id; |
@@ -177,9 +186,13 @@ discard block |
||
177 | 186 | $sql.= " t.active,"; |
178 | 187 | $sql.= " t.module"; |
179 | 188 | $sql.= " FROM ".MAIN_DB_PREFIX."c_typent as t"; |
180 | - if ($id) $sql.= " WHERE t.id = ".$id; |
|
181 | - elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; |
|
182 | - elseif ($label) $sql.= " WHERE t.libelle = '".$this->db->escape($label)."'"; |
|
189 | + if ($id) { |
|
190 | + $sql.= " WHERE t.id = ".$id; |
|
191 | + } elseif ($code) { |
|
192 | + $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; |
|
193 | + } elseif ($label) { |
|
194 | + $sql.= " WHERE t.libelle = '".$this->db->escape($label)."'"; |
|
195 | + } |
|
183 | 196 | |
184 | 197 | $resql=$this->db->query($sql); |
185 | 198 | if ($resql) |
@@ -198,8 +211,7 @@ discard block |
||
198 | 211 | $this->db->free($resql); |
199 | 212 | |
200 | 213 | return 1; |
201 | - } |
|
202 | - else |
|
214 | + } else |
|
203 | 215 | { |
204 | 216 | $this->error="Error ".$this->db->lasterror(); |
205 | 217 | return -1; |
@@ -220,10 +232,18 @@ discard block |
||
220 | 232 | $error=0; |
221 | 233 | |
222 | 234 | // Clean parameters |
223 | - if (isset($this->code)) $this->code=trim($this->code); |
|
224 | - if (isset($this->libelle)) $this->libelle=trim($this->libelle); |
|
225 | - if (isset($this->active)) $this->active=trim($this->active); |
|
226 | - if (isset($this->module)) $this->module=trim($this->module); |
|
235 | + if (isset($this->code)) { |
|
236 | + $this->code=trim($this->code); |
|
237 | + } |
|
238 | + if (isset($this->libelle)) { |
|
239 | + $this->libelle=trim($this->libelle); |
|
240 | + } |
|
241 | + if (isset($this->active)) { |
|
242 | + $this->active=trim($this->active); |
|
243 | + } |
|
244 | + if (isset($this->module)) { |
|
245 | + $this->module=trim($this->module); |
|
246 | + } |
|
227 | 247 | |
228 | 248 | |
229 | 249 | // Check parameters |
@@ -269,8 +289,7 @@ discard block |
||
269 | 289 | } |
270 | 290 | $this->db->rollback(); |
271 | 291 | return -1*$error; |
272 | - } |
|
273 | - else |
|
292 | + } else |
|
274 | 293 | { |
275 | 294 | $this->db->commit(); |
276 | 295 | return 1; |
@@ -325,8 +344,7 @@ discard block |
||
325 | 344 | } |
326 | 345 | $this->db->rollback(); |
327 | 346 | return -1*$error; |
328 | - } |
|
329 | - else |
|
347 | + } else |
|
330 | 348 | { |
331 | 349 | $this->db->commit(); |
332 | 350 | return 1; |