@@ -48,33 +48,33 @@ discard block |
||
| 48 | 48 | * @param int $includehidden Include also hidden boxes |
| 49 | 49 | * @return array Array of boxes |
| 50 | 50 | */ |
| 51 | - static function listBoxes($db, $mode, $zone, $user=null, $excludelist=array(), $includehidden=1) |
|
| 51 | + static function listBoxes($db, $mode, $zone, $user = null, $excludelist = array(), $includehidden = 1) |
|
| 52 | 52 | { |
| 53 | 53 | global $conf; |
| 54 | 54 | |
| 55 | - $boxes=array(); |
|
| 55 | + $boxes = array(); |
|
| 56 | 56 | |
| 57 | - $confuserzone='MAIN_BOXES_'.$zone; |
|
| 57 | + $confuserzone = 'MAIN_BOXES_'.$zone; |
|
| 58 | 58 | if ($mode == 'activated') // activated |
| 59 | 59 | { |
| 60 | 60 | $sql = "SELECT b.rowid, b.position, b.box_order, b.fk_user,"; |
| 61 | - $sql.= " d.rowid as box_id, d.file, d.note, d.tms"; |
|
| 62 | - $sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; |
|
| 63 | - $sql.= " WHERE b.box_id = d.rowid"; |
|
| 64 | - $sql.= " AND b.entity IN (0,".$conf->entity.")"; |
|
| 65 | - if ($zone >= 0) $sql.= " AND b.position = ".$zone; |
|
| 66 | - if (is_object($user)) $sql.= " AND b.fk_user IN (0,".$user->id.")"; |
|
| 67 | - else $sql.= " AND b.fk_user = 0"; |
|
| 68 | - $sql.= " ORDER BY b.box_order"; |
|
| 61 | + $sql .= " d.rowid as box_id, d.file, d.note, d.tms"; |
|
| 62 | + $sql .= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; |
|
| 63 | + $sql .= " WHERE b.box_id = d.rowid"; |
|
| 64 | + $sql .= " AND b.entity IN (0,".$conf->entity.")"; |
|
| 65 | + if ($zone >= 0) $sql .= " AND b.position = ".$zone; |
|
| 66 | + if (is_object($user)) $sql .= " AND b.fk_user IN (0,".$user->id.")"; |
|
| 67 | + else $sql .= " AND b.fk_user = 0"; |
|
| 68 | + $sql .= " ORDER BY b.box_order"; |
|
| 69 | 69 | } |
| 70 | 70 | else // available |
| 71 | 71 | { |
| 72 | 72 | $sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms"; |
| 73 | - $sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d"; |
|
| 74 | - $sql.= " WHERE d.entity IN (0,".$conf->entity.")"; |
|
| 73 | + $sql .= " FROM ".MAIN_DB_PREFIX."boxes_def as d"; |
|
| 74 | + $sql .= " WHERE d.entity IN (0,".$conf->entity.")"; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user)?$user->id:'')."", LOG_DEBUG); |
|
| 77 | + dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user) ? $user->id : '')."", LOG_DEBUG); |
|
| 78 | 78 | $resql = $db->query($sql); |
| 79 | 79 | if ($resql) |
| 80 | 80 | { |
@@ -84,18 +84,18 @@ discard block |
||
| 84 | 84 | { |
| 85 | 85 | $obj = $db->fetch_object($resql); |
| 86 | 86 | |
| 87 | - if (! in_array($obj->box_id, $excludelist)) |
|
| 87 | + if (!in_array($obj->box_id, $excludelist)) |
|
| 88 | 88 | { |
| 89 | 89 | |
| 90 | - if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs)) |
|
| 90 | + if (preg_match('/^([^@]+)@([^@]+)$/i', $obj->file, $regs)) |
|
| 91 | 91 | { |
| 92 | - $boxname = preg_replace('/\.php$/i','',$regs[1]); |
|
| 92 | + $boxname = preg_replace('/\.php$/i', '', $regs[1]); |
|
| 93 | 93 | $module = $regs[2]; |
| 94 | 94 | $relsourcefile = "/".$module."/core/boxes/".$boxname.".php"; |
| 95 | 95 | } |
| 96 | 96 | else |
| 97 | 97 | { |
| 98 | - $boxname=preg_replace('/\.php$/i','',$obj->file); |
|
| 98 | + $boxname = preg_replace('/\.php$/i', '', $obj->file); |
|
| 99 | 99 | $relsourcefile = "/core/boxes/".$boxname.".php"; |
| 100 | 100 | } |
| 101 | 101 | |
@@ -107,48 +107,48 @@ discard block |
||
| 107 | 107 | dol_include_once($relsourcefile); |
| 108 | 108 | if (class_exists($boxname)) |
| 109 | 109 | { |
| 110 | - $box=new $boxname($db,$obj->note); // Constructor may set properties like box->enabled. obj->note is note into box def, not user params. |
|
| 110 | + $box = new $boxname($db, $obj->note); // Constructor may set properties like box->enabled. obj->note is note into box def, not user params. |
|
| 111 | 111 | //$box=new stdClass(); |
| 112 | 112 | |
| 113 | 113 | // box properties |
| 114 | - $box->rowid = (empty($obj->rowid) ? '' : $obj->rowid); |
|
| 115 | - $box->id = (empty($obj->box_id) ? '' : $obj->box_id); |
|
| 116 | - $box->position = ($obj->position == '' ? '' : $obj->position); // '0' must staty '0' |
|
| 114 | + $box->rowid = (empty($obj->rowid) ? '' : $obj->rowid); |
|
| 115 | + $box->id = (empty($obj->box_id) ? '' : $obj->box_id); |
|
| 116 | + $box->position = ($obj->position == '' ? '' : $obj->position); // '0' must staty '0' |
|
| 117 | 117 | $box->box_order = (empty($obj->box_order) ? '' : $obj->box_order); |
| 118 | - $box->fk_user = (empty($obj->fk_user) ? 0 : $obj->fk_user); |
|
| 119 | - $box->sourcefile= $relsourcefile; |
|
| 120 | - $box->class = $boxname; |
|
| 118 | + $box->fk_user = (empty($obj->fk_user) ? 0 : $obj->fk_user); |
|
| 119 | + $box->sourcefile = $relsourcefile; |
|
| 120 | + $box->class = $boxname; |
|
| 121 | 121 | |
| 122 | - if ($mode == 'activated' && ! is_object($user)) // List of activated box was not yet personalized into database |
|
| 122 | + if ($mode == 'activated' && !is_object($user)) // List of activated box was not yet personalized into database |
|
| 123 | 123 | { |
| 124 | 124 | if (is_numeric($box->box_order)) |
| 125 | 125 | { |
| 126 | - if ($box->box_order % 2 == 1) $box->box_order='A'.$box->box_order; |
|
| 127 | - elseif ($box->box_order % 2 == 0) $box->box_order='B'.$box->box_order; |
|
| 126 | + if ($box->box_order % 2 == 1) $box->box_order = 'A'.$box->box_order; |
|
| 127 | + elseif ($box->box_order % 2 == 0) $box->box_order = 'B'.$box->box_order; |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | // box_def properties |
| 131 | - $box->box_id = (empty($obj->box_id) ? '' : $obj->box_id); |
|
| 132 | - $box->note = (empty($obj->note) ? '' : $obj->note); |
|
| 131 | + $box->box_id = (empty($obj->box_id) ? '' : $obj->box_id); |
|
| 132 | + $box->note = (empty($obj->note) ? '' : $obj->note); |
|
| 133 | 133 | |
| 134 | 134 | // Filter on box->enabled (used for example by box_comptes) |
| 135 | 135 | // Filter also on box->depends. Example: array("product|service") or array("contrat", "service") |
| 136 | - $enabled=$box->enabled; |
|
| 136 | + $enabled = $box->enabled; |
|
| 137 | 137 | if (isset($box->depends) && count($box->depends) > 0) |
| 138 | 138 | { |
| 139 | - foreach($box->depends as $moduleelem) |
|
| 139 | + foreach ($box->depends as $moduleelem) |
|
| 140 | 140 | { |
| 141 | - $arrayelem=explode('|',$moduleelem); |
|
| 142 | - $tmpenabled=0; // $tmpenabled is used for the '|' test (OR) |
|
| 143 | - foreach($arrayelem as $module) |
|
| 141 | + $arrayelem = explode('|', $moduleelem); |
|
| 142 | + $tmpenabled = 0; // $tmpenabled is used for the '|' test (OR) |
|
| 143 | + foreach ($arrayelem as $module) |
|
| 144 | 144 | { |
| 145 | - $tmpmodule=preg_replace('/@[^@]+/','',$module); |
|
| 146 | - if (! empty($conf->$tmpmodule->enabled)) $tmpenabled=1; |
|
| 145 | + $tmpmodule = preg_replace('/@[^@]+/', '', $module); |
|
| 146 | + if (!empty($conf->$tmpmodule->enabled)) $tmpenabled = 1; |
|
| 147 | 147 | //print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'<br>'; |
| 148 | 148 | } |
| 149 | 149 | if (empty($tmpenabled)) // We found at least one module required that is disabled |
| 150 | 150 | { |
| 151 | - $enabled=0; |
|
| 151 | + $enabled = 0; |
|
| 152 | 152 | break; |
| 153 | 153 | } |
| 154 | 154 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | //print '=>'.$boxname.'-enabled='.$enabled.'<br>'; |
| 157 | 157 | |
| 158 | 158 | //print 'xx module='.$module.' enabled='.$enabled; |
| 159 | - if ($enabled && ($includehidden || empty($box->hidden))) $boxes[]=$box; |
|
| 159 | + if ($enabled && ($includehidden || empty($box->hidden))) $boxes[] = $box; |
|
| 160 | 160 | else unset($box); |
| 161 | 161 | } |
| 162 | 162 | else |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | else |
| 171 | 171 | { |
| 172 | - dol_syslog($db->lasterror(),LOG_ERR); |
|
| 172 | + dol_syslog($db->lasterror(), LOG_ERR); |
|
| 173 | 173 | return array('error'=>$db->lasterror()); |
| 174 | 174 | } |
| 175 | 175 | |
@@ -186,70 +186,70 @@ discard block |
||
| 186 | 186 | * @param int $userid Id of user |
| 187 | 187 | * @return int <0 if KO, 0=Nothing done, > 0 if OK |
| 188 | 188 | */ |
| 189 | - static function saveboxorder($db, $zone,$boxorder,$userid=0) |
|
| 189 | + static function saveboxorder($db, $zone, $boxorder, $userid = 0) |
|
| 190 | 190 | { |
| 191 | 191 | global $conf; |
| 192 | 192 | |
| 193 | - $error=0; |
|
| 193 | + $error = 0; |
|
| 194 | 194 | |
| 195 | 195 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
| 196 | 196 | |
| 197 | 197 | dol_syslog(get_class()."::saveboxorder zone=".$zone." userid=".$userid); |
| 198 | 198 | |
| 199 | - if (! $userid || $userid == 0) return 0; |
|
| 199 | + if (!$userid || $userid == 0) return 0; |
|
| 200 | 200 | |
| 201 | 201 | $user = new User($db); |
| 202 | - $user->id=$userid; |
|
| 202 | + $user->id = $userid; |
|
| 203 | 203 | |
| 204 | 204 | $db->begin(); |
| 205 | 205 | |
| 206 | 206 | // Save parameters to say user has a dedicated setup |
| 207 | - $tab=array(); |
|
| 208 | - $confuserzone='MAIN_BOXES_'.$zone; |
|
| 209 | - $tab[$confuserzone]=1; |
|
| 207 | + $tab = array(); |
|
| 208 | + $confuserzone = 'MAIN_BOXES_'.$zone; |
|
| 209 | + $tab[$confuserzone] = 1; |
|
| 210 | 210 | if (dol_set_user_param($db, $conf, $user, $tab) < 0) |
| 211 | 211 | { |
| 212 | - $error=$db->lasterror(); |
|
| 212 | + $error = $db->lasterror(); |
|
| 213 | 213 | $db->rollback(); |
| 214 | 214 | return -3; |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | // Delete all lines |
| 218 | 218 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; |
| 219 | - $sql.= " WHERE entity = ".$conf->entity; |
|
| 220 | - $sql.= " AND fk_user = ".$userid; |
|
| 221 | - $sql.= " AND position = ".$zone; |
|
| 219 | + $sql .= " WHERE entity = ".$conf->entity; |
|
| 220 | + $sql .= " AND fk_user = ".$userid; |
|
| 221 | + $sql .= " AND position = ".$zone; |
|
| 222 | 222 | |
| 223 | 223 | dol_syslog(get_class()."::saveboxorder", LOG_DEBUG); |
| 224 | 224 | $result = $db->query($sql); |
| 225 | 225 | if ($result) |
| 226 | 226 | { |
| 227 | - $colonnes=explode('-',$boxorder); |
|
| 227 | + $colonnes = explode('-', $boxorder); |
|
| 228 | 228 | foreach ($colonnes as $collist) |
| 229 | 229 | { |
| 230 | - $part=explode(':',$collist); |
|
| 231 | - $colonne=$part[0]; |
|
| 232 | - $list=$part[1]; |
|
| 230 | + $part = explode(':', $collist); |
|
| 231 | + $colonne = $part[0]; |
|
| 232 | + $list = $part[1]; |
|
| 233 | 233 | dol_syslog(get_class()."::saveboxorder column=".$colonne.' list='.$list); |
| 234 | 234 | |
| 235 | - $i=0; |
|
| 236 | - $listarray=explode(',',$list); |
|
| 235 | + $i = 0; |
|
| 236 | + $listarray = explode(',', $list); |
|
| 237 | 237 | foreach ($listarray as $id) |
| 238 | 238 | { |
| 239 | 239 | if (is_numeric($id)) |
| 240 | 240 | { |
| 241 | 241 | //dol_syslog("aaaaa".count($listarray)); |
| 242 | 242 | $i++; |
| 243 | - $ii=sprintf('%02d',$i); |
|
| 243 | + $ii = sprintf('%02d', $i); |
|
| 244 | 244 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes"; |
| 245 | - $sql.= "(box_id, position, box_order, fk_user, entity)"; |
|
| 246 | - $sql.= " values ("; |
|
| 247 | - $sql.= " ".$id.","; |
|
| 248 | - $sql.= " ".$zone.","; |
|
| 249 | - $sql.= " '".$colonne.$ii."',"; |
|
| 250 | - $sql.= " ".$userid.","; |
|
| 251 | - $sql.= " ".$conf->entity; |
|
| 252 | - $sql.= ")"; |
|
| 245 | + $sql .= "(box_id, position, box_order, fk_user, entity)"; |
|
| 246 | + $sql .= " values ("; |
|
| 247 | + $sql .= " ".$id.","; |
|
| 248 | + $sql .= " ".$zone.","; |
|
| 249 | + $sql .= " '".$colonne.$ii."',"; |
|
| 250 | + $sql .= " ".$userid.","; |
|
| 251 | + $sql .= " ".$conf->entity; |
|
| 252 | + $sql .= ")"; |
|
| 253 | 253 | |
| 254 | 254 | dol_syslog(get_class()."::saveboxorder", LOG_DEBUG); |
| 255 | 255 | $result = $db->query($sql); |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | if ($error) |
| 265 | 265 | { |
| 266 | - $error=$db->error(); |
|
| 266 | + $error = $db->error(); |
|
| 267 | 267 | $db->rollback(); |
| 268 | 268 | return -2; |
| 269 | 269 | } |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | } |
| 276 | 276 | else |
| 277 | 277 | { |
| 278 | - $error=$db->lasterror(); |
|
| 278 | + $error = $db->lasterror(); |
|
| 279 | 279 | $db->rollback(); |
| 280 | 280 | dol_syslog(get_class()."::saveboxorder ".$error); |
| 281 | 281 | return -1; |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | /** |
| 36 | 36 | * @var string Error code (or message) |
| 37 | 37 | */ |
| 38 | - public $error=''; |
|
| 38 | + public $error = ''; |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -60,31 +60,31 @@ discard block |
||
| 60 | 60 | * @param int $showempty Show empty line |
| 61 | 61 | * @return int Nbre of project if OK, <0 if KO |
| 62 | 62 | */ |
| 63 | - function select_interventions($socid=-1, $selected='', $htmlname='interventionid', $maxlength=16, $showempty=1) |
|
| 63 | + function select_interventions($socid = -1, $selected = '', $htmlname = 'interventionid', $maxlength = 16, $showempty = 1) |
|
| 64 | 64 | { |
| 65 | 65 | // phpcs:enable |
| 66 | - global $db,$user,$conf,$langs; |
|
| 66 | + global $db, $user, $conf, $langs; |
|
| 67 | 67 | |
| 68 | - $out=''; |
|
| 68 | + $out = ''; |
|
| 69 | 69 | |
| 70 | - $hideunselectables=false; |
|
| 70 | + $hideunselectables = false; |
|
| 71 | 71 | |
| 72 | 72 | // Search all contacts |
| 73 | 73 | $sql = 'SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut'; |
| 74 | - $sql.= ' FROM '.MAIN_DB_PREFIX .'fichinter as f'; |
|
| 75 | - $sql.= " WHERE f.entity = ".$conf->entity; |
|
| 74 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'fichinter as f'; |
|
| 75 | + $sql .= " WHERE f.entity = ".$conf->entity; |
|
| 76 | 76 | if ($socid != '') |
| 77 | 77 | { |
| 78 | - if ($socid == '0') $sql.= " AND (f.fk_soc = 0 OR f.fk_soc IS NULL)"; |
|
| 79 | - else $sql.= " AND f.fk_soc = ".$socid; |
|
| 78 | + if ($socid == '0') $sql .= " AND (f.fk_soc = 0 OR f.fk_soc IS NULL)"; |
|
| 79 | + else $sql .= " AND f.fk_soc = ".$socid; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | dol_syslog(get_class($this)."::select_intervention", LOG_DEBUG); |
| 83 | - $resql=$db->query($sql); |
|
| 83 | + $resql = $db->query($sql); |
|
| 84 | 84 | if ($resql) |
| 85 | 85 | { |
| 86 | - $out.='<select id="interventionid" class="flat" name="'.$htmlname.'">'; |
|
| 87 | - if ($showempty) $out.='<option value="0"> </option>'; |
|
| 86 | + $out .= '<select id="interventionid" class="flat" name="'.$htmlname.'">'; |
|
| 87 | + if ($showempty) $out .= '<option value="0"> </option>'; |
|
| 88 | 88 | $num = $db->num_rows($resql); |
| 89 | 89 | $i = 0; |
| 90 | 90 | if ($num) |
@@ -93,49 +93,49 @@ discard block |
||
| 93 | 93 | { |
| 94 | 94 | $obj = $db->fetch_object($resql); |
| 95 | 95 | // If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project. |
| 96 | - if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire) |
|
| 96 | + if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->rights->societe->lire) |
|
| 97 | 97 | { |
| 98 | 98 | // Do nothing |
| 99 | 99 | } |
| 100 | 100 | else |
| 101 | 101 | { |
| 102 | - $labeltoshow=dol_trunc($obj->ref,18); |
|
| 102 | + $labeltoshow = dol_trunc($obj->ref, 18); |
|
| 103 | 103 | if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0) |
| 104 | 104 | { |
| 105 | - $out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
|
| 105 | + $out .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
|
| 106 | 106 | } |
| 107 | 107 | else |
| 108 | 108 | { |
| 109 | - $disabled=0; |
|
| 110 | - if (! $obj->fk_statut > 0) |
|
| 109 | + $disabled = 0; |
|
| 110 | + if (!$obj->fk_statut > 0) |
|
| 111 | 111 | { |
| 112 | - $disabled=1; |
|
| 113 | - $labeltoshow.=' ('.$langs->trans("Draft").')'; |
|
| 112 | + $disabled = 1; |
|
| 113 | + $labeltoshow .= ' ('.$langs->trans("Draft").')'; |
|
| 114 | 114 | } |
| 115 | - if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) |
|
| 115 | + if ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) |
|
| 116 | 116 | { |
| 117 | - $disabled=1; |
|
| 118 | - $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); |
|
| 117 | + $disabled = 1; |
|
| 118 | + $labeltoshow .= ' - '.$langs->trans("LinkedToAnotherCompany"); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | if ($hideunselectables && $disabled) |
| 122 | 122 | { |
| 123 | - $resultat=''; |
|
| 123 | + $resultat = ''; |
|
| 124 | 124 | } |
| 125 | 125 | else |
| 126 | 126 | { |
| 127 | - $resultat='<option value="'.$obj->rowid.'"'; |
|
| 128 | - if ($disabled) $resultat.=' disabled'; |
|
| 129 | - $resultat.='>'.$labeltoshow; |
|
| 130 | - $resultat.='</option>'; |
|
| 127 | + $resultat = '<option value="'.$obj->rowid.'"'; |
|
| 128 | + if ($disabled) $resultat .= ' disabled'; |
|
| 129 | + $resultat .= '>'.$labeltoshow; |
|
| 130 | + $resultat .= '</option>'; |
|
| 131 | 131 | } |
| 132 | - $out.=$resultat; |
|
| 132 | + $out .= $resultat; |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | $i++; |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | - $out.='</select>'; |
|
| 138 | + $out .= '</select>'; |
|
| 139 | 139 | $db->free($resql); |
| 140 | 140 | return $out; |
| 141 | 141 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public $db; |
| 38 | 38 | |
| 39 | - var $dir; // Directory with all core and external triggers files |
|
| 39 | + var $dir; // Directory with all core and external triggers files |
|
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * @var string[] Error codes (or messages) |
@@ -65,22 +65,22 @@ discard block |
||
| 65 | 65 | * @param Conf $conf Objet conf |
| 66 | 66 | * @return int Nb of triggers ran if no error, -Nb of triggers with errors otherwise. |
| 67 | 67 | */ |
| 68 | - function run_triggers($action,$object,$user,$langs,$conf) |
|
| 68 | + function run_triggers($action, $object, $user, $langs, $conf) |
|
| 69 | 69 | { |
| 70 | 70 | // phpcs:enable |
| 71 | 71 | // Check parameters |
| 72 | - if (! is_object($object) || ! is_object($conf)) // Error |
|
| 72 | + if (!is_object($object) || !is_object($conf)) // Error |
|
| 73 | 73 | { |
| 74 | - $this->error='function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); |
|
| 74 | + $this->error = 'function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); |
|
| 75 | 75 | dol_syslog(get_class($this).'::run_triggers '.$this->error, LOG_ERR); |
| 76 | - $this->errors[]=$this->error; |
|
| 76 | + $this->errors[] = $this->error; |
|
| 77 | 77 | return -1; |
| 78 | 78 | } |
| 79 | - if (! is_object($langs)) // Warning |
|
| 79 | + if (!is_object($langs)) // Warning |
|
| 80 | 80 | { |
| 81 | 81 | dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING); |
| 82 | 82 | } |
| 83 | - if (! is_object($user)) // Warning |
|
| 83 | + if (!is_object($user)) // Warning |
|
| 84 | 84 | { |
| 85 | 85 | dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING); |
| 86 | 86 | global $db; |
@@ -92,43 +92,43 @@ discard block |
||
| 92 | 92 | $files = array(); |
| 93 | 93 | $modules = array(); |
| 94 | 94 | $orders = array(); |
| 95 | - $i=0; |
|
| 95 | + $i = 0; |
|
| 96 | 96 | |
| 97 | - $dirtriggers=array_merge(array('/core/triggers'),$conf->modules_parts['triggers']); |
|
| 98 | - foreach($dirtriggers as $reldir) |
|
| 97 | + $dirtriggers = array_merge(array('/core/triggers'), $conf->modules_parts['triggers']); |
|
| 98 | + foreach ($dirtriggers as $reldir) |
|
| 99 | 99 | { |
| 100 | - $dir=dol_buildpath($reldir,0); |
|
| 101 | - $newdir=dol_osencode($dir); |
|
| 100 | + $dir = dol_buildpath($reldir, 0); |
|
| 101 | + $newdir = dol_osencode($dir); |
|
| 102 | 102 | //print "xx".$dir;exit; |
| 103 | 103 | |
| 104 | 104 | // Check if directory exists (we do not use dol_is_dir to avoir loading files.lib.php at each call) |
| 105 | - if (! is_dir($newdir)) continue; |
|
| 105 | + if (!is_dir($newdir)) continue; |
|
| 106 | 106 | |
| 107 | - $handle=opendir($newdir); |
|
| 107 | + $handle = opendir($newdir); |
|
| 108 | 108 | if (is_resource($handle)) |
| 109 | 109 | { |
| 110 | - while (($file = readdir($handle))!==false) |
|
| 110 | + while (($file = readdir($handle)) !== false) |
|
| 111 | 111 | { |
| 112 | - if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i',$file,$reg)) |
|
| 112 | + if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i', $file, $reg)) |
|
| 113 | 113 | { |
| 114 | - $part1=$reg[1]; |
|
| 115 | - $part2=$reg[2]; |
|
| 116 | - $part3=$reg[3]; |
|
| 114 | + $part1 = $reg[1]; |
|
| 115 | + $part2 = $reg[2]; |
|
| 116 | + $part3 = $reg[3]; |
|
| 117 | 117 | |
| 118 | 118 | $nbfile++; |
| 119 | 119 | |
| 120 | 120 | // Check if trigger file is disabled by name |
| 121 | - if (preg_match('/NORUN$/i',$file)) continue; |
|
| 121 | + if (preg_match('/NORUN$/i', $file)) continue; |
|
| 122 | 122 | // Check if trigger file is for a particular module |
| 123 | - $qualified=true; |
|
| 123 | + $qualified = true; |
|
| 124 | 124 | if (strtolower($reg[2]) != 'all') |
| 125 | 125 | { |
| 126 | - $module=preg_replace('/^mod/i','',$reg[2]); |
|
| 127 | - $constparam='MAIN_MODULE_'.strtoupper($module); |
|
| 128 | - if (empty($conf->global->$constparam)) $qualified=false; |
|
| 126 | + $module = preg_replace('/^mod/i', '', $reg[2]); |
|
| 127 | + $constparam = 'MAIN_MODULE_'.strtoupper($module); |
|
| 128 | + if (empty($conf->global->$constparam)) $qualified = false; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if (! $qualified) |
|
| 131 | + if (!$qualified) |
|
| 132 | 132 | { |
| 133 | 133 | //dol_syslog(get_class($this)."::run_triggers action=".$action." Triggers for file '".$file."' need module to be enabled", LOG_DEBUG); |
| 134 | 134 | continue; |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | $modName = "Interface".ucfirst($reg[3]); |
| 138 | 138 | //print "file=$file - modName=$modName\n"; |
| 139 | - if (in_array($modName,$modules)) // $modules = list of modName already loaded |
|
| 139 | + if (in_array($modName, $modules)) // $modules = list of modName already loaded |
|
| 140 | 140 | { |
| 141 | 141 | $langs->load("errors"); |
| 142 | 142 | dol_syslog(get_class($this)."::run_triggers action=".$action." ".$langs->trans("ErrorDuplicateTrigger", $newdir."/".$file, $fullpathfiles[$modName]), LOG_WARNING); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | include_once $newdir.'/'.$file; |
| 149 | 149 | //print 'Done for '.$modName."\n"; |
| 150 | 150 | } |
| 151 | - catch(Exception $e) |
|
| 151 | + catch (Exception $e) |
|
| 152 | 152 | { |
| 153 | 153 | dol_syslog('ko for '.$modName." ".$e->getMessage()."\n", LOG_ERR); |
| 154 | 154 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | $modules[$i] = $modName; |
| 157 | 157 | $files[$i] = $file; |
| 158 | 158 | $fullpathfiles[$modName] = $newdir.'/'.$file; |
| 159 | - $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value |
|
| 159 | + $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value |
|
| 160 | 160 | |
| 161 | 161 | $i++; |
| 162 | 162 | } |
@@ -175,17 +175,17 @@ discard block |
||
| 175 | 175 | $objMod = new $modName($this->db); |
| 176 | 176 | if ($objMod) |
| 177 | 177 | { |
| 178 | - $result=0; |
|
| 178 | + $result = 0; |
|
| 179 | 179 | |
| 180 | 180 | if (method_exists($objMod, 'runTrigger')) // New method to implement |
| 181 | 181 | { |
| 182 | 182 | //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG); |
| 183 | - $result=$objMod->runTrigger($action,$object,$user,$langs,$conf); |
|
| 183 | + $result = $objMod->runTrigger($action, $object, $user, $langs, $conf); |
|
| 184 | 184 | } |
| 185 | 185 | elseif (method_exists($objMod, 'run_trigger')) // Deprecated method |
| 186 | 186 | { |
| 187 | 187 | dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING); |
| 188 | - $result=$objMod->run_trigger($action,$object,$user,$langs,$conf); |
|
| 188 | + $result = $objMod->run_trigger($action, $object, $user, $langs, $conf); |
|
| 189 | 189 | } |
| 190 | 190 | else |
| 191 | 191 | { |
@@ -209,8 +209,8 @@ discard block |
||
| 209 | 209 | //dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($objMod->errors), LOG_ERR); |
| 210 | 210 | $nbtotal++; |
| 211 | 211 | $nbko++; |
| 212 | - if (! empty($objMod->errors)) $this->errors=array_merge($this->errors,$objMod->errors); |
|
| 213 | - else if (! empty($objMod->error)) $this->errors[]=$objMod->error; |
|
| 212 | + if (!empty($objMod->errors)) $this->errors = array_merge($this->errors, $objMod->errors); |
|
| 213 | + else if (!empty($objMod->error)) $this->errors[] = $objMod->error; |
|
| 214 | 214 | //dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($this->errors), LOG_ERR); |
| 215 | 215 | } |
| 216 | 216 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * @param array $forcedirtriggers null=All default directories. This parameter is used by modulebuilder module only. |
| 240 | 240 | * @return array Array list of triggers |
| 241 | 241 | */ |
| 242 | - function getTriggersList($forcedirtriggers=null) |
|
| 242 | + function getTriggersList($forcedirtriggers = null) |
|
| 243 | 243 | { |
| 244 | 244 | global $conf, $langs, $db; |
| 245 | 245 | |
@@ -251,39 +251,39 @@ discard block |
||
| 251 | 251 | $orders = array(); |
| 252 | 252 | $i = 0; |
| 253 | 253 | |
| 254 | - $dirtriggers=array_merge(array('/core/triggers/'),$conf->modules_parts['triggers']); |
|
| 254 | + $dirtriggers = array_merge(array('/core/triggers/'), $conf->modules_parts['triggers']); |
|
| 255 | 255 | if (is_array($forcedirtriggers)) |
| 256 | 256 | { |
| 257 | - $dirtriggers=$forcedirtriggers; |
|
| 257 | + $dirtriggers = $forcedirtriggers; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - foreach($dirtriggers as $reldir) |
|
| 260 | + foreach ($dirtriggers as $reldir) |
|
| 261 | 261 | { |
| 262 | - $dir=dol_buildpath($reldir,0); |
|
| 263 | - $newdir=dol_osencode($dir); |
|
| 262 | + $dir = dol_buildpath($reldir, 0); |
|
| 263 | + $newdir = dol_osencode($dir); |
|
| 264 | 264 | |
| 265 | 265 | // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call) |
| 266 | - if (! is_dir($newdir)) continue; |
|
| 266 | + if (!is_dir($newdir)) continue; |
|
| 267 | 267 | |
| 268 | - $handle=opendir($newdir); |
|
| 268 | + $handle = opendir($newdir); |
|
| 269 | 269 | if (is_resource($handle)) |
| 270 | 270 | { |
| 271 | - while (($file = readdir($handle))!==false) |
|
| 271 | + while (($file = readdir($handle)) !== false) |
|
| 272 | 272 | { |
| 273 | - if (is_readable($newdir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/',$file,$reg)) |
|
| 273 | + if (is_readable($newdir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/', $file, $reg)) |
|
| 274 | 274 | { |
| 275 | - if (preg_match('/\.back$/',$file)) continue; |
|
| 275 | + if (preg_match('/\.back$/', $file)) continue; |
|
| 276 | 276 | |
| 277 | - $part1=$reg[1]; |
|
| 278 | - $part2=$reg[2]; |
|
| 279 | - $part3=$reg[3]; |
|
| 277 | + $part1 = $reg[1]; |
|
| 278 | + $part2 = $reg[2]; |
|
| 279 | + $part3 = $reg[3]; |
|
| 280 | 280 | |
| 281 | 281 | $modName = 'Interface'.ucfirst($reg[3]); |
| 282 | 282 | //print "file=$file"; print "modName=$modName"; exit; |
| 283 | - if (in_array($modName,$modules)) |
|
| 283 | + if (in_array($modName, $modules)) |
|
| 284 | 284 | { |
| 285 | 285 | $langs->load("errors"); |
| 286 | - print '<div class="error">'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateTrigger",$modName,"/htdocs/core/triggers/").'</div>'; |
|
| 286 | + print '<div class="error">'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateTrigger", $modName, "/htdocs/core/triggers/").'</div>'; |
|
| 287 | 287 | } |
| 288 | 288 | else |
| 289 | 289 | { |
@@ -292,10 +292,10 @@ discard block |
||
| 292 | 292 | |
| 293 | 293 | $files[$i] = $file; |
| 294 | 294 | $fullpath[$i] = $dir.'/'.$file; |
| 295 | - $relpath[$i] = preg_replace('/^\//','',$reldir).'/'.$file; |
|
| 296 | - $iscoreorexternal[$i] = ($reldir == '/core/triggers/'?'internal':'external'); |
|
| 295 | + $relpath[$i] = preg_replace('/^\//', '', $reldir).'/'.$file; |
|
| 296 | + $iscoreorexternal[$i] = ($reldir == '/core/triggers/' ? 'internal' : 'external'); |
|
| 297 | 297 | $modules[$i] = $modName; |
| 298 | - $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value |
|
| 298 | + $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value |
|
| 299 | 299 | |
| 300 | 300 | $i++; |
| 301 | 301 | } |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | $modName = $modules[$key]; |
| 316 | 316 | if (empty($modName)) continue; |
| 317 | 317 | |
| 318 | - if (! class_exists($modName)) |
|
| 318 | + if (!class_exists($modName)) |
|
| 319 | 319 | { |
| 320 | 320 | print 'Error: A trigger file was found but its class "'.$modName.'" was not found.'."<br>\n"; |
| 321 | 321 | continue; |
@@ -324,45 +324,45 @@ discard block |
||
| 324 | 324 | $objMod = new $modName($db); |
| 325 | 325 | |
| 326 | 326 | // Define disabledbyname and disabledbymodule |
| 327 | - $disabledbyname=0; |
|
| 328 | - $disabledbymodule=1; |
|
| 329 | - $module=''; |
|
| 327 | + $disabledbyname = 0; |
|
| 328 | + $disabledbymodule = 1; |
|
| 329 | + $module = ''; |
|
| 330 | 330 | |
| 331 | 331 | // Check if trigger file is disabled by name |
| 332 | - if (preg_match('/NORUN$/i',$files[$key])) $disabledbyname=1; |
|
| 332 | + if (preg_match('/NORUN$/i', $files[$key])) $disabledbyname = 1; |
|
| 333 | 333 | // Check if trigger file is for a particular module |
| 334 | - if (preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/i',$files[$key],$reg)) |
|
| 334 | + if (preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/i', $files[$key], $reg)) |
|
| 335 | 335 | { |
| 336 | - $module=preg_replace('/^mod/i','',$reg[2]); |
|
| 337 | - $constparam='MAIN_MODULE_'.strtoupper($module); |
|
| 338 | - if (strtolower($module) == 'all') $disabledbymodule=0; |
|
| 339 | - else if (empty($conf->global->$constparam)) $disabledbymodule=2; |
|
| 340 | - $triggers[$j]['module']=strtolower($module); |
|
| 336 | + $module = preg_replace('/^mod/i', '', $reg[2]); |
|
| 337 | + $constparam = 'MAIN_MODULE_'.strtoupper($module); |
|
| 338 | + if (strtolower($module) == 'all') $disabledbymodule = 0; |
|
| 339 | + else if (empty($conf->global->$constparam)) $disabledbymodule = 2; |
|
| 340 | + $triggers[$j]['module'] = strtolower($module); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | // We set info of modules |
| 344 | - $triggers[$j]['picto'] = $objMod->picto?img_object('',$objMod->picto):img_object('','generic'); |
|
| 344 | + $triggers[$j]['picto'] = $objMod->picto ?img_object('', $objMod->picto) : img_object('', 'generic'); |
|
| 345 | 345 | $triggers[$j]['file'] = $files[$key]; |
| 346 | 346 | $triggers[$j]['fullpath'] = $fullpath[$key]; |
| 347 | 347 | $triggers[$j]['relpath'] = $relpath[$key]; |
| 348 | 348 | $triggers[$j]['iscoreorexternal'] = $iscoreorexternal[$key]; |
| 349 | 349 | $triggers[$j]['version'] = $objMod->getVersion(); |
| 350 | - $triggers[$j]['status'] = img_picto($langs->trans("Active"),'tick'); |
|
| 350 | + $triggers[$j]['status'] = img_picto($langs->trans("Active"), 'tick'); |
|
| 351 | 351 | if ($disabledbyname > 0 || $disabledbymodule > 1) $triggers[$j]['status'] = ''; |
| 352 | 352 | |
| 353 | - $text ='<b>'.$langs->trans("Description").':</b><br>'; |
|
| 354 | - $text.=$objMod->getDesc().'<br>'; |
|
| 355 | - $text.='<br><b>'.$langs->trans("Status").':</b><br>'; |
|
| 353 | + $text = '<b>'.$langs->trans("Description").':</b><br>'; |
|
| 354 | + $text .= $objMod->getDesc().'<br>'; |
|
| 355 | + $text .= '<br><b>'.$langs->trans("Status").':</b><br>'; |
|
| 356 | 356 | if ($disabledbyname == 1) |
| 357 | 357 | { |
| 358 | - $text.=$langs->trans("TriggerDisabledByName").'<br>'; |
|
| 359 | - if ($disabledbymodule == 2) $text.=$langs->trans("TriggerDisabledAsModuleDisabled",$module).'<br>'; |
|
| 358 | + $text .= $langs->trans("TriggerDisabledByName").'<br>'; |
|
| 359 | + if ($disabledbymodule == 2) $text .= $langs->trans("TriggerDisabledAsModuleDisabled", $module).'<br>'; |
|
| 360 | 360 | } |
| 361 | 361 | else |
| 362 | 362 | { |
| 363 | - if ($disabledbymodule == 0) $text.=$langs->trans("TriggerAlwaysActive").'<br>'; |
|
| 364 | - if ($disabledbymodule == 1) $text.=$langs->trans("TriggerActiveAsModuleActive",$module).'<br>'; |
|
| 365 | - if ($disabledbymodule == 2) $text.=$langs->trans("TriggerDisabledAsModuleDisabled",$module).'<br>'; |
|
| 363 | + if ($disabledbymodule == 0) $text .= $langs->trans("TriggerAlwaysActive").'<br>'; |
|
| 364 | + if ($disabledbymodule == 1) $text .= $langs->trans("TriggerActiveAsModuleActive", $module).'<br>'; |
|
| 365 | + if ($disabledbymodule == 2) $text .= $langs->trans("TriggerDisabledAsModuleDisabled", $module).'<br>'; |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | $triggers[$j]['info'] = $text; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | /** |
| 35 | 35 | * @var string Error code (or message) |
| 36 | 36 | */ |
| 37 | - public $error=''; |
|
| 37 | + public $error = ''; |
|
| 38 | 38 | |
| 39 | 39 | public $key; |
| 40 | 40 | |
@@ -44,10 +44,10 @@ discard block |
||
| 44 | 44 | * @param DoliDB $db Database handler |
| 45 | 45 | * @param string $key Google key |
| 46 | 46 | */ |
| 47 | - function __construct($db,$key) |
|
| 47 | + function __construct($db, $key) |
|
| 48 | 48 | { |
| 49 | - $this->db=$db; |
|
| 50 | - $this->key=$key; |
|
| 49 | + $this->db = $db; |
|
| 50 | + $this->key = $key; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | { |
| 64 | 64 | global $conf; |
| 65 | 65 | |
| 66 | - $i=0; |
|
| 66 | + $i = 0; |
|
| 67 | 67 | |
| 68 | 68 | // Desired address |
| 69 | 69 | $urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key; |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | $code = strstr($page, '<coordinates>'); |
| 75 | 75 | $code = strstr($code, '>'); |
| 76 | - $val=strpos($code, "<"); |
|
| 77 | - $code = substr($code, 1, $val-1); |
|
| 76 | + $val = strpos($code, "<"); |
|
| 77 | + $code = substr($code, 1, $val - 1); |
|
| 78 | 78 | //print $code; |
| 79 | 79 | //print "<br>"; |
| 80 | 80 | $latitude = substr($code, 0, strpos($code, ",")); |
| 81 | - $longitude = substr($code, strpos($code, ",")+1, dol_strlen(strpos($code, ","))-3); |
|
| 81 | + $longitude = substr($code, strpos($code, ",") + 1, dol_strlen(strpos($code, ",")) - 3); |
|
| 82 | 82 | |
| 83 | 83 | // Output the coordinates |
| 84 | 84 | //echo "Longitude: $longitude ',' Latitude: $latitude"; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * @var string Error code (or message) |
| 39 | 39 | */ |
| 40 | - public $error=''; |
|
| 40 | + public $error = ''; |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -64,10 +64,10 @@ discard block |
||
| 64 | 64 | * @param string $morecss More css on select field |
| 65 | 65 | * @return void |
| 66 | 66 | */ |
| 67 | - function form_select_status_action($formname, $selected, $canedit=1, $htmlname='complete', $showempty=0, $onlyselect=0, $morecss='maxwidth100') |
|
| 67 | + function form_select_status_action($formname, $selected, $canedit = 1, $htmlname = 'complete', $showempty = 0, $onlyselect = 0, $morecss = 'maxwidth100') |
|
| 68 | 68 | { |
| 69 | 69 | // phpcs:enable |
| 70 | - global $langs,$conf; |
|
| 70 | + global $langs, $conf; |
|
| 71 | 71 | |
| 72 | 72 | $listofstatus = array( |
| 73 | 73 | '-1' => $langs->trans("ActionNotApplicable"), |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | ); |
| 78 | 78 | // +ActionUncomplete |
| 79 | 79 | |
| 80 | - if (! empty($conf->use_javascript_ajax)) |
|
| 80 | + if (!empty($conf->use_javascript_ajax)) |
|
| 81 | 81 | { |
| 82 | 82 | print "\n"; |
| 83 | 83 | print "<script type=\"text/javascript\"> |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | function select_status() { |
| 99 | 99 | var defaultvalue = $('#select' + htmlname).val(); |
| 100 | 100 | var percentage = $('input[name=percentage]'); |
| 101 | - var selected = '".(isset($selected)?$selected:'')."'; |
|
| 101 | + var selected = '".(isset($selected) ? $selected : '')."'; |
|
| 102 | 102 | var value = (selected>0?selected:(defaultvalue>=0?defaultvalue:'')); |
| 103 | 103 | |
| 104 | 104 | percentage.val(value); |
@@ -125,13 +125,13 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | </script>\n"; |
| 127 | 127 | } |
| 128 | - if (! empty($conf->use_javascript_ajax) || $onlyselect) |
|
| 128 | + if (!empty($conf->use_javascript_ajax) || $onlyselect) |
|
| 129 | 129 | { |
| 130 | 130 | //var_dump($selected); |
| 131 | - if ($selected == 'done') $selected='100'; |
|
| 132 | - print '<select '.($canedit?'':'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss?' '.$morecss:'').'">'; |
|
| 133 | - if ($showempty) print '<option value=""'.($selected == ''?' selected':'').'></option>'; |
|
| 134 | - foreach($listofstatus as $key => $val) |
|
| 131 | + if ($selected == 'done') $selected = '100'; |
|
| 132 | + print '<select '.($canedit ? '' : 'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'">'; |
|
| 133 | + if ($showempty) print '<option value=""'.($selected == '' ? ' selected' : '').'></option>'; |
|
| 134 | + foreach ($listofstatus as $key => $val) |
|
| 135 | 135 | { |
| 136 | 136 | print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>'.$val.'</option>'; |
| 137 | 137 | if ($key == '50' && $onlyselect == 2) |
@@ -140,17 +140,17 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | print '</select>'; |
| 143 | - if ($selected == 0 || $selected == 100) $canedit=0; |
|
| 143 | + if ($selected == 0 || $selected == 100) $canedit = 0; |
|
| 144 | 144 | |
| 145 | 145 | if (empty($onlyselect)) |
| 146 | 146 | { |
| 147 | - print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit&&($selected>=0)?'':' disabled').'>'; |
|
| 147 | + print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit && ($selected >= 0) ? '' : ' disabled').'>'; |
|
| 148 | 148 | print '<span class="hideonsmartphone hideifna">%</span>'; |
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | else |
| 152 | 152 | { |
| 153 | - print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit?'':' disabled').'>%'; |
|
| 153 | + print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit ? '' : ' disabled').'>%'; |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
@@ -168,64 +168,64 @@ discard block |
||
| 168 | 168 | * @param string $morehtmlright More html text on right of title line |
| 169 | 169 | * @return int <0 if KO, >=0 if OK |
| 170 | 170 | */ |
| 171 | - function showactions($object, $typeelement, $socid=0, $forceshowtitle=0, $morecss='listactions', $max=0, $moreparambacktopage='', $morehtmlright='') |
|
| 171 | + function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss = 'listactions', $max = 0, $moreparambacktopage = '', $morehtmlright = '') |
|
| 172 | 172 | { |
| 173 | - global $langs,$conf,$user; |
|
| 173 | + global $langs, $conf, $user; |
|
| 174 | 174 | global $bc; |
| 175 | 175 | |
| 176 | 176 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
| 177 | 177 | |
| 178 | - $sortfield='a.datep,a.id'; |
|
| 179 | - $sortorder='DESC,DESC'; |
|
| 178 | + $sortfield = 'a.datep,a.id'; |
|
| 179 | + $sortorder = 'DESC,DESC'; |
|
| 180 | 180 | |
| 181 | - $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'); |
|
| 181 | + $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'); |
|
| 183 | 183 | |
| 184 | 184 | $num = count($listofactions); |
| 185 | 185 | if ($num || $forceshowtitle) |
| 186 | 186 | { |
| 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:''); |
|
| 199 | - |
|
| 200 | - $urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:''); |
|
| 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 : ''); |
|
| 199 | + |
|
| 200 | + $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage ? '&'.$moreparambacktopage : ''); |
|
| 201 | 201 | |
| 202 | 202 | $projectid = $object->fk_project; |
| 203 | 203 | if ($typeelement == 'project') $projectid = $object->id; |
| 204 | 204 | |
| 205 | - $newcardbutton=''; |
|
| 206 | - if (! empty($conf->agenda->enabled)) |
|
| 205 | + $newcardbutton = ''; |
|
| 206 | + if (!empty($conf->agenda->enabled)) |
|
| 207 | 207 | { |
| 208 | - $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(),'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid>0?'&socid='.$object->socid:($socid>0?'&socid='.$socid:'')).($projectid>0?'&projectid='.$projectid:'').'&backtopage='.urlencode($urlbacktopage).'"><span class="valignmiddle">'.$langs->trans("AddEvent").'</span>'; |
|
| 209 | - $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>'; |
|
| 210 | - $newcardbutton.= '</a>'; |
|
| 208 | + $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(), 'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage).'"><span class="valignmiddle">'.$langs->trans("AddEvent").'</span>'; |
|
| 209 | + $newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>'; |
|
| 210 | + $newcardbutton .= '</a>'; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | print '<!-- formactions->showactions -->'."\n"; |
| 214 | 214 | print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlright); |
| 215 | 215 | |
| 216 | - $page=0; $param=''; |
|
| 216 | + $page = 0; $param = ''; |
|
| 217 | 217 | |
| 218 | 218 | $total = 0; |
| 219 | 219 | |
| 220 | 220 | print '<div class="div-table-responsive-no-min">'; |
| 221 | - print '<table class="noborder'.($morecss?' '.$morecss:'').'" width="100%">'; |
|
| 221 | + print '<table class="noborder'.($morecss ? ' '.$morecss : '').'" width="100%">'; |
|
| 222 | 222 | print '<tr class="liste_titre">'; |
| 223 | - print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 224 | - print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 225 | - print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 223 | + print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 224 | + print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 225 | + print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 226 | 226 | print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
| 227 | - print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, 'align="center"', $sortfield, $sortorder, '', 1); |
|
| 228 | - print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"', $sortfield, $sortorder, '', 1); |
|
| 227 | + print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, 'align="center"', $sortfield, $sortorder, '', 1); |
|
| 228 | + print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"', $sortfield, $sortorder, '', 1); |
|
| 229 | 229 | print '</tr>'; |
| 230 | 230 | print "\n"; |
| 231 | 231 | |
@@ -234,37 +234,37 @@ discard block |
||
| 234 | 234 | if (count($listofactions)) |
| 235 | 235 | { |
| 236 | 236 | $cursorevent = 0; |
| 237 | - foreach($listofactions as $action) |
|
| 237 | + foreach ($listofactions as $action) |
|
| 238 | 238 | { |
| 239 | 239 | if ($max && $cursorevent >= $max) break; |
| 240 | 240 | |
| 241 | - $ref=$action->getNomUrl(1,-1); |
|
| 242 | - $label=$action->getNomUrl(0,38); |
|
| 241 | + $ref = $action->getNomUrl(1, -1); |
|
| 242 | + $label = $action->getNomUrl(0, 38); |
|
| 243 | 243 | |
| 244 | 244 | print '<tr class="oddeven">'; |
| 245 | 245 | // Ref |
| 246 | 246 | print '<td>'.$ref.'</td>'; |
| 247 | 247 | // Onwer |
| 248 | 248 | print '<td>'; |
| 249 | - if (! empty($action->userownerid)) |
|
| 249 | + if (!empty($action->userownerid)) |
|
| 250 | 250 | { |
| 251 | - $userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched |
|
| 251 | + $userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched |
|
| 252 | 252 | print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, '', ''); |
| 253 | 253 | } |
| 254 | 254 | print '</td>'; |
| 255 | 255 | // Type |
| 256 | 256 | print '<td>'; |
| 257 | - $imgpicto=''; |
|
| 258 | - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
|
| 257 | + $imgpicto = ''; |
|
| 258 | + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
|
| 259 | 259 | { |
| 260 | - if ($action->type_picto) $imgpicto=img_picto('', $action->type_picto); |
|
| 260 | + if ($action->type_picto) $imgpicto = img_picto('', $action->type_picto); |
|
| 261 | 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').' '; |
|
| 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').' '; |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | print $imgpicto; |
@@ -276,8 +276,8 @@ discard block |
||
| 276 | 276 | print '<td align="center">'.dol_print_date($action->datep, 'dayhour', 'tzuserrel'); |
| 277 | 277 | if ($action->datef) |
| 278 | 278 | { |
| 279 | - $tmpa=dol_getdate($action->datep); |
|
| 280 | - $tmpb=dol_getdate($action->datef); |
|
| 279 | + $tmpa = dol_getdate($action->datep); |
|
| 280 | + $tmpb = dol_getdate($action->datef); |
|
| 281 | 281 | if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) |
| 282 | 282 | { |
| 283 | 283 | if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel'); |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | } |
| 287 | 287 | print '</td>'; |
| 288 | 288 | print '<td align="right">'; |
| 289 | - if (! empty($action->author->id)) |
|
| 289 | + if (!empty($action->author->id)) |
|
| 290 | 290 | { |
| 291 | 291 | print $action->getLibStatut(3); |
| 292 | 292 | } |
@@ -327,42 +327,42 @@ discard block |
||
| 327 | 327 | * @param int $nooutput 1=No output |
| 328 | 328 | * @return string |
| 329 | 329 | */ |
| 330 | - function select_type_actions($selected='', $htmlname='actioncode', $excludetype='', $onlyautoornot=0, $hideinfohelp=0, $multiselect=0, $nooutput=0) |
|
| 330 | + function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0) |
|
| 331 | 331 | { |
| 332 | 332 | // phpcs:enable |
| 333 | - global $langs,$user,$form,$conf; |
|
| 333 | + global $langs, $user, $form, $conf; |
|
| 334 | 334 | |
| 335 | - if (! is_object($form)) $form=new Form($this->db); |
|
| 335 | + if (!is_object($form)) $form = new Form($this->db); |
|
| 336 | 336 | |
| 337 | 337 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; |
| 338 | 338 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
| 339 | - $caction=new CActionComm($this->db); |
|
| 339 | + $caction = new CActionComm($this->db); |
|
| 340 | 340 | |
| 341 | 341 | // Suggest a list with manual events or all auto events |
| 342 | - $arraylist=$caction->liste_array(1, 'code', $excludetype, $onlyautoornot); |
|
| 343 | - array_unshift($arraylist,' '); // Add empty line at start |
|
| 342 | + $arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot); |
|
| 343 | + array_unshift($arraylist, ' '); // Add empty line at start |
|
| 344 | 344 | //asort($arraylist); |
| 345 | 345 | |
| 346 | - if ($selected == 'manual') $selected='AC_OTH'; |
|
| 347 | - if ($selected == 'auto') $selected='AC_OTH_AUTO'; |
|
| 346 | + if ($selected == 'manual') $selected = 'AC_OTH'; |
|
| 347 | + if ($selected == 'auto') $selected = 'AC_OTH_AUTO'; |
|
| 348 | 348 | |
| 349 | - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); |
|
| 349 | + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); |
|
| 350 | 350 | |
| 351 | - $out=''; |
|
| 351 | + $out = ''; |
|
| 352 | 352 | |
| 353 | - if (! empty($multiselect)) |
|
| 353 | + if (!empty($multiselect)) |
|
| 354 | 354 | { |
| 355 | 355 | if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); |
| 356 | - $out.=$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); |
|
| 356 | + $out .= $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); |
|
| 357 | 357 | } |
| 358 | 358 | else |
| 359 | 359 | { |
| 360 | - $out.=$form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); |
|
| 360 | + $out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) |
| 364 | 364 | { |
| 365 | - $out.=info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''),1); |
|
| 365 | + $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | if ($nooutput) return $out; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * \ingroup core |
| 21 | 21 | * \brief File of predefined functions for HTML forms for mailing module |
| 22 | 22 | */ |
| 23 | -require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; |
|
| 23 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Class to offer components to list and upload files |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param integer $show_empty Show empty option |
| 41 | 41 | * @return string HTML select |
| 42 | 42 | */ |
| 43 | - public function selectDestinariesStatus($selectedid='', $htmlname='dest_status', $show_empty=0) |
|
| 43 | + public function selectDestinariesStatus($selectedid = '', $htmlname = 'dest_status', $show_empty = 0) |
|
| 44 | 44 | { |
| 45 | 45 | |
| 46 | 46 | global $langs; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $options = array(); |
| 53 | 53 | |
| 54 | 54 | if ($show_empty) { |
| 55 | - $options[-2] = ''; // Note -1 is used for error |
|
| 55 | + $options[-2] = ''; // Note -1 is used for error |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $options = $options + $mailing->statut_dest; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * @var string Error code (or message) |
| 41 | 41 | */ |
| 42 | - public $error=''; |
|
| 42 | + public $error = ''; |
|
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * Constructor |
@@ -60,20 +60,20 @@ discard block |
||
| 60 | 60 | * @param string $filter Add a SQL filter to select |
| 61 | 61 | * @return array Array of types |
| 62 | 62 | */ |
| 63 | - function typent_array($mode=0, $filter='') |
|
| 63 | + function typent_array($mode = 0, $filter = '') |
|
| 64 | 64 | { |
| 65 | 65 | // phpcs:enable |
| 66 | - global $langs,$mysoc; |
|
| 66 | + global $langs, $mysoc; |
|
| 67 | 67 | |
| 68 | 68 | $effs = array(); |
| 69 | 69 | |
| 70 | 70 | $sql = "SELECT id, code, libelle"; |
| 71 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_typent"; |
|
| 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; |
|
| 74 | - $sql.= " ORDER by position, id"; |
|
| 71 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_typent"; |
|
| 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; |
|
| 74 | + $sql .= " ORDER by position, id"; |
|
| 75 | 75 | dol_syslog(get_class($this).'::typent_array', LOG_DEBUG); |
| 76 | - $resql=$this->db->query($sql); |
|
| 76 | + $resql = $this->db->query($sql); |
|
| 77 | 77 | if ($resql) |
| 78 | 78 | { |
| 79 | 79 | $num = $this->db->num_rows($resql); |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | while ($i < $num) |
| 83 | 83 | { |
| 84 | 84 | $objp = $this->db->fetch_object($resql); |
| 85 | - if (! $mode) $key=$objp->id; |
|
| 86 | - else $key=$objp->code; |
|
| 85 | + if (!$mode) $key = $objp->id; |
|
| 86 | + else $key = $objp->code; |
|
| 87 | 87 | if ($langs->trans($objp->code) != $objp->code) $effs[$key] = $langs->trans($objp->code); |
| 88 | 88 | else $effs[$key] = $objp->libelle; |
| 89 | - if ($effs[$key]=='-') $effs[$key]=''; |
|
| 89 | + if ($effs[$key] == '-') $effs[$key] = ''; |
|
| 90 | 90 | $i++; |
| 91 | 91 | } |
| 92 | 92 | $this->db->free($resql); |
@@ -103,18 +103,18 @@ discard block |
||
| 103 | 103 | * @param string $filter Add a SQL filter to select |
| 104 | 104 | * @return array Array of types d'effectifs |
| 105 | 105 | */ |
| 106 | - function effectif_array($mode=0, $filter='') |
|
| 106 | + function effectif_array($mode = 0, $filter = '') |
|
| 107 | 107 | { |
| 108 | 108 | // phpcs:enable |
| 109 | 109 | $effs = array(); |
| 110 | 110 | |
| 111 | 111 | $sql = "SELECT id, code, libelle"; |
| 112 | 112 | $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif"; |
| 113 | - $sql.= " WHERE active = 1"; |
|
| 114 | - if ($filter) $sql.=" ".$filter; |
|
| 113 | + $sql .= " WHERE active = 1"; |
|
| 114 | + if ($filter) $sql .= " ".$filter; |
|
| 115 | 115 | $sql .= " ORDER BY id ASC"; |
| 116 | 116 | dol_syslog(get_class($this).'::effectif_array', LOG_DEBUG); |
| 117 | - $resql=$this->db->query($sql); |
|
| 117 | + $resql = $this->db->query($sql); |
|
| 118 | 118 | if ($resql) |
| 119 | 119 | { |
| 120 | 120 | $num = $this->db->num_rows($resql); |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | while ($i < $num) |
| 124 | 124 | { |
| 125 | 125 | $objp = $this->db->fetch_object($resql); |
| 126 | - if (! $mode) $key=$objp->id; |
|
| 127 | - else $key=$objp->code; |
|
| 126 | + if (!$mode) $key = $objp->id; |
|
| 127 | + else $key = $objp->code; |
|
| 128 | 128 | |
| 129 | - $effs[$key] = $objp->libelle!='-'?$objp->libelle:''; |
|
| 129 | + $effs[$key] = $objp->libelle != '-' ? $objp->libelle : ''; |
|
| 130 | 130 | $i++; |
| 131 | 131 | } |
| 132 | 132 | $this->db->free($resql); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @param int $empty Add empty value in list |
| 146 | 146 | * @return void |
| 147 | 147 | */ |
| 148 | - function form_prospect_level($page, $selected='', $htmlname='prospect_level_id', $empty=0) |
|
| 148 | + function form_prospect_level($page, $selected = '', $htmlname = 'prospect_level_id', $empty = 0) |
|
| 149 | 149 | { |
| 150 | 150 | // phpcs:enable |
| 151 | 151 | global $user, $langs; |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | print '<input type="hidden" name="action" value="setprospectlevel">'; |
| 155 | 155 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
| 156 | 156 | |
| 157 | - dol_syslog(get_class($this).'::form_prospect_level',LOG_DEBUG); |
|
| 157 | + dol_syslog(get_class($this).'::form_prospect_level', LOG_DEBUG); |
|
| 158 | 158 | $sql = "SELECT code, label"; |
| 159 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; |
|
| 160 | - $sql.= " WHERE active > 0"; |
|
| 161 | - $sql.= " ORDER BY sortorder"; |
|
| 159 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; |
|
| 160 | + $sql .= " WHERE active > 0"; |
|
| 161 | + $sql .= " ORDER BY sortorder"; |
|
| 162 | 162 | $resql = $this->db->query($sql); |
| 163 | 163 | if ($resql) |
| 164 | 164 | { |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | print Form::selectarray($htmlname, $options, $selected); |
| 182 | 182 | } |
| 183 | 183 | else dol_print_error($this->db); |
| 184 | - if (! empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 184 | + if (!empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 185 | 185 | print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
| 186 | 186 | print '</form>'; |
| 187 | 187 | } |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | * @param string $htmlname Id of department |
| 200 | 200 | * @return void |
| 201 | 201 | */ |
| 202 | - function select_departement($selected='',$country_codeid=0, $htmlname='state_id') |
|
| 202 | + function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id') |
|
| 203 | 203 | { |
| 204 | 204 | // phpcs:enable |
| 205 | - print $this->select_state($selected,$country_codeid, $htmlname); |
|
| 205 | + print $this->select_state($selected, $country_codeid, $htmlname); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -219,91 +219,91 @@ discard block |
||
| 219 | 219 | * @return string String with HTML select |
| 220 | 220 | * @see select_country |
| 221 | 221 | */ |
| 222 | - function select_state($selected='',$country_codeid=0, $htmlname='state_id') |
|
| 222 | + function select_state($selected = '', $country_codeid = 0, $htmlname = 'state_id') |
|
| 223 | 223 | { |
| 224 | 224 | // phpcs:enable |
| 225 | - global $conf,$langs,$user; |
|
| 225 | + global $conf, $langs, $user; |
|
| 226 | 226 | |
| 227 | - dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid,LOG_DEBUG); |
|
| 227 | + dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid, LOG_DEBUG); |
|
| 228 | 228 | |
| 229 | 229 | $langs->load("dict"); |
| 230 | 230 | |
| 231 | - $out=''; |
|
| 231 | + $out = ''; |
|
| 232 | 232 | |
| 233 | 233 | // Serch departements/cantons/province active d'une region et pays actif |
| 234 | 234 | $sql = "SELECT d.rowid, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.nom as region_name FROM"; |
| 235 | - $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; |
|
| 235 | + $sql .= " ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; |
|
| 236 | 236 | $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid"; |
| 237 | 237 | $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; |
| 238 | 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)."'"; |
|
| 239 | + if ($country_codeid && !is_numeric($country_codeid)) $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; |
|
| 240 | 240 | $sql .= " ORDER BY c.code, d.code_departement"; |
| 241 | 241 | |
| 242 | - $result=$this->db->query($sql); |
|
| 242 | + $result = $this->db->query($sql); |
|
| 243 | 243 | if ($result) |
| 244 | 244 | { |
| 245 | - if (!empty($htmlname)) $out.= '<select id="'.$htmlname.'" class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'">'; |
|
| 246 | - if ($country_codeid) $out.= '<option value="0"> </option>'; |
|
| 245 | + if (!empty($htmlname)) $out .= '<select id="'.$htmlname.'" class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'">'; |
|
| 246 | + if ($country_codeid) $out .= '<option value="0"> </option>'; |
|
| 247 | 247 | $num = $this->db->num_rows($result); |
| 248 | 248 | $i = 0; |
| 249 | - dol_syslog(get_class($this)."::select_departement num=".$num,LOG_DEBUG); |
|
| 249 | + dol_syslog(get_class($this)."::select_departement num=".$num, LOG_DEBUG); |
|
| 250 | 250 | if ($num) |
| 251 | 251 | { |
| 252 | - $country=''; |
|
| 252 | + $country = ''; |
|
| 253 | 253 | while ($i < $num) |
| 254 | 254 | { |
| 255 | 255 | $obj = $this->db->fetch_object($result); |
| 256 | 256 | if ($obj->code == '0') // Le code peut etre une chaine |
| 257 | 257 | { |
| 258 | - $out.= '<option value="0"> </option>'; |
|
| 258 | + $out .= '<option value="0"> </option>'; |
|
| 259 | 259 | } |
| 260 | 260 | else { |
| 261 | - if (! $country || $country != $obj->country) |
|
| 261 | + if (!$country || $country != $obj->country) |
|
| 262 | 262 | { |
| 263 | 263 | // Affiche la rupture si on est en mode liste multipays |
| 264 | - if (! $country_codeid && $obj->country_code) |
|
| 264 | + if (!$country_codeid && $obj->country_code) |
|
| 265 | 265 | { |
| 266 | - $out.= '<option value="-1" disabled>----- '.$obj->country." -----</option>\n"; |
|
| 267 | - $country=$obj->country; |
|
| 266 | + $out .= '<option value="-1" disabled>----- '.$obj->country." -----</option>\n"; |
|
| 267 | + $country = $obj->country; |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - if ((! empty($selected) && $selected == $obj->rowid) |
|
| 272 | - || (empty($selected) && ! empty($conf->global->MAIN_FORCE_DEFAULT_STATE_ID) && $conf->global->MAIN_FORCE_DEFAULT_STATE_ID == $obj->rowid)) |
|
| 271 | + if ((!empty($selected) && $selected == $obj->rowid) |
|
| 272 | + || (empty($selected) && !empty($conf->global->MAIN_FORCE_DEFAULT_STATE_ID) && $conf->global->MAIN_FORCE_DEFAULT_STATE_ID == $obj->rowid)) |
|
| 273 | 273 | { |
| 274 | - $out.= '<option value="'.$obj->rowid.'" selected>'; |
|
| 274 | + $out .= '<option value="'.$obj->rowid.'" selected>'; |
|
| 275 | 275 | } |
| 276 | 276 | else |
| 277 | 277 | { |
| 278 | - $out.= '<option value="'.$obj->rowid.'">'; |
|
| 278 | + $out .= '<option value="'.$obj->rowid.'">'; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut |
| 282 | 282 | if (!empty($conf->global->MAIN_SHOW_STATE_CODE) && |
| 283 | 283 | ($conf->global->MAIN_SHOW_STATE_CODE == 1 || $conf->global->MAIN_SHOW_STATE_CODE == 2 || $conf->global->MAIN_SHOW_STATE_CODE === 'all')) { |
| 284 | - if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
|
| 285 | - $out.= $obj->region_name . ' - ' . $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
| 284 | + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
|
| 285 | + $out .= $obj->region_name.' - '.$obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); |
|
| 286 | 286 | } |
| 287 | 287 | else { |
| 288 | - $out.= $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
| 288 | + $out .= $obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); |
|
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | else { |
| 292 | - if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
|
| 293 | - $out.= $obj->region_name . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
| 292 | + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
|
| 293 | + $out .= $obj->region_name.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); |
|
| 294 | 294 | } |
| 295 | 295 | else { |
| 296 | - $out.= ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
| 296 | + $out .= ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); |
|
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - $out.= '</option>'; |
|
| 300 | + $out .= '</option>'; |
|
| 301 | 301 | } |
| 302 | 302 | $i++; |
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | - if (! empty($htmlname)) $out.= '</select>'; |
|
| 306 | - if (! empty($htmlname) && $user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 305 | + if (!empty($htmlname)) $out .= '</select>'; |
|
| 306 | + if (!empty($htmlname) && $user->admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 307 | 307 | } |
| 308 | 308 | else |
| 309 | 309 | { |
@@ -311,9 +311,9 @@ discard block |
||
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | // Make select dynamic |
| 314 | - if (! empty($htmlname)) |
|
| 314 | + if (!empty($htmlname)) |
|
| 315 | 315 | { |
| 316 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
| 316 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
|
| 317 | 317 | $out .= ajax_combobox($htmlname); |
| 318 | 318 | } |
| 319 | 319 | |
@@ -332,19 +332,19 @@ discard block |
||
| 332 | 332 | * @param string $htmlname Name of HTML select field |
| 333 | 333 | * @return void |
| 334 | 334 | */ |
| 335 | - function select_region($selected='',$htmlname='region_id') |
|
| 335 | + function select_region($selected = '', $htmlname = 'region_id') |
|
| 336 | 336 | { |
| 337 | 337 | // phpcs:enable |
| 338 | - global $conf,$langs; |
|
| 338 | + global $conf, $langs; |
|
| 339 | 339 | $langs->load("dict"); |
| 340 | 340 | |
| 341 | 341 | $sql = "SELECT r.rowid, r.code_region as code, r.nom as label, r.active, c.code as country_code, c.label as country"; |
| 342 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c"; |
|
| 343 | - $sql.= " WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1"; |
|
| 344 | - $sql.= " ORDER BY c.code, c.label ASC"; |
|
| 342 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c"; |
|
| 343 | + $sql .= " WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1"; |
|
| 344 | + $sql .= " ORDER BY c.code, c.label ASC"; |
|
| 345 | 345 | |
| 346 | 346 | dol_syslog(get_class($this)."::select_region", LOG_DEBUG); |
| 347 | - $resql=$this->db->query($sql); |
|
| 347 | + $resql = $this->db->query($sql); |
|
| 348 | 348 | if ($resql) |
| 349 | 349 | { |
| 350 | 350 | print '<select class="flat" name="'.$htmlname.'">'; |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | $i = 0; |
| 353 | 353 | if ($num) |
| 354 | 354 | { |
| 355 | - $country=''; |
|
| 355 | + $country = ''; |
|
| 356 | 356 | while ($i < $num) |
| 357 | 357 | { |
| 358 | 358 | $obj = $this->db->fetch_object($resql); |
@@ -363,10 +363,10 @@ discard block |
||
| 363 | 363 | if ($country == '' || $country != $obj->country) |
| 364 | 364 | { |
| 365 | 365 | // Show break |
| 366 | - $key=$langs->trans("Country".strtoupper($obj->country_code)); |
|
| 367 | - $valuetoshow=($key != "Country".strtoupper($obj->country_code))?$obj->country_code." - ".$key:$obj->country; |
|
| 366 | + $key = $langs->trans("Country".strtoupper($obj->country_code)); |
|
| 367 | + $valuetoshow = ($key != "Country".strtoupper($obj->country_code)) ? $obj->country_code." - ".$key : $obj->country; |
|
| 368 | 368 | print '<option value="-1" disabled>----- '.$valuetoshow." -----</option>\n"; |
| 369 | - $country=$obj->country; |
|
| 369 | + $country = $obj->country; |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | if ($selected > 0 && $selected == $obj->code) |
@@ -398,23 +398,23 @@ discard block |
||
| 398 | 398 | * @param string $morecss Add more css on SELECT element |
| 399 | 399 | * @return string String with HTML select |
| 400 | 400 | */ |
| 401 | - function select_civility($selected='',$htmlname='civility_id',$morecss='maxwidth100') |
|
| 401 | + function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth100') |
|
| 402 | 402 | { |
| 403 | 403 | // phpcs:enable |
| 404 | - global $conf,$langs,$user; |
|
| 404 | + global $conf, $langs, $user; |
|
| 405 | 405 | $langs->load("dict"); |
| 406 | 406 | |
| 407 | - $out=''; |
|
| 407 | + $out = ''; |
|
| 408 | 408 | |
| 409 | 409 | $sql = "SELECT rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_civility"; |
| 410 | - $sql.= " WHERE active = 1"; |
|
| 410 | + $sql .= " WHERE active = 1"; |
|
| 411 | 411 | |
| 412 | 412 | dol_syslog("Form::select_civility", LOG_DEBUG); |
| 413 | - $resql=$this->db->query($sql); |
|
| 413 | + $resql = $this->db->query($sql); |
|
| 414 | 414 | if ($resql) |
| 415 | 415 | { |
| 416 | - $out.= '<select class="flat'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 417 | - $out.= '<option value=""> </option>'; |
|
| 416 | + $out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 417 | + $out .= '<option value=""> </option>'; |
|
| 418 | 418 | $num = $this->db->num_rows($resql); |
| 419 | 419 | $i = 0; |
| 420 | 420 | if ($num) |
@@ -424,20 +424,20 @@ discard block |
||
| 424 | 424 | $obj = $this->db->fetch_object($resql); |
| 425 | 425 | if ($selected == $obj->code) |
| 426 | 426 | { |
| 427 | - $out.= '<option value="'.$obj->code.'" selected>'; |
|
| 427 | + $out .= '<option value="'.$obj->code.'" selected>'; |
|
| 428 | 428 | } |
| 429 | 429 | else |
| 430 | 430 | { |
| 431 | - $out.= '<option value="'.$obj->code.'">'; |
|
| 431 | + $out .= '<option value="'.$obj->code.'">'; |
|
| 432 | 432 | } |
| 433 | 433 | // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut |
| 434 | - $out.= ($langs->trans("Civility".$obj->code)!="Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->label!='-'?$obj->label:'')); |
|
| 435 | - $out.= '</option>'; |
|
| 434 | + $out .= ($langs->trans("Civility".$obj->code) != "Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->label != '-' ? $obj->label : '')); |
|
| 435 | + $out .= '</option>'; |
|
| 436 | 436 | $i++; |
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | - $out.= '</select>'; |
|
| 440 | - if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 439 | + $out .= '</select>'; |
|
| 440 | + if ($user->admin) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 441 | 441 | } |
| 442 | 442 | else |
| 443 | 443 | { |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | * @deprecated Use print xxx->select_juridicalstatus instead |
| 460 | 460 | * @see select_juridicalstatus() |
| 461 | 461 | */ |
| 462 | - function select_forme_juridique($selected='', $country_codeid=0, $filter='') |
|
| 462 | + function select_forme_juridique($selected = '', $country_codeid = 0, $filter = '') |
|
| 463 | 463 | { |
| 464 | 464 | // phpcs:enable |
| 465 | 465 | print $this->select_juridicalstatus($selected, $country_codeid, $filter); |
@@ -476,13 +476,13 @@ discard block |
||
| 476 | 476 | * @param string $htmlname HTML name of select |
| 477 | 477 | * @return string String with HTML select |
| 478 | 478 | */ |
| 479 | - function select_juridicalstatus($selected='', $country_codeid=0, $filter='', $htmlname='forme_juridique_code') |
|
| 479 | + function select_juridicalstatus($selected = '', $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code') |
|
| 480 | 480 | { |
| 481 | 481 | // phpcs:enable |
| 482 | - global $conf,$langs,$user; |
|
| 482 | + global $conf, $langs, $user; |
|
| 483 | 483 | $langs->load("dict"); |
| 484 | 484 | |
| 485 | - $out=''; |
|
| 485 | + $out = ''; |
|
| 486 | 486 | |
| 487 | 487 | // On recherche les formes juridiques actives des pays actifs |
| 488 | 488 | $sql = "SELECT f.rowid, f.code as code , f.libelle as label, f.active, c.label as country, c.code as country_code"; |
@@ -494,70 +494,70 @@ discard block |
||
| 494 | 494 | $sql .= " ORDER BY c.code"; |
| 495 | 495 | |
| 496 | 496 | dol_syslog(get_class($this)."::select_juridicalstatus", LOG_DEBUG); |
| 497 | - $resql=$this->db->query($sql); |
|
| 497 | + $resql = $this->db->query($sql); |
|
| 498 | 498 | if ($resql) |
| 499 | 499 | { |
| 500 | - $out.= '<div id="particulier2" class="visible">'; |
|
| 501 | - $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. |
|
| 500 | + $out .= '<div id="particulier2" class="visible">'; |
|
| 501 | + $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. |
|
| 503 | 503 | |
| 504 | 504 | $num = $this->db->num_rows($resql); |
| 505 | 505 | if ($num) |
| 506 | 506 | { |
| 507 | 507 | $i = 0; |
| 508 | - $country=''; $arraydata=array(); |
|
| 508 | + $country = ''; $arraydata = array(); |
|
| 509 | 509 | while ($i < $num) |
| 510 | 510 | { |
| 511 | 511 | $obj = $this->db->fetch_object($resql); |
| 512 | 512 | |
| 513 | 513 | if ($obj->code) // We exclude empty line, we will add it later |
| 514 | 514 | { |
| 515 | - $labelcountry=(($langs->trans("Country".$obj->country_code)!="Country".$obj->country_code) ? $langs->trans("Country".$obj->country_code) : $obj->country); |
|
| 516 | - $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 | - $arraydata[$obj->code]=array('code'=>$obj->code, 'label'=>$labeljs, 'label_sort'=>$labelcountry.'_'.$labeljs, 'country_code'=>$obj->country_code, 'country'=>$labelcountry); |
|
| 515 | + $labelcountry = (($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code) ? $langs->trans("Country".$obj->country_code) : $obj->country); |
|
| 516 | + $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 | + $arraydata[$obj->code] = array('code'=>$obj->code, 'label'=>$labeljs, 'label_sort'=>$labelcountry.'_'.$labeljs, 'country_code'=>$obj->country_code, 'country'=>$labelcountry); |
|
| 518 | 518 | } |
| 519 | 519 | $i++; |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | - $arraydata=dol_sort_array($arraydata, 'label_sort', 'ASC'); |
|
| 522 | + $arraydata = dol_sort_array($arraydata, 'label_sort', 'ASC'); |
|
| 523 | 523 | if (empty($country_codeid)) // Introduce empty value (if $country_codeid not empty, empty value was already added) |
| 524 | 524 | { |
| 525 | - $arraydata[0]=array('code'=>0, 'label'=>'', 'label_sort'=>'_', 'country_code'=>'', 'country'=>''); |
|
| 525 | + $arraydata[0] = array('code'=>0, 'label'=>'', 'label_sort'=>'_', 'country_code'=>'', 'country'=>''); |
|
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - foreach($arraydata as $key => $val) |
|
| 528 | + foreach ($arraydata as $key => $val) |
|
| 529 | 529 | { |
| 530 | - if (! $country || $country != $val['country']) |
|
| 530 | + if (!$country || $country != $val['country']) |
|
| 531 | 531 | { |
| 532 | 532 | // Show break when we are in multi country mode |
| 533 | 533 | if (empty($country_codeid) && $val['country_code']) |
| 534 | 534 | { |
| 535 | - $out.= '<option value="0" disabled class="selectoptiondisabledwhite">----- '.$val['country']." -----</option>\n"; |
|
| 536 | - $country=$val['country']; |
|
| 535 | + $out .= '<option value="0" disabled class="selectoptiondisabledwhite">----- '.$val['country']." -----</option>\n"; |
|
| 536 | + $country = $val['country']; |
|
| 537 | 537 | } |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | if ($selected > 0 && $selected == $val['code']) |
| 541 | 541 | { |
| 542 | - $out.= '<option value="'.$val['code'].'" selected>'; |
|
| 542 | + $out .= '<option value="'.$val['code'].'" selected>'; |
|
| 543 | 543 | } |
| 544 | 544 | else |
| 545 | 545 | { |
| 546 | - $out.= '<option value="'.$val['code'].'">'; |
|
| 546 | + $out .= '<option value="'.$val['code'].'">'; |
|
| 547 | 547 | } |
| 548 | 548 | // If translation exists, we use it, otherwise we use default label in database |
| 549 | - $out.= $val['label']; |
|
| 550 | - $out.= '</option>'; |
|
| 549 | + $out .= $val['label']; |
|
| 550 | + $out .= '</option>'; |
|
| 551 | 551 | } |
| 552 | 552 | } |
| 553 | - $out.= '</select>'; |
|
| 554 | - if ($user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 553 | + $out .= '</select>'; |
|
| 554 | + if ($user->admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 555 | 555 | |
| 556 | 556 | // Make select dynamic |
| 557 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
| 557 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
|
| 558 | 558 | $out .= ajax_combobox($htmlname); |
| 559 | 559 | |
| 560 | - $out.= '</div>'; |
|
| 560 | + $out .= '</div>'; |
|
| 561 | 561 | } |
| 562 | 562 | else |
| 563 | 563 | { |
@@ -581,19 +581,19 @@ discard block |
||
| 581 | 581 | * @param string $morecss More CSS on select component |
| 582 | 582 | * @return int The selected third party ID |
| 583 | 583 | */ |
| 584 | - function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='', $forceid=0, $moreparam='', $morecss='') |
|
| 584 | + function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany', $limitto = '', $forceid = 0, $moreparam = '', $morecss = '') |
|
| 585 | 585 | { |
| 586 | 586 | global $conf, $langs; |
| 587 | 587 | |
| 588 | - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) |
|
| 588 | + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) |
|
| 589 | 589 | { |
| 590 | 590 | // Use Ajax search |
| 591 | - $minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2); |
|
| 591 | + $minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT) ? $conf->global->COMPANY_USE_SEARCH_TO_SELECT : 2); |
|
| 592 | 592 | |
| 593 | - $socid=0; $name=''; |
|
| 593 | + $socid = 0; $name = ''; |
|
| 594 | 594 | if ($selected > 0) |
| 595 | 595 | { |
| 596 | - $tmpthirdparty=new Societe($this->db); |
|
| 596 | + $tmpthirdparty = new Societe($this->db); |
|
| 597 | 597 | $result = $tmpthirdparty->fetch($selected); |
| 598 | 598 | if ($result > 0) |
| 599 | 599 | { |
@@ -603,13 +603,13 @@ discard block |
||
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | |
| 606 | - $events=array(); |
|
| 606 | + $events = array(); |
|
| 607 | 607 | // Add an entry 'method' to say 'yes, we must execute url with param action = method'; |
| 608 | 608 | // Add an entry 'url' to say which url to execute |
| 609 | 609 | // Add an entry htmlname to say which element we must change once url is called |
| 610 | 610 | // Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines |
| 611 | 611 | // To refresh contacts list on thirdparty list change |
| 612 | - $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); |
|
| 612 | + $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); |
|
| 613 | 613 | |
| 614 | 614 | if (count($events)) // If there is some ajax events to run once selection is done, we add code here to run events |
| 615 | 615 | { |
@@ -665,29 +665,29 @@ discard block |
||
| 665 | 665 | |
| 666 | 666 | print "\n".'<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->'."\n"; |
| 667 | 667 | print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="'.$name.'" />'; |
| 668 | - print ajax_autocompleter(($socid?$socid:-1), $htmlname, DOL_URL_ROOT.'/societe/ajaxcompanies.php', '', $minLength, 0); |
|
| 668 | + print ajax_autocompleter(($socid ? $socid : -1), $htmlname, DOL_URL_ROOT.'/societe/ajaxcompanies.php', '', $minLength, 0); |
|
| 669 | 669 | return $socid; |
| 670 | 670 | } |
| 671 | 671 | else |
| 672 | 672 | { |
| 673 | 673 | // Search to list thirdparties |
| 674 | 674 | $sql = "SELECT s.rowid, s.nom as name FROM"; |
| 675 | - $sql.= " ".MAIN_DB_PREFIX."societe as s"; |
|
| 676 | - $sql.= " WHERE s.entity IN (".getEntity('societe').")"; |
|
| 675 | + $sql .= " ".MAIN_DB_PREFIX."societe as s"; |
|
| 676 | + $sql .= " WHERE s.entity IN (".getEntity('societe').")"; |
|
| 677 | 677 | // For ajax search we limit here. For combo list, we limit later |
| 678 | 678 | if (is_array($limitto) && count($limitto)) |
| 679 | 679 | { |
| 680 | - $sql.= " AND s.rowid IN (".join(',',$limitto).")"; |
|
| 680 | + $sql .= " AND s.rowid IN (".join(',', $limitto).")"; |
|
| 681 | 681 | } |
| 682 | - $sql.= " ORDER BY s.nom ASC"; |
|
| 682 | + $sql .= " ORDER BY s.nom ASC"; |
|
| 683 | 683 | |
| 684 | 684 | $resql = $this->db->query($sql); |
| 685 | 685 | if ($resql) |
| 686 | 686 | { |
| 687 | - print '<select class="flat'.($morecss?' '.$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'"'; |
|
| 687 | + print '<select class="flat'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'"'; |
|
| 688 | 688 | if ($conf->use_javascript_ajax) |
| 689 | 689 | { |
| 690 | - $javaScript = "window.location='".$_SERVER['PHP_SELF']."?".$var_id."=".($forceid>0?$forceid:$object->id).$moreparam."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; |
|
| 690 | + $javaScript = "window.location='".$_SERVER['PHP_SELF']."?".$var_id."=".($forceid > 0 ? $forceid : $object->id).$moreparam."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; |
|
| 691 | 691 | print ' onChange="'.$javaScript.'"'; |
| 692 | 692 | } |
| 693 | 693 | print '>'; |
@@ -699,22 +699,22 @@ discard block |
||
| 699 | 699 | { |
| 700 | 700 | $obj = $this->db->fetch_object($resql); |
| 701 | 701 | if ($i == 0) $firstCompany = $obj->rowid; |
| 702 | - $disabled=0; |
|
| 703 | - if (is_array($limitto) && count($limitto) && ! in_array($obj->rowid,$limitto)) $disabled=1; |
|
| 702 | + $disabled = 0; |
|
| 703 | + if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) $disabled = 1; |
|
| 704 | 704 | if ($selected > 0 && $selected == $obj->rowid) |
| 705 | 705 | { |
| 706 | 706 | print '<option value="'.$obj->rowid.'"'; |
| 707 | 707 | if ($disabled) print ' disabled'; |
| 708 | - print ' selected>'.dol_trunc($obj->name,24).'</option>'; |
|
| 708 | + print ' selected>'.dol_trunc($obj->name, 24).'</option>'; |
|
| 709 | 709 | $firstCompany = $obj->rowid; |
| 710 | 710 | } |
| 711 | 711 | else |
| 712 | 712 | { |
| 713 | 713 | print '<option value="'.$obj->rowid.'"'; |
| 714 | 714 | if ($disabled) print ' disabled'; |
| 715 | - print '>'.dol_trunc($obj->name,24).'</option>'; |
|
| 715 | + print '>'.dol_trunc($obj->name, 24).'</option>'; |
|
| 716 | 716 | } |
| 717 | - $i ++; |
|
| 717 | + $i++; |
|
| 718 | 718 | } |
| 719 | 719 | } |
| 720 | 720 | print "</select>\n"; |
@@ -740,23 +740,23 @@ discard block |
||
| 740 | 740 | * @param string $morecss Add more css to select component |
| 741 | 741 | * @return void |
| 742 | 742 | */ |
| 743 | - function selectTypeContact($object, $selected, $htmlname = 'type', $source='internal', $sortorder='position', $showempty=0, $morecss='') |
|
| 743 | + function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '') |
|
| 744 | 744 | { |
| 745 | 745 | global $user, $langs; |
| 746 | 746 | |
| 747 | 747 | if (is_object($object) && method_exists($object, 'liste_type_contact')) |
| 748 | 748 | { |
| 749 | 749 | $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1); |
| 750 | - print '<select class="flat valignmiddle'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 750 | + print '<select class="flat valignmiddle'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 751 | 751 | if ($showempty) print '<option value="0"></option>'; |
| 752 | - foreach($lesTypes as $key=>$value) |
|
| 752 | + foreach ($lesTypes as $key=>$value) |
|
| 753 | 753 | { |
| 754 | 754 | print '<option value="'.$key.'"'; |
| 755 | 755 | if ($key == $selected) print ' selected'; |
| 756 | 756 | print '>'.$value.'</option>'; |
| 757 | 757 | } |
| 758 | 758 | print "</select>"; |
| 759 | - if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 759 | + if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 760 | 760 | print "\n"; |
| 761 | 761 | } |
| 762 | 762 | } |
@@ -774,22 +774,22 @@ discard block |
||
| 774 | 774 | * @param string $morecss More css |
| 775 | 775 | * @return string |
| 776 | 776 | */ |
| 777 | - function select_ziptown($selected='', $htmlname='zipcode', $fields='', $fieldsize=0, $disableautocomplete=0, $moreattrib='',$morecss='') |
|
| 777 | + function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = '', $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '') |
|
| 778 | 778 | { |
| 779 | 779 | // phpcs:enable |
| 780 | 780 | global $conf; |
| 781 | 781 | |
| 782 | - $out=''; |
|
| 782 | + $out = ''; |
|
| 783 | 783 | |
| 784 | - $size=''; |
|
| 785 | - if (!empty($fieldsize)) $size='size="'.$fieldsize.'"'; |
|
| 784 | + $size = ''; |
|
| 785 | + if (!empty($fieldsize)) $size = 'size="'.$fieldsize.'"'; |
|
| 786 | 786 | |
| 787 | 787 | if ($conf->use_javascript_ajax && empty($disableautocomplete)) |
| 788 | 788 | { |
| 789 | - $out.= ajax_multiautocompleter($htmlname,$fields,DOL_URL_ROOT.'/core/ajax/ziptown.php')."\n"; |
|
| 790 | - $moreattrib.=' autocomplete="off"'; |
|
| 789 | + $out .= ajax_multiautocompleter($htmlname, $fields, DOL_URL_ROOT.'/core/ajax/ziptown.php')."\n"; |
|
| 790 | + $moreattrib .= ' autocomplete="off"'; |
|
| 791 | 791 | } |
| 792 | - $out.= '<input id="'.$htmlname.'" class="maxwidthonsmartphone'.($morecss?' '.$morecss:'').'" type="text"'.($moreattrib?' '.$moreattrib:'').' name="'.$htmlname.'" '.$size.' value="'.$selected.'">'."\n"; |
|
| 792 | + $out .= '<input id="'.$htmlname.'" class="maxwidthonsmartphone'.($morecss ? ' '.$morecss : '').'" type="text"'.($moreattrib ? ' '.$moreattrib : '').' name="'.$htmlname.'" '.$size.' value="'.$selected.'">'."\n"; |
|
| 793 | 793 | |
| 794 | 794 | return $out; |
| 795 | 795 | } |
@@ -805,43 +805,43 @@ discard block |
||
| 805 | 805 | * @param string $morecss More css |
| 806 | 806 | * @return string HTML string with prof id |
| 807 | 807 | */ |
| 808 | - function get_input_id_prof($idprof,$htmlname,$preselected,$country_code,$morecss='maxwidth100onsmartphone quatrevingtpercent') |
|
| 808 | + function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth100onsmartphone quatrevingtpercent') |
|
| 809 | 809 | { |
| 810 | 810 | // phpcs:enable |
| 811 | - global $conf,$langs; |
|
| 811 | + global $conf, $langs; |
|
| 812 | 812 | |
| 813 | - $formlength=0; |
|
| 813 | + $formlength = 0; |
|
| 814 | 814 | if (empty($conf->global->MAIN_DISABLEPROFIDRULES)) { |
| 815 | 815 | if ($country_code == 'FR') |
| 816 | 816 | { |
| 817 | 817 | 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 |
|
| 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 |
|
| 822 | 822 | } |
| 823 | 823 | } |
| 824 | 824 | else if ($country_code == 'ES') |
| 825 | 825 | { |
| 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 |
|
| 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 |
|
| 830 | 830 | } |
| 831 | 831 | } |
| 832 | 832 | |
| 833 | - $selected=$preselected; |
|
| 834 | - 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; |
|
| 833 | + $selected = $preselected; |
|
| 834 | + 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; |
|
| 839 | 839 | } |
| 840 | 840 | |
| 841 | - $maxlength=$formlength; |
|
| 842 | - if (empty($formlength)) { $formlength=24; $maxlength=128; } |
|
| 841 | + $maxlength = $formlength; |
|
| 842 | + if (empty($formlength)) { $formlength = 24; $maxlength = 128; } |
|
| 843 | 843 | |
| 844 | - $out = '<input type="text" '.($morecss?'class="'.$morecss.'" ':'').'name="'.$htmlname.'" id="'.$htmlname.'" maxlength="'.$maxlength.'" value="'.$selected.'">'; |
|
| 844 | + $out = '<input type="text" '.($morecss ? 'class="'.$morecss.'" ' : '').'name="'.$htmlname.'" id="'.$htmlname.'" maxlength="'.$maxlength.'" value="'.$selected.'">'; |
|
| 845 | 845 | |
| 846 | 846 | return $out; |
| 847 | 847 | } |
@@ -858,19 +858,19 @@ discard block |
||
| 858 | 858 | function select_localtax($local, $selected, $htmlname) |
| 859 | 859 | { |
| 860 | 860 | // phpcs:enable |
| 861 | - $tax=get_localtax_by_third($local); |
|
| 861 | + $tax = get_localtax_by_third($local); |
|
| 862 | 862 | |
| 863 | 863 | $num = $this->db->num_rows($tax); |
| 864 | 864 | $i = 0; |
| 865 | 865 | if ($num) |
| 866 | 866 | { |
| 867 | - $valors=explode(":", $tax); |
|
| 867 | + $valors = explode(":", $tax); |
|
| 868 | 868 | |
| 869 | 869 | if (count($valors) > 1) |
| 870 | 870 | { |
| 871 | 871 | //montar select |
| 872 | 872 | print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">'; |
| 873 | - while ($i <= (count($valors))-1) |
|
| 873 | + while ($i <= (count($valors)) - 1) |
|
| 874 | 874 | { |
| 875 | 875 | if ($selected == $valors[$i]) |
| 876 | 876 | { |
@@ -117,10 +117,10 @@ discard block |
||
| 117 | 117 | /** |
| 118 | 118 | * Message Sensitivity |
| 119 | 119 | */ |
| 120 | - var $_arySensitivity = array ( false, |
|
| 120 | + var $_arySensitivity = array(false, |
|
| 121 | 121 | 'Personal', |
| 122 | 122 | 'Private', |
| 123 | - 'Company Confidential' ); |
|
| 123 | + 'Company Confidential'); |
|
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | 126 | * Message Sensitivity |
@@ -131,12 +131,12 @@ discard block |
||
| 131 | 131 | /** |
| 132 | 132 | * Message Priority |
| 133 | 133 | */ |
| 134 | - var $_aryPriority = array ( 'Bulk', |
|
| 134 | + var $_aryPriority = array('Bulk', |
|
| 135 | 135 | 'Highest', |
| 136 | 136 | 'High', |
| 137 | 137 | 'Normal', |
| 138 | 138 | 'Low', |
| 139 | - 'Lowest' ); |
|
| 139 | + 'Lowest'); |
|
| 140 | 140 | |
| 141 | 141 | /** |
| 142 | 142 | * Content-Transfer-Encoding |
@@ -147,13 +147,13 @@ discard block |
||
| 147 | 147 | /** |
| 148 | 148 | * Content-Transfer-Encoding |
| 149 | 149 | */ |
| 150 | - var $_smtpsTransEncodeTypes = array( '7bit', // Simple 7-bit ASCII |
|
| 151 | - '8bit', // 8-bit coding with line termination characters |
|
| 152 | - 'base64', // 3 octets encoded into 4 sextets with offset |
|
| 153 | - 'binary', // Arbitrary binary stream |
|
| 154 | - 'mac-binhex40', // Macintosh binary to hex encoding |
|
| 155 | - 'quoted-printable', // Mostly 7-bit, with 8-bit characters encoded as "=HH" |
|
| 156 | - 'uuencode' ); // UUENCODE encoding |
|
| 150 | + var $_smtpsTransEncodeTypes = array('7bit', // Simple 7-bit ASCII |
|
| 151 | + '8bit', // 8-bit coding with line termination characters |
|
| 152 | + 'base64', // 3 octets encoded into 4 sextets with offset |
|
| 153 | + 'binary', // Arbitrary binary stream |
|
| 154 | + 'mac-binhex40', // Macintosh binary to hex encoding |
|
| 155 | + 'quoted-printable', // Mostly 7-bit, with 8-bit characters encoded as "=HH" |
|
| 156 | + 'uuencode'); // UUENCODE encoding |
|
| 157 | 157 | |
| 158 | 158 | /** |
| 159 | 159 | * Content-Transfer-Encoding |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | */ |
| 301 | 301 | function setErrorsTo($_strErrorsTo) |
| 302 | 302 | { |
| 303 | - if ( $_strErrorsTo ) |
|
| 303 | + if ($_strErrorsTo) |
|
| 304 | 304 | $this->_errorsTo = $this->_strip_email($_strErrorsTo); |
| 305 | 305 | } |
| 306 | 306 | |
@@ -310,11 +310,11 @@ discard block |
||
| 310 | 310 | * @param boolean $_part Variant |
| 311 | 311 | * @return string Errors to |
| 312 | 312 | */ |
| 313 | - function getErrorsTo($_part = true ) |
|
| 313 | + function getErrorsTo($_part = true) |
|
| 314 | 314 | { |
| 315 | 315 | $_retValue = ''; |
| 316 | 316 | |
| 317 | - if ( $_part === true ) |
|
| 317 | + if ($_part === true) |
|
| 318 | 318 | $_retValue = $this->_errorsTo; |
| 319 | 319 | else |
| 320 | 320 | $_retValue = $this->_errorsTo[$_part]; |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | * @param boolean $_vDebug Value for debug |
| 329 | 329 | * @return void |
| 330 | 330 | */ |
| 331 | - function setDebug($_vDebug = false ) |
|
| 331 | + function setDebug($_vDebug = false) |
|
| 332 | 332 | { |
| 333 | 333 | $this->_debug = $_vDebug; |
| 334 | 334 | } |
@@ -359,29 +359,29 @@ discard block |
||
| 359 | 359 | // We have to make sure the HOST given is valid |
| 360 | 360 | // This is done here because '@fsockopen' will not give me this |
| 361 | 361 | // information if it failes to connect because it can't find the HOST |
| 362 | - $host=$this->getHost(); |
|
| 363 | - $usetls = preg_match('@tls://@i',$host); |
|
| 362 | + $host = $this->getHost(); |
|
| 363 | + $usetls = preg_match('@tls://@i', $host); |
|
| 364 | 364 | |
| 365 | - $host=preg_replace('@tcp://@i','',$host); // Remove prefix |
|
| 366 | - $host=preg_replace('@ssl://@i','',$host); // Remove prefix |
|
| 367 | - $host=preg_replace('@tls://@i','',$host); // Remove prefix |
|
| 365 | + $host = preg_replace('@tcp://@i', '', $host); // Remove prefix |
|
| 366 | + $host = preg_replace('@ssl://@i', '', $host); // Remove prefix |
|
| 367 | + $host = preg_replace('@tls://@i', '', $host); // Remove prefix |
|
| 368 | 368 | |
| 369 | 369 | // @CHANGE LDR |
| 370 | 370 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
| 371 | 371 | |
| 372 | - if ( (! is_ip($host)) && ((gethostbyname($host)) == $host)) |
|
| 372 | + if ((!is_ip($host)) && ((gethostbyname($host)) == $host)) |
|
| 373 | 373 | { |
| 374 | - $this->_setErr(99, $host . ' is either offline or is an invalid host name.'); |
|
| 374 | + $this->_setErr(99, $host.' is either offline or is an invalid host name.'); |
|
| 375 | 375 | $_retVal = false; |
| 376 | 376 | } |
| 377 | 377 | else |
| 378 | 378 | { |
| 379 | 379 | //See if we can connect to the SMTP server |
| 380 | 380 | if ($this->socket = @fsockopen( |
| 381 | - preg_replace('@tls://@i','',$this->getHost()), // Host to 'hit', IP or domain |
|
| 382 | - $this->getPort(), // which Port number to use |
|
| 383 | - $this->errno, // actual system level error |
|
| 384 | - $this->errstr, // and any text that goes with the error |
|
| 381 | + preg_replace('@tls://@i', '', $this->getHost()), // Host to 'hit', IP or domain |
|
| 382 | + $this->getPort(), // which Port number to use |
|
| 383 | + $this->errno, // actual system level error |
|
| 384 | + $this->errstr, // and any text that goes with the error |
|
| 385 | 385 | $this->_smtpTimeout |
| 386 | 386 | )) // timeout for reading/writing data over the socket |
| 387 | 387 | { |
@@ -392,14 +392,14 @@ discard block |
||
| 392 | 392 | if (function_exists('stream_set_timeout')) stream_set_timeout($this->socket, $this->_smtpTimeout, 0); |
| 393 | 393 | |
| 394 | 394 | // Check response from Server |
| 395 | - if ( $_retVal = $this->server_parse($this->socket, "220") ) |
|
| 395 | + if ($_retVal = $this->server_parse($this->socket, "220")) |
|
| 396 | 396 | $_retVal = $this->socket; |
| 397 | 397 | } |
| 398 | 398 | // This connection attempt failed. |
| 399 | 399 | else |
| 400 | 400 | { |
| 401 | 401 | // @CHANGE LDR |
| 402 | - if (empty($this->errstr)) $this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort(); |
|
| 402 | + if (empty($this->errstr)) $this->errstr = 'Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort(); |
|
| 403 | 403 | $this->_setErr($this->errno, $this->errstr); |
| 404 | 404 | $_retVal = false; |
| 405 | 405 | } |
@@ -422,18 +422,18 @@ discard block |
||
| 422 | 422 | // Send the RFC2554 specified EHLO. |
| 423 | 423 | // This improvment as provided by 'SirSir' to |
| 424 | 424 | // accomodate both SMTP AND ESMTP capable servers |
| 425 | - $host=$this->getHost(); |
|
| 426 | - $usetls = preg_match('@tls://@i',$host); |
|
| 425 | + $host = $this->getHost(); |
|
| 426 | + $usetls = preg_match('@tls://@i', $host); |
|
| 427 | 427 | |
| 428 | - $host=preg_replace('@tcp://@i','',$host); // Remove prefix |
|
| 429 | - $host=preg_replace('@ssl://@i','',$host); // Remove prefix |
|
| 430 | - $host=preg_replace('@tls://@i','',$host); // Remove prefix |
|
| 428 | + $host = preg_replace('@tcp://@i', '', $host); // Remove prefix |
|
| 429 | + $host = preg_replace('@ssl://@i', '', $host); // Remove prefix |
|
| 430 | + $host = preg_replace('@tls://@i', '', $host); // Remove prefix |
|
| 431 | 431 | |
| 432 | - if ($usetls) $host='tls://'.$host; |
|
| 432 | + if ($usetls) $host = 'tls://'.$host; |
|
| 433 | 433 | |
| 434 | 434 | $hosth = $host; |
| 435 | 435 | |
| 436 | - if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) |
|
| 436 | + if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) |
|
| 437 | 437 | { |
| 438 | 438 | // If the from to is 'aaa <[email protected]>', we will keep 'ccc.com' |
| 439 | 439 | $hosth = $this->getFrom('addr'); |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | $hosth = preg_replace('/.*@/', '', $hosth); |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if ( $_retVal = $this->socket_send_str('EHLO ' . $hosth, '250') ) |
|
| 445 | + if ($_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) |
|
| 446 | 446 | { |
| 447 | 447 | if ($usetls) |
| 448 | 448 | { |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | // the answer with list of supported AUTH methods. They may differs between non STARTTLS and with STARTTLS. |
| 494 | 494 | if (!$_retVal = $this->socket_send_str('EHLO '.$host, '250')) |
| 495 | 495 | { |
| 496 | - $this->_setErr(126, '"' . $host . '" does not support authenticated connections.'); |
|
| 496 | + $this->_setErr(126, '"'.$host.'" does not support authenticated connections.'); |
|
| 497 | 497 | return $_retVal; |
| 498 | 498 | } |
| 499 | 499 | } |
@@ -506,12 +506,12 @@ discard block |
||
| 506 | 506 | |
| 507 | 507 | // The error here just means the ID/password combo doesn't work. |
| 508 | 508 | // 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') ) |
|
| 509 | + if (!$_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235')) |
|
| 510 | 510 | $this->_setErr(130, 'Invalid Authentication Credentials.'); |
| 511 | 511 | } |
| 512 | 512 | else |
| 513 | 513 | { |
| 514 | - $this->_setErr(126, '"' . $host . '" does not support authenticated connections.'); |
|
| 514 | + $this->_setErr(126, '"'.$host.'" does not support authenticated connections.'); |
|
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | return $_retVal; |
@@ -535,10 +535,10 @@ discard block |
||
| 535 | 535 | $_retVal = false; |
| 536 | 536 | |
| 537 | 537 | // Connect to Server |
| 538 | - if ( $this->socket = $this->_server_connect() ) |
|
| 538 | + if ($this->socket = $this->_server_connect()) |
|
| 539 | 539 | { |
| 540 | 540 | // If a User ID *and* a password is given, assume Authentication is desired |
| 541 | - if( !empty($this->_smtpsID) && !empty($this->_smtpsPW) ) |
|
| 541 | + if (!empty($this->_smtpsID) && !empty($this->_smtpsPW)) |
|
| 542 | 542 | { |
| 543 | 543 | // Send the RFC2554 specified EHLO. |
| 544 | 544 | $_retVal = $this->_server_authenticate(); |
@@ -548,16 +548,16 @@ discard block |
||
| 548 | 548 | else |
| 549 | 549 | { |
| 550 | 550 | // Send the RFC821 specified HELO. |
| 551 | - $host=$this->getHost(); |
|
| 552 | - $usetls = preg_match('@tls://@i',$host); |
|
| 551 | + $host = $this->getHost(); |
|
| 552 | + $usetls = preg_match('@tls://@i', $host); |
|
| 553 | 553 | |
| 554 | - $host=preg_replace('@tcp://@i','',$host); // Remove prefix |
|
| 555 | - $host=preg_replace('@ssl://@i','',$host); // Remove prefix |
|
| 556 | - $host=preg_replace('@tls://@i','',$host); // Remove prefix |
|
| 554 | + $host = preg_replace('@tcp://@i', '', $host); // Remove prefix |
|
| 555 | + $host = preg_replace('@ssl://@i', '', $host); // Remove prefix |
|
| 556 | + $host = preg_replace('@tls://@i', '', $host); // Remove prefix |
|
| 557 | 557 | |
| 558 | 558 | $hosth = $host; |
| 559 | 559 | |
| 560 | - if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) |
|
| 560 | + if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) |
|
| 561 | 561 | { |
| 562 | 562 | // If the from to is 'aaa <[email protected]>', we will keep 'ccc.com' |
| 563 | 563 | $hosth = $this->getFrom('addr'); |
@@ -566,21 +566,21 @@ discard block |
||
| 566 | 566 | $hosth = preg_replace('/.*@/', '', $hosth); |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | - $_retVal = $this->socket_send_str('HELO ' . $hosth, '250'); |
|
| 569 | + $_retVal = $this->socket_send_str('HELO '.$hosth, '250'); |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | // Well, did we get to the server? |
| 573 | - if ( $_retVal ) |
|
| 573 | + if ($_retVal) |
|
| 574 | 574 | { |
| 575 | 575 | // From this point onward most server response codes should be 250 |
| 576 | 576 | // Specify who the mail is from.... |
| 577 | 577 | // This has to be the raw email address, strip the "name" off |
| 578 | - $this->socket_send_str('MAIL FROM: ' . $this->getFrom('addr'), '250'); |
|
| 578 | + $this->socket_send_str('MAIL FROM: '.$this->getFrom('addr'), '250'); |
|
| 579 | 579 | |
| 580 | 580 | // 'RCPT TO:' must be given a single address, so this has to loop |
| 581 | 581 | // through the list of addresses, regardless of TO, CC or BCC |
| 582 | 582 | // and send it out "single file" |
| 583 | - foreach ( $this->get_RCPT_list() as $_address ) |
|
| 583 | + foreach ($this->get_RCPT_list() as $_address) |
|
| 584 | 584 | { |
| 585 | 585 | /* Note: |
| 586 | 586 | * BCC email addresses must be listed in the RCPT TO command list, |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | * mark the last address as "bad" and start the address loop over again. |
| 597 | 597 | * If any address fails, the entire message fails. |
| 598 | 598 | */ |
| 599 | - $this->socket_send_str('RCPT TO: <' . $_address . '>', '250'); |
|
| 599 | + $this->socket_send_str('RCPT TO: <'.$_address.'>', '250'); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | // Tell the server we are ready to start sending data |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | |
| 607 | 607 | // Now we are ready for the message... |
| 608 | 608 | // Ok, all the ingredients are mixed in let's cook this puppy... |
| 609 | - $this->socket_send_str($this->getHeader().$this->getBodyContent() . "\r\n" . '.', '250'); |
|
| 609 | + $this->socket_send_str($this->getHeader().$this->getBodyContent()."\r\n".'.', '250'); |
|
| 610 | 610 | |
| 611 | 611 | // Now tell the server we are done and close the socket... |
| 612 | 612 | fputs($this->socket, 'QUIT'); |
@@ -656,13 +656,13 @@ discard block |
||
| 656 | 656 | $_retVal = true; |
| 657 | 657 | |
| 658 | 658 | // if we have a path... |
| 659 | - if ( ! empty ($_strConfigPath) ) |
|
| 659 | + if (!empty ($_strConfigPath)) |
|
| 660 | 660 | { |
| 661 | 661 | // If the path is not valid, this will NOT generate an error, |
| 662 | 662 | // it will simply return false. |
| 663 | - if ( ! @include $_strConfigPath) |
|
| 663 | + if (!@include $_strConfigPath) |
|
| 664 | 664 | { |
| 665 | - $this->_setErr(110, '"' . $_strConfigPath . '" is not a valid path.'); |
|
| 665 | + $this->_setErr(110, '"'.$_strConfigPath.'" is not a valid path.'); |
|
| 666 | 666 | $_retVal = false; |
| 667 | 667 | } |
| 668 | 668 | } |
@@ -672,13 +672,13 @@ discard block |
||
| 672 | 672 | { |
| 673 | 673 | // Set these properties ONLY if they are set in the php.ini file. |
| 674 | 674 | // Otherwise the default values will be used. |
| 675 | - if ( $_host = ini_get('SMTPs') ) |
|
| 675 | + if ($_host = ini_get('SMTPs')) |
|
| 676 | 676 | $this->setHost($_host); |
| 677 | 677 | |
| 678 | - if ( $_port = ini_get('smtp_port') ) |
|
| 678 | + if ($_port = ini_get('smtp_port')) |
|
| 679 | 679 | $this->setPort($_port); |
| 680 | 680 | |
| 681 | - if ( $_from = ini_get('sendmail_from') ) |
|
| 681 | + if ($_from = ini_get('sendmail_from')) |
|
| 682 | 682 | $this->setFrom($_from); |
| 683 | 683 | } |
| 684 | 684 | |
@@ -697,8 +697,8 @@ discard block |
||
| 697 | 697 | */ |
| 698 | 698 | function setTransportType($_type = 0) |
| 699 | 699 | { |
| 700 | - if ( ( is_numeric($_type) ) && |
|
| 701 | - ( ( $_type >= 0 ) && ( $_type <= 3 ) ) ) |
|
| 700 | + if ((is_numeric($_type)) && |
|
| 701 | + (($_type >= 0) && ($_type <= 3))) |
|
| 702 | 702 | $this->_transportType = $_type; |
| 703 | 703 | } |
| 704 | 704 | |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | */ |
| 741 | 741 | function setHost($_strHost) |
| 742 | 742 | { |
| 743 | - if ( $_strHost ) |
|
| 743 | + if ($_strHost) |
|
| 744 | 744 | $this->_smtpsHost = $_strHost; |
| 745 | 745 | } |
| 746 | 746 | |
@@ -765,8 +765,8 @@ discard block |
||
| 765 | 765 | */ |
| 766 | 766 | function setPort($_intPort) |
| 767 | 767 | { |
| 768 | - if ( ( is_numeric($_intPort) ) && |
|
| 769 | - ( ( $_intPort >= 1 ) && ( $_intPort <= 65536 ) ) ) |
|
| 768 | + if ((is_numeric($_intPort)) && |
|
| 769 | + (($_intPort >= 1) && ($_intPort <= 65536))) |
|
| 770 | 770 | $this->_smtpsPort = $_intPort; |
| 771 | 771 | } |
| 772 | 772 | |
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | */ |
| 833 | 833 | function setCharSet($_strCharSet) |
| 834 | 834 | { |
| 835 | - if ( $_strCharSet ) |
|
| 835 | + if ($_strCharSet) |
|
| 836 | 836 | $this->_smtpsCharSet = $_strCharSet; |
| 837 | 837 | } |
| 838 | 838 | |
@@ -920,7 +920,7 @@ discard block |
||
| 920 | 920 | */ |
| 921 | 921 | function setFrom($_strFrom) |
| 922 | 922 | { |
| 923 | - if ( $_strFrom ) |
|
| 923 | + if ($_strFrom) |
|
| 924 | 924 | $this->_msgFrom = $this->_strip_email($_strFrom); |
| 925 | 925 | } |
| 926 | 926 | |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | { |
| 935 | 935 | $_retValue = ''; |
| 936 | 936 | |
| 937 | - if ( $_part === true ) |
|
| 937 | + if ($_part === true) |
|
| 938 | 938 | $_retValue = $this->_msgFrom; |
| 939 | 939 | else |
| 940 | 940 | $_retValue = $this->_msgFrom[$_part]; |
@@ -950,7 +950,7 @@ discard block |
||
| 950 | 950 | */ |
| 951 | 951 | function setReplyTo($_strReplyTo) |
| 952 | 952 | { |
| 953 | - if ( $_strReplyTo ) |
|
| 953 | + if ($_strReplyTo) |
|
| 954 | 954 | $this->_msgReplyTo = $this->_strip_email($_strReplyTo); |
| 955 | 955 | } |
| 956 | 956 | |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | { |
| 965 | 965 | $_retValue = ''; |
| 966 | 966 | |
| 967 | - if ( $_part === true ) |
|
| 967 | + if ($_part === true) |
|
| 968 | 968 | $_retValue = $this->_msgReplyTo; |
| 969 | 969 | else |
| 970 | 970 | $_retValue = $this->_msgReplyTo[$_part]; |
@@ -990,13 +990,13 @@ discard block |
||
| 990 | 990 | $aryHost = $this->_msgRecipients; |
| 991 | 991 | |
| 992 | 992 | // Only run this if we have something |
| 993 | - if ( !empty ($_addrList )) |
|
| 993 | + if (!empty ($_addrList)) |
|
| 994 | 994 | { |
| 995 | 995 | // $_addrList can be a STRING or an array |
| 996 | - if ( is_string($_addrList) ) |
|
| 996 | + if (is_string($_addrList)) |
|
| 997 | 997 | { |
| 998 | 998 | // This could be a COMMA delimited string |
| 999 | - if ( strstr($_addrList, ',') ) |
|
| 999 | + if (strstr($_addrList, ',')) |
|
| 1000 | 1000 | // "explode "list" into an array |
| 1001 | 1001 | $_addrList = explode(',', $_addrList); |
| 1002 | 1002 | |
@@ -1006,7 +1006,7 @@ discard block |
||
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | 1008 | // take the array of addresses and split them further |
| 1009 | - foreach ( $_addrList as $_strAddr ) |
|
| 1009 | + foreach ($_addrList as $_strAddr) |
|
| 1010 | 1010 | { |
| 1011 | 1011 | // Strip off the end '>' |
| 1012 | 1012 | $_strAddr = str_replace('>', '', $_strAddr); |
@@ -1016,7 +1016,7 @@ discard block |
||
| 1016 | 1016 | $_tmpaddr = explode('<', $_strAddr); |
| 1017 | 1017 | |
| 1018 | 1018 | // We have a "Real Name" and eMail address |
| 1019 | - if ( count($_tmpaddr) == 2 ) |
|
| 1019 | + if (count($_tmpaddr) == 2) |
|
| 1020 | 1020 | { |
| 1021 | 1021 | $_tmpHost = explode('@', $_tmpaddr[1]); |
| 1022 | 1022 | $_tmpaddr[0] = trim($_tmpaddr[0], ' ">'); |
@@ -1073,10 +1073,10 @@ discard block |
||
| 1073 | 1073 | $_tmpAry = explode('<', $_strAddr); |
| 1074 | 1074 | |
| 1075 | 1075 | // Do we have a "Real name" |
| 1076 | - if ( count($_tmpAry) == 2 ) |
|
| 1076 | + if (count($_tmpAry) == 2) |
|
| 1077 | 1077 | { |
| 1078 | 1078 | // We may not really have a "Real Name" |
| 1079 | - if ( $_tmpAry[0]) |
|
| 1079 | + if ($_tmpAry[0]) |
|
| 1080 | 1080 | $_aryEmail['real'] = trim($_tmpAry[0], ' ">'); |
| 1081 | 1081 | |
| 1082 | 1082 | $_aryEmail['addr'] = $_tmpAry[1]; |
@@ -1085,10 +1085,10 @@ discard block |
||
| 1085 | 1085 | $_aryEmail['addr'] = $_tmpAry[0]; |
| 1086 | 1086 | |
| 1087 | 1087 | // Pull User Name and Host.tld apart |
| 1088 | - list($_aryEmail['user'], $_aryEmail['host'] ) = explode('@', $_aryEmail['addr']); |
|
| 1088 | + list($_aryEmail['user'], $_aryEmail['host']) = explode('@', $_aryEmail['addr']); |
|
| 1089 | 1089 | |
| 1090 | 1090 | // Put the brackets back around the address |
| 1091 | - $_aryEmail['addr'] = '<' . $_aryEmail['addr'] . '>'; |
|
| 1091 | + $_aryEmail['addr'] = '<'.$_aryEmail['addr'].'>'; |
|
| 1092 | 1092 | |
| 1093 | 1093 | return $_aryEmail; |
| 1094 | 1094 | } |
@@ -1107,17 +1107,17 @@ discard block |
||
| 1107 | 1107 | /** |
| 1108 | 1108 | * An array of bares addresses for use with 'RCPT TO:' |
| 1109 | 1109 | */ |
| 1110 | - $_RCPT_list=array(); |
|
| 1110 | + $_RCPT_list = array(); |
|
| 1111 | 1111 | |
| 1112 | 1112 | // walk down Recipients array and pull just email addresses |
| 1113 | - foreach ( $this->_msgRecipients as $_host => $_list ) |
|
| 1113 | + foreach ($this->_msgRecipients as $_host => $_list) |
|
| 1114 | 1114 | { |
| 1115 | - foreach ( $_list as $_subList ) |
|
| 1115 | + foreach ($_list as $_subList) |
|
| 1116 | 1116 | { |
| 1117 | - foreach ( $_subList as $_name => $_addr ) |
|
| 1117 | + foreach ($_subList as $_name => $_addr) |
|
| 1118 | 1118 | { |
| 1119 | 1119 | // build RCPT list |
| 1120 | - $_RCPT_list[] = $_name . '@' . $_host; |
|
| 1120 | + $_RCPT_list[] = $_name.'@'.$_host; |
|
| 1121 | 1121 | } |
| 1122 | 1122 | } |
| 1123 | 1123 | } |
@@ -1136,27 +1136,27 @@ discard block |
||
| 1136 | 1136 | { |
| 1137 | 1137 | // phpcs:enable |
| 1138 | 1138 | // We need to know which address segment to pull |
| 1139 | - if ( $_which ) |
|
| 1139 | + if ($_which) |
|
| 1140 | 1140 | { |
| 1141 | 1141 | // Make sure we have addresses to process |
| 1142 | - if ( $this->_msgRecipients ) |
|
| 1142 | + if ($this->_msgRecipients) |
|
| 1143 | 1143 | { |
| 1144 | - $_RCPT_list=array(); |
|
| 1144 | + $_RCPT_list = array(); |
|
| 1145 | 1145 | // walk down Recipients array and pull just email addresses |
| 1146 | - foreach ( $this->_msgRecipients as $_host => $_list ) |
|
| 1146 | + foreach ($this->_msgRecipients as $_host => $_list) |
|
| 1147 | 1147 | { |
| 1148 | - if ( $this->_msgRecipients[$_host][$_which] ) |
|
| 1148 | + if ($this->_msgRecipients[$_host][$_which]) |
|
| 1149 | 1149 | { |
| 1150 | - foreach ( $this->_msgRecipients[$_host][$_which] as $_addr => $_realName ) |
|
| 1150 | + foreach ($this->_msgRecipients[$_host][$_which] as $_addr => $_realName) |
|
| 1151 | 1151 | { |
| 1152 | - if ( $_realName ) // @CHANGE LDR |
|
| 1152 | + if ($_realName) // @CHANGE LDR |
|
| 1153 | 1153 | { |
| 1154 | - $_realName = '"' . $_realName . '"'; |
|
| 1155 | - $_RCPT_list[] = $_realName . ' <' . $_addr . '@' . $_host . '>'; |
|
| 1154 | + $_realName = '"'.$_realName.'"'; |
|
| 1155 | + $_RCPT_list[] = $_realName.' <'.$_addr.'@'.$_host.'>'; |
|
| 1156 | 1156 | } |
| 1157 | 1157 | else |
| 1158 | 1158 | { |
| 1159 | - $_RCPT_list[] = $_addr . '@' . $_host; |
|
| 1159 | + $_RCPT_list[] = $_addr.'@'.$_host; |
|
| 1160 | 1160 | } |
| 1161 | 1161 | } |
| 1162 | 1162 | } |
@@ -1185,7 +1185,7 @@ discard block |
||
| 1185 | 1185 | */ |
| 1186 | 1186 | function setTO($_addrTo) |
| 1187 | 1187 | { |
| 1188 | - if ( $_addrTo ) |
|
| 1188 | + if ($_addrTo) |
|
| 1189 | 1189 | $this->_buildAddrList('to', $_addrTo); |
| 1190 | 1190 | } |
| 1191 | 1191 | |
@@ -1207,7 +1207,7 @@ discard block |
||
| 1207 | 1207 | */ |
| 1208 | 1208 | function setCC($_strCC) |
| 1209 | 1209 | { |
| 1210 | - if ( $_strCC ) |
|
| 1210 | + if ($_strCC) |
|
| 1211 | 1211 | $this->_buildAddrList('cc', $_strCC); |
| 1212 | 1212 | } |
| 1213 | 1213 | |
@@ -1229,7 +1229,7 @@ discard block |
||
| 1229 | 1229 | */ |
| 1230 | 1230 | function setBCC($_strBCC) |
| 1231 | 1231 | { |
| 1232 | - if ( $_strBCC ) |
|
| 1232 | + if ($_strBCC) |
|
| 1233 | 1233 | $this->_buildAddrList('bcc', $_strBCC); |
| 1234 | 1234 | } |
| 1235 | 1235 | |
@@ -1251,7 +1251,7 @@ discard block |
||
| 1251 | 1251 | */ |
| 1252 | 1252 | function setSubject($_strSubject = '') |
| 1253 | 1253 | { |
| 1254 | - if ( $_strSubject ) |
|
| 1254 | + if ($_strSubject) |
|
| 1255 | 1255 | $this->_msgSubject = $_strSubject; |
| 1256 | 1256 | } |
| 1257 | 1257 | |
@@ -1274,11 +1274,11 @@ discard block |
||
| 1274 | 1274 | { |
| 1275 | 1275 | global $conf; |
| 1276 | 1276 | |
| 1277 | - $_header = 'From: ' . $this->getFrom('org') . "\r\n" |
|
| 1278 | - . 'To: ' . $this->getTO() . "\r\n"; |
|
| 1277 | + $_header = 'From: '.$this->getFrom('org')."\r\n" |
|
| 1278 | + . 'To: '.$this->getTO()."\r\n"; |
|
| 1279 | 1279 | |
| 1280 | - if ( $this->getCC() ) |
|
| 1281 | - $_header .= 'Cc: ' . $this->getCC() . "\r\n"; |
|
| 1280 | + if ($this->getCC()) |
|
| 1281 | + $_header .= 'Cc: '.$this->getCC()."\r\n"; |
|
| 1282 | 1282 | |
| 1283 | 1283 | /* Note: |
| 1284 | 1284 | * BCC email addresses must be listed in the RCPT TO command list, |
@@ -1291,57 +1291,57 @@ discard block |
||
| 1291 | 1291 | $_header .= 'Bcc: ' . $this->getBCC() . "\r\n"; |
| 1292 | 1292 | */ |
| 1293 | 1293 | |
| 1294 | - $host=$this->getHost(); |
|
| 1295 | - $usetls = preg_match('@tls://@i',$host); |
|
| 1294 | + $host = $this->getHost(); |
|
| 1295 | + $usetls = preg_match('@tls://@i', $host); |
|
| 1296 | 1296 | |
| 1297 | - $host=preg_replace('@tcp://@i','',$host); // Remove prefix |
|
| 1298 | - $host=preg_replace('@ssl://@i','',$host); // Remove prefix |
|
| 1299 | - $host=preg_replace('@tls://@i','',$host); // Remove prefix |
|
| 1297 | + $host = preg_replace('@tcp://@i', '', $host); // Remove prefix |
|
| 1298 | + $host = preg_replace('@ssl://@i', '', $host); // Remove prefix |
|
| 1299 | + $host = preg_replace('@tls://@i', '', $host); // Remove prefix |
|
| 1300 | 1300 | |
| 1301 | - $host=dol_getprefix('email'); |
|
| 1301 | + $host = dol_getprefix('email'); |
|
| 1302 | 1302 | |
| 1303 | 1303 | //NOTE: Message-ID should probably contain the username of the user who sent the msg |
| 1304 | - $_header .= 'Subject: ' . $this->getSubject() . "\r\n"; |
|
| 1305 | - $_header .= 'Date: ' . date("r") . "\r\n"; |
|
| 1304 | + $_header .= 'Subject: '.$this->getSubject()."\r\n"; |
|
| 1305 | + $_header .= 'Date: '.date("r")."\r\n"; |
|
| 1306 | 1306 | |
| 1307 | 1307 | $trackid = $this->getTrackId(); |
| 1308 | 1308 | if ($trackid) |
| 1309 | 1309 | { |
| 1310 | 1310 | // References is kept in response and Message-ID is returned into In-Reply-To: |
| 1311 | - $_header .= 'Message-ID: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n"; |
|
| 1312 | - $_header .= 'References: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n"; |
|
| 1313 | - $_header .= 'X-Dolibarr-TRACKID: ' . $trackid . '@' . $host . "\r\n"; |
|
| 1311 | + $_header .= 'Message-ID: <'.time().'.SMTPs-dolibarr-'.$trackid.'@'.$host.">\r\n"; |
|
| 1312 | + $_header .= 'References: <'.time().'.SMTPs-dolibarr-'.$trackid.'@'.$host.">\r\n"; |
|
| 1313 | + $_header .= 'X-Dolibarr-TRACKID: '.$trackid.'@'.$host."\r\n"; |
|
| 1314 | 1314 | } |
| 1315 | 1315 | else |
| 1316 | 1316 | { |
| 1317 | - $_header .= 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n"; |
|
| 1317 | + $_header .= 'Message-ID: <'.time().'.SMTPs@'.$host.">\r\n"; |
|
| 1318 | 1318 | } |
| 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"; |
|
| 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"; |
|
| 1322 | 1322 | |
| 1323 | 1323 | //$_header .= |
| 1324 | 1324 | // 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n" |
| 1325 | 1325 | // 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"; |
| 1326 | 1326 | |
| 1327 | - if ( $this->getSensitivity() ) |
|
| 1328 | - $_header .= 'Sensitivity: ' . $this->getSensitivity() . "\r\n"; |
|
| 1327 | + if ($this->getSensitivity()) |
|
| 1328 | + $_header .= 'Sensitivity: '.$this->getSensitivity()."\r\n"; |
|
| 1329 | 1329 | |
| 1330 | - if ( $this->_msgPriority != 3 ) |
|
| 1330 | + if ($this->_msgPriority != 3) |
|
| 1331 | 1331 | $_header .= $this->getPriority(); |
| 1332 | 1332 | |
| 1333 | 1333 | |
| 1334 | 1334 | // @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"; |
|
| 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"; |
|
| 1341 | 1341 | |
| 1342 | - $_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n"; |
|
| 1343 | - $_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART?'MAIN_MAIL_USE_MULTI_PART':'No MAIN_MAIL_USE_MULTI_PART') . "\r\n"; |
|
| 1344 | - $_header .= 'Mime-Version: 1.0' . "\r\n"; |
|
| 1342 | + $_header .= 'X-Mailer: Dolibarr version '.DOL_VERSION.' (using SMTPs Mailer)'."\r\n"; |
|
| 1343 | + $_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART ? 'MAIN_MAIL_USE_MULTI_PART' : 'No MAIN_MAIL_USE_MULTI_PART')."\r\n"; |
|
| 1344 | + $_header .= 'Mime-Version: 1.0'."\r\n"; |
|
| 1345 | 1345 | |
| 1346 | 1346 | |
| 1347 | 1347 | return $_header; |
@@ -1358,7 +1358,7 @@ discard block |
||
| 1358 | 1358 | { |
| 1359 | 1359 | //if ( $strContent ) |
| 1360 | 1360 | //{ |
| 1361 | - if ( $strType == 'html' ) |
|
| 1361 | + if ($strType == 'html') |
|
| 1362 | 1362 | $strMimeType = 'text/html'; |
| 1363 | 1363 | else |
| 1364 | 1364 | $strMimeType = 'text/plain'; |
@@ -1370,14 +1370,14 @@ discard block |
||
| 1370 | 1370 | if ($strType == 'html') |
| 1371 | 1371 | { |
| 1372 | 1372 | // Similar code to forge a text from html is also in CMailFile.class.php |
| 1373 | - $strContentAltText = preg_replace("/<br\s*[^>]*>/"," ", $strContent); |
|
| 1373 | + $strContentAltText = preg_replace("/<br\s*[^>]*>/", " ", $strContent); |
|
| 1374 | 1374 | $strContentAltText = html_entity_decode(strip_tags($strContentAltText)); |
| 1375 | 1375 | $strContentAltText = rtrim(wordwrap($strContentAltText, 75, "\r\n")); |
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | 1378 | // Make RFC2045 Compliant |
| 1379 | 1379 | //$strContent = rtrim(chunk_split($strContent)); // Function chunck_split seems ko if not used on a base64 content |
| 1380 | - $strContent = rtrim(wordwrap($strContent, 75, "\r\n")); // TODO Using this method creates unexpected line break on text/plain content. |
|
| 1380 | + $strContent = rtrim(wordwrap($strContent, 75, "\r\n")); // TODO Using this method creates unexpected line break on text/plain content. |
|
| 1381 | 1381 | |
| 1382 | 1382 | $this->_msgContent[$strType] = array(); |
| 1383 | 1383 | |
@@ -1385,7 +1385,7 @@ discard block |
||
| 1385 | 1385 | $this->_msgContent[$strType]['data'] = $strContent; |
| 1386 | 1386 | $this->_msgContent[$strType]['dataText'] = $strContentAltText; |
| 1387 | 1387 | |
| 1388 | - if ( $this->getMD5flag() ) |
|
| 1388 | + if ($this->getMD5flag()) |
|
| 1389 | 1389 | $this->_msgContent[$strType]['md5'] = dol_hash($strContent, 3); |
| 1390 | 1390 | //} |
| 1391 | 1391 | } |
@@ -1409,49 +1409,49 @@ discard block |
||
| 1409 | 1409 | $keyCount = count($_types); |
| 1410 | 1410 | |
| 1411 | 1411 | // If we have ZERO, we have a problem |
| 1412 | - if( $keyCount === 0 ) |
|
| 1412 | + if ($keyCount === 0) |
|
| 1413 | 1413 | die ("Sorry, no content"); |
| 1414 | 1414 | |
| 1415 | 1415 | // If we have ONE, we can use the simple format |
| 1416 | - else if( $keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) |
|
| 1416 | + else if ($keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) |
|
| 1417 | 1417 | { |
| 1418 | 1418 | $_msgData = $this->_msgContent; |
| 1419 | 1419 | $_msgData = $_msgData[$_types[0]]; |
| 1420 | 1420 | |
| 1421 | - $content = 'Content-Type: ' . $_msgData['mimeType'] . '; charset="' . $this->getCharSet() . '"' . "\r\n" |
|
| 1422 | - . 'Content-Transfer-Encoding: ' . $this->getTransEncodeType() . "\r\n" |
|
| 1423 | - . 'Content-Disposition: inline' . "\r\n" |
|
| 1424 | - . 'Content-Description: Message' . "\r\n"; |
|
| 1421 | + $content = 'Content-Type: '.$_msgData['mimeType'].'; charset="'.$this->getCharSet().'"'."\r\n" |
|
| 1422 | + . 'Content-Transfer-Encoding: '.$this->getTransEncodeType()."\r\n" |
|
| 1423 | + . 'Content-Disposition: inline'."\r\n" |
|
| 1424 | + . 'Content-Description: Message'."\r\n"; |
|
| 1425 | 1425 | |
| 1426 | - if ( $this->getMD5flag() ) |
|
| 1427 | - $content .= 'Content-MD5: ' . $_msgData['md5'] . "\r\n"; |
|
| 1426 | + if ($this->getMD5flag()) |
|
| 1427 | + $content .= 'Content-MD5: '.$_msgData['md5']."\r\n"; |
|
| 1428 | 1428 | |
| 1429 | 1429 | $content .= "\r\n" |
| 1430 | - . $_msgData['data'] . "\r\n"; |
|
| 1430 | + . $_msgData['data']."\r\n"; |
|
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | 1433 | // If we have more than ONE, we use the multi-part format |
| 1434 | - else if( $keyCount >= 1 || ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) |
|
| 1434 | + else if ($keyCount >= 1 || !empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) |
|
| 1435 | 1435 | { |
| 1436 | 1436 | // Since this is an actual multi-part message |
| 1437 | 1437 | // We need to define a content message Boundary |
| 1438 | 1438 | // NOTE: This was 'multipart/alternative', but Windows based mail servers have issues with this. |
| 1439 | 1439 | |
| 1440 | 1440 | //$content = 'Content-Type: multipart/related; boundary="' . $this->_getBoundary() . '"' . "\r\n"; |
| 1441 | - $content = 'Content-Type: multipart/mixed; boundary="' . $this->_getBoundary('mixed') . '"' . "\r\n"; |
|
| 1441 | + $content = 'Content-Type: multipart/mixed; boundary="'.$this->_getBoundary('mixed').'"'."\r\n"; |
|
| 1442 | 1442 | |
| 1443 | 1443 | // . "\r\n" |
| 1444 | 1444 | // . 'This is a multi-part message in MIME format.' . "\r\n"; |
| 1445 | 1445 | $content .= "Content-Transfer-Encoding: 8bit\r\n"; |
| 1446 | 1446 | $content .= "\r\n"; |
| 1447 | 1447 | |
| 1448 | - $content .= "--" . $this->_getBoundary('mixed') . "\r\n"; |
|
| 1448 | + $content .= "--".$this->_getBoundary('mixed')."\r\n"; |
|
| 1449 | 1449 | |
| 1450 | 1450 | if (key_exists('image', $this->_msgContent)) // If inline image found |
| 1451 | 1451 | { |
| 1452 | - $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; |
|
| 1452 | + $content .= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"'."\r\n"; |
|
| 1453 | 1453 | $content .= "\r\n"; |
| 1454 | - $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; |
|
| 1454 | + $content .= "--".$this->_getBoundary('alternative')."\r\n"; |
|
| 1455 | 1455 | } |
| 1456 | 1456 | |
| 1457 | 1457 | |
@@ -1459,93 +1459,93 @@ discard block |
||
| 1459 | 1459 | |
| 1460 | 1460 | |
| 1461 | 1461 | // Loop through message content array |
| 1462 | - foreach ($this->_msgContent as $type => $_content ) |
|
| 1462 | + foreach ($this->_msgContent as $type => $_content) |
|
| 1463 | 1463 | { |
| 1464 | - if ( $type == 'attachment' ) |
|
| 1464 | + if ($type == 'attachment') |
|
| 1465 | 1465 | { |
| 1466 | 1466 | // loop through all attachments |
| 1467 | - foreach ( $_content as $_file => $_data ) |
|
| 1467 | + foreach ($_content as $_file => $_data) |
|
| 1468 | 1468 | { |
| 1469 | - $content .= "--" . $this->_getBoundary('mixed') . "\r\n" |
|
| 1470 | - . 'Content-Disposition: attachment; filename="' . $_data['fileName'] . '"' . "\r\n" |
|
| 1471 | - . 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['fileName'] . '"' . "\r\n" |
|
| 1472 | - . 'Content-Transfer-Encoding: base64' . "\r\n" |
|
| 1473 | - . 'Content-Description: ' . $_data['fileName'] ."\r\n"; |
|
| 1469 | + $content .= "--".$this->_getBoundary('mixed')."\r\n" |
|
| 1470 | + . 'Content-Disposition: attachment; filename="'.$_data['fileName'].'"'."\r\n" |
|
| 1471 | + . 'Content-Type: '.$_data['mimeType'].'; name="'.$_data['fileName'].'"'."\r\n" |
|
| 1472 | + . 'Content-Transfer-Encoding: base64'."\r\n" |
|
| 1473 | + . 'Content-Description: '.$_data['fileName']."\r\n"; |
|
| 1474 | 1474 | |
| 1475 | - if ( $this->getMD5flag() ) |
|
| 1476 | - $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; |
|
| 1475 | + if ($this->getMD5flag()) |
|
| 1476 | + $content .= 'Content-MD5: '.$_data['md5']."\r\n"; |
|
| 1477 | 1477 | |
| 1478 | - $content .= "\r\n" . $_data['data'] . "\r\n\r\n"; |
|
| 1478 | + $content .= "\r\n".$_data['data']."\r\n\r\n"; |
|
| 1479 | 1479 | } |
| 1480 | 1480 | } |
| 1481 | 1481 | // @CHANGE LDR |
| 1482 | - else if ( $type == 'image' ) |
|
| 1482 | + else if ($type == 'image') |
|
| 1483 | 1483 | { |
| 1484 | 1484 | // loop through all images |
| 1485 | - foreach ( $_content as $_image => $_data ) |
|
| 1485 | + foreach ($_content as $_image => $_data) |
|
| 1486 | 1486 | { |
| 1487 | - $content .= "--" . $this->_getBoundary('related') . "\r\n"; // always related for an inline image |
|
| 1487 | + $content .= "--".$this->_getBoundary('related')."\r\n"; // always related for an inline image |
|
| 1488 | 1488 | |
| 1489 | - $content .= 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['imageName'] . '"' . "\r\n" |
|
| 1490 | - . 'Content-Transfer-Encoding: base64' . "\r\n" |
|
| 1491 | - . 'Content-Disposition: inline; filename="' . $_data['imageName'] . '"' . "\r\n" |
|
| 1492 | - . 'Content-ID: <' . $_data['cid'] . '> ' . "\r\n"; |
|
| 1489 | + $content .= 'Content-Type: '.$_data['mimeType'].'; name="'.$_data['imageName'].'"'."\r\n" |
|
| 1490 | + . 'Content-Transfer-Encoding: base64'."\r\n" |
|
| 1491 | + . 'Content-Disposition: inline; filename="'.$_data['imageName'].'"'."\r\n" |
|
| 1492 | + . 'Content-ID: <'.$_data['cid'].'> '."\r\n"; |
|
| 1493 | 1493 | |
| 1494 | - if ( $this->getMD5flag() ) |
|
| 1495 | - $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; |
|
| 1494 | + if ($this->getMD5flag()) |
|
| 1495 | + $content .= 'Content-MD5: '.$_data['md5']."\r\n"; |
|
| 1496 | 1496 | |
| 1497 | 1497 | $content .= "\r\n" |
| 1498 | - . $_data['data'] . "\r\n"; |
|
| 1498 | + . $_data['data']."\r\n"; |
|
| 1499 | 1499 | } |
| 1500 | 1500 | |
| 1501 | 1501 | // always end related and end alternative after inline images |
| 1502 | - $content.= "--" . $this->_getBoundary('related') . "--" . "\r\n"; |
|
| 1503 | - $content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n"; |
|
| 1504 | - $content.= "\r\n"; |
|
| 1502 | + $content .= "--".$this->_getBoundary('related')."--"."\r\n"; |
|
| 1503 | + $content .= "\r\n"."--".$this->_getBoundary('alternative')."--"."\r\n"; |
|
| 1504 | + $content .= "\r\n"; |
|
| 1505 | 1505 | } |
| 1506 | 1506 | else |
| 1507 | 1507 | { |
| 1508 | 1508 | if (key_exists('image', $this->_msgContent)) |
| 1509 | 1509 | { |
| 1510 | - $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; |
|
| 1511 | - $content.= "\r\n" . ($_content['dataText']?$_content['dataText']:strip_tags($_content['data'])) . "\r\n"; // Add plain text message |
|
| 1512 | - $content.= "--" . $this->_getBoundary('alternative') . "\r\n"; |
|
| 1513 | - $content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n"; |
|
| 1514 | - $content.= "\r\n"; |
|
| 1515 | - $content.= "--" . $this->_getBoundary('related') . "\r\n"; |
|
| 1510 | + $content .= "Content-Type: text/plain; charset=".$this->getCharSet()."\r\n"; |
|
| 1511 | + $content .= "\r\n".($_content['dataText'] ? $_content['dataText'] : strip_tags($_content['data']))."\r\n"; // Add plain text message |
|
| 1512 | + $content .= "--".$this->_getBoundary('alternative')."\r\n"; |
|
| 1513 | + $content .= 'Content-Type: multipart/related; boundary="'.$this->_getBoundary('related').'"'."\r\n"; |
|
| 1514 | + $content .= "\r\n"; |
|
| 1515 | + $content .= "--".$this->_getBoundary('related')."\r\n"; |
|
| 1516 | 1516 | } |
| 1517 | 1517 | |
| 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 |
|
| 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 |
|
| 1519 | 1519 | { |
| 1520 | - $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; |
|
| 1520 | + $content .= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"'."\r\n"; |
|
| 1521 | 1521 | $content .= "\r\n"; |
| 1522 | - $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; |
|
| 1522 | + $content .= "--".$this->_getBoundary('alternative')."\r\n"; |
|
| 1523 | 1523 | |
| 1524 | - $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; |
|
| 1525 | - $content.= "\r\n". $_content['dataText'] . "\r\n"; |
|
| 1526 | - $content.= "--" . $this->_getBoundary('alternative') . "\r\n"; |
|
| 1524 | + $content .= "Content-Type: text/plain; charset=".$this->getCharSet()."\r\n"; |
|
| 1525 | + $content .= "\r\n".$_content['dataText']."\r\n"; |
|
| 1526 | + $content .= "--".$this->_getBoundary('alternative')."\r\n"; |
|
| 1527 | 1527 | } |
| 1528 | 1528 | |
| 1529 | - $content .= 'Content-Type: ' . $_content['mimeType'] . '; ' |
|
| 1529 | + $content .= 'Content-Type: '.$_content['mimeType'].'; ' |
|
| 1530 | 1530 | // . 'charset="' . $this->getCharSet() . '"'; |
| 1531 | - . 'charset=' . $this->getCharSet() . ''; |
|
| 1531 | + . 'charset='.$this->getCharSet().''; |
|
| 1532 | 1532 | |
| 1533 | 1533 | // $content .= ( $type == 'html') ? '; name="HTML Part"' : ''; |
| 1534 | - $content .= "\r\n"; |
|
| 1534 | + $content .= "\r\n"; |
|
| 1535 | 1535 | // $content .= 'Content-Transfer-Encoding: '; |
| 1536 | 1536 | // $content .= ($type == 'html') ? 'quoted-printable' : $this->getTransEncodeType(); |
| 1537 | 1537 | // $content .= "\r\n" |
| 1538 | 1538 | // . 'Content-Disposition: inline' . "\r\n" |
| 1539 | 1539 | // . 'Content-Description: ' . $type . ' message' . "\r\n"; |
| 1540 | 1540 | |
| 1541 | - if ( $this->getMD5flag() ) |
|
| 1542 | - $content .= 'Content-MD5: ' . $_content['md5'] . "\r\n"; |
|
| 1541 | + if ($this->getMD5flag()) |
|
| 1542 | + $content .= 'Content-MD5: '.$_content['md5']."\r\n"; |
|
| 1543 | 1543 | |
| 1544 | - $content .= "\r\n" . $_content['data'] . "\r\n"; |
|
| 1544 | + $content .= "\r\n".$_content['data']."\r\n"; |
|
| 1545 | 1545 | |
| 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 |
|
| 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 |
|
| 1547 | 1547 | { |
| 1548 | - $content.= "--" . $this->_getBoundary('alternative') . "--". "\r\n"; |
|
| 1548 | + $content .= "--".$this->_getBoundary('alternative')."--"."\r\n"; |
|
| 1549 | 1549 | } |
| 1550 | 1550 | |
| 1551 | 1551 | $content .= "\r\n"; |
@@ -1554,7 +1554,7 @@ discard block |
||
| 1554 | 1554 | |
| 1555 | 1555 | // Close message boundries |
| 1556 | 1556 | // $content .= "\r\n--" . $this->_getBoundary() . '--' . "\r\n" ; |
| 1557 | - $content .= "--" . $this->_getBoundary('mixed') . '--' . "\r\n" ; |
|
| 1557 | + $content .= "--".$this->_getBoundary('mixed').'--'."\r\n"; |
|
| 1558 | 1558 | } |
| 1559 | 1559 | |
| 1560 | 1560 | return $content; |
@@ -1571,15 +1571,15 @@ discard block |
||
| 1571 | 1571 | */ |
| 1572 | 1572 | function setAttachment($strContent, $strFileName = 'unknown', $strMimeType = 'unknown') |
| 1573 | 1573 | { |
| 1574 | - if ( $strContent ) |
|
| 1574 | + if ($strContent) |
|
| 1575 | 1575 | { |
| 1576 | - $strContent = rtrim(chunk_split(base64_encode($strContent), 76, "\r\n")); // 76 max is defined into http://tools.ietf.org/html/rfc2047 |
|
| 1576 | + $strContent = rtrim(chunk_split(base64_encode($strContent), 76, "\r\n")); // 76 max is defined into http://tools.ietf.org/html/rfc2047 |
|
| 1577 | 1577 | |
| 1578 | 1578 | $this->_msgContent['attachment'][$strFileName]['mimeType'] = $strMimeType; |
| 1579 | 1579 | $this->_msgContent['attachment'][$strFileName]['fileName'] = $strFileName; |
| 1580 | 1580 | $this->_msgContent['attachment'][$strFileName]['data'] = $strContent; |
| 1581 | 1581 | |
| 1582 | - if ( $this->getMD5flag() ) |
|
| 1582 | + if ($this->getMD5flag()) |
|
| 1583 | 1583 | $this->_msgContent['attachment'][$strFileName]['md5'] = dol_hash($strContent, 3); |
| 1584 | 1584 | } |
| 1585 | 1585 | } |
@@ -1606,7 +1606,7 @@ discard block |
||
| 1606 | 1606 | $this->_msgContent['image'][$strImageName]['cid'] = $strImageCid; |
| 1607 | 1607 | $this->_msgContent['image'][$strImageName]['data'] = $strContent; |
| 1608 | 1608 | |
| 1609 | - if ( $this->getMD5flag() ) |
|
| 1609 | + if ($this->getMD5flag()) |
|
| 1610 | 1610 | $this->_msgContent['image'][$strImageName]['md5'] = dol_hash($strContent, 3); |
| 1611 | 1611 | } |
| 1612 | 1612 | } |
@@ -1626,8 +1626,8 @@ discard block |
||
| 1626 | 1626 | */ |
| 1627 | 1627 | function setSensitivity($_value = 0) |
| 1628 | 1628 | { |
| 1629 | - if ( ( is_numeric($_value) ) && |
|
| 1630 | - ( ( $_value >= 0 ) && ( $_value <= 3 ) ) ) |
|
| 1629 | + if ((is_numeric($_value)) && |
|
| 1630 | + (($_value >= 0) && ($_value <= 3))) |
|
| 1631 | 1631 | $this->_msgSensitivity = $_value; |
| 1632 | 1632 | } |
| 1633 | 1633 | |
@@ -1659,10 +1659,10 @@ discard block |
||
| 1659 | 1659 | * @param integer $_value Message Priority |
| 1660 | 1660 | * @return void |
| 1661 | 1661 | */ |
| 1662 | - function setPriority( $_value = 3 ) |
|
| 1662 | + function setPriority($_value = 3) |
|
| 1663 | 1663 | { |
| 1664 | - if ( ( is_numeric($_value) ) && |
|
| 1665 | - ( ( $_value >= 0 ) && ( $_value <= 5 ) ) ) |
|
| 1664 | + if ((is_numeric($_value)) && |
|
| 1665 | + (($_value >= 0) && ($_value <= 5))) |
|
| 1666 | 1666 | $this->_msgPriority = $_value; |
| 1667 | 1667 | } |
| 1668 | 1668 | |
@@ -1680,9 +1680,9 @@ discard block |
||
| 1680 | 1680 | */ |
| 1681 | 1681 | function getPriority() |
| 1682 | 1682 | { |
| 1683 | - return 'Importance: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n" |
|
| 1684 | - . 'Priority: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n" |
|
| 1685 | - . 'X-Priority: ' . $this->_msgPriority . ' (' . $this->_aryPriority[$this->_msgPriority] . ')' . "\r\n"; |
|
| 1683 | + return 'Importance: '.$this->_aryPriority[$this->_msgPriority]."\r\n" |
|
| 1684 | + . 'Priority: '.$this->_aryPriority[$this->_msgPriority]."\r\n" |
|
| 1685 | + . 'X-Priority: '.$this->_msgPriority.' ('.$this->_aryPriority[$this->_msgPriority].')'."\r\n"; |
|
| 1686 | 1686 | } |
| 1687 | 1687 | |
| 1688 | 1688 | /** |
@@ -1716,7 +1716,7 @@ discard block |
||
| 1716 | 1716 | */ |
| 1717 | 1717 | function setXheader($strXdata) |
| 1718 | 1718 | { |
| 1719 | - if ( $strXdata ) |
|
| 1719 | + if ($strXdata) |
|
| 1720 | 1720 | $this->_msgXheader[] = $strXdata; |
| 1721 | 1721 | } |
| 1722 | 1722 | |
@@ -1737,7 +1737,7 @@ discard block |
||
| 1737 | 1737 | */ |
| 1738 | 1738 | function _setBoundary() |
| 1739 | 1739 | { |
| 1740 | - $this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary"; |
|
| 1740 | + $this->_smtpsBoundary = "multipart_x.".time().".x_boundary"; |
|
| 1741 | 1741 | $this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2"), 3); |
| 1742 | 1742 | $this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3); |
| 1743 | 1743 | } |
@@ -1748,7 +1748,7 @@ discard block |
||
| 1748 | 1748 | * @param string $type Type of boundary |
| 1749 | 1749 | * @return string $_smtpsBoundary MIME message Boundary |
| 1750 | 1750 | */ |
| 1751 | - function _getBoundary($type='mixed') |
|
| 1751 | + function _getBoundary($type = 'mixed') |
|
| 1752 | 1752 | { |
| 1753 | 1753 | if ($type == 'mixed') return $this->_smtpsBoundary; |
| 1754 | 1754 | else if ($type == 'related') return $this->_smtpsRelatedBoundary; |
@@ -1776,11 +1776,11 @@ discard block |
||
| 1776 | 1776 | $server_response = ''; |
| 1777 | 1777 | |
| 1778 | 1778 | // avoid infinite loop |
| 1779 | - $limit=0; |
|
| 1779 | + $limit = 0; |
|
| 1780 | 1780 | |
| 1781 | - while (substr($server_response,3,1) != ' ' && $limit<100) |
|
| 1781 | + while (substr($server_response, 3, 1) != ' ' && $limit < 100) |
|
| 1782 | 1782 | { |
| 1783 | - if (! ($server_response = fgets($socket, 256))) |
|
| 1783 | + if (!($server_response = fgets($socket, 256))) |
|
| 1784 | 1784 | { |
| 1785 | 1785 | $this->_setErr(121, "Couldn't get mail server response codes"); |
| 1786 | 1786 | $_retVal = false; |
@@ -1789,7 +1789,7 @@ discard block |
||
| 1789 | 1789 | $limit++; |
| 1790 | 1790 | } |
| 1791 | 1791 | |
| 1792 | - if (! (substr($server_response, 0, 3) == $response)) |
|
| 1792 | + if (!(substr($server_response, 0, 3) == $response)) |
|
| 1793 | 1793 | { |
| 1794 | 1794 | $this->_setErr(120, "Ran into problems sending Mail.\r\nResponse: $server_response"); |
| 1795 | 1795 | $_retVal = false; |
@@ -1807,14 +1807,14 @@ discard block |
||
| 1807 | 1807 | * @param string $CRLF CRLF |
| 1808 | 1808 | * @return boolean|null True or false |
| 1809 | 1809 | */ |
| 1810 | - function socket_send_str( $_strSend, $_returnCode = null, $CRLF = "\r\n" ) |
|
| 1810 | + function socket_send_str($_strSend, $_returnCode = null, $CRLF = "\r\n") |
|
| 1811 | 1811 | { |
| 1812 | 1812 | // phpcs:enable |
| 1813 | - if ($this->_debug) $this->log.=$_strSend; // @CHANGE LDR for log |
|
| 1814 | - fputs($this->socket, $_strSend . $CRLF); |
|
| 1815 | - if ($this->_debug) $this->log.=' ('.$_returnCode.')' . $CRLF; |
|
| 1813 | + if ($this->_debug) $this->log .= $_strSend; // @CHANGE LDR for log |
|
| 1814 | + fputs($this->socket, $_strSend.$CRLF); |
|
| 1815 | + if ($this->_debug) $this->log .= ' ('.$_returnCode.')'.$CRLF; |
|
| 1816 | 1816 | |
| 1817 | - if ( $_returnCode ) |
|
| 1817 | + if ($_returnCode) |
|
| 1818 | 1818 | return $this->server_parse($this->socket, $_returnCode); |
| 1819 | 1819 | } |
| 1820 | 1820 | |
@@ -1828,7 +1828,7 @@ discard block |
||
| 1828 | 1828 | * @param string $_errMsg Error Message |
| 1829 | 1829 | * @return void |
| 1830 | 1830 | */ |
| 1831 | - function _setErr( $_errNum, $_errMsg ) |
|
| 1831 | + function _setErr($_errNum, $_errMsg) |
|
| 1832 | 1832 | { |
| 1833 | 1833 | $this->_smtpsErrors[] = array( |
| 1834 | 1834 | 'num' => $_errNum, |
@@ -1847,9 +1847,9 @@ discard block |
||
| 1847 | 1847 | |
| 1848 | 1848 | if (is_array($this->_smtpsErrors)) |
| 1849 | 1849 | { |
| 1850 | - foreach ( $this->_smtpsErrors as $_err => $_info ) |
|
| 1850 | + foreach ($this->_smtpsErrors as $_err => $_info) |
|
| 1851 | 1851 | { |
| 1852 | - $_errMsg[] = 'Error [' . $_info['num'] .']: '. $_info['msg']; |
|
| 1852 | + $_errMsg[] = 'Error ['.$_info['num'].']: '.$_info['msg']; |
|
| 1853 | 1853 | } |
| 1854 | 1854 | } |
| 1855 | 1855 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @param string $type Label type (long or short) |
| 58 | 58 | * @return string|int <0 if ko, label if ok |
| 59 | 59 | */ |
| 60 | - public function getLabelOfUnit($type='long') |
|
| 60 | + public function getLabelOfUnit($type = 'long') |
|
| 61 | 61 | { |
| 62 | 62 | global $langs; |
| 63 | 63 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | $sql = 'select '.$label_type.' from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit; |
| 78 | 78 | $resql = $this->db->query($sql); |
| 79 | - if($resql && $this->db->num_rows($resql) > 0) |
|
| 79 | + if ($resql && $this->db->num_rows($resql) > 0) |
|
| 80 | 80 | { |
| 81 | 81 | $res = $this->db->fetch_array($resql); |
| 82 | 82 | $label = $res[$label_type]; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | } |
| 86 | 86 | else |
| 87 | 87 | { |
| 88 | - $this->error=$this->db->error().' sql='.$sql; |
|
| 88 | + $this->error = $this->db->error().' sql='.$sql; |
|
| 89 | 89 | dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR); |
| 90 | 90 | return -1; |
| 91 | 91 | } |