@@ -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"; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \brief File of the superclass of invoices classes (customer and supplier) |
24 | 24 | */ |
25 | 25 | |
26 | -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; |
|
26 | +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Superclass for invoices classes |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | * @param int $multicurrency Return multicurrency_amount instead of amount |
98 | 98 | * @return double Remain of amount to pay |
99 | 99 | */ |
100 | - function getRemainToPay($multicurrency=0) |
|
100 | + function getRemainToPay($multicurrency = 0) |
|
101 | 101 | { |
102 | - $alreadypaid=0; |
|
103 | - $alreadypaid+=$this->getSommePaiement($multicurrency); |
|
104 | - $alreadypaid+=$this->getSumDepositsUsed($multicurrency); |
|
105 | - $alreadypaid+=$this->getSumCreditNotesUsed($multicurrency); |
|
102 | + $alreadypaid = 0; |
|
103 | + $alreadypaid += $this->getSommePaiement($multicurrency); |
|
104 | + $alreadypaid += $this->getSumDepositsUsed($multicurrency); |
|
105 | + $alreadypaid += $this->getSumCreditNotesUsed($multicurrency); |
|
106 | 106 | return $this->total_ttc - $alreadypaid; |
107 | 107 | } |
108 | 108 | |
@@ -112,22 +112,22 @@ discard block |
||
112 | 112 | * @param int $multicurrency Return multicurrency_amount instead of amount |
113 | 113 | * @return int Amount of payment already done, <0 if KO |
114 | 114 | */ |
115 | - function getSommePaiement($multicurrency=0) |
|
115 | + function getSommePaiement($multicurrency = 0) |
|
116 | 116 | { |
117 | - $table='paiement_facture'; |
|
118 | - $field='fk_facture'; |
|
117 | + $table = 'paiement_facture'; |
|
118 | + $field = 'fk_facture'; |
|
119 | 119 | if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
120 | 120 | { |
121 | - $table='paiementfourn_facturefourn'; |
|
122 | - $field='fk_facturefourn'; |
|
121 | + $table = 'paiementfourn_facturefourn'; |
|
122 | + $field = 'fk_facturefourn'; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | $sql = 'SELECT sum(amount) as amount, sum(multicurrency_amount) as multicurrency_amount'; |
126 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$table; |
|
127 | - $sql.= ' WHERE '.$field.' = '.$this->id; |
|
126 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$table; |
|
127 | + $sql .= ' WHERE '.$field.' = '.$this->id; |
|
128 | 128 | |
129 | 129 | dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); |
130 | - $resql=$this->db->query($sql); |
|
130 | + $resql = $this->db->query($sql); |
|
131 | 131 | if ($resql) |
132 | 132 | { |
133 | 133 | $obj = $this->db->fetch_object($resql); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } |
138 | 138 | else |
139 | 139 | { |
140 | - $this->error=$this->db->lasterror(); |
|
140 | + $this->error = $this->db->lasterror(); |
|
141 | 141 | return -1; |
142 | 142 | } |
143 | 143 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @param int $multicurrency Return multicurrency_amount instead of amount |
150 | 150 | * @return int <0 if KO, Sum of deposits amount otherwise |
151 | 151 | */ |
152 | - function getSumDepositsUsed($multicurrency=0) |
|
152 | + function getSumDepositsUsed($multicurrency = 0) |
|
153 | 153 | { |
154 | 154 | if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
155 | 155 | { |
@@ -159,15 +159,15 @@ discard block |
||
159 | 159 | |
160 | 160 | require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
161 | 161 | |
162 | - $discountstatic=new DiscountAbsolute($this->db); |
|
163 | - $result=$discountstatic->getSumDepositsUsed($this, $multicurrency); |
|
162 | + $discountstatic = new DiscountAbsolute($this->db); |
|
163 | + $result = $discountstatic->getSumDepositsUsed($this, $multicurrency); |
|
164 | 164 | if ($result >= 0) |
165 | 165 | { |
166 | 166 | return $result; |
167 | 167 | } |
168 | 168 | else |
169 | 169 | { |
170 | - $this->error=$discountstatic->error; |
|
170 | + $this->error = $discountstatic->error; |
|
171 | 171 | return -1; |
172 | 172 | } |
173 | 173 | } |
@@ -178,19 +178,19 @@ discard block |
||
178 | 178 | * @param int $multicurrency Return multicurrency_amount instead of amount |
179 | 179 | * @return int <0 if KO, Sum of credit notes and deposits amount otherwise |
180 | 180 | */ |
181 | - function getSumCreditNotesUsed($multicurrency=0) |
|
181 | + function getSumCreditNotesUsed($multicurrency = 0) |
|
182 | 182 | { |
183 | 183 | require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
184 | 184 | |
185 | - $discountstatic=new DiscountAbsolute($this->db); |
|
186 | - $result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency); |
|
185 | + $discountstatic = new DiscountAbsolute($this->db); |
|
186 | + $result = $discountstatic->getSumCreditNotesUsed($this, $multicurrency); |
|
187 | 187 | if ($result >= 0) |
188 | 188 | { |
189 | 189 | return $result; |
190 | 190 | } |
191 | 191 | else |
192 | 192 | { |
193 | - $this->error=$discountstatic->error; |
|
193 | + $this->error = $discountstatic->error; |
|
194 | 194 | return -1; |
195 | 195 | } |
196 | 196 | } |
@@ -202,13 +202,13 @@ discard block |
||
202 | 202 | */ |
203 | 203 | function getListIdAvoirFromInvoice() |
204 | 204 | { |
205 | - $idarray=array(); |
|
205 | + $idarray = array(); |
|
206 | 206 | |
207 | 207 | $sql = 'SELECT rowid'; |
208 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
209 | - $sql.= ' WHERE fk_facture_source = '.$this->id; |
|
210 | - $sql.= ' AND type = 2'; |
|
211 | - $resql=$this->db->query($sql); |
|
208 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
209 | + $sql .= ' WHERE fk_facture_source = '.$this->id; |
|
210 | + $sql .= ' AND type = 2'; |
|
211 | + $resql = $this->db->query($sql); |
|
212 | 212 | if ($resql) |
213 | 213 | { |
214 | 214 | $num = $this->db->num_rows($resql); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | while ($i < $num) |
217 | 217 | { |
218 | 218 | $row = $this->db->fetch_row($resql); |
219 | - $idarray[]=$row[0]; |
|
219 | + $idarray[] = $row[0]; |
|
220 | 220 | $i++; |
221 | 221 | } |
222 | 222 | } |
@@ -233,21 +233,21 @@ discard block |
||
233 | 233 | * @param string $option filtre sur statut ('', 'validated', ...) |
234 | 234 | * @return int <0 si KO, 0 si aucune facture ne remplace, id facture sinon |
235 | 235 | */ |
236 | - function getIdReplacingInvoice($option='') |
|
236 | + function getIdReplacingInvoice($option = '') |
|
237 | 237 | { |
238 | 238 | $sql = 'SELECT rowid'; |
239 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
240 | - $sql.= ' WHERE fk_facture_source = '.$this->id; |
|
241 | - $sql.= ' AND type < 2'; |
|
242 | - if ($option == 'validated') $sql.= ' AND fk_statut = 1'; |
|
239 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
240 | + $sql .= ' WHERE fk_facture_source = '.$this->id; |
|
241 | + $sql .= ' AND type < 2'; |
|
242 | + if ($option == 'validated') $sql .= ' AND fk_statut = 1'; |
|
243 | 243 | // PROTECTION BAD DATA |
244 | 244 | // Au cas ou base corrompue et qu'il y a une facture de remplacement validee |
245 | 245 | // et une autre non, on donne priorite a la validee. |
246 | 246 | // Ne devrait pas arriver (sauf si acces concurrentiel et que 2 personnes |
247 | 247 | // ont cree en meme temps une facture de remplacement pour la meme facture) |
248 | - $sql.= ' ORDER BY fk_statut DESC'; |
|
248 | + $sql .= ' ORDER BY fk_statut DESC'; |
|
249 | 249 | |
250 | - $resql=$this->db->query($sql); |
|
250 | + $resql = $this->db->query($sql); |
|
251 | 251 | if ($resql) |
252 | 252 | { |
253 | 253 | $obj = $this->db->fetch_object($resql); |
@@ -274,43 +274,43 @@ discard block |
||
274 | 274 | * @param string $filtertype 1 to filter on type of payment == 'PRE' |
275 | 275 | * @return array Array with list of payments |
276 | 276 | */ |
277 | - function getListOfPayments($filtertype='') |
|
277 | + function getListOfPayments($filtertype = '') |
|
278 | 278 | { |
279 | - $retarray=array(); |
|
279 | + $retarray = array(); |
|
280 | 280 | |
281 | - $table='paiement_facture'; |
|
282 | - $table2='paiement'; |
|
283 | - $field='fk_facture'; |
|
284 | - $field2='fk_paiement'; |
|
285 | - $sharedentity='facture'; |
|
281 | + $table = 'paiement_facture'; |
|
282 | + $table2 = 'paiement'; |
|
283 | + $field = 'fk_facture'; |
|
284 | + $field2 = 'fk_paiement'; |
|
285 | + $sharedentity = 'facture'; |
|
286 | 286 | if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
287 | 287 | { |
288 | - $table='paiementfourn_facturefourn'; |
|
289 | - $table2='paiementfourn'; |
|
290 | - $field='fk_facturefourn'; |
|
291 | - $field2='fk_paiementfourn'; |
|
292 | - $sharedentity='facture_fourn'; |
|
288 | + $table = 'paiementfourn_facturefourn'; |
|
289 | + $table2 = 'paiementfourn'; |
|
290 | + $field = 'fk_facturefourn'; |
|
291 | + $field2 = 'fk_paiementfourn'; |
|
292 | + $sharedentity = 'facture_fourn'; |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | $sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'; |
296 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; |
|
297 | - $sql.= ' WHERE pf.'.$field.' = '.$this->id; |
|
296 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; |
|
297 | + $sql .= ' WHERE pf.'.$field.' = '.$this->id; |
|
298 | 298 | //$sql.= ' WHERE pf.'.$field.' = 1'; |
299 | - $sql.= ' AND pf.'.$field2.' = p.rowid'; |
|
300 | - $sql.= ' AND p.fk_paiement = t.id'; |
|
301 | - $sql.= ' AND p.entity IN (' . getEntity($sharedentity).')'; |
|
302 | - if ($filtertype) $sql.=" AND t.code='PRE'"; |
|
299 | + $sql .= ' AND pf.'.$field2.' = p.rowid'; |
|
300 | + $sql .= ' AND p.fk_paiement = t.id'; |
|
301 | + $sql .= ' AND p.entity IN ('.getEntity($sharedentity).')'; |
|
302 | + if ($filtertype) $sql .= " AND t.code='PRE'"; |
|
303 | 303 | |
304 | 304 | dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG); |
305 | - $resql=$this->db->query($sql); |
|
305 | + $resql = $this->db->query($sql); |
|
306 | 306 | if ($resql) |
307 | 307 | { |
308 | 308 | $num = $this->db->num_rows($resql); |
309 | - $i=0; |
|
309 | + $i = 0; |
|
310 | 310 | while ($i < $num) |
311 | 311 | { |
312 | 312 | $obj = $this->db->fetch_object($resql); |
313 | - $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); |
|
313 | + $retarray[] = array('amount'=>$obj->amount, 'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); |
|
314 | 314 | $i++; |
315 | 315 | } |
316 | 316 | $this->db->free($resql); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | } |
319 | 319 | else |
320 | 320 | { |
321 | - $this->error=$this->db->lasterror(); |
|
321 | + $this->error = $this->db->lasterror(); |
|
322 | 322 | dol_print_error($this->db); |
323 | 323 | return array(); |
324 | 324 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | return 1; |
353 | 353 | } |
354 | 354 | |
355 | - if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0; |
|
355 | + if (!empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0; |
|
356 | 356 | |
357 | 357 | // If not a draft invoice and not temporary invoice |
358 | 358 | if ($tmppart !== 'PROV') |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | // Get last number of validated invoice |
364 | 364 | if ($this->element != 'invoice_supplier') |
365 | 365 | { |
366 | - if (empty($this->thirdparty)) $this->fetch_thirdparty(); // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag). |
|
367 | - $maxref = $this->getNextNumRef($this->thirdparty,'last'); |
|
366 | + if (empty($this->thirdparty)) $this->fetch_thirdparty(); // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag). |
|
367 | + $maxref = $this->getNextNumRef($this->thirdparty, 'last'); |
|
368 | 368 | |
369 | 369 | // If there is no invoice into the reset range and not already dispatched, we can delete |
370 | 370 | // If invoice to delete is last one and not already dispatched, we can delete |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | if ($this->situation_cycle_ref && method_exists($this, 'is_last_in_cycle')) |
377 | 377 | { |
378 | 378 | $last = $this->is_last_in_cycle(); |
379 | - if (! $last) return -3; |
|
379 | + if (!$last) return -3; |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | } |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); |
436 | 436 | elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); |
437 | 437 | elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); |
438 | - elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. |
|
438 | + elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. |
|
439 | 439 | elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); |
440 | 440 | return $langs->trans("Unknown"); |
441 | 441 | } |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) |
448 | 448 | * @return string Label of status |
449 | 449 | */ |
450 | - function getLibStatut($mode=0, $alreadypaid=-1) |
|
450 | + function getLibStatut($mode = 0, $alreadypaid = -1) |
|
451 | 451 | { |
452 | 452 | return $this->LibStatut($this->paye, $this->statut, $mode, $alreadypaid, $this->type); |
453 | 453 | } |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | * @param int $type Type invoice |
464 | 464 | * @return string Label of status |
465 | 465 | */ |
466 | - function LibStatut($paye, $status, $mode=0, $alreadypaid=-1, $type=0) |
|
466 | + function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = 0) |
|
467 | 467 | { |
468 | 468 | // phpcs:enable |
469 | 469 | global $langs; |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | //print "$paye,$status,$mode,$alreadypaid,$type"; |
473 | 473 | if ($mode == 0) |
474 | 474 | { |
475 | - $prefix=''; |
|
476 | - if (! $paye) |
|
475 | + $prefix = ''; |
|
476 | + if (!$paye) |
|
477 | 477 | { |
478 | 478 | if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
479 | 479 | elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); |
@@ -483,15 +483,15 @@ discard block |
||
483 | 483 | } |
484 | 484 | else |
485 | 485 | { |
486 | - if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note |
|
487 | - elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice |
|
486 | + if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note |
|
487 | + elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice |
|
488 | 488 | else return $langs->trans('Bill'.$prefix.'StatusPaid'); |
489 | 489 | } |
490 | 490 | } |
491 | 491 | elseif ($mode == 1) |
492 | 492 | { |
493 | - $prefix='Short'; |
|
494 | - if (! $paye) |
|
493 | + $prefix = 'Short'; |
|
494 | + if (!$paye) |
|
495 | 495 | { |
496 | 496 | if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
497 | 497 | elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled'); |
@@ -508,79 +508,79 @@ discard block |
||
508 | 508 | } |
509 | 509 | elseif ($mode == 2) |
510 | 510 | { |
511 | - $prefix='Short'; |
|
512 | - if (! $paye) |
|
511 | + $prefix = 'Short'; |
|
512 | + if (!$paye) |
|
513 | 513 | { |
514 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); |
|
515 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
516 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
517 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
518 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); |
|
514 | + if ($status == 0) return img_picto($langs->trans('BillStatusDraft'), 'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); |
|
515 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'), 'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
516 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
517 | + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'), 'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
518 | + else return img_picto($langs->trans('BillStatusStarted'), 'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); |
|
519 | 519 | } |
520 | 520 | else |
521 | 521 | { |
522 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
523 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted'); |
|
524 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid'); |
|
522 | + if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
523 | + elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'), 'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted'); |
|
524 | + else return img_picto($langs->trans('BillStatusPaid'), 'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid'); |
|
525 | 525 | } |
526 | 526 | } |
527 | 527 | elseif ($mode == 3) |
528 | 528 | { |
529 | - $prefix='Short'; |
|
530 | - if (! $paye) |
|
529 | + $prefix = 'Short'; |
|
530 | + if (!$paye) |
|
531 | 531 | { |
532 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
533 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
534 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
535 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
536 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
532 | + if ($status == 0) return img_picto($langs->trans('BillStatusDraft'), 'statut0'); |
|
533 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'), 'statut5'); |
|
534 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9'); |
|
535 | + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'), 'statut1'); |
|
536 | + else return img_picto($langs->trans('BillStatusStarted'), 'statut3'); |
|
537 | 537 | } |
538 | 538 | else |
539 | 539 | { |
540 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
541 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
542 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
540 | + if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6'); |
|
541 | + elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'), 'statut6'); |
|
542 | + else return img_picto($langs->trans('BillStatusPaid'), 'statut6'); |
|
543 | 543 | } |
544 | 544 | } |
545 | 545 | elseif ($mode == 4) |
546 | 546 | { |
547 | - $prefix=''; |
|
548 | - if (! $paye) |
|
547 | + $prefix = ''; |
|
548 | + if (!$paye) |
|
549 | 549 | { |
550 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft'); |
|
551 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
552 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
553 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid'); |
|
554 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted'); |
|
550 | + if ($status == 0) return img_picto($langs->trans('BillStatusDraft'), 'statut0').' '.$langs->trans('BillStatusDraft'); |
|
551 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'), 'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
552 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
553 | + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'), 'statut1').' '.$langs->trans('BillStatusNotPaid'); |
|
554 | + else return img_picto($langs->trans('BillStatusStarted'), 'statut3').' '.$langs->trans('BillStatusStarted'); |
|
555 | 555 | } |
556 | 556 | else |
557 | 557 | { |
558 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted'); |
|
559 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted'); |
|
560 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid'); |
|
558 | + if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted'); |
|
559 | + elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'), 'statut6').' '.$langs->trans('BillStatusConverted'); |
|
560 | + else return img_picto($langs->trans('BillStatusPaid'), 'statut6').' '.$langs->trans('BillStatusPaid'); |
|
561 | 561 | } |
562 | 562 | } |
563 | 563 | elseif ($mode == 5 || $mode == 6) |
564 | 564 | { |
565 | - $prefix=''; |
|
566 | - if ($mode == 5) $prefix='Short'; |
|
567 | - if (! $paye) |
|
565 | + $prefix = ''; |
|
566 | + if ($mode == 5) $prefix = 'Short'; |
|
567 | + if (!$paye) |
|
568 | 568 | { |
569 | - if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
570 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
571 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
569 | + if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'), 'statut0'); |
|
570 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'), 'statut5'); |
|
571 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9'); |
|
572 | 572 | elseif ($alreadypaid <= 0) |
573 | 573 | { |
574 | - if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1'); |
|
575 | - return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
574 | + if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'), 'statut1'); |
|
575 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'), 'statut1'); |
|
576 | 576 | } |
577 | - else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
577 | + else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'), 'statut3'); |
|
578 | 578 | } |
579 | 579 | else |
580 | 580 | { |
581 | - if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
582 | - elseif ($type == self::TYPE_DEPOSIT) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
583 | - else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
581 | + if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6'); |
|
582 | + elseif ($type == self::TYPE_DEPOSIT) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'), 'statut6'); |
|
583 | + else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'), 'statut6'); |
|
584 | 584 | } |
585 | 585 | } |
586 | 586 | } |
@@ -593,26 +593,26 @@ discard block |
||
593 | 593 | * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. |
594 | 594 | * @return date Date limite de reglement si ok, <0 si ko |
595 | 595 | */ |
596 | - function calculate_date_lim_reglement($cond_reglement=0) |
|
596 | + function calculate_date_lim_reglement($cond_reglement = 0) |
|
597 | 597 | { |
598 | 598 | // phpcs:enable |
599 | - if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code; |
|
600 | - if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id; |
|
599 | + if (!$cond_reglement) $cond_reglement = $this->cond_reglement_code; |
|
600 | + if (!$cond_reglement) $cond_reglement = $this->cond_reglement_id; |
|
601 | 601 | |
602 | - $cdr_nbjour=0; |
|
603 | - $cdr_type=0; |
|
604 | - $cdr_decalage=0; |
|
602 | + $cdr_nbjour = 0; |
|
603 | + $cdr_type = 0; |
|
604 | + $cdr_decalage = 0; |
|
605 | 605 | |
606 | 606 | $sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage'; |
607 | - $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; |
|
608 | - if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement; |
|
607 | + $sqltemp .= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; |
|
608 | + if (is_numeric($cond_reglement)) $sqltemp .= " WHERE c.rowid=".$cond_reglement; |
|
609 | 609 | else { |
610 | - $sqltemp.= " WHERE c.entity IN (".getEntity('c_payment_term').")"; |
|
611 | - $sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'"; |
|
610 | + $sqltemp .= " WHERE c.entity IN (".getEntity('c_payment_term').")"; |
|
611 | + $sqltemp .= " AND c.code='".$this->db->escape($cond_reglement)."'"; |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | dol_syslog(get_class($this).'::calculate_date_lim_reglement', LOG_DEBUG); |
615 | - $resqltemp=$this->db->query($sqltemp); |
|
615 | + $resqltemp = $this->db->query($sqltemp); |
|
616 | 616 | if ($resqltemp) |
617 | 617 | { |
618 | 618 | if ($this->db->num_rows($resqltemp)) |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | } |
626 | 626 | else |
627 | 627 | { |
628 | - $this->error=$this->db->error(); |
|
628 | + $this->error = $this->db->error(); |
|
629 | 629 | return -1; |
630 | 630 | } |
631 | 631 | $this->db->free($resqltemp); |
@@ -644,8 +644,8 @@ discard block |
||
644 | 644 | { |
645 | 645 | $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
646 | 646 | |
647 | - $mois=date('m', $datelim); |
|
648 | - $annee=date('Y', $datelim); |
|
647 | + $mois = date('m', $datelim); |
|
648 | + $annee = date('Y', $datelim); |
|
649 | 649 | if ($mois == 12) |
650 | 650 | { |
651 | 651 | $mois = 1; |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | $mois += 1; |
657 | 657 | } |
658 | 658 | // On se deplace au debut du mois suivant, et on retire un jour |
659 | - $datelim=dol_mktime(12,0,0,$mois,1,$annee); |
|
659 | + $datelim = dol_mktime(12, 0, 0, $mois, 1, $annee); |
|
660 | 660 | $datelim -= (3600 * 24); |
661 | 661 | |
662 | 662 | $datelim += ($cdr_decalage * 3600 * 24); |
@@ -666,9 +666,9 @@ discard block |
||
666 | 666 | { |
667 | 667 | $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
668 | 668 | |
669 | - $date_piece = dol_mktime(0, 0, 0, date('m', $datelim),date('d', $datelim),date('Y', $datelim)); // Sans les heures minutes et secondes |
|
669 | + $date_piece = dol_mktime(0, 0, 0, date('m', $datelim), date('d', $datelim), date('Y', $datelim)); // Sans les heures minutes et secondes |
|
670 | 670 | $date_lim_current = dol_mktime(0, 0, 0, date('m', $datelim), $cdr_decalage, date('Y', $datelim)); // Sans les heures minutes et secondes |
671 | - $date_lim_next = dol_time_plus_duree($date_lim_current, 1, 'm'); // Add 1 month |
|
671 | + $date_lim_next = dol_time_plus_duree($date_lim_current, 1, 'm'); // Add 1 month |
|
672 | 672 | |
673 | 673 | $diff = $date_piece - $date_lim_current; |
674 | 674 | |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | |
684 | 684 | |
685 | 685 | |
686 | -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php'; |
|
686 | +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; |
|
687 | 687 | |
688 | 688 | /** |
689 | 689 | * Parent class of all other business classes for details of elements (invoices, contracts, proposals, orders, ...) |
@@ -24,17 +24,17 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * @var string ID to identify managed object |
26 | 26 | */ |
27 | - public $element='comment'; |
|
27 | + public $element = 'comment'; |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @var string Name of table without prefix where object is stored |
31 | 31 | */ |
32 | - public $table_element='comment'; |
|
32 | + public $table_element = 'comment'; |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * @var int Field with ID of parent key if this field has a parent |
36 | 36 | */ |
37 | - public $fk_element =''; |
|
37 | + public $fk_element = ''; |
|
38 | 38 | |
39 | 39 | public $element_type; |
40 | 40 | |
@@ -82,30 +82,30 @@ discard block |
||
82 | 82 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
83 | 83 | * @return int <0 if KO, Id of created object if OK |
84 | 84 | */ |
85 | - function create($user, $notrigger=0) |
|
85 | + function create($user, $notrigger = 0) |
|
86 | 86 | { |
87 | 87 | global $conf, $langs; |
88 | 88 | |
89 | - $error=0; |
|
89 | + $error = 0; |
|
90 | 90 | |
91 | 91 | // Insert request |
92 | 92 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."comment ("; |
93 | - $sql.= "description"; |
|
94 | - $sql.= ", datec"; |
|
95 | - $sql.= ", fk_element"; |
|
96 | - $sql.= ", element_type"; |
|
97 | - $sql.= ", fk_user_author"; |
|
98 | - $sql.= ", entity"; |
|
99 | - $sql.= ", import_key"; |
|
100 | - $sql.= ") VALUES ("; |
|
101 | - $sql.= "'".$this->db->escape($this->description)."'"; |
|
102 | - $sql.= ", ".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null'); |
|
103 | - $sql.= ", '".(isset($this->fk_element)?$this->fk_element:"null")."'"; |
|
104 | - $sql.= ", '".$this->db->escape($this->element_type)."'"; |
|
105 | - $sql.= ", '".(isset($this->fk_user_author)?$this->fk_user_author:"null")."'"; |
|
106 | - $sql.= ", ".(!empty($this->entity)?$this->entity:'1'); |
|
107 | - $sql.= ", ".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
108 | - $sql.= ")"; |
|
93 | + $sql .= "description"; |
|
94 | + $sql .= ", datec"; |
|
95 | + $sql .= ", fk_element"; |
|
96 | + $sql .= ", element_type"; |
|
97 | + $sql .= ", fk_user_author"; |
|
98 | + $sql .= ", entity"; |
|
99 | + $sql .= ", import_key"; |
|
100 | + $sql .= ") VALUES ("; |
|
101 | + $sql .= "'".$this->db->escape($this->description)."'"; |
|
102 | + $sql .= ", ".($this->datec != '' ? "'".$this->db->idate($this->datec)."'" : 'null'); |
|
103 | + $sql .= ", '".(isset($this->fk_element) ? $this->fk_element : "null")."'"; |
|
104 | + $sql .= ", '".$this->db->escape($this->element_type)."'"; |
|
105 | + $sql .= ", '".(isset($this->fk_user_author) ? $this->fk_user_author : "null")."'"; |
|
106 | + $sql .= ", ".(!empty($this->entity) ? $this->entity : '1'); |
|
107 | + $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); |
|
108 | + $sql .= ")"; |
|
109 | 109 | |
110 | 110 | //var_dump($this->db); |
111 | 111 | //echo $sql; |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | $this->db->begin(); |
114 | 114 | |
115 | 115 | dol_syslog(get_class($this)."::create", LOG_DEBUG); |
116 | - $resql=$this->db->query($sql); |
|
117 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
116 | + $resql = $this->db->query($sql); |
|
117 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
118 | 118 | |
119 | - if (! $error) |
|
119 | + if (!$error) |
|
120 | 120 | { |
121 | 121 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_comment"); |
122 | 122 | |
123 | - if (! $notrigger) |
|
123 | + if (!$notrigger) |
|
124 | 124 | { |
125 | 125 | // Call trigger |
126 | - $result=$this->call_trigger('TASK_COMMENT_CREATE',$user); |
|
126 | + $result = $this->call_trigger('TASK_COMMENT_CREATE', $user); |
|
127 | 127 | if ($result < 0) { $error++; } |
128 | 128 | // End call triggers |
129 | 129 | } |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | // Commit or rollback |
133 | 133 | if ($error) |
134 | 134 | { |
135 | - foreach($this->errors as $errmsg) |
|
135 | + foreach ($this->errors as $errmsg) |
|
136 | 136 | { |
137 | 137 | dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); |
138 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
138 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
139 | 139 | } |
140 | 140 | $this->db->rollback(); |
141 | - return -1*$error; |
|
141 | + return -1 * $error; |
|
142 | 142 | } |
143 | 143 | else |
144 | 144 | { |
@@ -155,25 +155,25 @@ discard block |
||
155 | 155 | * @param int $ref ref object |
156 | 156 | * @return int <0 if KO, 0 if not found, >0 if OK |
157 | 157 | */ |
158 | - function fetch($id, $ref='') |
|
158 | + function fetch($id, $ref = '') |
|
159 | 159 | { |
160 | 160 | global $langs; |
161 | 161 | |
162 | 162 | $sql = "SELECT"; |
163 | - $sql.= " c.rowid,"; |
|
164 | - $sql.= " c.description,"; |
|
165 | - $sql.= " c.datec,"; |
|
166 | - $sql.= " c.tms,"; |
|
167 | - $sql.= " c.fk_element,"; |
|
168 | - $sql.= " c.element_type,"; |
|
169 | - $sql.= " c.fk_user_author,"; |
|
170 | - $sql.= " c.entity,"; |
|
171 | - $sql.= " c.import_key"; |
|
172 | - $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
173 | - $sql.= " WHERE c.rowid = ".$id; |
|
163 | + $sql .= " c.rowid,"; |
|
164 | + $sql .= " c.description,"; |
|
165 | + $sql .= " c.datec,"; |
|
166 | + $sql .= " c.tms,"; |
|
167 | + $sql .= " c.fk_element,"; |
|
168 | + $sql .= " c.element_type,"; |
|
169 | + $sql .= " c.fk_user_author,"; |
|
170 | + $sql .= " c.entity,"; |
|
171 | + $sql .= " c.import_key"; |
|
172 | + $sql .= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
173 | + $sql .= " WHERE c.rowid = ".$id; |
|
174 | 174 | |
175 | 175 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
176 | - $resql=$this->db->query($sql); |
|
176 | + $resql = $this->db->query($sql); |
|
177 | 177 | if ($resql) |
178 | 178 | { |
179 | 179 | $num_rows = $this->db->num_rows($resql); |
@@ -182,14 +182,14 @@ discard block |
||
182 | 182 | { |
183 | 183 | $obj = $this->db->fetch_object($resql); |
184 | 184 | |
185 | - $this->id = $obj->rowid; |
|
186 | - $this->description = $obj->description; |
|
187 | - $this->element_type = $obj->element_type; |
|
188 | - $this->datec = $this->db->jdate($obj->datec); |
|
189 | - $this->tms = $obj->tms; |
|
190 | - $this->fk_user_author = $obj->fk_user_author; |
|
185 | + $this->id = $obj->rowid; |
|
186 | + $this->description = $obj->description; |
|
187 | + $this->element_type = $obj->element_type; |
|
188 | + $this->datec = $this->db->jdate($obj->datec); |
|
189 | + $this->tms = $obj->tms; |
|
190 | + $this->fk_user_author = $obj->fk_user_author; |
|
191 | 191 | $this->fk_element = $obj->fk_element; |
192 | - $this->entity = $obj->entity; |
|
192 | + $this->entity = $obj->entity; |
|
193 | 193 | $this->import_key = $obj->import_key; |
194 | 194 | } |
195 | 195 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | } |
201 | 201 | else |
202 | 202 | { |
203 | - $this->error="Error ".$this->db->lasterror(); |
|
203 | + $this->error = "Error ".$this->db->lasterror(); |
|
204 | 204 | return -1; |
205 | 205 | } |
206 | 206 | } |
@@ -213,40 +213,40 @@ discard block |
||
213 | 213 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
214 | 214 | * @return int <=0 if KO, >0 if OK |
215 | 215 | */ |
216 | - function update(User $user, $notrigger=0) |
|
216 | + function update(User $user, $notrigger = 0) |
|
217 | 217 | { |
218 | 218 | global $conf, $langs; |
219 | - $error=0; |
|
219 | + $error = 0; |
|
220 | 220 | |
221 | 221 | // Clean parameters |
222 | - if (isset($this->fk_element)) $this->fk_project=(int) trim($this->fk_element); |
|
223 | - if (isset($this->fk_user_author)) $this->fk_user_author=(int) trim($this->fk_user_author); |
|
224 | - if (isset($this->description)) $this->description=trim($this->description); |
|
222 | + if (isset($this->fk_element)) $this->fk_project = (int) trim($this->fk_element); |
|
223 | + if (isset($this->fk_user_author)) $this->fk_user_author = (int) trim($this->fk_user_author); |
|
224 | + if (isset($this->description)) $this->description = trim($this->description); |
|
225 | 225 | |
226 | 226 | |
227 | 227 | // Update request |
228 | 228 | $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_comment SET"; |
229 | - $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; |
|
230 | - $sql.= " datec=".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null').","; |
|
231 | - $sql.= " fk_element=".(isset($this->fk_element)?$this->fk_element:"null").","; |
|
232 | - $sql.= " element_type='".$this->db->escape($this->element_type)."',"; |
|
233 | - $sql.= " fk_user_author=".(isset($this->fk_user_author)?$this->fk_user_author:"null").","; |
|
234 | - $sql.= " entity=".(!empty($this->entity)?$this->entity:'1').","; |
|
235 | - $sql.= " import_key=".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
236 | - $sql.= " WHERE rowid=".$this->id; |
|
229 | + $sql .= " description=".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").","; |
|
230 | + $sql .= " datec=".($this->datec != '' ? "'".$this->db->idate($this->datec)."'" : 'null').","; |
|
231 | + $sql .= " fk_element=".(isset($this->fk_element) ? $this->fk_element : "null").","; |
|
232 | + $sql .= " element_type='".$this->db->escape($this->element_type)."',"; |
|
233 | + $sql .= " fk_user_author=".(isset($this->fk_user_author) ? $this->fk_user_author : "null").","; |
|
234 | + $sql .= " entity=".(!empty($this->entity) ? $this->entity : '1').","; |
|
235 | + $sql .= " import_key=".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); |
|
236 | + $sql .= " WHERE rowid=".$this->id; |
|
237 | 237 | |
238 | 238 | $this->db->begin(); |
239 | 239 | |
240 | 240 | dol_syslog(get_class($this)."::update", LOG_DEBUG); |
241 | 241 | $resql = $this->db->query($sql); |
242 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
242 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
243 | 243 | |
244 | - if (! $error) |
|
244 | + if (!$error) |
|
245 | 245 | { |
246 | - if (! $notrigger) |
|
246 | + if (!$notrigger) |
|
247 | 247 | { |
248 | 248 | // Call trigger |
249 | - $result=$this->call_trigger('TASK_COMMENT_MODIFY',$user); |
|
249 | + $result = $this->call_trigger('TASK_COMMENT_MODIFY', $user); |
|
250 | 250 | if ($result < 0) { $error++; } |
251 | 251 | // End call triggers |
252 | 252 | } |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | // Commit or rollback |
256 | 256 | if ($error) |
257 | 257 | { |
258 | - foreach($this->errors as $errmsg) |
|
258 | + foreach ($this->errors as $errmsg) |
|
259 | 259 | { |
260 | 260 | dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
261 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
261 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
262 | 262 | } |
263 | 263 | $this->db->rollback(); |
264 | - return -1*$error; |
|
264 | + return -1 * $error; |
|
265 | 265 | } |
266 | 266 | else |
267 | 267 | { |
@@ -278,27 +278,27 @@ discard block |
||
278 | 278 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
279 | 279 | * @return int <0 if KO, >0 if OK |
280 | 280 | */ |
281 | - function delete($user, $notrigger=0) |
|
281 | + function delete($user, $notrigger = 0) |
|
282 | 282 | { |
283 | 283 | global $conf, $langs; |
284 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
284 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
285 | 285 | |
286 | - $error=0; |
|
286 | + $error = 0; |
|
287 | 287 | |
288 | 288 | $this->db->begin(); |
289 | 289 | |
290 | 290 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."comment"; |
291 | - $sql.= " WHERE rowid=".$this->id; |
|
291 | + $sql .= " WHERE rowid=".$this->id; |
|
292 | 292 | |
293 | 293 | $resql = $this->db->query($sql); |
294 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
294 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
295 | 295 | |
296 | - if (! $error) |
|
296 | + if (!$error) |
|
297 | 297 | { |
298 | - if (! $notrigger) |
|
298 | + if (!$notrigger) |
|
299 | 299 | { |
300 | 300 | // Call trigger |
301 | - $result=$this->call_trigger('TASK_COMMENT_DELETE',$user); |
|
301 | + $result = $this->call_trigger('TASK_COMMENT_DELETE', $user); |
|
302 | 302 | if ($result < 0) { $error++; } |
303 | 303 | // End call triggers |
304 | 304 | } |
@@ -307,14 +307,14 @@ discard block |
||
307 | 307 | // Commit or rollback |
308 | 308 | if ($error) |
309 | 309 | { |
310 | - foreach($this->errors as $errmsg) |
|
310 | + foreach ($this->errors as $errmsg) |
|
311 | 311 | { |
312 | 312 | dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
313 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
313 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
314 | 314 | } |
315 | 315 | $this->db->rollback(); |
316 | - return -1*$error; |
|
317 | - }else{ |
|
316 | + return -1 * $error; |
|
317 | + } else { |
|
318 | 318 | $this->db->commit(); |
319 | 319 | return 1; |
320 | 320 | } |
@@ -330,25 +330,25 @@ discard block |
||
330 | 330 | */ |
331 | 331 | public function fetchAllFor($element_type, $fk_element) |
332 | 332 | { |
333 | - global $db,$conf; |
|
333 | + global $db, $conf; |
|
334 | 334 | $this->comments = array(); |
335 | - if(!empty($element_type) && !empty($fk_element)) { |
|
335 | + if (!empty($element_type) && !empty($fk_element)) { |
|
336 | 336 | $sql = "SELECT"; |
337 | - $sql.= " c.rowid"; |
|
338 | - $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
339 | - $sql.= " WHERE c.fk_element = ".$fk_element; |
|
340 | - $sql.= " AND c.element_type = '".$db->escape($element_type)."'"; |
|
341 | - $sql.= " AND c.entity = ".$conf->entity; |
|
342 | - $sql.= " ORDER BY c.tms DESC"; |
|
337 | + $sql .= " c.rowid"; |
|
338 | + $sql .= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
339 | + $sql .= " WHERE c.fk_element = ".$fk_element; |
|
340 | + $sql .= " AND c.element_type = '".$db->escape($element_type)."'"; |
|
341 | + $sql .= " AND c.entity = ".$conf->entity; |
|
342 | + $sql .= " ORDER BY c.tms DESC"; |
|
343 | 343 | |
344 | 344 | dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); |
345 | - $resql=$db->query($sql); |
|
345 | + $resql = $db->query($sql); |
|
346 | 346 | if ($resql) |
347 | 347 | { |
348 | 348 | $num_rows = $db->num_rows($resql); |
349 | 349 | if ($num_rows > 0) |
350 | 350 | { |
351 | - while($obj = $db->fetch_object($resql)) |
|
351 | + while ($obj = $db->fetch_object($resql)) |
|
352 | 352 | { |
353 | 353 | $comment = new self($db); |
354 | 354 | $comment->fetch($obj->rowid); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | } |
358 | 358 | $db->free($resql); |
359 | 359 | } else { |
360 | - $this->errors[]="Error ".$this->db->lasterror(); |
|
360 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
361 | 361 | return -1; |
362 | 362 | } |
363 | 363 | } |
@@ -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; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | /** |
37 | 37 | * @var string Error code (or message) |
38 | 38 | */ |
39 | - public $error=''; |
|
39 | + public $error = ''; |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Constructor |
@@ -58,43 +58,43 @@ discard block |
||
58 | 58 | * @param integer $readonly Select is read only or not |
59 | 59 | * @return string HTML select field |
60 | 60 | */ |
61 | - function select_typejob($htmlname,$selected=0,$readonly=0) |
|
61 | + function select_typejob($htmlname, $selected = 0, $readonly = 0) |
|
62 | 62 | { |
63 | 63 | // phpcs:enable |
64 | 64 | global $langs; |
65 | 65 | |
66 | 66 | $langs->load('cron@cron'); |
67 | 67 | if (!empty($readonly)) { |
68 | - if ($selected=='command') { |
|
69 | - $out= $langs->trans('CronType_command'); |
|
70 | - $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
71 | - $out.= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>'; |
|
72 | - $out.='</SELECT>'; |
|
73 | - } elseif ($selected=='method') { |
|
74 | - $out= $langs->trans('CronType_method'); |
|
75 | - $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
76 | - $out.= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>'; |
|
77 | - $out.='</SELECT>'; |
|
68 | + if ($selected == 'command') { |
|
69 | + $out = $langs->trans('CronType_command'); |
|
70 | + $out .= '<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
71 | + $out .= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>'; |
|
72 | + $out .= '</SELECT>'; |
|
73 | + } elseif ($selected == 'method') { |
|
74 | + $out = $langs->trans('CronType_method'); |
|
75 | + $out .= '<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
76 | + $out .= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>'; |
|
77 | + $out .= '</SELECT>'; |
|
78 | 78 | } |
79 | - }else { |
|
79 | + } else { |
|
80 | 80 | |
81 | - $out='<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />'; |
|
81 | + $out = '<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />'; |
|
82 | 82 | |
83 | - if ($selected=='command') { |
|
84 | - $selected_attr=' selected '; |
|
83 | + if ($selected == 'command') { |
|
84 | + $selected_attr = ' selected '; |
|
85 | 85 | } else { |
86 | - $selected_attr=''; |
|
86 | + $selected_attr = ''; |
|
87 | 87 | } |
88 | - $out.= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>'; |
|
88 | + $out .= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>'; |
|
89 | 89 | |
90 | - if ($selected=='method') { |
|
91 | - $selected_attr=' selected '; |
|
90 | + if ($selected == 'method') { |
|
91 | + $selected_attr = ' selected '; |
|
92 | 92 | } else { |
93 | - $selected_attr=''; |
|
93 | + $selected_attr = ''; |
|
94 | 94 | } |
95 | - $out.= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>'; |
|
95 | + $out .= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>'; |
|
96 | 96 | |
97 | - $out.='</SELECT>'; |
|
97 | + $out .= '</SELECT>'; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | 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; |