@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | function encode($string) |
32 | 32 | { |
33 | - return str_replace(";","\;",(dol_quoted_printable_encode(utf8_decode($string)))); |
|
33 | + return str_replace(";", "\;", (dol_quoted_printable_encode(utf8_decode($string)))); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | * @param int $line_max Max length of lines |
43 | 43 | * @return string Encoded string |
44 | 44 | */ |
45 | -function dol_quoted_printable_encode($input, $line_max=76) |
|
45 | +function dol_quoted_printable_encode($input, $line_max = 76) |
|
46 | 46 | { |
47 | - $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
|
47 | + $hex = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
|
48 | 48 | $lines = preg_split("/(\?:\r\n|\r|\n)/", $input); |
49 | 49 | $eol = "\r\n"; |
50 | 50 | $linebreak = "=0D=0A"; |
@@ -57,23 +57,23 @@ discard block |
||
57 | 57 | $line = $lines[$j]; |
58 | 58 | $linlen = strlen($line); |
59 | 59 | $newline = ""; |
60 | - for($i = 0; $i < $linlen; $i++) { |
|
60 | + for ($i = 0; $i < $linlen; $i++) { |
|
61 | 61 | $c = substr($line, $i, 1); |
62 | 62 | $dec = ord($c); |
63 | - if ( ($dec == 32) && ($i == ($linlen - 1)) ) { // convert space at eol only |
|
63 | + if (($dec == 32) && ($i == ($linlen - 1))) { // convert space at eol only |
|
64 | 64 | $c = "=20"; |
65 | - } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required |
|
66 | - $h2 = floor($dec/16); $h1 = floor($dec%16); |
|
65 | + } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) { // always encode "\t", which is *not* required |
|
66 | + $h2 = floor($dec / 16); $h1 = floor($dec % 16); |
|
67 | 67 | $c = $escape.$hex["$h2"].$hex["$h1"]; |
68 | 68 | } |
69 | - if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted |
|
69 | + if ((strlen($newline) + strlen($c)) >= $line_max) { // CRLF is not counted |
|
70 | 70 | $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay |
71 | 71 | $newline = " "; |
72 | 72 | } |
73 | 73 | $newline .= $c; |
74 | 74 | } // end of for |
75 | 75 | $output .= $newline; |
76 | - if ($j<count($lines)-1) $output .= $linebreak; |
|
76 | + if ($j < count($lines) - 1) $output .= $linebreak; |
|
77 | 77 | } |
78 | 78 | return trim($output); |
79 | 79 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | var $filename; |
89 | 89 | |
90 | 90 | //var $encoding="UTF-8"; |
91 | - var $encoding="ISO-8859-1;ENCODING=QUOTED-PRINTABLE"; |
|
91 | + var $encoding = "ISO-8859-1;ENCODING=QUOTED-PRINTABLE"; |
|
92 | 92 | |
93 | 93 | |
94 | 94 | /** |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | * @param string $type Type |
99 | 99 | * @return void |
100 | 100 | */ |
101 | - function setPhoneNumber($number, $type="") |
|
101 | + function setPhoneNumber($number, $type = "") |
|
102 | 102 | { |
103 | 103 | // type may be PREF | WORK | HOME | VOICE | FAX | MSG | CELL | PAGER | BBS | CAR | MODEM | ISDN | VIDEO or any senseful combination, e.g. "PREF;WORK;VOICE" |
104 | 104 | $key = "TEL"; |
105 | - if ($type!="") $key .= ";".$type; |
|
106 | - $key.= ";CHARSET=".$this->encoding; |
|
105 | + if ($type != "") $key .= ";".$type; |
|
106 | + $key .= ";CHARSET=".$this->encoding; |
|
107 | 107 | $this->properties[$key] = encode($number); |
108 | 108 | } |
109 | 109 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param string $suffix Suffix |
143 | 143 | * @return void |
144 | 144 | */ |
145 | - function setName($family="", $first="", $additional="", $prefix="", $suffix="") |
|
145 | + function setName($family = "", $first = "", $additional = "", $prefix = "", $suffix = "") |
|
146 | 146 | { |
147 | 147 | $this->properties["N;CHARSET=".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix); |
148 | 148 | $this->filename = "$first%20$family.vcf"; |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | * @param string $type Type |
175 | 175 | * @return void |
176 | 176 | */ |
177 | - function setAddress($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME;POSTAL") |
|
177 | + function setAddress($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") |
|
178 | 178 | { |
179 | 179 | // $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL" |
180 | 180 | $key = "ADR"; |
181 | - if ($type!="") $key.= ";$type"; |
|
182 | - $key.= ";CHARSET=".$this->encoding; |
|
181 | + if ($type != "") $key .= ";$type"; |
|
182 | + $key .= ";CHARSET=".$this->encoding; |
|
183 | 183 | $this->properties[$key] = ";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country); |
184 | 184 | |
185 | 185 | if ($this->properties["LABEL;$type;CHARSET=".$this->encoding] == "") |
@@ -201,16 +201,16 @@ discard block |
||
201 | 201 | * @param string $type Type |
202 | 202 | * @return void |
203 | 203 | */ |
204 | - function setLabel($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME;POSTAL") |
|
204 | + function setLabel($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") |
|
205 | 205 | { |
206 | 206 | $label = ""; |
207 | - if ($postoffice!="") $label.= "$postoffice\r\n"; |
|
208 | - if ($extended!="") $label.= "$extended\r\n"; |
|
209 | - if ($street!="") $label.= "$street\r\n"; |
|
210 | - if ($zip!="") $label.= "$zip "; |
|
211 | - if ($city!="") $label.= "$city\r\n"; |
|
212 | - if ($region!="") $label.= "$region\r\n"; |
|
213 | - if ($country!="") $country.= "$country\r\n"; |
|
207 | + if ($postoffice != "") $label .= "$postoffice\r\n"; |
|
208 | + if ($extended != "") $label .= "$extended\r\n"; |
|
209 | + if ($street != "") $label .= "$street\r\n"; |
|
210 | + if ($zip != "") $label .= "$zip "; |
|
211 | + if ($city != "") $label .= "$city\r\n"; |
|
212 | + if ($region != "") $label .= "$region\r\n"; |
|
213 | + if ($country != "") $country .= "$country\r\n"; |
|
214 | 214 | |
215 | 215 | $this->properties["LABEL;$type;CHARSET=".$this->encoding] = encode($label); |
216 | 216 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @param string $type Vcard type |
223 | 223 | * @return void |
224 | 224 | */ |
225 | - function setEmail($address,$type="internet,pref") |
|
225 | + function setEmail($address, $type = "internet,pref") |
|
226 | 226 | { |
227 | 227 | $this->properties["EMAIL;TYPE=".$type] = $address; |
228 | 228 | } |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | * @param string $type Type |
294 | 294 | * @return void |
295 | 295 | */ |
296 | - function setURL($url, $type="") |
|
296 | + function setURL($url, $type = "") |
|
297 | 297 | { |
298 | 298 | // $type may be WORK | HOME |
299 | 299 | $key = "URL"; |
300 | - if ($type!="") $key.= ";$type"; |
|
300 | + if ($type != "") $key .= ";$type"; |
|
301 | 301 | $this->properties[$key] = $url; |
302 | 302 | } |
303 | 303 | |
@@ -309,15 +309,15 @@ discard block |
||
309 | 309 | function getVCard() |
310 | 310 | { |
311 | 311 | $text = "BEGIN:VCARD\r\n"; |
312 | - $text.= "VERSION:3.0\r\n"; |
|
312 | + $text .= "VERSION:3.0\r\n"; |
|
313 | 313 | //$text.= "VERSION:2.1\r\n"; |
314 | - foreach($this->properties as $key => $value) |
|
314 | + foreach ($this->properties as $key => $value) |
|
315 | 315 | { |
316 | - $text.= "$key:$value\r\n"; |
|
316 | + $text .= "$key:$value\r\n"; |
|
317 | 317 | } |
318 | - $text.= "REV:".date("Y-m-d")."T".date("H:i:s")."Z\r\n"; |
|
319 | - $text.= "MAILER: Dolibarr\r\n"; |
|
320 | - $text.= "END:VCARD\r\n"; |
|
318 | + $text .= "REV:".date("Y-m-d")."T".date("H:i:s")."Z\r\n"; |
|
319 | + $text .= "MAILER: Dolibarr\r\n"; |
|
320 | + $text .= "END:VCARD\r\n"; |
|
321 | 321 | return $text; |
322 | 322 | } |
323 | 323 |
@@ -73,7 +73,9 @@ discard block |
||
73 | 73 | $newline .= $c; |
74 | 74 | } // end of for |
75 | 75 | $output .= $newline; |
76 | - if ($j<count($lines)-1) $output .= $linebreak; |
|
76 | + if ($j<count($lines)-1) { |
|
77 | + $output .= $linebreak; |
|
78 | + } |
|
77 | 79 | } |
78 | 80 | return trim($output); |
79 | 81 | } |
@@ -102,7 +104,9 @@ discard block |
||
102 | 104 | { |
103 | 105 | // type may be PREF | WORK | HOME | VOICE | FAX | MSG | CELL | PAGER | BBS | CAR | MODEM | ISDN | VIDEO or any senseful combination, e.g. "PREF;WORK;VOICE" |
104 | 106 | $key = "TEL"; |
105 | - if ($type!="") $key .= ";".$type; |
|
107 | + if ($type!="") { |
|
108 | + $key .= ";".$type; |
|
109 | + } |
|
106 | 110 | $key.= ";CHARSET=".$this->encoding; |
107 | 111 | $this->properties[$key] = encode($number); |
108 | 112 | } |
@@ -146,7 +150,9 @@ discard block |
||
146 | 150 | { |
147 | 151 | $this->properties["N;CHARSET=".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix); |
148 | 152 | $this->filename = "$first%20$family.vcf"; |
149 | - if (empty($this->properties["FN"])) $this->setFormattedName(trim("$prefix $first $additional $family $suffix")); |
|
153 | + if (empty($this->properties["FN"])) { |
|
154 | + $this->setFormattedName(trim("$prefix $first $additional $family $suffix")); |
|
155 | + } |
|
150 | 156 | } |
151 | 157 | |
152 | 158 | /** |
@@ -178,7 +184,9 @@ discard block |
||
178 | 184 | { |
179 | 185 | // $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL" |
180 | 186 | $key = "ADR"; |
181 | - if ($type!="") $key.= ";$type"; |
|
187 | + if ($type!="") { |
|
188 | + $key.= ";$type"; |
|
189 | + } |
|
182 | 190 | $key.= ";CHARSET=".$this->encoding; |
183 | 191 | $this->properties[$key] = ";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country); |
184 | 192 | |
@@ -204,13 +212,27 @@ discard block |
||
204 | 212 | function setLabel($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME;POSTAL") |
205 | 213 | { |
206 | 214 | $label = ""; |
207 | - if ($postoffice!="") $label.= "$postoffice\r\n"; |
|
208 | - if ($extended!="") $label.= "$extended\r\n"; |
|
209 | - if ($street!="") $label.= "$street\r\n"; |
|
210 | - if ($zip!="") $label.= "$zip "; |
|
211 | - if ($city!="") $label.= "$city\r\n"; |
|
212 | - if ($region!="") $label.= "$region\r\n"; |
|
213 | - if ($country!="") $country.= "$country\r\n"; |
|
215 | + if ($postoffice!="") { |
|
216 | + $label.= "$postoffice\r\n"; |
|
217 | + } |
|
218 | + if ($extended!="") { |
|
219 | + $label.= "$extended\r\n"; |
|
220 | + } |
|
221 | + if ($street!="") { |
|
222 | + $label.= "$street\r\n"; |
|
223 | + } |
|
224 | + if ($zip!="") { |
|
225 | + $label.= "$zip "; |
|
226 | + } |
|
227 | + if ($city!="") { |
|
228 | + $label.= "$city\r\n"; |
|
229 | + } |
|
230 | + if ($region!="") { |
|
231 | + $label.= "$region\r\n"; |
|
232 | + } |
|
233 | + if ($country!="") { |
|
234 | + $country.= "$country\r\n"; |
|
235 | + } |
|
214 | 236 | |
215 | 237 | $this->properties["LABEL;$type;CHARSET=".$this->encoding] = encode($label); |
216 | 238 | } |
@@ -297,7 +319,9 @@ discard block |
||
297 | 319 | { |
298 | 320 | // $type may be WORK | HOME |
299 | 321 | $key = "URL"; |
300 | - if ($type!="") $key.= ";$type"; |
|
322 | + if ($type!="") { |
|
323 | + $key.= ";$type"; |
|
324 | + } |
|
301 | 325 | $this->properties[$key] = $url; |
302 | 326 | } |
303 | 327 |
@@ -61,226 +61,226 @@ |
||
61 | 61 | */ |
62 | 62 | abstract class CommonStickerGenerator |
63 | 63 | { |
64 | - public $code; // Code of format |
|
64 | + public $code; // Code of format |
|
65 | 65 | |
66 | - /** |
|
66 | + /** |
|
67 | 67 | * @var array format Array with informations |
68 | 68 | */ |
69 | 69 | public $format; |
70 | 70 | |
71 | - // protected |
|
72 | - var $_Avery_Name = ''; // Nom du format de l'etiquette |
|
73 | - var $_Margin_Left = 0; // Marge de gauche de l'etiquette |
|
74 | - var $_Margin_Top = 0; // marge en haut de la page avant la premiere etiquette |
|
75 | - var $_X_Space = 0; // Espace horizontal entre 2 bandes d'etiquettes |
|
76 | - var $_Y_Space = 0; // Espace vertical entre 2 bandes d'etiquettes |
|
77 | - var $_X_Number = 0; // NX Nombre d'etiquettes sur la largeur de la page |
|
78 | - var $_Y_Number = 0; // NY Nombre d'etiquettes sur la hauteur de la page |
|
79 | - var $_Width = 0; // Largeur de chaque etiquette |
|
80 | - var $_Height = 0; // Hauteur de chaque etiquette |
|
81 | - var $_Char_Size = 10; // Hauteur des caracteres |
|
82 | - var $_Line_Height = 10; // Hauteur par defaut d'une ligne |
|
83 | - var $_Metric = 'mm'; // Type of metric.. Will help to calculate good values |
|
84 | - var $_Metric_Doc = 'mm'; // Type of metric for the doc.. |
|
85 | - var $_COUNTX = 1; |
|
86 | - var $_COUNTY = 1; |
|
87 | - var $_First = 1; |
|
88 | - var $Tformat; |
|
71 | + // protected |
|
72 | + var $_Avery_Name = ''; // Nom du format de l'etiquette |
|
73 | + var $_Margin_Left = 0; // Marge de gauche de l'etiquette |
|
74 | + var $_Margin_Top = 0; // marge en haut de la page avant la premiere etiquette |
|
75 | + var $_X_Space = 0; // Espace horizontal entre 2 bandes d'etiquettes |
|
76 | + var $_Y_Space = 0; // Espace vertical entre 2 bandes d'etiquettes |
|
77 | + var $_X_Number = 0; // NX Nombre d'etiquettes sur la largeur de la page |
|
78 | + var $_Y_Number = 0; // NY Nombre d'etiquettes sur la hauteur de la page |
|
79 | + var $_Width = 0; // Largeur de chaque etiquette |
|
80 | + var $_Height = 0; // Hauteur de chaque etiquette |
|
81 | + var $_Char_Size = 10; // Hauteur des caracteres |
|
82 | + var $_Line_Height = 10; // Hauteur par defaut d'une ligne |
|
83 | + var $_Metric = 'mm'; // Type of metric.. Will help to calculate good values |
|
84 | + var $_Metric_Doc = 'mm'; // Type of metric for the doc.. |
|
85 | + var $_COUNTX = 1; |
|
86 | + var $_COUNTY = 1; |
|
87 | + var $_First = 1; |
|
88 | + var $Tformat; |
|
89 | 89 | |
90 | - /** |
|
91 | - * Constructor |
|
92 | - * |
|
93 | - * @param DoliDB $db Database handler |
|
94 | - */ |
|
95 | - function __construct($db) |
|
96 | - { |
|
97 | - $this->db = $db; |
|
98 | - } |
|
90 | + /** |
|
91 | + * Constructor |
|
92 | + * |
|
93 | + * @param DoliDB $db Database handler |
|
94 | + */ |
|
95 | + function __construct($db) |
|
96 | + { |
|
97 | + $this->db = $db; |
|
98 | + } |
|
99 | 99 | |
100 | 100 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
101 | - /** |
|
102 | - * Function to build PDF on disk, then output on HTTP strem. |
|
103 | - * |
|
104 | - * @param array $arrayofrecords Array of record informations (array('textleft'=>,'textheader'=>, ..., 'id'=>,'photo'=>) |
|
105 | - * @param Translate $outputlangs Lang object for output language |
|
106 | - * @param string $srctemplatepath Full path of source filename for generator using a template file |
|
107 | - * @param string $outputdir Output directory for pdf file |
|
108 | - * @return int 1=OK, 0=KO |
|
109 | - */ |
|
110 | - abstract function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir=''); |
|
101 | + /** |
|
102 | + * Function to build PDF on disk, then output on HTTP strem. |
|
103 | + * |
|
104 | + * @param array $arrayofrecords Array of record informations (array('textleft'=>,'textheader'=>, ..., 'id'=>,'photo'=>) |
|
105 | + * @param Translate $outputlangs Lang object for output language |
|
106 | + * @param string $srctemplatepath Full path of source filename for generator using a template file |
|
107 | + * @param string $outputdir Output directory for pdf file |
|
108 | + * @return int 1=OK, 0=KO |
|
109 | + */ |
|
110 | + abstract function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir=''); |
|
111 | 111 | // phpcs:enable |
112 | 112 | |
113 | - /** |
|
114 | - * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) |
|
115 | - * |
|
116 | - * @param PDF $pdf PDF reference |
|
117 | - * @param Translate $outputlangs Output langs |
|
118 | - * @param array $param Associative array containing label content and optional parameters |
|
119 | - * @return void |
|
120 | - */ |
|
121 | - abstract function addSticker(&$pdf,$outputlangs,$param); |
|
113 | + /** |
|
114 | + * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) |
|
115 | + * |
|
116 | + * @param PDF $pdf PDF reference |
|
117 | + * @param Translate $outputlangs Output langs |
|
118 | + * @param array $param Associative array containing label content and optional parameters |
|
119 | + * @return void |
|
120 | + */ |
|
121 | + abstract function addSticker(&$pdf,$outputlangs,$param); |
|
122 | 122 | |
123 | 123 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
124 | - /** |
|
125 | - * Methode qui permet de modifier la taille des caracteres |
|
126 | - * Cela modiera aussi l'espace entre chaque ligne |
|
127 | - * |
|
128 | - * @param PDF $pdf PDF reference |
|
129 | - * @param int $pt point |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function Set_Char_Size(&$pdf,$pt) |
|
133 | - { |
|
124 | + /** |
|
125 | + * Methode qui permet de modifier la taille des caracteres |
|
126 | + * Cela modiera aussi l'espace entre chaque ligne |
|
127 | + * |
|
128 | + * @param PDF $pdf PDF reference |
|
129 | + * @param int $pt point |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function Set_Char_Size(&$pdf,$pt) |
|
133 | + { |
|
134 | 134 | // phpcs:enable |
135 | - if ($pt > 3) { |
|
136 | - $this->_Char_Size = $pt; |
|
137 | - $this->_Line_Height = $this->_Get_Height_Chars($pt); |
|
138 | - $pdf->SetFont('','',$pt); |
|
139 | - } |
|
140 | - } |
|
135 | + if ($pt > 3) { |
|
136 | + $this->_Char_Size = $pt; |
|
137 | + $this->_Line_Height = $this->_Get_Height_Chars($pt); |
|
138 | + $pdf->SetFont('','',$pt); |
|
139 | + } |
|
140 | + } |
|
141 | 141 | |
142 | 142 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
143 | - /** |
|
144 | - * protected Print dot line |
|
145 | - * |
|
146 | - * @param PDF $pdf PDF reference |
|
147 | - * @param int $x1 X1 |
|
148 | - * @param int $y1 Y1 |
|
149 | - * @param int $x2 X2 |
|
150 | - * @param int $y2 Y2 |
|
151 | - * @param int $epaisseur Epaisseur |
|
152 | - * @param int $nbPointilles Nb pointilles |
|
153 | - * @return void |
|
154 | - */ |
|
143 | + /** |
|
144 | + * protected Print dot line |
|
145 | + * |
|
146 | + * @param PDF $pdf PDF reference |
|
147 | + * @param int $x1 X1 |
|
148 | + * @param int $y1 Y1 |
|
149 | + * @param int $x2 X2 |
|
150 | + * @param int $y2 Y2 |
|
151 | + * @param int $epaisseur Epaisseur |
|
152 | + * @param int $nbPointilles Nb pointilles |
|
153 | + * @return void |
|
154 | + */ |
|
155 | 155 | function _Pointille(&$pdf,$x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$nbPointilles=15) |
156 | - { |
|
156 | + { |
|
157 | 157 | // phpcs:enable |
158 | - $pdf->SetLineWidth($epaisseur); |
|
159 | - $length=abs($x1-$x2); |
|
160 | - $hauteur=abs($y1-$y2); |
|
161 | - if($length>$hauteur) { |
|
162 | - $Pointilles=($length/$nbPointilles)/2; // taille des pointilles |
|
163 | - } |
|
164 | - else { |
|
165 | - $Pointilles=($hauteur/$nbPointilles)/2; |
|
166 | - } |
|
167 | - for($i=$x1;$i<=$x2;$i+=$Pointilles+$Pointilles) { |
|
168 | - for($j=$i;$j<=($i+$Pointilles);$j++) { |
|
169 | - if($j<=($x2-1)) { |
|
170 | - $pdf->Line($j,$y1,$j+1,$y1); // on trace le pointill? du haut, point par point |
|
171 | - $pdf->Line($j,$y2,$j+1,$y2); // on trace le pointill? du bas, point par point |
|
172 | - } |
|
173 | - } |
|
174 | - } |
|
175 | - for($i=$y1;$i<=$y2;$i+=$Pointilles+$Pointilles) { |
|
176 | - for($j=$i;$j<=($i+$Pointilles);$j++) { |
|
177 | - if($j<=($y2-1)) { |
|
178 | - $pdf->Line($x1,$j,$x1,$j+1); // on trace le pointill? du haut, point par point |
|
179 | - $pdf->Line($x2,$j,$x2,$j+1); // on trace le pointill? du bas, point par point |
|
180 | - } |
|
181 | - } |
|
182 | - } |
|
183 | - } |
|
158 | + $pdf->SetLineWidth($epaisseur); |
|
159 | + $length=abs($x1-$x2); |
|
160 | + $hauteur=abs($y1-$y2); |
|
161 | + if($length>$hauteur) { |
|
162 | + $Pointilles=($length/$nbPointilles)/2; // taille des pointilles |
|
163 | + } |
|
164 | + else { |
|
165 | + $Pointilles=($hauteur/$nbPointilles)/2; |
|
166 | + } |
|
167 | + for($i=$x1;$i<=$x2;$i+=$Pointilles+$Pointilles) { |
|
168 | + for($j=$i;$j<=($i+$Pointilles);$j++) { |
|
169 | + if($j<=($x2-1)) { |
|
170 | + $pdf->Line($j,$y1,$j+1,$y1); // on trace le pointill? du haut, point par point |
|
171 | + $pdf->Line($j,$y2,$j+1,$y2); // on trace le pointill? du bas, point par point |
|
172 | + } |
|
173 | + } |
|
174 | + } |
|
175 | + for($i=$y1;$i<=$y2;$i+=$Pointilles+$Pointilles) { |
|
176 | + for($j=$i;$j<=($i+$Pointilles);$j++) { |
|
177 | + if($j<=($y2-1)) { |
|
178 | + $pdf->Line($x1,$j,$x1,$j+1); // on trace le pointill? du haut, point par point |
|
179 | + $pdf->Line($x2,$j,$x2,$j+1); // on trace le pointill? du bas, point par point |
|
180 | + } |
|
181 | + } |
|
182 | + } |
|
183 | + } |
|
184 | 184 | |
185 | 185 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
186 | - /** |
|
187 | - * protected Function realisant une croix aux 4 coins des cartes |
|
188 | - * |
|
189 | - * @param PDF $pdf PDF reference |
|
190 | - * @param int $x1 X1 |
|
191 | - * @param int $y1 Y1 |
|
192 | - * @param int $x2 X2 |
|
193 | - * @param int $y2 Y2 |
|
194 | - * @param int $epaisseur Epaisseur |
|
195 | - * @param int $taille Size |
|
196 | - * @return void |
|
197 | - */ |
|
198 | - function _Croix(&$pdf,$x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$taille=4) |
|
199 | - { |
|
186 | + /** |
|
187 | + * protected Function realisant une croix aux 4 coins des cartes |
|
188 | + * |
|
189 | + * @param PDF $pdf PDF reference |
|
190 | + * @param int $x1 X1 |
|
191 | + * @param int $y1 Y1 |
|
192 | + * @param int $x2 X2 |
|
193 | + * @param int $y2 Y2 |
|
194 | + * @param int $epaisseur Epaisseur |
|
195 | + * @param int $taille Size |
|
196 | + * @return void |
|
197 | + */ |
|
198 | + function _Croix(&$pdf,$x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$taille=4) |
|
199 | + { |
|
200 | 200 | // phpcs:enable |
201 | - $pdf->SetDrawColor(192,192,192); |
|
201 | + $pdf->SetDrawColor(192,192,192); |
|
202 | 202 | |
203 | - $pdf->SetLineWidth($epaisseur); |
|
204 | - $lg=$taille/2; |
|
205 | - // croix haut gauche |
|
206 | - $pdf->Line($x1,$y1-$lg,$x1,$y1+$lg); |
|
207 | - $pdf->Line($x1-$lg,$y1,$x1+$lg,$y1); |
|
208 | - // croix bas gauche |
|
209 | - $pdf->Line($x1,$y2-$lg,$x1,$y2+$lg); |
|
210 | - $pdf->Line($x1-$lg,$y2,$x1+$lg,$y2); |
|
211 | - // croix haut droit |
|
212 | - $pdf->Line($x2,$y1-$lg,$x2,$y1+$lg); |
|
213 | - $pdf->Line($x2-$lg,$y1,$x2+$lg,$y1); |
|
214 | - // croix bas droit |
|
215 | - $pdf->Line($x2,$y2-$lg,$x2,$y2+$lg); |
|
216 | - $pdf->Line($x2-$lg,$y2,$x2+$lg,$y2); |
|
203 | + $pdf->SetLineWidth($epaisseur); |
|
204 | + $lg=$taille/2; |
|
205 | + // croix haut gauche |
|
206 | + $pdf->Line($x1,$y1-$lg,$x1,$y1+$lg); |
|
207 | + $pdf->Line($x1-$lg,$y1,$x1+$lg,$y1); |
|
208 | + // croix bas gauche |
|
209 | + $pdf->Line($x1,$y2-$lg,$x1,$y2+$lg); |
|
210 | + $pdf->Line($x1-$lg,$y2,$x1+$lg,$y2); |
|
211 | + // croix haut droit |
|
212 | + $pdf->Line($x2,$y1-$lg,$x2,$y1+$lg); |
|
213 | + $pdf->Line($x2-$lg,$y1,$x2+$lg,$y1); |
|
214 | + // croix bas droit |
|
215 | + $pdf->Line($x2,$y2-$lg,$x2,$y2+$lg); |
|
216 | + $pdf->Line($x2-$lg,$y2,$x2+$lg,$y2); |
|
217 | 217 | |
218 | - $pdf->SetDrawColor(0,0,0); |
|
219 | - } |
|
218 | + $pdf->SetDrawColor(0,0,0); |
|
219 | + } |
|
220 | 220 | |
221 | - /** |
|
222 | - * Convert units (in to mm, mm to in) |
|
223 | - * $src and $dest must be 'in' or 'mm' |
|
224 | - * |
|
225 | - * @param int $value value |
|
226 | - * @param string $src from ('in' or 'mm') |
|
227 | - * @param string $dest to ('in' or 'mm') |
|
228 | - * @return float value value after conversion |
|
229 | - */ |
|
230 | - private function convertMetric($value, $src, $dest) |
|
231 | - { |
|
232 | - if ($src != $dest) { |
|
233 | - $tab = array( |
|
234 | - 'in'=>39.37008, |
|
235 | - 'mm'=>1000 |
|
236 | - ); |
|
237 | - return $value * $tab[$dest] / $tab[$src]; |
|
238 | - } |
|
221 | + /** |
|
222 | + * Convert units (in to mm, mm to in) |
|
223 | + * $src and $dest must be 'in' or 'mm' |
|
224 | + * |
|
225 | + * @param int $value value |
|
226 | + * @param string $src from ('in' or 'mm') |
|
227 | + * @param string $dest to ('in' or 'mm') |
|
228 | + * @return float value value after conversion |
|
229 | + */ |
|
230 | + private function convertMetric($value, $src, $dest) |
|
231 | + { |
|
232 | + if ($src != $dest) { |
|
233 | + $tab = array( |
|
234 | + 'in'=>39.37008, |
|
235 | + 'mm'=>1000 |
|
236 | + ); |
|
237 | + return $value * $tab[$dest] / $tab[$src]; |
|
238 | + } |
|
239 | 239 | |
240 | - return $value; |
|
241 | - } |
|
240 | + return $value; |
|
241 | + } |
|
242 | 242 | |
243 | 243 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
244 | - /** |
|
245 | - * protected Give the height for a char size given. |
|
246 | - * |
|
247 | - * @param int $pt Point |
|
248 | - * @return int Height chars |
|
249 | - */ |
|
250 | - function _Get_Height_Chars($pt) |
|
251 | - { |
|
244 | + /** |
|
245 | + * protected Give the height for a char size given. |
|
246 | + * |
|
247 | + * @param int $pt Point |
|
248 | + * @return int Height chars |
|
249 | + */ |
|
250 | + function _Get_Height_Chars($pt) |
|
251 | + { |
|
252 | 252 | // phpcs:enable |
253 | - // Tableau de concordance entre la hauteur des caracteres et de l'espacement entre les lignes |
|
254 | - $_Table_Hauteur_Chars = array(6=>2, 7=>2.5, 8=>3, 9=>3.5, 10=>4, 11=>6, 12=>7, 13=>8, 14=>9, 15=>10); |
|
255 | - if (in_array($pt, array_keys($_Table_Hauteur_Chars))) { |
|
256 | - return $_Table_Hauteur_Chars[$pt]; |
|
257 | - } else { |
|
258 | - return 100; // There is a prob.. |
|
259 | - } |
|
260 | - } |
|
253 | + // Tableau de concordance entre la hauteur des caracteres et de l'espacement entre les lignes |
|
254 | + $_Table_Hauteur_Chars = array(6=>2, 7=>2.5, 8=>3, 9=>3.5, 10=>4, 11=>6, 12=>7, 13=>8, 14=>9, 15=>10); |
|
255 | + if (in_array($pt, array_keys($_Table_Hauteur_Chars))) { |
|
256 | + return $_Table_Hauteur_Chars[$pt]; |
|
257 | + } else { |
|
258 | + return 100; // There is a prob.. |
|
259 | + } |
|
260 | + } |
|
261 | 261 | |
262 | 262 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
263 | - /** |
|
264 | - * protected Set format |
|
265 | - * |
|
266 | - * @param PDF $pdf PDF reference |
|
267 | - * @param string $format Format |
|
268 | - * @return void |
|
269 | - */ |
|
270 | - function _Set_Format(&$pdf, $format) |
|
271 | - { |
|
263 | + /** |
|
264 | + * protected Set format |
|
265 | + * |
|
266 | + * @param PDF $pdf PDF reference |
|
267 | + * @param string $format Format |
|
268 | + * @return void |
|
269 | + */ |
|
270 | + function _Set_Format(&$pdf, $format) |
|
271 | + { |
|
272 | 272 | // phpcs:enable |
273 | - $this->_Metric = $format['metric']; |
|
274 | - $this->_Avery_Name = $format['name']; |
|
275 | - $this->_Avery_Code = $format['code']; |
|
276 | - $this->_Margin_Left = $this->convertMetric($format['marginLeft'], $this->_Metric, $this->_Metric_Doc); |
|
277 | - $this->_Margin_Top = $this->convertMetric($format['marginTop'], $this->_Metric, $this->_Metric_Doc); |
|
278 | - $this->_X_Space = $this->convertMetric($format['SpaceX'], $this->_Metric, $this->_Metric_Doc); |
|
279 | - $this->_Y_Space = $this->convertMetric($format['SpaceY'], $this->_Metric, $this->_Metric_Doc); |
|
280 | - $this->_X_Number = $format['NX']; |
|
281 | - $this->_Y_Number = $format['NY']; |
|
282 | - $this->_Width = $this->convertMetric($format['width'], $this->_Metric, $this->_Metric_Doc); |
|
283 | - $this->_Height = $this->convertMetric($format['height'], $this->_Metric, $this->_Metric_Doc); |
|
284 | - $this->Set_Char_Size($pdf, $format['font-size']); |
|
285 | - } |
|
273 | + $this->_Metric = $format['metric']; |
|
274 | + $this->_Avery_Name = $format['name']; |
|
275 | + $this->_Avery_Code = $format['code']; |
|
276 | + $this->_Margin_Left = $this->convertMetric($format['marginLeft'], $this->_Metric, $this->_Metric_Doc); |
|
277 | + $this->_Margin_Top = $this->convertMetric($format['marginTop'], $this->_Metric, $this->_Metric_Doc); |
|
278 | + $this->_X_Space = $this->convertMetric($format['SpaceX'], $this->_Metric, $this->_Metric_Doc); |
|
279 | + $this->_Y_Space = $this->convertMetric($format['SpaceY'], $this->_Metric, $this->_Metric_Doc); |
|
280 | + $this->_X_Number = $format['NX']; |
|
281 | + $this->_Y_Number = $format['NY']; |
|
282 | + $this->_Width = $this->convertMetric($format['width'], $this->_Metric, $this->_Metric_Doc); |
|
283 | + $this->_Height = $this->convertMetric($format['height'], $this->_Metric, $this->_Metric_Doc); |
|
284 | + $this->Set_Char_Size($pdf, $format['font-size']); |
|
285 | + } |
|
286 | 286 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | abstract class CommonStickerGenerator |
63 | 63 | { |
64 | - public $code; // Code of format |
|
64 | + public $code; // Code of format |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * @var array format Array with informations |
@@ -69,19 +69,19 @@ discard block |
||
69 | 69 | public $format; |
70 | 70 | |
71 | 71 | // protected |
72 | - var $_Avery_Name = ''; // Nom du format de l'etiquette |
|
73 | - var $_Margin_Left = 0; // Marge de gauche de l'etiquette |
|
74 | - var $_Margin_Top = 0; // marge en haut de la page avant la premiere etiquette |
|
75 | - var $_X_Space = 0; // Espace horizontal entre 2 bandes d'etiquettes |
|
76 | - var $_Y_Space = 0; // Espace vertical entre 2 bandes d'etiquettes |
|
77 | - var $_X_Number = 0; // NX Nombre d'etiquettes sur la largeur de la page |
|
78 | - var $_Y_Number = 0; // NY Nombre d'etiquettes sur la hauteur de la page |
|
79 | - var $_Width = 0; // Largeur de chaque etiquette |
|
80 | - var $_Height = 0; // Hauteur de chaque etiquette |
|
81 | - var $_Char_Size = 10; // Hauteur des caracteres |
|
82 | - var $_Line_Height = 10; // Hauteur par defaut d'une ligne |
|
83 | - var $_Metric = 'mm'; // Type of metric.. Will help to calculate good values |
|
84 | - var $_Metric_Doc = 'mm'; // Type of metric for the doc.. |
|
72 | + var $_Avery_Name = ''; // Nom du format de l'etiquette |
|
73 | + var $_Margin_Left = 0; // Marge de gauche de l'etiquette |
|
74 | + var $_Margin_Top = 0; // marge en haut de la page avant la premiere etiquette |
|
75 | + var $_X_Space = 0; // Espace horizontal entre 2 bandes d'etiquettes |
|
76 | + var $_Y_Space = 0; // Espace vertical entre 2 bandes d'etiquettes |
|
77 | + var $_X_Number = 0; // NX Nombre d'etiquettes sur la largeur de la page |
|
78 | + var $_Y_Number = 0; // NY Nombre d'etiquettes sur la hauteur de la page |
|
79 | + var $_Width = 0; // Largeur de chaque etiquette |
|
80 | + var $_Height = 0; // Hauteur de chaque etiquette |
|
81 | + var $_Char_Size = 10; // Hauteur des caracteres |
|
82 | + var $_Line_Height = 10; // Hauteur par defaut d'une ligne |
|
83 | + var $_Metric = 'mm'; // Type of metric.. Will help to calculate good values |
|
84 | + var $_Metric_Doc = 'mm'; // Type of metric for the doc.. |
|
85 | 85 | var $_COUNTX = 1; |
86 | 86 | var $_COUNTY = 1; |
87 | 87 | var $_First = 1; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @param string $outputdir Output directory for pdf file |
108 | 108 | * @return int 1=OK, 0=KO |
109 | 109 | */ |
110 | - abstract function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir=''); |
|
110 | + abstract function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = ''); |
|
111 | 111 | // phpcs:enable |
112 | 112 | |
113 | 113 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @param array $param Associative array containing label content and optional parameters |
119 | 119 | * @return void |
120 | 120 | */ |
121 | - abstract function addSticker(&$pdf,$outputlangs,$param); |
|
121 | + abstract function addSticker(&$pdf, $outputlangs, $param); |
|
122 | 122 | |
123 | 123 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
124 | 124 | /** |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | * @param int $pt point |
130 | 130 | * @return void |
131 | 131 | */ |
132 | - function Set_Char_Size(&$pdf,$pt) |
|
132 | + function Set_Char_Size(&$pdf, $pt) |
|
133 | 133 | { |
134 | 134 | // phpcs:enable |
135 | 135 | if ($pt > 3) { |
136 | 136 | $this->_Char_Size = $pt; |
137 | 137 | $this->_Line_Height = $this->_Get_Height_Chars($pt); |
138 | - $pdf->SetFont('','',$pt); |
|
138 | + $pdf->SetFont('', '', $pt); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
@@ -152,31 +152,31 @@ discard block |
||
152 | 152 | * @param int $nbPointilles Nb pointilles |
153 | 153 | * @return void |
154 | 154 | */ |
155 | - function _Pointille(&$pdf,$x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$nbPointilles=15) |
|
155 | + function _Pointille(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $nbPointilles = 15) |
|
156 | 156 | { |
157 | 157 | // phpcs:enable |
158 | 158 | $pdf->SetLineWidth($epaisseur); |
159 | - $length=abs($x1-$x2); |
|
160 | - $hauteur=abs($y1-$y2); |
|
161 | - if($length>$hauteur) { |
|
162 | - $Pointilles=($length/$nbPointilles)/2; // taille des pointilles |
|
159 | + $length = abs($x1 - $x2); |
|
160 | + $hauteur = abs($y1 - $y2); |
|
161 | + if ($length > $hauteur) { |
|
162 | + $Pointilles = ($length / $nbPointilles) / 2; // taille des pointilles |
|
163 | 163 | } |
164 | 164 | else { |
165 | - $Pointilles=($hauteur/$nbPointilles)/2; |
|
165 | + $Pointilles = ($hauteur / $nbPointilles) / 2; |
|
166 | 166 | } |
167 | - for($i=$x1;$i<=$x2;$i+=$Pointilles+$Pointilles) { |
|
168 | - for($j=$i;$j<=($i+$Pointilles);$j++) { |
|
169 | - if($j<=($x2-1)) { |
|
170 | - $pdf->Line($j,$y1,$j+1,$y1); // on trace le pointill? du haut, point par point |
|
171 | - $pdf->Line($j,$y2,$j+1,$y2); // on trace le pointill? du bas, point par point |
|
167 | + for ($i = $x1; $i <= $x2; $i += $Pointilles + $Pointilles) { |
|
168 | + for ($j = $i; $j <= ($i + $Pointilles); $j++) { |
|
169 | + if ($j <= ($x2 - 1)) { |
|
170 | + $pdf->Line($j, $y1, $j + 1, $y1); // on trace le pointill? du haut, point par point |
|
171 | + $pdf->Line($j, $y2, $j + 1, $y2); // on trace le pointill? du bas, point par point |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | } |
175 | - for($i=$y1;$i<=$y2;$i+=$Pointilles+$Pointilles) { |
|
176 | - for($j=$i;$j<=($i+$Pointilles);$j++) { |
|
177 | - if($j<=($y2-1)) { |
|
178 | - $pdf->Line($x1,$j,$x1,$j+1); // on trace le pointill? du haut, point par point |
|
179 | - $pdf->Line($x2,$j,$x2,$j+1); // on trace le pointill? du bas, point par point |
|
175 | + for ($i = $y1; $i <= $y2; $i += $Pointilles + $Pointilles) { |
|
176 | + for ($j = $i; $j <= ($i + $Pointilles); $j++) { |
|
177 | + if ($j <= ($y2 - 1)) { |
|
178 | + $pdf->Line($x1, $j, $x1, $j + 1); // on trace le pointill? du haut, point par point |
|
179 | + $pdf->Line($x2, $j, $x2, $j + 1); // on trace le pointill? du bas, point par point |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | } |
@@ -195,27 +195,27 @@ discard block |
||
195 | 195 | * @param int $taille Size |
196 | 196 | * @return void |
197 | 197 | */ |
198 | - function _Croix(&$pdf,$x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$taille=4) |
|
198 | + function _Croix(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $taille = 4) |
|
199 | 199 | { |
200 | 200 | // phpcs:enable |
201 | - $pdf->SetDrawColor(192,192,192); |
|
201 | + $pdf->SetDrawColor(192, 192, 192); |
|
202 | 202 | |
203 | 203 | $pdf->SetLineWidth($epaisseur); |
204 | - $lg=$taille/2; |
|
204 | + $lg = $taille / 2; |
|
205 | 205 | // croix haut gauche |
206 | - $pdf->Line($x1,$y1-$lg,$x1,$y1+$lg); |
|
207 | - $pdf->Line($x1-$lg,$y1,$x1+$lg,$y1); |
|
206 | + $pdf->Line($x1, $y1 - $lg, $x1, $y1 + $lg); |
|
207 | + $pdf->Line($x1 - $lg, $y1, $x1 + $lg, $y1); |
|
208 | 208 | // croix bas gauche |
209 | - $pdf->Line($x1,$y2-$lg,$x1,$y2+$lg); |
|
210 | - $pdf->Line($x1-$lg,$y2,$x1+$lg,$y2); |
|
209 | + $pdf->Line($x1, $y2 - $lg, $x1, $y2 + $lg); |
|
210 | + $pdf->Line($x1 - $lg, $y2, $x1 + $lg, $y2); |
|
211 | 211 | // croix haut droit |
212 | - $pdf->Line($x2,$y1-$lg,$x2,$y1+$lg); |
|
213 | - $pdf->Line($x2-$lg,$y1,$x2+$lg,$y1); |
|
212 | + $pdf->Line($x2, $y1 - $lg, $x2, $y1 + $lg); |
|
213 | + $pdf->Line($x2 - $lg, $y1, $x2 + $lg, $y1); |
|
214 | 214 | // croix bas droit |
215 | - $pdf->Line($x2,$y2-$lg,$x2,$y2+$lg); |
|
216 | - $pdf->Line($x2-$lg,$y2,$x2+$lg,$y2); |
|
215 | + $pdf->Line($x2, $y2 - $lg, $x2, $y2 + $lg); |
|
216 | + $pdf->Line($x2 - $lg, $y2, $x2 + $lg, $y2); |
|
217 | 217 | |
218 | - $pdf->SetDrawColor(0,0,0); |
|
218 | + $pdf->SetDrawColor(0, 0, 0); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | $this->_Metric = $format['metric']; |
274 | 274 | $this->_Avery_Name = $format['name']; |
275 | 275 | $this->_Avery_Code = $format['code']; |
276 | - $this->_Margin_Left = $this->convertMetric($format['marginLeft'], $this->_Metric, $this->_Metric_Doc); |
|
276 | + $this->_Margin_Left = $this->convertMetric($format['marginLeft'], $this->_Metric, $this->_Metric_Doc); |
|
277 | 277 | $this->_Margin_Top = $this->convertMetric($format['marginTop'], $this->_Metric, $this->_Metric_Doc); |
278 | 278 | $this->_X_Space = $this->convertMetric($format['SpaceX'], $this->_Metric, $this->_Metric_Doc); |
279 | 279 | $this->_Y_Space = $this->convertMetric($format['SpaceY'], $this->_Metric, $this->_Metric_Doc); |
@@ -160,8 +160,7 @@ |
||
160 | 160 | $hauteur=abs($y1-$y2); |
161 | 161 | if($length>$hauteur) { |
162 | 162 | $Pointilles=($length/$nbPointilles)/2; // taille des pointilles |
163 | - } |
|
164 | - else { |
|
163 | + } else { |
|
165 | 164 | $Pointilles=($hauteur/$nbPointilles)/2; |
166 | 165 | } |
167 | 166 | for($i=$x1;$i<=$x2;$i+=$Pointilles+$Pointilles) { |
@@ -27,26 +27,26 @@ discard block |
||
27 | 27 | */ |
28 | 28 | class FormSocialContrib |
29 | 29 | { |
30 | - /** |
|
30 | + /** |
|
31 | 31 | * @var DoliDB Database handler. |
32 | 32 | */ |
33 | 33 | public $db; |
34 | 34 | |
35 | - /** |
|
36 | - * @var string Error code (or message) |
|
37 | - */ |
|
38 | - public $error=''; |
|
35 | + /** |
|
36 | + * @var string Error code (or message) |
|
37 | + */ |
|
38 | + public $error=''; |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * Constructor |
|
43 | - * |
|
44 | - * @param DoliDB $db Database handler |
|
45 | - */ |
|
46 | - public function __construct($db) |
|
47 | - { |
|
48 | - $this->db = $db; |
|
49 | - } |
|
41 | + /** |
|
42 | + * Constructor |
|
43 | + * |
|
44 | + * @param DoliDB $db Database handler |
|
45 | + */ |
|
46 | + public function __construct($db) |
|
47 | + { |
|
48 | + $this->db = $db; |
|
49 | + } |
|
50 | 50 | |
51 | 51 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
52 | 52 | /** |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $num = $db->num_rows($resql); |
97 | 97 | if ($num) |
98 | 98 | { |
99 | - print '<select class="'.($morecss?$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'">'; |
|
99 | + print '<select class="'.($morecss?$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'">'; |
|
100 | 100 | $i = 0; |
101 | 101 | |
102 | 102 | if ($useempty) print '<option value="0"> </option>'; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @var string Error code (or message) |
37 | 37 | */ |
38 | - public $error=''; |
|
38 | + public $error = ''; |
|
39 | 39 | |
40 | 40 | |
41 | 41 | /** |
@@ -61,42 +61,42 @@ discard block |
||
61 | 61 | * @param string $morecss Add more CSS on select |
62 | 62 | * @return void |
63 | 63 | */ |
64 | - function select_type_socialcontrib($selected='',$htmlname='actioncode', $useempty=0, $maxlen=40, $help=1, $morecss='minwidth300') |
|
64 | + function select_type_socialcontrib($selected = '', $htmlname = 'actioncode', $useempty = 0, $maxlen = 40, $help = 1, $morecss = 'minwidth300') |
|
65 | 65 | { |
66 | 66 | // phpcs:enable |
67 | - global $conf,$db,$langs,$user,$mysoc; |
|
67 | + global $conf, $db, $langs, $user, $mysoc; |
|
68 | 68 | |
69 | 69 | if (empty($mysoc->country_id) && empty($mysoc->country_code)) |
70 | 70 | { |
71 | - dol_print_error('','Call to select_type_socialcontrib with mysoc country not yet defined'); |
|
71 | + dol_print_error('', 'Call to select_type_socialcontrib with mysoc country not yet defined'); |
|
72 | 72 | exit; |
73 | 73 | } |
74 | 74 | |
75 | - if (! empty($mysoc->country_id)) |
|
75 | + if (!empty($mysoc->country_id)) |
|
76 | 76 | { |
77 | 77 | $sql = "SELECT c.id, c.libelle as type"; |
78 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; |
|
79 | - $sql.= " WHERE c.active = 1"; |
|
80 | - $sql.= " AND c.fk_pays = ".$mysoc->country_id; |
|
81 | - $sql.= " ORDER BY c.libelle ASC"; |
|
78 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; |
|
79 | + $sql .= " WHERE c.active = 1"; |
|
80 | + $sql .= " AND c.fk_pays = ".$mysoc->country_id; |
|
81 | + $sql .= " ORDER BY c.libelle ASC"; |
|
82 | 82 | } |
83 | 83 | else |
84 | 84 | { |
85 | 85 | $sql = "SELECT c.id, c.libelle as type"; |
86 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."c_country as co"; |
|
87 | - $sql.= " WHERE c.active = 1 AND c.fk_pays = co.rowid"; |
|
88 | - $sql.= " AND co.code = '".$mysoc->country_code."'"; |
|
89 | - $sql.= " ORDER BY c.libelle ASC"; |
|
86 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."c_country as co"; |
|
87 | + $sql .= " WHERE c.active = 1 AND c.fk_pays = co.rowid"; |
|
88 | + $sql .= " AND co.code = '".$mysoc->country_code."'"; |
|
89 | + $sql .= " ORDER BY c.libelle ASC"; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | dol_syslog("Form::select_type_socialcontrib", LOG_DEBUG); |
93 | - $resql=$db->query($sql); |
|
93 | + $resql = $db->query($sql); |
|
94 | 94 | if ($resql) |
95 | 95 | { |
96 | 96 | $num = $db->num_rows($resql); |
97 | 97 | if ($num) |
98 | 98 | { |
99 | - print '<select class="'.($morecss?$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'">'; |
|
99 | + print '<select class="'.($morecss ? $morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'">'; |
|
100 | 100 | $i = 0; |
101 | 101 | |
102 | 102 | if ($useempty) print '<option value="0"> </option>'; |
@@ -105,21 +105,21 @@ discard block |
||
105 | 105 | $obj = $db->fetch_object($resql); |
106 | 106 | print '<option value="'.$obj->id.'"'; |
107 | 107 | if ($obj->id == $selected) print ' selected'; |
108 | - print '>'.dol_trunc($obj->type,$maxlen); |
|
108 | + print '>'.dol_trunc($obj->type, $maxlen); |
|
109 | 109 | $i++; |
110 | 110 | } |
111 | 111 | print '</select>'; |
112 | - if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
113 | - if (! empty($conf->use_javascript_ajax)) print ajax_combobox($htmlname); |
|
112 | + if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
113 | + if (!empty($conf->use_javascript_ajax)) print ajax_combobox($htmlname); |
|
114 | 114 | } |
115 | 115 | else |
116 | 116 | { |
117 | - print $langs->trans("ErrorNoSocialContributionForSellerCountry",$mysoc->country_code); |
|
117 | + print $langs->trans("ErrorNoSocialContributionForSellerCountry", $mysoc->country_code); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | else |
121 | 121 | { |
122 | - dol_print_error($db,$db->lasterror()); |
|
122 | + dol_print_error($db, $db->lasterror()); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | } |
@@ -79,8 +79,7 @@ discard block |
||
79 | 79 | $sql.= " WHERE c.active = 1"; |
80 | 80 | $sql.= " AND c.fk_pays = ".$mysoc->country_id; |
81 | 81 | $sql.= " ORDER BY c.libelle ASC"; |
82 | - } |
|
83 | - else |
|
82 | + } else |
|
84 | 83 | { |
85 | 84 | $sql = "SELECT c.id, c.libelle as type"; |
86 | 85 | $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."c_country as co"; |
@@ -99,25 +98,31 @@ discard block |
||
99 | 98 | print '<select class="'.($morecss?$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'">'; |
100 | 99 | $i = 0; |
101 | 100 | |
102 | - if ($useempty) print '<option value="0"> </option>'; |
|
101 | + if ($useempty) { |
|
102 | + print '<option value="0"> </option>'; |
|
103 | + } |
|
103 | 104 | while ($i < $num) |
104 | 105 | { |
105 | 106 | $obj = $db->fetch_object($resql); |
106 | 107 | print '<option value="'.$obj->id.'"'; |
107 | - if ($obj->id == $selected) print ' selected'; |
|
108 | + if ($obj->id == $selected) { |
|
109 | + print ' selected'; |
|
110 | + } |
|
108 | 111 | print '>'.dol_trunc($obj->type,$maxlen); |
109 | 112 | $i++; |
110 | 113 | } |
111 | 114 | print '</select>'; |
112 | - if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
113 | - if (! empty($conf->use_javascript_ajax)) print ajax_combobox($htmlname); |
|
114 | - } |
|
115 | - else |
|
115 | + if ($user->admin && $help) { |
|
116 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
117 | + } |
|
118 | + if (! empty($conf->use_javascript_ajax)) { |
|
119 | + print ajax_combobox($htmlname); |
|
120 | + } |
|
121 | + } else |
|
116 | 122 | { |
117 | 123 | print $langs->trans("ErrorNoSocialContributionForSellerCountry",$mysoc->country_code); |
118 | 124 | } |
119 | - } |
|
120 | - else |
|
125 | + } else |
|
121 | 126 | { |
122 | 127 | dol_print_error($db,$db->lasterror()); |
123 | 128 | } |
@@ -32,38 +32,38 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class Ccountry // extends CommonObject |
34 | 34 | { |
35 | - /** |
|
35 | + /** |
|
36 | 36 | * @var DoliDB Database handler. |
37 | 37 | */ |
38 | 38 | public $db; |
39 | 39 | |
40 | - /** |
|
41 | - * @var string Error code (or message) |
|
42 | - */ |
|
43 | - public $error=''; |
|
40 | + /** |
|
41 | + * @var string Error code (or message) |
|
42 | + */ |
|
43 | + public $error=''; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @var string[] Error codes (or messages) |
|
47 | - */ |
|
48 | - public $errors = array(); |
|
45 | + /** |
|
46 | + * @var string[] Error codes (or messages) |
|
47 | + */ |
|
48 | + public $errors = array(); |
|
49 | 49 | |
50 | - //var $element='ccountry'; //!< Id that identify managed objects |
|
51 | - //var $table_element='ccountry'; //!< Name of table without prefix where object is stored |
|
50 | + //var $element='ccountry'; //!< Id that identify managed objects |
|
51 | + //var $table_element='ccountry'; //!< Name of table without prefix where object is stored |
|
52 | 52 | |
53 | 53 | /** |
54 | - * @var int ID |
|
55 | - */ |
|
56 | - public $id; |
|
54 | + * @var int ID |
|
55 | + */ |
|
56 | + public $id; |
|
57 | 57 | |
58 | - public $code; |
|
59 | - public $code_iso; |
|
58 | + public $code; |
|
59 | + public $code_iso; |
|
60 | 60 | |
61 | - /** |
|
61 | + /** |
|
62 | 62 | * @var string Countries label |
63 | 63 | */ |
64 | 64 | public $label; |
65 | 65 | |
66 | - public $active; |
|
66 | + public $active; |
|
67 | 67 | |
68 | 68 | |
69 | 69 | |
@@ -88,73 +88,73 @@ discard block |
||
88 | 88 | */ |
89 | 89 | function create($user, $notrigger=0) |
90 | 90 | { |
91 | - global $conf, $langs; |
|
92 | - $error=0; |
|
91 | + global $conf, $langs; |
|
92 | + $error=0; |
|
93 | 93 | |
94 | - // Clean parameters |
|
95 | - if (isset($this->code)) $this->code=trim($this->code); |
|
96 | - if (isset($this->code_iso)) $this->code_iso=trim($this->code_iso); |
|
97 | - if (isset($this->label)) $this->label=trim($this->label); |
|
98 | - if (isset($this->active)) $this->active=trim($this->active); |
|
94 | + // Clean parameters |
|
95 | + if (isset($this->code)) $this->code=trim($this->code); |
|
96 | + if (isset($this->code_iso)) $this->code_iso=trim($this->code_iso); |
|
97 | + if (isset($this->label)) $this->label=trim($this->label); |
|
98 | + if (isset($this->active)) $this->active=trim($this->active); |
|
99 | 99 | |
100 | - // Check parameters |
|
101 | - // Put here code to add control on parameters values |
|
100 | + // Check parameters |
|
101 | + // Put here code to add control on parameters values |
|
102 | 102 | |
103 | 103 | // Insert request |
104 | - $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_country("; |
|
105 | - $sql.= "rowid,"; |
|
106 | - $sql.= "code,"; |
|
107 | - $sql.= "code_iso,"; |
|
108 | - $sql.= "label,"; |
|
109 | - $sql.= "active"; |
|
104 | + $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_country("; |
|
105 | + $sql.= "rowid,"; |
|
106 | + $sql.= "code,"; |
|
107 | + $sql.= "code_iso,"; |
|
108 | + $sql.= "label,"; |
|
109 | + $sql.= "active"; |
|
110 | 110 | $sql.= ") VALUES ("; |
111 | - $sql.= " ".(! isset($this->rowid)?'NULL':"'".$this->db->escape($this->rowid)."'").","; |
|
112 | - $sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").","; |
|
113 | - $sql.= " ".(! isset($this->code_iso)?'NULL':"'".$this->db->escape($this->code_iso)."'").","; |
|
114 | - $sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").","; |
|
115 | - $sql.= " ".(! isset($this->active)?'NULL':"'".$this->db->escape($this->active)."'").""; |
|
116 | - $sql.= ")"; |
|
111 | + $sql.= " ".(! isset($this->rowid)?'NULL':"'".$this->db->escape($this->rowid)."'").","; |
|
112 | + $sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").","; |
|
113 | + $sql.= " ".(! isset($this->code_iso)?'NULL':"'".$this->db->escape($this->code_iso)."'").","; |
|
114 | + $sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").","; |
|
115 | + $sql.= " ".(! isset($this->active)?'NULL':"'".$this->db->escape($this->active)."'").""; |
|
116 | + $sql.= ")"; |
|
117 | 117 | |
118 | - $this->db->begin(); |
|
118 | + $this->db->begin(); |
|
119 | 119 | |
120 | - dol_syslog(get_class($this)."::create", LOG_DEBUG); |
|
120 | + dol_syslog(get_class($this)."::create", LOG_DEBUG); |
|
121 | 121 | $resql=$this->db->query($sql); |
122 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
122 | + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
123 | 123 | |
124 | - if (! $error) |
|
124 | + if (! $error) |
|
125 | 125 | { |
126 | 126 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_country"); |
127 | 127 | |
128 | - if (! $notrigger) |
|
129 | - { |
|
130 | - // Uncomment this and change MYOBJECT to your own tag if you |
|
131 | - // want this action call a trigger. |
|
132 | - |
|
133 | - //// Call triggers |
|
134 | - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; |
|
135 | - //$interface=new Interfaces($this->db); |
|
136 | - //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); |
|
137 | - //if ($result < 0) { $error++; $this->errors=$interface->errors; } |
|
138 | - //// End call triggers |
|
139 | - } |
|
128 | + if (! $notrigger) |
|
129 | + { |
|
130 | + // Uncomment this and change MYOBJECT to your own tag if you |
|
131 | + // want this action call a trigger. |
|
132 | + |
|
133 | + //// Call triggers |
|
134 | + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; |
|
135 | + //$interface=new Interfaces($this->db); |
|
136 | + //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); |
|
137 | + //if ($result < 0) { $error++; $this->errors=$interface->errors; } |
|
138 | + //// End call triggers |
|
139 | + } |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | // Commit or rollback |
143 | 143 | if ($error) |
144 | - { |
|
145 | - foreach($this->errors as $errmsg) |
|
146 | - { |
|
147 | - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); |
|
148 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
149 | - } |
|
150 | - $this->db->rollback(); |
|
151 | - return -1*$error; |
|
152 | - } |
|
153 | - else |
|
154 | - { |
|
155 | - $this->db->commit(); |
|
144 | + { |
|
145 | + foreach($this->errors as $errmsg) |
|
146 | + { |
|
147 | + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); |
|
148 | + $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
149 | + } |
|
150 | + $this->db->rollback(); |
|
151 | + return -1*$error; |
|
152 | + } |
|
153 | + else |
|
154 | + { |
|
155 | + $this->db->commit(); |
|
156 | 156 | return $this->id; |
157 | - } |
|
157 | + } |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -167,18 +167,18 @@ discard block |
||
167 | 167 | */ |
168 | 168 | function fetch($id,$code='') |
169 | 169 | { |
170 | - global $langs; |
|
170 | + global $langs; |
|
171 | 171 | $sql = "SELECT"; |
172 | - $sql.= " t.rowid,"; |
|
173 | - $sql.= " t.code,"; |
|
174 | - $sql.= " t.code_iso,"; |
|
175 | - $sql.= " t.label,"; |
|
176 | - $sql.= " t.active"; |
|
172 | + $sql.= " t.rowid,"; |
|
173 | + $sql.= " t.code,"; |
|
174 | + $sql.= " t.code_iso,"; |
|
175 | + $sql.= " t.label,"; |
|
176 | + $sql.= " t.active"; |
|
177 | 177 | $sql.= " FROM ".MAIN_DB_PREFIX."c_country as t"; |
178 | 178 | if ($id) $sql.= " WHERE t.rowid = ".$id; |
179 | 179 | elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; |
180 | 180 | |
181 | - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
|
181 | + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
|
182 | 182 | $resql=$this->db->query($sql); |
183 | 183 | if ($resql) |
184 | 184 | { |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | $obj = $this->db->fetch_object($resql); |
188 | 188 | |
189 | 189 | $this->id = $obj->rowid; |
190 | - $this->code = $obj->code; |
|
191 | - $this->code_iso = $obj->code_iso; |
|
192 | - $this->label = $obj->label; |
|
193 | - $this->active = $obj->active; |
|
190 | + $this->code = $obj->code; |
|
191 | + $this->code_iso = $obj->code_iso; |
|
192 | + $this->label = $obj->label; |
|
193 | + $this->active = $obj->active; |
|
194 | 194 | |
195 | 195 | $this->db->free($resql); |
196 | 196 | return 1; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | } |
202 | 202 | else |
203 | 203 | { |
204 | - $this->error="Error ".$this->db->lasterror(); |
|
204 | + $this->error="Error ".$this->db->lasterror(); |
|
205 | 205 | return -1; |
206 | 206 | } |
207 | 207 | } |
@@ -216,120 +216,120 @@ discard block |
||
216 | 216 | */ |
217 | 217 | function update($user=null, $notrigger=0) |
218 | 218 | { |
219 | - global $conf, $langs; |
|
220 | - $error=0; |
|
219 | + global $conf, $langs; |
|
220 | + $error=0; |
|
221 | 221 | |
222 | - // Clean parameters |
|
223 | - if (isset($this->code)) $this->code=trim($this->code); |
|
224 | - if (isset($this->code_iso)) $this->code_iso=trim($this->code_iso); |
|
225 | - if (isset($this->label)) $this->label=trim($this->label); |
|
226 | - if (isset($this->active)) $this->active=trim($this->active); |
|
222 | + // Clean parameters |
|
223 | + if (isset($this->code)) $this->code=trim($this->code); |
|
224 | + if (isset($this->code_iso)) $this->code_iso=trim($this->code_iso); |
|
225 | + if (isset($this->label)) $this->label=trim($this->label); |
|
226 | + if (isset($this->active)) $this->active=trim($this->active); |
|
227 | 227 | |
228 | 228 | |
229 | - // Check parameters |
|
230 | - // Put here code to add control on parameters values |
|
229 | + // Check parameters |
|
230 | + // Put here code to add control on parameters values |
|
231 | 231 | |
232 | 232 | // Update request |
233 | 233 | $sql = "UPDATE ".MAIN_DB_PREFIX."c_country SET"; |
234 | - $sql.= " code=".(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").","; |
|
235 | - $sql.= " code_iso=".(isset($this->code_iso)?"'".$this->db->escape($this->code_iso)."'":"null").","; |
|
236 | - $sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").","; |
|
237 | - $sql.= " active=".(isset($this->active)?$this->active:"null").""; |
|
234 | + $sql.= " code=".(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").","; |
|
235 | + $sql.= " code_iso=".(isset($this->code_iso)?"'".$this->db->escape($this->code_iso)."'":"null").","; |
|
236 | + $sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").","; |
|
237 | + $sql.= " active=".(isset($this->active)?$this->active:"null").""; |
|
238 | 238 | $sql.= " WHERE rowid=".$this->id; |
239 | 239 | |
240 | - $this->db->begin(); |
|
240 | + $this->db->begin(); |
|
241 | 241 | |
242 | - dol_syslog(get_class($this)."::update", LOG_DEBUG); |
|
242 | + dol_syslog(get_class($this)."::update", LOG_DEBUG); |
|
243 | 243 | $resql = $this->db->query($sql); |
244 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
245 | - |
|
246 | - if (! $error) |
|
247 | - { |
|
248 | - if (! $notrigger) |
|
249 | - { |
|
250 | - // Uncomment this and change MYOBJECT to your own tag if you |
|
251 | - // want this action call a trigger. |
|
252 | - |
|
253 | - //// Call triggers |
|
254 | - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; |
|
255 | - //$interface=new Interfaces($this->db); |
|
256 | - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); |
|
257 | - //if ($result < 0) { $error++; $this->errors=$interface->errors; } |
|
258 | - //// End call triggers |
|
259 | - } |
|
260 | - } |
|
244 | + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
245 | + |
|
246 | + if (! $error) |
|
247 | + { |
|
248 | + if (! $notrigger) |
|
249 | + { |
|
250 | + // Uncomment this and change MYOBJECT to your own tag if you |
|
251 | + // want this action call a trigger. |
|
252 | + |
|
253 | + //// Call triggers |
|
254 | + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; |
|
255 | + //$interface=new Interfaces($this->db); |
|
256 | + //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); |
|
257 | + //if ($result < 0) { $error++; $this->errors=$interface->errors; } |
|
258 | + //// End call triggers |
|
259 | + } |
|
260 | + } |
|
261 | 261 | |
262 | 262 | // Commit or rollback |
263 | - if ($error) |
|
264 | - { |
|
265 | - foreach($this->errors as $errmsg) |
|
266 | - { |
|
267 | - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
|
268 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
269 | - } |
|
270 | - $this->db->rollback(); |
|
271 | - return -1*$error; |
|
272 | - } |
|
273 | - else |
|
274 | - { |
|
275 | - $this->db->commit(); |
|
276 | - return 1; |
|
277 | - } |
|
263 | + if ($error) |
|
264 | + { |
|
265 | + foreach($this->errors as $errmsg) |
|
266 | + { |
|
267 | + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
|
268 | + $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
269 | + } |
|
270 | + $this->db->rollback(); |
|
271 | + return -1*$error; |
|
272 | + } |
|
273 | + else |
|
274 | + { |
|
275 | + $this->db->commit(); |
|
276 | + return 1; |
|
277 | + } |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | |
281 | - /** |
|
282 | - * Delete object in database |
|
283 | - * |
|
284 | - * @param User $user User that delete |
|
285 | - * @param int $notrigger 0=launch triggers after, 1=disable triggers |
|
286 | - * @return int <0 if KO, >0 if OK |
|
287 | - */ |
|
288 | - function delete($user, $notrigger=0) |
|
289 | - { |
|
290 | - global $conf, $langs; |
|
291 | - $error=0; |
|
292 | - |
|
293 | - $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_country"; |
|
294 | - $sql.= " WHERE rowid=".$this->id; |
|
295 | - |
|
296 | - $this->db->begin(); |
|
297 | - |
|
298 | - dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
|
299 | - $resql = $this->db->query($sql); |
|
300 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
301 | - |
|
302 | - if (! $error) |
|
303 | - { |
|
304 | - if (! $notrigger) |
|
305 | - { |
|
306 | - // Uncomment this and change MYOBJECT to your own tag if you |
|
307 | - // want this action call a trigger. |
|
308 | - |
|
309 | - //// Call triggers |
|
310 | - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; |
|
311 | - //$interface=new Interfaces($this->db); |
|
312 | - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); |
|
313 | - //if ($result < 0) { $error++; $this->errors=$interface->errors; } |
|
314 | - //// End call triggers |
|
315 | - } |
|
316 | - } |
|
281 | + /** |
|
282 | + * Delete object in database |
|
283 | + * |
|
284 | + * @param User $user User that delete |
|
285 | + * @param int $notrigger 0=launch triggers after, 1=disable triggers |
|
286 | + * @return int <0 if KO, >0 if OK |
|
287 | + */ |
|
288 | + function delete($user, $notrigger=0) |
|
289 | + { |
|
290 | + global $conf, $langs; |
|
291 | + $error=0; |
|
292 | + |
|
293 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_country"; |
|
294 | + $sql.= " WHERE rowid=".$this->id; |
|
295 | + |
|
296 | + $this->db->begin(); |
|
297 | + |
|
298 | + dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
|
299 | + $resql = $this->db->query($sql); |
|
300 | + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
301 | + |
|
302 | + if (! $error) |
|
303 | + { |
|
304 | + if (! $notrigger) |
|
305 | + { |
|
306 | + // Uncomment this and change MYOBJECT to your own tag if you |
|
307 | + // want this action call a trigger. |
|
308 | + |
|
309 | + //// Call triggers |
|
310 | + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; |
|
311 | + //$interface=new Interfaces($this->db); |
|
312 | + //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); |
|
313 | + //if ($result < 0) { $error++; $this->errors=$interface->errors; } |
|
314 | + //// End call triggers |
|
315 | + } |
|
316 | + } |
|
317 | 317 | |
318 | 318 | // Commit or rollback |
319 | - if ($error) |
|
320 | - { |
|
321 | - foreach($this->errors as $errmsg) |
|
322 | - { |
|
323 | - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
|
324 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
325 | - } |
|
326 | - $this->db->rollback(); |
|
327 | - return -1*$error; |
|
328 | - } |
|
329 | - else |
|
330 | - { |
|
331 | - $this->db->commit(); |
|
332 | - return 1; |
|
333 | - } |
|
334 | - } |
|
319 | + if ($error) |
|
320 | + { |
|
321 | + foreach($this->errors as $errmsg) |
|
322 | + { |
|
323 | + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
|
324 | + $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
325 | + } |
|
326 | + $this->db->rollback(); |
|
327 | + return -1*$error; |
|
328 | + } |
|
329 | + else |
|
330 | + { |
|
331 | + $this->db->commit(); |
|
332 | + return 1; |
|
333 | + } |
|
334 | + } |
|
335 | 335 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * @var string Error code (or message) |
42 | 42 | */ |
43 | - public $error=''; |
|
43 | + public $error = ''; |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @var string[] Error codes (or messages) |
@@ -86,46 +86,46 @@ discard block |
||
86 | 86 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
87 | 87 | * @return int <0 if KO, Id of created object if OK |
88 | 88 | */ |
89 | - function create($user, $notrigger=0) |
|
89 | + function create($user, $notrigger = 0) |
|
90 | 90 | { |
91 | 91 | global $conf, $langs; |
92 | - $error=0; |
|
92 | + $error = 0; |
|
93 | 93 | |
94 | 94 | // Clean parameters |
95 | - if (isset($this->code)) $this->code=trim($this->code); |
|
96 | - if (isset($this->code_iso)) $this->code_iso=trim($this->code_iso); |
|
97 | - if (isset($this->label)) $this->label=trim($this->label); |
|
98 | - if (isset($this->active)) $this->active=trim($this->active); |
|
95 | + if (isset($this->code)) $this->code = trim($this->code); |
|
96 | + if (isset($this->code_iso)) $this->code_iso = trim($this->code_iso); |
|
97 | + if (isset($this->label)) $this->label = trim($this->label); |
|
98 | + if (isset($this->active)) $this->active = trim($this->active); |
|
99 | 99 | |
100 | 100 | // Check parameters |
101 | 101 | // Put here code to add control on parameters values |
102 | 102 | |
103 | 103 | // Insert request |
104 | 104 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_country("; |
105 | - $sql.= "rowid,"; |
|
106 | - $sql.= "code,"; |
|
107 | - $sql.= "code_iso,"; |
|
108 | - $sql.= "label,"; |
|
109 | - $sql.= "active"; |
|
110 | - $sql.= ") VALUES ("; |
|
111 | - $sql.= " ".(! isset($this->rowid)?'NULL':"'".$this->db->escape($this->rowid)."'").","; |
|
112 | - $sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").","; |
|
113 | - $sql.= " ".(! isset($this->code_iso)?'NULL':"'".$this->db->escape($this->code_iso)."'").","; |
|
114 | - $sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").","; |
|
115 | - $sql.= " ".(! isset($this->active)?'NULL':"'".$this->db->escape($this->active)."'").""; |
|
116 | - $sql.= ")"; |
|
105 | + $sql .= "rowid,"; |
|
106 | + $sql .= "code,"; |
|
107 | + $sql .= "code_iso,"; |
|
108 | + $sql .= "label,"; |
|
109 | + $sql .= "active"; |
|
110 | + $sql .= ") VALUES ("; |
|
111 | + $sql .= " ".(!isset($this->rowid) ? 'NULL' : "'".$this->db->escape($this->rowid)."'").","; |
|
112 | + $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; |
|
113 | + $sql .= " ".(!isset($this->code_iso) ? 'NULL' : "'".$this->db->escape($this->code_iso)."'").","; |
|
114 | + $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").","; |
|
115 | + $sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->escape($this->active)."'").""; |
|
116 | + $sql .= ")"; |
|
117 | 117 | |
118 | 118 | $this->db->begin(); |
119 | 119 | |
120 | 120 | dol_syslog(get_class($this)."::create", LOG_DEBUG); |
121 | - $resql=$this->db->query($sql); |
|
122 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
121 | + $resql = $this->db->query($sql); |
|
122 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
123 | 123 | |
124 | - if (! $error) |
|
124 | + if (!$error) |
|
125 | 125 | { |
126 | 126 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_country"); |
127 | 127 | |
128 | - if (! $notrigger) |
|
128 | + if (!$notrigger) |
|
129 | 129 | { |
130 | 130 | // Uncomment this and change MYOBJECT to your own tag if you |
131 | 131 | // want this action call a trigger. |
@@ -142,13 +142,13 @@ discard block |
||
142 | 142 | // Commit or rollback |
143 | 143 | if ($error) |
144 | 144 | { |
145 | - foreach($this->errors as $errmsg) |
|
145 | + foreach ($this->errors as $errmsg) |
|
146 | 146 | { |
147 | 147 | dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); |
148 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
148 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
149 | 149 | } |
150 | 150 | $this->db->rollback(); |
151 | - return -1*$error; |
|
151 | + return -1 * $error; |
|
152 | 152 | } |
153 | 153 | else |
154 | 154 | { |
@@ -165,28 +165,28 @@ discard block |
||
165 | 165 | * @param string $code Code |
166 | 166 | * @return int >0 if OK, 0 if not found, <0 if KO |
167 | 167 | */ |
168 | - function fetch($id,$code='') |
|
168 | + function fetch($id, $code = '') |
|
169 | 169 | { |
170 | 170 | global $langs; |
171 | 171 | $sql = "SELECT"; |
172 | - $sql.= " t.rowid,"; |
|
173 | - $sql.= " t.code,"; |
|
174 | - $sql.= " t.code_iso,"; |
|
175 | - $sql.= " t.label,"; |
|
176 | - $sql.= " t.active"; |
|
177 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_country as t"; |
|
178 | - if ($id) $sql.= " WHERE t.rowid = ".$id; |
|
179 | - elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; |
|
172 | + $sql .= " t.rowid,"; |
|
173 | + $sql .= " t.code,"; |
|
174 | + $sql .= " t.code_iso,"; |
|
175 | + $sql .= " t.label,"; |
|
176 | + $sql .= " t.active"; |
|
177 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_country as t"; |
|
178 | + if ($id) $sql .= " WHERE t.rowid = ".$id; |
|
179 | + elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; |
|
180 | 180 | |
181 | 181 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
182 | - $resql=$this->db->query($sql); |
|
182 | + $resql = $this->db->query($sql); |
|
183 | 183 | if ($resql) |
184 | 184 | { |
185 | 185 | if ($this->db->num_rows($resql)) |
186 | 186 | { |
187 | 187 | $obj = $this->db->fetch_object($resql); |
188 | 188 | |
189 | - $this->id = $obj->rowid; |
|
189 | + $this->id = $obj->rowid; |
|
190 | 190 | $this->code = $obj->code; |
191 | 191 | $this->code_iso = $obj->code_iso; |
192 | 192 | $this->label = $obj->label; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | } |
202 | 202 | else |
203 | 203 | { |
204 | - $this->error="Error ".$this->db->lasterror(); |
|
204 | + $this->error = "Error ".$this->db->lasterror(); |
|
205 | 205 | return -1; |
206 | 206 | } |
207 | 207 | } |
@@ -214,16 +214,16 @@ discard block |
||
214 | 214 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
215 | 215 | * @return int <0 if KO, >0 if OK |
216 | 216 | */ |
217 | - function update($user=null, $notrigger=0) |
|
217 | + function update($user = null, $notrigger = 0) |
|
218 | 218 | { |
219 | 219 | global $conf, $langs; |
220 | - $error=0; |
|
220 | + $error = 0; |
|
221 | 221 | |
222 | 222 | // Clean parameters |
223 | - if (isset($this->code)) $this->code=trim($this->code); |
|
224 | - if (isset($this->code_iso)) $this->code_iso=trim($this->code_iso); |
|
225 | - if (isset($this->label)) $this->label=trim($this->label); |
|
226 | - if (isset($this->active)) $this->active=trim($this->active); |
|
223 | + if (isset($this->code)) $this->code = trim($this->code); |
|
224 | + if (isset($this->code_iso)) $this->code_iso = trim($this->code_iso); |
|
225 | + if (isset($this->label)) $this->label = trim($this->label); |
|
226 | + if (isset($this->active)) $this->active = trim($this->active); |
|
227 | 227 | |
228 | 228 | |
229 | 229 | // Check parameters |
@@ -231,21 +231,21 @@ discard block |
||
231 | 231 | |
232 | 232 | // Update request |
233 | 233 | $sql = "UPDATE ".MAIN_DB_PREFIX."c_country SET"; |
234 | - $sql.= " code=".(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").","; |
|
235 | - $sql.= " code_iso=".(isset($this->code_iso)?"'".$this->db->escape($this->code_iso)."'":"null").","; |
|
236 | - $sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").","; |
|
237 | - $sql.= " active=".(isset($this->active)?$this->active:"null").""; |
|
238 | - $sql.= " WHERE rowid=".$this->id; |
|
234 | + $sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").","; |
|
235 | + $sql .= " code_iso=".(isset($this->code_iso) ? "'".$this->db->escape($this->code_iso)."'" : "null").","; |
|
236 | + $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; |
|
237 | + $sql .= " active=".(isset($this->active) ? $this->active : "null").""; |
|
238 | + $sql .= " WHERE rowid=".$this->id; |
|
239 | 239 | |
240 | 240 | $this->db->begin(); |
241 | 241 | |
242 | 242 | dol_syslog(get_class($this)."::update", LOG_DEBUG); |
243 | 243 | $resql = $this->db->query($sql); |
244 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
244 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
245 | 245 | |
246 | - if (! $error) |
|
246 | + if (!$error) |
|
247 | 247 | { |
248 | - if (! $notrigger) |
|
248 | + if (!$notrigger) |
|
249 | 249 | { |
250 | 250 | // Uncomment this and change MYOBJECT to your own tag if you |
251 | 251 | // want this action call a trigger. |
@@ -262,13 +262,13 @@ discard block |
||
262 | 262 | // Commit or rollback |
263 | 263 | if ($error) |
264 | 264 | { |
265 | - foreach($this->errors as $errmsg) |
|
265 | + foreach ($this->errors as $errmsg) |
|
266 | 266 | { |
267 | 267 | dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
268 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
268 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
269 | 269 | } |
270 | 270 | $this->db->rollback(); |
271 | - return -1*$error; |
|
271 | + return -1 * $error; |
|
272 | 272 | } |
273 | 273 | else |
274 | 274 | { |
@@ -285,23 +285,23 @@ discard block |
||
285 | 285 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
286 | 286 | * @return int <0 if KO, >0 if OK |
287 | 287 | */ |
288 | - function delete($user, $notrigger=0) |
|
288 | + function delete($user, $notrigger = 0) |
|
289 | 289 | { |
290 | 290 | global $conf, $langs; |
291 | - $error=0; |
|
291 | + $error = 0; |
|
292 | 292 | |
293 | 293 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_country"; |
294 | - $sql.= " WHERE rowid=".$this->id; |
|
294 | + $sql .= " WHERE rowid=".$this->id; |
|
295 | 295 | |
296 | 296 | $this->db->begin(); |
297 | 297 | |
298 | 298 | dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
299 | 299 | $resql = $this->db->query($sql); |
300 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
300 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
301 | 301 | |
302 | - if (! $error) |
|
302 | + if (!$error) |
|
303 | 303 | { |
304 | - if (! $notrigger) |
|
304 | + if (!$notrigger) |
|
305 | 305 | { |
306 | 306 | // Uncomment this and change MYOBJECT to your own tag if you |
307 | 307 | // want this action call a trigger. |
@@ -318,13 +318,13 @@ discard block |
||
318 | 318 | // Commit or rollback |
319 | 319 | if ($error) |
320 | 320 | { |
321 | - foreach($this->errors as $errmsg) |
|
321 | + foreach ($this->errors as $errmsg) |
|
322 | 322 | { |
323 | 323 | dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
324 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
324 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
325 | 325 | } |
326 | 326 | $this->db->rollback(); |
327 | - return -1*$error; |
|
327 | + return -1 * $error; |
|
328 | 328 | } |
329 | 329 | else |
330 | 330 | { |
@@ -92,10 +92,18 @@ discard block |
||
92 | 92 | $error=0; |
93 | 93 | |
94 | 94 | // Clean parameters |
95 | - if (isset($this->code)) $this->code=trim($this->code); |
|
96 | - if (isset($this->code_iso)) $this->code_iso=trim($this->code_iso); |
|
97 | - if (isset($this->label)) $this->label=trim($this->label); |
|
98 | - if (isset($this->active)) $this->active=trim($this->active); |
|
95 | + if (isset($this->code)) { |
|
96 | + $this->code=trim($this->code); |
|
97 | + } |
|
98 | + if (isset($this->code_iso)) { |
|
99 | + $this->code_iso=trim($this->code_iso); |
|
100 | + } |
|
101 | + if (isset($this->label)) { |
|
102 | + $this->label=trim($this->label); |
|
103 | + } |
|
104 | + if (isset($this->active)) { |
|
105 | + $this->active=trim($this->active); |
|
106 | + } |
|
99 | 107 | |
100 | 108 | // Check parameters |
101 | 109 | // Put here code to add control on parameters values |
@@ -149,8 +157,7 @@ discard block |
||
149 | 157 | } |
150 | 158 | $this->db->rollback(); |
151 | 159 | return -1*$error; |
152 | - } |
|
153 | - else |
|
160 | + } else |
|
154 | 161 | { |
155 | 162 | $this->db->commit(); |
156 | 163 | return $this->id; |
@@ -175,8 +182,11 @@ discard block |
||
175 | 182 | $sql.= " t.label,"; |
176 | 183 | $sql.= " t.active"; |
177 | 184 | $sql.= " FROM ".MAIN_DB_PREFIX."c_country as t"; |
178 | - if ($id) $sql.= " WHERE t.rowid = ".$id; |
|
179 | - elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; |
|
185 | + if ($id) { |
|
186 | + $sql.= " WHERE t.rowid = ".$id; |
|
187 | + } elseif ($code) { |
|
188 | + $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; |
|
189 | + } |
|
180 | 190 | |
181 | 191 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
182 | 192 | $resql=$this->db->query($sql); |
@@ -194,12 +204,10 @@ discard block |
||
194 | 204 | |
195 | 205 | $this->db->free($resql); |
196 | 206 | return 1; |
197 | - } |
|
198 | - else { |
|
207 | + } else { |
|
199 | 208 | return 0; |
200 | 209 | } |
201 | - } |
|
202 | - else |
|
210 | + } else |
|
203 | 211 | { |
204 | 212 | $this->error="Error ".$this->db->lasterror(); |
205 | 213 | return -1; |
@@ -220,10 +228,18 @@ discard block |
||
220 | 228 | $error=0; |
221 | 229 | |
222 | 230 | // Clean parameters |
223 | - if (isset($this->code)) $this->code=trim($this->code); |
|
224 | - if (isset($this->code_iso)) $this->code_iso=trim($this->code_iso); |
|
225 | - if (isset($this->label)) $this->label=trim($this->label); |
|
226 | - if (isset($this->active)) $this->active=trim($this->active); |
|
231 | + if (isset($this->code)) { |
|
232 | + $this->code=trim($this->code); |
|
233 | + } |
|
234 | + if (isset($this->code_iso)) { |
|
235 | + $this->code_iso=trim($this->code_iso); |
|
236 | + } |
|
237 | + if (isset($this->label)) { |
|
238 | + $this->label=trim($this->label); |
|
239 | + } |
|
240 | + if (isset($this->active)) { |
|
241 | + $this->active=trim($this->active); |
|
242 | + } |
|
227 | 243 | |
228 | 244 | |
229 | 245 | // Check parameters |
@@ -269,8 +285,7 @@ discard block |
||
269 | 285 | } |
270 | 286 | $this->db->rollback(); |
271 | 287 | return -1*$error; |
272 | - } |
|
273 | - else |
|
288 | + } else |
|
274 | 289 | { |
275 | 290 | $this->db->commit(); |
276 | 291 | return 1; |
@@ -325,8 +340,7 @@ discard block |
||
325 | 340 | } |
326 | 341 | $this->db->rollback(); |
327 | 342 | return -1*$error; |
328 | - } |
|
329 | - else |
|
343 | + } else |
|
330 | 344 | { |
331 | 345 | $this->db->commit(); |
332 | 346 | return 1; |
@@ -34,27 +34,27 @@ discard block |
||
34 | 34 | */ |
35 | 35 | abstract class CommonDocGenerator |
36 | 36 | { |
37 | - /** |
|
38 | - * @var string Error code (or message) |
|
39 | - */ |
|
40 | - public $error=''; |
|
37 | + /** |
|
38 | + * @var string Error code (or message) |
|
39 | + */ |
|
40 | + public $error=''; |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @var string[] Array of error strings |
44 | 44 | */ |
45 | 45 | public $errors = array(); |
46 | 46 | |
47 | - /** |
|
47 | + /** |
|
48 | 48 | * @var DoliDB Database handler. |
49 | 49 | */ |
50 | - protected $db; |
|
50 | + protected $db; |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * Constructor |
|
55 | - * |
|
56 | - * @param DoliDB $db Database handler |
|
57 | - */ |
|
53 | + /** |
|
54 | + * Constructor |
|
55 | + * |
|
56 | + * @param DoliDB $db Database handler |
|
57 | + */ |
|
58 | 58 | public function __construct($db) |
59 | 59 | { |
60 | 60 | $this->db = $db; |
@@ -82,18 +82,18 @@ discard block |
||
82 | 82 | 'myuser_fullname'=>$user->getFullName($outputlangs,1), |
83 | 83 | 'myuser_login'=>$user->login, |
84 | 84 | 'myuser_phone'=>$user->office_phone, |
85 | - 'myuser_address'=>$user->address, |
|
86 | - 'myuser_zip'=>$user->zip, |
|
87 | - 'myuser_town'=>$user->town, |
|
88 | - 'myuser_country'=>$user->country, |
|
89 | - 'myuser_country_code'=>$user->country_code, |
|
90 | - 'myuser_state'=>$user->state, |
|
91 | - 'myuser_state_code'=>$user->state_code, |
|
92 | - 'myuser_fax'=>$user->office_fax, |
|
85 | + 'myuser_address'=>$user->address, |
|
86 | + 'myuser_zip'=>$user->zip, |
|
87 | + 'myuser_town'=>$user->town, |
|
88 | + 'myuser_country'=>$user->country, |
|
89 | + 'myuser_country_code'=>$user->country_code, |
|
90 | + 'myuser_state'=>$user->state, |
|
91 | + 'myuser_state_code'=>$user->state_code, |
|
92 | + 'myuser_fax'=>$user->office_fax, |
|
93 | 93 | 'myuser_mobile'=>$user->user_mobile, |
94 | 94 | 'myuser_email'=>$user->email, |
95 | - 'myuser_logo'=>$logotouse, |
|
96 | - 'myuser_job'=>$user->job, |
|
95 | + 'myuser_logo'=>$logotouse, |
|
96 | + 'myuser_job'=>$user->job, |
|
97 | 97 | 'myuser_web'=>'' // url not exist in $user object |
98 | 98 | ); |
99 | 99 | } |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | } |
119 | 119 | if (empty($mysoc->country) && ! empty($mysoc->country_code)) |
120 | 120 | { |
121 | - $mysoc->country=$outputlangs->transnoentitiesnoconv("Country".$mysoc->country_code); |
|
121 | + $mysoc->country=$outputlangs->transnoentitiesnoconv("Country".$mysoc->country_code); |
|
122 | 122 | } |
123 | 123 | if (empty($mysoc->state) && ! empty($mysoc->state_code)) |
124 | 124 | { |
125 | - $mysoc->state=getState($mysoc->state_code,0); |
|
125 | + $mysoc->state=getState($mysoc->state_code,0); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | $logotouse=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | 'mycompany_country_code'=>$mysoc->country_code, |
141 | 141 | 'mycompany_state'=>$mysoc->state, |
142 | 142 | 'mycompany_state_code'=>$mysoc->state_code, |
143 | - 'mycompany_web'=>$mysoc->url, |
|
143 | + 'mycompany_web'=>$mysoc->url, |
|
144 | 144 | 'mycompany_juridicalstatus'=>$mysoc->forme_juridique, |
145 | 145 | 'mycompany_managers'=>$mysoc->managers, |
146 | 146 | 'mycompany_capital'=>$mysoc->capital, |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | 'mycompany_idprof4'=>$mysoc->idprof4, |
152 | 152 | 'mycompany_idprof5'=>$mysoc->idprof5, |
153 | 153 | 'mycompany_idprof6'=>$mysoc->idprof6, |
154 | - 'mycompany_vatnumber'=>$mysoc->tva_intra, |
|
155 | - 'mycompany_object'=>$mysoc->object, |
|
154 | + 'mycompany_vatnumber'=>$mysoc->tva_intra, |
|
155 | + 'mycompany_object'=>$mysoc->object, |
|
156 | 156 | 'mycompany_note_private'=>$mysoc->note_private, |
157 | 157 | //'mycompany_note_public'=>$mysoc->note_public, // Only private not exists for "mysoc" but both for thirdparties |
158 | 158 | ); |
@@ -174,16 +174,16 @@ discard block |
||
174 | 174 | |
175 | 175 | if (empty($object->country) && ! empty($object->country_code)) |
176 | 176 | { |
177 | - $object->country=$outputlangs->transnoentitiesnoconv("Country".$object->country_code); |
|
177 | + $object->country=$outputlangs->transnoentitiesnoconv("Country".$object->country_code); |
|
178 | 178 | } |
179 | 179 | if (empty($object->state) && ! empty($object->state_code)) |
180 | 180 | { |
181 | - $object->state=getState($object->state_code,0); |
|
181 | + $object->state=getState($object->state_code,0); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $array_thirdparty = array( |
185 | 185 | 'company_name'=>$object->name, |
186 | - 'company_name_alias' => $object->name_alias, |
|
186 | + 'company_name_alias' => $object->name_alias, |
|
187 | 187 | 'company_email'=>$object->email, |
188 | 188 | 'company_phone'=>$object->phone, |
189 | 189 | 'company_fax'=>$object->fax, |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | 'company_zip'=>$object->zip, |
192 | 192 | 'company_town'=>$object->town, |
193 | 193 | 'company_country'=>$object->country, |
194 | - 'company_country_code'=>$object->country_code, |
|
194 | + 'company_country_code'=>$object->country_code, |
|
195 | 195 | 'company_state'=>$object->state, |
196 | - 'company_state_code'=>$object->state_code, |
|
197 | - 'company_web'=>$object->url, |
|
196 | + 'company_state_code'=>$object->state_code, |
|
197 | + 'company_web'=>$object->url, |
|
198 | 198 | 'company_barcode'=>$object->barcode, |
199 | 199 | 'company_vatnumber'=>$object->tva_intra, |
200 | 200 | 'company_customercode'=>$object->code_client, |
@@ -219,52 +219,52 @@ discard block |
||
219 | 219 | // Retrieve extrafields |
220 | 220 | if(is_array($object->array_options) && count($object->array_options)) |
221 | 221 | { |
222 | - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
223 | - $extrafields = new ExtraFields($this->db); |
|
224 | - $extralabels = $extrafields->fetch_name_optionals_label('societe',true); |
|
225 | - $object->fetch_optionals(); |
|
226 | - |
|
227 | - foreach($extrafields->attribute_label as $key=>$label) |
|
228 | - { |
|
229 | - if($extrafields->attribute_type[$key] == 'price') |
|
230 | - { |
|
231 | - $object->array_options['options_'.$key] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); |
|
232 | - } |
|
233 | - else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
234 | - { |
|
235 | - $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
|
236 | - } |
|
237 | - $array_thirdparty = array_merge($array_thirdparty, array ('company_options_'.$key => $object->array_options ['options_' . $key])); |
|
238 | - } |
|
239 | - } |
|
240 | - return $array_thirdparty; |
|
241 | - } |
|
222 | + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
223 | + $extrafields = new ExtraFields($this->db); |
|
224 | + $extralabels = $extrafields->fetch_name_optionals_label('societe',true); |
|
225 | + $object->fetch_optionals(); |
|
226 | + |
|
227 | + foreach($extrafields->attribute_label as $key=>$label) |
|
228 | + { |
|
229 | + if($extrafields->attribute_type[$key] == 'price') |
|
230 | + { |
|
231 | + $object->array_options['options_'.$key] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); |
|
232 | + } |
|
233 | + else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
234 | + { |
|
235 | + $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
|
236 | + } |
|
237 | + $array_thirdparty = array_merge($array_thirdparty, array ('company_options_'.$key => $object->array_options ['options_' . $key])); |
|
238 | + } |
|
239 | + } |
|
240 | + return $array_thirdparty; |
|
241 | + } |
|
242 | 242 | |
243 | 243 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
244 | - /** |
|
245 | - * Define array with couple subtitution key => subtitution value |
|
246 | - * |
|
247 | - * @param Contact $object contact |
|
248 | - * @param Translate $outputlangs object for output |
|
249 | - * @param array $array_key Name of the key for return array |
|
250 | - * @return array Array of substitution key->code |
|
251 | - */ |
|
244 | + /** |
|
245 | + * Define array with couple subtitution key => subtitution value |
|
246 | + * |
|
247 | + * @param Contact $object contact |
|
248 | + * @param Translate $outputlangs object for output |
|
249 | + * @param array $array_key Name of the key for return array |
|
250 | + * @return array Array of substitution key->code |
|
251 | + */ |
|
252 | 252 | function get_substitutionarray_contact($object, $outputlangs, $array_key = 'object') |
253 | 253 | { |
254 | 254 | // phpcs:enable |
255 | - global $conf; |
|
256 | - |
|
257 | - if(empty($object->country) && ! empty($object->country_code)) |
|
258 | - { |
|
259 | - $object->country = $outputlangs->transnoentitiesnoconv("Country" . $object->country_code); |
|
260 | - } |
|
261 | - if(empty($object->state) && ! empty($object->state_code)) |
|
262 | - { |
|
263 | - $object->state = getState($object->state_code, 0); |
|
264 | - } |
|
265 | - |
|
266 | - $array_contact = array ( |
|
267 | - $array_key . '_fullname' => $object->getFullName($outputlangs, 1), |
|
255 | + global $conf; |
|
256 | + |
|
257 | + if(empty($object->country) && ! empty($object->country_code)) |
|
258 | + { |
|
259 | + $object->country = $outputlangs->transnoentitiesnoconv("Country" . $object->country_code); |
|
260 | + } |
|
261 | + if(empty($object->state) && ! empty($object->state_code)) |
|
262 | + { |
|
263 | + $object->state = getState($object->state_code, 0); |
|
264 | + } |
|
265 | + |
|
266 | + $array_contact = array ( |
|
267 | + $array_key . '_fullname' => $object->getFullName($outputlangs, 1), |
|
268 | 268 | $array_key . '_lastname' => $object->lastname, |
269 | 269 | $array_key . '_firstname' => $object->firstname, |
270 | 270 | $array_key . '_address' => $object->address, |
@@ -290,28 +290,28 @@ discard block |
||
290 | 290 | $array_key . '_default_lang' => $object->default_lang, |
291 | 291 | $array_key . '_note_public' => $object->note_public, |
292 | 292 | $array_key . '_note_private' => $object->note_private |
293 | - ); |
|
294 | - |
|
295 | - // Retrieve extrafields |
|
296 | - require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; |
|
297 | - $extrafields = new ExtraFields($this->db); |
|
298 | - $extralabels = $extrafields->fetch_name_optionals_label('socpeople', true); |
|
299 | - $object->fetch_optionals(); |
|
300 | - |
|
301 | - foreach($extrafields->attribute_label as $key => $label) |
|
302 | - { |
|
303 | - if ($extrafields->attribute_type[$key] == 'price') |
|
304 | - { |
|
305 | - $object->array_options['options_' . $key] = price($object->array_options ['options_' . $key], 0, $outputlangs, 0, 0, - 1, $conf->currency); |
|
306 | - } |
|
307 | - elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
308 | - { |
|
309 | - $object->array_options['options_' . $key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_' . $key]]; |
|
310 | - } |
|
311 | - $array_contact = array_merge($array_contact, array($array_key.'_options_' . $key => $object->array_options['options_'. $key])); |
|
312 | - } |
|
313 | - return $array_contact; |
|
314 | - } |
|
293 | + ); |
|
294 | + |
|
295 | + // Retrieve extrafields |
|
296 | + require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; |
|
297 | + $extrafields = new ExtraFields($this->db); |
|
298 | + $extralabels = $extrafields->fetch_name_optionals_label('socpeople', true); |
|
299 | + $object->fetch_optionals(); |
|
300 | + |
|
301 | + foreach($extrafields->attribute_label as $key => $label) |
|
302 | + { |
|
303 | + if ($extrafields->attribute_type[$key] == 'price') |
|
304 | + { |
|
305 | + $object->array_options['options_' . $key] = price($object->array_options ['options_' . $key], 0, $outputlangs, 0, 0, - 1, $conf->currency); |
|
306 | + } |
|
307 | + elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
308 | + { |
|
309 | + $object->array_options['options_' . $key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_' . $key]]; |
|
310 | + } |
|
311 | + $array_contact = array_merge($array_contact, array($array_key.'_options_' . $key => $object->array_options['options_'. $key])); |
|
312 | + } |
|
313 | + return $array_contact; |
|
314 | + } |
|
315 | 315 | |
316 | 316 | |
317 | 317 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -324,260 +324,260 @@ discard block |
||
324 | 324 | function get_substitutionarray_other($outputlangs) |
325 | 325 | { |
326 | 326 | // phpcs:enable |
327 | - global $conf; |
|
328 | - |
|
329 | - $now=dol_now('gmt'); // gmt |
|
330 | - $array_other = array( |
|
331 | - // Date in default language |
|
332 | - 'current_date'=>dol_print_date($now,'day','tzuser'), |
|
333 | - 'current_datehour'=>dol_print_date($now,'dayhour','tzuser'), |
|
334 | - 'current_server_date'=>dol_print_date($now,'day','tzserver'), |
|
335 | - 'current_server_datehour'=>dol_print_date($now,'dayhour','tzserver'), |
|
336 | - // Date in requested output language |
|
337 | - 'current_date_locale'=>dol_print_date($now,'day','tzuser',$outputlangs), |
|
338 | - 'current_datehour_locale'=>dol_print_date($now,'dayhour','tzuser',$outputlangs), |
|
339 | - 'current_server_date_locale'=>dol_print_date($now,'day','tzserver',$outputlangs), |
|
340 | - 'current_server_datehour_locale'=>dol_print_date($now,'dayhour','tzserver',$outputlangs), |
|
341 | - ); |
|
342 | - |
|
343 | - |
|
344 | - foreach($conf->global as $key => $val) |
|
345 | - { |
|
346 | - if (preg_match('/(_pass|password|secret|_key|key$)/i', $key)) $newval = '*****forbidden*****'; |
|
347 | - else $newval = $val; |
|
348 | - $array_other['__['.$key.']__'] = $newval; |
|
349 | - } |
|
350 | - |
|
351 | - return $array_other; |
|
327 | + global $conf; |
|
328 | + |
|
329 | + $now=dol_now('gmt'); // gmt |
|
330 | + $array_other = array( |
|
331 | + // Date in default language |
|
332 | + 'current_date'=>dol_print_date($now,'day','tzuser'), |
|
333 | + 'current_datehour'=>dol_print_date($now,'dayhour','tzuser'), |
|
334 | + 'current_server_date'=>dol_print_date($now,'day','tzserver'), |
|
335 | + 'current_server_datehour'=>dol_print_date($now,'dayhour','tzserver'), |
|
336 | + // Date in requested output language |
|
337 | + 'current_date_locale'=>dol_print_date($now,'day','tzuser',$outputlangs), |
|
338 | + 'current_datehour_locale'=>dol_print_date($now,'dayhour','tzuser',$outputlangs), |
|
339 | + 'current_server_date_locale'=>dol_print_date($now,'day','tzserver',$outputlangs), |
|
340 | + 'current_server_datehour_locale'=>dol_print_date($now,'dayhour','tzserver',$outputlangs), |
|
341 | + ); |
|
342 | + |
|
343 | + |
|
344 | + foreach($conf->global as $key => $val) |
|
345 | + { |
|
346 | + if (preg_match('/(_pass|password|secret|_key|key$)/i', $key)) $newval = '*****forbidden*****'; |
|
347 | + else $newval = $val; |
|
348 | + $array_other['__['.$key.']__'] = $newval; |
|
349 | + } |
|
350 | + |
|
351 | + return $array_other; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | |
355 | 355 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
356 | - /** |
|
357 | - * Define array with couple substitution key => substitution value |
|
358 | - * |
|
359 | - * @param Object $object Main object to use as data source |
|
360 | - * @param Translate $outputlangs Lang object to use for output |
|
356 | + /** |
|
357 | + * Define array with couple substitution key => substitution value |
|
358 | + * |
|
359 | + * @param Object $object Main object to use as data source |
|
360 | + * @param Translate $outputlangs Lang object to use for output |
|
361 | 361 | * @param string $array_key Name of the key for return array |
362 | - * @return array Array of substitution |
|
363 | - */ |
|
364 | - function get_substitutionarray_object($object,$outputlangs,$array_key='object') |
|
365 | - { |
|
362 | + * @return array Array of substitution |
|
363 | + */ |
|
364 | + function get_substitutionarray_object($object,$outputlangs,$array_key='object') |
|
365 | + { |
|
366 | 366 | // phpcs:enable |
367 | - global $conf; |
|
368 | - |
|
369 | - $sumpayed=$sumdeposit=$sumcreditnote=''; |
|
370 | - if ($object->element == 'facture') |
|
371 | - { |
|
372 | - $invoice_source=new Facture($this->db); |
|
373 | - if ($object->fk_facture_source > 0) |
|
374 | - { |
|
375 | - $invoice_source->fetch($object->fk_facture_source); |
|
376 | - } |
|
377 | - $sumpayed = $object->getSommePaiement(); |
|
378 | - $sumdeposit = $object->getSumDepositsUsed(); |
|
379 | - $sumcreditnote = $object->getSumCreditNotesUsed(); |
|
380 | - } |
|
381 | - |
|
382 | - $date = ($object->element == 'contrat' ? $object->date_contrat : $object->date); |
|
383 | - |
|
384 | - $resarray=array( |
|
385 | - $array_key.'_id'=>$object->id, |
|
386 | - $array_key.'_ref'=>$object->ref, |
|
387 | - $array_key.'_ref_ext'=>$object->ref_ext, |
|
388 | - $array_key.'_ref_customer'=>(! empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), |
|
389 | - $array_key.'_ref_supplier'=>(! empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), |
|
390 | - $array_key.'_source_invoice_ref'=>$invoice_source->ref, |
|
391 | - // Dates |
|
367 | + global $conf; |
|
368 | + |
|
369 | + $sumpayed=$sumdeposit=$sumcreditnote=''; |
|
370 | + if ($object->element == 'facture') |
|
371 | + { |
|
372 | + $invoice_source=new Facture($this->db); |
|
373 | + if ($object->fk_facture_source > 0) |
|
374 | + { |
|
375 | + $invoice_source->fetch($object->fk_facture_source); |
|
376 | + } |
|
377 | + $sumpayed = $object->getSommePaiement(); |
|
378 | + $sumdeposit = $object->getSumDepositsUsed(); |
|
379 | + $sumcreditnote = $object->getSumCreditNotesUsed(); |
|
380 | + } |
|
381 | + |
|
382 | + $date = ($object->element == 'contrat' ? $object->date_contrat : $object->date); |
|
383 | + |
|
384 | + $resarray=array( |
|
385 | + $array_key.'_id'=>$object->id, |
|
386 | + $array_key.'_ref'=>$object->ref, |
|
387 | + $array_key.'_ref_ext'=>$object->ref_ext, |
|
388 | + $array_key.'_ref_customer'=>(! empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), |
|
389 | + $array_key.'_ref_supplier'=>(! empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), |
|
390 | + $array_key.'_source_invoice_ref'=>$invoice_source->ref, |
|
391 | + // Dates |
|
392 | 392 | $array_key.'_hour'=>dol_print_date($date,'hour'), |
393 | - $array_key.'_date'=>dol_print_date($date,'day'), |
|
394 | - $array_key.'_date_rfc'=>dol_print_date($date,'dayrfc'), |
|
395 | - $array_key.'_date_limit'=>(! empty($object->date_lim_reglement)?dol_print_date($object->date_lim_reglement,'day'):''), |
|
396 | - $array_key.'_date_end'=>(! empty($object->fin_validite)?dol_print_date($object->fin_validite,'day'):''), |
|
397 | - $array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'), |
|
398 | - $array_key.'_date_modification'=>(! empty($object->date_modification)?dol_print_date($object->date_modification,'day'):''), |
|
399 | - $array_key.'_date_validation'=>(! empty($object->date_validation)?dol_print_date($object->date_validation,'dayhour'):''), |
|
400 | - $array_key.'_date_delivery_planed'=>(! empty($object->date_livraison)?dol_print_date($object->date_livraison,'day'):''), |
|
401 | - $array_key.'_date_close'=>(! empty($object->date_cloture)?dol_print_date($object->date_cloture,'dayhour'):''), |
|
402 | - |
|
403 | - $array_key.'_payment_mode_code'=>$object->mode_reglement_code, |
|
404 | - $array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement), |
|
405 | - $array_key.'_payment_term_code'=>$object->cond_reglement_code, |
|
406 | - $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):($object->cond_reglement_doc?$object->cond_reglement_doc:$object->cond_reglement)), |
|
407 | - |
|
408 | - $array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs), |
|
409 | - $array_key.'_total_vat_locale'=>(! empty($object->total_vat)?price($object->total_vat, 0, $outputlangs):price($object->total_tva, 0, $outputlangs)), |
|
410 | - $array_key.'_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs), |
|
411 | - $array_key.'_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs), |
|
412 | - $array_key.'_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs), |
|
413 | - |
|
414 | - $array_key.'_total_ht'=>price2num($object->total_ht), |
|
415 | - $array_key.'_total_vat'=>(! empty($object->total_vat)?price2num($object->total_vat):price2num($object->total_tva)), |
|
416 | - $array_key.'_total_localtax1'=>price2num($object->total_localtax1), |
|
417 | - $array_key.'_total_localtax2'=>price2num($object->total_localtax2), |
|
418 | - $array_key.'_total_ttc'=>price2num($object->total_ttc), |
|
419 | - |
|
420 | - $array_key.'_multicurrency_code' => price2num($object->multicurrency_code), |
|
421 | - $array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx), |
|
422 | - $array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht), |
|
423 | - $array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva), |
|
424 | - $array_key.'_multicurrency_total_ttc' => price2num($object->multicurrency_total_ttc), |
|
425 | - $array_key.'_multicurrency_total_ht_locale' => price($object->multicurrency_total_ht, 0, $outputlangs), |
|
426 | - $array_key.'_multicurrency_total_tva_locale' => price($object->multicurrency_total_tva, 0, $outputlangs), |
|
427 | - $array_key.'_multicurrency_total_ttc_locale' => price($object->multicurrency_total_ttc, 0, $outputlangs), |
|
428 | - |
|
429 | - $array_key.'_note_private'=>$object->note, |
|
430 | - $array_key.'_note_public'=>$object->note_public, |
|
431 | - $array_key.'_note'=>$object->note_public, // For backward compatibility |
|
432 | - |
|
433 | - // Payments |
|
434 | - $array_key.'_already_payed_locale'=>price($sumpayed, 0, $outputlangs), |
|
435 | - $array_key.'_already_payed'=>price2num($sumpayed), |
|
436 | - $array_key.'_already_deposit_locale'=>price($sumdeposit, 0, $outputlangs), |
|
437 | - $array_key.'_already_deposit'=>price2num($sumdeposit), |
|
438 | - $array_key.'_already_creditnote_locale'=>price($sumcreditnote, 0, $outputlangs), |
|
439 | - $array_key.'_already_creditnote'=>price2num($sumcreditnote), |
|
440 | - |
|
441 | - $array_key.'_already_payed_all_locale'=>price(price2num($sumpayed + $sumdeposit + $sumcreditnote, 'MT'), 0, $outputlangs), |
|
442 | - $array_key.'_already_payed_all'=> price2num(($sumpayed + $sumdeposit + $sumcreditnote), 'MT'), |
|
443 | - |
|
444 | - // Remain to pay with all know infrmation (except open direct debit requests) |
|
445 | - $array_key.'_remain_to_pay_locale'=>price(price2num($object->total_ttc - $sumpayed - $sumdeposit - $sumcreditnote, 'MT'), 0, $outputlangs), |
|
446 | - $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $sumpayed - $sumdeposit - $sumcreditnote, 'MT') |
|
447 | - ); |
|
448 | - |
|
449 | - if (method_exists($object, 'getTotalDiscount')) { |
|
450 | - $resarray[$array_key.'_total_discount_ht_locale'] = price($object->getTotalDiscount(), 0, $outputlangs); |
|
451 | - $resarray[$array_key.'_total_discount_ht'] = price2num($object->getTotalDiscount()); |
|
452 | - } else { |
|
453 | - $resarray[$array_key.'_total_discount_ht_locale'] = ''; |
|
454 | - $resarray[$array_key.'_total_discount_ht'] = ''; |
|
455 | - } |
|
456 | - |
|
457 | - // Fetch project information if there is a project assigned to this object |
|
458 | - if ($object->element != "project" && ! empty($object->fk_project) && $object->fk_project > 0) |
|
459 | - { |
|
460 | - if (! is_object($object->project)) |
|
461 | - { |
|
462 | - $object->fetch_projet(); |
|
463 | - } |
|
464 | - |
|
465 | - $resarray[$array_key.'_project_ref'] = $object->project->ref; |
|
466 | - $resarray[$array_key.'_project_title'] = $object->project->title; |
|
467 | - $resarray[$array_key.'_project_description'] = $object->project->description; |
|
468 | - $resarray[$array_key.'_project_date_start'] = dol_print_date($object->project->date_start, 'day'); |
|
469 | - $resarray[$array_key.'_project_date_end'] = dol_print_date($object->project->date_end, 'day'); |
|
470 | - } |
|
471 | - |
|
472 | - // Add vat by rates |
|
473 | - if (is_array($object->lines) && count($object->lines)>0) |
|
474 | - { |
|
475 | - foreach ($object->lines as $line) |
|
476 | - { |
|
477 | - // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility |
|
478 | - if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
479 | - $resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
|
480 | - $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); |
|
481 | - // $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example) |
|
482 | - $vatformated=vatrate($line->tva_tx); |
|
483 | - if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0; |
|
484 | - $resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva; |
|
485 | - $resarray[$array_key.'_total_vat_locale_'.$vatformated]=price($resarray[$array_key.'_total_vat_'.$vatformated]); |
|
486 | - } |
|
487 | - } |
|
488 | - // Retrieve extrafields |
|
489 | - if (is_array($object->array_options) && count($object->array_options)) |
|
490 | - { |
|
491 | - $extrafieldkey=$object->element; |
|
492 | - |
|
493 | - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
494 | - $extrafields = new ExtraFields($this->db); |
|
495 | - $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true); |
|
496 | - $object->fetch_optionals(); |
|
497 | - |
|
498 | - $resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs); |
|
499 | - } |
|
500 | - return $resarray; |
|
501 | - } |
|
393 | + $array_key.'_date'=>dol_print_date($date,'day'), |
|
394 | + $array_key.'_date_rfc'=>dol_print_date($date,'dayrfc'), |
|
395 | + $array_key.'_date_limit'=>(! empty($object->date_lim_reglement)?dol_print_date($object->date_lim_reglement,'day'):''), |
|
396 | + $array_key.'_date_end'=>(! empty($object->fin_validite)?dol_print_date($object->fin_validite,'day'):''), |
|
397 | + $array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'), |
|
398 | + $array_key.'_date_modification'=>(! empty($object->date_modification)?dol_print_date($object->date_modification,'day'):''), |
|
399 | + $array_key.'_date_validation'=>(! empty($object->date_validation)?dol_print_date($object->date_validation,'dayhour'):''), |
|
400 | + $array_key.'_date_delivery_planed'=>(! empty($object->date_livraison)?dol_print_date($object->date_livraison,'day'):''), |
|
401 | + $array_key.'_date_close'=>(! empty($object->date_cloture)?dol_print_date($object->date_cloture,'dayhour'):''), |
|
402 | + |
|
403 | + $array_key.'_payment_mode_code'=>$object->mode_reglement_code, |
|
404 | + $array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement), |
|
405 | + $array_key.'_payment_term_code'=>$object->cond_reglement_code, |
|
406 | + $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):($object->cond_reglement_doc?$object->cond_reglement_doc:$object->cond_reglement)), |
|
407 | + |
|
408 | + $array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs), |
|
409 | + $array_key.'_total_vat_locale'=>(! empty($object->total_vat)?price($object->total_vat, 0, $outputlangs):price($object->total_tva, 0, $outputlangs)), |
|
410 | + $array_key.'_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs), |
|
411 | + $array_key.'_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs), |
|
412 | + $array_key.'_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs), |
|
413 | + |
|
414 | + $array_key.'_total_ht'=>price2num($object->total_ht), |
|
415 | + $array_key.'_total_vat'=>(! empty($object->total_vat)?price2num($object->total_vat):price2num($object->total_tva)), |
|
416 | + $array_key.'_total_localtax1'=>price2num($object->total_localtax1), |
|
417 | + $array_key.'_total_localtax2'=>price2num($object->total_localtax2), |
|
418 | + $array_key.'_total_ttc'=>price2num($object->total_ttc), |
|
419 | + |
|
420 | + $array_key.'_multicurrency_code' => price2num($object->multicurrency_code), |
|
421 | + $array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx), |
|
422 | + $array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht), |
|
423 | + $array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva), |
|
424 | + $array_key.'_multicurrency_total_ttc' => price2num($object->multicurrency_total_ttc), |
|
425 | + $array_key.'_multicurrency_total_ht_locale' => price($object->multicurrency_total_ht, 0, $outputlangs), |
|
426 | + $array_key.'_multicurrency_total_tva_locale' => price($object->multicurrency_total_tva, 0, $outputlangs), |
|
427 | + $array_key.'_multicurrency_total_ttc_locale' => price($object->multicurrency_total_ttc, 0, $outputlangs), |
|
428 | + |
|
429 | + $array_key.'_note_private'=>$object->note, |
|
430 | + $array_key.'_note_public'=>$object->note_public, |
|
431 | + $array_key.'_note'=>$object->note_public, // For backward compatibility |
|
432 | + |
|
433 | + // Payments |
|
434 | + $array_key.'_already_payed_locale'=>price($sumpayed, 0, $outputlangs), |
|
435 | + $array_key.'_already_payed'=>price2num($sumpayed), |
|
436 | + $array_key.'_already_deposit_locale'=>price($sumdeposit, 0, $outputlangs), |
|
437 | + $array_key.'_already_deposit'=>price2num($sumdeposit), |
|
438 | + $array_key.'_already_creditnote_locale'=>price($sumcreditnote, 0, $outputlangs), |
|
439 | + $array_key.'_already_creditnote'=>price2num($sumcreditnote), |
|
440 | + |
|
441 | + $array_key.'_already_payed_all_locale'=>price(price2num($sumpayed + $sumdeposit + $sumcreditnote, 'MT'), 0, $outputlangs), |
|
442 | + $array_key.'_already_payed_all'=> price2num(($sumpayed + $sumdeposit + $sumcreditnote), 'MT'), |
|
443 | + |
|
444 | + // Remain to pay with all know infrmation (except open direct debit requests) |
|
445 | + $array_key.'_remain_to_pay_locale'=>price(price2num($object->total_ttc - $sumpayed - $sumdeposit - $sumcreditnote, 'MT'), 0, $outputlangs), |
|
446 | + $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $sumpayed - $sumdeposit - $sumcreditnote, 'MT') |
|
447 | + ); |
|
448 | + |
|
449 | + if (method_exists($object, 'getTotalDiscount')) { |
|
450 | + $resarray[$array_key.'_total_discount_ht_locale'] = price($object->getTotalDiscount(), 0, $outputlangs); |
|
451 | + $resarray[$array_key.'_total_discount_ht'] = price2num($object->getTotalDiscount()); |
|
452 | + } else { |
|
453 | + $resarray[$array_key.'_total_discount_ht_locale'] = ''; |
|
454 | + $resarray[$array_key.'_total_discount_ht'] = ''; |
|
455 | + } |
|
456 | + |
|
457 | + // Fetch project information if there is a project assigned to this object |
|
458 | + if ($object->element != "project" && ! empty($object->fk_project) && $object->fk_project > 0) |
|
459 | + { |
|
460 | + if (! is_object($object->project)) |
|
461 | + { |
|
462 | + $object->fetch_projet(); |
|
463 | + } |
|
464 | + |
|
465 | + $resarray[$array_key.'_project_ref'] = $object->project->ref; |
|
466 | + $resarray[$array_key.'_project_title'] = $object->project->title; |
|
467 | + $resarray[$array_key.'_project_description'] = $object->project->description; |
|
468 | + $resarray[$array_key.'_project_date_start'] = dol_print_date($object->project->date_start, 'day'); |
|
469 | + $resarray[$array_key.'_project_date_end'] = dol_print_date($object->project->date_end, 'day'); |
|
470 | + } |
|
471 | + |
|
472 | + // Add vat by rates |
|
473 | + if (is_array($object->lines) && count($object->lines)>0) |
|
474 | + { |
|
475 | + foreach ($object->lines as $line) |
|
476 | + { |
|
477 | + // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility |
|
478 | + if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
479 | + $resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
|
480 | + $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); |
|
481 | + // $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example) |
|
482 | + $vatformated=vatrate($line->tva_tx); |
|
483 | + if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0; |
|
484 | + $resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva; |
|
485 | + $resarray[$array_key.'_total_vat_locale_'.$vatformated]=price($resarray[$array_key.'_total_vat_'.$vatformated]); |
|
486 | + } |
|
487 | + } |
|
488 | + // Retrieve extrafields |
|
489 | + if (is_array($object->array_options) && count($object->array_options)) |
|
490 | + { |
|
491 | + $extrafieldkey=$object->element; |
|
492 | + |
|
493 | + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
494 | + $extrafields = new ExtraFields($this->db); |
|
495 | + $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true); |
|
496 | + $object->fetch_optionals(); |
|
497 | + |
|
498 | + $resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs); |
|
499 | + } |
|
500 | + return $resarray; |
|
501 | + } |
|
502 | 502 | |
503 | 503 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
504 | - /** |
|
505 | - * Define array with couple substitution key => substitution value |
|
506 | - * |
|
507 | - * @param Object $line Object line |
|
508 | - * @param Translate $outputlangs Lang object to use for output |
|
509 | - * @return array Return a substitution array |
|
510 | - */ |
|
511 | - function get_substitutionarray_lines($line, $outputlangs) |
|
512 | - { |
|
504 | + /** |
|
505 | + * Define array with couple substitution key => substitution value |
|
506 | + * |
|
507 | + * @param Object $line Object line |
|
508 | + * @param Translate $outputlangs Lang object to use for output |
|
509 | + * @return array Return a substitution array |
|
510 | + */ |
|
511 | + function get_substitutionarray_lines($line, $outputlangs) |
|
512 | + { |
|
513 | 513 | // phpcs:enable |
514 | - global $conf; |
|
515 | - |
|
516 | - $resarray= array( |
|
517 | - 'line_fulldesc'=>doc_getlinedesc($line,$outputlangs), |
|
518 | - 'line_product_ref'=>$line->product_ref, |
|
519 | - 'line_product_ref_fourn'=>$line->ref_fourn, // for supplier doc lines |
|
520 | - 'line_product_label'=>$line->product_label, |
|
521 | - 'line_product_type'=>$line->product_type, |
|
522 | - 'line_desc'=>$line->desc, |
|
523 | - 'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits), |
|
524 | - 'line_up'=>price2num($line->subprice), |
|
525 | - 'line_up_locale'=>price($line->subprice, 0, $outputlangs), |
|
526 | - 'line_qty'=>$line->qty, |
|
527 | - 'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''), |
|
528 | - 'line_price_ht'=>price2num($line->total_ht), |
|
529 | - 'line_price_ttc'=>price2num($line->total_ttc), |
|
530 | - 'line_price_vat'=>price2num($line->total_tva), |
|
531 | - 'line_price_ht_locale'=>price($line->total_ht, 0, $outputlangs), |
|
532 | - 'line_price_ttc_locale'=>price($line->total_ttc, 0, $outputlangs), |
|
533 | - 'line_price_vat_locale'=>price($line->total_tva, 0, $outputlangs), |
|
534 | - // Dates |
|
535 | - 'line_date_start'=>dol_print_date($line->date_start, 'day', 'tzuser'), |
|
536 | - 'line_date_start_locale'=>dol_print_date($line->date_start, 'day', 'tzuser', $outputlangs), |
|
537 | - 'line_date_start_rfc'=>dol_print_date($line->date_start, 'dayrfc', 'tzuser'), |
|
538 | - 'line_date_end'=>dol_print_date($line->date_end, 'day', 'tzuser'), |
|
539 | - 'line_date_end_locale'=>dol_print_date($line->date_end, 'day', 'tzuser', $outputlangs), |
|
540 | - 'line_date_end_rfc'=>dol_print_date($line->date_end, 'dayrfc', 'tzuser'), |
|
541 | - |
|
542 | - 'line_multicurrency_code' => price2num($line->multicurrency_code), |
|
543 | - 'line_multicurrency_subprice' => price2num($line->multicurrency_subprice), |
|
544 | - 'line_multicurrency_total_ht' => price2num($line->multicurrency_total_ht), |
|
545 | - 'line_multicurrency_total_tva' => price2num($line->multicurrency_total_tva), |
|
546 | - 'line_multicurrency_total_ttc' => price2num($line->multicurrency_total_ttc), |
|
547 | - 'line_multicurrency_subprice_locale' => price($line->multicurrency_subprice, 0, $outputlangs), |
|
548 | - 'line_multicurrency_total_ht_locale' => price($line->multicurrency_total_ht, 0, $outputlangs), |
|
549 | - 'line_multicurrency_total_tva_locale' => price($line->multicurrency_total_tva, 0, $outputlangs), |
|
550 | - 'line_multicurrency_total_ttc_locale' => price($line->multicurrency_total_ttc, 0, $outputlangs), |
|
551 | - ); |
|
552 | - |
|
553 | - // Units |
|
554 | - if ($conf->global->PRODUCT_USE_UNITS) |
|
555 | - { |
|
556 | - $resarray['line_unit']=$outputlangs->trans($line->getLabelOfUnit('long')); |
|
557 | - $resarray['line_unit_short']=$outputlangs->trans($line->getLabelOfUnit('short')); |
|
558 | - } |
|
559 | - |
|
560 | - // Retrieve extrafields |
|
561 | - $extrafieldkey=$line->element; |
|
562 | - $array_key="line"; |
|
563 | - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
564 | - $extrafields = new ExtraFields($this->db); |
|
565 | - $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true); |
|
566 | - $line->fetch_optionals(); |
|
567 | - |
|
568 | - $resarray = $this->fill_substitutionarray_with_extrafields($line,$resarray,$extrafields,$array_key=$array_key,$outputlangs); |
|
569 | - |
|
570 | - // Load product data optional fields to the line -> enables to use "line_options_{extrafield}" |
|
571 | - if (isset($line->fk_product) && $line->fk_product > 0) |
|
572 | - { |
|
573 | - $tmpproduct = new Product($this->db); |
|
574 | - $result = $tmpproduct->fetch($line->fk_product); |
|
575 | - foreach($tmpproduct->array_options as $key=>$label) |
|
576 | - $resarray["line_product_".$key] = $label; |
|
577 | - } |
|
578 | - |
|
579 | - return $resarray; |
|
580 | - } |
|
514 | + global $conf; |
|
515 | + |
|
516 | + $resarray= array( |
|
517 | + 'line_fulldesc'=>doc_getlinedesc($line,$outputlangs), |
|
518 | + 'line_product_ref'=>$line->product_ref, |
|
519 | + 'line_product_ref_fourn'=>$line->ref_fourn, // for supplier doc lines |
|
520 | + 'line_product_label'=>$line->product_label, |
|
521 | + 'line_product_type'=>$line->product_type, |
|
522 | + 'line_desc'=>$line->desc, |
|
523 | + 'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits), |
|
524 | + 'line_up'=>price2num($line->subprice), |
|
525 | + 'line_up_locale'=>price($line->subprice, 0, $outputlangs), |
|
526 | + 'line_qty'=>$line->qty, |
|
527 | + 'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''), |
|
528 | + 'line_price_ht'=>price2num($line->total_ht), |
|
529 | + 'line_price_ttc'=>price2num($line->total_ttc), |
|
530 | + 'line_price_vat'=>price2num($line->total_tva), |
|
531 | + 'line_price_ht_locale'=>price($line->total_ht, 0, $outputlangs), |
|
532 | + 'line_price_ttc_locale'=>price($line->total_ttc, 0, $outputlangs), |
|
533 | + 'line_price_vat_locale'=>price($line->total_tva, 0, $outputlangs), |
|
534 | + // Dates |
|
535 | + 'line_date_start'=>dol_print_date($line->date_start, 'day', 'tzuser'), |
|
536 | + 'line_date_start_locale'=>dol_print_date($line->date_start, 'day', 'tzuser', $outputlangs), |
|
537 | + 'line_date_start_rfc'=>dol_print_date($line->date_start, 'dayrfc', 'tzuser'), |
|
538 | + 'line_date_end'=>dol_print_date($line->date_end, 'day', 'tzuser'), |
|
539 | + 'line_date_end_locale'=>dol_print_date($line->date_end, 'day', 'tzuser', $outputlangs), |
|
540 | + 'line_date_end_rfc'=>dol_print_date($line->date_end, 'dayrfc', 'tzuser'), |
|
541 | + |
|
542 | + 'line_multicurrency_code' => price2num($line->multicurrency_code), |
|
543 | + 'line_multicurrency_subprice' => price2num($line->multicurrency_subprice), |
|
544 | + 'line_multicurrency_total_ht' => price2num($line->multicurrency_total_ht), |
|
545 | + 'line_multicurrency_total_tva' => price2num($line->multicurrency_total_tva), |
|
546 | + 'line_multicurrency_total_ttc' => price2num($line->multicurrency_total_ttc), |
|
547 | + 'line_multicurrency_subprice_locale' => price($line->multicurrency_subprice, 0, $outputlangs), |
|
548 | + 'line_multicurrency_total_ht_locale' => price($line->multicurrency_total_ht, 0, $outputlangs), |
|
549 | + 'line_multicurrency_total_tva_locale' => price($line->multicurrency_total_tva, 0, $outputlangs), |
|
550 | + 'line_multicurrency_total_ttc_locale' => price($line->multicurrency_total_ttc, 0, $outputlangs), |
|
551 | + ); |
|
552 | + |
|
553 | + // Units |
|
554 | + if ($conf->global->PRODUCT_USE_UNITS) |
|
555 | + { |
|
556 | + $resarray['line_unit']=$outputlangs->trans($line->getLabelOfUnit('long')); |
|
557 | + $resarray['line_unit_short']=$outputlangs->trans($line->getLabelOfUnit('short')); |
|
558 | + } |
|
559 | + |
|
560 | + // Retrieve extrafields |
|
561 | + $extrafieldkey=$line->element; |
|
562 | + $array_key="line"; |
|
563 | + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
564 | + $extrafields = new ExtraFields($this->db); |
|
565 | + $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true); |
|
566 | + $line->fetch_optionals(); |
|
567 | + |
|
568 | + $resarray = $this->fill_substitutionarray_with_extrafields($line,$resarray,$extrafields,$array_key=$array_key,$outputlangs); |
|
569 | + |
|
570 | + // Load product data optional fields to the line -> enables to use "line_options_{extrafield}" |
|
571 | + if (isset($line->fk_product) && $line->fk_product > 0) |
|
572 | + { |
|
573 | + $tmpproduct = new Product($this->db); |
|
574 | + $result = $tmpproduct->fetch($line->fk_product); |
|
575 | + foreach($tmpproduct->array_options as $key=>$label) |
|
576 | + $resarray["line_product_".$key] = $label; |
|
577 | + } |
|
578 | + |
|
579 | + return $resarray; |
|
580 | + } |
|
581 | 581 | |
582 | 582 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
583 | 583 | /** |
@@ -591,54 +591,54 @@ discard block |
||
591 | 591 | function get_substitutionarray_shipment($object,$outputlangs,$array_key='object') |
592 | 592 | { |
593 | 593 | // phpcs:enable |
594 | - global $conf; |
|
595 | - dol_include_once('/core/lib/product.lib.php'); |
|
596 | - $object->list_delivery_methods($object->shipping_method_id); |
|
597 | - $calculatedVolume=($object->trueWidth * $object->trueHeight * $object->trueDepth); |
|
598 | - |
|
599 | - $array_shipment=array( |
|
600 | - $array_key.'_id'=>$object->id, |
|
601 | - $array_key.'_ref'=>$object->ref, |
|
602 | - $array_key.'_ref_ext'=>$object->ref_ext, |
|
603 | - $array_key.'_ref_customer'=>$object->ref_customer, |
|
604 | - $array_key.'_date_delivery'=>dol_print_date($object->date_delivery,'day'), |
|
605 | - $array_key.'_hour_delivery'=>dol_print_date($object->date_delivery,'hour'), |
|
606 | - $array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'), |
|
607 | - $array_key.'_total_ht'=>price($object->total_ht), |
|
608 | - $array_key.'_total_vat'=>price($object->total_tva), |
|
609 | - $array_key.'_total_ttc'=>price($object->total_ttc), |
|
610 | - $array_key.'_total_discount_ht' => price($object->getTotalDiscount()), |
|
611 | - $array_key.'_note_private'=>$object->note_private, |
|
612 | - $array_key.'_note'=>$object->note_public, |
|
613 | - $array_key.'_tracking_number'=>$object->tracking_number, |
|
614 | - $array_key.'_tracking_url'=>$object->tracking_url, |
|
615 | - $array_key.'_shipping_method'=>$object->listmeths[0]['libelle'], |
|
616 | - $array_key.'_weight'=>$object->trueWeight.' '.measuring_units_string($object->weight_units, 'weight'), |
|
617 | - $array_key.'_width'=>$object->trueWidth.' '.measuring_units_string($object->width_units, 'size'), |
|
618 | - $array_key.'_height'=>$object->trueHeight.' '.measuring_units_string($object->height_units, 'size'), |
|
619 | - $array_key.'_depth'=>$object->trueDepth.' '.measuring_units_string($object->depth_units, 'size'), |
|
620 | - $array_key.'_size'=>$calculatedVolume.' '.measuring_units_string(0, 'volume'), |
|
621 | - ); |
|
622 | - |
|
623 | - // Add vat by rates |
|
624 | - foreach ($object->lines as $line) |
|
625 | - { |
|
626 | - if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
627 | - $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
|
628 | - } |
|
629 | - |
|
630 | - // Retrieve extrafields |
|
631 | - if (is_array($object->array_options) && count($object->array_options)) |
|
632 | - { |
|
633 | - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
634 | - $extrafields = new ExtraFields($this->db); |
|
635 | - $extralabels = $extrafields->fetch_name_optionals_label('expedition',true); |
|
636 | - $object->fetch_optionals(); |
|
637 | - |
|
638 | - $array_shipment = $this->fill_substitutionarray_with_extrafields($object,$array_shipment,$extrafields,$array_key,$outputlangs); |
|
639 | - } |
|
640 | - |
|
641 | - return $array_shipment; |
|
594 | + global $conf; |
|
595 | + dol_include_once('/core/lib/product.lib.php'); |
|
596 | + $object->list_delivery_methods($object->shipping_method_id); |
|
597 | + $calculatedVolume=($object->trueWidth * $object->trueHeight * $object->trueDepth); |
|
598 | + |
|
599 | + $array_shipment=array( |
|
600 | + $array_key.'_id'=>$object->id, |
|
601 | + $array_key.'_ref'=>$object->ref, |
|
602 | + $array_key.'_ref_ext'=>$object->ref_ext, |
|
603 | + $array_key.'_ref_customer'=>$object->ref_customer, |
|
604 | + $array_key.'_date_delivery'=>dol_print_date($object->date_delivery,'day'), |
|
605 | + $array_key.'_hour_delivery'=>dol_print_date($object->date_delivery,'hour'), |
|
606 | + $array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'), |
|
607 | + $array_key.'_total_ht'=>price($object->total_ht), |
|
608 | + $array_key.'_total_vat'=>price($object->total_tva), |
|
609 | + $array_key.'_total_ttc'=>price($object->total_ttc), |
|
610 | + $array_key.'_total_discount_ht' => price($object->getTotalDiscount()), |
|
611 | + $array_key.'_note_private'=>$object->note_private, |
|
612 | + $array_key.'_note'=>$object->note_public, |
|
613 | + $array_key.'_tracking_number'=>$object->tracking_number, |
|
614 | + $array_key.'_tracking_url'=>$object->tracking_url, |
|
615 | + $array_key.'_shipping_method'=>$object->listmeths[0]['libelle'], |
|
616 | + $array_key.'_weight'=>$object->trueWeight.' '.measuring_units_string($object->weight_units, 'weight'), |
|
617 | + $array_key.'_width'=>$object->trueWidth.' '.measuring_units_string($object->width_units, 'size'), |
|
618 | + $array_key.'_height'=>$object->trueHeight.' '.measuring_units_string($object->height_units, 'size'), |
|
619 | + $array_key.'_depth'=>$object->trueDepth.' '.measuring_units_string($object->depth_units, 'size'), |
|
620 | + $array_key.'_size'=>$calculatedVolume.' '.measuring_units_string(0, 'volume'), |
|
621 | + ); |
|
622 | + |
|
623 | + // Add vat by rates |
|
624 | + foreach ($object->lines as $line) |
|
625 | + { |
|
626 | + if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
627 | + $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
|
628 | + } |
|
629 | + |
|
630 | + // Retrieve extrafields |
|
631 | + if (is_array($object->array_options) && count($object->array_options)) |
|
632 | + { |
|
633 | + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
634 | + $extrafields = new ExtraFields($this->db); |
|
635 | + $extralabels = $extrafields->fetch_name_optionals_label('expedition',true); |
|
636 | + $object->fetch_optionals(); |
|
637 | + |
|
638 | + $array_shipment = $this->fill_substitutionarray_with_extrafields($object,$array_shipment,$extrafields,$array_key,$outputlangs); |
|
639 | + } |
|
640 | + |
|
641 | + return $array_shipment; |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | |
@@ -657,24 +657,24 @@ discard block |
||
657 | 657 | dol_include_once('/core/lib/product.lib.php'); |
658 | 658 | |
659 | 659 | $resarray = array( |
660 | - 'line_fulldesc'=>doc_getlinedesc($line,$outputlangs), |
|
661 | - 'line_product_ref'=>$line->product_ref, |
|
662 | - 'line_product_label'=>$line->product_label, |
|
663 | - 'line_desc'=>$line->desc, |
|
664 | - 'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits), |
|
665 | - 'line_up'=>price($line->subprice), |
|
666 | - 'line_qty'=>$line->qty, |
|
667 | - 'line_qty_shipped'=>$line->qty_shipped, |
|
668 | - 'line_qty_asked'=>$line->qty_asked, |
|
669 | - 'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''), |
|
670 | - 'line_price_ht'=>price($line->total_ht), |
|
671 | - 'line_price_ttc'=>price($line->total_ttc), |
|
672 | - 'line_price_vat'=>price($line->total_tva), |
|
673 | - 'line_weight'=>empty($line->weight) ? '' : $line->weight*$line->qty_shipped.' '.measuring_units_string($line->weight_units, 'weight'), |
|
674 | - 'line_length'=>empty($line->length) ? '' : $line->length*$line->qty_shipped.' '.measuring_units_string($line->length_units, 'size'), |
|
675 | - 'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuring_units_string($line->surface_units, 'surface'), |
|
676 | - 'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuring_units_string($line->volume_units, 'volume'), |
|
677 | - ); |
|
660 | + 'line_fulldesc'=>doc_getlinedesc($line,$outputlangs), |
|
661 | + 'line_product_ref'=>$line->product_ref, |
|
662 | + 'line_product_label'=>$line->product_label, |
|
663 | + 'line_desc'=>$line->desc, |
|
664 | + 'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits), |
|
665 | + 'line_up'=>price($line->subprice), |
|
666 | + 'line_qty'=>$line->qty, |
|
667 | + 'line_qty_shipped'=>$line->qty_shipped, |
|
668 | + 'line_qty_asked'=>$line->qty_asked, |
|
669 | + 'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''), |
|
670 | + 'line_price_ht'=>price($line->total_ht), |
|
671 | + 'line_price_ttc'=>price($line->total_ttc), |
|
672 | + 'line_price_vat'=>price($line->total_tva), |
|
673 | + 'line_weight'=>empty($line->weight) ? '' : $line->weight*$line->qty_shipped.' '.measuring_units_string($line->weight_units, 'weight'), |
|
674 | + 'line_length'=>empty($line->length) ? '' : $line->length*$line->qty_shipped.' '.measuring_units_string($line->length_units, 'size'), |
|
675 | + 'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuring_units_string($line->surface_units, 'surface'), |
|
676 | + 'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuring_units_string($line->volume_units, 'volume'), |
|
677 | + ); |
|
678 | 678 | |
679 | 679 | // Retrieve extrafields |
680 | 680 | $extrafieldkey = $line->element; |
@@ -731,92 +731,92 @@ discard block |
||
731 | 731 | * @return array Substitution array |
732 | 732 | */ |
733 | 733 | function fill_substitutionarray_with_extrafields($object,$array_to_fill,$extrafields,$array_key,$outputlangs) |
734 | - { |
|
734 | + { |
|
735 | 735 | // phpcs:enable |
736 | - global $conf; |
|
737 | - foreach($extrafields->attribute_label as $key=>$label) |
|
738 | - { |
|
739 | - if($extrafields->attribute_type[$key] == 'price') |
|
740 | - { |
|
741 | - $object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key]); |
|
742 | - $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); |
|
743 | - //Add value to store price with currency |
|
744 | - $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); |
|
745 | - } |
|
746 | - else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
747 | - { |
|
748 | - $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
|
749 | - } |
|
750 | - else if($extrafields->attribute_type[$key] == 'date') |
|
751 | - { |
|
752 | - if (strlen($object->array_options['options_'.$key])>0) |
|
753 | - { |
|
754 | - $date = $object->array_options['options_'.$key]; |
|
755 | - $object->array_options['options_'.$key] = dol_print_date($date,'day'); // using company output language |
|
756 | - $object->array_options['options_'.$key.'_locale'] = dol_print_date($date,'day','tzserver',$outputlangs); // using output language format |
|
757 | - $object->array_options['options_'.$key.'_rfc'] = dol_print_date($date,'dayrfc'); // international format |
|
758 | - } |
|
759 | - else |
|
760 | - { |
|
761 | - $object->array_options['options_'.$key] = ''; |
|
762 | - $object->array_options['options_'.$key.'_locale'] = ''; |
|
763 | - $object->array_options['options_'.$key.'_rfc'] = ''; |
|
764 | - } |
|
765 | - $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); |
|
766 | - $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); |
|
767 | - } |
|
768 | - else if($extrafields->attribute_type[$key] == 'datetime') |
|
769 | - { |
|
770 | - $datetime = $object->array_options['options_'.$key]; |
|
771 | - $object->array_options['options_'.$key] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhour'):''); // using company output language |
|
772 | - $object->array_options['options_'.$key.'_locale'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhour','tzserver',$outputlangs):''); // using output language format |
|
773 | - $object->array_options['options_'.$key.'_rfc'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhourrfc'):''); // international format |
|
774 | - $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); |
|
775 | - $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); |
|
776 | - } |
|
777 | - else if($extrafields->attribute_type[$key] == 'link') |
|
778 | - { |
|
779 | - $id = $object->array_options['options_'.$key]; |
|
780 | - if ($id != "") |
|
781 | - { |
|
782 | - $param = $extrafields->attribute_param[$key]; |
|
783 | - $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' |
|
784 | - $InfoFieldList = explode(":", $param_list[0]); |
|
785 | - $classname=$InfoFieldList[0]; |
|
786 | - $classpath=$InfoFieldList[1]; |
|
787 | - if (! empty($classpath)) |
|
788 | - { |
|
789 | - dol_include_once($InfoFieldList[1]); |
|
790 | - if ($classname && class_exists($classname)) |
|
791 | - { |
|
792 | - $tmpobject = new $classname($this->db); |
|
793 | - $tmpobject->fetch($id); |
|
794 | - // completely replace the id with the linked object name |
|
795 | - $object->array_options['options_'.$key] = $tmpobject->name; |
|
796 | - } |
|
797 | - } |
|
798 | - } |
|
799 | - } |
|
800 | - |
|
801 | - $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); |
|
802 | - } |
|
803 | - |
|
804 | - return $array_to_fill; |
|
805 | - } |
|
806 | - |
|
807 | - |
|
808 | - /** |
|
809 | - * Rect pdf |
|
810 | - * |
|
811 | - * @param TCPDF $pdf Object PDF |
|
812 | - * @param float $x Abscissa of first point |
|
813 | - * @param float $y Ordinate of first point |
|
814 | - * @param float $l ?? |
|
815 | - * @param float $h ?? |
|
816 | - * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title |
|
817 | - * @param int $hidebottom Hide bottom |
|
818 | - * @return void |
|
819 | - */ |
|
736 | + global $conf; |
|
737 | + foreach($extrafields->attribute_label as $key=>$label) |
|
738 | + { |
|
739 | + if($extrafields->attribute_type[$key] == 'price') |
|
740 | + { |
|
741 | + $object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key]); |
|
742 | + $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); |
|
743 | + //Add value to store price with currency |
|
744 | + $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); |
|
745 | + } |
|
746 | + else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
747 | + { |
|
748 | + $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
|
749 | + } |
|
750 | + else if($extrafields->attribute_type[$key] == 'date') |
|
751 | + { |
|
752 | + if (strlen($object->array_options['options_'.$key])>0) |
|
753 | + { |
|
754 | + $date = $object->array_options['options_'.$key]; |
|
755 | + $object->array_options['options_'.$key] = dol_print_date($date,'day'); // using company output language |
|
756 | + $object->array_options['options_'.$key.'_locale'] = dol_print_date($date,'day','tzserver',$outputlangs); // using output language format |
|
757 | + $object->array_options['options_'.$key.'_rfc'] = dol_print_date($date,'dayrfc'); // international format |
|
758 | + } |
|
759 | + else |
|
760 | + { |
|
761 | + $object->array_options['options_'.$key] = ''; |
|
762 | + $object->array_options['options_'.$key.'_locale'] = ''; |
|
763 | + $object->array_options['options_'.$key.'_rfc'] = ''; |
|
764 | + } |
|
765 | + $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); |
|
766 | + $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); |
|
767 | + } |
|
768 | + else if($extrafields->attribute_type[$key] == 'datetime') |
|
769 | + { |
|
770 | + $datetime = $object->array_options['options_'.$key]; |
|
771 | + $object->array_options['options_'.$key] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhour'):''); // using company output language |
|
772 | + $object->array_options['options_'.$key.'_locale'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhour','tzserver',$outputlangs):''); // using output language format |
|
773 | + $object->array_options['options_'.$key.'_rfc'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhourrfc'):''); // international format |
|
774 | + $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); |
|
775 | + $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); |
|
776 | + } |
|
777 | + else if($extrafields->attribute_type[$key] == 'link') |
|
778 | + { |
|
779 | + $id = $object->array_options['options_'.$key]; |
|
780 | + if ($id != "") |
|
781 | + { |
|
782 | + $param = $extrafields->attribute_param[$key]; |
|
783 | + $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' |
|
784 | + $InfoFieldList = explode(":", $param_list[0]); |
|
785 | + $classname=$InfoFieldList[0]; |
|
786 | + $classpath=$InfoFieldList[1]; |
|
787 | + if (! empty($classpath)) |
|
788 | + { |
|
789 | + dol_include_once($InfoFieldList[1]); |
|
790 | + if ($classname && class_exists($classname)) |
|
791 | + { |
|
792 | + $tmpobject = new $classname($this->db); |
|
793 | + $tmpobject->fetch($id); |
|
794 | + // completely replace the id with the linked object name |
|
795 | + $object->array_options['options_'.$key] = $tmpobject->name; |
|
796 | + } |
|
797 | + } |
|
798 | + } |
|
799 | + } |
|
800 | + |
|
801 | + $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); |
|
802 | + } |
|
803 | + |
|
804 | + return $array_to_fill; |
|
805 | + } |
|
806 | + |
|
807 | + |
|
808 | + /** |
|
809 | + * Rect pdf |
|
810 | + * |
|
811 | + * @param TCPDF $pdf Object PDF |
|
812 | + * @param float $x Abscissa of first point |
|
813 | + * @param float $y Ordinate of first point |
|
814 | + * @param float $l ?? |
|
815 | + * @param float $h ?? |
|
816 | + * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title |
|
817 | + * @param int $hidebottom Hide bottom |
|
818 | + * @return void |
|
819 | + */ |
|
820 | 820 | function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
821 | 821 | { |
822 | 822 | if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | /** |
38 | 38 | * @var string Error code (or message) |
39 | 39 | */ |
40 | - public $error=''; |
|
40 | + public $error = ''; |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @var string[] Array of error strings |
@@ -69,17 +69,17 @@ discard block |
||
69 | 69 | * @param Translate $outputlangs Language object for output |
70 | 70 | * @return array Array of substitution key->code |
71 | 71 | */ |
72 | - function get_substitutionarray_user($user,$outputlangs) |
|
72 | + function get_substitutionarray_user($user, $outputlangs) |
|
73 | 73 | { |
74 | 74 | // phpcs:enable |
75 | 75 | global $conf; |
76 | 76 | |
77 | - $logotouse=$conf->user->dir_output.'/'.get_exdir($user->id, 2, 0, 1, $user, 'user').'/'.$user->photo; |
|
77 | + $logotouse = $conf->user->dir_output.'/'.get_exdir($user->id, 2, 0, 1, $user, 'user').'/'.$user->photo; |
|
78 | 78 | |
79 | 79 | return array( |
80 | 80 | 'myuser_lastname'=>$user->lastname, |
81 | 81 | 'myuser_firstname'=>$user->firstname, |
82 | - 'myuser_fullname'=>$user->getFullName($outputlangs,1), |
|
82 | + 'myuser_fullname'=>$user->getFullName($outputlangs, 1), |
|
83 | 83 | 'myuser_login'=>$user->login, |
84 | 84 | 'myuser_phone'=>$user->office_phone, |
85 | 85 | 'myuser_address'=>$user->address, |
@@ -107,25 +107,25 @@ discard block |
||
107 | 107 | * @param Translate $outputlangs Language object for output |
108 | 108 | * @return array Array of substitution key->code |
109 | 109 | */ |
110 | - function get_substitutionarray_mysoc($mysoc,$outputlangs) |
|
110 | + function get_substitutionarray_mysoc($mysoc, $outputlangs) |
|
111 | 111 | { |
112 | 112 | // phpcs:enable |
113 | 113 | global $conf; |
114 | 114 | |
115 | - if (empty($mysoc->forme_juridique) && ! empty($mysoc->forme_juridique_code)) |
|
115 | + if (empty($mysoc->forme_juridique) && !empty($mysoc->forme_juridique_code)) |
|
116 | 116 | { |
117 | - $mysoc->forme_juridique=getFormeJuridiqueLabel($mysoc->forme_juridique_code); |
|
117 | + $mysoc->forme_juridique = getFormeJuridiqueLabel($mysoc->forme_juridique_code); |
|
118 | 118 | } |
119 | - if (empty($mysoc->country) && ! empty($mysoc->country_code)) |
|
119 | + if (empty($mysoc->country) && !empty($mysoc->country_code)) |
|
120 | 120 | { |
121 | - $mysoc->country=$outputlangs->transnoentitiesnoconv("Country".$mysoc->country_code); |
|
121 | + $mysoc->country = $outputlangs->transnoentitiesnoconv("Country".$mysoc->country_code); |
|
122 | 122 | } |
123 | - if (empty($mysoc->state) && ! empty($mysoc->state_code)) |
|
123 | + if (empty($mysoc->state) && !empty($mysoc->state_code)) |
|
124 | 124 | { |
125 | - $mysoc->state=getState($mysoc->state_code,0); |
|
125 | + $mysoc->state = getState($mysoc->state_code, 0); |
|
126 | 126 | } |
127 | 127 | |
128 | - $logotouse=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
128 | + $logotouse = $conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
129 | 129 | |
130 | 130 | return array( |
131 | 131 | 'mycompany_logo'=>$logotouse, |
@@ -167,18 +167,18 @@ discard block |
||
167 | 167 | * @param Translate $outputlangs Language object for output |
168 | 168 | * @return array Array of substitution key->code |
169 | 169 | */ |
170 | - function get_substitutionarray_thirdparty($object,$outputlangs) |
|
170 | + function get_substitutionarray_thirdparty($object, $outputlangs) |
|
171 | 171 | { |
172 | 172 | // phpcs:enable |
173 | 173 | global $conf; |
174 | 174 | |
175 | - if (empty($object->country) && ! empty($object->country_code)) |
|
175 | + if (empty($object->country) && !empty($object->country_code)) |
|
176 | 176 | { |
177 | - $object->country=$outputlangs->transnoentitiesnoconv("Country".$object->country_code); |
|
177 | + $object->country = $outputlangs->transnoentitiesnoconv("Country".$object->country_code); |
|
178 | 178 | } |
179 | - if (empty($object->state) && ! empty($object->state_code)) |
|
179 | + if (empty($object->state) && !empty($object->state_code)) |
|
180 | 180 | { |
181 | - $object->state=getState($object->state_code,0); |
|
181 | + $object->state = getState($object->state_code, 0); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $array_thirdparty = array( |
@@ -217,24 +217,24 @@ discard block |
||
217 | 217 | ); |
218 | 218 | |
219 | 219 | // Retrieve extrafields |
220 | - if(is_array($object->array_options) && count($object->array_options)) |
|
220 | + if (is_array($object->array_options) && count($object->array_options)) |
|
221 | 221 | { |
222 | 222 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
223 | 223 | $extrafields = new ExtraFields($this->db); |
224 | - $extralabels = $extrafields->fetch_name_optionals_label('societe',true); |
|
224 | + $extralabels = $extrafields->fetch_name_optionals_label('societe', true); |
|
225 | 225 | $object->fetch_optionals(); |
226 | 226 | |
227 | - foreach($extrafields->attribute_label as $key=>$label) |
|
227 | + foreach ($extrafields->attribute_label as $key=>$label) |
|
228 | 228 | { |
229 | - if($extrafields->attribute_type[$key] == 'price') |
|
229 | + if ($extrafields->attribute_type[$key] == 'price') |
|
230 | 230 | { |
231 | - $object->array_options['options_'.$key] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); |
|
231 | + $object->array_options['options_'.$key] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency); |
|
232 | 232 | } |
233 | - else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
233 | + else if ($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
234 | 234 | { |
235 | 235 | $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
236 | 236 | } |
237 | - $array_thirdparty = array_merge($array_thirdparty, array ('company_options_'.$key => $object->array_options ['options_' . $key])); |
|
237 | + $array_thirdparty = array_merge($array_thirdparty, array('company_options_'.$key => $object->array_options ['options_'.$key])); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | return $array_thirdparty; |
@@ -254,61 +254,61 @@ discard block |
||
254 | 254 | // phpcs:enable |
255 | 255 | global $conf; |
256 | 256 | |
257 | - if(empty($object->country) && ! empty($object->country_code)) |
|
257 | + if (empty($object->country) && !empty($object->country_code)) |
|
258 | 258 | { |
259 | - $object->country = $outputlangs->transnoentitiesnoconv("Country" . $object->country_code); |
|
259 | + $object->country = $outputlangs->transnoentitiesnoconv("Country".$object->country_code); |
|
260 | 260 | } |
261 | - if(empty($object->state) && ! empty($object->state_code)) |
|
261 | + if (empty($object->state) && !empty($object->state_code)) |
|
262 | 262 | { |
263 | 263 | $object->state = getState($object->state_code, 0); |
264 | 264 | } |
265 | 265 | |
266 | - $array_contact = array ( |
|
267 | - $array_key . '_fullname' => $object->getFullName($outputlangs, 1), |
|
268 | - $array_key . '_lastname' => $object->lastname, |
|
269 | - $array_key . '_firstname' => $object->firstname, |
|
270 | - $array_key . '_address' => $object->address, |
|
271 | - $array_key . '_zip' => $object->zip, |
|
272 | - $array_key . '_town' => $object->town, |
|
273 | - $array_key . '_state_id' => $object->state_id, |
|
274 | - $array_key . '_state_code' => $object->state_code, |
|
275 | - $array_key . '_state' => $object->state, |
|
276 | - $array_key . '_country_id' => $object->country_id, |
|
277 | - $array_key . '_country_code' => $object->country_code, |
|
278 | - $array_key . '_country' => $object->country, |
|
279 | - $array_key . '_poste' => $object->poste, |
|
280 | - $array_key . '_socid' => $object->socid, |
|
281 | - $array_key . '_statut' => $object->statut, |
|
282 | - $array_key . '_code' => $object->code, |
|
283 | - $array_key . '_email' => $object->email, |
|
284 | - $array_key . '_jabberid' => $object->jabberid, |
|
285 | - $array_key . '_phone_pro' => $object->phone_pro, |
|
286 | - $array_key . '_phone_perso' => $object->phone_perso, |
|
287 | - $array_key . '_phone_mobile' => $object->phone_mobile, |
|
288 | - $array_key . '_fax' => $object->fax, |
|
289 | - $array_key . '_birthday' => $object->birthday, |
|
290 | - $array_key . '_default_lang' => $object->default_lang, |
|
291 | - $array_key . '_note_public' => $object->note_public, |
|
292 | - $array_key . '_note_private' => $object->note_private |
|
266 | + $array_contact = array( |
|
267 | + $array_key.'_fullname' => $object->getFullName($outputlangs, 1), |
|
268 | + $array_key.'_lastname' => $object->lastname, |
|
269 | + $array_key.'_firstname' => $object->firstname, |
|
270 | + $array_key.'_address' => $object->address, |
|
271 | + $array_key.'_zip' => $object->zip, |
|
272 | + $array_key.'_town' => $object->town, |
|
273 | + $array_key.'_state_id' => $object->state_id, |
|
274 | + $array_key.'_state_code' => $object->state_code, |
|
275 | + $array_key.'_state' => $object->state, |
|
276 | + $array_key.'_country_id' => $object->country_id, |
|
277 | + $array_key.'_country_code' => $object->country_code, |
|
278 | + $array_key.'_country' => $object->country, |
|
279 | + $array_key.'_poste' => $object->poste, |
|
280 | + $array_key.'_socid' => $object->socid, |
|
281 | + $array_key.'_statut' => $object->statut, |
|
282 | + $array_key.'_code' => $object->code, |
|
283 | + $array_key.'_email' => $object->email, |
|
284 | + $array_key.'_jabberid' => $object->jabberid, |
|
285 | + $array_key.'_phone_pro' => $object->phone_pro, |
|
286 | + $array_key.'_phone_perso' => $object->phone_perso, |
|
287 | + $array_key.'_phone_mobile' => $object->phone_mobile, |
|
288 | + $array_key.'_fax' => $object->fax, |
|
289 | + $array_key.'_birthday' => $object->birthday, |
|
290 | + $array_key.'_default_lang' => $object->default_lang, |
|
291 | + $array_key.'_note_public' => $object->note_public, |
|
292 | + $array_key.'_note_private' => $object->note_private |
|
293 | 293 | ); |
294 | 294 | |
295 | 295 | // Retrieve extrafields |
296 | - require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; |
|
296 | + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
297 | 297 | $extrafields = new ExtraFields($this->db); |
298 | 298 | $extralabels = $extrafields->fetch_name_optionals_label('socpeople', true); |
299 | 299 | $object->fetch_optionals(); |
300 | 300 | |
301 | - foreach($extrafields->attribute_label as $key => $label) |
|
301 | + foreach ($extrafields->attribute_label as $key => $label) |
|
302 | 302 | { |
303 | 303 | if ($extrafields->attribute_type[$key] == 'price') |
304 | 304 | { |
305 | - $object->array_options['options_' . $key] = price($object->array_options ['options_' . $key], 0, $outputlangs, 0, 0, - 1, $conf->currency); |
|
305 | + $object->array_options['options_'.$key] = price($object->array_options ['options_'.$key], 0, $outputlangs, 0, 0, - 1, $conf->currency); |
|
306 | 306 | } |
307 | - elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
307 | + elseif ($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
308 | 308 | { |
309 | - $object->array_options['options_' . $key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_' . $key]]; |
|
309 | + $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
|
310 | 310 | } |
311 | - $array_contact = array_merge($array_contact, array($array_key.'_options_' . $key => $object->array_options['options_'. $key])); |
|
311 | + $array_contact = array_merge($array_contact, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); |
|
312 | 312 | } |
313 | 313 | return $array_contact; |
314 | 314 | } |
@@ -326,22 +326,22 @@ discard block |
||
326 | 326 | // phpcs:enable |
327 | 327 | global $conf; |
328 | 328 | |
329 | - $now=dol_now('gmt'); // gmt |
|
329 | + $now = dol_now('gmt'); // gmt |
|
330 | 330 | $array_other = array( |
331 | 331 | // Date in default language |
332 | - 'current_date'=>dol_print_date($now,'day','tzuser'), |
|
333 | - 'current_datehour'=>dol_print_date($now,'dayhour','tzuser'), |
|
334 | - 'current_server_date'=>dol_print_date($now,'day','tzserver'), |
|
335 | - 'current_server_datehour'=>dol_print_date($now,'dayhour','tzserver'), |
|
332 | + 'current_date'=>dol_print_date($now, 'day', 'tzuser'), |
|
333 | + 'current_datehour'=>dol_print_date($now, 'dayhour', 'tzuser'), |
|
334 | + 'current_server_date'=>dol_print_date($now, 'day', 'tzserver'), |
|
335 | + 'current_server_datehour'=>dol_print_date($now, 'dayhour', 'tzserver'), |
|
336 | 336 | // Date in requested output language |
337 | - 'current_date_locale'=>dol_print_date($now,'day','tzuser',$outputlangs), |
|
338 | - 'current_datehour_locale'=>dol_print_date($now,'dayhour','tzuser',$outputlangs), |
|
339 | - 'current_server_date_locale'=>dol_print_date($now,'day','tzserver',$outputlangs), |
|
340 | - 'current_server_datehour_locale'=>dol_print_date($now,'dayhour','tzserver',$outputlangs), |
|
337 | + 'current_date_locale'=>dol_print_date($now, 'day', 'tzuser', $outputlangs), |
|
338 | + 'current_datehour_locale'=>dol_print_date($now, 'dayhour', 'tzuser', $outputlangs), |
|
339 | + 'current_server_date_locale'=>dol_print_date($now, 'day', 'tzserver', $outputlangs), |
|
340 | + 'current_server_datehour_locale'=>dol_print_date($now, 'dayhour', 'tzserver', $outputlangs), |
|
341 | 341 | ); |
342 | 342 | |
343 | 343 | |
344 | - foreach($conf->global as $key => $val) |
|
344 | + foreach ($conf->global as $key => $val) |
|
345 | 345 | { |
346 | 346 | if (preg_match('/(_pass|password|secret|_key|key$)/i', $key)) $newval = '*****forbidden*****'; |
347 | 347 | else $newval = $val; |
@@ -361,15 +361,15 @@ discard block |
||
361 | 361 | * @param string $array_key Name of the key for return array |
362 | 362 | * @return array Array of substitution |
363 | 363 | */ |
364 | - function get_substitutionarray_object($object,$outputlangs,$array_key='object') |
|
364 | + function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') |
|
365 | 365 | { |
366 | 366 | // phpcs:enable |
367 | 367 | global $conf; |
368 | 368 | |
369 | - $sumpayed=$sumdeposit=$sumcreditnote=''; |
|
369 | + $sumpayed = $sumdeposit = $sumcreditnote = ''; |
|
370 | 370 | if ($object->element == 'facture') |
371 | 371 | { |
372 | - $invoice_source=new Facture($this->db); |
|
372 | + $invoice_source = new Facture($this->db); |
|
373 | 373 | if ($object->fk_facture_source > 0) |
374 | 374 | { |
375 | 375 | $invoice_source->fetch($object->fk_facture_source); |
@@ -381,38 +381,38 @@ discard block |
||
381 | 381 | |
382 | 382 | $date = ($object->element == 'contrat' ? $object->date_contrat : $object->date); |
383 | 383 | |
384 | - $resarray=array( |
|
384 | + $resarray = array( |
|
385 | 385 | $array_key.'_id'=>$object->id, |
386 | 386 | $array_key.'_ref'=>$object->ref, |
387 | 387 | $array_key.'_ref_ext'=>$object->ref_ext, |
388 | - $array_key.'_ref_customer'=>(! empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), |
|
389 | - $array_key.'_ref_supplier'=>(! empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), |
|
388 | + $array_key.'_ref_customer'=>(!empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), |
|
389 | + $array_key.'_ref_supplier'=>(!empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), |
|
390 | 390 | $array_key.'_source_invoice_ref'=>$invoice_source->ref, |
391 | 391 | // Dates |
392 | - $array_key.'_hour'=>dol_print_date($date,'hour'), |
|
393 | - $array_key.'_date'=>dol_print_date($date,'day'), |
|
394 | - $array_key.'_date_rfc'=>dol_print_date($date,'dayrfc'), |
|
395 | - $array_key.'_date_limit'=>(! empty($object->date_lim_reglement)?dol_print_date($object->date_lim_reglement,'day'):''), |
|
396 | - $array_key.'_date_end'=>(! empty($object->fin_validite)?dol_print_date($object->fin_validite,'day'):''), |
|
397 | - $array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'), |
|
398 | - $array_key.'_date_modification'=>(! empty($object->date_modification)?dol_print_date($object->date_modification,'day'):''), |
|
399 | - $array_key.'_date_validation'=>(! empty($object->date_validation)?dol_print_date($object->date_validation,'dayhour'):''), |
|
400 | - $array_key.'_date_delivery_planed'=>(! empty($object->date_livraison)?dol_print_date($object->date_livraison,'day'):''), |
|
401 | - $array_key.'_date_close'=>(! empty($object->date_cloture)?dol_print_date($object->date_cloture,'dayhour'):''), |
|
392 | + $array_key.'_hour'=>dol_print_date($date, 'hour'), |
|
393 | + $array_key.'_date'=>dol_print_date($date, 'day'), |
|
394 | + $array_key.'_date_rfc'=>dol_print_date($date, 'dayrfc'), |
|
395 | + $array_key.'_date_limit'=>(!empty($object->date_lim_reglement) ?dol_print_date($object->date_lim_reglement, 'day') : ''), |
|
396 | + $array_key.'_date_end'=>(!empty($object->fin_validite) ?dol_print_date($object->fin_validite, 'day') : ''), |
|
397 | + $array_key.'_date_creation'=>dol_print_date($object->date_creation, 'day'), |
|
398 | + $array_key.'_date_modification'=>(!empty($object->date_modification) ?dol_print_date($object->date_modification, 'day') : ''), |
|
399 | + $array_key.'_date_validation'=>(!empty($object->date_validation) ?dol_print_date($object->date_validation, 'dayhour') : ''), |
|
400 | + $array_key.'_date_delivery_planed'=>(!empty($object->date_livraison) ?dol_print_date($object->date_livraison, 'day') : ''), |
|
401 | + $array_key.'_date_close'=>(!empty($object->date_cloture) ?dol_print_date($object->date_cloture, 'dayhour') : ''), |
|
402 | 402 | |
403 | 403 | $array_key.'_payment_mode_code'=>$object->mode_reglement_code, |
404 | - $array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement), |
|
404 | + $array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) : $object->mode_reglement), |
|
405 | 405 | $array_key.'_payment_term_code'=>$object->cond_reglement_code, |
406 | - $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):($object->cond_reglement_doc?$object->cond_reglement_doc:$object->cond_reglement)), |
|
406 | + $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) : ($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement)), |
|
407 | 407 | |
408 | 408 | $array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs), |
409 | - $array_key.'_total_vat_locale'=>(! empty($object->total_vat)?price($object->total_vat, 0, $outputlangs):price($object->total_tva, 0, $outputlangs)), |
|
409 | + $array_key.'_total_vat_locale'=>(!empty($object->total_vat) ?price($object->total_vat, 0, $outputlangs) : price($object->total_tva, 0, $outputlangs)), |
|
410 | 410 | $array_key.'_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs), |
411 | 411 | $array_key.'_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs), |
412 | 412 | $array_key.'_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs), |
413 | 413 | |
414 | 414 | $array_key.'_total_ht'=>price2num($object->total_ht), |
415 | - $array_key.'_total_vat'=>(! empty($object->total_vat)?price2num($object->total_vat):price2num($object->total_tva)), |
|
415 | + $array_key.'_total_vat'=>(!empty($object->total_vat) ?price2num($object->total_vat) : price2num($object->total_tva)), |
|
416 | 416 | $array_key.'_total_localtax1'=>price2num($object->total_localtax1), |
417 | 417 | $array_key.'_total_localtax2'=>price2num($object->total_localtax2), |
418 | 418 | $array_key.'_total_ttc'=>price2num($object->total_ttc), |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | |
429 | 429 | $array_key.'_note_private'=>$object->note, |
430 | 430 | $array_key.'_note_public'=>$object->note_public, |
431 | - $array_key.'_note'=>$object->note_public, // For backward compatibility |
|
431 | + $array_key.'_note'=>$object->note_public, // For backward compatibility |
|
432 | 432 | |
433 | 433 | // Payments |
434 | 434 | $array_key.'_already_payed_locale'=>price($sumpayed, 0, $outputlangs), |
@@ -455,9 +455,9 @@ discard block |
||
455 | 455 | } |
456 | 456 | |
457 | 457 | // Fetch project information if there is a project assigned to this object |
458 | - if ($object->element != "project" && ! empty($object->fk_project) && $object->fk_project > 0) |
|
458 | + if ($object->element != "project" && !empty($object->fk_project) && $object->fk_project > 0) |
|
459 | 459 | { |
460 | - if (! is_object($object->project)) |
|
460 | + if (!is_object($object->project)) |
|
461 | 461 | { |
462 | 462 | $object->fetch_projet(); |
463 | 463 | } |
@@ -470,32 +470,32 @@ discard block |
||
470 | 470 | } |
471 | 471 | |
472 | 472 | // Add vat by rates |
473 | - if (is_array($object->lines) && count($object->lines)>0) |
|
473 | + if (is_array($object->lines) && count($object->lines) > 0) |
|
474 | 474 | { |
475 | 475 | foreach ($object->lines as $line) |
476 | 476 | { |
477 | 477 | // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility |
478 | - if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
479 | - $resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
|
480 | - $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); |
|
478 | + if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx] = 0; |
|
479 | + $resarray[$array_key.'_total_vat_'.$line->tva_tx] += $line->total_tva; |
|
480 | + $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx] = price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); |
|
481 | 481 | // $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example) |
482 | - $vatformated=vatrate($line->tva_tx); |
|
483 | - if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0; |
|
484 | - $resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva; |
|
485 | - $resarray[$array_key.'_total_vat_locale_'.$vatformated]=price($resarray[$array_key.'_total_vat_'.$vatformated]); |
|
482 | + $vatformated = vatrate($line->tva_tx); |
|
483 | + if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated] = 0; |
|
484 | + $resarray[$array_key.'_total_vat_'.$vatformated] += $line->total_tva; |
|
485 | + $resarray[$array_key.'_total_vat_locale_'.$vatformated] = price($resarray[$array_key.'_total_vat_'.$vatformated]); |
|
486 | 486 | } |
487 | 487 | } |
488 | 488 | // Retrieve extrafields |
489 | 489 | if (is_array($object->array_options) && count($object->array_options)) |
490 | 490 | { |
491 | - $extrafieldkey=$object->element; |
|
491 | + $extrafieldkey = $object->element; |
|
492 | 492 | |
493 | 493 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
494 | 494 | $extrafields = new ExtraFields($this->db); |
495 | - $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true); |
|
495 | + $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey, true); |
|
496 | 496 | $object->fetch_optionals(); |
497 | 497 | |
498 | - $resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs); |
|
498 | + $resarray = $this->fill_substitutionarray_with_extrafields($object, $resarray, $extrafields, $array_key, $outputlangs); |
|
499 | 499 | } |
500 | 500 | return $resarray; |
501 | 501 | } |
@@ -513,18 +513,18 @@ discard block |
||
513 | 513 | // phpcs:enable |
514 | 514 | global $conf; |
515 | 515 | |
516 | - $resarray= array( |
|
517 | - 'line_fulldesc'=>doc_getlinedesc($line,$outputlangs), |
|
516 | + $resarray = array( |
|
517 | + 'line_fulldesc'=>doc_getlinedesc($line, $outputlangs), |
|
518 | 518 | 'line_product_ref'=>$line->product_ref, |
519 | 519 | 'line_product_ref_fourn'=>$line->ref_fourn, // for supplier doc lines |
520 | 520 | 'line_product_label'=>$line->product_label, |
521 | 521 | 'line_product_type'=>$line->product_type, |
522 | 522 | 'line_desc'=>$line->desc, |
523 | - 'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits), |
|
523 | + 'line_vatrate'=>vatrate($line->tva_tx, true, $line->info_bits), |
|
524 | 524 | 'line_up'=>price2num($line->subprice), |
525 | 525 | 'line_up_locale'=>price($line->subprice, 0, $outputlangs), |
526 | 526 | 'line_qty'=>$line->qty, |
527 | - 'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''), |
|
527 | + 'line_discount_percent'=>($line->remise_percent ? $line->remise_percent.'%' : ''), |
|
528 | 528 | 'line_price_ht'=>price2num($line->total_ht), |
529 | 529 | 'line_price_ttc'=>price2num($line->total_ttc), |
530 | 530 | 'line_price_vat'=>price2num($line->total_tva), |
@@ -553,26 +553,26 @@ discard block |
||
553 | 553 | // Units |
554 | 554 | if ($conf->global->PRODUCT_USE_UNITS) |
555 | 555 | { |
556 | - $resarray['line_unit']=$outputlangs->trans($line->getLabelOfUnit('long')); |
|
557 | - $resarray['line_unit_short']=$outputlangs->trans($line->getLabelOfUnit('short')); |
|
556 | + $resarray['line_unit'] = $outputlangs->trans($line->getLabelOfUnit('long')); |
|
557 | + $resarray['line_unit_short'] = $outputlangs->trans($line->getLabelOfUnit('short')); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | // Retrieve extrafields |
561 | - $extrafieldkey=$line->element; |
|
562 | - $array_key="line"; |
|
561 | + $extrafieldkey = $line->element; |
|
562 | + $array_key = "line"; |
|
563 | 563 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
564 | 564 | $extrafields = new ExtraFields($this->db); |
565 | - $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true); |
|
565 | + $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey, true); |
|
566 | 566 | $line->fetch_optionals(); |
567 | 567 | |
568 | - $resarray = $this->fill_substitutionarray_with_extrafields($line,$resarray,$extrafields,$array_key=$array_key,$outputlangs); |
|
568 | + $resarray = $this->fill_substitutionarray_with_extrafields($line, $resarray, $extrafields, $array_key = $array_key, $outputlangs); |
|
569 | 569 | |
570 | 570 | // Load product data optional fields to the line -> enables to use "line_options_{extrafield}" |
571 | 571 | if (isset($line->fk_product) && $line->fk_product > 0) |
572 | 572 | { |
573 | 573 | $tmpproduct = new Product($this->db); |
574 | 574 | $result = $tmpproduct->fetch($line->fk_product); |
575 | - foreach($tmpproduct->array_options as $key=>$label) |
|
575 | + foreach ($tmpproduct->array_options as $key=>$label) |
|
576 | 576 | $resarray["line_product_".$key] = $label; |
577 | 577 | } |
578 | 578 | |
@@ -588,22 +588,22 @@ discard block |
||
588 | 588 | * @param array $array_key Name of the key for return array |
589 | 589 | * @return array Array of substitution |
590 | 590 | */ |
591 | - function get_substitutionarray_shipment($object,$outputlangs,$array_key='object') |
|
591 | + function get_substitutionarray_shipment($object, $outputlangs, $array_key = 'object') |
|
592 | 592 | { |
593 | 593 | // phpcs:enable |
594 | 594 | global $conf; |
595 | 595 | dol_include_once('/core/lib/product.lib.php'); |
596 | 596 | $object->list_delivery_methods($object->shipping_method_id); |
597 | - $calculatedVolume=($object->trueWidth * $object->trueHeight * $object->trueDepth); |
|
597 | + $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth); |
|
598 | 598 | |
599 | - $array_shipment=array( |
|
599 | + $array_shipment = array( |
|
600 | 600 | $array_key.'_id'=>$object->id, |
601 | 601 | $array_key.'_ref'=>$object->ref, |
602 | 602 | $array_key.'_ref_ext'=>$object->ref_ext, |
603 | 603 | $array_key.'_ref_customer'=>$object->ref_customer, |
604 | - $array_key.'_date_delivery'=>dol_print_date($object->date_delivery,'day'), |
|
605 | - $array_key.'_hour_delivery'=>dol_print_date($object->date_delivery,'hour'), |
|
606 | - $array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'), |
|
604 | + $array_key.'_date_delivery'=>dol_print_date($object->date_delivery, 'day'), |
|
605 | + $array_key.'_hour_delivery'=>dol_print_date($object->date_delivery, 'hour'), |
|
606 | + $array_key.'_date_creation'=>dol_print_date($object->date_creation, 'day'), |
|
607 | 607 | $array_key.'_total_ht'=>price($object->total_ht), |
608 | 608 | $array_key.'_total_vat'=>price($object->total_tva), |
609 | 609 | $array_key.'_total_ttc'=>price($object->total_ttc), |
@@ -623,8 +623,8 @@ discard block |
||
623 | 623 | // Add vat by rates |
624 | 624 | foreach ($object->lines as $line) |
625 | 625 | { |
626 | - if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
627 | - $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
|
626 | + if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) $array_shipment[$array_key.'_total_vat_'.$line->tva_tx] = 0; |
|
627 | + $array_shipment[$array_key.'_total_vat_'.$line->tva_tx] += $line->total_tva; |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | // Retrieve extrafields |
@@ -632,10 +632,10 @@ discard block |
||
632 | 632 | { |
633 | 633 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
634 | 634 | $extrafields = new ExtraFields($this->db); |
635 | - $extralabels = $extrafields->fetch_name_optionals_label('expedition',true); |
|
635 | + $extralabels = $extrafields->fetch_name_optionals_label('expedition', true); |
|
636 | 636 | $object->fetch_optionals(); |
637 | 637 | |
638 | - $array_shipment = $this->fill_substitutionarray_with_extrafields($object,$array_shipment,$extrafields,$array_key,$outputlangs); |
|
638 | + $array_shipment = $this->fill_substitutionarray_with_extrafields($object, $array_shipment, $extrafields, $array_key, $outputlangs); |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | return $array_shipment; |
@@ -657,23 +657,23 @@ discard block |
||
657 | 657 | dol_include_once('/core/lib/product.lib.php'); |
658 | 658 | |
659 | 659 | $resarray = array( |
660 | - 'line_fulldesc'=>doc_getlinedesc($line,$outputlangs), |
|
660 | + 'line_fulldesc'=>doc_getlinedesc($line, $outputlangs), |
|
661 | 661 | 'line_product_ref'=>$line->product_ref, |
662 | 662 | 'line_product_label'=>$line->product_label, |
663 | 663 | 'line_desc'=>$line->desc, |
664 | - 'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits), |
|
664 | + 'line_vatrate'=>vatrate($line->tva_tx, true, $line->info_bits), |
|
665 | 665 | 'line_up'=>price($line->subprice), |
666 | 666 | 'line_qty'=>$line->qty, |
667 | 667 | 'line_qty_shipped'=>$line->qty_shipped, |
668 | 668 | 'line_qty_asked'=>$line->qty_asked, |
669 | - 'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''), |
|
669 | + 'line_discount_percent'=>($line->remise_percent ? $line->remise_percent.'%' : ''), |
|
670 | 670 | 'line_price_ht'=>price($line->total_ht), |
671 | 671 | 'line_price_ttc'=>price($line->total_ttc), |
672 | 672 | 'line_price_vat'=>price($line->total_tva), |
673 | - 'line_weight'=>empty($line->weight) ? '' : $line->weight*$line->qty_shipped.' '.measuring_units_string($line->weight_units, 'weight'), |
|
674 | - 'line_length'=>empty($line->length) ? '' : $line->length*$line->qty_shipped.' '.measuring_units_string($line->length_units, 'size'), |
|
675 | - 'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuring_units_string($line->surface_units, 'surface'), |
|
676 | - 'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuring_units_string($line->volume_units, 'volume'), |
|
673 | + 'line_weight'=>empty($line->weight) ? '' : $line->weight * $line->qty_shipped.' '.measuring_units_string($line->weight_units, 'weight'), |
|
674 | + 'line_length'=>empty($line->length) ? '' : $line->length * $line->qty_shipped.' '.measuring_units_string($line->length_units, 'size'), |
|
675 | + 'line_surface'=>empty($line->surface) ? '' : $line->surface * $line->qty_shipped.' '.measuring_units_string($line->surface_units, 'surface'), |
|
676 | + 'line_volume'=>empty($line->volume) ? '' : $line->volume * $line->qty_shipped.' '.measuring_units_string($line->volume_units, 'volume'), |
|
677 | 677 | ); |
678 | 678 | |
679 | 679 | // Retrieve extrafields |
@@ -699,18 +699,18 @@ discard block |
||
699 | 699 | * @param boolean $recursive Want to fetch child array or child object |
700 | 700 | * @return array Array of substitution key->code |
701 | 701 | */ |
702 | - function get_substitutionarray_each_var_object(&$object,$outputlangs,$recursive=true) |
|
702 | + function get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive = true) |
|
703 | 703 | { |
704 | 704 | // phpcs:enable |
705 | 705 | $array_other = array(); |
706 | 706 | if (!empty($object)) { |
707 | - foreach($object as $key => $value) { |
|
707 | + foreach ($object as $key => $value) { |
|
708 | 708 | if (!empty($value)) { |
709 | 709 | if (!is_array($value) && !is_object($value)) { |
710 | 710 | $array_other['object_'.$key] = $value; |
711 | 711 | } |
712 | 712 | if (is_array($value) && $recursive) { |
713 | - $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value,$outputlangs,false); |
|
713 | + $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value, $outputlangs, false); |
|
714 | 714 | } |
715 | 715 | } |
716 | 716 | } |
@@ -730,31 +730,31 @@ discard block |
||
730 | 730 | * @param Translate $outputlangs Lang object to use for output |
731 | 731 | * @return array Substitution array |
732 | 732 | */ |
733 | - function fill_substitutionarray_with_extrafields($object,$array_to_fill,$extrafields,$array_key,$outputlangs) |
|
733 | + function fill_substitutionarray_with_extrafields($object, $array_to_fill, $extrafields, $array_key, $outputlangs) |
|
734 | 734 | { |
735 | 735 | // phpcs:enable |
736 | 736 | global $conf; |
737 | - foreach($extrafields->attribute_label as $key=>$label) |
|
737 | + foreach ($extrafields->attribute_label as $key=>$label) |
|
738 | 738 | { |
739 | - if($extrafields->attribute_type[$key] == 'price') |
|
739 | + if ($extrafields->attribute_type[$key] == 'price') |
|
740 | 740 | { |
741 | 741 | $object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key]); |
742 | - $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); |
|
742 | + $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency); |
|
743 | 743 | //Add value to store price with currency |
744 | - $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); |
|
744 | + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); |
|
745 | 745 | } |
746 | - else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
746 | + else if ($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
747 | 747 | { |
748 | 748 | $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
749 | 749 | } |
750 | - else if($extrafields->attribute_type[$key] == 'date') |
|
750 | + else if ($extrafields->attribute_type[$key] == 'date') |
|
751 | 751 | { |
752 | - if (strlen($object->array_options['options_'.$key])>0) |
|
752 | + if (strlen($object->array_options['options_'.$key]) > 0) |
|
753 | 753 | { |
754 | 754 | $date = $object->array_options['options_'.$key]; |
755 | - $object->array_options['options_'.$key] = dol_print_date($date,'day'); // using company output language |
|
756 | - $object->array_options['options_'.$key.'_locale'] = dol_print_date($date,'day','tzserver',$outputlangs); // using output language format |
|
757 | - $object->array_options['options_'.$key.'_rfc'] = dol_print_date($date,'dayrfc'); // international format |
|
755 | + $object->array_options['options_'.$key] = dol_print_date($date, 'day'); // using company output language |
|
756 | + $object->array_options['options_'.$key.'_locale'] = dol_print_date($date, 'day', 'tzserver', $outputlangs); // using output language format |
|
757 | + $object->array_options['options_'.$key.'_rfc'] = dol_print_date($date, 'dayrfc'); // international format |
|
758 | 758 | } |
759 | 759 | else |
760 | 760 | { |
@@ -762,29 +762,29 @@ discard block |
||
762 | 762 | $object->array_options['options_'.$key.'_locale'] = ''; |
763 | 763 | $object->array_options['options_'.$key.'_rfc'] = ''; |
764 | 764 | } |
765 | - $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); |
|
766 | - $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); |
|
765 | + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); |
|
766 | + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); |
|
767 | 767 | } |
768 | - else if($extrafields->attribute_type[$key] == 'datetime') |
|
768 | + else if ($extrafields->attribute_type[$key] == 'datetime') |
|
769 | 769 | { |
770 | 770 | $datetime = $object->array_options['options_'.$key]; |
771 | - $object->array_options['options_'.$key] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhour'):''); // using company output language |
|
772 | - $object->array_options['options_'.$key.'_locale'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhour','tzserver',$outputlangs):''); // using output language format |
|
773 | - $object->array_options['options_'.$key.'_rfc'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhourrfc'):''); // international format |
|
774 | - $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); |
|
775 | - $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); |
|
771 | + $object->array_options['options_'.$key] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhour') : ''); // using company output language |
|
772 | + $object->array_options['options_'.$key.'_locale'] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhour', 'tzserver', $outputlangs) : ''); // using output language format |
|
773 | + $object->array_options['options_'.$key.'_rfc'] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhourrfc') : ''); // international format |
|
774 | + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); |
|
775 | + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); |
|
776 | 776 | } |
777 | - else if($extrafields->attribute_type[$key] == 'link') |
|
777 | + else if ($extrafields->attribute_type[$key] == 'link') |
|
778 | 778 | { |
779 | 779 | $id = $object->array_options['options_'.$key]; |
780 | 780 | if ($id != "") |
781 | 781 | { |
782 | 782 | $param = $extrafields->attribute_param[$key]; |
783 | - $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' |
|
783 | + $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath' |
|
784 | 784 | $InfoFieldList = explode(":", $param_list[0]); |
785 | - $classname=$InfoFieldList[0]; |
|
786 | - $classpath=$InfoFieldList[1]; |
|
787 | - if (! empty($classpath)) |
|
785 | + $classname = $InfoFieldList[0]; |
|
786 | + $classpath = $InfoFieldList[1]; |
|
787 | + if (!empty($classpath)) |
|
788 | 788 | { |
789 | 789 | dol_include_once($InfoFieldList[1]); |
790 | 790 | if ($classname && class_exists($classname)) |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | } |
799 | 799 | } |
800 | 800 | |
801 | - $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); |
|
801 | + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | return $array_to_fill; |
@@ -817,12 +817,12 @@ discard block |
||
817 | 817 | * @param int $hidebottom Hide bottom |
818 | 818 | * @return void |
819 | 819 | */ |
820 | - function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
|
820 | + function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0) |
|
821 | 821 | { |
822 | - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
823 | - $pdf->line($x+$l, $y, $x+$l, $y+$h); |
|
824 | - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
825 | - $pdf->line($x, $y+$h, $x, $y); |
|
822 | + if (empty($hidetop) || $hidetop == -1) $pdf->line($x, $y, $x + $l, $y); |
|
823 | + $pdf->line($x + $l, $y, $x + $l, $y + $h); |
|
824 | + if (empty($hidebottom)) $pdf->line($x + $l, $y + $h, $x, $y + $h); |
|
825 | + $pdf->line($x, $y + $h, $x, $y); |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | |
@@ -835,8 +835,8 @@ discard block |
||
835 | 835 | */ |
836 | 836 | function columnSort($a, $b) |
837 | 837 | { |
838 | - if(empty($a['rank'])){ $a['rank'] = 0; } |
|
839 | - if(empty($b['rank'])){ $b['rank'] = 0; } |
|
838 | + if (empty($a['rank'])) { $a['rank'] = 0; } |
|
839 | + if (empty($b['rank'])) { $b['rank'] = 0; } |
|
840 | 840 | if ($a['rank'] == $b['rank']) { |
841 | 841 | return 0; |
842 | 842 | } |
@@ -853,38 +853,38 @@ discard block |
||
853 | 853 | * @param int $hideref Do not show ref |
854 | 854 | * @return null |
855 | 855 | */ |
856 | - function prepareArrayColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0) |
|
856 | + function prepareArrayColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
857 | 857 | { |
858 | 858 | global $conf; |
859 | 859 | |
860 | - $this->defineColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref); |
|
860 | + $this->defineColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
861 | 861 | |
862 | 862 | |
863 | 863 | // Sorting |
864 | - uasort ( $this->cols, array( $this, 'columnSort' ) ); |
|
864 | + uasort($this->cols, array($this, 'columnSort')); |
|
865 | 865 | |
866 | 866 | // Positionning |
867 | - $curX = $this->page_largeur-$this->marge_droite; // start from right |
|
867 | + $curX = $this->page_largeur - $this->marge_droite; // start from right |
|
868 | 868 | |
869 | 869 | // Array witdh |
870 | - $arrayWidth = $this->page_largeur-$this->marge_droite-$this->marge_gauche; |
|
870 | + $arrayWidth = $this->page_largeur - $this->marge_droite - $this->marge_gauche; |
|
871 | 871 | |
872 | 872 | // Count flexible column |
873 | 873 | $totalDefinedColWidth = 0; |
874 | 874 | $countFlexCol = 0; |
875 | 875 | foreach ($this->cols as $colKey =>& $colDef) |
876 | 876 | { |
877 | - if(!$this->getColumnStatus($colKey)) continue; // continue if desable |
|
877 | + if (!$this->getColumnStatus($colKey)) continue; // continue if desable |
|
878 | 878 | |
879 | - if(!empty($colDef['scale'])){ |
|
879 | + if (!empty($colDef['scale'])) { |
|
880 | 880 | // In case of column widht is defined by percentage |
881 | - $colDef['width'] = abs($arrayWidth * $colDef['scale'] / 100 ); |
|
881 | + $colDef['width'] = abs($arrayWidth * $colDef['scale'] / 100); |
|
882 | 882 | } |
883 | 883 | |
884 | - if(empty($colDef['width'])){ |
|
884 | + if (empty($colDef['width'])) { |
|
885 | 885 | $countFlexCol++; |
886 | 886 | } |
887 | - else{ |
|
887 | + else { |
|
888 | 888 | $totalDefinedColWidth += $colDef['width']; |
889 | 889 | } |
890 | 890 | } |
@@ -892,25 +892,25 @@ discard block |
||
892 | 892 | foreach ($this->cols as $colKey =>& $colDef) |
893 | 893 | { |
894 | 894 | // setting empty conf with default |
895 | - if(!empty($colDef['title'])){ |
|
895 | + if (!empty($colDef['title'])) { |
|
896 | 896 | $colDef['title'] = array_replace($this->defaultTitlesFieldsStyle, $colDef['title']); |
897 | 897 | } |
898 | - else{ |
|
898 | + else { |
|
899 | 899 | $colDef['title'] = $this->defaultTitlesFieldsStyle; |
900 | 900 | } |
901 | 901 | |
902 | 902 | // setting empty conf with default |
903 | - if(!empty($colDef['content'])){ |
|
903 | + if (!empty($colDef['content'])) { |
|
904 | 904 | $colDef['content'] = array_replace($this->defaultContentsFieldsStyle, $colDef['content']); |
905 | 905 | } |
906 | - else{ |
|
906 | + else { |
|
907 | 907 | $colDef['content'] = $this->defaultContentsFieldsStyle; |
908 | 908 | } |
909 | 909 | |
910 | - if($this->getColumnStatus($colKey)) |
|
910 | + if ($this->getColumnStatus($colKey)) |
|
911 | 911 | { |
912 | 912 | // In case of flexible column |
913 | - if(empty($colDef['width'])){ |
|
913 | + if (empty($colDef['width'])) { |
|
914 | 914 | $colDef['width'] = abs(($arrayWidth - $totalDefinedColWidth)) / $countFlexCol; |
915 | 915 | } |
916 | 916 | |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | */ |
957 | 957 | function getColumnRank($colKey) |
958 | 958 | { |
959 | - if(!isset($this->cols[$colKey]['rank'])) return -1; |
|
959 | + if (!isset($this->cols[$colKey]['rank'])) return -1; |
|
960 | 960 | return $this->cols[$colKey]['rank']; |
961 | 961 | } |
962 | 962 | |
@@ -975,22 +975,22 @@ discard block |
||
975 | 975 | $rank = -1; |
976 | 976 | |
977 | 977 | // try to get rank from target column |
978 | - if(!empty($targetCol)){ |
|
978 | + if (!empty($targetCol)) { |
|
979 | 979 | $rank = $this->getColumnRank($targetCol); |
980 | - if($rank>=0 && $insertAfterTarget){ $rank++; } |
|
980 | + if ($rank >= 0 && $insertAfterTarget) { $rank++; } |
|
981 | 981 | } |
982 | 982 | |
983 | 983 | // get rank from new column definition |
984 | - if($rank<0 && !empty($defArray['rank'])){ |
|
984 | + if ($rank < 0 && !empty($defArray['rank'])) { |
|
985 | 985 | $rank = $defArray['rank']; |
986 | 986 | } |
987 | 987 | |
988 | 988 | // error: no rank |
989 | - if($rank<0){ return -1; } |
|
989 | + if ($rank < 0) { return -1; } |
|
990 | 990 | |
991 | 991 | foreach ($this->cols as $colKey =>& $colDef) |
992 | 992 | { |
993 | - if( $rank <= $colDef['rank']) |
|
993 | + if ($rank <= $colDef['rank']) |
|
994 | 994 | { |
995 | 995 | $colDef['rank'] = $colDef['rank'] + 1; |
996 | 996 | } |
@@ -1016,19 +1016,19 @@ discard block |
||
1016 | 1016 | { |
1017 | 1017 | global $hookmanager; |
1018 | 1018 | |
1019 | - $parameters=array( |
|
1019 | + $parameters = array( |
|
1020 | 1020 | 'curY' => &$curY, |
1021 | 1021 | 'columnText' => $columnText, |
1022 | 1022 | 'colKey' => $colKey |
1023 | 1023 | ); |
1024 | - $reshook=$hookmanager->executeHooks('printStdColumnContent',$parameters,$this); // Note that $action and $object may have been modified by hook |
|
1025 | - if ($reshook < 0) setEventMessages($hookmanager->error,$hookmanager->errors,'errors'); |
|
1024 | + $reshook = $hookmanager->executeHooks('printStdColumnContent', $parameters, $this); // Note that $action and $object may have been modified by hook |
|
1025 | + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
1026 | 1026 | if (!$reshook) |
1027 | 1027 | { |
1028 | - if(empty($columnText)) return; |
|
1029 | - $pdf->SetXY($this->getColumnContentXStart($colKey),$curY); // Set curent position |
|
1028 | + if (empty($columnText)) return; |
|
1029 | + $pdf->SetXY($this->getColumnContentXStart($colKey), $curY); // Set curent position |
|
1030 | 1030 | $colDef = $this->cols[$colKey]; |
1031 | - $pdf->writeHTMLCell( $this->getColumnContentWidth($colKey),2,$this->getColumnContentXStart($colKey),$curY, $columnText,0,0,0,true,$colDef['content']['align']); |
|
1031 | + $pdf->writeHTMLCell($this->getColumnContentWidth($colKey), 2, $this->getColumnContentXStart($colKey), $curY, $columnText, 0, 0, 0, true, $colDef['content']['align']); |
|
1032 | 1032 | } |
1033 | 1033 | } |
1034 | 1034 | |
@@ -1041,7 +1041,7 @@ discard block |
||
1041 | 1041 | */ |
1042 | 1042 | function getColumnStatus($colKey) |
1043 | 1043 | { |
1044 | - if( !empty($this->cols[$colKey]['status'])){ |
|
1044 | + if (!empty($this->cols[$colKey]['status'])) { |
|
1045 | 1045 | return true; |
1046 | 1046 | } |
1047 | 1047 | else return false; |
@@ -229,8 +229,7 @@ discard block |
||
229 | 229 | if($extrafields->attribute_type[$key] == 'price') |
230 | 230 | { |
231 | 231 | $object->array_options['options_'.$key] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); |
232 | - } |
|
233 | - else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
232 | + } else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
234 | 233 | { |
235 | 234 | $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
236 | 235 | } |
@@ -303,8 +302,7 @@ discard block |
||
303 | 302 | if ($extrafields->attribute_type[$key] == 'price') |
304 | 303 | { |
305 | 304 | $object->array_options['options_' . $key] = price($object->array_options ['options_' . $key], 0, $outputlangs, 0, 0, - 1, $conf->currency); |
306 | - } |
|
307 | - elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
305 | + } elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
308 | 306 | { |
309 | 307 | $object->array_options['options_' . $key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_' . $key]]; |
310 | 308 | } |
@@ -343,8 +341,11 @@ discard block |
||
343 | 341 | |
344 | 342 | foreach($conf->global as $key => $val) |
345 | 343 | { |
346 | - if (preg_match('/(_pass|password|secret|_key|key$)/i', $key)) $newval = '*****forbidden*****'; |
|
347 | - else $newval = $val; |
|
344 | + if (preg_match('/(_pass|password|secret|_key|key$)/i', $key)) { |
|
345 | + $newval = '*****forbidden*****'; |
|
346 | + } else { |
|
347 | + $newval = $val; |
|
348 | + } |
|
348 | 349 | $array_other['__['.$key.']__'] = $newval; |
349 | 350 | } |
350 | 351 | |
@@ -475,12 +476,16 @@ discard block |
||
475 | 476 | foreach ($object->lines as $line) |
476 | 477 | { |
477 | 478 | // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility |
478 | - if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
479 | + if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) { |
|
480 | + $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
481 | + } |
|
479 | 482 | $resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
480 | 483 | $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); |
481 | 484 | // $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example) |
482 | 485 | $vatformated=vatrate($line->tva_tx); |
483 | - if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0; |
|
486 | + if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) { |
|
487 | + $resarray[$array_key.'_total_vat_'.$vatformated]=0; |
|
488 | + } |
|
484 | 489 | $resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva; |
485 | 490 | $resarray[$array_key.'_total_vat_locale_'.$vatformated]=price($resarray[$array_key.'_total_vat_'.$vatformated]); |
486 | 491 | } |
@@ -572,8 +577,9 @@ discard block |
||
572 | 577 | { |
573 | 578 | $tmpproduct = new Product($this->db); |
574 | 579 | $result = $tmpproduct->fetch($line->fk_product); |
575 | - foreach($tmpproduct->array_options as $key=>$label) |
|
576 | - $resarray["line_product_".$key] = $label; |
|
580 | + foreach($tmpproduct->array_options as $key=>$label) { |
|
581 | + $resarray["line_product_".$key] = $label; |
|
582 | + } |
|
577 | 583 | } |
578 | 584 | |
579 | 585 | return $resarray; |
@@ -623,7 +629,9 @@ discard block |
||
623 | 629 | // Add vat by rates |
624 | 630 | foreach ($object->lines as $line) |
625 | 631 | { |
626 | - if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
632 | + if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) { |
|
633 | + $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
634 | + } |
|
627 | 635 | $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
628 | 636 | } |
629 | 637 | |
@@ -742,12 +750,10 @@ discard block |
||
742 | 750 | $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); |
743 | 751 | //Add value to store price with currency |
744 | 752 | $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); |
745 | - } |
|
746 | - else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
753 | + } else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
747 | 754 | { |
748 | 755 | $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
749 | - } |
|
750 | - else if($extrafields->attribute_type[$key] == 'date') |
|
756 | + } else if($extrafields->attribute_type[$key] == 'date') |
|
751 | 757 | { |
752 | 758 | if (strlen($object->array_options['options_'.$key])>0) |
753 | 759 | { |
@@ -755,8 +761,7 @@ discard block |
||
755 | 761 | $object->array_options['options_'.$key] = dol_print_date($date,'day'); // using company output language |
756 | 762 | $object->array_options['options_'.$key.'_locale'] = dol_print_date($date,'day','tzserver',$outputlangs); // using output language format |
757 | 763 | $object->array_options['options_'.$key.'_rfc'] = dol_print_date($date,'dayrfc'); // international format |
758 | - } |
|
759 | - else |
|
764 | + } else |
|
760 | 765 | { |
761 | 766 | $object->array_options['options_'.$key] = ''; |
762 | 767 | $object->array_options['options_'.$key.'_locale'] = ''; |
@@ -764,8 +769,7 @@ discard block |
||
764 | 769 | } |
765 | 770 | $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); |
766 | 771 | $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); |
767 | - } |
|
768 | - else if($extrafields->attribute_type[$key] == 'datetime') |
|
772 | + } else if($extrafields->attribute_type[$key] == 'datetime') |
|
769 | 773 | { |
770 | 774 | $datetime = $object->array_options['options_'.$key]; |
771 | 775 | $object->array_options['options_'.$key] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhour'):''); // using company output language |
@@ -773,8 +777,7 @@ discard block |
||
773 | 777 | $object->array_options['options_'.$key.'_rfc'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhourrfc'):''); // international format |
774 | 778 | $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); |
775 | 779 | $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); |
776 | - } |
|
777 | - else if($extrafields->attribute_type[$key] == 'link') |
|
780 | + } else if($extrafields->attribute_type[$key] == 'link') |
|
778 | 781 | { |
779 | 782 | $id = $object->array_options['options_'.$key]; |
780 | 783 | if ($id != "") |
@@ -819,9 +822,13 @@ discard block |
||
819 | 822 | */ |
820 | 823 | function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
821 | 824 | { |
822 | - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
825 | + if (empty($hidetop) || $hidetop==-1) { |
|
826 | + $pdf->line($x, $y, $x+$l, $y); |
|
827 | + } |
|
823 | 828 | $pdf->line($x+$l, $y, $x+$l, $y+$h); |
824 | - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
829 | + if (empty($hidebottom)) { |
|
830 | + $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
831 | + } |
|
825 | 832 | $pdf->line($x, $y+$h, $x, $y); |
826 | 833 | } |
827 | 834 | |
@@ -874,7 +881,10 @@ discard block |
||
874 | 881 | $countFlexCol = 0; |
875 | 882 | foreach ($this->cols as $colKey =>& $colDef) |
876 | 883 | { |
877 | - if(!$this->getColumnStatus($colKey)) continue; // continue if desable |
|
884 | + if(!$this->getColumnStatus($colKey)) { |
|
885 | + continue; |
|
886 | + } |
|
887 | + // continue if desable |
|
878 | 888 | |
879 | 889 | if(!empty($colDef['scale'])){ |
880 | 890 | // In case of column widht is defined by percentage |
@@ -883,8 +893,7 @@ discard block |
||
883 | 893 | |
884 | 894 | if(empty($colDef['width'])){ |
885 | 895 | $countFlexCol++; |
886 | - } |
|
887 | - else{ |
|
896 | + } else{ |
|
888 | 897 | $totalDefinedColWidth += $colDef['width']; |
889 | 898 | } |
890 | 899 | } |
@@ -894,16 +903,14 @@ discard block |
||
894 | 903 | // setting empty conf with default |
895 | 904 | if(!empty($colDef['title'])){ |
896 | 905 | $colDef['title'] = array_replace($this->defaultTitlesFieldsStyle, $colDef['title']); |
897 | - } |
|
898 | - else{ |
|
906 | + } else{ |
|
899 | 907 | $colDef['title'] = $this->defaultTitlesFieldsStyle; |
900 | 908 | } |
901 | 909 | |
902 | 910 | // setting empty conf with default |
903 | 911 | if(!empty($colDef['content'])){ |
904 | 912 | $colDef['content'] = array_replace($this->defaultContentsFieldsStyle, $colDef['content']); |
905 | - } |
|
906 | - else{ |
|
913 | + } else{ |
|
907 | 914 | $colDef['content'] = $this->defaultContentsFieldsStyle; |
908 | 915 | } |
909 | 916 | |
@@ -956,7 +963,9 @@ discard block |
||
956 | 963 | */ |
957 | 964 | function getColumnRank($colKey) |
958 | 965 | { |
959 | - if(!isset($this->cols[$colKey]['rank'])) return -1; |
|
966 | + if(!isset($this->cols[$colKey]['rank'])) { |
|
967 | + return -1; |
|
968 | + } |
|
960 | 969 | return $this->cols[$colKey]['rank']; |
961 | 970 | } |
962 | 971 | |
@@ -1022,10 +1031,14 @@ discard block |
||
1022 | 1031 | 'colKey' => $colKey |
1023 | 1032 | ); |
1024 | 1033 | $reshook=$hookmanager->executeHooks('printStdColumnContent',$parameters,$this); // Note that $action and $object may have been modified by hook |
1025 | - if ($reshook < 0) setEventMessages($hookmanager->error,$hookmanager->errors,'errors'); |
|
1034 | + if ($reshook < 0) { |
|
1035 | + setEventMessages($hookmanager->error,$hookmanager->errors,'errors'); |
|
1036 | + } |
|
1026 | 1037 | if (!$reshook) |
1027 | 1038 | { |
1028 | - if(empty($columnText)) return; |
|
1039 | + if(empty($columnText)) { |
|
1040 | + return; |
|
1041 | + } |
|
1029 | 1042 | $pdf->SetXY($this->getColumnContentXStart($colKey),$curY); // Set curent position |
1030 | 1043 | $colDef = $this->cols[$colKey]; |
1031 | 1044 | $pdf->writeHTMLCell( $this->getColumnContentWidth($colKey),2,$this->getColumnContentXStart($colKey),$curY, $columnText,0,0,0,true,$colDef['content']['align']); |
@@ -1043,7 +1056,8 @@ discard block |
||
1043 | 1056 | { |
1044 | 1057 | if( !empty($this->cols[$colKey]['status'])){ |
1045 | 1058 | return true; |
1059 | + } else { |
|
1060 | + return false; |
|
1046 | 1061 | } |
1047 | - else return false; |
|
1048 | 1062 | } |
1049 | 1063 | } |
@@ -28,22 +28,22 @@ discard block |
||
28 | 28 | */ |
29 | 29 | class Canvas |
30 | 30 | { |
31 | - /** |
|
31 | + /** |
|
32 | 32 | * @var DoliDB Database handler. |
33 | 33 | */ |
34 | 34 | public $db; |
35 | 35 | |
36 | - /** |
|
37 | - * @var string Error code (or message) |
|
38 | - */ |
|
39 | - public $error=''; |
|
36 | + /** |
|
37 | + * @var string Error code (or message) |
|
38 | + */ |
|
39 | + public $error=''; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var string[] Error codes (or messages) |
|
43 | - */ |
|
44 | - public $errors = array(); |
|
41 | + /** |
|
42 | + * @var string[] Error codes (or messages) |
|
43 | + */ |
|
44 | + public $errors = array(); |
|
45 | 45 | |
46 | - public $actiontype; |
|
46 | + public $actiontype; |
|
47 | 47 | |
48 | 48 | public $dirmodule; // Module directory |
49 | 49 | public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) |
@@ -54,65 +54,65 @@ discard block |
||
54 | 54 | public $control; // Initialized by getCanvas with controller instance |
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * Constructor |
|
59 | - * |
|
60 | - * @param DoliDB $db Database handler |
|
61 | - * @param string $actiontype Action type ('create', 'view', 'edit', 'list') |
|
62 | - */ |
|
63 | - function __construct($db, $actiontype='view') |
|
64 | - { |
|
65 | - $this->db = $db; |
|
66 | - |
|
67 | - $this->actiontype = $this->_cleanaction($actiontype); |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Return action code cleaned |
|
72 | - * |
|
73 | - * @param string $action Action type ('create', 'view', 'edit', 'list', 'add', 'update') |
|
74 | - * @return string Cleaned action type ('create', 'view', 'edit', 'list') |
|
75 | - */ |
|
76 | - private function _cleanaction($action) |
|
77 | - { |
|
78 | - $newaction = $action; |
|
79 | - if ($newaction == 'add') $newaction='create'; |
|
80 | - if ($newaction == 'update') $newaction='edit'; |
|
81 | - if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction='view'; |
|
82 | - return $newaction; |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * Initialize properties: ->targetmodule, ->canvas, ->card, ->dirmodule, ->template_dir |
|
88 | - * |
|
89 | - * @param string $module Name of target module (thirdparty, contact, ...) |
|
90 | - * @param string $card Tab name of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page |
|
91 | - * @param string $canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) |
|
92 | - * @return void |
|
93 | - */ |
|
94 | - function getCanvas($module, $card, $canvas) |
|
95 | - { |
|
96 | - global $conf, $langs; |
|
97 | - |
|
98 | - // Set properties with value specific to dolibarr core: this->targetmodule, this->card, this->canvas |
|
57 | + /** |
|
58 | + * Constructor |
|
59 | + * |
|
60 | + * @param DoliDB $db Database handler |
|
61 | + * @param string $actiontype Action type ('create', 'view', 'edit', 'list') |
|
62 | + */ |
|
63 | + function __construct($db, $actiontype='view') |
|
64 | + { |
|
65 | + $this->db = $db; |
|
66 | + |
|
67 | + $this->actiontype = $this->_cleanaction($actiontype); |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Return action code cleaned |
|
72 | + * |
|
73 | + * @param string $action Action type ('create', 'view', 'edit', 'list', 'add', 'update') |
|
74 | + * @return string Cleaned action type ('create', 'view', 'edit', 'list') |
|
75 | + */ |
|
76 | + private function _cleanaction($action) |
|
77 | + { |
|
78 | + $newaction = $action; |
|
79 | + if ($newaction == 'add') $newaction='create'; |
|
80 | + if ($newaction == 'update') $newaction='edit'; |
|
81 | + if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction='view'; |
|
82 | + return $newaction; |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * Initialize properties: ->targetmodule, ->canvas, ->card, ->dirmodule, ->template_dir |
|
88 | + * |
|
89 | + * @param string $module Name of target module (thirdparty, contact, ...) |
|
90 | + * @param string $card Tab name of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page |
|
91 | + * @param string $canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) |
|
92 | + * @return void |
|
93 | + */ |
|
94 | + function getCanvas($module, $card, $canvas) |
|
95 | + { |
|
96 | + global $conf, $langs; |
|
97 | + |
|
98 | + // Set properties with value specific to dolibarr core: this->targetmodule, this->card, this->canvas |
|
99 | 99 | $this->targetmodule = $module; |
100 | 100 | $this->canvas = $canvas; |
101 | 101 | $this->card = $card; |
102 | 102 | $this->dirmodule = $module; |
103 | 103 | // Correct values if canvas is into an external module |
104 | - if (preg_match('/^([^@]+)@([^@]+)$/i',$canvas,$regs)) |
|
105 | - { |
|
104 | + if (preg_match('/^([^@]+)@([^@]+)$/i',$canvas,$regs)) |
|
105 | + { |
|
106 | 106 | $this->canvas = $regs[1]; |
107 | - $this->dirmodule = $regs[2]; |
|
108 | - } |
|
109 | - // For compatibility |
|
107 | + $this->dirmodule = $regs[2]; |
|
108 | + } |
|
109 | + // For compatibility |
|
110 | 110 | if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; } |
111 | 111 | |
112 | 112 | // Control file |
113 | - $controlclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php'); |
|
114 | - if (file_exists($controlclassfile)) |
|
115 | - { |
|
113 | + $controlclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php'); |
|
114 | + if (file_exists($controlclassfile)) |
|
115 | + { |
|
116 | 116 | // Include actions class (controller) |
117 | 117 | $this->control_file=$controlclassfile; |
118 | 118 | require_once $controlclassfile; |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | // Instantiate actions class (controller) |
121 | 121 | $controlclassname = 'Actions'.ucfirst($this->card).ucfirst($this->canvas); |
122 | 122 | $this->control = new $controlclassname($this->db, $this->dirmodule, $this->targetmodule, $this->canvas, $this->card); |
123 | - } |
|
123 | + } |
|
124 | 124 | |
125 | - // Template dir |
|
126 | - $this->template_dir = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/tpl/'); |
|
125 | + // Template dir |
|
126 | + $this->template_dir = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/tpl/'); |
|
127 | 127 | if (! is_dir($this->template_dir)) |
128 | 128 | { |
129 | 129 | $this->template_dir=''; |
@@ -131,27 +131,27 @@ discard block |
||
131 | 131 | |
132 | 132 | //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'<br>'; |
133 | 133 | //print ' => template_dir='.$this->template_dir.'<br>'; |
134 | - } |
|
134 | + } |
|
135 | 135 | |
136 | 136 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
137 | 137 | /** |
138 | - * Shared method for canvas to assign values for templates |
|
139 | - * |
|
140 | - * @param string $action Action string |
|
141 | - * @param int $id Object id (if ref not provided) |
|
142 | - * @param string $ref Object ref (if id not provided) |
|
143 | - * @return void |
|
144 | - */ |
|
145 | - function assign_values(&$action='view', $id=0, $ref='') |
|
146 | - { |
|
138 | + * Shared method for canvas to assign values for templates |
|
139 | + * |
|
140 | + * @param string $action Action string |
|
141 | + * @param int $id Object id (if ref not provided) |
|
142 | + * @param string $ref Object ref (if id not provided) |
|
143 | + * @return void |
|
144 | + */ |
|
145 | + function assign_values(&$action='view', $id=0, $ref='') |
|
146 | + { |
|
147 | 147 | // phpcs:enable |
148 | - if (method_exists($this->control,'assign_values')) $this->control->assign_values($action, $id, $ref); |
|
149 | - } |
|
148 | + if (method_exists($this->control,'assign_values')) $this->control->assign_values($action, $id, $ref); |
|
149 | + } |
|
150 | 150 | |
151 | 151 | /** |
152 | 152 | * Return the template to display canvas (if it exists) |
153 | - * |
|
154 | - * @param string $action Action code |
|
153 | + * |
|
154 | + * @param string $action Action code |
|
155 | 155 | * @return int 0=Canvas template file does not exist, 1=Canvas template file exists |
156 | 156 | */ |
157 | 157 | function displayCanvasExists($action) |
@@ -163,53 +163,53 @@ discard block |
||
163 | 163 | } |
164 | 164 | |
165 | 165 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
166 | - /** |
|
167 | - * Display a canvas page. This will include the template for output. |
|
168 | - * Variables used by templates may have been defined or loaded before into the assign_values function. |
|
169 | - * |
|
170 | - * @param string $action Action code |
|
171 | - * @return void |
|
172 | - */ |
|
173 | - function display_canvas($action) |
|
174 | - { |
|
166 | + /** |
|
167 | + * Display a canvas page. This will include the template for output. |
|
168 | + * Variables used by templates may have been defined or loaded before into the assign_values function. |
|
169 | + * |
|
170 | + * @param string $action Action code |
|
171 | + * @return void |
|
172 | + */ |
|
173 | + function display_canvas($action) |
|
174 | + { |
|
175 | 175 | // phpcs:enable |
176 | - global $db, $conf, $langs, $user, $canvas; |
|
177 | - global $form, $formfile; |
|
176 | + global $db, $conf, $langs, $user, $canvas; |
|
177 | + global $form, $formfile; |
|
178 | 178 | |
179 | - include $this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template |
|
180 | - } |
|
179 | + include $this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template |
|
180 | + } |
|
181 | 181 | |
182 | 182 | |
183 | - // This functions should not be used anymore because canvas should contains only templates. |
|
184 | - // http://wiki.dolibarr.org/index.php/Canvas_development |
|
183 | + // This functions should not be used anymore because canvas should contains only templates. |
|
184 | + // http://wiki.dolibarr.org/index.php/Canvas_development |
|
185 | 185 | |
186 | - /** |
|
187 | - * Return if a canvas contains an action controller |
|
188 | - * |
|
189 | - * @return boolean Return if canvas contains actions (old feature. now actions should be inside hooks) |
|
190 | - */ |
|
191 | - function hasActions() |
|
192 | - { |
|
186 | + /** |
|
187 | + * Return if a canvas contains an action controller |
|
188 | + * |
|
189 | + * @return boolean Return if canvas contains actions (old feature. now actions should be inside hooks) |
|
190 | + */ |
|
191 | + function hasActions() |
|
192 | + { |
|
193 | 193 | return (is_object($this->control)); |
194 | - } |
|
194 | + } |
|
195 | 195 | |
196 | - /** |
|
197 | - * Shared method for canvas to execute actions. |
|
196 | + /** |
|
197 | + * Shared method for canvas to execute actions. |
|
198 | 198 | * @deprecated Use the doActions of hooks instead of this. |
199 | - * This function is called if you add a doActions class inside your canvas. Try to not |
|
200 | - * do that and add action code into a hook instead. |
|
201 | - * |
|
202 | - * @param string $action Action string |
|
203 | - * @param int $id Object id |
|
204 | - * @return mixed Return return code of doActions of canvas |
|
205 | - * @see http://wiki.dolibarr.org/index.php/Canvas_development |
|
206 | - */ |
|
207 | - function doActions(&$action='view', $id=0) |
|
208 | - { |
|
209 | - if (method_exists($this->control,'doActions')) |
|
210 | - { |
|
211 | - $ret = $this->control->doActions($action, $id); |
|
212 | - return $ret; |
|
213 | - } |
|
214 | - } |
|
199 | + * This function is called if you add a doActions class inside your canvas. Try to not |
|
200 | + * do that and add action code into a hook instead. |
|
201 | + * |
|
202 | + * @param string $action Action string |
|
203 | + * @param int $id Object id |
|
204 | + * @return mixed Return return code of doActions of canvas |
|
205 | + * @see http://wiki.dolibarr.org/index.php/Canvas_development |
|
206 | + */ |
|
207 | + function doActions(&$action='view', $id=0) |
|
208 | + { |
|
209 | + if (method_exists($this->control,'doActions')) |
|
210 | + { |
|
211 | + $ret = $this->control->doActions($action, $id); |
|
212 | + return $ret; |
|
213 | + } |
|
214 | + } |
|
215 | 215 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | /** |
37 | 37 | * @var string Error code (or message) |
38 | 38 | */ |
39 | - public $error=''; |
|
39 | + public $error = ''; |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @var string[] Error codes (or messages) |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | |
46 | 46 | public $actiontype; |
47 | 47 | |
48 | - public $dirmodule; // Module directory |
|
49 | - public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) |
|
50 | - public $canvas; // Name of canvas (ex: company, individual, product, service, ...) |
|
51 | - public $card; // Tab (sub-canvas) |
|
48 | + public $dirmodule; // Module directory |
|
49 | + public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) |
|
50 | + public $canvas; // Name of canvas (ex: company, individual, product, service, ...) |
|
51 | + public $card; // Tab (sub-canvas) |
|
52 | 52 | |
53 | - public $template_dir; // Initialized by getCanvas with templates directory |
|
54 | - public $control; // Initialized by getCanvas with controller instance |
|
53 | + public $template_dir; // Initialized by getCanvas with templates directory |
|
54 | + public $control; // Initialized by getCanvas with controller instance |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param DoliDB $db Database handler |
61 | 61 | * @param string $actiontype Action type ('create', 'view', 'edit', 'list') |
62 | 62 | */ |
63 | - function __construct($db, $actiontype='view') |
|
63 | + function __construct($db, $actiontype = 'view') |
|
64 | 64 | { |
65 | 65 | $this->db = $db; |
66 | 66 | |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | private function _cleanaction($action) |
77 | 77 | { |
78 | 78 | $newaction = $action; |
79 | - if ($newaction == 'add') $newaction='create'; |
|
80 | - if ($newaction == 'update') $newaction='edit'; |
|
81 | - if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction='view'; |
|
79 | + if ($newaction == 'add') $newaction = 'create'; |
|
80 | + if ($newaction == 'update') $newaction = 'edit'; |
|
81 | + if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction = 'view'; |
|
82 | 82 | return $newaction; |
83 | 83 | } |
84 | 84 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $this->card = $card; |
102 | 102 | $this->dirmodule = $module; |
103 | 103 | // Correct values if canvas is into an external module |
104 | - if (preg_match('/^([^@]+)@([^@]+)$/i',$canvas,$regs)) |
|
104 | + if (preg_match('/^([^@]+)@([^@]+)$/i', $canvas, $regs)) |
|
105 | 105 | { |
106 | 106 | $this->canvas = $regs[1]; |
107 | 107 | $this->dirmodule = $regs[2]; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | if (file_exists($controlclassfile)) |
115 | 115 | { |
116 | 116 | // Include actions class (controller) |
117 | - $this->control_file=$controlclassfile; |
|
117 | + $this->control_file = $controlclassfile; |
|
118 | 118 | require_once $controlclassfile; |
119 | 119 | |
120 | 120 | // Instantiate actions class (controller) |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | |
125 | 125 | // Template dir |
126 | 126 | $this->template_dir = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/tpl/'); |
127 | - if (! is_dir($this->template_dir)) |
|
127 | + if (!is_dir($this->template_dir)) |
|
128 | 128 | { |
129 | - $this->template_dir=''; |
|
129 | + $this->template_dir = ''; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'<br>'; |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | * @param string $ref Object ref (if id not provided) |
143 | 143 | * @return void |
144 | 144 | */ |
145 | - function assign_values(&$action='view', $id=0, $ref='') |
|
145 | + function assign_values(&$action = 'view', $id = 0, $ref = '') |
|
146 | 146 | { |
147 | 147 | // phpcs:enable |
148 | - if (method_exists($this->control,'assign_values')) $this->control->assign_values($action, $id, $ref); |
|
148 | + if (method_exists($this->control, 'assign_values')) $this->control->assign_values($action, $id, $ref); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | { |
159 | 159 | if (empty($this->template_dir)) return 0; |
160 | 160 | |
161 | - if (file_exists($this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1; |
|
161 | + if (file_exists($this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php')) return 1; |
|
162 | 162 | else return 0; |
163 | 163 | } |
164 | 164 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | global $db, $conf, $langs, $user, $canvas; |
177 | 177 | global $form, $formfile; |
178 | 178 | |
179 | - include $this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template |
|
179 | + include $this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | * @return mixed Return return code of doActions of canvas |
205 | 205 | * @see http://wiki.dolibarr.org/index.php/Canvas_development |
206 | 206 | */ |
207 | - function doActions(&$action='view', $id=0) |
|
207 | + function doActions(&$action = 'view', $id = 0) |
|
208 | 208 | { |
209 | - if (method_exists($this->control,'doActions')) |
|
209 | + if (method_exists($this->control, 'doActions')) |
|
210 | 210 | { |
211 | 211 | $ret = $this->control->doActions($action, $id); |
212 | 212 | return $ret; |
@@ -76,9 +76,15 @@ discard block |
||
76 | 76 | private function _cleanaction($action) |
77 | 77 | { |
78 | 78 | $newaction = $action; |
79 | - if ($newaction == 'add') $newaction='create'; |
|
80 | - if ($newaction == 'update') $newaction='edit'; |
|
81 | - if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction='view'; |
|
79 | + if ($newaction == 'add') { |
|
80 | + $newaction='create'; |
|
81 | + } |
|
82 | + if ($newaction == 'update') { |
|
83 | + $newaction='edit'; |
|
84 | + } |
|
85 | + if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') { |
|
86 | + $newaction='view'; |
|
87 | + } |
|
82 | 88 | return $newaction; |
83 | 89 | } |
84 | 90 | |
@@ -145,7 +151,9 @@ discard block |
||
145 | 151 | function assign_values(&$action='view', $id=0, $ref='') |
146 | 152 | { |
147 | 153 | // phpcs:enable |
148 | - if (method_exists($this->control,'assign_values')) $this->control->assign_values($action, $id, $ref); |
|
154 | + if (method_exists($this->control,'assign_values')) { |
|
155 | + $this->control->assign_values($action, $id, $ref); |
|
156 | + } |
|
149 | 157 | } |
150 | 158 | |
151 | 159 | /** |
@@ -156,10 +164,15 @@ discard block |
||
156 | 164 | */ |
157 | 165 | function displayCanvasExists($action) |
158 | 166 | { |
159 | - if (empty($this->template_dir)) return 0; |
|
167 | + if (empty($this->template_dir)) { |
|
168 | + return 0; |
|
169 | + } |
|
160 | 170 | |
161 | - if (file_exists($this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1; |
|
162 | - else return 0; |
|
171 | + if (file_exists($this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) { |
|
172 | + return 1; |
|
173 | + } else { |
|
174 | + return 0; |
|
175 | + } |
|
163 | 176 | } |
164 | 177 | |
165 | 178 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -27,55 +27,55 @@ discard block |
||
27 | 27 | |
28 | 28 | class CoreObject extends CommonObject |
29 | 29 | { |
30 | - public $withChild = true; |
|
30 | + public $withChild = true; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @var Array $_fields Fields to synchronize with Database |
|
34 | - */ |
|
35 | - protected $fields=array(); |
|
32 | + /** |
|
33 | + * @var Array $_fields Fields to synchronize with Database |
|
34 | + */ |
|
35 | + protected $fields=array(); |
|
36 | 36 | |
37 | 37 | /** |
38 | - * Constructor |
|
39 | - * |
|
40 | - * @param DoliDB $db Database handler |
|
41 | - */ |
|
42 | - function __construct(DoliDB &$db) |
|
38 | + * Constructor |
|
39 | + * |
|
40 | + * @param DoliDB $db Database handler |
|
41 | + */ |
|
42 | + function __construct(DoliDB &$db) |
|
43 | 43 | { |
44 | 44 | $this->db = $db; |
45 | - } |
|
45 | + } |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Function to init fields |
49 | 49 | * |
50 | 50 | * @return bool |
51 | 51 | */ |
52 | - protected function init() |
|
52 | + protected function init() |
|
53 | 53 | { |
54 | - $this->id = 0; |
|
55 | - $this->datec = 0; |
|
56 | - $this->tms = 0; |
|
57 | - |
|
58 | - if (!empty($this->fields)) |
|
59 | - { |
|
60 | - foreach ($this->fields as $field=>$info) |
|
61 | - { |
|
62 | - if ($this->isDate($info)) $this->{$field} = time(); |
|
63 | - elseif ($this->isArray($info)) $this->{$field} = array(); |
|
64 | - elseif ($this->isInt($info)) $this->{$field} = (int) 0; |
|
65 | - elseif ($this->isFloat($info)) $this->{$field} = (double) 0; |
|
66 | - else $this->{$field} = ''; |
|
67 | - } |
|
54 | + $this->id = 0; |
|
55 | + $this->datec = 0; |
|
56 | + $this->tms = 0; |
|
57 | + |
|
58 | + if (!empty($this->fields)) |
|
59 | + { |
|
60 | + foreach ($this->fields as $field=>$info) |
|
61 | + { |
|
62 | + if ($this->isDate($info)) $this->{$field} = time(); |
|
63 | + elseif ($this->isArray($info)) $this->{$field} = array(); |
|
64 | + elseif ($this->isInt($info)) $this->{$field} = (int) 0; |
|
65 | + elseif ($this->isFloat($info)) $this->{$field} = (double) 0; |
|
66 | + else $this->{$field} = ''; |
|
67 | + } |
|
68 | 68 | |
69 | 69 | $this->to_delete=false; |
70 | 70 | $this->is_clone=false; |
71 | 71 | |
72 | - return true; |
|
73 | - } |
|
74 | - else |
|
72 | + return true; |
|
73 | + } |
|
74 | + else |
|
75 | 75 | { |
76 | - return false; |
|
77 | - } |
|
78 | - } |
|
76 | + return false; |
|
77 | + } |
|
78 | + } |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Test type of field |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | */ |
87 | 87 | private function checkFieldType($field, $type) |
88 | 88 | { |
89 | - if (isset($this->fields[$field]) && method_exists($this, 'is_'.$type)) |
|
90 | - { |
|
91 | - return $this->{'is_'.$type}($this->fields[$field]); |
|
92 | - } |
|
93 | - else |
|
89 | + if (isset($this->fields[$field]) && method_exists($this, 'is_'.$type)) |
|
90 | + { |
|
91 | + return $this->{'is_'.$type}($this->fields[$field]); |
|
92 | + } |
|
93 | + else |
|
94 | 94 | { |
95 | 95 | return false; |
96 | 96 | } |
97 | - } |
|
97 | + } |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Get object and children from database |
@@ -103,15 +103,15 @@ discard block |
||
103 | 103 | * @param bool $loadChild used to load children from database |
104 | 104 | * @return int >0 if OK, <0 if KO, 0 if not found |
105 | 105 | */ |
106 | - public function fetch($id, $loadChild = true) |
|
106 | + public function fetch($id, $loadChild = true) |
|
107 | 107 | { |
108 | - $res = $this->fetchCommon($id); |
|
109 | - if($res>0) { |
|
110 | - if ($loadChild) $this->fetchChild(); |
|
111 | - } |
|
108 | + $res = $this->fetchCommon($id); |
|
109 | + if($res>0) { |
|
110 | + if ($loadChild) $this->fetchChild(); |
|
111 | + } |
|
112 | 112 | |
113 | - return $res; |
|
114 | - } |
|
113 | + return $res; |
|
114 | + } |
|
115 | 115 | |
116 | 116 | |
117 | 117 | /** |
@@ -125,25 +125,25 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function addChild($tabName, $id=0, $key='id', $try_to_load = false) |
127 | 127 | { |
128 | - if(!empty($id)) |
|
129 | - { |
|
130 | - foreach($this->{$tabName} as $k=>&$object) |
|
131 | - { |
|
132 | - if($object->{$key} === $id) return $k; |
|
133 | - } |
|
134 | - } |
|
128 | + if(!empty($id)) |
|
129 | + { |
|
130 | + foreach($this->{$tabName} as $k=>&$object) |
|
131 | + { |
|
132 | + if($object->{$key} === $id) return $k; |
|
133 | + } |
|
134 | + } |
|
135 | 135 | |
136 | - $k = count($this->{$tabName}); |
|
136 | + $k = count($this->{$tabName}); |
|
137 | 137 | |
138 | - $className = ucfirst($tabName); |
|
139 | - $this->{$tabName}[$k] = new $className($this->db); |
|
140 | - if($id>0 && $key==='id' && $try_to_load) |
|
141 | - { |
|
142 | - $this->{$tabName}[$k]->fetch($id); |
|
143 | - } |
|
138 | + $className = ucfirst($tabName); |
|
139 | + $this->{$tabName}[$k] = new $className($this->db); |
|
140 | + if($id>0 && $key==='id' && $try_to_load) |
|
141 | + { |
|
142 | + $this->{$tabName}[$k]->fetch($id); |
|
143 | + } |
|
144 | 144 | |
145 | - return $k; |
|
146 | - } |
|
145 | + return $k; |
|
146 | + } |
|
147 | 147 | |
148 | 148 | |
149 | 149 | /** |
@@ -156,16 +156,16 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function removeChild($tabName, $id, $key='id') |
158 | 158 | { |
159 | - foreach ($this->{$tabName} as &$object) |
|
160 | - { |
|
161 | - if ($object->{$key} == $id) |
|
162 | - { |
|
163 | - $object->to_delete = true; |
|
164 | - return true; |
|
165 | - } |
|
166 | - } |
|
167 | - return false; |
|
168 | - } |
|
159 | + foreach ($this->{$tabName} as &$object) |
|
160 | + { |
|
161 | + if ($object->{$key} == $id) |
|
162 | + { |
|
163 | + $object->to_delete = true; |
|
164 | + return true; |
|
165 | + } |
|
166 | + } |
|
167 | + return false; |
|
168 | + } |
|
169 | 169 | |
170 | 170 | |
171 | 171 | /** |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function fetchChild() |
177 | 177 | { |
178 | - if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) |
|
179 | - { |
|
180 | - foreach($this->childtables as &$childTable) |
|
181 | - { |
|
178 | + if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) |
|
179 | + { |
|
180 | + foreach($this->childtables as &$childTable) |
|
181 | + { |
|
182 | 182 | $className = ucfirst($childTable); |
183 | 183 | |
184 | 184 | $this->{$className}=array(); |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | { |
201 | 201 | $this->errors[] = $this->db->lasterror(); |
202 | 202 | } |
203 | - } |
|
204 | - } |
|
205 | - } |
|
203 | + } |
|
204 | + } |
|
205 | + } |
|
206 | 206 | |
207 | 207 | /** |
208 | 208 | * Function to update children data |
@@ -210,26 +210,26 @@ discard block |
||
210 | 210 | * @param User $user user object |
211 | 211 | * @return void |
212 | 212 | */ |
213 | - public function saveChild(User &$user) |
|
213 | + public function saveChild(User &$user) |
|
214 | 214 | { |
215 | - if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) |
|
216 | - { |
|
217 | - foreach($this->childtables as &$childTable) |
|
218 | - { |
|
219 | - $className = ucfirst($childTable); |
|
220 | - if(!empty($this->{$className})) |
|
221 | - { |
|
222 | - foreach($this->{$className} as $i => &$object) |
|
223 | - { |
|
224 | - $object->{$this->fk_element} = $this->id; |
|
225 | - |
|
226 | - $object->update($user); |
|
227 | - if($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete==true) unset($this->{$className}[$i]); |
|
228 | - } |
|
229 | - } |
|
230 | - } |
|
231 | - } |
|
232 | - } |
|
215 | + if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) |
|
216 | + { |
|
217 | + foreach($this->childtables as &$childTable) |
|
218 | + { |
|
219 | + $className = ucfirst($childTable); |
|
220 | + if(!empty($this->{$className})) |
|
221 | + { |
|
222 | + foreach($this->{$className} as $i => &$object) |
|
223 | + { |
|
224 | + $object->{$this->fk_element} = $this->id; |
|
225 | + |
|
226 | + $object->update($user); |
|
227 | + if($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete==true) unset($this->{$className}[$i]); |
|
228 | + } |
|
229 | + } |
|
230 | + } |
|
231 | + } |
|
232 | + } |
|
233 | 233 | |
234 | 234 | |
235 | 235 | /** |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function update(User &$user) |
242 | 242 | { |
243 | - if (empty($this->id)) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed |
|
243 | + if (empty($this->id)) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed |
|
244 | 244 | elseif (isset($this->to_delete) && $this->to_delete==true) return $this->delete($user); |
245 | 245 | |
246 | 246 | $error = 0; |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | $this->db->rollback(); |
271 | 271 | return -1; |
272 | 272 | } |
273 | - } |
|
273 | + } |
|
274 | 274 | |
275 | 275 | /** |
276 | 276 | * Function to create object in database |
@@ -280,26 +280,26 @@ discard block |
||
280 | 280 | */ |
281 | 281 | public function create(User &$user) |
282 | 282 | { |
283 | - if($this->id > 0) return $this->update($user); |
|
283 | + if($this->id > 0) return $this->update($user); |
|
284 | 284 | |
285 | 285 | $error = 0; |
286 | 286 | $this->db->begin(); |
287 | 287 | |
288 | 288 | $res = $this->createCommon($user); |
289 | - if($res) |
|
290 | - { |
|
291 | - $this->id = $this->db->last_insert_id($this->table_element); |
|
289 | + if($res) |
|
290 | + { |
|
291 | + $this->id = $this->db->last_insert_id($this->table_element); |
|
292 | 292 | |
293 | - $result = $this->call_trigger(strtoupper($this->element). '_CREATE', $user); |
|
293 | + $result = $this->call_trigger(strtoupper($this->element). '_CREATE', $user); |
|
294 | 294 | if ($result < 0) $error++; |
295 | 295 | else $this->saveChild($user); |
296 | - } |
|
297 | - else |
|
296 | + } |
|
297 | + else |
|
298 | 298 | { |
299 | 299 | $error++; |
300 | 300 | $this->error = $this->db->lasterror(); |
301 | 301 | $this->errors[] = $this->error; |
302 | - } |
|
302 | + } |
|
303 | 303 | |
304 | 304 | if (empty($error)) |
305 | 305 | { |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | $this->db->rollback(); |
312 | 312 | return -1; |
313 | 313 | } |
314 | - } |
|
314 | + } |
|
315 | 315 | |
316 | 316 | /** |
317 | 317 | * Function to delete object in database |
@@ -319,9 +319,9 @@ discard block |
||
319 | 319 | * @param User $user user object |
320 | 320 | * @return < 0 if ko, > 0 if ok |
321 | 321 | */ |
322 | - public function delete(User &$user) |
|
322 | + public function delete(User &$user) |
|
323 | 323 | { |
324 | - if ($this->id <= 0) return 0; |
|
324 | + if ($this->id <= 0) return 0; |
|
325 | 325 | |
326 | 326 | $error = 0; |
327 | 327 | $this->db->begin(); |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | $this->db->rollback(); |
361 | 361 | return -1; |
362 | 362 | } |
363 | - } |
|
363 | + } |
|
364 | 364 | |
365 | 365 | |
366 | 366 | /** |
@@ -372,12 +372,12 @@ discard block |
||
372 | 372 | */ |
373 | 373 | public function getDate($field, $format='') |
374 | 374 | { |
375 | - if(empty($this->{$field})) return ''; |
|
376 | - else |
|
375 | + if(empty($this->{$field})) return ''; |
|
376 | + else |
|
377 | 377 | { |
378 | - return dol_print_date($this->{$field}, $format); |
|
379 | - } |
|
380 | - } |
|
378 | + return dol_print_date($this->{$field}, $format); |
|
379 | + } |
|
380 | + } |
|
381 | 381 | |
382 | 382 | /** |
383 | 383 | * Function to set date in field |
@@ -388,18 +388,18 @@ discard block |
||
388 | 388 | */ |
389 | 389 | public function setDate($field, $date) |
390 | 390 | { |
391 | - if (empty($date)) |
|
392 | - { |
|
393 | - $this->{$field} = 0; |
|
394 | - } |
|
395 | - else |
|
391 | + if (empty($date)) |
|
392 | + { |
|
393 | + $this->{$field} = 0; |
|
394 | + } |
|
395 | + else |
|
396 | 396 | { |
397 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
|
398 | - $this->{$field} = dol_stringtotime($date); |
|
399 | - } |
|
397 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
|
398 | + $this->{$field} = dol_stringtotime($date); |
|
399 | + } |
|
400 | 400 | |
401 | - return $this->{$field}; |
|
402 | - } |
|
401 | + return $this->{$field}; |
|
402 | + } |
|
403 | 403 | |
404 | 404 | |
405 | 405 | /** |
@@ -410,29 +410,29 @@ discard block |
||
410 | 410 | */ |
411 | 411 | public function setValues(&$Tab) |
412 | 412 | { |
413 | - foreach ($Tab as $key => $value) |
|
414 | - { |
|
415 | - if($this->checkFieldType($key, 'date')) |
|
416 | - { |
|
417 | - $this->setDate($key, $value); |
|
418 | - } |
|
419 | - else if( $this->checkFieldType($key, 'array')) |
|
420 | - { |
|
421 | - $this->{$key} = $value; |
|
422 | - } |
|
423 | - else if( $this->checkFieldType($key, 'float') ) |
|
424 | - { |
|
425 | - $this->{$key} = (double) price2num($value); |
|
426 | - } |
|
427 | - else if( $this->checkFieldType($key, 'int') ) { |
|
428 | - $this->{$key} = (int) price2num($value); |
|
429 | - } |
|
430 | - else |
|
413 | + foreach ($Tab as $key => $value) |
|
414 | + { |
|
415 | + if($this->checkFieldType($key, 'date')) |
|
416 | + { |
|
417 | + $this->setDate($key, $value); |
|
418 | + } |
|
419 | + else if( $this->checkFieldType($key, 'array')) |
|
431 | 420 | { |
432 | - $this->{$key} = $value; |
|
433 | - } |
|
434 | - } |
|
421 | + $this->{$key} = $value; |
|
422 | + } |
|
423 | + else if( $this->checkFieldType($key, 'float') ) |
|
424 | + { |
|
425 | + $this->{$key} = (double) price2num($value); |
|
426 | + } |
|
427 | + else if( $this->checkFieldType($key, 'int') ) { |
|
428 | + $this->{$key} = (int) price2num($value); |
|
429 | + } |
|
430 | + else |
|
431 | + { |
|
432 | + $this->{$key} = $value; |
|
433 | + } |
|
434 | + } |
|
435 | 435 | |
436 | - return 1; |
|
437 | - } |
|
436 | + return 1; |
|
437 | + } |
|
438 | 438 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @var Array $_fields Fields to synchronize with Database |
34 | 34 | */ |
35 | - protected $fields=array(); |
|
35 | + protected $fields = array(); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Constructor |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | else $this->{$field} = ''; |
67 | 67 | } |
68 | 68 | |
69 | - $this->to_delete=false; |
|
70 | - $this->is_clone=false; |
|
69 | + $this->to_delete = false; |
|
70 | + $this->is_clone = false; |
|
71 | 71 | |
72 | 72 | return true; |
73 | 73 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | public function fetch($id, $loadChild = true) |
107 | 107 | { |
108 | 108 | $res = $this->fetchCommon($id); |
109 | - if($res>0) { |
|
109 | + if ($res > 0) { |
|
110 | 110 | if ($loadChild) $this->fetchChild(); |
111 | 111 | } |
112 | 112 | |
@@ -123,13 +123,13 @@ discard block |
||
123 | 123 | * @param bool $try_to_load Force the fetch if an id is given |
124 | 124 | * @return int |
125 | 125 | */ |
126 | - public function addChild($tabName, $id=0, $key='id', $try_to_load = false) |
|
126 | + public function addChild($tabName, $id = 0, $key = 'id', $try_to_load = false) |
|
127 | 127 | { |
128 | - if(!empty($id)) |
|
128 | + if (!empty($id)) |
|
129 | 129 | { |
130 | - foreach($this->{$tabName} as $k=>&$object) |
|
130 | + foreach ($this->{$tabName} as $k=>&$object) |
|
131 | 131 | { |
132 | - if($object->{$key} === $id) return $k; |
|
132 | + if ($object->{$key} === $id) return $k; |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | $className = ucfirst($tabName); |
139 | 139 | $this->{$tabName}[$k] = new $className($this->db); |
140 | - if($id>0 && $key==='id' && $try_to_load) |
|
140 | + if ($id > 0 && $key === 'id' && $try_to_load) |
|
141 | 141 | { |
142 | 142 | $this->{$tabName}[$k]->fetch($id); |
143 | 143 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @param string $key Attribute name of the object id |
155 | 155 | * @return bool |
156 | 156 | */ |
157 | - public function removeChild($tabName, $id, $key='id') |
|
157 | + public function removeChild($tabName, $id, $key = 'id') |
|
158 | 158 | { |
159 | 159 | foreach ($this->{$tabName} as &$object) |
160 | 160 | { |
@@ -175,22 +175,22 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function fetchChild() |
177 | 177 | { |
178 | - if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) |
|
178 | + if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) |
|
179 | 179 | { |
180 | - foreach($this->childtables as &$childTable) |
|
180 | + foreach ($this->childtables as &$childTable) |
|
181 | 181 | { |
182 | 182 | $className = ucfirst($childTable); |
183 | 183 | |
184 | - $this->{$className}=array(); |
|
184 | + $this->{$className} = array(); |
|
185 | 185 | |
186 | 186 | $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$childTable.' WHERE '.$this->fk_element.' = '.$this->id; |
187 | 187 | $res = $this->db->query($sql); |
188 | 188 | |
189 | - if($res) |
|
189 | + if ($res) |
|
190 | 190 | { |
191 | - while($obj = $this->db->fetch_object($res)) |
|
191 | + while ($obj = $this->db->fetch_object($res)) |
|
192 | 192 | { |
193 | - $o=new $className($this->db); |
|
193 | + $o = new $className($this->db); |
|
194 | 194 | $o->fetch($obj->rowid); |
195 | 195 | |
196 | 196 | $this->{$className}[] = $o; |
@@ -212,19 +212,19 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function saveChild(User &$user) |
214 | 214 | { |
215 | - if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) |
|
215 | + if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) |
|
216 | 216 | { |
217 | - foreach($this->childtables as &$childTable) |
|
217 | + foreach ($this->childtables as &$childTable) |
|
218 | 218 | { |
219 | 219 | $className = ucfirst($childTable); |
220 | - if(!empty($this->{$className})) |
|
220 | + if (!empty($this->{$className})) |
|
221 | 221 | { |
222 | - foreach($this->{$className} as $i => &$object) |
|
222 | + foreach ($this->{$className} as $i => &$object) |
|
223 | 223 | { |
224 | 224 | $object->{$this->fk_element} = $this->id; |
225 | 225 | |
226 | 226 | $object->update($user); |
227 | - if($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete==true) unset($this->{$className}[$i]); |
|
227 | + if ($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete == true) unset($this->{$className}[$i]); |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | public function update(User &$user) |
242 | 242 | { |
243 | 243 | if (empty($this->id)) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed |
244 | - elseif (isset($this->to_delete) && $this->to_delete==true) return $this->delete($user); |
|
244 | + elseif (isset($this->to_delete) && $this->to_delete == true) return $this->delete($user); |
|
245 | 245 | |
246 | 246 | $error = 0; |
247 | 247 | $this->db->begin(); |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $res = $this->updateCommon($user); |
250 | 250 | if ($res) |
251 | 251 | { |
252 | - $result = $this->call_trigger(strtoupper($this->element). '_UPDATE', $user); |
|
252 | + $result = $this->call_trigger(strtoupper($this->element).'_UPDATE', $user); |
|
253 | 253 | if ($result < 0) $error++; |
254 | 254 | else $this->saveChild($user); |
255 | 255 | } |
@@ -280,17 +280,17 @@ discard block |
||
280 | 280 | */ |
281 | 281 | public function create(User &$user) |
282 | 282 | { |
283 | - if($this->id > 0) return $this->update($user); |
|
283 | + if ($this->id > 0) return $this->update($user); |
|
284 | 284 | |
285 | 285 | $error = 0; |
286 | 286 | $this->db->begin(); |
287 | 287 | |
288 | 288 | $res = $this->createCommon($user); |
289 | - if($res) |
|
289 | + if ($res) |
|
290 | 290 | { |
291 | 291 | $this->id = $this->db->last_insert_id($this->table_element); |
292 | 292 | |
293 | - $result = $this->call_trigger(strtoupper($this->element). '_CREATE', $user); |
|
293 | + $result = $this->call_trigger(strtoupper($this->element).'_CREATE', $user); |
|
294 | 294 | if ($result < 0) $error++; |
295 | 295 | else $this->saveChild($user); |
296 | 296 | } |
@@ -326,20 +326,20 @@ discard block |
||
326 | 326 | $error = 0; |
327 | 327 | $this->db->begin(); |
328 | 328 | |
329 | - $result = $this->call_trigger(strtoupper($this->element). '_DELETE', $user); |
|
329 | + $result = $this->call_trigger(strtoupper($this->element).'_DELETE', $user); |
|
330 | 330 | if ($result < 0) $error++; |
331 | 331 | |
332 | 332 | if (!$error) |
333 | 333 | { |
334 | 334 | $this->deleteCommon($user); |
335 | - if($this->withChild && !empty($this->childtables)) |
|
335 | + if ($this->withChild && !empty($this->childtables)) |
|
336 | 336 | { |
337 | - foreach($this->childtables as &$childTable) |
|
337 | + foreach ($this->childtables as &$childTable) |
|
338 | 338 | { |
339 | 339 | $className = ucfirst($childTable); |
340 | 340 | if (!empty($this->{$className})) |
341 | 341 | { |
342 | - foreach($this->{$className} as &$object) |
|
342 | + foreach ($this->{$className} as &$object) |
|
343 | 343 | { |
344 | 344 | $object->delete($user); |
345 | 345 | } |
@@ -370,9 +370,9 @@ discard block |
||
370 | 370 | * @param string $format Output date format |
371 | 371 | * @return string |
372 | 372 | */ |
373 | - public function getDate($field, $format='') |
|
373 | + public function getDate($field, $format = '') |
|
374 | 374 | { |
375 | - if(empty($this->{$field})) return ''; |
|
375 | + if (empty($this->{$field})) return ''; |
|
376 | 376 | else |
377 | 377 | { |
378 | 378 | return dol_print_date($this->{$field}, $format); |
@@ -412,19 +412,19 @@ discard block |
||
412 | 412 | { |
413 | 413 | foreach ($Tab as $key => $value) |
414 | 414 | { |
415 | - if($this->checkFieldType($key, 'date')) |
|
415 | + if ($this->checkFieldType($key, 'date')) |
|
416 | 416 | { |
417 | 417 | $this->setDate($key, $value); |
418 | 418 | } |
419 | - else if( $this->checkFieldType($key, 'array')) |
|
419 | + else if ($this->checkFieldType($key, 'array')) |
|
420 | 420 | { |
421 | 421 | $this->{$key} = $value; |
422 | 422 | } |
423 | - else if( $this->checkFieldType($key, 'float') ) |
|
423 | + else if ($this->checkFieldType($key, 'float')) |
|
424 | 424 | { |
425 | 425 | $this->{$key} = (double) price2num($value); |
426 | 426 | } |
427 | - else if( $this->checkFieldType($key, 'int') ) { |
|
427 | + else if ($this->checkFieldType($key, 'int')) { |
|
428 | 428 | $this->{$key} = (int) price2num($value); |
429 | 429 | } |
430 | 430 | else |
@@ -59,19 +59,24 @@ discard block |
||
59 | 59 | { |
60 | 60 | foreach ($this->fields as $field=>$info) |
61 | 61 | { |
62 | - if ($this->isDate($info)) $this->{$field} = time(); |
|
63 | - elseif ($this->isArray($info)) $this->{$field} = array(); |
|
64 | - elseif ($this->isInt($info)) $this->{$field} = (int) 0; |
|
65 | - elseif ($this->isFloat($info)) $this->{$field} = (double) 0; |
|
66 | - else $this->{$field} = ''; |
|
62 | + if ($this->isDate($info)) { |
|
63 | + $this->{$field} = time(); |
|
64 | + } elseif ($this->isArray($info)) { |
|
65 | + $this->{$field} = array(); |
|
66 | + } elseif ($this->isInt($info)) { |
|
67 | + $this->{$field} = (int) 0; |
|
68 | + } elseif ($this->isFloat($info)) { |
|
69 | + $this->{$field} = (double) 0; |
|
70 | + } else { |
|
71 | + $this->{$field} = ''; |
|
72 | + } |
|
67 | 73 | } |
68 | 74 | |
69 | 75 | $this->to_delete=false; |
70 | 76 | $this->is_clone=false; |
71 | 77 | |
72 | 78 | return true; |
73 | - } |
|
74 | - else |
|
79 | + } else |
|
75 | 80 | { |
76 | 81 | return false; |
77 | 82 | } |
@@ -89,8 +94,7 @@ discard block |
||
89 | 94 | if (isset($this->fields[$field]) && method_exists($this, 'is_'.$type)) |
90 | 95 | { |
91 | 96 | return $this->{'is_'.$type}($this->fields[$field]); |
92 | - } |
|
93 | - else |
|
97 | + } else |
|
94 | 98 | { |
95 | 99 | return false; |
96 | 100 | } |
@@ -107,7 +111,9 @@ discard block |
||
107 | 111 | { |
108 | 112 | $res = $this->fetchCommon($id); |
109 | 113 | if($res>0) { |
110 | - if ($loadChild) $this->fetchChild(); |
|
114 | + if ($loadChild) { |
|
115 | + $this->fetchChild(); |
|
116 | + } |
|
111 | 117 | } |
112 | 118 | |
113 | 119 | return $res; |
@@ -129,7 +135,9 @@ discard block |
||
129 | 135 | { |
130 | 136 | foreach($this->{$tabName} as $k=>&$object) |
131 | 137 | { |
132 | - if($object->{$key} === $id) return $k; |
|
138 | + if($object->{$key} === $id) { |
|
139 | + return $k; |
|
140 | + } |
|
133 | 141 | } |
134 | 142 | } |
135 | 143 | |
@@ -195,8 +203,7 @@ discard block |
||
195 | 203 | |
196 | 204 | $this->{$className}[] = $o; |
197 | 205 | } |
198 | - } |
|
199 | - else |
|
206 | + } else |
|
200 | 207 | { |
201 | 208 | $this->errors[] = $this->db->lasterror(); |
202 | 209 | } |
@@ -224,7 +231,9 @@ discard block |
||
224 | 231 | $object->{$this->fk_element} = $this->id; |
225 | 232 | |
226 | 233 | $object->update($user); |
227 | - if($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete==true) unset($this->{$className}[$i]); |
|
234 | + if($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete==true) { |
|
235 | + unset($this->{$className}[$i]); |
|
236 | + } |
|
228 | 237 | } |
229 | 238 | } |
230 | 239 | } |
@@ -240,8 +249,13 @@ discard block |
||
240 | 249 | */ |
241 | 250 | public function update(User &$user) |
242 | 251 | { |
243 | - if (empty($this->id)) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed |
|
244 | - elseif (isset($this->to_delete) && $this->to_delete==true) return $this->delete($user); |
|
252 | + if (empty($this->id)) { |
|
253 | + return $this->create($user); |
|
254 | + } |
|
255 | + // To test, with that, no need to test on high level object, the core decide it, update just needed |
|
256 | + elseif (isset($this->to_delete) && $this->to_delete==true) { |
|
257 | + return $this->delete($user); |
|
258 | + } |
|
245 | 259 | |
246 | 260 | $error = 0; |
247 | 261 | $this->db->begin(); |
@@ -250,10 +264,12 @@ discard block |
||
250 | 264 | if ($res) |
251 | 265 | { |
252 | 266 | $result = $this->call_trigger(strtoupper($this->element). '_UPDATE', $user); |
253 | - if ($result < 0) $error++; |
|
254 | - else $this->saveChild($user); |
|
255 | - } |
|
256 | - else |
|
267 | + if ($result < 0) { |
|
268 | + $error++; |
|
269 | + } else { |
|
270 | + $this->saveChild($user); |
|
271 | + } |
|
272 | + } else |
|
257 | 273 | { |
258 | 274 | $error++; |
259 | 275 | $this->error = $this->db->lasterror(); |
@@ -264,8 +280,7 @@ discard block |
||
264 | 280 | { |
265 | 281 | $this->db->commit(); |
266 | 282 | return $this->id; |
267 | - } |
|
268 | - else |
|
283 | + } else |
|
269 | 284 | { |
270 | 285 | $this->db->rollback(); |
271 | 286 | return -1; |
@@ -280,7 +295,9 @@ discard block |
||
280 | 295 | */ |
281 | 296 | public function create(User &$user) |
282 | 297 | { |
283 | - if($this->id > 0) return $this->update($user); |
|
298 | + if($this->id > 0) { |
|
299 | + return $this->update($user); |
|
300 | + } |
|
284 | 301 | |
285 | 302 | $error = 0; |
286 | 303 | $this->db->begin(); |
@@ -291,10 +308,12 @@ discard block |
||
291 | 308 | $this->id = $this->db->last_insert_id($this->table_element); |
292 | 309 | |
293 | 310 | $result = $this->call_trigger(strtoupper($this->element). '_CREATE', $user); |
294 | - if ($result < 0) $error++; |
|
295 | - else $this->saveChild($user); |
|
296 | - } |
|
297 | - else |
|
311 | + if ($result < 0) { |
|
312 | + $error++; |
|
313 | + } else { |
|
314 | + $this->saveChild($user); |
|
315 | + } |
|
316 | + } else |
|
298 | 317 | { |
299 | 318 | $error++; |
300 | 319 | $this->error = $this->db->lasterror(); |
@@ -305,8 +324,7 @@ discard block |
||
305 | 324 | { |
306 | 325 | $this->db->commit(); |
307 | 326 | return $this->id; |
308 | - } |
|
309 | - else |
|
327 | + } else |
|
310 | 328 | { |
311 | 329 | $this->db->rollback(); |
312 | 330 | return -1; |
@@ -321,13 +339,17 @@ discard block |
||
321 | 339 | */ |
322 | 340 | public function delete(User &$user) |
323 | 341 | { |
324 | - if ($this->id <= 0) return 0; |
|
342 | + if ($this->id <= 0) { |
|
343 | + return 0; |
|
344 | + } |
|
325 | 345 | |
326 | 346 | $error = 0; |
327 | 347 | $this->db->begin(); |
328 | 348 | |
329 | 349 | $result = $this->call_trigger(strtoupper($this->element). '_DELETE', $user); |
330 | - if ($result < 0) $error++; |
|
350 | + if ($result < 0) { |
|
351 | + $error++; |
|
352 | + } |
|
331 | 353 | |
332 | 354 | if (!$error) |
333 | 355 | { |
@@ -352,8 +374,7 @@ discard block |
||
352 | 374 | { |
353 | 375 | $this->db->commit(); |
354 | 376 | return 1; |
355 | - } |
|
356 | - else |
|
377 | + } else |
|
357 | 378 | { |
358 | 379 | $this->error = $this->db->lasterror(); |
359 | 380 | $this->errors[] = $this->error; |
@@ -372,8 +393,9 @@ discard block |
||
372 | 393 | */ |
373 | 394 | public function getDate($field, $format='') |
374 | 395 | { |
375 | - if(empty($this->{$field})) return ''; |
|
376 | - else |
|
396 | + if(empty($this->{$field})) { |
|
397 | + return ''; |
|
398 | + } else |
|
377 | 399 | { |
378 | 400 | return dol_print_date($this->{$field}, $format); |
379 | 401 | } |
@@ -391,8 +413,7 @@ discard block |
||
391 | 413 | if (empty($date)) |
392 | 414 | { |
393 | 415 | $this->{$field} = 0; |
394 | - } |
|
395 | - else |
|
416 | + } else |
|
396 | 417 | { |
397 | 418 | require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
398 | 419 | $this->{$field} = dol_stringtotime($date); |
@@ -415,19 +436,15 @@ discard block |
||
415 | 436 | if($this->checkFieldType($key, 'date')) |
416 | 437 | { |
417 | 438 | $this->setDate($key, $value); |
418 | - } |
|
419 | - else if( $this->checkFieldType($key, 'array')) |
|
439 | + } else if( $this->checkFieldType($key, 'array')) |
|
420 | 440 | { |
421 | 441 | $this->{$key} = $value; |
422 | - } |
|
423 | - else if( $this->checkFieldType($key, 'float') ) |
|
442 | + } else if( $this->checkFieldType($key, 'float') ) |
|
424 | 443 | { |
425 | 444 | $this->{$key} = (double) price2num($value); |
426 | - } |
|
427 | - else if( $this->checkFieldType($key, 'int') ) { |
|
445 | + } else if( $this->checkFieldType($key, 'int') ) { |
|
428 | 446 | $this->{$key} = (int) price2num($value); |
429 | - } |
|
430 | - else |
|
447 | + } else |
|
431 | 448 | { |
432 | 449 | $this->{$key} = $value; |
433 | 450 | } |
@@ -32,44 +32,44 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class Cstate // extends CommonObject |
34 | 34 | { |
35 | - /** |
|
35 | + /** |
|
36 | 36 | * @var DoliDB Database handler. |
37 | 37 | */ |
38 | 38 | public $db; |
39 | 39 | |
40 | - /** |
|
41 | - * @var string Error code (or message) |
|
42 | - */ |
|
43 | - public $error=''; |
|
40 | + /** |
|
41 | + * @var string Error code (or message) |
|
42 | + */ |
|
43 | + public $error=''; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @var string[] Error codes (or messages) |
|
47 | - */ |
|
48 | - public $errors = array(); |
|
45 | + /** |
|
46 | + * @var string[] Error codes (or messages) |
|
47 | + */ |
|
48 | + public $errors = array(); |
|
49 | 49 | |
50 | - //var $element='cstate'; //!< Id that identify managed objects |
|
51 | - //var $table_element='cstate'; //!< Name of table without prefix where object is stored |
|
50 | + //var $element='cstate'; //!< Id that identify managed objects |
|
51 | + //var $table_element='cstate'; //!< Name of table without prefix where object is stored |
|
52 | 52 | |
53 | 53 | /** |
54 | - * @var int ID |
|
55 | - */ |
|
56 | - public $id; |
|
54 | + * @var int ID |
|
55 | + */ |
|
56 | + public $id; |
|
57 | 57 | |
58 | - public $code_departement; |
|
58 | + public $code_departement; |
|
59 | 59 | |
60 | - /** |
|
61 | - * @var string |
|
62 | - * @deprecated |
|
63 | - * @see name |
|
64 | - */ |
|
65 | - public $nom=''; |
|
60 | + /** |
|
61 | + * @var string |
|
62 | + * @deprecated |
|
63 | + * @see name |
|
64 | + */ |
|
65 | + public $nom=''; |
|
66 | 66 | |
67 | - /** |
|
68 | - * @var string name |
|
69 | - */ |
|
70 | - public $name=''; |
|
67 | + /** |
|
68 | + * @var string name |
|
69 | + */ |
|
70 | + public $name=''; |
|
71 | 71 | |
72 | - public $active; |
|
72 | + public $active; |
|
73 | 73 | |
74 | 74 | |
75 | 75 | |
@@ -94,70 +94,70 @@ discard block |
||
94 | 94 | */ |
95 | 95 | function create($user, $notrigger=0) |
96 | 96 | { |
97 | - global $conf, $langs; |
|
98 | - $error=0; |
|
97 | + global $conf, $langs; |
|
98 | + $error=0; |
|
99 | 99 | |
100 | - // Clean parameters |
|
101 | - if (isset($this->code_departement)) $this->code_departement=trim($this->code_departement); |
|
102 | - if (isset($this->nom)) $this->nom=trim($this->nom); |
|
103 | - if (isset($this->active)) $this->active=trim($this->active); |
|
100 | + // Clean parameters |
|
101 | + if (isset($this->code_departement)) $this->code_departement=trim($this->code_departement); |
|
102 | + if (isset($this->nom)) $this->nom=trim($this->nom); |
|
103 | + if (isset($this->active)) $this->active=trim($this->active); |
|
104 | 104 | |
105 | - // Check parameters |
|
106 | - // Put here code to add control on parameters values |
|
105 | + // Check parameters |
|
106 | + // Put here code to add control on parameters values |
|
107 | 107 | |
108 | 108 | // Insert request |
109 | - $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_departements("; |
|
110 | - $sql.= "rowid,"; |
|
111 | - $sql.= "code_departement,"; |
|
112 | - $sql.= "nom,"; |
|
113 | - $sql.= "active"; |
|
109 | + $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_departements("; |
|
110 | + $sql.= "rowid,"; |
|
111 | + $sql.= "code_departement,"; |
|
112 | + $sql.= "nom,"; |
|
113 | + $sql.= "active"; |
|
114 | 114 | $sql.= ") VALUES ("; |
115 | - $sql.= " ".(! isset($this->rowid)?'NULL':"'".$this->db->escape($this->rowid)."'").","; |
|
116 | - $sql.= " ".(! isset($this->code_departement)?'NULL':"'".$this->db->escape($this->code_departement)."'").","; |
|
117 | - $sql.= " ".(! isset($this->nom)?'NULL':"'".$this->db->escape($this->nom)."'").","; |
|
118 | - $sql.= " ".(! isset($this->active)?'NULL':"'".$this->db->escape($this->active)."'").""; |
|
119 | - $sql.= ")"; |
|
115 | + $sql.= " ".(! isset($this->rowid)?'NULL':"'".$this->db->escape($this->rowid)."'").","; |
|
116 | + $sql.= " ".(! isset($this->code_departement)?'NULL':"'".$this->db->escape($this->code_departement)."'").","; |
|
117 | + $sql.= " ".(! isset($this->nom)?'NULL':"'".$this->db->escape($this->nom)."'").","; |
|
118 | + $sql.= " ".(! isset($this->active)?'NULL':"'".$this->db->escape($this->active)."'").""; |
|
119 | + $sql.= ")"; |
|
120 | 120 | |
121 | - $this->db->begin(); |
|
121 | + $this->db->begin(); |
|
122 | 122 | |
123 | - dol_syslog(get_class($this)."::create", LOG_DEBUG); |
|
123 | + dol_syslog(get_class($this)."::create", LOG_DEBUG); |
|
124 | 124 | $resql=$this->db->query($sql); |
125 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
125 | + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
126 | 126 | |
127 | - if (! $error) |
|
127 | + if (! $error) |
|
128 | 128 | { |
129 | 129 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_departements"); |
130 | 130 | |
131 | - if (! $notrigger) |
|
132 | - { |
|
133 | - // Uncomment this and change MYOBJECT to your own tag if you |
|
134 | - // want this action call a trigger. |
|
135 | - |
|
136 | - //// Call triggers |
|
137 | - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; |
|
138 | - //$interface=new Interfaces($this->db); |
|
139 | - //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); |
|
140 | - //if ($result < 0) { $error++; $this->errors=$interface->errors; } |
|
141 | - //// End call triggers |
|
142 | - } |
|
131 | + if (! $notrigger) |
|
132 | + { |
|
133 | + // Uncomment this and change MYOBJECT to your own tag if you |
|
134 | + // want this action call a trigger. |
|
135 | + |
|
136 | + //// Call triggers |
|
137 | + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; |
|
138 | + //$interface=new Interfaces($this->db); |
|
139 | + //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); |
|
140 | + //if ($result < 0) { $error++; $this->errors=$interface->errors; } |
|
141 | + //// End call triggers |
|
142 | + } |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | // Commit or rollback |
146 | 146 | if ($error) |
147 | - { |
|
148 | - foreach($this->errors as $errmsg) |
|
149 | - { |
|
150 | - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); |
|
151 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
152 | - } |
|
153 | - $this->db->rollback(); |
|
154 | - return -1*$error; |
|
155 | - } |
|
156 | - else |
|
157 | - { |
|
158 | - $this->db->commit(); |
|
147 | + { |
|
148 | + foreach($this->errors as $errmsg) |
|
149 | + { |
|
150 | + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); |
|
151 | + $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
152 | + } |
|
153 | + $this->db->rollback(); |
|
154 | + return -1*$error; |
|
155 | + } |
|
156 | + else |
|
157 | + { |
|
158 | + $this->db->commit(); |
|
159 | 159 | return $this->id; |
160 | - } |
|
160 | + } |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | |
@@ -170,17 +170,17 @@ discard block |
||
170 | 170 | */ |
171 | 171 | function fetch($id,$code='') |
172 | 172 | { |
173 | - global $langs; |
|
173 | + global $langs; |
|
174 | 174 | $sql = "SELECT"; |
175 | - $sql.= " t.rowid,"; |
|
176 | - $sql.= " t.code_departement,"; |
|
177 | - $sql.= " t.nom,"; |
|
178 | - $sql.= " t.active"; |
|
175 | + $sql.= " t.rowid,"; |
|
176 | + $sql.= " t.code_departement,"; |
|
177 | + $sql.= " t.nom,"; |
|
178 | + $sql.= " t.active"; |
|
179 | 179 | $sql.= " FROM ".MAIN_DB_PREFIX."c_departements as t"; |
180 | 180 | if ($id) $sql.= " WHERE t.rowid = ".$id; |
181 | 181 | elseif ($code) $sql.= " WHERE t.code_departement = '".$this->db->escape($code)."'"; |
182 | 182 | |
183 | - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
|
183 | + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
|
184 | 184 | $resql=$this->db->query($sql); |
185 | 185 | if ($resql) |
186 | 186 | { |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | $obj = $this->db->fetch_object($resql); |
190 | 190 | |
191 | 191 | $this->id = $obj->rowid; |
192 | - $this->code_departement = $obj->code_departement; |
|
193 | - $this->nom = $obj->nom; |
|
194 | - $this->active = $obj->active; |
|
192 | + $this->code_departement = $obj->code_departement; |
|
193 | + $this->nom = $obj->nom; |
|
194 | + $this->active = $obj->active; |
|
195 | 195 | } |
196 | 196 | $this->db->free($resql); |
197 | 197 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | } |
200 | 200 | else |
201 | 201 | { |
202 | - $this->error="Error ".$this->db->lasterror(); |
|
202 | + $this->error="Error ".$this->db->lasterror(); |
|
203 | 203 | return -1; |
204 | 204 | } |
205 | 205 | } |
@@ -214,118 +214,118 @@ discard block |
||
214 | 214 | */ |
215 | 215 | function update($user=null, $notrigger=0) |
216 | 216 | { |
217 | - global $conf, $langs; |
|
218 | - $error=0; |
|
217 | + global $conf, $langs; |
|
218 | + $error=0; |
|
219 | 219 | |
220 | - // Clean parameters |
|
221 | - if (isset($this->code_departement)) $this->code_departement=trim($this->code_departement); |
|
222 | - if (isset($this->nom)) $this->nom=trim($this->nom); |
|
223 | - if (isset($this->active)) $this->active=trim($this->active); |
|
220 | + // Clean parameters |
|
221 | + if (isset($this->code_departement)) $this->code_departement=trim($this->code_departement); |
|
222 | + if (isset($this->nom)) $this->nom=trim($this->nom); |
|
223 | + if (isset($this->active)) $this->active=trim($this->active); |
|
224 | 224 | |
225 | 225 | |
226 | - // Check parameters |
|
227 | - // Put here code to add control on parameters values |
|
226 | + // Check parameters |
|
227 | + // Put here code to add control on parameters values |
|
228 | 228 | |
229 | 229 | // Update request |
230 | 230 | $sql = "UPDATE ".MAIN_DB_PREFIX."c_departements SET"; |
231 | - $sql.= " code_departement=".(isset($this->code_departement)?"'".$this->db->escape($this->code_departement)."'":"null").","; |
|
232 | - $sql.= " nom=".(isset($this->nom)?"'".$this->db->escape($this->nom)."'":"null").","; |
|
233 | - $sql.= " active=".(isset($this->active)?$this->active:"null").""; |
|
231 | + $sql.= " code_departement=".(isset($this->code_departement)?"'".$this->db->escape($this->code_departement)."'":"null").","; |
|
232 | + $sql.= " nom=".(isset($this->nom)?"'".$this->db->escape($this->nom)."'":"null").","; |
|
233 | + $sql.= " active=".(isset($this->active)?$this->active:"null").""; |
|
234 | 234 | $sql.= " WHERE rowid=".$this->id; |
235 | 235 | |
236 | - $this->db->begin(); |
|
236 | + $this->db->begin(); |
|
237 | 237 | |
238 | - dol_syslog(get_class($this)."::update", LOG_DEBUG); |
|
238 | + dol_syslog(get_class($this)."::update", LOG_DEBUG); |
|
239 | 239 | $resql = $this->db->query($sql); |
240 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
241 | - |
|
242 | - if (! $error) |
|
243 | - { |
|
244 | - if (! $notrigger) |
|
245 | - { |
|
246 | - // Uncomment this and change MYOBJECT to your own tag if you |
|
247 | - // want this action call a trigger. |
|
248 | - |
|
249 | - //// Call triggers |
|
250 | - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; |
|
251 | - //$interface=new Interfaces($this->db); |
|
252 | - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); |
|
253 | - //if ($result < 0) { $error++; $this->errors=$interface->errors; } |
|
254 | - //// End call triggers |
|
255 | - } |
|
256 | - } |
|
240 | + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
241 | + |
|
242 | + if (! $error) |
|
243 | + { |
|
244 | + if (! $notrigger) |
|
245 | + { |
|
246 | + // Uncomment this and change MYOBJECT to your own tag if you |
|
247 | + // want this action call a trigger. |
|
248 | + |
|
249 | + //// Call triggers |
|
250 | + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; |
|
251 | + //$interface=new Interfaces($this->db); |
|
252 | + //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); |
|
253 | + //if ($result < 0) { $error++; $this->errors=$interface->errors; } |
|
254 | + //// End call triggers |
|
255 | + } |
|
256 | + } |
|
257 | 257 | |
258 | 258 | // Commit or rollback |
259 | - if ($error) |
|
260 | - { |
|
261 | - foreach($this->errors as $errmsg) |
|
262 | - { |
|
263 | - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
|
264 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
265 | - } |
|
266 | - $this->db->rollback(); |
|
267 | - return -1*$error; |
|
268 | - } |
|
269 | - else |
|
270 | - { |
|
271 | - $this->db->commit(); |
|
272 | - return 1; |
|
273 | - } |
|
259 | + if ($error) |
|
260 | + { |
|
261 | + foreach($this->errors as $errmsg) |
|
262 | + { |
|
263 | + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
|
264 | + $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
265 | + } |
|
266 | + $this->db->rollback(); |
|
267 | + return -1*$error; |
|
268 | + } |
|
269 | + else |
|
270 | + { |
|
271 | + $this->db->commit(); |
|
272 | + return 1; |
|
273 | + } |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
277 | - /** |
|
278 | - * Delete object in database |
|
279 | - * |
|
280 | - * @param User $user User that delete |
|
281 | - * @param int $notrigger 0=launch triggers after, 1=disable triggers |
|
282 | - * @return int <0 if KO, >0 if OK |
|
283 | - */ |
|
284 | - function delete($user, $notrigger=0) |
|
285 | - { |
|
286 | - global $conf, $langs; |
|
287 | - $error=0; |
|
288 | - |
|
289 | - $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_departements"; |
|
290 | - $sql.= " WHERE rowid=".$this->id; |
|
291 | - |
|
292 | - $this->db->begin(); |
|
293 | - |
|
294 | - dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
|
295 | - $resql = $this->db->query($sql); |
|
296 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
297 | - |
|
298 | - if (! $error) |
|
299 | - { |
|
300 | - if (! $notrigger) |
|
301 | - { |
|
302 | - // Uncomment this and change MYOBJECT to your own tag if you |
|
303 | - // want this action call a trigger. |
|
304 | - |
|
305 | - //// Call triggers |
|
306 | - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; |
|
307 | - //$interface=new Interfaces($this->db); |
|
308 | - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); |
|
309 | - //if ($result < 0) { $error++; $this->errors=$interface->errors; } |
|
310 | - //// End call triggers |
|
311 | - } |
|
312 | - } |
|
277 | + /** |
|
278 | + * Delete object in database |
|
279 | + * |
|
280 | + * @param User $user User that delete |
|
281 | + * @param int $notrigger 0=launch triggers after, 1=disable triggers |
|
282 | + * @return int <0 if KO, >0 if OK |
|
283 | + */ |
|
284 | + function delete($user, $notrigger=0) |
|
285 | + { |
|
286 | + global $conf, $langs; |
|
287 | + $error=0; |
|
288 | + |
|
289 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_departements"; |
|
290 | + $sql.= " WHERE rowid=".$this->id; |
|
291 | + |
|
292 | + $this->db->begin(); |
|
293 | + |
|
294 | + dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
|
295 | + $resql = $this->db->query($sql); |
|
296 | + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
297 | + |
|
298 | + if (! $error) |
|
299 | + { |
|
300 | + if (! $notrigger) |
|
301 | + { |
|
302 | + // Uncomment this and change MYOBJECT to your own tag if you |
|
303 | + // want this action call a trigger. |
|
304 | + |
|
305 | + //// Call triggers |
|
306 | + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; |
|
307 | + //$interface=new Interfaces($this->db); |
|
308 | + //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); |
|
309 | + //if ($result < 0) { $error++; $this->errors=$interface->errors; } |
|
310 | + //// End call triggers |
|
311 | + } |
|
312 | + } |
|
313 | 313 | |
314 | 314 | // Commit or rollback |
315 | - if ($error) |
|
316 | - { |
|
317 | - foreach($this->errors as $errmsg) |
|
318 | - { |
|
319 | - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
|
320 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
321 | - } |
|
322 | - $this->db->rollback(); |
|
323 | - return -1*$error; |
|
324 | - } |
|
325 | - else |
|
326 | - { |
|
327 | - $this->db->commit(); |
|
328 | - return 1; |
|
329 | - } |
|
330 | - } |
|
315 | + if ($error) |
|
316 | + { |
|
317 | + foreach($this->errors as $errmsg) |
|
318 | + { |
|
319 | + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
|
320 | + $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
321 | + } |
|
322 | + $this->db->rollback(); |
|
323 | + return -1*$error; |
|
324 | + } |
|
325 | + else |
|
326 | + { |
|
327 | + $this->db->commit(); |
|
328 | + return 1; |
|
329 | + } |
|
330 | + } |
|
331 | 331 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * @var string Error code (or message) |
42 | 42 | */ |
43 | - public $error=''; |
|
43 | + public $error = ''; |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @var string[] Error codes (or messages) |
@@ -62,12 +62,12 @@ discard block |
||
62 | 62 | * @deprecated |
63 | 63 | * @see name |
64 | 64 | */ |
65 | - public $nom=''; |
|
65 | + public $nom = ''; |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * @var string name |
69 | 69 | */ |
70 | - public $name=''; |
|
70 | + public $name = ''; |
|
71 | 71 | |
72 | 72 | public $active; |
73 | 73 | |
@@ -92,43 +92,43 @@ discard block |
||
92 | 92 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
93 | 93 | * @return int <0 if KO, Id of created object if OK |
94 | 94 | */ |
95 | - function create($user, $notrigger=0) |
|
95 | + function create($user, $notrigger = 0) |
|
96 | 96 | { |
97 | 97 | global $conf, $langs; |
98 | - $error=0; |
|
98 | + $error = 0; |
|
99 | 99 | |
100 | 100 | // Clean parameters |
101 | - if (isset($this->code_departement)) $this->code_departement=trim($this->code_departement); |
|
102 | - if (isset($this->nom)) $this->nom=trim($this->nom); |
|
103 | - if (isset($this->active)) $this->active=trim($this->active); |
|
101 | + if (isset($this->code_departement)) $this->code_departement = trim($this->code_departement); |
|
102 | + if (isset($this->nom)) $this->nom = trim($this->nom); |
|
103 | + if (isset($this->active)) $this->active = trim($this->active); |
|
104 | 104 | |
105 | 105 | // Check parameters |
106 | 106 | // Put here code to add control on parameters values |
107 | 107 | |
108 | 108 | // Insert request |
109 | 109 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_departements("; |
110 | - $sql.= "rowid,"; |
|
111 | - $sql.= "code_departement,"; |
|
112 | - $sql.= "nom,"; |
|
113 | - $sql.= "active"; |
|
114 | - $sql.= ") VALUES ("; |
|
115 | - $sql.= " ".(! isset($this->rowid)?'NULL':"'".$this->db->escape($this->rowid)."'").","; |
|
116 | - $sql.= " ".(! isset($this->code_departement)?'NULL':"'".$this->db->escape($this->code_departement)."'").","; |
|
117 | - $sql.= " ".(! isset($this->nom)?'NULL':"'".$this->db->escape($this->nom)."'").","; |
|
118 | - $sql.= " ".(! isset($this->active)?'NULL':"'".$this->db->escape($this->active)."'").""; |
|
119 | - $sql.= ")"; |
|
110 | + $sql .= "rowid,"; |
|
111 | + $sql .= "code_departement,"; |
|
112 | + $sql .= "nom,"; |
|
113 | + $sql .= "active"; |
|
114 | + $sql .= ") VALUES ("; |
|
115 | + $sql .= " ".(!isset($this->rowid) ? 'NULL' : "'".$this->db->escape($this->rowid)."'").","; |
|
116 | + $sql .= " ".(!isset($this->code_departement) ? 'NULL' : "'".$this->db->escape($this->code_departement)."'").","; |
|
117 | + $sql .= " ".(!isset($this->nom) ? 'NULL' : "'".$this->db->escape($this->nom)."'").","; |
|
118 | + $sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->escape($this->active)."'").""; |
|
119 | + $sql .= ")"; |
|
120 | 120 | |
121 | 121 | $this->db->begin(); |
122 | 122 | |
123 | 123 | dol_syslog(get_class($this)."::create", LOG_DEBUG); |
124 | - $resql=$this->db->query($sql); |
|
125 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
124 | + $resql = $this->db->query($sql); |
|
125 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
126 | 126 | |
127 | - if (! $error) |
|
127 | + if (!$error) |
|
128 | 128 | { |
129 | 129 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_departements"); |
130 | 130 | |
131 | - if (! $notrigger) |
|
131 | + if (!$notrigger) |
|
132 | 132 | { |
133 | 133 | // Uncomment this and change MYOBJECT to your own tag if you |
134 | 134 | // want this action call a trigger. |
@@ -145,13 +145,13 @@ discard block |
||
145 | 145 | // Commit or rollback |
146 | 146 | if ($error) |
147 | 147 | { |
148 | - foreach($this->errors as $errmsg) |
|
148 | + foreach ($this->errors as $errmsg) |
|
149 | 149 | { |
150 | 150 | dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); |
151 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
151 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
152 | 152 | } |
153 | 153 | $this->db->rollback(); |
154 | - return -1*$error; |
|
154 | + return -1 * $error; |
|
155 | 155 | } |
156 | 156 | else |
157 | 157 | { |
@@ -168,27 +168,27 @@ discard block |
||
168 | 168 | * @param string $code Code |
169 | 169 | * @return int <0 if KO, >0 if OK |
170 | 170 | */ |
171 | - function fetch($id,$code='') |
|
171 | + function fetch($id, $code = '') |
|
172 | 172 | { |
173 | 173 | global $langs; |
174 | 174 | $sql = "SELECT"; |
175 | - $sql.= " t.rowid,"; |
|
176 | - $sql.= " t.code_departement,"; |
|
177 | - $sql.= " t.nom,"; |
|
178 | - $sql.= " t.active"; |
|
179 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_departements as t"; |
|
180 | - if ($id) $sql.= " WHERE t.rowid = ".$id; |
|
181 | - elseif ($code) $sql.= " WHERE t.code_departement = '".$this->db->escape($code)."'"; |
|
175 | + $sql .= " t.rowid,"; |
|
176 | + $sql .= " t.code_departement,"; |
|
177 | + $sql .= " t.nom,"; |
|
178 | + $sql .= " t.active"; |
|
179 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_departements as t"; |
|
180 | + if ($id) $sql .= " WHERE t.rowid = ".$id; |
|
181 | + elseif ($code) $sql .= " WHERE t.code_departement = '".$this->db->escape($code)."'"; |
|
182 | 182 | |
183 | 183 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
184 | - $resql=$this->db->query($sql); |
|
184 | + $resql = $this->db->query($sql); |
|
185 | 185 | if ($resql) |
186 | 186 | { |
187 | 187 | if ($this->db->num_rows($resql)) |
188 | 188 | { |
189 | 189 | $obj = $this->db->fetch_object($resql); |
190 | 190 | |
191 | - $this->id = $obj->rowid; |
|
191 | + $this->id = $obj->rowid; |
|
192 | 192 | $this->code_departement = $obj->code_departement; |
193 | 193 | $this->nom = $obj->nom; |
194 | 194 | $this->active = $obj->active; |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | } |
200 | 200 | else |
201 | 201 | { |
202 | - $this->error="Error ".$this->db->lasterror(); |
|
202 | + $this->error = "Error ".$this->db->lasterror(); |
|
203 | 203 | return -1; |
204 | 204 | } |
205 | 205 | } |
@@ -212,15 +212,15 @@ discard block |
||
212 | 212 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
213 | 213 | * @return int <0 if KO, >0 if OK |
214 | 214 | */ |
215 | - function update($user=null, $notrigger=0) |
|
215 | + function update($user = null, $notrigger = 0) |
|
216 | 216 | { |
217 | 217 | global $conf, $langs; |
218 | - $error=0; |
|
218 | + $error = 0; |
|
219 | 219 | |
220 | 220 | // Clean parameters |
221 | - if (isset($this->code_departement)) $this->code_departement=trim($this->code_departement); |
|
222 | - if (isset($this->nom)) $this->nom=trim($this->nom); |
|
223 | - if (isset($this->active)) $this->active=trim($this->active); |
|
221 | + if (isset($this->code_departement)) $this->code_departement = trim($this->code_departement); |
|
222 | + if (isset($this->nom)) $this->nom = trim($this->nom); |
|
223 | + if (isset($this->active)) $this->active = trim($this->active); |
|
224 | 224 | |
225 | 225 | |
226 | 226 | // Check parameters |
@@ -228,20 +228,20 @@ discard block |
||
228 | 228 | |
229 | 229 | // Update request |
230 | 230 | $sql = "UPDATE ".MAIN_DB_PREFIX."c_departements SET"; |
231 | - $sql.= " code_departement=".(isset($this->code_departement)?"'".$this->db->escape($this->code_departement)."'":"null").","; |
|
232 | - $sql.= " nom=".(isset($this->nom)?"'".$this->db->escape($this->nom)."'":"null").","; |
|
233 | - $sql.= " active=".(isset($this->active)?$this->active:"null").""; |
|
234 | - $sql.= " WHERE rowid=".$this->id; |
|
231 | + $sql .= " code_departement=".(isset($this->code_departement) ? "'".$this->db->escape($this->code_departement)."'" : "null").","; |
|
232 | + $sql .= " nom=".(isset($this->nom) ? "'".$this->db->escape($this->nom)."'" : "null").","; |
|
233 | + $sql .= " active=".(isset($this->active) ? $this->active : "null").""; |
|
234 | + $sql .= " WHERE rowid=".$this->id; |
|
235 | 235 | |
236 | 236 | $this->db->begin(); |
237 | 237 | |
238 | 238 | dol_syslog(get_class($this)."::update", LOG_DEBUG); |
239 | 239 | $resql = $this->db->query($sql); |
240 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
240 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
241 | 241 | |
242 | - if (! $error) |
|
242 | + if (!$error) |
|
243 | 243 | { |
244 | - if (! $notrigger) |
|
244 | + if (!$notrigger) |
|
245 | 245 | { |
246 | 246 | // Uncomment this and change MYOBJECT to your own tag if you |
247 | 247 | // want this action call a trigger. |
@@ -258,13 +258,13 @@ discard block |
||
258 | 258 | // Commit or rollback |
259 | 259 | if ($error) |
260 | 260 | { |
261 | - foreach($this->errors as $errmsg) |
|
261 | + foreach ($this->errors as $errmsg) |
|
262 | 262 | { |
263 | 263 | dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
264 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
264 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
265 | 265 | } |
266 | 266 | $this->db->rollback(); |
267 | - return -1*$error; |
|
267 | + return -1 * $error; |
|
268 | 268 | } |
269 | 269 | else |
270 | 270 | { |
@@ -281,23 +281,23 @@ discard block |
||
281 | 281 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
282 | 282 | * @return int <0 if KO, >0 if OK |
283 | 283 | */ |
284 | - function delete($user, $notrigger=0) |
|
284 | + function delete($user, $notrigger = 0) |
|
285 | 285 | { |
286 | 286 | global $conf, $langs; |
287 | - $error=0; |
|
287 | + $error = 0; |
|
288 | 288 | |
289 | 289 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_departements"; |
290 | - $sql.= " WHERE rowid=".$this->id; |
|
290 | + $sql .= " WHERE rowid=".$this->id; |
|
291 | 291 | |
292 | 292 | $this->db->begin(); |
293 | 293 | |
294 | 294 | dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
295 | 295 | $resql = $this->db->query($sql); |
296 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
296 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
297 | 297 | |
298 | - if (! $error) |
|
298 | + if (!$error) |
|
299 | 299 | { |
300 | - if (! $notrigger) |
|
300 | + if (!$notrigger) |
|
301 | 301 | { |
302 | 302 | // Uncomment this and change MYOBJECT to your own tag if you |
303 | 303 | // want this action call a trigger. |
@@ -314,13 +314,13 @@ discard block |
||
314 | 314 | // Commit or rollback |
315 | 315 | if ($error) |
316 | 316 | { |
317 | - foreach($this->errors as $errmsg) |
|
317 | + foreach ($this->errors as $errmsg) |
|
318 | 318 | { |
319 | 319 | dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
320 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
320 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
321 | 321 | } |
322 | 322 | $this->db->rollback(); |
323 | - return -1*$error; |
|
323 | + return -1 * $error; |
|
324 | 324 | } |
325 | 325 | else |
326 | 326 | { |
@@ -98,9 +98,15 @@ discard block |
||
98 | 98 | $error=0; |
99 | 99 | |
100 | 100 | // Clean parameters |
101 | - if (isset($this->code_departement)) $this->code_departement=trim($this->code_departement); |
|
102 | - if (isset($this->nom)) $this->nom=trim($this->nom); |
|
103 | - if (isset($this->active)) $this->active=trim($this->active); |
|
101 | + if (isset($this->code_departement)) { |
|
102 | + $this->code_departement=trim($this->code_departement); |
|
103 | + } |
|
104 | + if (isset($this->nom)) { |
|
105 | + $this->nom=trim($this->nom); |
|
106 | + } |
|
107 | + if (isset($this->active)) { |
|
108 | + $this->active=trim($this->active); |
|
109 | + } |
|
104 | 110 | |
105 | 111 | // Check parameters |
106 | 112 | // Put here code to add control on parameters values |
@@ -152,8 +158,7 @@ discard block |
||
152 | 158 | } |
153 | 159 | $this->db->rollback(); |
154 | 160 | return -1*$error; |
155 | - } |
|
156 | - else |
|
161 | + } else |
|
157 | 162 | { |
158 | 163 | $this->db->commit(); |
159 | 164 | return $this->id; |
@@ -177,8 +182,11 @@ discard block |
||
177 | 182 | $sql.= " t.nom,"; |
178 | 183 | $sql.= " t.active"; |
179 | 184 | $sql.= " FROM ".MAIN_DB_PREFIX."c_departements as t"; |
180 | - if ($id) $sql.= " WHERE t.rowid = ".$id; |
|
181 | - elseif ($code) $sql.= " WHERE t.code_departement = '".$this->db->escape($code)."'"; |
|
185 | + if ($id) { |
|
186 | + $sql.= " WHERE t.rowid = ".$id; |
|
187 | + } elseif ($code) { |
|
188 | + $sql.= " WHERE t.code_departement = '".$this->db->escape($code)."'"; |
|
189 | + } |
|
182 | 190 | |
183 | 191 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
184 | 192 | $resql=$this->db->query($sql); |
@@ -196,8 +204,7 @@ discard block |
||
196 | 204 | $this->db->free($resql); |
197 | 205 | |
198 | 206 | return 1; |
199 | - } |
|
200 | - else |
|
207 | + } else |
|
201 | 208 | { |
202 | 209 | $this->error="Error ".$this->db->lasterror(); |
203 | 210 | return -1; |
@@ -218,9 +225,15 @@ discard block |
||
218 | 225 | $error=0; |
219 | 226 | |
220 | 227 | // Clean parameters |
221 | - if (isset($this->code_departement)) $this->code_departement=trim($this->code_departement); |
|
222 | - if (isset($this->nom)) $this->nom=trim($this->nom); |
|
223 | - if (isset($this->active)) $this->active=trim($this->active); |
|
228 | + if (isset($this->code_departement)) { |
|
229 | + $this->code_departement=trim($this->code_departement); |
|
230 | + } |
|
231 | + if (isset($this->nom)) { |
|
232 | + $this->nom=trim($this->nom); |
|
233 | + } |
|
234 | + if (isset($this->active)) { |
|
235 | + $this->active=trim($this->active); |
|
236 | + } |
|
224 | 237 | |
225 | 238 | |
226 | 239 | // Check parameters |
@@ -265,8 +278,7 @@ discard block |
||
265 | 278 | } |
266 | 279 | $this->db->rollback(); |
267 | 280 | return -1*$error; |
268 | - } |
|
269 | - else |
|
281 | + } else |
|
270 | 282 | { |
271 | 283 | $this->db->commit(); |
272 | 284 | return 1; |
@@ -321,8 +333,7 @@ discard block |
||
321 | 333 | } |
322 | 334 | $this->db->rollback(); |
323 | 335 | return -1*$error; |
324 | - } |
|
325 | - else |
|
336 | + } else |
|
326 | 337 | { |
327 | 338 | $this->db->commit(); |
328 | 339 | return 1; |
@@ -32,7 +32,6 @@ discard block |
||
32 | 32 | * Classe permettant la generation du formulaire d'un nouveau ticket. |
33 | 33 | * |
34 | 34 | * @package Ticket |
35 | - |
|
36 | 35 | * \remarks Utilisation: $formticket = new FormTicket($db) |
37 | 36 | * \remarks $formticket->proprietes=1 ou chaine ou tableau de valeurs |
38 | 37 | * \remarks $formticket->show_form() affiche le formulaire |
@@ -88,9 +87,9 @@ discard block |
||
88 | 87 | public $param = array(); |
89 | 88 | |
90 | 89 | /** |
91 | - * @var string Error code (or message) |
|
92 | - */ |
|
93 | - public $error; |
|
90 | + * @var string Error code (or message) |
|
91 | + */ |
|
92 | + public $error; |
|
94 | 93 | |
95 | 94 | |
96 | 95 | /** |
@@ -153,7 +152,7 @@ discard block |
||
153 | 152 | print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; |
154 | 153 | print '<input type="hidden" name="action" value="' . $this->action . '">'; |
155 | 154 | foreach ($this->param as $key => $value) { |
156 | - print '<input type="hidden" name="' . $key . '" value="' . $value . '">'; |
|
155 | + print '<input type="hidden" name="' . $key . '" value="' . $value . '">'; |
|
157 | 156 | } |
158 | 157 | print '<input type="hidden" name="fk_user_create" value="' . $this->fk_user_create . '">'; |
159 | 158 | |
@@ -306,9 +305,9 @@ discard block |
||
306 | 305 | // Notify thirdparty at creation |
307 | 306 | if (empty($this->ispublic)) |
308 | 307 | { |
309 | - print '<tr><td><label for="notify_tiers_at_create">' . $langs->trans("TicketNotifyTiersAtCreation") . '</label></td><td>'; |
|
310 | - print '<input type="checkbox" id="notify_tiers_at_create" name="notify_tiers_at_create"'.($this->withnotifytiersatcreate?' checked="checked"':'').'>'; |
|
311 | - print '</td></tr>'; |
|
308 | + print '<tr><td><label for="notify_tiers_at_create">' . $langs->trans("TicketNotifyTiersAtCreation") . '</label></td><td>'; |
|
309 | + print '<input type="checkbox" id="notify_tiers_at_create" name="notify_tiers_at_create"'.($this->withnotifytiersatcreate?' checked="checked"':'').'>'; |
|
310 | + print '</td></tr>'; |
|
312 | 311 | } |
313 | 312 | |
314 | 313 | // TITLE |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | * \ingroup ticket |
22 | 22 | * \brief Fichier de la classe permettant la generation du formulaire html d'envoi de mail unitaire |
23 | 23 | */ |
24 | -require_once DOL_DOCUMENT_ROOT . "/core/class/html.form.class.php"; |
|
25 | -require_once DOL_DOCUMENT_ROOT . "/core/class/html.formmail.class.php"; |
|
24 | +require_once DOL_DOCUMENT_ROOT."/core/class/html.form.class.php"; |
|
25 | +require_once DOL_DOCUMENT_ROOT."/core/class/html.formmail.class.php"; |
|
26 | 26 | |
27 | 27 | if (!class_exists('FormCompany')) { |
28 | - include DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; |
|
28 | + include DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $this->withcreatereadonly = 1; |
115 | 115 | $this->withemail = 0; |
116 | 116 | $this->withref = 0; |
117 | - $this->withextrafields = 0; // Show extrafields or not |
|
117 | + $this->withextrafields = 0; // Show extrafields or not |
|
118 | 118 | //$this->withtopicreadonly=0; |
119 | 119 | } |
120 | 120 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @param int $withdolfichehead With dol_fiche_head |
125 | 125 | * @return void |
126 | 126 | */ |
127 | - public function showForm($withdolfichehead=0) |
|
127 | + public function showForm($withdolfichehead = 0) |
|
128 | 128 | { |
129 | 129 | global $conf, $langs, $user, $hookmanager; |
130 | 130 | |
@@ -149,25 +149,25 @@ discard block |
||
149 | 149 | |
150 | 150 | if ($withdolfichehead) dol_fiche_head(null, 'card', '', 0, ''); |
151 | 151 | |
152 | - print '<form method="POST" '.($withdolfichehead?'':'style="margin-bottom: 30px;" ').'name="ticket" id="form_create_ticket" enctype="multipart/form-data" action="' . $this->param["returnurl"] . '">'; |
|
153 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; |
|
154 | - print '<input type="hidden" name="action" value="' . $this->action . '">'; |
|
152 | + print '<form method="POST" '.($withdolfichehead ? '' : 'style="margin-bottom: 30px;" ').'name="ticket" id="form_create_ticket" enctype="multipart/form-data" action="'.$this->param["returnurl"].'">'; |
|
153 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
154 | + print '<input type="hidden" name="action" value="'.$this->action.'">'; |
|
155 | 155 | foreach ($this->param as $key => $value) { |
156 | - print '<input type="hidden" name="' . $key . '" value="' . $value . '">'; |
|
156 | + print '<input type="hidden" name="'.$key.'" value="'.$value.'">'; |
|
157 | 157 | } |
158 | - print '<input type="hidden" name="fk_user_create" value="' . $this->fk_user_create . '">'; |
|
158 | + print '<input type="hidden" name="fk_user_create" value="'.$this->fk_user_create.'">'; |
|
159 | 159 | |
160 | 160 | print '<table class="border">'; |
161 | 161 | |
162 | 162 | if ($this->withref) { |
163 | 163 | // Ref |
164 | 164 | $defaultref = $ticketstat->getDefaultRef(); |
165 | - print '<tr><td class="titlefield"><span class="fieldrequired">' . $langs->trans("Ref") . '</span></td><td><input size="18" type="text" name="ref" value="' . (GETPOST("ref", 'alpha') ? GETPOST("ref", 'alpha') : $defaultref) . '"></td></tr>'; |
|
165 | + print '<tr><td class="titlefield"><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td><input size="18" type="text" name="ref" value="'.(GETPOST("ref", 'alpha') ? GETPOST("ref", 'alpha') : $defaultref).'"></td></tr>'; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | // FK_USER_CREATE |
169 | 169 | if ($this->withusercreate > 0 && $this->fk_user_create) { |
170 | - print '<tr><td class="titlefield">' . $langs->trans("CreatedBy") . '</td><td>'; |
|
170 | + print '<tr><td class="titlefield">'.$langs->trans("CreatedBy").'</td><td>'; |
|
171 | 171 | $langs->load("users"); |
172 | 172 | $fuser = new User($this->db); |
173 | 173 | |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | // altairis: force company and contact id for external user |
186 | 186 | if (empty($user->socid)) { |
187 | 187 | // Company |
188 | - print '<tr><td class="titlefield">' . $langs->trans("ThirdParty") . '</td><td>'; |
|
188 | + print '<tr><td class="titlefield">'.$langs->trans("ThirdParty").'</td><td>'; |
|
189 | 189 | $events = array(); |
190 | 190 | $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); |
191 | 191 | print $form->select_company($this->withfromsocid, 'socid', '', 1, 1, '', $events, 0, 'minwidth200'); |
192 | 192 | print '</td></tr>'; |
193 | - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) { |
|
193 | + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) { |
|
194 | 194 | $htmlname = 'socid'; |
195 | 195 | print '<script type="text/javascript"> |
196 | 196 | $(document).ready(function () { |
@@ -245,23 +245,23 @@ discard block |
||
245 | 245 | } |
246 | 246 | |
247 | 247 | // Contact and type |
248 | - print '<tr><td>' . $langs->trans("Contact") . '</td><td>'; |
|
248 | + print '<tr><td>'.$langs->trans("Contact").'</td><td>'; |
|
249 | 249 | // If no socid, set to -1 to avoid full contacts list |
250 | 250 | $selectedCompany = ($this->withfromsocid > 0) ? $this->withfromsocid : -1; |
251 | 251 | $nbofcontacts = $form->select_contacts($selectedCompany, $this->withfromcontactid, 'contactid', 3, '', '', 0, 'minwidth200'); |
252 | 252 | $formcompany->selectTypeContact($ticketstatic, '', 'type', 'external', '', 0, 'maginleftonly'); |
253 | 253 | print '</td></tr>'; |
254 | 254 | } else { |
255 | - print '<tr><td class="titlefield"><input type="hidden" name="socid" value="' . $user->socid . '"/></td>'; |
|
256 | - print '<td><input type="hidden" name="contactid" value="' . $user->contactid . '"/></td>'; |
|
255 | + print '<tr><td class="titlefield"><input type="hidden" name="socid" value="'.$user->socid.'"/></td>'; |
|
256 | + print '<td><input type="hidden" name="contactid" value="'.$user->contactid.'"/></td>'; |
|
257 | 257 | print '<td><input type="hidden" name="type" value="Z"/></td></tr>'; |
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | 261 | // TITLE |
262 | 262 | if ($this->withemail) { |
263 | - print '<tr><td class="titlefield"><label for="email"><span class="fieldrequired">' . $langs->trans("Email") . '</span></label></td><td>'; |
|
264 | - print '<input class="text minwidth200" id="email" name="email" value="' . (GETPOST('email', 'alpha') ? GETPOST('email', 'alpha') : $subject) . '" />'; |
|
263 | + print '<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans("Email").'</span></label></td><td>'; |
|
264 | + print '<input class="text minwidth200" id="email" name="email" value="'.(GETPOST('email', 'alpha') ? GETPOST('email', 'alpha') : $subject).'" />'; |
|
265 | 265 | print '</td></tr>'; |
266 | 266 | } |
267 | 267 | |
@@ -274,10 +274,10 @@ discard block |
||
274 | 274 | $subelement = $regs[2]; |
275 | 275 | } |
276 | 276 | |
277 | - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); |
|
277 | + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); |
|
278 | 278 | $classname = ucfirst($subelement); |
279 | 279 | $objectsrc = new $classname($this->db); |
280 | - $objectsrc->fetch(GETPOST('originid','int')); |
|
280 | + $objectsrc->fetch(GETPOST('originid', 'int')); |
|
281 | 281 | |
282 | 282 | if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) { |
283 | 283 | $objectsrc->fetch_lines(); |
@@ -285,58 +285,58 @@ discard block |
||
285 | 285 | |
286 | 286 | $objectsrc->fetch_thirdparty(); |
287 | 287 | $newclassname = $classname; |
288 | - print '<tr><td>' . $langs->trans($newclassname) . '</td><td colspan="2"><input name="' . $subelement . 'id" value="' . GETPOST('originid') . '" type="hidden" />' . $objectsrc->getNomUrl(1) . '</td></tr>'; |
|
288 | + print '<tr><td>'.$langs->trans($newclassname).'</td><td colspan="2"><input name="'.$subelement.'id" value="'.GETPOST('originid').'" type="hidden" />'.$objectsrc->getNomUrl(1).'</td></tr>'; |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | // Type |
292 | - print '<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">' . $langs->trans("TicketTypeRequest") . '</span></label></td><td>'; |
|
292 | + print '<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">'.$langs->trans("TicketTypeRequest").'</span></label></td><td>'; |
|
293 | 293 | print $this->selectTypesTickets((GETPOST('type_code') ? GETPOST('type_code') : $this->type_code), 'type_code', '', '2'); |
294 | 294 | print '</td></tr>'; |
295 | 295 | |
296 | 296 | // Category |
297 | - print '<tr><td><span class="fieldrequired"><label for="selectcategory_code">' . $langs->trans("TicketCategory") . '</span></label></td><td>'; |
|
297 | + print '<tr><td><span class="fieldrequired"><label for="selectcategory_code">'.$langs->trans("TicketCategory").'</span></label></td><td>'; |
|
298 | 298 | print $this->selectCategoriesTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', '', '2'); |
299 | 299 | print '</td></tr>'; |
300 | 300 | |
301 | 301 | // Severity |
302 | - print '<tr><td><span class="fieldrequired"><label for="selectseverity_code">' . $langs->trans("TicketSeverity") . '</span></label></td><td>'; |
|
302 | + print '<tr><td><span class="fieldrequired"><label for="selectseverity_code">'.$langs->trans("TicketSeverity").'</span></label></td><td>'; |
|
303 | 303 | print $this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', '2'); |
304 | 304 | print '</td></tr>'; |
305 | 305 | |
306 | 306 | // Notify thirdparty at creation |
307 | 307 | if (empty($this->ispublic)) |
308 | 308 | { |
309 | - print '<tr><td><label for="notify_tiers_at_create">' . $langs->trans("TicketNotifyTiersAtCreation") . '</label></td><td>'; |
|
310 | - print '<input type="checkbox" id="notify_tiers_at_create" name="notify_tiers_at_create"'.($this->withnotifytiersatcreate?' checked="checked"':'').'>'; |
|
309 | + print '<tr><td><label for="notify_tiers_at_create">'.$langs->trans("TicketNotifyTiersAtCreation").'</label></td><td>'; |
|
310 | + print '<input type="checkbox" id="notify_tiers_at_create" name="notify_tiers_at_create"'.($this->withnotifytiersatcreate ? ' checked="checked"' : '').'>'; |
|
311 | 311 | print '</td></tr>'; |
312 | 312 | } |
313 | 313 | |
314 | 314 | // TITLE |
315 | 315 | if ($this->withtitletopic) { |
316 | - print '<tr><td><label for="subject"><span class="fieldrequired">' . $langs->trans("Subject") . '</span></label></td><td>'; |
|
316 | + print '<tr><td><label for="subject"><span class="fieldrequired">'.$langs->trans("Subject").'</span></label></td><td>'; |
|
317 | 317 | |
318 | 318 | // Réponse à un ticket : affichage du titre du thread en readonly |
319 | 319 | if ($this->withtopicreadonly) { |
320 | - print $langs->trans('SubjectAnswerToTicket') . ' ' . $this->topic_title; |
|
320 | + print $langs->trans('SubjectAnswerToTicket').' '.$this->topic_title; |
|
321 | 321 | print '</td></tr>'; |
322 | 322 | } else { |
323 | 323 | if ($this->withthreadid > 0) { |
324 | - $subject = $langs->trans('SubjectAnswerToTicket') . ' ' . $this->withthreadid . ' : ' . $this->topic_title . ''; |
|
324 | + $subject = $langs->trans('SubjectAnswerToTicket').' '.$this->withthreadid.' : '.$this->topic_title.''; |
|
325 | 325 | } |
326 | - print '<input class="text" size="50" id="subject" name="subject" value="' . (GETPOST('subject', 'alpha') ? GETPOST('subject', 'alpha') : $subject) . '" />'; |
|
326 | + print '<input class="text" size="50" id="subject" name="subject" value="'.(GETPOST('subject', 'alpha') ? GETPOST('subject', 'alpha') : $subject).'" />'; |
|
327 | 327 | print '</td></tr>'; |
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
331 | 331 | // MESSAGE |
332 | 332 | $msg = GETPOST('message', 'alpha') ? GETPOST('message', 'alpha') : ''; |
333 | - print '<tr><td><label for="message"><span class="fieldrequired">' . $langs->trans("Message") . '</span></label></td><td>'; |
|
333 | + print '<tr><td><label for="message"><span class="fieldrequired">'.$langs->trans("Message").'</span></label></td><td>'; |
|
334 | 334 | |
335 | 335 | // If public form, display more information |
336 | 336 | if ($this->ispublic) { |
337 | - print '<div class="warning">' . ($conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe')) . '</div>'; |
|
337 | + print '<div class="warning">'.($conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe')).'</div>'; |
|
338 | 338 | } |
339 | - include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; |
|
339 | + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
|
340 | 340 | $uselocalbrowser = true; |
341 | 341 | $doleditor = new DolEditor('message', GETPOST('message', 'alpha'), '100%', 250, 'dolibarr_details', 'In', true, $uselocalbrowser); |
342 | 342 | $doleditor->Create(); |
@@ -361,33 +361,33 @@ discard block |
||
361 | 361 | } |
362 | 362 | |
363 | 363 | $out .= '<tr>'; |
364 | - $out .= '<td width="180">' . $langs->trans("MailFile") . '</td>'; |
|
364 | + $out .= '<td width="180">'.$langs->trans("MailFile").'</td>'; |
|
365 | 365 | $out .= '<td colspan="2">'; |
366 | 366 | // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript |
367 | - $out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">' . "\n"; |
|
367 | + $out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">'."\n"; |
|
368 | 368 | $out .= '<script type="text/javascript" language="javascript">'; |
369 | 369 | $out .= 'jQuery(document).ready(function () {'; |
370 | 370 | $out .= ' jQuery(".removedfile").click(function() {'; |
371 | 371 | $out .= ' jQuery(".removedfilehidden").val(jQuery(this).val());'; |
372 | 372 | $out .= ' });'; |
373 | 373 | $out .= '})'; |
374 | - $out .= '</script>' . "\n"; |
|
374 | + $out .= '</script>'."\n"; |
|
375 | 375 | if (count($listofpaths)) { |
376 | 376 | foreach ($listofpaths as $key => $val) { |
377 | - $out .= '<div id="attachfile_' . $key . '">'; |
|
378 | - $out .= img_mime($listofnames[$key]) . ' ' . $listofnames[$key]; |
|
377 | + $out .= '<div id="attachfile_'.$key.'">'; |
|
378 | + $out .= img_mime($listofnames[$key]).' '.$listofnames[$key]; |
|
379 | 379 | if (!$this->withfilereadonly) { |
380 | - $out .= ' <input type="image" style="border: 0px;" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/delete.png" value="' . ($key + 1) . '" class="removedfile" id="removedfile_' . $key . '" name="removedfile_' . $key . '" />'; |
|
380 | + $out .= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key + 1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />'; |
|
381 | 381 | } |
382 | 382 | $out .= '<br></div>'; |
383 | 383 | } |
384 | 384 | } else { |
385 | - $out .= $langs->trans("NoAttachedFiles") . '<br>'; |
|
385 | + $out .= $langs->trans("NoAttachedFiles").'<br>'; |
|
386 | 386 | } |
387 | 387 | if ($this->withfile == 2) { // Can add other files |
388 | - $out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="' . $langs->trans("Upload") . '" />'; |
|
388 | + $out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />'; |
|
389 | 389 | $out .= ' '; |
390 | - $out .= '<input type="submit" class="button" id="addfile" name="addfile" value="' . $langs->trans("MailingAddFile") . '" />'; |
|
390 | + $out .= '<input type="submit" class="button" id="addfile" name="addfile" value="'.$langs->trans("MailingAddFile").'" />'; |
|
391 | 391 | } |
392 | 392 | $out .= "</td></tr>\n"; |
393 | 393 | |
@@ -406,11 +406,11 @@ discard block |
||
406 | 406 | if ($withdolfichehead) dol_fiche_end(); |
407 | 407 | |
408 | 408 | print '<center>'; |
409 | - print '<input class="button" type="submit" name="add_ticket" value="' . $langs->trans(($this->withthreadid > 0 ? "SendResponse" : "NewTicket")) . '" />'; |
|
409 | + print '<input class="button" type="submit" name="add_ticket" value="'.$langs->trans(($this->withthreadid > 0 ? "SendResponse" : "NewTicket")).'" />'; |
|
410 | 410 | |
411 | 411 | if ($this->withcancel) { |
412 | 412 | print " "; |
413 | - print "<input class=\"button\" type=\"submit\" name=\"cancel\" value=\"" . $langs->trans("Cancel") . "\">"; |
|
413 | + print "<input class=\"button\" type=\"submit\" name=\"cancel\" value=\"".$langs->trans("Cancel")."\">"; |
|
414 | 414 | } |
415 | 415 | print "</center>\n"; |
416 | 416 | |
@@ -431,13 +431,13 @@ discard block |
||
431 | 431 | * @param string $morecss More CSS |
432 | 432 | * @return void |
433 | 433 | */ |
434 | - public function selectTypesTickets($selected = '', $htmlname = 'tickettype', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss='') |
|
434 | + public function selectTypesTickets($selected = '', $htmlname = 'tickettype', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '') |
|
435 | 435 | { |
436 | 436 | global $langs, $user; |
437 | 437 | |
438 | 438 | $ticketstat = new Ticket($this->db); |
439 | 439 | |
440 | - dol_syslog(get_class($this) . "::select_types_tickets " . $selected . ", " . $htmlname . ", " . $filtertype . ", " . $format, LOG_DEBUG); |
|
440 | + dol_syslog(get_class($this)."::select_types_tickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); |
|
441 | 441 | |
442 | 442 | $filterarray = array(); |
443 | 443 | |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | |
448 | 448 | $ticketstat->loadCacheTypesTickets(); |
449 | 449 | |
450 | - print '<select id="select' . $htmlname . '" class="flat minwidth100'.($morecss?' '.$morecss:'').'" name="' . $htmlname . '">'; |
|
450 | + print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">'; |
|
451 | 451 | if ($empty) { |
452 | 452 | print '<option value=""> </option>'; |
453 | 453 | } |
@@ -465,19 +465,19 @@ discard block |
||
465 | 465 | } |
466 | 466 | |
467 | 467 | if ($format == 0) { |
468 | - print '<option value="' . $id . '"'; |
|
468 | + print '<option value="'.$id.'"'; |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | if ($format == 1) { |
472 | - print '<option value="' . $arraytypes['code'] . '"'; |
|
472 | + print '<option value="'.$arraytypes['code'].'"'; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | if ($format == 2) { |
476 | - print '<option value="' . $arraytypes['code'] . '"'; |
|
476 | + print '<option value="'.$arraytypes['code'].'"'; |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | if ($format == 3) { |
480 | - print '<option value="' . $id . '"'; |
|
480 | + print '<option value="'.$id.'"'; |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | // Si selected est text, on compare avec code, sinon avec id |
@@ -531,13 +531,13 @@ discard block |
||
531 | 531 | * @param string $morecss More CSS |
532 | 532 | * @return void |
533 | 533 | */ |
534 | - public function selectCategoriesTickets($selected = '', $htmlname = 'ticketcategory', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss='') |
|
534 | + public function selectCategoriesTickets($selected = '', $htmlname = 'ticketcategory', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '') |
|
535 | 535 | { |
536 | 536 | global $langs, $user; |
537 | 537 | |
538 | 538 | $ticketstat = new Ticket($this->db); |
539 | 539 | |
540 | - dol_syslog(get_class($this) . "::selectCategoryTickets " . $selected . ", " . $htmlname . ", " . $filtertype . ", " . $format, LOG_DEBUG); |
|
540 | + dol_syslog(get_class($this)."::selectCategoryTickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); |
|
541 | 541 | |
542 | 542 | $filterarray = array(); |
543 | 543 | |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | |
548 | 548 | $ticketstat->loadCacheCategoriesTickets(); |
549 | 549 | |
550 | - print '<select id="select' . $htmlname . '" class="flat minwidth100'.($morecss?' '.$morecss:'').'" name="' . $htmlname . '">'; |
|
550 | + print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">'; |
|
551 | 551 | if ($empty) { |
552 | 552 | print '<option value=""> </option>'; |
553 | 553 | } |
@@ -565,19 +565,19 @@ discard block |
||
565 | 565 | } |
566 | 566 | |
567 | 567 | if ($format == 0) { |
568 | - print '<option value="' . $id . '"'; |
|
568 | + print '<option value="'.$id.'"'; |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | if ($format == 1) { |
572 | - print '<option value="' . $arraycategories['code'] . '"'; |
|
572 | + print '<option value="'.$arraycategories['code'].'"'; |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | if ($format == 2) { |
576 | - print '<option value="' . $arraycategories['code'] . '"'; |
|
576 | + print '<option value="'.$arraycategories['code'].'"'; |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | if ($format == 3) { |
580 | - print '<option value="' . $id . '"'; |
|
580 | + print '<option value="'.$id.'"'; |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | // Si selected est text, on compare avec code, sinon avec id |
@@ -632,13 +632,13 @@ discard block |
||
632 | 632 | * @param string $morecss More CSS |
633 | 633 | * @return void |
634 | 634 | */ |
635 | - public function selectSeveritiesTickets($selected = '', $htmlname = 'ticketseverity', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss='') |
|
635 | + public function selectSeveritiesTickets($selected = '', $htmlname = 'ticketseverity', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '') |
|
636 | 636 | { |
637 | 637 | global $langs, $user; |
638 | 638 | |
639 | 639 | $ticketstat = new Ticket($this->db); |
640 | 640 | |
641 | - dol_syslog(get_class($this) . "::selectSeveritiesTickets " . $selected . ", " . $htmlname . ", " . $filtertype . ", " . $format, LOG_DEBUG); |
|
641 | + dol_syslog(get_class($this)."::selectSeveritiesTickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); |
|
642 | 642 | |
643 | 643 | $filterarray = array(); |
644 | 644 | |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | |
649 | 649 | $ticketstat->loadCacheSeveritiesTickets(); |
650 | 650 | |
651 | - print '<select id="select' . $htmlname . '" class="flat minwidth150'.($morecss?' '.$morecss:'').'" name="' . $htmlname . '">'; |
|
651 | + print '<select id="select'.$htmlname.'" class="flat minwidth150'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">'; |
|
652 | 652 | if ($empty) { |
653 | 653 | print '<option value=""> </option>'; |
654 | 654 | } |
@@ -666,19 +666,19 @@ discard block |
||
666 | 666 | } |
667 | 667 | |
668 | 668 | if ($format == 0) { |
669 | - print '<option value="' . $id . '"'; |
|
669 | + print '<option value="'.$id.'"'; |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | if ($format == 1) { |
673 | - print '<option value="' . $arrayseverities['code'] . '"'; |
|
673 | + print '<option value="'.$arrayseverities['code'].'"'; |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | if ($format == 2) { |
677 | - print '<option value="' . $arrayseverities['code'] . '"'; |
|
677 | + print '<option value="'.$arrayseverities['code'].'"'; |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | if ($format == 3) { |
681 | - print '<option value="' . $id . '"'; |
|
681 | + print '<option value="'.$id.'"'; |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | // Si selected est text, on compare avec code, sinon avec id |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { |
761 | 761 | $newlang = $this->param['langsmodels']; |
762 | 762 | } |
763 | - if (! empty($newlang)) { |
|
763 | + if (!empty($newlang)) { |
|
764 | 764 | $outputlangs = new Translate("", $conf); |
765 | 765 | $outputlangs->setDefaultLang($newlang); |
766 | 766 | $outputlangs->load('other'); |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | // Example 1 : Adding jquery code |
774 | 774 | print '<script type="text/javascript" language="javascript"> |
775 | 775 | jQuery(document).ready(function() { |
776 | - send_email=' . $send_email . '; |
|
776 | + send_email=' . $send_email.'; |
|
777 | 777 | if (send_email) { |
778 | 778 | jQuery(".email_line").show(); |
779 | 779 | } else { |
@@ -791,42 +791,42 @@ discard block |
||
791 | 791 | print '}); |
792 | 792 | </script>'; |
793 | 793 | |
794 | - print '<form method="post" name="ticket" enctype="multipart/form-data" action="' . $this->param["returnurl"] . '">'; |
|
795 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; |
|
796 | - print '<input type="hidden" name="action" value="' . $this->action . '">'; |
|
794 | + print '<form method="post" name="ticket" enctype="multipart/form-data" action="'.$this->param["returnurl"].'">'; |
|
795 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
796 | + print '<input type="hidden" name="action" value="'.$this->action.'">'; |
|
797 | 797 | foreach ($this->param as $key => $value) { |
798 | - print '<input type="hidden" name="' . $key . '" value="' . $value . '">'; |
|
798 | + print '<input type="hidden" name="'.$key.'" value="'.$value.'">'; |
|
799 | 799 | } |
800 | 800 | |
801 | 801 | // Get message template |
802 | - $model_id=0; |
|
802 | + $model_id = 0; |
|
803 | 803 | if (array_key_exists('models_id', $this->param)) { |
804 | - $model_id=$this->param["models_id"]; |
|
805 | - $arraydefaultmessage=$formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); |
|
804 | + $model_id = $this->param["models_id"]; |
|
805 | + $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); |
|
806 | 806 | } |
807 | 807 | |
808 | 808 | $result = $formmail->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs); |
809 | - if ($result<0) { |
|
809 | + if ($result < 0) { |
|
810 | 810 | setEventMessages($this->error, $this->errors, 'errors'); |
811 | 811 | } |
812 | - $modelmail_array=array(); |
|
812 | + $modelmail_array = array(); |
|
813 | 813 | foreach ($formmail->lines_model as $line) { |
814 | - $modelmail_array[$line->id]=$line->label; |
|
814 | + $modelmail_array[$line->id] = $line->label; |
|
815 | 815 | } |
816 | 816 | |
817 | - print '<table class="border" width="' . $width . '">'; |
|
817 | + print '<table class="border" width="'.$width.'">'; |
|
818 | 818 | |
819 | 819 | |
820 | 820 | // External users can't send message email |
821 | 821 | if ($user->rights->ticket->write && !$user->socid) { |
822 | 822 | print '<tr><td width="30%"></td><td colspan="2">'; |
823 | - $checkbox_selected = ( GETPOST('send_email') == "1" ? ' checked' : ''); |
|
823 | + $checkbox_selected = (GETPOST('send_email') == "1" ? ' checked' : ''); |
|
824 | 824 | print '<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.'/> '; |
825 | - print '<label for="send_msg_email">' . $langs->trans('SendMessageByEmail') . '</label>'; |
|
825 | + print '<label for="send_msg_email">'.$langs->trans('SendMessageByEmail').'</label>'; |
|
826 | 826 | print '</td></tr>'; |
827 | 827 | |
828 | 828 | // Zone to select its email template |
829 | - if (count($modelmail_array)>0) { |
|
829 | + if (count($modelmail_array) > 0) { |
|
830 | 830 | print '<tr class="email_line"><td></td><td colspan="2"><div style="padding: 3px 0 3px 0">'."\n"; |
831 | 831 | print $langs->trans('SelectMailModel').': '.$formmail->selectarray('modelmailselected', $modelmail_array, $this->param['models_id'], 1); |
832 | 832 | if ($user->admin) { |
@@ -841,32 +841,32 @@ discard block |
||
841 | 841 | // Substitution array |
842 | 842 | if ($this->withsubstit) { |
843 | 843 | print '<tr class="email_line"><td></td><td colspan="2">'; |
844 | - $help=""; |
|
844 | + $help = ""; |
|
845 | 845 | foreach ($this->substit as $key => $val) { |
846 | - $help.=$key.' -> '.$langs->trans($val).'<br>'; |
|
846 | + $help .= $key.' -> '.$langs->trans($val).'<br>'; |
|
847 | 847 | } |
848 | 848 | print $form->textwithpicto($langs->trans("TicketMessageSubstitutionReplacedByGenericValues"), $help); |
849 | 849 | print "</td></tr>"; |
850 | 850 | } |
851 | 851 | |
852 | - if (! $user->socid) { |
|
852 | + if (!$user->socid) { |
|
853 | 853 | print '<tr><td width="30%"></td><td>'; |
854 | - $checkbox_selected = ( GETPOST('private_message') == "1" ? ' checked' : ''); |
|
854 | + $checkbox_selected = (GETPOST('private_message') == "1" ? ' checked' : ''); |
|
855 | 855 | print '<input type="checkbox" name="private_message" value="1" id="private_message" '.$checkbox_selected.'/> '; |
856 | - print '<label for="private_message">' . $langs->trans('MarkMessageAsPrivate') . '</label>'; |
|
856 | + print '<label for="private_message">'.$langs->trans('MarkMessageAsPrivate').'</label>'; |
|
857 | 857 | print '</td><td align="center">'; |
858 | 858 | print $form->textwithpicto('', $langs->trans("TicketMessagePrivateHelp"), 1, 'help'); |
859 | 859 | print '</td></tr>'; |
860 | 860 | } |
861 | 861 | |
862 | 862 | |
863 | - print '<tr class="email_line"><td width=20%">' . $langs->trans('Subject') . '</td>'; |
|
863 | + print '<tr class="email_line"><td width=20%">'.$langs->trans('Subject').'</td>'; |
|
864 | 864 | $label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE; |
865 | - print '<td colspan="2"><input type="text" class="text" size="80" name="subject" value="[' . $label_title . ' - ticket #' . $this->track_id . '] ' . $langs->trans('TicketNewMessage') . '" />'; |
|
865 | + print '<td colspan="2"><input type="text" class="text" size="80" name="subject" value="['.$label_title.' - ticket #'.$this->track_id.'] '.$langs->trans('TicketNewMessage').'" />'; |
|
866 | 866 | print '</td></tr>'; |
867 | 867 | |
868 | 868 | // Destinataires |
869 | - print '<tr class="email_line"><td>' . $langs->trans('MailRecipients') . '</td><td colspan="2">'; |
|
869 | + print '<tr class="email_line"><td>'.$langs->trans('MailRecipients').'</td><td colspan="2">'; |
|
870 | 870 | $ticketstat = new Ticket($this->db); |
871 | 871 | $res = $ticketstat->fetch('', '', $this->track_id); |
872 | 872 | if ($res) { |
@@ -878,13 +878,13 @@ discard block |
||
878 | 878 | if (is_array($contacts) && count($contacts) > 0) { |
879 | 879 | foreach ($contacts as $key => $info_sendto) { |
880 | 880 | if ($info_sendto['email'] != '') { |
881 | - $sendto[] = dol_escape_htmltag(trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . "> (" . $info_sendto['libelle'] . ")"); |
|
881 | + $sendto[] = dol_escape_htmltag(trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email']."> (".$info_sendto['libelle'].")"); |
|
882 | 882 | } |
883 | 883 | } |
884 | 884 | } |
885 | 885 | |
886 | 886 | if ($ticketstat->origin_email && !in_array($this->dao->origin_email, $sendto)) { |
887 | - $sendto[] = $ticketstat->origin_email . "(origin)"; |
|
887 | + $sendto[] = $ticketstat->origin_email."(origin)"; |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | if ($ticketstat->fk_soc > 0) { |
@@ -892,19 +892,19 @@ discard block |
||
892 | 892 | $ticketstat->fetch_thirdparty(); |
893 | 893 | |
894 | 894 | if (is_array($ticketstat->thirdparty->email) && !in_array($ticketstat->thirdparty->email, $sendto)) { |
895 | - $sendto[] = $ticketstat->thirdparty->email . '(' . $langs->trans('Customer') . ')'; |
|
895 | + $sendto[] = $ticketstat->thirdparty->email.'('.$langs->trans('Customer').')'; |
|
896 | 896 | } |
897 | 897 | } |
898 | 898 | |
899 | 899 | if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS) { |
900 | - $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO . '(generic email)'; |
|
900 | + $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO.'(generic email)'; |
|
901 | 901 | } |
902 | 902 | |
903 | 903 | // Print recipient list |
904 | 904 | if (is_array($sendto) && count($sendto) > 0) { |
905 | 905 | print implode(', ', $sendto); |
906 | 906 | } else { |
907 | - print '<div class="warning">' . $langs->trans('WarningNoEMailsAdded') . ' ' . $langs->trans('TicketGoIntoContactTab') . '</div>'; |
|
907 | + print '<div class="warning">'.$langs->trans('WarningNoEMailsAdded').' '.$langs->trans('TicketGoIntoContactTab').'</div>'; |
|
908 | 908 | } |
909 | 909 | } |
910 | 910 | print '</td></tr>'; |
@@ -914,10 +914,10 @@ discard block |
||
914 | 914 | // External users can't send message email |
915 | 915 | if ($user->rights->ticket->write && !$user->socid) { |
916 | 916 | $mail_intro = GETPOST('mail_intro') ? GETPOST('mail_intro') : $conf->global->TICKET_MESSAGE_MAIL_INTRO; |
917 | - print '<tr class="email_line"><td><label for="mail_intro">' . $langs->trans("TicketMessageMailIntro") . '</label>'; |
|
917 | + print '<tr class="email_line"><td><label for="mail_intro">'.$langs->trans("TicketMessageMailIntro").'</label>'; |
|
918 | 918 | |
919 | 919 | print '</td><td>'; |
920 | - include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; |
|
920 | + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
|
921 | 921 | $uselocalbrowser = true; |
922 | 922 | |
923 | 923 | $doleditor = new DolEditor('mail_intro', $mail_intro, '100%', 140, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); |
@@ -929,11 +929,11 @@ discard block |
||
929 | 929 | } |
930 | 930 | |
931 | 931 | // MESSAGE |
932 | - $defaultmessage=""; |
|
932 | + $defaultmessage = ""; |
|
933 | 933 | if (is_array($arraydefaultmessage) && count($arraydefaultmessage) > 0 && $arraydefaultmessage->content) { |
934 | - $defaultmessage=$arraydefaultmessage->content; |
|
934 | + $defaultmessage = $arraydefaultmessage->content; |
|
935 | 935 | } |
936 | - $defaultmessage=str_replace('\n', "\n", $defaultmessage); |
|
936 | + $defaultmessage = str_replace('\n', "\n", $defaultmessage); |
|
937 | 937 | |
938 | 938 | // Deal with format differences between message and signature (text / HTML) |
939 | 939 | if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__SIGNATURE__'])) { |
@@ -941,17 +941,17 @@ discard block |
||
941 | 941 | } elseif (!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__SIGNATURE__'])) { |
942 | 942 | $defaultmessage = dol_nl2br($defaultmessage); |
943 | 943 | } |
944 | - if (isset($_POST["message"]) && ! $_POST['modelselected']) { |
|
945 | - $defaultmessage=GETPOST('message'); |
|
944 | + if (isset($_POST["message"]) && !$_POST['modelselected']) { |
|
945 | + $defaultmessage = GETPOST('message'); |
|
946 | 946 | } else { |
947 | - $defaultmessage=make_substitutions($defaultmessage, $this->substit); |
|
947 | + $defaultmessage = make_substitutions($defaultmessage, $this->substit); |
|
948 | 948 | // Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty) |
949 | - $defaultmessage=preg_replace("/^(<br>)+/", "", $defaultmessage); |
|
950 | - $defaultmessage=preg_replace("/^\n+/", "", $defaultmessage); |
|
949 | + $defaultmessage = preg_replace("/^(<br>)+/", "", $defaultmessage); |
|
950 | + $defaultmessage = preg_replace("/^\n+/", "", $defaultmessage); |
|
951 | 951 | } |
952 | 952 | |
953 | - print '<tr><td><label for="message"><span class="fieldrequired">' . $langs->trans("Message") . '</span></label></td><td>'; |
|
954 | - include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; |
|
953 | + print '<tr><td><label for="message"><span class="fieldrequired">'.$langs->trans("Message").'</span></label></td><td>'; |
|
954 | + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
|
955 | 955 | $doleditor = new DolEditor('message', $defaultmessage, '100%', 350, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); |
956 | 956 | $doleditor->Create(); |
957 | 957 | print '</td><td align="center">'; |
@@ -965,10 +965,10 @@ discard block |
||
965 | 965 | // External users can't send message email |
966 | 966 | if ($user->rights->ticket->write && !$user->socid) { |
967 | 967 | $mail_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE; |
968 | - print '<tr class="email_line"><td><label for="mail_intro">' . $langs->trans("TicketMessageMailSignature") . '</label>'; |
|
968 | + print '<tr class="email_line"><td><label for="mail_intro">'.$langs->trans("TicketMessageMailSignature").'</label>'; |
|
969 | 969 | |
970 | 970 | print '</td><td>'; |
971 | - include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; |
|
971 | + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
|
972 | 972 | $doleditor = new DolEditor('mail_signature', $mail_signature, '100%', 150, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); |
973 | 973 | $doleditor->Create(); |
974 | 974 | print '</td><td align="center">'; |
@@ -979,33 +979,33 @@ discard block |
||
979 | 979 | // Attached files |
980 | 980 | if (!empty($this->withfile)) { |
981 | 981 | $out .= '<tr>'; |
982 | - $out .= '<td width="180">' . $langs->trans("MailFile") . '</td>'; |
|
982 | + $out .= '<td width="180">'.$langs->trans("MailFile").'</td>'; |
|
983 | 983 | $out .= '<td colspan="2">'; |
984 | 984 | // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript |
985 | - $out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">' . "\n"; |
|
985 | + $out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">'."\n"; |
|
986 | 986 | $out .= '<script type="text/javascript" language="javascript">'; |
987 | 987 | $out .= 'jQuery(document).ready(function () {'; |
988 | 988 | $out .= ' jQuery(".removedfile").click(function() {'; |
989 | 989 | $out .= ' jQuery(".removedfilehidden").val(jQuery(this).val());'; |
990 | 990 | $out .= ' });'; |
991 | 991 | $out .= '})'; |
992 | - $out .= '</script>' . "\n"; |
|
992 | + $out .= '</script>'."\n"; |
|
993 | 993 | if (count($listofpaths)) { |
994 | 994 | foreach ($listofpaths as $key => $val) { |
995 | - $out .= '<div id="attachfile_' . $key . '">'; |
|
996 | - $out .= img_mime($listofnames[$key]) . ' ' . $listofnames[$key]; |
|
995 | + $out .= '<div id="attachfile_'.$key.'">'; |
|
996 | + $out .= img_mime($listofnames[$key]).' '.$listofnames[$key]; |
|
997 | 997 | if (!$this->withfilereadonly) { |
998 | - $out .= ' <input type="image" style="border: 0px;" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/delete.png" value="' . ($key + 1) . '" class="removedfile" id="removedfile_' . $key . '" name="removedfile_' . $key . '" />'; |
|
998 | + $out .= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key + 1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />'; |
|
999 | 999 | } |
1000 | 1000 | $out .= '<br></div>'; |
1001 | 1001 | } |
1002 | 1002 | } else { |
1003 | - $out .= $langs->trans("NoAttachedFiles") . '<br>'; |
|
1003 | + $out .= $langs->trans("NoAttachedFiles").'<br>'; |
|
1004 | 1004 | } |
1005 | 1005 | if ($this->withfile == 2) { // Can add other files |
1006 | - $out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="' . $langs->trans("Upload") . '" />'; |
|
1006 | + $out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />'; |
|
1007 | 1007 | $out .= ' '; |
1008 | - $out .= '<input type="submit" class="button" id="' . $addfileaction . '" name="' . $addfileaction . '" value="' . $langs->trans("MailingAddFile") . '" />'; |
|
1008 | + $out .= '<input type="submit" class="button" id="'.$addfileaction.'" name="'.$addfileaction.'" value="'.$langs->trans("MailingAddFile").'" />'; |
|
1009 | 1009 | } |
1010 | 1010 | $out .= "</td></tr>\n"; |
1011 | 1011 | |
@@ -1014,11 +1014,11 @@ discard block |
||
1014 | 1014 | |
1015 | 1015 | print '<tr><td colspan="3">'; |
1016 | 1016 | print '<center>'; |
1017 | - print '<input class="button" type="submit" name="btn_add_message" value="' . $langs->trans("AddMessage") . '" />'; |
|
1017 | + print '<input class="button" type="submit" name="btn_add_message" value="'.$langs->trans("AddMessage").'" />'; |
|
1018 | 1018 | |
1019 | 1019 | if ($this->withcancel) { |
1020 | 1020 | print " "; |
1021 | - print "<input class=\"button\" type=\"submit\" name=\"cancel\" value=\"" . $langs->trans("Cancel") . "\">"; |
|
1021 | + print "<input class=\"button\" type=\"submit\" name=\"cancel\" value=\"".$langs->trans("Cancel")."\">"; |
|
1022 | 1022 | } |
1023 | 1023 | print "</center>\n"; |
1024 | 1024 | print '</td></tr>'; |
@@ -147,7 +147,9 @@ discard block |
||
147 | 147 | |
148 | 148 | print "\n<!-- Begin form TICKETSUP -->\n"; |
149 | 149 | |
150 | - if ($withdolfichehead) dol_fiche_head(null, 'card', '', 0, ''); |
|
150 | + if ($withdolfichehead) { |
|
151 | + dol_fiche_head(null, 'card', '', 0, ''); |
|
152 | + } |
|
151 | 153 | |
152 | 154 | print '<form method="POST" '.($withdolfichehead?'':'style="margin-bottom: 30px;" ').'name="ticket" id="form_create_ticket" enctype="multipart/form-data" action="' . $this->param["returnurl"] . '">'; |
153 | 155 | print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; |
@@ -403,7 +405,9 @@ discard block |
||
403 | 405 | |
404 | 406 | print '</table>'; |
405 | 407 | |
406 | - if ($withdolfichehead) dol_fiche_end(); |
|
408 | + if ($withdolfichehead) { |
|
409 | + dol_fiche_end(); |
|
410 | + } |
|
407 | 411 | |
408 | 412 | print '<center>'; |
409 | 413 | print '<input class="button" type="submit" name="add_ticket" value="' . $langs->trans(($this->withthreadid > 0 ? "SendResponse" : "NewTicket")) . '" />'; |