@@ -101,7 +101,7 @@ |
||
101 | 101 | /** |
102 | 102 | * Return next free value |
103 | 103 | * |
104 | - * @param Societe $objsoc Object thirdparty |
|
104 | + * @param integer $objsoc Object thirdparty |
|
105 | 105 | * @param Object $object Object we need next value for |
106 | 106 | * @return string Value if KO, <0 if KO |
107 | 107 | */ |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class mod_pacific extends ModeleNumRefFicheinter |
32 | 32 | { |
33 | - var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
33 | + var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
34 | 34 | var $prefix='FI'; |
35 | 35 | var $error=''; |
36 | 36 | var $nom = 'pacific'; |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * Return description of numbering module |
41 | 41 | * |
42 | - * @return string Text with description |
|
43 | - */ |
|
44 | - function info() |
|
45 | - { |
|
46 | - global $langs; |
|
47 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
48 | - } |
|
42 | + * @return string Text with description |
|
43 | + */ |
|
44 | + function info() |
|
45 | + { |
|
46 | + global $langs; |
|
47 | + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
48 | + } |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Renvoi un exemple de numerotation |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | $date=$object->datec; |
126 | 126 | $yymm = strftime("%y%m",$date); |
127 | 127 | |
128 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
129 | - else $num = sprintf("%04s",$max+1); |
|
128 | + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
129 | + else $num = sprintf("%04s",$max+1); |
|
130 | 130 | |
131 | 131 | return $this->prefix.$yymm."-".$num; |
132 | 132 | } |
@@ -86,8 +86,7 @@ discard block |
||
86 | 86 | if (! $fayymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$fayymm)) |
87 | 87 | { |
88 | 88 | return true; |
89 | - } |
|
90 | - else |
|
89 | + } else |
|
91 | 90 | { |
92 | 91 | $langs->load("errors"); |
93 | 92 | $this->error=$langs->trans('ErrorNumRefModel',$max); |
@@ -117,16 +116,24 @@ discard block |
||
117 | 116 | if ($resql) |
118 | 117 | { |
119 | 118 | $obj = $db->fetch_object($resql); |
120 | - if ($obj) $max = intval($obj->max); |
|
121 | - else $max=0; |
|
119 | + if ($obj) { |
|
120 | + $max = intval($obj->max); |
|
121 | + } else { |
|
122 | + $max=0; |
|
123 | + } |
|
122 | 124 | } |
123 | 125 | |
124 | 126 | //$date=time(); |
125 | 127 | $date=$object->datec; |
126 | 128 | $yymm = strftime("%y%m",$date); |
127 | 129 | |
128 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
129 | - else $num = sprintf("%04s",$max+1); |
|
130 | + if ($max >= (pow(10, 4) - 1)) { |
|
131 | + $num=$max+1; |
|
132 | + } |
|
133 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
134 | + else { |
|
135 | + $num = sprintf("%04s",$max+1); |
|
136 | + } |
|
130 | 137 | |
131 | 138 | return $this->prefix.$yymm."-".$num; |
132 | 139 | } |
@@ -23,16 +23,16 @@ discard block |
||
23 | 23 | * \ingroup fiche intervention |
24 | 24 | * \brief File with Pacific numbering module for interventions |
25 | 25 | */ |
26 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/fichinter/modules_fichinter.php'; |
|
26 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php'; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Class to manage numbering of intervention cards with rule Pacific. |
30 | 30 | */ |
31 | 31 | class mod_pacific extends ModeleNumRefFicheinter |
32 | 32 | { |
33 | - var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
34 | - var $prefix='FI'; |
|
35 | - var $error=''; |
|
33 | + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
34 | + var $prefix = 'FI'; |
|
35 | + var $error = ''; |
|
36 | 36 | var $nom = 'pacific'; |
37 | 37 | |
38 | 38 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | function info() |
45 | 45 | { |
46 | 46 | global $langs; |
47 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
47 | + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -65,32 +65,32 @@ discard block |
||
65 | 65 | */ |
66 | 66 | function canBeActivated() |
67 | 67 | { |
68 | - global $langs,$conf,$db; |
|
68 | + global $langs, $conf, $db; |
|
69 | 69 | |
70 | 70 | $langs->load("bills"); |
71 | 71 | |
72 | - $fayymm=''; $max=''; |
|
72 | + $fayymm = ''; $max = ''; |
|
73 | 73 | |
74 | - $posindice=8; |
|
74 | + $posindice = 8; |
|
75 | 75 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
76 | - $sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; |
|
77 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
78 | - $sql.= " WHERE entity = ".$conf->entity; |
|
76 | + $sql .= " FROM ".MAIN_DB_PREFIX."fichinter"; |
|
77 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
78 | + $sql .= " WHERE entity = ".$conf->entity; |
|
79 | 79 | |
80 | - $resql=$db->query($sql); |
|
80 | + $resql = $db->query($sql); |
|
81 | 81 | if ($resql) |
82 | 82 | { |
83 | 83 | $row = $db->fetch_row($resql); |
84 | - if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; } |
|
84 | + if ($row) { $fayymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
85 | 85 | } |
86 | - if (! $fayymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$fayymm)) |
|
86 | + if (!$fayymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $fayymm)) |
|
87 | 87 | { |
88 | 88 | return true; |
89 | 89 | } |
90 | 90 | else |
91 | 91 | { |
92 | 92 | $langs->load("errors"); |
93 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
93 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
94 | 94 | return false; |
95 | 95 | } |
96 | 96 | } |
@@ -102,31 +102,31 @@ discard block |
||
102 | 102 | * @param Object $object Object we need next value for |
103 | 103 | * @return string Value if KO, <0 if KO |
104 | 104 | */ |
105 | - function getNextValue($objsoc=0,$object='') |
|
105 | + function getNextValue($objsoc = 0, $object = '') |
|
106 | 106 | { |
107 | - global $db,$conf; |
|
107 | + global $db, $conf; |
|
108 | 108 | |
109 | 109 | // D'abord on recupere la valeur max |
110 | - $posindice=8; |
|
110 | + $posindice = 8; |
|
111 | 111 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
112 | - $sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; |
|
113 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
114 | - $sql.= " AND entity = ".$conf->entity; |
|
112 | + $sql .= " FROM ".MAIN_DB_PREFIX."fichinter"; |
|
113 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
114 | + $sql .= " AND entity = ".$conf->entity; |
|
115 | 115 | |
116 | - $resql=$db->query($sql); |
|
116 | + $resql = $db->query($sql); |
|
117 | 117 | if ($resql) |
118 | 118 | { |
119 | 119 | $obj = $db->fetch_object($resql); |
120 | 120 | if ($obj) $max = intval($obj->max); |
121 | - else $max=0; |
|
121 | + else $max = 0; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | //$date=time(); |
125 | - $date=$object->datec; |
|
126 | - $yymm = strftime("%y%m",$date); |
|
125 | + $date = $object->datec; |
|
126 | + $yymm = strftime("%y%m", $date); |
|
127 | 127 | |
128 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
129 | - else $num = sprintf("%04s",$max+1); |
|
128 | + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
129 | + else $num = sprintf("%04s", $max + 1); |
|
130 | 130 | |
131 | 131 | return $this->prefix.$yymm."-".$num; |
132 | 132 | } |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | * @param Object $objforref Object for number to search |
139 | 139 | * @return string Next free value |
140 | 140 | */ |
141 | - function getNumRef($objsoc,$objforref) |
|
141 | + function getNumRef($objsoc, $objforref) |
|
142 | 142 | { |
143 | - return $this->getNextValue($objsoc,$objforref); |
|
143 | + return $this->getNextValue($objsoc, $objforref); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | } |
@@ -240,7 +240,7 @@ |
||
240 | 240 | * @param Adherent $object Member object. Old usage: Array of record informations (array('textleft'=>,'textheader'=>, ...'id'=>,'photo'=>) |
241 | 241 | * @param Translate $outputlangs Lang object for output language |
242 | 242 | * @param string $srctemplatepath Full path of source filename for generator using a template file. Example: '5161', 'AVERYC32010', 'CARD', ... |
243 | - * @param string $mode Tell if doc module is called for 'member', ... |
|
243 | + * @param integer $mode Tell if doc module is called for 'member', ... |
|
244 | 244 | * @param int $nooutput 1=Generate only file on disk and do not return it on response |
245 | 245 | * @return int 1=OK, 0=KO |
246 | 246 | */ |
@@ -252,58 +252,58 @@ discard block |
||
252 | 252 | |
253 | 253 | if (is_object($object)) |
254 | 254 | { |
255 | - if ($object->country == '-') $object->country=''; |
|
256 | - |
|
257 | - // List of values to scan for a replacement |
|
258 | - $substitutionarray = array ( |
|
259 | - '%ID%'=>$object->rowid, |
|
260 | - '%LOGIN%'=>$object->login, |
|
261 | - '%FIRSTNAME%'=>$object->firstname, |
|
262 | - '%LASTNAME%'=>$object->lastname, |
|
263 | - '%FULLNAME%'=>$object->getFullName($langs), |
|
264 | - '%COMPANY%'=>$object->company, |
|
265 | - '%ADDRESS%'=>$object->address, |
|
266 | - '%ZIP%'=>$object->zip, |
|
267 | - '%TOWN%'=>$object->town, |
|
268 | - '%COUNTRY%'=>$object->country, |
|
269 | - '%COUNTRY_CODE%'=>$object->country_code, |
|
270 | - '%EMAIL%'=>$object->email, |
|
271 | - '%BIRTH%'=>dol_print_date($object->birth,'day'), |
|
272 | - '%TYPE%'=>$object->type, |
|
273 | - '%YEAR%'=>$year, |
|
274 | - '%MONTH%'=>$month, |
|
275 | - '%DAY%'=>$day, |
|
276 | - '%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT, |
|
277 | - '%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/" |
|
278 | - ); |
|
279 | - complete_substitutions_array($substitutionarray, $langs); |
|
280 | - |
|
281 | - // For business cards |
|
282 | - $textleft=make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); |
|
283 | - $textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); |
|
284 | - $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); |
|
285 | - $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); |
|
255 | + if ($object->country == '-') $object->country=''; |
|
256 | + |
|
257 | + // List of values to scan for a replacement |
|
258 | + $substitutionarray = array ( |
|
259 | + '%ID%'=>$object->rowid, |
|
260 | + '%LOGIN%'=>$object->login, |
|
261 | + '%FIRSTNAME%'=>$object->firstname, |
|
262 | + '%LASTNAME%'=>$object->lastname, |
|
263 | + '%FULLNAME%'=>$object->getFullName($langs), |
|
264 | + '%COMPANY%'=>$object->company, |
|
265 | + '%ADDRESS%'=>$object->address, |
|
266 | + '%ZIP%'=>$object->zip, |
|
267 | + '%TOWN%'=>$object->town, |
|
268 | + '%COUNTRY%'=>$object->country, |
|
269 | + '%COUNTRY_CODE%'=>$object->country_code, |
|
270 | + '%EMAIL%'=>$object->email, |
|
271 | + '%BIRTH%'=>dol_print_date($object->birth,'day'), |
|
272 | + '%TYPE%'=>$object->type, |
|
273 | + '%YEAR%'=>$year, |
|
274 | + '%MONTH%'=>$month, |
|
275 | + '%DAY%'=>$day, |
|
276 | + '%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT, |
|
277 | + '%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/" |
|
278 | + ); |
|
279 | + complete_substitutions_array($substitutionarray, $langs); |
|
280 | + |
|
281 | + // For business cards |
|
282 | + $textleft=make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); |
|
283 | + $textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); |
|
284 | + $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); |
|
285 | + $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); |
|
286 | 286 | |
287 | - $nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY']; |
|
288 | - if ($nb <= 0) $nb=1; // Protection to avoid empty page |
|
287 | + $nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY']; |
|
288 | + if ($nb <= 0) $nb=1; // Protection to avoid empty page |
|
289 | 289 | |
290 | - for($j=0;$j<$nb;$j++) |
|
291 | - { |
|
292 | - $arrayofmembers[]=array( |
|
293 | - 'textleft'=>$textleft, |
|
294 | - 'textheader'=>$textheader, |
|
295 | - 'textfooter'=>$textfooter, |
|
296 | - 'textright'=>$textright, |
|
297 | - 'id'=>$object->rowid, |
|
298 | - 'photo'=>$object->photo |
|
299 | - ); |
|
300 | - } |
|
290 | + for($j=0;$j<$nb;$j++) |
|
291 | + { |
|
292 | + $arrayofmembers[]=array( |
|
293 | + 'textleft'=>$textleft, |
|
294 | + 'textheader'=>$textheader, |
|
295 | + 'textfooter'=>$textfooter, |
|
296 | + 'textright'=>$textright, |
|
297 | + 'id'=>$object->rowid, |
|
298 | + 'photo'=>$object->photo |
|
299 | + ); |
|
300 | + } |
|
301 | 301 | |
302 | - $arrayofrecords = $arrayofmembers; |
|
302 | + $arrayofrecords = $arrayofmembers; |
|
303 | 303 | } |
304 | 304 | else |
305 | 305 | { |
306 | - $arrayofrecords = $object; |
|
306 | + $arrayofrecords = $object; |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | //var_dump($arrayofrecords);exit; |
@@ -311,14 +311,14 @@ discard block |
||
311 | 311 | $this->Tformat = $_Avery_Labels[$this->code]; |
312 | 312 | if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; } |
313 | 313 | $this->type = 'pdf'; |
314 | - // standard format or custom |
|
315 | - if ($this->Tformat['paper-size']!='custom') { |
|
316 | - $this->format = $this->Tformat['paper-size']; |
|
317 | - } else { |
|
318 | - //custom |
|
319 | - $resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']); |
|
320 | - $this->format = $resolution; |
|
321 | - } |
|
314 | + // standard format or custom |
|
315 | + if ($this->Tformat['paper-size']!='custom') { |
|
316 | + $this->format = $this->Tformat['paper-size']; |
|
317 | + } else { |
|
318 | + //custom |
|
319 | + $resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']); |
|
320 | + $this->format = $resolution; |
|
321 | + } |
|
322 | 322 | |
323 | 323 | if (! is_object($outputlangs)) $outputlangs=$langs; |
324 | 324 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
@@ -344,15 +344,15 @@ discard block |
||
344 | 344 | $filename = 'tmp_cards.pdf'; |
345 | 345 | if (is_object($object)) |
346 | 346 | { |
347 | - $outputdir = $conf->adherent->dir_output; |
|
348 | - $dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member'); |
|
349 | - $file = $dir.'/'.$filename; |
|
347 | + $outputdir = $conf->adherent->dir_output; |
|
348 | + $dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member'); |
|
349 | + $file = $dir.'/'.$filename; |
|
350 | 350 | } |
351 | 351 | else |
352 | 352 | { |
353 | - $outputdir = $conf->adherent->dir_temp; |
|
354 | - $dir = $outputdir; |
|
355 | - $file = $dir.'/'.$filename; |
|
353 | + $outputdir = $conf->adherent->dir_temp; |
|
354 | + $dir = $outputdir; |
|
355 | + $file = $dir.'/'.$filename; |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | //var_dump($file);exit; |
@@ -421,22 +421,22 @@ discard block |
||
421 | 421 | // Output to http stream |
422 | 422 | if (empty($nooutput)) |
423 | 423 | { |
424 | - clearstatcache(); |
|
424 | + clearstatcache(); |
|
425 | 425 | |
426 | - $attachment=true; |
|
427 | - if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; |
|
428 | - $type=dol_mimetype($filename); |
|
426 | + $attachment=true; |
|
427 | + if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; |
|
428 | + $type=dol_mimetype($filename); |
|
429 | 429 | |
430 | - //if ($encoding) header('Content-Encoding: '.$encoding); |
|
431 | - if ($type) header('Content-Type: '.$type); |
|
432 | - if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
433 | - else header('Content-Disposition: inline; filename="'.$filename.'"'); |
|
430 | + //if ($encoding) header('Content-Encoding: '.$encoding); |
|
431 | + if ($type) header('Content-Type: '.$type); |
|
432 | + if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
433 | + else header('Content-Disposition: inline; filename="'.$filename.'"'); |
|
434 | 434 | |
435 | - // Ajout directives pour resoudre bug IE |
|
436 | - header('Cache-Control: Public, must-revalidate'); |
|
437 | - header('Pragma: public'); |
|
435 | + // Ajout directives pour resoudre bug IE |
|
436 | + header('Cache-Control: Public, must-revalidate'); |
|
437 | + header('Pragma: public'); |
|
438 | 438 | |
439 | - readfile($file); |
|
439 | + readfile($file); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | return 1; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param array $param Associative array containing label content and optional parameters |
43 | 43 | * @return void |
44 | 44 | */ |
45 | - function addSticker(&$pdf,$outputlangs,$param) { |
|
45 | + function addSticker(&$pdf, $outputlangs, $param) { |
|
46 | 46 | // use this method in future refactoring |
47 | 47 | } |
48 | 48 | |
@@ -61,161 +61,161 @@ discard block |
||
61 | 61 | * @param string $photo Photo (full path to image file used as replacement for key %PHOTOS% into left, right, header or footer text) |
62 | 62 | * @return void |
63 | 63 | */ |
64 | - function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$idmember=0,$photo='') |
|
64 | + function Add_PDF_card(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $idmember = 0, $photo = '') |
|
65 | 65 | { |
66 | - global $db,$mysoc,$conf,$langs; |
|
67 | - global $forceimgscalewidth,$forceimgscaleheight; |
|
66 | + global $db, $mysoc, $conf, $langs; |
|
67 | + global $forceimgscalewidth, $forceimgscaleheight; |
|
68 | 68 | |
69 | - $imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth); // Scale of image for width (1=Full width of sticker) |
|
70 | - $imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth); // Scale of image for height (1=Full height of sticker) |
|
69 | + $imgscalewidth = (empty($forceimgscalewidth) ? 0.3 : $forceimgscalewidth); // Scale of image for width (1=Full width of sticker) |
|
70 | + $imgscaleheight = (empty($forceimgscalewidth) ? 0.5 : $forceimgscalewidth); // Scale of image for height (1=Full height of sticker) |
|
71 | 71 | |
72 | 72 | // We are in a new page, then we must add a page |
73 | - if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) { |
|
73 | + if (($this->_COUNTX == 0) && ($this->_COUNTY == 0) and (!$this->_First == 1)) { |
|
74 | 74 | $pdf->AddPage(); |
75 | 75 | } |
76 | - $this->_First=0; |
|
77 | - $_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space)); |
|
78 | - $_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space)); |
|
76 | + $this->_First = 0; |
|
77 | + $_PosX = $this->_Margin_Left + ($this->_COUNTX * ($this->_Width + $this->_X_Space)); |
|
78 | + $_PosY = $this->_Margin_Top + ($this->_COUNTY * ($this->_Height + $this->_Y_Space)); |
|
79 | 79 | |
80 | 80 | // Define logo |
81 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
82 | - if (! is_readable($logo)) |
|
81 | + $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
82 | + if (!is_readable($logo)) |
|
83 | 83 | { |
84 | - $logo=''; |
|
85 | - if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
|
84 | + $logo = ''; |
|
85 | + if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
|
86 | 86 | { |
87 | - $logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
87 | + $logo = $conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
88 | 88 | } |
89 | - elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
89 | + elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
90 | 90 | { |
91 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
91 | + $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | - $member=new Adherent($db); |
|
95 | + $member = new Adherent($db); |
|
96 | 96 | $member->id = $idmember; |
97 | 97 | $member->ref = $idmember; |
98 | 98 | |
99 | 99 | // Define photo |
100 | - $dir=$conf->adherent->dir_output; |
|
101 | - if (! empty($photo)) |
|
100 | + $dir = $conf->adherent->dir_output; |
|
101 | + if (!empty($photo)) |
|
102 | 102 | { |
103 | - $file=get_exdir(0,0,0,0,$member,'member').'photos/'.$photo; |
|
104 | - $photo=$dir.'/'.$file; |
|
105 | - if (! is_readable($photo)) $photo=''; |
|
103 | + $file = get_exdir(0, 0, 0, 0, $member, 'member').'photos/'.$photo; |
|
104 | + $photo = $dir.'/'.$file; |
|
105 | + if (!is_readable($photo)) $photo = ''; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | // Define background image |
109 | - $backgroundimage=''; |
|
110 | - if(! empty($conf->global->ADHERENT_CARD_BACKGROUND) && file_exists($conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND)) |
|
109 | + $backgroundimage = ''; |
|
110 | + if (!empty($conf->global->ADHERENT_CARD_BACKGROUND) && file_exists($conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND)) |
|
111 | 111 | { |
112 | - $backgroundimage=$conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND; |
|
112 | + $backgroundimage = $conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | // Print lines |
116 | 116 | if ($this->code == "CARD") |
117 | 117 | { |
118 | - $this->Tformat=$this->_Avery_Labels["CARD"]; |
|
118 | + $this->Tformat = $this->_Avery_Labels["CARD"]; |
|
119 | 119 | //$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25); |
120 | - $this->_Croix($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.1,10); |
|
120 | + $this->_Croix($pdf, $_PosX, $_PosY, $_PosX + $this->_Width, $_PosY + $this->_Height, 0.1, 10); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | // Background |
124 | 124 | if ($backgroundimage) |
125 | 125 | { |
126 | - $pdf->image($backgroundimage,$_PosX,$_PosY,$this->_Width,$this->_Height); |
|
126 | + $pdf->image($backgroundimage, $_PosX, $_PosY, $this->_Width, $this->_Height); |
|
127 | 127 | } |
128 | 128 | |
129 | - $xleft=2; $ytop=2; |
|
129 | + $xleft = 2; $ytop = 2; |
|
130 | 130 | |
131 | 131 | // Top |
132 | - if ($header!='') |
|
132 | + if ($header != '') |
|
133 | 133 | { |
134 | 134 | if ($this->code == "CARD") |
135 | 135 | { |
136 | - $pdf->SetDrawColor(128,128,128); |
|
137 | - $pdf->Line($_PosX, $_PosY+$this->_Line_Height+1, $_PosX+$this->_Width, $_PosY+$this->_Line_Height+1); // Only 1 mm and not ytop for top text |
|
138 | - $pdf->SetDrawColor(0,0,0); |
|
136 | + $pdf->SetDrawColor(128, 128, 128); |
|
137 | + $pdf->Line($_PosX, $_PosY + $this->_Line_Height + 1, $_PosX + $this->_Width, $_PosY + $this->_Line_Height + 1); // Only 1 mm and not ytop for top text |
|
138 | + $pdf->SetDrawColor(0, 0, 0); |
|
139 | 139 | } |
140 | - $pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text |
|
141 | - $pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C'); |
|
140 | + $pdf->SetXY($_PosX + $xleft, $_PosY + 1); // Only 1 mm and not ytop for top text |
|
141 | + $pdf->Cell($this->_Width - 2 * $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header), 0, 1, 'C'); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | |
145 | - $ytop+=(empty($header)?0:(1+$this->_Line_Height)); |
|
145 | + $ytop += (empty($header) ? 0 : (1 + $this->_Line_Height)); |
|
146 | 146 | |
147 | 147 | // Define widthtouse and heighttouse |
148 | - $maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight); |
|
149 | - $defaultratio=($maxwidthtouse/$maxheighttouse); |
|
150 | - $widthtouse=$maxwidthtouse; $heighttouse=0; // old value for image |
|
151 | - $tmp=dol_getImageSize($photo, false); |
|
148 | + $maxwidthtouse = round(($this->_Width - 2 * $xleft) * $imgscalewidth); $maxheighttouse = round(($this->_Height - 2 * $ytop) * $imgscaleheight); |
|
149 | + $defaultratio = ($maxwidthtouse / $maxheighttouse); |
|
150 | + $widthtouse = $maxwidthtouse; $heighttouse = 0; // old value for image |
|
151 | + $tmp = dol_getImageSize($photo, false); |
|
152 | 152 | if ($tmp['height']) |
153 | 153 | { |
154 | - $imgratio=$tmp['width']/$tmp['height']; |
|
154 | + $imgratio = $tmp['width'] / $tmp['height']; |
|
155 | 155 | if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } |
156 | 156 | else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); } |
157 | 157 | } |
158 | 158 | //var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit; |
159 | 159 | |
160 | 160 | // Center |
161 | - if ($textright=='') // Only a left part |
|
161 | + if ($textright == '') // Only a left part |
|
162 | 162 | { |
163 | 163 | // Output left area |
164 | - if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
165 | - else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
164 | + if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
165 | + else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
166 | 166 | else |
167 | 167 | { |
168 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
169 | - $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
168 | + $pdf->SetXY($_PosX + $xleft, $_PosY + $ytop); |
|
169 | + $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); |
|
170 | 170 | } |
171 | 171 | } |
172 | - else if ($textleft!='' && $textright!='') // |
|
172 | + else if ($textleft != '' && $textright != '') // |
|
173 | 173 | { |
174 | 174 | if ($textleft == '%LOGO%' || $textleft == '%PHOTO%') |
175 | 175 | { |
176 | - if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
177 | - else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
178 | - $pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop); |
|
179 | - $pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
176 | + if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
177 | + else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
178 | + $pdf->SetXY($_PosX + $xleft + $widthtouse + 1, $_PosY + $ytop); |
|
179 | + $pdf->MultiCell($this->_Width - $xleft - $xleft - $widthtouse - 1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R'); |
|
180 | 180 | } |
181 | 181 | else if ($textright == '%LOGO%' || $textright == '%PHOTO%') |
182 | 182 | { |
183 | - if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
184 | - else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
185 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
186 | - $pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
183 | + if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
184 | + else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
185 | + $pdf->SetXY($_PosX + $xleft, $_PosY + $ytop); |
|
186 | + $pdf->MultiCell($this->_Width - $widthtouse - $xleft - $xleft - 1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); |
|
187 | 187 | } |
188 | 188 | else // text on halft left and text on half right |
189 | 189 | { |
190 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
191 | - $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
192 | - $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop); |
|
193 | - $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
190 | + $pdf->SetXY($_PosX + $xleft, $_PosY + $ytop); |
|
191 | + $pdf->MultiCell(round($this->_Width / 2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); |
|
192 | + $pdf->SetXY($_PosX + round($this->_Width / 2), $_PosY + $ytop); |
|
193 | + $pdf->MultiCell(round($this->_Width / 2) - 2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R'); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | else // Only a right part |
197 | 197 | { |
198 | 198 | // Output right area |
199 | - if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
200 | - else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
199 | + if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
200 | + else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
201 | 201 | else |
202 | 202 | { |
203 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
204 | - $pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
203 | + $pdf->SetXY($_PosX + $xleft, $_PosY + $ytop); |
|
204 | + $pdf->MultiCell($this->_Width - $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R'); |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | 208 | // Bottom |
209 | - if ($footer!='') |
|
209 | + if ($footer != '') |
|
210 | 210 | { |
211 | 211 | if ($this->code == "CARD") |
212 | 212 | { |
213 | - $pdf->SetDrawColor(128,128,128); |
|
214 | - $pdf->Line($_PosX, $_PosY+$this->_Height-$this->_Line_Height-2, $_PosX+$this->_Width, $_PosY+$this->_Height-$this->_Line_Height-2); |
|
215 | - $pdf->SetDrawColor(0,0,0); |
|
213 | + $pdf->SetDrawColor(128, 128, 128); |
|
214 | + $pdf->Line($_PosX, $_PosY + $this->_Height - $this->_Line_Height - 2, $_PosX + $this->_Width, $_PosY + $this->_Height - $this->_Line_Height - 2); |
|
215 | + $pdf->SetDrawColor(0, 0, 0); |
|
216 | 216 | } |
217 | - $pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1); |
|
218 | - $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C'); |
|
217 | + $pdf->SetXY($_PosX, $_PosY + $this->_Height - $this->_Line_Height - 1); |
|
218 | + $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer), 0, 1, 'C'); |
|
219 | 219 | } |
220 | 220 | //print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n"; |
221 | 221 | |
@@ -224,13 +224,13 @@ discard block |
||
224 | 224 | if ($this->_COUNTY == $this->_Y_Number) { |
225 | 225 | // Si on est en bas de page, on remonte le 'curseur' de position |
226 | 226 | $this->_COUNTX++; |
227 | - $this->_COUNTY=0; |
|
227 | + $this->_COUNTY = 0; |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | if ($this->_COUNTX == $this->_X_Number) { |
231 | 231 | // Si on est en bout de page, alors on repart sur une nouvelle page |
232 | - $this->_COUNTX=0; |
|
233 | - $this->_COUNTY=0; |
|
232 | + $this->_COUNTX = 0; |
|
233 | + $this->_COUNTY = 0; |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
@@ -244,18 +244,18 @@ discard block |
||
244 | 244 | * @param int $nooutput 1=Generate only file on disk and do not return it on response |
245 | 245 | * @return int 1=OK, 0=KO |
246 | 246 | */ |
247 | - function write_file($object, $outputlangs, $srctemplatepath, $mode='member', $nooutput=0) |
|
247 | + function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = 0) |
|
248 | 248 | { |
249 | - global $user,$conf,$langs,$mysoc,$_Avery_Labels; |
|
249 | + global $user, $conf, $langs, $mysoc, $_Avery_Labels; |
|
250 | 250 | |
251 | - $this->code=$srctemplatepath; |
|
251 | + $this->code = $srctemplatepath; |
|
252 | 252 | |
253 | 253 | if (is_object($object)) |
254 | 254 | { |
255 | - if ($object->country == '-') $object->country=''; |
|
255 | + if ($object->country == '-') $object->country = ''; |
|
256 | 256 | |
257 | 257 | // List of values to scan for a replacement |
258 | - $substitutionarray = array ( |
|
258 | + $substitutionarray = array( |
|
259 | 259 | '%ID%'=>$object->rowid, |
260 | 260 | '%LOGIN%'=>$object->login, |
261 | 261 | '%FIRSTNAME%'=>$object->firstname, |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | '%COUNTRY%'=>$object->country, |
269 | 269 | '%COUNTRY_CODE%'=>$object->country_code, |
270 | 270 | '%EMAIL%'=>$object->email, |
271 | - '%BIRTH%'=>dol_print_date($object->birth,'day'), |
|
271 | + '%BIRTH%'=>dol_print_date($object->birth, 'day'), |
|
272 | 272 | '%TYPE%'=>$object->type, |
273 | 273 | '%YEAR%'=>$year, |
274 | 274 | '%MONTH%'=>$month, |
@@ -279,17 +279,17 @@ discard block |
||
279 | 279 | complete_substitutions_array($substitutionarray, $langs); |
280 | 280 | |
281 | 281 | // For business cards |
282 | - $textleft=make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); |
|
283 | - $textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); |
|
284 | - $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); |
|
285 | - $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); |
|
282 | + $textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); |
|
283 | + $textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); |
|
284 | + $textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); |
|
285 | + $textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); |
|
286 | 286 | |
287 | 287 | $nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY']; |
288 | - if ($nb <= 0) $nb=1; // Protection to avoid empty page |
|
288 | + if ($nb <= 0) $nb = 1; // Protection to avoid empty page |
|
289 | 289 | |
290 | - for($j=0;$j<$nb;$j++) |
|
290 | + for ($j = 0; $j < $nb; $j++) |
|
291 | 291 | { |
292 | - $arrayofmembers[]=array( |
|
292 | + $arrayofmembers[] = array( |
|
293 | 293 | 'textleft'=>$textleft, |
294 | 294 | 'textheader'=>$textheader, |
295 | 295 | 'textfooter'=>$textfooter, |
@@ -309,20 +309,20 @@ discard block |
||
309 | 309 | //var_dump($arrayofrecords);exit; |
310 | 310 | |
311 | 311 | $this->Tformat = $_Avery_Labels[$this->code]; |
312 | - if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; } |
|
312 | + if (empty($this->Tformat)) { dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; } |
|
313 | 313 | $this->type = 'pdf'; |
314 | 314 | // standard format or custom |
315 | - if ($this->Tformat['paper-size']!='custom') { |
|
315 | + if ($this->Tformat['paper-size'] != 'custom') { |
|
316 | 316 | $this->format = $this->Tformat['paper-size']; |
317 | 317 | } else { |
318 | 318 | //custom |
319 | - $resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']); |
|
319 | + $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']); |
|
320 | 320 | $this->format = $resolution; |
321 | 321 | } |
322 | 322 | |
323 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
323 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
324 | 324 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
325 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
325 | + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; |
|
326 | 326 | |
327 | 327 | $outputlangs->load("main"); |
328 | 328 | $outputlangs->load("dict"); |
@@ -332,12 +332,12 @@ discard block |
||
332 | 332 | |
333 | 333 | if (empty($mode) || $mode == 'member') |
334 | 334 | { |
335 | - $title=$outputlangs->transnoentities('MembersCards'); |
|
336 | - $keywords=$outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name); |
|
335 | + $title = $outputlangs->transnoentities('MembersCards'); |
|
336 | + $keywords = $outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name); |
|
337 | 337 | } |
338 | 338 | else |
339 | 339 | { |
340 | - dol_print_error('','Bad value for $mode'); |
|
340 | + dol_print_error('', 'Bad value for $mode'); |
|
341 | 341 | return -1; |
342 | 342 | } |
343 | 343 | |
@@ -357,16 +357,16 @@ discard block |
||
357 | 357 | |
358 | 358 | //var_dump($file);exit; |
359 | 359 | |
360 | - if (! file_exists($dir)) |
|
360 | + if (!file_exists($dir)) |
|
361 | 361 | { |
362 | 362 | if (dol_mkdir($dir) < 0) |
363 | 363 | { |
364 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
364 | + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); |
|
365 | 365 | return 0; |
366 | 366 | } |
367 | 367 | } |
368 | 368 | |
369 | - $pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']); |
|
369 | + $pdf = pdf_getInstance($this->format, $this->Tformat['metric'], $this->Tformat['orientation']); |
|
370 | 370 | |
371 | 371 | if (class_exists('TCPDF')) |
372 | 372 | { |
@@ -380,17 +380,17 @@ discard block |
||
380 | 380 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
381 | 381 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
382 | 382 | $pdf->SetKeyWords($keywords); |
383 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
383 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
384 | 384 | |
385 | - $pdf->SetMargins(0,0); |
|
385 | + $pdf->SetMargins(0, 0); |
|
386 | 386 | $pdf->SetAutoPageBreak(false); |
387 | 387 | |
388 | 388 | $this->_Metric_Doc = $this->Tformat['metric']; |
389 | 389 | // Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie |
390 | - $posX=1; |
|
391 | - $posY=1; |
|
392 | - if ($posX > 0) $posX--; else $posX=0; |
|
393 | - if ($posY > 0) $posY--; else $posY=0; |
|
390 | + $posX = 1; |
|
391 | + $posY = 1; |
|
392 | + if ($posX > 0) $posX--; else $posX = 0; |
|
393 | + if ($posY > 0) $posY--; else $posY = 0; |
|
394 | 394 | $this->_COUNTX = $posX; |
395 | 395 | $this->_COUNTY = $posY; |
396 | 396 | $this->_Set_Format($pdf, $this->Tformat); |
@@ -401,10 +401,10 @@ discard block |
||
401 | 401 | |
402 | 402 | |
403 | 403 | // Add each record |
404 | - foreach($arrayofrecords as $val) |
|
404 | + foreach ($arrayofrecords as $val) |
|
405 | 405 | { |
406 | 406 | // imprime le texte specifique sur la carte |
407 | - $this->Add_PDF_card($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['id'],$val['photo']); |
|
407 | + $this->Add_PDF_card($pdf, $val['textleft'], $val['textheader'], $val['textfooter'], $langs, $val['textright'], $val['id'], $val['photo']); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | //$pdf->SetXY(10, 295); |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | |
413 | 413 | |
414 | 414 | // Output to file |
415 | - $pdf->Output($file,'F'); |
|
415 | + $pdf->Output($file, 'F'); |
|
416 | 416 | |
417 | - if (! empty($conf->global->MAIN_UMASK)) |
|
417 | + if (!empty($conf->global->MAIN_UMASK)) |
|
418 | 418 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
419 | 419 | |
420 | 420 | |
@@ -423,9 +423,9 @@ discard block |
||
423 | 423 | { |
424 | 424 | clearstatcache(); |
425 | 425 | |
426 | - $attachment=true; |
|
427 | - if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; |
|
428 | - $type=dol_mimetype($filename); |
|
426 | + $attachment = true; |
|
427 | + if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false; |
|
428 | + $type = dol_mimetype($filename); |
|
429 | 429 | |
430 | 430 | //if ($encoding) header('Content-Encoding: '.$encoding); |
431 | 431 | if ($type) header('Content-Type: '.$type); |
@@ -85,8 +85,7 @@ discard block |
||
85 | 85 | if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
86 | 86 | { |
87 | 87 | $logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
88 | - } |
|
89 | - elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
88 | + } elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
90 | 89 | { |
91 | 90 | $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
92 | 91 | } |
@@ -102,7 +101,9 @@ discard block |
||
102 | 101 | { |
103 | 102 | $file=get_exdir(0,0,0,0,$member,'member').'photos/'.$photo; |
104 | 103 | $photo=$dir.'/'.$file; |
105 | - if (! is_readable($photo)) $photo=''; |
|
104 | + if (! is_readable($photo)) { |
|
105 | + $photo=''; |
|
106 | + } |
|
106 | 107 | } |
107 | 108 | |
108 | 109 | // Define background image |
@@ -152,53 +153,58 @@ discard block |
||
152 | 153 | if ($tmp['height']) |
153 | 154 | { |
154 | 155 | $imgratio=$tmp['width']/$tmp['height']; |
155 | - if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } |
|
156 | - else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); } |
|
156 | + if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); } |
|
157 | 157 | } |
158 | 158 | //var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit; |
159 | 159 | |
160 | 160 | // Center |
161 | - if ($textright=='') // Only a left part |
|
161 | + if ($textright=='') { |
|
162 | + // Only a left part |
|
162 | 163 | { |
163 | 164 | // Output left area |
164 | 165 | if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
165 | - else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
166 | - else |
|
166 | + } else if ($textleft == '%PHOTO%' && $photo) { |
|
167 | + $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
168 | + } else |
|
167 | 169 | { |
168 | 170 | $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
169 | 171 | $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
170 | 172 | } |
171 | - } |
|
172 | - else if ($textleft!='' && $textright!='') // |
|
173 | + } else if ($textleft!='' && $textright!='') { |
|
174 | + // |
|
173 | 175 | { |
174 | 176 | if ($textleft == '%LOGO%' || $textleft == '%PHOTO%') |
175 | 177 | { |
176 | 178 | if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
177 | - else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
179 | + } else if ($textleft == '%PHOTO%' && $photo) { |
|
180 | + $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
181 | + } |
|
178 | 182 | $pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop); |
179 | 183 | $pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
180 | - } |
|
181 | - else if ($textright == '%LOGO%' || $textright == '%PHOTO%') |
|
184 | + } else if ($textright == '%LOGO%' || $textright == '%PHOTO%') |
|
182 | 185 | { |
183 | - if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
184 | - else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
186 | + if ($textright == '%LOGO%' && $logo) { |
|
187 | + $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
188 | + } else if ($textright == '%PHOTO%' && $photo) { |
|
189 | + $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
190 | + } |
|
185 | 191 | $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
186 | 192 | $pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
187 | - } |
|
188 | - else // text on halft left and text on half right |
|
193 | + } else // text on halft left and text on half right |
|
189 | 194 | { |
190 | 195 | $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
191 | 196 | $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
192 | 197 | $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop); |
193 | 198 | $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
194 | 199 | } |
195 | - } |
|
196 | - else // Only a right part |
|
200 | + } else // Only a right part |
|
197 | 201 | { |
198 | 202 | // Output right area |
199 | - if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
200 | - else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
201 | - else |
|
203 | + if ($textright == '%LOGO%' && $logo) { |
|
204 | + $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
205 | + } else if ($textright == '%PHOTO%' && $photo) { |
|
206 | + $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
207 | + } else |
|
202 | 208 | { |
203 | 209 | $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
204 | 210 | $pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
@@ -252,7 +258,9 @@ discard block |
||
252 | 258 | |
253 | 259 | if (is_object($object)) |
254 | 260 | { |
255 | - if ($object->country == '-') $object->country=''; |
|
261 | + if ($object->country == '-') { |
|
262 | + $object->country=''; |
|
263 | + } |
|
256 | 264 | |
257 | 265 | // List of values to scan for a replacement |
258 | 266 | $substitutionarray = array ( |
@@ -285,7 +293,10 @@ discard block |
||
285 | 293 | $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); |
286 | 294 | |
287 | 295 | $nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY']; |
288 | - if ($nb <= 0) $nb=1; // Protection to avoid empty page |
|
296 | + if ($nb <= 0) { |
|
297 | + $nb=1; |
|
298 | + } |
|
299 | + // Protection to avoid empty page |
|
289 | 300 | |
290 | 301 | for($j=0;$j<$nb;$j++) |
291 | 302 | { |
@@ -300,8 +311,7 @@ discard block |
||
300 | 311 | } |
301 | 312 | |
302 | 313 | $arrayofrecords = $arrayofmembers; |
303 | - } |
|
304 | - else |
|
314 | + } else |
|
305 | 315 | { |
306 | 316 | $arrayofrecords = $object; |
307 | 317 | } |
@@ -320,9 +330,13 @@ discard block |
||
320 | 330 | $this->format = $resolution; |
321 | 331 | } |
322 | 332 | |
323 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
333 | + if (! is_object($outputlangs)) { |
|
334 | + $outputlangs=$langs; |
|
335 | + } |
|
324 | 336 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
325 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
337 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
338 | + $outputlangs->charset_output='ISO-8859-1'; |
|
339 | + } |
|
326 | 340 | |
327 | 341 | $outputlangs->load("main"); |
328 | 342 | $outputlangs->load("dict"); |
@@ -334,8 +348,7 @@ discard block |
||
334 | 348 | { |
335 | 349 | $title=$outputlangs->transnoentities('MembersCards'); |
336 | 350 | $keywords=$outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name); |
337 | - } |
|
338 | - else |
|
351 | + } else |
|
339 | 352 | { |
340 | 353 | dol_print_error('','Bad value for $mode'); |
341 | 354 | return -1; |
@@ -347,8 +360,7 @@ discard block |
||
347 | 360 | $outputdir = $conf->adherent->dir_output; |
348 | 361 | $dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member'); |
349 | 362 | $file = $dir.'/'.$filename; |
350 | - } |
|
351 | - else |
|
363 | + } else |
|
352 | 364 | { |
353 | 365 | $outputdir = $conf->adherent->dir_temp; |
354 | 366 | $dir = $outputdir; |
@@ -380,7 +392,9 @@ discard block |
||
380 | 392 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
381 | 393 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
382 | 394 | $pdf->SetKeyWords($keywords); |
383 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
395 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
396 | + $pdf->SetCompression(false); |
|
397 | + } |
|
384 | 398 | |
385 | 399 | $pdf->SetMargins(0,0); |
386 | 400 | $pdf->SetAutoPageBreak(false); |
@@ -389,8 +403,16 @@ discard block |
||
389 | 403 | // Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie |
390 | 404 | $posX=1; |
391 | 405 | $posY=1; |
392 | - if ($posX > 0) $posX--; else $posX=0; |
|
393 | - if ($posY > 0) $posY--; else $posY=0; |
|
406 | + if ($posX > 0) { |
|
407 | + $posX--; |
|
408 | + } else { |
|
409 | + $posX=0; |
|
410 | + } |
|
411 | + if ($posY > 0) { |
|
412 | + $posY--; |
|
413 | + } else { |
|
414 | + $posY=0; |
|
415 | + } |
|
394 | 416 | $this->_COUNTX = $posX; |
395 | 417 | $this->_COUNTY = $posY; |
396 | 418 | $this->_Set_Format($pdf, $this->Tformat); |
@@ -414,8 +436,9 @@ discard block |
||
414 | 436 | // Output to file |
415 | 437 | $pdf->Output($file,'F'); |
416 | 438 | |
417 | - if (! empty($conf->global->MAIN_UMASK)) |
|
418 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
439 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
440 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
441 | + } |
|
419 | 442 | |
420 | 443 | |
421 | 444 | $this->result = array('fullpath'=>$file); |
@@ -426,13 +449,20 @@ discard block |
||
426 | 449 | clearstatcache(); |
427 | 450 | |
428 | 451 | $attachment=true; |
429 | - if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; |
|
452 | + if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) { |
|
453 | + $attachment=false; |
|
454 | + } |
|
430 | 455 | $type=dol_mimetype($filename); |
431 | 456 | |
432 | 457 | //if ($encoding) header('Content-Encoding: '.$encoding); |
433 | - if ($type) header('Content-Type: '.$type); |
|
434 | - if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
435 | - else header('Content-Disposition: inline; filename="'.$filename.'"'); |
|
458 | + if ($type) { |
|
459 | + header('Content-Type: '.$type); |
|
460 | + } |
|
461 | + if ($attachment) { |
|
462 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
463 | + } else { |
|
464 | + header('Content-Disposition: inline; filename="'.$filename.'"'); |
|
465 | + } |
|
436 | 466 | |
437 | 467 | // Ajout directives pour resoudre bug IE |
438 | 468 | header('Cache-Control: Public, must-revalidate'); |
@@ -100,7 +100,7 @@ |
||
100 | 100 | * Return next free value |
101 | 101 | * |
102 | 102 | * @param Societe $objsoc Object thirdparty |
103 | - * @param Object $object Object we need next value for |
|
103 | + * @param string $object Object we need next value for |
|
104 | 104 | * @return string Value if KO, <0 if KO |
105 | 105 | */ |
106 | 106 | function getNextValue($objsoc,$object) |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | var $nom = 'Ant'; |
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * Renvoi la description du modele de numerotation |
|
40 | - * |
|
41 | - * @return string Texte descripif |
|
42 | - */ |
|
38 | + /** |
|
39 | + * Renvoi la description du modele de numerotation |
|
40 | + * |
|
41 | + * @return string Texte descripif |
|
42 | + */ |
|
43 | 43 | function info() |
44 | - { |
|
45 | - global $conf,$langs; |
|
44 | + { |
|
45 | + global $conf,$langs; |
|
46 | 46 | |
47 | 47 | $langs->load("bills"); |
48 | 48 | |
@@ -73,20 +73,20 @@ discard block |
||
73 | 73 | $texte.= '</form>'; |
74 | 74 | |
75 | 75 | return $texte; |
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Renvoi un exemple de numerotation |
|
80 | - * |
|
81 | - * @return string Example |
|
82 | - */ |
|
83 | - function getExample() |
|
84 | - { |
|
85 | - global $conf,$langs,$mysoc; |
|
86 | - |
|
87 | - $old_code_client=$mysoc->code_client; |
|
88 | - $mysoc->code_client='CCCCCCCCCC'; |
|
89 | - $numExample = $this->getNextValue($mysoc,''); |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Renvoi un exemple de numerotation |
|
80 | + * |
|
81 | + * @return string Example |
|
82 | + */ |
|
83 | + function getExample() |
|
84 | + { |
|
85 | + global $conf,$langs,$mysoc; |
|
86 | + |
|
87 | + $old_code_client=$mysoc->code_client; |
|
88 | + $mysoc->code_client='CCCCCCCCCC'; |
|
89 | + $numExample = $this->getNextValue($mysoc,''); |
|
90 | 90 | $mysoc->code_client=$old_code_client; |
91 | 91 | |
92 | 92 | if (! $numExample) |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $numExample = $langs->trans('NotConfigured'); |
95 | 95 | } |
96 | 96 | return $numExample; |
97 | - } |
|
97 | + } |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Return next free value |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | * @param Object $object Object we need next value for |
104 | 104 | * @return string Value if KO, <0 if KO |
105 | 105 | */ |
106 | - function getNextValue($objsoc,$object) |
|
107 | - { |
|
106 | + function getNextValue($objsoc,$object) |
|
107 | + { |
|
108 | 108 | global $db,$conf; |
109 | 109 | |
110 | 110 | require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | * @param Societe $objsoc Object third party |
131 | 131 | * @param string $objforref Object for number to search |
132 | 132 | * @return string Next free value |
133 | - */ |
|
134 | - function commande_get_num($objsoc,$objforref) |
|
135 | - { |
|
136 | - return $this->getNextValue($objsoc,$objforref); |
|
137 | - } |
|
133 | + */ |
|
134 | + function commande_get_num($objsoc,$objforref) |
|
135 | + { |
|
136 | + return $this->getNextValue($objsoc,$objforref); |
|
137 | + } |
|
138 | 138 | |
139 | 139 | } |
140 | 140 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief File containing class for numbering module Ant |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/payment/modules_payment.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/payment/modules_payment.php'; |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class mod_payment_ant extends ModeleNumRefPayments |
32 | 32 | { |
33 | - var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
33 | + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
34 | 34 | var $error = ''; |
35 | 35 | var $nom = 'Ant'; |
36 | 36 | |
@@ -42,35 +42,35 @@ discard block |
||
42 | 42 | */ |
43 | 43 | function info() |
44 | 44 | { |
45 | - global $conf,$langs; |
|
45 | + global $conf, $langs; |
|
46 | 46 | |
47 | 47 | $langs->load("bills"); |
48 | 48 | |
49 | 49 | $form = new Form($this->db); |
50 | 50 | |
51 | 51 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
52 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
53 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
54 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
55 | - $texte.= '<input type="hidden" name="maskconstpayment" value="PAYMENT_ANT_MASK">'; |
|
56 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
57 | - |
|
58 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
59 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
60 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
61 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
62 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
52 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
53 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
54 | + $texte .= '<input type="hidden" name="action" value="updateMask">'; |
|
55 | + $texte .= '<input type="hidden" name="maskconstpayment" value="PAYMENT_ANT_MASK">'; |
|
56 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
57 | + |
|
58 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Order"), $langs->transnoentities("Order")); |
|
59 | + $tooltip .= $langs->trans("GenericMaskCodes2"); |
|
60 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
61 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Order"), $langs->transnoentities("Order")); |
|
62 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
63 | 63 | |
64 | 64 | // Parametrage du prefix |
65 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
66 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskpayment" value="'.$conf->global->PAYMENT_ANT_MASK.'">',$tooltip,1,1).'</td>'; |
|
65 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
66 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskpayment" value="'.$conf->global->PAYMENT_ANT_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
67 | 67 | |
68 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
68 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
69 | 69 | |
70 | - $texte.= '</tr>'; |
|
70 | + $texte .= '</tr>'; |
|
71 | 71 | |
72 | - $texte.= '</table>'; |
|
73 | - $texte.= '</form>'; |
|
72 | + $texte .= '</table>'; |
|
73 | + $texte .= '</form>'; |
|
74 | 74 | |
75 | 75 | return $texte; |
76 | 76 | } |
@@ -82,14 +82,14 @@ discard block |
||
82 | 82 | */ |
83 | 83 | function getExample() |
84 | 84 | { |
85 | - global $conf,$langs,$mysoc; |
|
85 | + global $conf, $langs, $mysoc; |
|
86 | 86 | |
87 | - $old_code_client=$mysoc->code_client; |
|
88 | - $mysoc->code_client='CCCCCCCCCC'; |
|
89 | - $numExample = $this->getNextValue($mysoc,''); |
|
90 | - $mysoc->code_client=$old_code_client; |
|
87 | + $old_code_client = $mysoc->code_client; |
|
88 | + $mysoc->code_client = 'CCCCCCCCCC'; |
|
89 | + $numExample = $this->getNextValue($mysoc, ''); |
|
90 | + $mysoc->code_client = $old_code_client; |
|
91 | 91 | |
92 | - if (! $numExample) |
|
92 | + if (!$numExample) |
|
93 | 93 | { |
94 | 94 | $numExample = $langs->trans('NotConfigured'); |
95 | 95 | } |
@@ -103,22 +103,22 @@ discard block |
||
103 | 103 | * @param Object $object Object we need next value for |
104 | 104 | * @return string Value if KO, <0 if KO |
105 | 105 | */ |
106 | - function getNextValue($objsoc,$object) |
|
106 | + function getNextValue($objsoc, $object) |
|
107 | 107 | { |
108 | - global $db,$conf; |
|
108 | + global $db, $conf; |
|
109 | 109 | |
110 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
110 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
111 | 111 | |
112 | 112 | // We get cursor rule |
113 | - $mask=$conf->global->PAYMENT_ANT_MASK; |
|
113 | + $mask = $conf->global->PAYMENT_ANT_MASK; |
|
114 | 114 | |
115 | - if (! $mask) |
|
115 | + if (!$mask) |
|
116 | 116 | { |
117 | - $this->error='NotConfigured'; |
|
117 | + $this->error = 'NotConfigured'; |
|
118 | 118 | return 0; |
119 | 119 | } |
120 | 120 | |
121 | - $numFinal=get_next_value($db,$mask,'paiement','ref','',$objsoc,$object->datepaye); |
|
121 | + $numFinal = get_next_value($db, $mask, 'paiement', 'ref', '', $objsoc, $object->datepaye); |
|
122 | 122 | |
123 | 123 | return $numFinal; |
124 | 124 | } |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | * @param string $objforref Object for number to search |
132 | 132 | * @return string Next free value |
133 | 133 | */ |
134 | - function commande_get_num($objsoc,$objforref) |
|
134 | + function commande_get_num($objsoc, $objforref) |
|
135 | 135 | { |
136 | - return $this->getNextValue($objsoc,$objforref); |
|
136 | + return $this->getNextValue($objsoc, $objforref); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | } |
@@ -96,7 +96,7 @@ |
||
96 | 96 | * Return next free value |
97 | 97 | * |
98 | 98 | * @param Societe $objsoc Object thirdparty |
99 | - * @param Object $object Object we need next value for |
|
99 | + * @param string $object Object we need next value for |
|
100 | 100 | * @return string Value if KO, <0 if KO |
101 | 101 | */ |
102 | 102 | function getNextValue($objsoc,$object) |
@@ -35,16 +35,16 @@ discard block |
||
35 | 35 | var $nom='Cicada'; |
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * Return description of numbering module |
|
40 | - * |
|
41 | - * @return string Text with description |
|
42 | - */ |
|
43 | - function info() |
|
44 | - { |
|
45 | - global $langs; |
|
46 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
47 | - } |
|
38 | + /** |
|
39 | + * Return description of numbering module |
|
40 | + * |
|
41 | + * @return string Text with description |
|
42 | + */ |
|
43 | + function info() |
|
44 | + { |
|
45 | + global $langs; |
|
46 | + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | 50 | /** |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | $date=$object->datepaye; |
128 | 128 | $yymm = strftime("%y%m",$date); |
129 | 129 | |
130 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
131 | - else $num = sprintf("%04s",$max+1); |
|
130 | + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
131 | + else $num = sprintf("%04s",$max+1); |
|
132 | 132 | |
133 | 133 | dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
134 | 134 | return $this->prefix.$yymm."-".$num; |
@@ -114,10 +114,12 @@ discard block |
||
114 | 114 | if ($resql) |
115 | 115 | { |
116 | 116 | $obj = $db->fetch_object($resql); |
117 | - if ($obj) $max = intval($obj->max); |
|
118 | - else $max=0; |
|
119 | - } |
|
120 | - else |
|
117 | + if ($obj) { |
|
118 | + $max = intval($obj->max); |
|
119 | + } else { |
|
120 | + $max=0; |
|
121 | + } |
|
122 | + } else |
|
121 | 123 | { |
122 | 124 | dol_syslog(__METHOD__, LOG_DEBUG); |
123 | 125 | return -1; |
@@ -127,8 +129,13 @@ discard block |
||
127 | 129 | $date=$object->datepaye; |
128 | 130 | $yymm = strftime("%y%m",$date); |
129 | 131 | |
130 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
131 | - else $num = sprintf("%04s",$max+1); |
|
132 | + if ($max >= (pow(10, 4) - 1)) { |
|
133 | + $num=$max+1; |
|
134 | + } |
|
135 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
136 | + else { |
|
137 | + $num = sprintf("%04s",$max+1); |
|
138 | + } |
|
132 | 139 | |
133 | 140 | dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
134 | 141 | return $this->prefix.$yymm."-".$num; |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | * \brief File containing class for numbering module Cicada |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/payment/modules_payment.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/payment/modules_payment.php'; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Class to manage customer payment numbering rules Cicada |
29 | 29 | */ |
30 | 30 | class mod_payment_cicada extends ModeleNumRefPayments |
31 | 31 | { |
32 | - var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
33 | - var $prefix='PAY'; |
|
34 | - var $error=''; |
|
35 | - var $nom='Cicada'; |
|
32 | + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
33 | + var $prefix = 'PAY'; |
|
34 | + var $error = ''; |
|
35 | + var $nom = 'Cicada'; |
|
36 | 36 | |
37 | 37 | |
38 | 38 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | function info() |
44 | 44 | { |
45 | 45 | global $langs; |
46 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
46 | + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
@@ -66,26 +66,26 @@ discard block |
||
66 | 66 | */ |
67 | 67 | function canBeActivated() |
68 | 68 | { |
69 | - global $conf,$langs,$db; |
|
69 | + global $conf, $langs, $db; |
|
70 | 70 | |
71 | - $payyymm=''; $max=''; |
|
71 | + $payyymm = ''; $max = ''; |
|
72 | 72 | |
73 | - $posindice=9; |
|
73 | + $posindice = 9; |
|
74 | 74 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
75 | - $sql.= " FROM ".MAIN_DB_PREFIX."paiement"; |
|
76 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
77 | - $sql.= " AND entity = ".$conf->entity; |
|
75 | + $sql .= " FROM ".MAIN_DB_PREFIX."paiement"; |
|
76 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
77 | + $sql .= " AND entity = ".$conf->entity; |
|
78 | 78 | |
79 | - $resql=$db->query($sql); |
|
79 | + $resql = $db->query($sql); |
|
80 | 80 | if ($resql) |
81 | 81 | { |
82 | 82 | $row = $db->fetch_row($resql); |
83 | - if ($row) { $payyymm = substr($row[0],0,6); $max=$row[0]; } |
|
83 | + if ($row) { $payyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
84 | 84 | } |
85 | - if ($payyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$payyymm)) |
|
85 | + if ($payyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $payyymm)) |
|
86 | 86 | { |
87 | 87 | $langs->load("errors"); |
88 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
88 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
89 | 89 | return false; |
90 | 90 | } |
91 | 91 | |
@@ -99,23 +99,23 @@ discard block |
||
99 | 99 | * @param Object $object Object we need next value for |
100 | 100 | * @return string Value if KO, <0 if KO |
101 | 101 | */ |
102 | - function getNextValue($objsoc,$object) |
|
102 | + function getNextValue($objsoc, $object) |
|
103 | 103 | { |
104 | - global $db,$conf; |
|
104 | + global $db, $conf; |
|
105 | 105 | |
106 | 106 | // D'abord on recupere la valeur max |
107 | - $posindice=9; |
|
107 | + $posindice = 9; |
|
108 | 108 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
109 | - $sql.= " FROM ".MAIN_DB_PREFIX."paiement"; |
|
110 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
111 | - $sql.= " AND entity = ".$conf->entity; |
|
109 | + $sql .= " FROM ".MAIN_DB_PREFIX."paiement"; |
|
110 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
111 | + $sql .= " AND entity = ".$conf->entity; |
|
112 | 112 | |
113 | - $resql=$db->query($sql); |
|
113 | + $resql = $db->query($sql); |
|
114 | 114 | if ($resql) |
115 | 115 | { |
116 | 116 | $obj = $db->fetch_object($resql); |
117 | 117 | if ($obj) $max = intval($obj->max); |
118 | - else $max=0; |
|
118 | + else $max = 0; |
|
119 | 119 | } |
120 | 120 | else |
121 | 121 | { |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | //$date=time(); |
127 | - $date=$object->datepaye; |
|
128 | - $yymm = strftime("%y%m",$date); |
|
127 | + $date = $object->datepaye; |
|
128 | + $yymm = strftime("%y%m", $date); |
|
129 | 129 | |
130 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
131 | - else $num = sprintf("%04s",$max+1); |
|
130 | + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
131 | + else $num = sprintf("%04s", $max + 1); |
|
132 | 132 | |
133 | 133 | dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
134 | 134 | return $this->prefix.$yymm."-".$num; |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | * @param string $objforref Object for number to search |
143 | 143 | * @return string Next free value |
144 | 144 | */ |
145 | - function payment_get_num($objsoc,$objforref) |
|
145 | + function payment_get_num($objsoc, $objforref) |
|
146 | 146 | { |
147 | - return $this->getNextValue($objsoc,$objforref); |
|
147 | + return $this->getNextValue($objsoc, $objforref); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | } |
@@ -143,7 +143,7 @@ |
||
143 | 143 | /** |
144 | 144 | * Return next reference not yet used as a reference |
145 | 145 | * |
146 | - * @param Societe $objsoc Object third party |
|
146 | + * @param integer $objsoc Object third party |
|
147 | 147 | * @param Task $object Object task |
148 | 148 | * @return string Next not used reference |
149 | 149 | */ |
@@ -87,8 +87,7 @@ discard block |
||
87 | 87 | if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
88 | 88 | { |
89 | 89 | return true; |
90 | - } |
|
91 | - else |
|
90 | + } else |
|
92 | 91 | { |
93 | 92 | $langs->load("errors"); |
94 | 93 | $this->error=$langs->trans('ErrorNumRefModel',$max); |
@@ -118,10 +117,12 @@ discard block |
||
118 | 117 | if ($resql) |
119 | 118 | { |
120 | 119 | $obj = $db->fetch_object($resql); |
121 | - if ($obj) $max = intval($obj->max); |
|
122 | - else $max=0; |
|
123 | - } |
|
124 | - else |
|
120 | + if ($obj) { |
|
121 | + $max = intval($obj->max); |
|
122 | + } else { |
|
123 | + $max=0; |
|
124 | + } |
|
125 | + } else |
|
125 | 126 | { |
126 | 127 | dol_syslog("mod_task_simple::getNextValue", LOG_DEBUG); |
127 | 128 | return -1; |
@@ -132,8 +133,13 @@ discard block |
||
132 | 133 | //$yymm = strftime("%y%m",time()); |
133 | 134 | $yymm = strftime("%y%m",$date); |
134 | 135 | |
135 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
136 | - else $num = sprintf("%04s",$max+1); |
|
136 | + if ($max >= (pow(10, 4) - 1)) { |
|
137 | + $num=$max+1; |
|
138 | + } |
|
139 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
140 | + else { |
|
141 | + $num = sprintf("%04s",$max+1); |
|
142 | + } |
|
137 | 143 | |
138 | 144 | dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num); |
139 | 145 | return $this->prefix.$yymm."-".$num; |
@@ -33,44 +33,44 @@ discard block |
||
33 | 33 | { |
34 | 34 | var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
35 | 35 | var $prefix='TK'; |
36 | - var $error=''; |
|
36 | + var $error=''; |
|
37 | 37 | var $nom = "Simple"; |
38 | 38 | var $name = "Simple"; |
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * Return description of numbering module |
|
43 | - * |
|
44 | - * @return string Text with description |
|
45 | - */ |
|
46 | - function info() |
|
47 | - { |
|
48 | - global $langs; |
|
49 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * Return an example of numbering module values |
|
55 | - * |
|
56 | - * @return string Example |
|
57 | - */ |
|
58 | - function getExample() |
|
59 | - { |
|
60 | - return $this->prefix."0501-0001"; |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - /** Test si les numeros deja en vigueur dans la base ne provoquent pas de |
|
65 | - * de conflits qui empechera cette numerotation de fonctionner. |
|
66 | - * |
|
67 | - * @return boolean false si conflit, true si ok |
|
68 | - */ |
|
69 | - function canBeActivated() |
|
70 | - { |
|
71 | - global $conf,$langs,$db; |
|
72 | - |
|
73 | - $coyymm=''; $max=''; |
|
41 | + /** |
|
42 | + * Return description of numbering module |
|
43 | + * |
|
44 | + * @return string Text with description |
|
45 | + */ |
|
46 | + function info() |
|
47 | + { |
|
48 | + global $langs; |
|
49 | + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * Return an example of numbering module values |
|
55 | + * |
|
56 | + * @return string Example |
|
57 | + */ |
|
58 | + function getExample() |
|
59 | + { |
|
60 | + return $this->prefix."0501-0001"; |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + /** Test si les numeros deja en vigueur dans la base ne provoquent pas de |
|
65 | + * de conflits qui empechera cette numerotation de fonctionner. |
|
66 | + * |
|
67 | + * @return boolean false si conflit, true si ok |
|
68 | + */ |
|
69 | + function canBeActivated() |
|
70 | + { |
|
71 | + global $conf,$langs,$db; |
|
72 | + |
|
73 | + $coyymm=''; $max=''; |
|
74 | 74 | |
75 | 75 | $posindice=8; |
76 | 76 | $sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM " . $posindice . ") AS SIGNED)) as max"; |
@@ -78,34 +78,34 @@ discard block |
||
78 | 78 | $sql .= MAIN_DB_PREFIX . "projet AS project WHERE task.fk_projet=project.rowid"; |
79 | 79 | $sql .= " AND task.ref LIKE '" . $db->escape($this->prefix) . "____-%'"; |
80 | 80 | $sql .= " AND project.entity = " . $conf->entity; |
81 | - $resql=$db->query($sql); |
|
82 | - if ($resql) |
|
83 | - { |
|
84 | - $row = $db->fetch_row($resql); |
|
85 | - if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
86 | - } |
|
87 | - if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
88 | - { |
|
89 | - return true; |
|
90 | - } |
|
91 | - else |
|
92 | - { |
|
81 | + $resql=$db->query($sql); |
|
82 | + if ($resql) |
|
83 | + { |
|
84 | + $row = $db->fetch_row($resql); |
|
85 | + if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
86 | + } |
|
87 | + if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
88 | + { |
|
89 | + return true; |
|
90 | + } |
|
91 | + else |
|
92 | + { |
|
93 | 93 | $langs->load("errors"); |
94 | 94 | $this->error=$langs->trans('ErrorNumRefModel',$max); |
95 | - return false; |
|
96 | - } |
|
97 | - } |
|
95 | + return false; |
|
96 | + } |
|
97 | + } |
|
98 | 98 | |
99 | 99 | |
100 | 100 | /** |
101 | - * Return next value |
|
102 | - * |
|
103 | - * @param Societe $objsoc Object third party |
|
104 | - * @param Task $object Object Task |
|
105 | - * @return string Value if OK, 0 if KO |
|
106 | - */ |
|
107 | - function getNextValue($objsoc,$object) |
|
108 | - { |
|
101 | + * Return next value |
|
102 | + * |
|
103 | + * @param Societe $objsoc Object third party |
|
104 | + * @param Task $object Object Task |
|
105 | + * @return string Value if OK, 0 if KO |
|
106 | + */ |
|
107 | + function getNextValue($objsoc,$object) |
|
108 | + { |
|
109 | 109 | global $db,$conf; |
110 | 110 | |
111 | 111 | // D'abord on recupere la valeur max |
@@ -137,19 +137,19 @@ discard block |
||
137 | 137 | |
138 | 138 | dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num); |
139 | 139 | return $this->prefix.$yymm."-".$num; |
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * Return next reference not yet used as a reference |
|
145 | - * |
|
146 | - * @param Societe $objsoc Object third party |
|
147 | - * @param Task $object Object task |
|
148 | - * @return string Next not used reference |
|
149 | - */ |
|
150 | - function task_get_num($objsoc=0,$object='') |
|
151 | - { |
|
152 | - return $this->getNextValue($objsoc,$object); |
|
153 | - } |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * Return next reference not yet used as a reference |
|
145 | + * |
|
146 | + * @param Societe $objsoc Object third party |
|
147 | + * @param Task $object Object task |
|
148 | + * @return string Next not used reference |
|
149 | + */ |
|
150 | + function task_get_num($objsoc=0,$object='') |
|
151 | + { |
|
152 | + return $this->getNextValue($objsoc,$object); |
|
153 | + } |
|
154 | 154 | } |
155 | 155 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \brief File with class to manage the numbering module Simple for project references |
24 | 24 | */ |
25 | 25 | |
26 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/project/task/modules_task.php'; |
|
26 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php'; |
|
27 | 27 | |
28 | 28 | |
29 | 29 | /** |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class mod_task_simple extends ModeleNumRefTask |
33 | 33 | { |
34 | - var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
35 | - var $prefix='TK'; |
|
36 | - var $error=''; |
|
34 | + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
35 | + var $prefix = 'TK'; |
|
36 | + var $error = ''; |
|
37 | 37 | var $nom = "Simple"; |
38 | 38 | var $name = "Simple"; |
39 | 39 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | function info() |
47 | 47 | { |
48 | 48 | global $langs; |
49 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
49 | + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
@@ -68,30 +68,30 @@ discard block |
||
68 | 68 | */ |
69 | 69 | function canBeActivated() |
70 | 70 | { |
71 | - global $conf,$langs,$db; |
|
71 | + global $conf, $langs, $db; |
|
72 | 72 | |
73 | - $coyymm=''; $max=''; |
|
73 | + $coyymm = ''; $max = ''; |
|
74 | 74 | |
75 | - $posindice=8; |
|
76 | - $sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM " . $posindice . ") AS SIGNED)) as max"; |
|
77 | - $sql .= " FROM " . MAIN_DB_PREFIX . "projet_task AS task, "; |
|
78 | - $sql .= MAIN_DB_PREFIX . "projet AS project WHERE task.fk_projet=project.rowid"; |
|
79 | - $sql .= " AND task.ref LIKE '" . $db->escape($this->prefix) . "____-%'"; |
|
80 | - $sql .= " AND project.entity = " . $conf->entity; |
|
81 | - $resql=$db->query($sql); |
|
75 | + $posindice = 8; |
|
76 | + $sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
77 | + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task AS task, "; |
|
78 | + $sql .= MAIN_DB_PREFIX."projet AS project WHERE task.fk_projet=project.rowid"; |
|
79 | + $sql .= " AND task.ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
80 | + $sql .= " AND project.entity = ".$conf->entity; |
|
81 | + $resql = $db->query($sql); |
|
82 | 82 | if ($resql) |
83 | 83 | { |
84 | 84 | $row = $db->fetch_row($resql); |
85 | - if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
85 | + if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
86 | 86 | } |
87 | - if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
87 | + if (!$coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) |
|
88 | 88 | { |
89 | 89 | return true; |
90 | 90 | } |
91 | 91 | else |
92 | 92 | { |
93 | 93 | $langs->load("errors"); |
94 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
94 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
95 | 95 | return false; |
96 | 96 | } |
97 | 97 | } |
@@ -104,22 +104,22 @@ discard block |
||
104 | 104 | * @param Task $object Object Task |
105 | 105 | * @return string Value if OK, 0 if KO |
106 | 106 | */ |
107 | - function getNextValue($objsoc,$object) |
|
107 | + function getNextValue($objsoc, $object) |
|
108 | 108 | { |
109 | - global $db,$conf; |
|
109 | + global $db, $conf; |
|
110 | 110 | |
111 | 111 | // D'abord on recupere la valeur max |
112 | - $posindice=8; |
|
112 | + $posindice = 8; |
|
113 | 113 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
114 | - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task"; |
|
115 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
114 | + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task"; |
|
115 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
116 | 116 | |
117 | - $resql=$db->query($sql); |
|
117 | + $resql = $db->query($sql); |
|
118 | 118 | if ($resql) |
119 | 119 | { |
120 | 120 | $obj = $db->fetch_object($resql); |
121 | 121 | if ($obj) $max = intval($obj->max); |
122 | - else $max=0; |
|
122 | + else $max = 0; |
|
123 | 123 | } |
124 | 124 | else |
125 | 125 | { |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | return -1; |
128 | 128 | } |
129 | 129 | |
130 | - $date=empty($object->date_c)?dol_now():$object->date_c; |
|
130 | + $date = empty($object->date_c) ?dol_now() : $object->date_c; |
|
131 | 131 | |
132 | 132 | //$yymm = strftime("%y%m",time()); |
133 | - $yymm = strftime("%y%m",$date); |
|
133 | + $yymm = strftime("%y%m", $date); |
|
134 | 134 | |
135 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
136 | - else $num = sprintf("%04s",$max+1); |
|
135 | + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
136 | + else $num = sprintf("%04s", $max + 1); |
|
137 | 137 | |
138 | 138 | dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num); |
139 | 139 | return $this->prefix.$yymm."-".$num; |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | * @param Task $object Object task |
148 | 148 | * @return string Next not used reference |
149 | 149 | */ |
150 | - function task_get_num($objsoc=0,$object='') |
|
150 | + function task_get_num($objsoc = 0, $object = '') |
|
151 | 151 | { |
152 | - return $this->getNextValue($objsoc,$object); |
|
152 | + return $this->getNextValue($objsoc, $object); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 |
@@ -130,7 +130,7 @@ |
||
130 | 130 | /** |
131 | 131 | * Return next reference not yet used as a reference |
132 | 132 | * |
133 | - * @param Societe $objsoc Object third party |
|
133 | + * @param integer $objsoc Object third party |
|
134 | 134 | * @param Task $object Object task |
135 | 135 | * @return string Next not used reference |
136 | 136 | */ |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | var $name = 'Universal'; |
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Renvoi la description du modele de numerotation |
|
41 | - * |
|
42 | - * @return string Texte descripif |
|
43 | - */ |
|
39 | + /** |
|
40 | + * Renvoi la description du modele de numerotation |
|
41 | + * |
|
42 | + * @return string Texte descripif |
|
43 | + */ |
|
44 | 44 | function info() |
45 | - { |
|
46 | - global $conf,$langs; |
|
45 | + { |
|
46 | + global $conf,$langs; |
|
47 | 47 | |
48 | 48 | $langs->load("projects"); |
49 | 49 | $langs->load("admin"); |
@@ -75,20 +75,20 @@ discard block |
||
75 | 75 | $texte.= '</form>'; |
76 | 76 | |
77 | 77 | return $texte; |
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Renvoi un exemple de numerotation |
|
82 | - * |
|
83 | - * @return string Example |
|
84 | - */ |
|
85 | - function getExample() |
|
86 | - { |
|
87 | - global $conf,$langs,$mysoc; |
|
88 | - |
|
89 | - $old_code_client=$mysoc->code_client; |
|
90 | - $mysoc->code_client='CCCCCCCCCC'; |
|
91 | - $numExample = $this->getNextValue($mysoc,''); |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Renvoi un exemple de numerotation |
|
82 | + * |
|
83 | + * @return string Example |
|
84 | + */ |
|
85 | + function getExample() |
|
86 | + { |
|
87 | + global $conf,$langs,$mysoc; |
|
88 | + |
|
89 | + $old_code_client=$mysoc->code_client; |
|
90 | + $mysoc->code_client='CCCCCCCCCC'; |
|
91 | + $numExample = $this->getNextValue($mysoc,''); |
|
92 | 92 | $mysoc->code_client=$old_code_client; |
93 | 93 | |
94 | 94 | if (! $numExample) |
@@ -96,17 +96,17 @@ discard block |
||
96 | 96 | $numExample = $langs->trans('NotConfigured'); |
97 | 97 | } |
98 | 98 | return $numExample; |
99 | - } |
|
99 | + } |
|
100 | 100 | |
101 | 101 | /** |
102 | - * Return next value |
|
103 | - * |
|
104 | - * @param Societe $objsoc Object third party |
|
105 | - * @param Task $object Object task |
|
106 | - * @return string Value if OK, 0 if KO |
|
107 | - */ |
|
108 | - function getNextValue($objsoc,$object) |
|
109 | - { |
|
102 | + * Return next value |
|
103 | + * |
|
104 | + * @param Societe $objsoc Object third party |
|
105 | + * @param Task $object Object task |
|
106 | + * @return string Value if OK, 0 if KO |
|
107 | + */ |
|
108 | + function getNextValue($objsoc,$object) |
|
109 | + { |
|
110 | 110 | global $db,$conf; |
111 | 111 | |
112 | 112 | require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
@@ -127,16 +127,16 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | |
130 | - /** |
|
131 | - * Return next reference not yet used as a reference |
|
132 | - * |
|
133 | - * @param Societe $objsoc Object third party |
|
134 | - * @param Task $object Object task |
|
135 | - * @return string Next not used reference |
|
136 | - */ |
|
137 | - function project_get_num($objsoc=0,$object='') |
|
138 | - { |
|
139 | - return $this->getNextValue($objsoc,$object); |
|
140 | - } |
|
130 | + /** |
|
131 | + * Return next reference not yet used as a reference |
|
132 | + * |
|
133 | + * @param Societe $objsoc Object third party |
|
134 | + * @param Task $object Object task |
|
135 | + * @return string Next not used reference |
|
136 | + */ |
|
137 | + function project_get_num($objsoc=0,$object='') |
|
138 | + { |
|
139 | + return $this->getNextValue($objsoc,$object); |
|
140 | + } |
|
141 | 141 | } |
142 | 142 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief Fichier contenant la classe du modele de numerotation de reference de projet Universal |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/project/task/modules_task.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php'; |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class mod_task_universal extends ModeleNumRefTask |
32 | 32 | { |
33 | - var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
33 | + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
34 | 34 | var $error = ''; |
35 | 35 | var $nom = 'Universal'; |
36 | 36 | var $name = 'Universal'; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | function info() |
45 | 45 | { |
46 | - global $conf,$langs; |
|
46 | + global $conf, $langs; |
|
47 | 47 | |
48 | 48 | $langs->load("projects"); |
49 | 49 | $langs->load("admin"); |
@@ -51,28 +51,28 @@ discard block |
||
51 | 51 | $form = new Form($this->db); |
52 | 52 | |
53 | 53 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
54 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
55 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
56 | - $texte.= '<input type="hidden" name="action" value="updateMaskTask">'; |
|
57 | - $texte.= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">'; |
|
58 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
59 | - |
|
60 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Task"),$langs->transnoentities("Task")); |
|
61 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
62 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
63 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Task"),$langs->transnoentities("Task")); |
|
64 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
54 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
55 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
56 | + $texte .= '<input type="hidden" name="action" value="updateMaskTask">'; |
|
57 | + $texte .= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">'; |
|
58 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
59 | + |
|
60 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Task"), $langs->transnoentities("Task")); |
|
61 | + $tooltip .= $langs->trans("GenericMaskCodes2"); |
|
62 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
63 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Task"), $langs->transnoentities("Task")); |
|
64 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
65 | 65 | |
66 | 66 | // Parametrage du prefix |
67 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
68 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masktask" value="'.$conf->global->PROJECT_TASK_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>'; |
|
67 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
68 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masktask" value="'.$conf->global->PROJECT_TASK_UNIVERSAL_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
69 | 69 | |
70 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
70 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
71 | 71 | |
72 | - $texte.= '</tr>'; |
|
72 | + $texte .= '</tr>'; |
|
73 | 73 | |
74 | - $texte.= '</table>'; |
|
75 | - $texte.= '</form>'; |
|
74 | + $texte .= '</table>'; |
|
75 | + $texte .= '</form>'; |
|
76 | 76 | |
77 | 77 | return $texte; |
78 | 78 | } |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | */ |
85 | 85 | function getExample() |
86 | 86 | { |
87 | - global $conf,$langs,$mysoc; |
|
87 | + global $conf, $langs, $mysoc; |
|
88 | 88 | |
89 | - $old_code_client=$mysoc->code_client; |
|
90 | - $mysoc->code_client='CCCCCCCCCC'; |
|
91 | - $numExample = $this->getNextValue($mysoc,''); |
|
92 | - $mysoc->code_client=$old_code_client; |
|
89 | + $old_code_client = $mysoc->code_client; |
|
90 | + $mysoc->code_client = 'CCCCCCCCCC'; |
|
91 | + $numExample = $this->getNextValue($mysoc, ''); |
|
92 | + $mysoc->code_client = $old_code_client; |
|
93 | 93 | |
94 | - if (! $numExample) |
|
94 | + if (!$numExample) |
|
95 | 95 | { |
96 | 96 | $numExample = $langs->trans('NotConfigured'); |
97 | 97 | } |
@@ -105,23 +105,23 @@ discard block |
||
105 | 105 | * @param Task $object Object task |
106 | 106 | * @return string Value if OK, 0 if KO |
107 | 107 | */ |
108 | - function getNextValue($objsoc,$object) |
|
108 | + function getNextValue($objsoc, $object) |
|
109 | 109 | { |
110 | - global $db,$conf; |
|
110 | + global $db, $conf; |
|
111 | 111 | |
112 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
112 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
113 | 113 | |
114 | 114 | // On defini critere recherche compteur |
115 | - $mask=$conf->global->PROJECT_TASK_UNIVERSAL_MASK; |
|
115 | + $mask = $conf->global->PROJECT_TASK_UNIVERSAL_MASK; |
|
116 | 116 | |
117 | - if (! $mask) |
|
117 | + if (!$mask) |
|
118 | 118 | { |
119 | - $this->error='NotConfigured'; |
|
119 | + $this->error = 'NotConfigured'; |
|
120 | 120 | return 0; |
121 | 121 | } |
122 | 122 | |
123 | - $date=empty($object->date_c)?dol_now():$object->date_c; |
|
124 | - $numFinal=get_next_value($db,$mask,'projet_task','ref','',(is_object($objsoc)?$objsoc->code_client:''),$date); |
|
123 | + $date = empty($object->date_c) ?dol_now() : $object->date_c; |
|
124 | + $numFinal = get_next_value($db, $mask, 'projet_task', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date); |
|
125 | 125 | |
126 | 126 | return $numFinal; |
127 | 127 | } |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | * @param Task $object Object task |
135 | 135 | * @return string Next not used reference |
136 | 136 | */ |
137 | - function project_get_num($objsoc=0,$object='') |
|
137 | + function project_get_num($objsoc = 0, $object = '') |
|
138 | 138 | { |
139 | - return $this->getNextValue($objsoc,$object); |
|
139 | + return $this->getNextValue($objsoc, $object); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 |
@@ -100,7 +100,7 @@ |
||
100 | 100 | * Return next free value |
101 | 101 | * |
102 | 102 | * @param Societe $objsoc Object thirdparty |
103 | - * @param Object $object Object we need next value for |
|
103 | + * @param string $object Object we need next value for |
|
104 | 104 | * @return string Value if KO, <0 if KO |
105 | 105 | */ |
106 | 106 | function getNextValue($objsoc,$object) |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | var $nom = 'Brodator'; |
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * Renvoi la description du modele de numerotation |
|
40 | - * |
|
41 | - * @return string Texte descripif |
|
42 | - */ |
|
38 | + /** |
|
39 | + * Renvoi la description du modele de numerotation |
|
40 | + * |
|
41 | + * @return string Texte descripif |
|
42 | + */ |
|
43 | 43 | function info() |
44 | - { |
|
45 | - global $conf,$langs; |
|
44 | + { |
|
45 | + global $conf,$langs; |
|
46 | 46 | |
47 | 47 | $langs->load("bills"); |
48 | 48 | |
@@ -73,20 +73,20 @@ discard block |
||
73 | 73 | $texte.= '</form>'; |
74 | 74 | |
75 | 75 | return $texte; |
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Renvoi un exemple de numerotation |
|
80 | - * |
|
81 | - * @return string Example |
|
82 | - */ |
|
83 | - function getExample() |
|
84 | - { |
|
85 | - global $conf,$langs,$mysoc; |
|
86 | - |
|
87 | - $old_code_client=$mysoc->code_client; |
|
88 | - $mysoc->code_client='CCCCCCCCCC'; |
|
89 | - $numExample = $this->getNextValue($mysoc,''); |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Renvoi un exemple de numerotation |
|
80 | + * |
|
81 | + * @return string Example |
|
82 | + */ |
|
83 | + function getExample() |
|
84 | + { |
|
85 | + global $conf,$langs,$mysoc; |
|
86 | + |
|
87 | + $old_code_client=$mysoc->code_client; |
|
88 | + $mysoc->code_client='CCCCCCCCCC'; |
|
89 | + $numExample = $this->getNextValue($mysoc,''); |
|
90 | 90 | $mysoc->code_client=$old_code_client; |
91 | 91 | |
92 | 92 | if (! $numExample) |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $numExample = $langs->trans('NotConfigured'); |
95 | 95 | } |
96 | 96 | return $numExample; |
97 | - } |
|
97 | + } |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Return next free value |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | * @param Object $object Object we need next value for |
104 | 104 | * @return string Value if KO, <0 if KO |
105 | 105 | */ |
106 | - function getNextValue($objsoc,$object) |
|
107 | - { |
|
106 | + function getNextValue($objsoc,$object) |
|
107 | + { |
|
108 | 108 | global $db,$conf; |
109 | 109 | |
110 | 110 | require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | * @param Societe $objsoc Object third party |
131 | 131 | * @param string $objforref Object for number to search |
132 | 132 | * @return string Next free value |
133 | - */ |
|
134 | - function commande_get_num($objsoc,$objforref) |
|
135 | - { |
|
136 | - return $this->getNextValue($objsoc,$objforref); |
|
137 | - } |
|
133 | + */ |
|
134 | + function commande_get_num($objsoc,$objforref) |
|
135 | + { |
|
136 | + return $this->getNextValue($objsoc,$objforref); |
|
137 | + } |
|
138 | 138 | |
139 | 139 | } |
140 | 140 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief File containing class for numbering module Brodator |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_payment/modules_supplier_payment.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_payment/modules_supplier_payment.php'; |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments |
32 | 32 | { |
33 | - var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
33 | + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
34 | 34 | var $error = ''; |
35 | 35 | var $nom = 'Brodator'; |
36 | 36 | |
@@ -42,35 +42,35 @@ discard block |
||
42 | 42 | */ |
43 | 43 | function info() |
44 | 44 | { |
45 | - global $conf,$langs; |
|
45 | + global $conf, $langs; |
|
46 | 46 | |
47 | 47 | $langs->load("bills"); |
48 | 48 | |
49 | 49 | $form = new Form($this->db); |
50 | 50 | |
51 | 51 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
52 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
53 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
54 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
55 | - $texte.= '<input type="hidden" name="maskconstsupplierpayment" value="SUPPLIER_PAYMENT_BRODATOR_MASK">'; |
|
56 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
57 | - |
|
58 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
59 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
60 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
61 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
62 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
52 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
53 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
54 | + $texte .= '<input type="hidden" name="action" value="updateMask">'; |
|
55 | + $texte .= '<input type="hidden" name="maskconstsupplierpayment" value="SUPPLIER_PAYMENT_BRODATOR_MASK">'; |
|
56 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
57 | + |
|
58 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Order"), $langs->transnoentities("Order")); |
|
59 | + $tooltip .= $langs->trans("GenericMaskCodes2"); |
|
60 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
61 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Order"), $langs->transnoentities("Order")); |
|
62 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
63 | 63 | |
64 | 64 | // Parametrage du prefix |
65 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
66 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masksupplierpayment" value="'.$conf->global->SUPPLIER_PAYMENT_BRODATOR_MASK.'">',$tooltip,1,1).'</td>'; |
|
65 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
66 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masksupplierpayment" value="'.$conf->global->SUPPLIER_PAYMENT_BRODATOR_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
67 | 67 | |
68 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
68 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
69 | 69 | |
70 | - $texte.= '</tr>'; |
|
70 | + $texte .= '</tr>'; |
|
71 | 71 | |
72 | - $texte.= '</table>'; |
|
73 | - $texte.= '</form>'; |
|
72 | + $texte .= '</table>'; |
|
73 | + $texte .= '</form>'; |
|
74 | 74 | |
75 | 75 | return $texte; |
76 | 76 | } |
@@ -82,14 +82,14 @@ discard block |
||
82 | 82 | */ |
83 | 83 | function getExample() |
84 | 84 | { |
85 | - global $conf,$langs,$mysoc; |
|
85 | + global $conf, $langs, $mysoc; |
|
86 | 86 | |
87 | - $old_code_client=$mysoc->code_client; |
|
88 | - $mysoc->code_client='CCCCCCCCCC'; |
|
89 | - $numExample = $this->getNextValue($mysoc,''); |
|
90 | - $mysoc->code_client=$old_code_client; |
|
87 | + $old_code_client = $mysoc->code_client; |
|
88 | + $mysoc->code_client = 'CCCCCCCCCC'; |
|
89 | + $numExample = $this->getNextValue($mysoc, ''); |
|
90 | + $mysoc->code_client = $old_code_client; |
|
91 | 91 | |
92 | - if (! $numExample) |
|
92 | + if (!$numExample) |
|
93 | 93 | { |
94 | 94 | $numExample = $langs->trans('NotConfigured'); |
95 | 95 | } |
@@ -103,22 +103,22 @@ discard block |
||
103 | 103 | * @param Object $object Object we need next value for |
104 | 104 | * @return string Value if KO, <0 if KO |
105 | 105 | */ |
106 | - function getNextValue($objsoc,$object) |
|
106 | + function getNextValue($objsoc, $object) |
|
107 | 107 | { |
108 | - global $db,$conf; |
|
108 | + global $db, $conf; |
|
109 | 109 | |
110 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
110 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
111 | 111 | |
112 | 112 | // We get cursor rule |
113 | - $mask=$conf->global->SUPPLIER_PAYMENT_BRODATOR_MASK; |
|
113 | + $mask = $conf->global->SUPPLIER_PAYMENT_BRODATOR_MASK; |
|
114 | 114 | |
115 | - if (! $mask) |
|
115 | + if (!$mask) |
|
116 | 116 | { |
117 | - $this->error='NotConfigured'; |
|
117 | + $this->error = 'NotConfigured'; |
|
118 | 118 | return 0; |
119 | 119 | } |
120 | 120 | |
121 | - $numFinal=get_next_value($db,$mask,'paiementfourn','ref','',$objsoc,$object->datepaye); |
|
121 | + $numFinal = get_next_value($db, $mask, 'paiementfourn', 'ref', '', $objsoc, $object->datepaye); |
|
122 | 122 | |
123 | 123 | return $numFinal; |
124 | 124 | } |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | * @param string $objforref Object for number to search |
132 | 132 | * @return string Next free value |
133 | 133 | */ |
134 | - function commande_get_num($objsoc,$objforref) |
|
134 | + function commande_get_num($objsoc, $objforref) |
|
135 | 135 | { |
136 | - return $this->getNextValue($objsoc,$objforref); |
|
136 | + return $this->getNextValue($objsoc, $objforref); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | } |
@@ -96,7 +96,7 @@ |
||
96 | 96 | * Return next free value |
97 | 97 | * |
98 | 98 | * @param Societe $objsoc Object thirdparty |
99 | - * @param Object $object Object we need next value for |
|
99 | + * @param string $object Object we need next value for |
|
100 | 100 | * @return string Value if KO, <0 if KO |
101 | 101 | */ |
102 | 102 | function getNextValue($objsoc,$object) |
@@ -35,16 +35,16 @@ discard block |
||
35 | 35 | var $nom='Bronan'; |
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * Return description of numbering module |
|
40 | - * |
|
41 | - * @return string Text with description |
|
42 | - */ |
|
43 | - function info() |
|
44 | - { |
|
45 | - global $langs; |
|
46 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
47 | - } |
|
38 | + /** |
|
39 | + * Return description of numbering module |
|
40 | + * |
|
41 | + * @return string Text with description |
|
42 | + */ |
|
43 | + function info() |
|
44 | + { |
|
45 | + global $langs; |
|
46 | + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | 50 | /** |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | $date=$object->datepaye; |
128 | 128 | $yymm = strftime("%y%m",$date); |
129 | 129 | |
130 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
131 | - else $num = sprintf("%04s",$max+1); |
|
130 | + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
131 | + else $num = sprintf("%04s",$max+1); |
|
132 | 132 | |
133 | 133 | dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
134 | 134 | return $this->prefix.$yymm."-".$num; |
@@ -114,10 +114,12 @@ discard block |
||
114 | 114 | if ($resql) |
115 | 115 | { |
116 | 116 | $obj = $db->fetch_object($resql); |
117 | - if ($obj) $max = intval($obj->max); |
|
118 | - else $max=0; |
|
119 | - } |
|
120 | - else |
|
117 | + if ($obj) { |
|
118 | + $max = intval($obj->max); |
|
119 | + } else { |
|
120 | + $max=0; |
|
121 | + } |
|
122 | + } else |
|
121 | 123 | { |
122 | 124 | dol_syslog(__METHOD__, LOG_DEBUG); |
123 | 125 | return -1; |
@@ -127,8 +129,13 @@ discard block |
||
127 | 129 | $date=$object->datepaye; |
128 | 130 | $yymm = strftime("%y%m",$date); |
129 | 131 | |
130 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
131 | - else $num = sprintf("%04s",$max+1); |
|
132 | + if ($max >= (pow(10, 4) - 1)) { |
|
133 | + $num=$max+1; |
|
134 | + } |
|
135 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
136 | + else { |
|
137 | + $num = sprintf("%04s",$max+1); |
|
138 | + } |
|
132 | 139 | |
133 | 140 | dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
134 | 141 | return $this->prefix.$yymm."-".$num; |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | * \brief File containing class for numbering module Bronan |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_payment/modules_supplier_payment.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_payment/modules_supplier_payment.php'; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Class to manage customer payment numbering rules Cicada |
29 | 29 | */ |
30 | 30 | class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments |
31 | 31 | { |
32 | - var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
33 | - var $prefix='SPAY'; |
|
34 | - var $error=''; |
|
35 | - var $nom='Bronan'; |
|
32 | + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
33 | + var $prefix = 'SPAY'; |
|
34 | + var $error = ''; |
|
35 | + var $nom = 'Bronan'; |
|
36 | 36 | |
37 | 37 | |
38 | 38 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | function info() |
44 | 44 | { |
45 | 45 | global $langs; |
46 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
46 | + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
@@ -66,26 +66,26 @@ discard block |
||
66 | 66 | */ |
67 | 67 | function canBeActivated() |
68 | 68 | { |
69 | - global $conf,$langs,$db; |
|
69 | + global $conf, $langs, $db; |
|
70 | 70 | |
71 | - $payyymm=''; $max=''; |
|
71 | + $payyymm = ''; $max = ''; |
|
72 | 72 | |
73 | - $posindice=9; |
|
73 | + $posindice = 9; |
|
74 | 74 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
75 | - $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn"; |
|
76 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
77 | - $sql.= " AND entity = ".$conf->entity; |
|
75 | + $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn"; |
|
76 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
77 | + $sql .= " AND entity = ".$conf->entity; |
|
78 | 78 | |
79 | - $resql=$db->query($sql); |
|
79 | + $resql = $db->query($sql); |
|
80 | 80 | if ($resql) |
81 | 81 | { |
82 | 82 | $row = $db->fetch_row($resql); |
83 | - if ($row) { $payyymm = substr($row[0],0,6); $max=$row[0]; } |
|
83 | + if ($row) { $payyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
84 | 84 | } |
85 | - if ($payyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$payyymm)) |
|
85 | + if ($payyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $payyymm)) |
|
86 | 86 | { |
87 | 87 | $langs->load("errors"); |
88 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
88 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
89 | 89 | return false; |
90 | 90 | } |
91 | 91 | |
@@ -99,23 +99,23 @@ discard block |
||
99 | 99 | * @param Object $object Object we need next value for |
100 | 100 | * @return string Value if KO, <0 if KO |
101 | 101 | */ |
102 | - function getNextValue($objsoc,$object) |
|
102 | + function getNextValue($objsoc, $object) |
|
103 | 103 | { |
104 | - global $db,$conf; |
|
104 | + global $db, $conf; |
|
105 | 105 | |
106 | 106 | // D'abord on recupere la valeur max |
107 | - $posindice=10; |
|
107 | + $posindice = 10; |
|
108 | 108 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
109 | - $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn"; |
|
110 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
111 | - $sql.= " AND entity = ".$conf->entity; |
|
109 | + $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn"; |
|
110 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
111 | + $sql .= " AND entity = ".$conf->entity; |
|
112 | 112 | |
113 | - $resql=$db->query($sql); |
|
113 | + $resql = $db->query($sql); |
|
114 | 114 | if ($resql) |
115 | 115 | { |
116 | 116 | $obj = $db->fetch_object($resql); |
117 | 117 | if ($obj) $max = intval($obj->max); |
118 | - else $max=0; |
|
118 | + else $max = 0; |
|
119 | 119 | } |
120 | 120 | else |
121 | 121 | { |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | //$date=time(); |
127 | - $date=$object->datepaye; |
|
128 | - $yymm = strftime("%y%m",$date); |
|
127 | + $date = $object->datepaye; |
|
128 | + $yymm = strftime("%y%m", $date); |
|
129 | 129 | |
130 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
131 | - else $num = sprintf("%04s",$max+1); |
|
130 | + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
131 | + else $num = sprintf("%04s", $max + 1); |
|
132 | 132 | |
133 | 133 | dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
134 | 134 | return $this->prefix.$yymm."-".$num; |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | * @param string $objforref Object for number to search |
143 | 143 | * @return string Next free value |
144 | 144 | */ |
145 | - function payment_get_num($objsoc,$objforref) |
|
145 | + function payment_get_num($objsoc, $objforref) |
|
146 | 146 | { |
147 | - return $this->getNextValue($objsoc,$objforref); |
|
147 | + return $this->getNextValue($objsoc, $objforref); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | * @param string $sortorder Sort order |
91 | 91 | * @param int $limit Limit for list |
92 | 92 | * @param int $page Page number |
93 | - * @param string $user_ids User ids filter field. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i} |
|
93 | + * @param integer $user_ids User ids filter field. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i} |
|
94 | 94 | * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" |
95 | 95 | * @return array Array of Expense Report objects |
96 | 96 | */ |
@@ -29,171 +29,171 @@ discard block |
||
29 | 29 | class ExpenseReports extends DolibarrApi |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * @var array $FIELDS Mandatory fields, checked when create and update object |
|
34 | - */ |
|
35 | - static $FIELDS = array( |
|
36 | - 'socid' |
|
37 | - ); |
|
32 | + /** |
|
33 | + * @var array $FIELDS Mandatory fields, checked when create and update object |
|
34 | + */ |
|
35 | + static $FIELDS = array( |
|
36 | + 'socid' |
|
37 | + ); |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var ExpenseReport $expensereport {@type ExpenseReport} |
|
41 | - */ |
|
42 | - public $expensereport; |
|
39 | + /** |
|
40 | + * @var ExpenseReport $expensereport {@type ExpenseReport} |
|
41 | + */ |
|
42 | + public $expensereport; |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * Constructor |
|
47 | - */ |
|
48 | - function __construct() |
|
49 | - { |
|
45 | + /** |
|
46 | + * Constructor |
|
47 | + */ |
|
48 | + function __construct() |
|
49 | + { |
|
50 | 50 | global $db, $conf; |
51 | 51 | $this->db = $db; |
52 | - $this->expensereport = new ExpenseReport($this->db); |
|
53 | - } |
|
52 | + $this->expensereport = new ExpenseReport($this->db); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Get properties of a Expense Report object |
|
57 | - * |
|
58 | - * Return an array with Expense Report informations |
|
59 | - * |
|
60 | - * @param int $id ID of Expense Report |
|
61 | - * @return array|mixed Data without useless information |
|
55 | + /** |
|
56 | + * Get properties of a Expense Report object |
|
62 | 57 | * |
63 | - * @throws RestException |
|
64 | - */ |
|
65 | - function get($id) |
|
66 | - { |
|
58 | + * Return an array with Expense Report informations |
|
59 | + * |
|
60 | + * @param int $id ID of Expense Report |
|
61 | + * @return array|mixed Data without useless information |
|
62 | + * |
|
63 | + * @throws RestException |
|
64 | + */ |
|
65 | + function get($id) |
|
66 | + { |
|
67 | 67 | if(! DolibarrApiAccess::$user->rights->expensereport->lire) { |
68 | 68 | throw new RestException(401); |
69 | 69 | } |
70 | 70 | |
71 | - $result = $this->expensereport->fetch($id); |
|
72 | - if( ! $result ) { |
|
73 | - throw new RestException(404, 'Expense report not found'); |
|
74 | - } |
|
71 | + $result = $this->expensereport->fetch($id); |
|
72 | + if( ! $result ) { |
|
73 | + throw new RestException(404, 'Expense report not found'); |
|
74 | + } |
|
75 | 75 | |
76 | 76 | if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { |
77 | 77 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
78 | 78 | } |
79 | 79 | |
80 | - $this->expensereport->fetchObjectLinked(); |
|
80 | + $this->expensereport->fetchObjectLinked(); |
|
81 | 81 | return $this->_cleanObjectDatas($this->expensereport); |
82 | - } |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * List Expense Reports |
|
86 | - * |
|
87 | - * Get a list of Expense Reports |
|
88 | - * |
|
89 | - * @param string $sortfield Sort field |
|
90 | - * @param string $sortorder Sort order |
|
91 | - * @param int $limit Limit for list |
|
92 | - * @param int $page Page number |
|
93 | - * @param string $user_ids User ids filter field. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i} |
|
94 | - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" |
|
95 | - * @return array Array of Expense Report objects |
|
96 | - */ |
|
97 | - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $user_ids = 0, $sqlfilters = '') { |
|
98 | - global $db, $conf; |
|
84 | + /** |
|
85 | + * List Expense Reports |
|
86 | + * |
|
87 | + * Get a list of Expense Reports |
|
88 | + * |
|
89 | + * @param string $sortfield Sort field |
|
90 | + * @param string $sortorder Sort order |
|
91 | + * @param int $limit Limit for list |
|
92 | + * @param int $page Page number |
|
93 | + * @param string $user_ids User ids filter field. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i} |
|
94 | + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" |
|
95 | + * @return array Array of Expense Report objects |
|
96 | + */ |
|
97 | + function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $user_ids = 0, $sqlfilters = '') { |
|
98 | + global $db, $conf; |
|
99 | 99 | |
100 | - $obj_ret = array(); |
|
100 | + $obj_ret = array(); |
|
101 | 101 | |
102 | - // case of external user, $societe param is ignored and replaced by user's socid |
|
103 | - //$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $societe; |
|
102 | + // case of external user, $societe param is ignored and replaced by user's socid |
|
103 | + //$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $societe; |
|
104 | 104 | |
105 | - $sql = "SELECT t.rowid"; |
|
106 | - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as t"; |
|
107 | - $sql.= ' WHERE t.entity IN ('.getEntity('expensereport').')'; |
|
108 | - if ($user_ids) $sql.=" AND t.fk_user_author IN (".$user_ids.")"; |
|
105 | + $sql = "SELECT t.rowid"; |
|
106 | + $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as t"; |
|
107 | + $sql.= ' WHERE t.entity IN ('.getEntity('expensereport').')'; |
|
108 | + if ($user_ids) $sql.=" AND t.fk_user_author IN (".$user_ids.")"; |
|
109 | 109 | |
110 | - // Add sql filters |
|
111 | - if ($sqlfilters) |
|
112 | - { |
|
113 | - if (! DolibarrApi::_checkFilters($sqlfilters)) |
|
114 | - { |
|
115 | - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); |
|
116 | - } |
|
117 | - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
118 | - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; |
|
119 | - } |
|
110 | + // Add sql filters |
|
111 | + if ($sqlfilters) |
|
112 | + { |
|
113 | + if (! DolibarrApi::_checkFilters($sqlfilters)) |
|
114 | + { |
|
115 | + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); |
|
116 | + } |
|
117 | + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
118 | + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; |
|
119 | + } |
|
120 | 120 | |
121 | - $sql.= $db->order($sortfield, $sortorder); |
|
122 | - if ($limit) { |
|
123 | - if ($page < 0) |
|
124 | - { |
|
125 | - $page = 0; |
|
126 | - } |
|
127 | - $offset = $limit * $page; |
|
121 | + $sql.= $db->order($sortfield, $sortorder); |
|
122 | + if ($limit) { |
|
123 | + if ($page < 0) |
|
124 | + { |
|
125 | + $page = 0; |
|
126 | + } |
|
127 | + $offset = $limit * $page; |
|
128 | 128 | |
129 | - $sql.= $db->plimit($limit + 1, $offset); |
|
130 | - } |
|
129 | + $sql.= $db->plimit($limit + 1, $offset); |
|
130 | + } |
|
131 | 131 | |
132 | - $result = $db->query($sql); |
|
132 | + $result = $db->query($sql); |
|
133 | 133 | |
134 | - if ($result) |
|
135 | - { |
|
136 | - $num = $db->num_rows($result); |
|
137 | - $min = min($num, ($limit <= 0 ? $num : $limit)); |
|
138 | - while ($i < $min) |
|
139 | - { |
|
140 | - $obj = $db->fetch_object($result); |
|
141 | - $expensereport_static = new ExpenseReport($db); |
|
142 | - if($expensereport_static->fetch($obj->rowid)) { |
|
143 | - $obj_ret[] = $this->_cleanObjectDatas($expensereport_static); |
|
144 | - } |
|
145 | - $i++; |
|
146 | - } |
|
147 | - } |
|
148 | - else { |
|
149 | - throw new RestException(503, 'Error when retrieve Expense Report list : '.$db->lasterror()); |
|
150 | - } |
|
151 | - if( ! count($obj_ret)) { |
|
152 | - throw new RestException(404, 'No Expense Report found'); |
|
153 | - } |
|
134 | + if ($result) |
|
135 | + { |
|
136 | + $num = $db->num_rows($result); |
|
137 | + $min = min($num, ($limit <= 0 ? $num : $limit)); |
|
138 | + while ($i < $min) |
|
139 | + { |
|
140 | + $obj = $db->fetch_object($result); |
|
141 | + $expensereport_static = new ExpenseReport($db); |
|
142 | + if($expensereport_static->fetch($obj->rowid)) { |
|
143 | + $obj_ret[] = $this->_cleanObjectDatas($expensereport_static); |
|
144 | + } |
|
145 | + $i++; |
|
146 | + } |
|
147 | + } |
|
148 | + else { |
|
149 | + throw new RestException(503, 'Error when retrieve Expense Report list : '.$db->lasterror()); |
|
150 | + } |
|
151 | + if( ! count($obj_ret)) { |
|
152 | + throw new RestException(404, 'No Expense Report found'); |
|
153 | + } |
|
154 | 154 | return $obj_ret; |
155 | - } |
|
155 | + } |
|
156 | 156 | |
157 | - /** |
|
158 | - * Create Expense Report object |
|
159 | - * |
|
160 | - * @param array $request_data Request data |
|
161 | - * @return int ID of Expense Report |
|
162 | - */ |
|
163 | - function post($request_data = NULL) |
|
164 | - { |
|
165 | - if(! DolibarrApiAccess::$user->rights->expensereport->creer) { |
|
157 | + /** |
|
158 | + * Create Expense Report object |
|
159 | + * |
|
160 | + * @param array $request_data Request data |
|
161 | + * @return int ID of Expense Report |
|
162 | + */ |
|
163 | + function post($request_data = NULL) |
|
164 | + { |
|
165 | + if(! DolibarrApiAccess::$user->rights->expensereport->creer) { |
|
166 | 166 | throw new RestException(401, "Insuffisant rights"); |
167 | 167 | } |
168 | - // Check mandatory fields |
|
169 | - $result = $this->_validate($request_data); |
|
168 | + // Check mandatory fields |
|
169 | + $result = $this->_validate($request_data); |
|
170 | 170 | |
171 | - foreach($request_data as $field => $value) { |
|
172 | - $this->expensereport->$field = $value; |
|
173 | - } |
|
174 | - /*if (isset($request_data["lines"])) { |
|
171 | + foreach($request_data as $field => $value) { |
|
172 | + $this->expensereport->$field = $value; |
|
173 | + } |
|
174 | + /*if (isset($request_data["lines"])) { |
|
175 | 175 | $lines = array(); |
176 | 176 | foreach ($request_data["lines"] as $line) { |
177 | 177 | array_push($lines, (object) $line); |
178 | 178 | } |
179 | 179 | $this->expensereport->lines = $lines; |
180 | 180 | }*/ |
181 | - if ($this->expensereport->create(DolibarrApiAccess::$user) < 0) { |
|
182 | - throw new RestException(500, "Error creating expensereport", array_merge(array($this->expensereport->error), $this->expensereport->errors)); |
|
183 | - } |
|
181 | + if ($this->expensereport->create(DolibarrApiAccess::$user) < 0) { |
|
182 | + throw new RestException(500, "Error creating expensereport", array_merge(array($this->expensereport->error), $this->expensereport->errors)); |
|
183 | + } |
|
184 | 184 | |
185 | - return $this->expensereport->id; |
|
186 | - } |
|
185 | + return $this->expensereport->id; |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
189 | - * Get lines of an Expense Report |
|
190 | - * |
|
191 | - * @param int $id Id of Expense Report |
|
192 | - * |
|
193 | - * @url GET {id}/lines |
|
194 | - * |
|
195 | - * @return int |
|
196 | - */ |
|
188 | + /** |
|
189 | + * Get lines of an Expense Report |
|
190 | + * |
|
191 | + * @param int $id Id of Expense Report |
|
192 | + * |
|
193 | + * @url GET {id}/lines |
|
194 | + * |
|
195 | + * @return int |
|
196 | + */ |
|
197 | 197 | /* |
198 | 198 | function getLines($id) { |
199 | 199 | if(! DolibarrApiAccess::$user->rights->expensereport->lire) { |
@@ -217,16 +217,16 @@ discard block |
||
217 | 217 | } |
218 | 218 | */ |
219 | 219 | |
220 | - /** |
|
221 | - * Add a line to given Expense Report |
|
222 | - * |
|
223 | - * @param int $id Id of Expense Report to update |
|
224 | - * @param array $request_data Expense Report data |
|
225 | - * |
|
226 | - * @url POST {id}/lines |
|
227 | - * |
|
228 | - * @return int |
|
229 | - */ |
|
220 | + /** |
|
221 | + * Add a line to given Expense Report |
|
222 | + * |
|
223 | + * @param int $id Id of Expense Report to update |
|
224 | + * @param array $request_data Expense Report data |
|
225 | + * |
|
226 | + * @url POST {id}/lines |
|
227 | + * |
|
228 | + * @return int |
|
229 | + */ |
|
230 | 230 | /* |
231 | 231 | function postLine($id, $request_data = NULL) { |
232 | 232 | if(! DolibarrApiAccess::$user->rights->expensereport->creer) { |
@@ -278,18 +278,18 @@ discard block |
||
278 | 278 | } |
279 | 279 | */ |
280 | 280 | |
281 | - /** |
|
282 | - * Update a line to given Expense Report |
|
283 | - * |
|
284 | - * @param int $id Id of Expense Report to update |
|
285 | - * @param int $lineid Id of line to update |
|
286 | - * @param array $request_data Expense Report data |
|
287 | - * |
|
288 | - * @url PUT {id}/lines/{lineid} |
|
289 | - * |
|
290 | - * @return object |
|
291 | - */ |
|
292 | - /* |
|
281 | + /** |
|
282 | + * Update a line to given Expense Report |
|
283 | + * |
|
284 | + * @param int $id Id of Expense Report to update |
|
285 | + * @param int $lineid Id of line to update |
|
286 | + * @param array $request_data Expense Report data |
|
287 | + * |
|
288 | + * @url PUT {id}/lines/{lineid} |
|
289 | + * |
|
290 | + * @return object |
|
291 | + */ |
|
292 | + /* |
|
293 | 293 | function putLine($id, $lineid, $request_data = NULL) { |
294 | 294 | if(! DolibarrApiAccess::$user->rights->expensereport->creer) { |
295 | 295 | throw new RestException(401); |
@@ -337,17 +337,17 @@ discard block |
||
337 | 337 | } |
338 | 338 | */ |
339 | 339 | |
340 | - /** |
|
341 | - * Delete a line of given Expense Report |
|
342 | - * |
|
343 | - * @param int $id Id of Expense Report to update |
|
344 | - * @param int $lineid Id of line to delete |
|
345 | - * |
|
346 | - * @url DELETE {id}/lines/{lineid} |
|
347 | - * |
|
348 | - * @return int |
|
349 | - */ |
|
350 | - /* |
|
340 | + /** |
|
341 | + * Delete a line of given Expense Report |
|
342 | + * |
|
343 | + * @param int $id Id of Expense Report to update |
|
344 | + * @param int $lineid Id of line to delete |
|
345 | + * |
|
346 | + * @url DELETE {id}/lines/{lineid} |
|
347 | + * |
|
348 | + * @return int |
|
349 | + */ |
|
350 | + /* |
|
351 | 351 | function delLine($id, $lineid) { |
352 | 352 | if(! DolibarrApiAccess::$user->rights->expensereport->creer) { |
353 | 353 | throw new RestException(401); |
@@ -370,15 +370,15 @@ discard block |
||
370 | 370 | } |
371 | 371 | */ |
372 | 372 | |
373 | - /** |
|
374 | - * Update Expense Report general fields (won't touch lines of expensereport) |
|
375 | - * |
|
376 | - * @param int $id Id of Expense Report to update |
|
377 | - * @param array $request_data Datas |
|
378 | - * |
|
379 | - * @return int |
|
380 | - */ |
|
381 | - /* |
|
373 | + /** |
|
374 | + * Update Expense Report general fields (won't touch lines of expensereport) |
|
375 | + * |
|
376 | + * @param int $id Id of Expense Report to update |
|
377 | + * @param array $request_data Datas |
|
378 | + * |
|
379 | + * @return int |
|
380 | + */ |
|
381 | + /* |
|
382 | 382 | function put($id, $request_data = NULL) { |
383 | 383 | if(! DolibarrApiAccess::$user->rights->expensereport->creer) { |
384 | 384 | throw new RestException(401); |
@@ -404,56 +404,56 @@ discard block |
||
404 | 404 | } |
405 | 405 | */ |
406 | 406 | |
407 | - /** |
|
408 | - * Delete Expense Report |
|
409 | - * |
|
410 | - * @param int $id Expense Report ID |
|
411 | - * |
|
412 | - * @return array |
|
413 | - */ |
|
414 | - function delete($id) |
|
415 | - { |
|
416 | - if(! DolibarrApiAccess::$user->rights->expensereport->supprimer) { |
|
407 | + /** |
|
408 | + * Delete Expense Report |
|
409 | + * |
|
410 | + * @param int $id Expense Report ID |
|
411 | + * |
|
412 | + * @return array |
|
413 | + */ |
|
414 | + function delete($id) |
|
415 | + { |
|
416 | + if(! DolibarrApiAccess::$user->rights->expensereport->supprimer) { |
|
417 | 417 | throw new RestException(401); |
418 | 418 | } |
419 | - $result = $this->expensereport->fetch($id); |
|
420 | - if( ! $result ) { |
|
421 | - throw new RestException(404, 'Expense Report not found'); |
|
422 | - } |
|
419 | + $result = $this->expensereport->fetch($id); |
|
420 | + if( ! $result ) { |
|
421 | + throw new RestException(404, 'Expense Report not found'); |
|
422 | + } |
|
423 | 423 | |
424 | 424 | if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { |
425 | 425 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
426 | 426 | } |
427 | 427 | |
428 | - if( ! $this->expensereport->delete(DolibarrApiAccess::$user)) { |
|
429 | - throw new RestException(500, 'Error when delete Expense Report : '.$this->expensereport->error); |
|
430 | - } |
|
428 | + if( ! $this->expensereport->delete(DolibarrApiAccess::$user)) { |
|
429 | + throw new RestException(500, 'Error when delete Expense Report : '.$this->expensereport->error); |
|
430 | + } |
|
431 | 431 | |
432 | - return array( |
|
433 | - 'success' => array( |
|
434 | - 'code' => 200, |
|
435 | - 'message' => 'Expense Report deleted' |
|
436 | - ) |
|
437 | - ); |
|
432 | + return array( |
|
433 | + 'success' => array( |
|
434 | + 'code' => 200, |
|
435 | + 'message' => 'Expense Report deleted' |
|
436 | + ) |
|
437 | + ); |
|
438 | 438 | |
439 | - } |
|
439 | + } |
|
440 | 440 | |
441 | - /** |
|
442 | - * Validate an Expense Report |
|
443 | - * |
|
444 | - * @param int $id Expense Report ID |
|
445 | - * |
|
446 | - * @url POST {id}/validate |
|
447 | - * |
|
448 | - * @return array |
|
449 | - * FIXME An error 403 is returned if the request has an empty body. |
|
450 | - * Error message: "Forbidden: Content type `text/plain` is not supported." |
|
451 | - * Workaround: send this in the body |
|
452 | - * { |
|
453 | - * "idwarehouse": 0 |
|
454 | - * } |
|
455 | - */ |
|
456 | - /* |
|
441 | + /** |
|
442 | + * Validate an Expense Report |
|
443 | + * |
|
444 | + * @param int $id Expense Report ID |
|
445 | + * |
|
446 | + * @url POST {id}/validate |
|
447 | + * |
|
448 | + * @return array |
|
449 | + * FIXME An error 403 is returned if the request has an empty body. |
|
450 | + * Error message: "Forbidden: Content type `text/plain` is not supported." |
|
451 | + * Workaround: send this in the body |
|
452 | + * { |
|
453 | + * "idwarehouse": 0 |
|
454 | + * } |
|
455 | + */ |
|
456 | + /* |
|
457 | 457 | function validate($id, $idwarehouse=0) |
458 | 458 | { |
459 | 459 | if(! DolibarrApiAccess::$user->rights->expensereport->creer) { |
@@ -480,22 +480,22 @@ discard block |
||
480 | 480 | ); |
481 | 481 | }*/ |
482 | 482 | |
483 | - /** |
|
484 | - * Validate fields before create or update object |
|
485 | - * |
|
486 | - * @param array $data Array with data to verify |
|
487 | - * @return array |
|
488 | - * @throws RestException |
|
489 | - */ |
|
490 | - function _validate($data) |
|
491 | - { |
|
492 | - $expensereport = array(); |
|
493 | - foreach (ExpenseReports::$FIELDS as $field) { |
|
494 | - if (!isset($data[$field])) |
|
495 | - throw new RestException(400, "$field field missing"); |
|
496 | - $expensereport[$field] = $data[$field]; |
|
483 | + /** |
|
484 | + * Validate fields before create or update object |
|
485 | + * |
|
486 | + * @param array $data Array with data to verify |
|
487 | + * @return array |
|
488 | + * @throws RestException |
|
489 | + */ |
|
490 | + function _validate($data) |
|
491 | + { |
|
492 | + $expensereport = array(); |
|
493 | + foreach (ExpenseReports::$FIELDS as $field) { |
|
494 | + if (!isset($data[$field])) |
|
495 | + throw new RestException(400, "$field field missing"); |
|
496 | + $expensereport[$field] = $data[$field]; |
|
497 | 497 | |
498 | - } |
|
499 | - return $expensereport; |
|
500 | - } |
|
498 | + } |
|
499 | + return $expensereport; |
|
500 | + } |
|
501 | 501 | } |
@@ -64,16 +64,16 @@ discard block |
||
64 | 64 | */ |
65 | 65 | function get($id) |
66 | 66 | { |
67 | - if(! DolibarrApiAccess::$user->rights->expensereport->lire) { |
|
67 | + if (!DolibarrApiAccess::$user->rights->expensereport->lire) { |
|
68 | 68 | throw new RestException(401); |
69 | 69 | } |
70 | 70 | |
71 | 71 | $result = $this->expensereport->fetch($id); |
72 | - if( ! $result ) { |
|
72 | + if (!$result) { |
|
73 | 73 | throw new RestException(404, 'Expense report not found'); |
74 | 74 | } |
75 | 75 | |
76 | - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { |
|
76 | + if (!DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { |
|
77 | 77 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
78 | 78 | } |
79 | 79 | |
@@ -103,30 +103,30 @@ discard block |
||
103 | 103 | //$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $societe; |
104 | 104 | |
105 | 105 | $sql = "SELECT t.rowid"; |
106 | - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as t"; |
|
107 | - $sql.= ' WHERE t.entity IN ('.getEntity('expensereport').')'; |
|
108 | - if ($user_ids) $sql.=" AND t.fk_user_author IN (".$user_ids.")"; |
|
106 | + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t"; |
|
107 | + $sql .= ' WHERE t.entity IN ('.getEntity('expensereport').')'; |
|
108 | + if ($user_ids) $sql .= " AND t.fk_user_author IN (".$user_ids.")"; |
|
109 | 109 | |
110 | 110 | // Add sql filters |
111 | 111 | if ($sqlfilters) |
112 | 112 | { |
113 | - if (! DolibarrApi::_checkFilters($sqlfilters)) |
|
113 | + if (!DolibarrApi::_checkFilters($sqlfilters)) |
|
114 | 114 | { |
115 | 115 | throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); |
116 | 116 | } |
117 | - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
118 | - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; |
|
117 | + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
118 | + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; |
|
119 | 119 | } |
120 | 120 | |
121 | - $sql.= $db->order($sortfield, $sortorder); |
|
122 | - if ($limit) { |
|
121 | + $sql .= $db->order($sortfield, $sortorder); |
|
122 | + if ($limit) { |
|
123 | 123 | if ($page < 0) |
124 | 124 | { |
125 | 125 | $page = 0; |
126 | 126 | } |
127 | 127 | $offset = $limit * $page; |
128 | 128 | |
129 | - $sql.= $db->plimit($limit + 1, $offset); |
|
129 | + $sql .= $db->plimit($limit + 1, $offset); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | $result = $db->query($sql); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | { |
140 | 140 | $obj = $db->fetch_object($result); |
141 | 141 | $expensereport_static = new ExpenseReport($db); |
142 | - if($expensereport_static->fetch($obj->rowid)) { |
|
142 | + if ($expensereport_static->fetch($obj->rowid)) { |
|
143 | 143 | $obj_ret[] = $this->_cleanObjectDatas($expensereport_static); |
144 | 144 | } |
145 | 145 | $i++; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | else { |
149 | 149 | throw new RestException(503, 'Error when retrieve Expense Report list : '.$db->lasterror()); |
150 | 150 | } |
151 | - if( ! count($obj_ret)) { |
|
151 | + if (!count($obj_ret)) { |
|
152 | 152 | throw new RestException(404, 'No Expense Report found'); |
153 | 153 | } |
154 | 154 | return $obj_ret; |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | */ |
163 | 163 | function post($request_data = NULL) |
164 | 164 | { |
165 | - if(! DolibarrApiAccess::$user->rights->expensereport->creer) { |
|
165 | + if (!DolibarrApiAccess::$user->rights->expensereport->creer) { |
|
166 | 166 | throw new RestException(401, "Insuffisant rights"); |
167 | 167 | } |
168 | 168 | // Check mandatory fields |
169 | 169 | $result = $this->_validate($request_data); |
170 | 170 | |
171 | - foreach($request_data as $field => $value) { |
|
171 | + foreach ($request_data as $field => $value) { |
|
172 | 172 | $this->expensereport->$field = $value; |
173 | 173 | } |
174 | 174 | /*if (isset($request_data["lines"])) { |
@@ -413,19 +413,19 @@ discard block |
||
413 | 413 | */ |
414 | 414 | function delete($id) |
415 | 415 | { |
416 | - if(! DolibarrApiAccess::$user->rights->expensereport->supprimer) { |
|
416 | + if (!DolibarrApiAccess::$user->rights->expensereport->supprimer) { |
|
417 | 417 | throw new RestException(401); |
418 | 418 | } |
419 | 419 | $result = $this->expensereport->fetch($id); |
420 | - if( ! $result ) { |
|
420 | + if (!$result) { |
|
421 | 421 | throw new RestException(404, 'Expense Report not found'); |
422 | 422 | } |
423 | 423 | |
424 | - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { |
|
424 | + if (!DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { |
|
425 | 425 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
426 | 426 | } |
427 | 427 | |
428 | - if( ! $this->expensereport->delete(DolibarrApiAccess::$user)) { |
|
428 | + if (!$this->expensereport->delete(DolibarrApiAccess::$user)) { |
|
429 | 429 | throw new RestException(500, 'Error when delete Expense Report : '.$this->expensereport->error); |
430 | 430 | } |
431 | 431 |
@@ -105,7 +105,9 @@ discard block |
||
105 | 105 | $sql = "SELECT t.rowid"; |
106 | 106 | $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as t"; |
107 | 107 | $sql.= ' WHERE t.entity IN ('.getEntity('expensereport').')'; |
108 | - if ($user_ids) $sql.=" AND t.fk_user_author IN (".$user_ids.")"; |
|
108 | + if ($user_ids) { |
|
109 | + $sql.=" AND t.fk_user_author IN (".$user_ids.")"; |
|
110 | + } |
|
109 | 111 | |
110 | 112 | // Add sql filters |
111 | 113 | if ($sqlfilters) |
@@ -144,8 +146,7 @@ discard block |
||
144 | 146 | } |
145 | 147 | $i++; |
146 | 148 | } |
147 | - } |
|
148 | - else { |
|
149 | + } else { |
|
149 | 150 | throw new RestException(503, 'Error when retrieve Expense Report list : '.$db->lasterror()); |
150 | 151 | } |
151 | 152 | if( ! count($obj_ret)) { |
@@ -491,8 +492,9 @@ discard block |
||
491 | 492 | { |
492 | 493 | $expensereport = array(); |
493 | 494 | foreach (ExpenseReports::$FIELDS as $field) { |
494 | - if (!isset($data[$field])) |
|
495 | - throw new RestException(400, "$field field missing"); |
|
495 | + if (!isset($data[$field])) { |
|
496 | + throw new RestException(400, "$field field missing"); |
|
497 | + } |
|
496 | 498 | $expensereport[$field] = $data[$field]; |
497 | 499 | |
498 | 500 | } |