@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | |
26 | 26 | require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/modules_barcode.class.php'; |
27 | -require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // This is to include def like $genbarcode_loc and $font_loc |
|
27 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // This is to include def like $genbarcode_loc and $font_loc |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Class to generate barcode images using tcpdf barcode generator |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | * Dolibarr version of the loaded document |
36 | 36 | * @public string |
37 | 37 | */ |
38 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @var string Error code (or message) |
42 | 42 | */ |
43 | - public $error=''; |
|
43 | + public $error = ''; |
|
44 | 44 | |
45 | 45 | public $is2d = false; |
46 | 46 | |
@@ -105,19 +105,19 @@ discard block |
||
105 | 105 | * @param integer $nooutputiferror No output if error (not used with this engine) |
106 | 106 | * @return int <0 if KO, >0 if OK |
107 | 107 | */ |
108 | - function buildBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0) |
|
108 | + function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) |
|
109 | 109 | { |
110 | 110 | global $_GET; |
111 | 111 | |
112 | 112 | $tcpdfEncoding = $this->getTcpdfEncodingType($encoding); |
113 | 113 | if (empty($tcpdfEncoding)) return -1; |
114 | 114 | |
115 | - $color = array(0,0,0); |
|
115 | + $color = array(0, 0, 0); |
|
116 | 116 | |
117 | - $_GET["code"]=$code; |
|
118 | - $_GET["type"]=$encoding; |
|
119 | - $_GET["height"]=$height; |
|
120 | - $_GET["readable"]=$readable; |
|
117 | + $_GET["code"] = $code; |
|
118 | + $_GET["type"] = $encoding; |
|
119 | + $_GET["height"] = $height; |
|
120 | + $_GET["readable"] = $readable; |
|
121 | 121 | |
122 | 122 | if ($code) { |
123 | 123 | // Load the tcpdf barcode class |
@@ -152,22 +152,22 @@ discard block |
||
152 | 152 | * @param integer $nooutputiferror No output if error (not used with this engine) |
153 | 153 | * @return int <0 if KO, >0 if OK |
154 | 154 | */ |
155 | - function writeBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0) |
|
155 | + function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) |
|
156 | 156 | { |
157 | - global $conf,$_GET; |
|
157 | + global $conf, $_GET; |
|
158 | 158 | |
159 | 159 | dol_mkdir($conf->barcode->dir_temp); |
160 | - $file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png'; |
|
160 | + $file = $conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png'; |
|
161 | 161 | |
162 | 162 | $tcpdfEncoding = $this->getTcpdfEncodingType($encoding); |
163 | 163 | if (empty($tcpdfEncoding)) return -1; |
164 | 164 | |
165 | - $color = array(0,0,0); |
|
165 | + $color = array(0, 0, 0); |
|
166 | 166 | |
167 | - $_GET["code"]=$code; |
|
168 | - $_GET["type"]=$encoding; |
|
169 | - $_GET["height"]=$height; |
|
170 | - $_GET["readable"]=$readable; |
|
167 | + $_GET["code"] = $code; |
|
168 | + $_GET["type"] = $encoding; |
|
169 | + $_GET["height"] = $height; |
|
170 | + $_GET["readable"] = $readable; |
|
171 | 171 | |
172 | 172 | if ($code) { |
173 | 173 | // Load the tcpdf barcode class |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | |
26 | 26 | require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/modules_barcode.class.php'; |
27 | -require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // This is to include def like $genbarcode_loc and $font_loc |
|
27 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // This is to include def like $genbarcode_loc and $font_loc |
|
28 | 28 | |
29 | 29 | |
30 | 30 | /** |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | * Dolibarr version of the loaded document |
37 | 37 | * @public string |
38 | 38 | */ |
39 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
39 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @var string Error code (or message) |
43 | 43 | */ |
44 | - public $error=''; |
|
44 | + public $error = ''; |
|
45 | 45 | |
46 | 46 | |
47 | 47 | /** |
@@ -95,17 +95,17 @@ discard block |
||
95 | 95 | global $genbarcode_loc; |
96 | 96 | //print 'genbarcode_loc='.$genbarcode_loc.' encoding='.$encoding;exit; |
97 | 97 | |
98 | - $supported=0; |
|
99 | - if ($encoding == 'EAN13') $supported=1; |
|
100 | - if ($encoding == 'ISBN') $supported=1; |
|
98 | + $supported = 0; |
|
99 | + if ($encoding == 'EAN13') $supported = 1; |
|
100 | + if ($encoding == 'ISBN') $supported = 1; |
|
101 | 101 | // Formats that hangs on Windows (when genbarcode.exe for Windows is called, so they are not |
102 | 102 | // activated on Windows) |
103 | 103 | if (file_exists($genbarcode_loc) && empty($_SERVER["WINDIR"])) |
104 | 104 | { |
105 | - if ($encoding == 'EAN8') $supported=1; |
|
106 | - if ($encoding == 'UPC') $supported=1; |
|
107 | - if ($encoding == 'C39') $supported=1; |
|
108 | - if ($encoding == 'C128') $supported=1; |
|
105 | + if ($encoding == 'EAN8') $supported = 1; |
|
106 | + if ($encoding == 'UPC') $supported = 1; |
|
107 | + if ($encoding == 'C39') $supported = 1; |
|
108 | + if ($encoding == 'C128') $supported = 1; |
|
109 | 109 | } |
110 | 110 | return $supported; |
111 | 111 | } |
@@ -120,30 +120,30 @@ discard block |
||
120 | 120 | * @param integer $nooutputiferror No output if error |
121 | 121 | * @return int <0 if KO, >0 if OK |
122 | 122 | */ |
123 | - function buildBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0) |
|
123 | + function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) |
|
124 | 124 | { |
125 | - global $_GET,$_SERVER; |
|
125 | + global $_GET, $_SERVER; |
|
126 | 126 | global $conf; |
127 | 127 | global $genbarcode_loc, $bar_color, $bg_color, $text_color, $font_loc; |
128 | 128 | |
129 | - if (! $this->encodingIsSupported($encoding)) return -1; |
|
129 | + if (!$this->encodingIsSupported($encoding)) return -1; |
|
130 | 130 | |
131 | 131 | if ($encoding == 'EAN8' || $encoding == 'EAN13') $encoding = 'EAN'; |
132 | - if ($encoding == 'C39' || $encoding == 'C128') $encoding = substr($encoding,1); |
|
132 | + if ($encoding == 'C39' || $encoding == 'C128') $encoding = substr($encoding, 1); |
|
133 | 133 | |
134 | - $mode='png'; |
|
134 | + $mode = 'png'; |
|
135 | 135 | |
136 | - $_GET["code"]=$code; |
|
137 | - $_GET["encoding"]=$encoding; |
|
138 | - $_GET["scale"]=$scale; |
|
139 | - $_GET["mode"]=$mode; |
|
136 | + $_GET["code"] = $code; |
|
137 | + $_GET["encoding"] = $encoding; |
|
138 | + $_GET["scale"] = $scale; |
|
139 | + $_GET["mode"] = $mode; |
|
140 | 140 | |
141 | 141 | dol_syslog(get_class($this)."::buildBarCode $code,$encoding,$scale,$mode"); |
142 | - if ($code) $result=barcode_print($code,$encoding,$scale,$mode); |
|
142 | + if ($code) $result = barcode_print($code, $encoding, $scale, $mode); |
|
143 | 143 | |
144 | - if (! is_array($result)) |
|
144 | + if (!is_array($result)) |
|
145 | 145 | { |
146 | - $this->error=$result; |
|
146 | + $this->error = $result; |
|
147 | 147 | if (empty($nooutputiferror)) print $this->error; |
148 | 148 | return -1; |
149 | 149 | } |
@@ -161,17 +161,17 @@ discard block |
||
161 | 161 | * @param integer $nooutputiferror No output if error |
162 | 162 | * @return int <0 if KO, >0 if OK |
163 | 163 | */ |
164 | - function writeBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0) |
|
164 | + function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) |
|
165 | 165 | { |
166 | - global $conf,$filebarcode; |
|
166 | + global $conf, $filebarcode; |
|
167 | 167 | |
168 | 168 | dol_mkdir($conf->barcode->dir_temp); |
169 | 169 | |
170 | - $file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png'; |
|
170 | + $file = $conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png'; |
|
171 | 171 | |
172 | - $filebarcode=$file; // global var to be used in barcode_outimage called by barcode_print in buildBarCode |
|
172 | + $filebarcode = $file; // global var to be used in barcode_outimage called by barcode_print in buildBarCode |
|
173 | 173 | |
174 | - $result=$this->buildBarCode($code,$encoding,$readable,$scale,$nooutputiferror); |
|
174 | + $result = $this->buildBarCode($code, $encoding, $readable, $scale, $nooutputiferror); |
|
175 | 175 | |
176 | 176 | return $result; |
177 | 177 | } |
@@ -33,23 +33,23 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class mod_barcode_product_standard extends ModeleNumRefBarCode |
35 | 35 | { |
36 | - public $name='Standard'; // Model Name |
|
36 | + public $name = 'Standard'; // Model Name |
|
37 | 37 | |
38 | - public $code_modifiable; // Editable code |
|
38 | + public $code_modifiable; // Editable code |
|
39 | 39 | |
40 | - public $code_modifiable_invalide; // Modified code if it is invalid |
|
40 | + public $code_modifiable_invalide; // Modified code if it is invalid |
|
41 | 41 | |
42 | - public $code_modifiable_null; // Modified code if it is null |
|
42 | + public $code_modifiable_null; // Modified code if it is null |
|
43 | 43 | |
44 | - public $code_null; // Optional code |
|
44 | + public $code_null; // Optional code |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Dolibarr version of the loaded document |
48 | 48 | * @public string |
49 | 49 | */ |
50 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
50 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
51 | 51 | |
52 | - public $code_auto; // Automatic Numbering |
|
52 | + public $code_auto; // Automatic Numbering |
|
53 | 53 | |
54 | 54 | public $searchcode; // Search string |
55 | 55 | |
@@ -84,29 +84,29 @@ discard block |
||
84 | 84 | |
85 | 85 | $langs->load("products"); |
86 | 86 | |
87 | - $disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); |
|
87 | + $disabled = ((!empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); |
|
88 | 88 | |
89 | 89 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
90 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
91 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
92 | - $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
93 | - $texte.= '<input type="hidden" name="param1" value="BARCODE_STANDARD_PRODUCT_MASK">'; |
|
94 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
90 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
91 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
92 | + $texte .= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
93 | + $texte .= '<input type="hidden" name="param1" value="BARCODE_STANDARD_PRODUCT_MASK">'; |
|
94 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
95 | 95 | |
96 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("BarCode"),$langs->transnoentities("BarCode")); |
|
97 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
98 | - $tooltip.=$langs->trans("GenericMaskCodes4c"); |
|
99 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
96 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("BarCode"), $langs->transnoentities("BarCode")); |
|
97 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
98 | + $tooltip .= $langs->trans("GenericMaskCodes4c"); |
|
99 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
100 | 100 | |
101 | 101 | // Mask parameter |
102 | 102 | //$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("BarCodeModel").'):</td>'; |
103 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
104 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?$conf->global->BARCODE_STANDARD_PRODUCT_MASK:'').'"'.$disabled.'>',$tooltip,1,1).'</td>'; |
|
105 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>'; |
|
106 | - $texte.= '</tr>'; |
|
103 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
104 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(!empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK) ? $conf->global->BARCODE_STANDARD_PRODUCT_MASK : '').'"'.$disabled.'>', $tooltip, 1, 1).'</td>'; |
|
105 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>'; |
|
106 | + $texte .= '</tr>'; |
|
107 | 107 | |
108 | - $texte.= '</table>'; |
|
109 | - $texte.= '</form>'; |
|
108 | + $texte .= '</table>'; |
|
109 | + $texte .= '</form>'; |
|
110 | 110 | |
111 | 111 | return $texte; |
112 | 112 | } |
@@ -119,17 +119,17 @@ discard block |
||
119 | 119 | * @param Product $objproduct Object product |
120 | 120 | * @return string Return string example |
121 | 121 | */ |
122 | - function getExample($langs,$objproduct=0) |
|
122 | + function getExample($langs, $objproduct = 0) |
|
123 | 123 | { |
124 | - $examplebarcode = $this->getNextValue($objproduct,''); |
|
125 | - if (! $examplebarcode) |
|
124 | + $examplebarcode = $this->getNextValue($objproduct, ''); |
|
125 | + if (!$examplebarcode) |
|
126 | 126 | { |
127 | 127 | $examplebarcode = $langs->trans('NotConfigured'); |
128 | 128 | } |
129 | - if($examplebarcode=="ErrorBadMask") |
|
129 | + if ($examplebarcode == "ErrorBadMask") |
|
130 | 130 | { |
131 | 131 | $langs->load("errors"); |
132 | - $examplebarcode=$langs->trans($examplebarcode); |
|
132 | + $examplebarcode = $langs->trans($examplebarcode); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | return $examplebarcode; |
@@ -142,29 +142,29 @@ discard block |
||
142 | 142 | * @param string $type Type of barcode (EAN, ISBN, ...) |
143 | 143 | * @return string Value if OK, '' if module not configured, <0 if KO |
144 | 144 | */ |
145 | - function getNextValue($objproduct=null,$type='') |
|
145 | + function getNextValue($objproduct = null, $type = '') |
|
146 | 146 | { |
147 | - global $db,$conf; |
|
147 | + global $db, $conf; |
|
148 | 148 | |
149 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
149 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
150 | 150 | |
151 | 151 | // TODO |
152 | 152 | |
153 | 153 | // Get Mask value |
154 | 154 | $mask = ''; |
155 | - if (! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) $mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK; |
|
155 | + if (!empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) $mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK; |
|
156 | 156 | |
157 | 157 | if (empty($mask)) |
158 | 158 | { |
159 | - $this->error='NotConfigured'; |
|
159 | + $this->error = 'NotConfigured'; |
|
160 | 160 | return ''; |
161 | 161 | } |
162 | 162 | |
163 | - $field='barcode';$where=''; |
|
163 | + $field = 'barcode'; $where = ''; |
|
164 | 164 | |
165 | - $now=dol_now(); |
|
165 | + $now = dol_now(); |
|
166 | 166 | |
167 | - $numFinal=get_next_value($db,$mask,'product',$field,$where,'',$now); |
|
167 | + $numFinal = get_next_value($db, $mask, 'product', $field, $where, '', $now); |
|
168 | 168 | |
169 | 169 | return $numFinal; |
170 | 170 | } |
@@ -190,18 +190,18 @@ discard block |
||
190 | 190 | |
191 | 191 | //var_dump($code.' '.$product->ref.' '.$thirdparty_type);exit; |
192 | 192 | |
193 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
193 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
194 | 194 | |
195 | - $result=0; |
|
195 | + $result = 0; |
|
196 | 196 | $code = strtoupper(trim($code)); |
197 | 197 | |
198 | 198 | if (empty($code) && $this->code_null && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) |
199 | 199 | { |
200 | - $result=0; |
|
200 | + $result = 0; |
|
201 | 201 | } |
202 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) ) |
|
202 | + else if (empty($code) && (!$this->code_null || !empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK))) |
|
203 | 203 | { |
204 | - $result=-2; |
|
204 | + $result = -2; |
|
205 | 205 | } |
206 | 206 | else |
207 | 207 | { |
@@ -210,22 +210,22 @@ discard block |
||
210 | 210 | $is_dispo = $this->verif_dispo($db, $code, $product); |
211 | 211 | if ($is_dispo <> 0) |
212 | 212 | { |
213 | - $result=-3; |
|
213 | + $result = -3; |
|
214 | 214 | } |
215 | 215 | else |
216 | 216 | { |
217 | - $result=0; |
|
217 | + $result = 0; |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | else |
221 | 221 | { |
222 | 222 | if (dol_strlen($code) == 0) |
223 | 223 | { |
224 | - $result=-2; |
|
224 | + $result = -2; |
|
225 | 225 | } |
226 | 226 | else |
227 | 227 | { |
228 | - $result=-1; |
|
228 | + $result = -1; |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | } |
@@ -248,10 +248,10 @@ discard block |
||
248 | 248 | { |
249 | 249 | // phpcs:enable |
250 | 250 | $sql = "SELECT barcode FROM ".MAIN_DB_PREFIX."product"; |
251 | - $sql.= " WHERE barcode = '".$code."'"; |
|
252 | - if ($product->id > 0) $sql.= " AND rowid <> ".$product->id; |
|
251 | + $sql .= " WHERE barcode = '".$code."'"; |
|
252 | + if ($product->id > 0) $sql .= " AND rowid <> ".$product->id; |
|
253 | 253 | |
254 | - $resql=$db->query($sql); |
|
254 | + $resql = $db->query($sql); |
|
255 | 255 | if ($resql) |
256 | 256 | { |
257 | 257 | if ($db->num_rows($resql) == 0) |
@@ -285,28 +285,28 @@ discard block |
||
285 | 285 | $result = 0; |
286 | 286 | |
287 | 287 | // Get Mask value |
288 | - $mask = empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?'':$conf->global->BARCODE_STANDARD_PRODUCT_MASK; |
|
289 | - if (! $mask) |
|
288 | + $mask = empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK) ? '' : $conf->global->BARCODE_STANDARD_PRODUCT_MASK; |
|
289 | + if (!$mask) |
|
290 | 290 | { |
291 | - $this->error='NotConfigured'; |
|
291 | + $this->error = 'NotConfigured'; |
|
292 | 292 | return -1; |
293 | 293 | } |
294 | 294 | |
295 | 295 | dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest); |
296 | 296 | |
297 | - $newcodefortest=$codefortest; |
|
297 | + $newcodefortest = $codefortest; |
|
298 | 298 | |
299 | 299 | // Special case, if mask is on 12 digits instead of 13, we remove last char into code to test |
300 | - if (in_array($typefortest,array('EAN13','ISBN'))) // We remove the CRC char not included into mask |
|
300 | + if (in_array($typefortest, array('EAN13', 'ISBN'))) // We remove the CRC char not included into mask |
|
301 | 301 | { |
302 | - if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg)) |
|
302 | + if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) |
|
303 | 303 | { |
304 | - if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest,0,12); |
|
304 | + if (strlen($reg[1]) == 12) $newcodefortest = substr($newcodefortest, 0, 12); |
|
305 | 305 | dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest); |
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
309 | - $result=check_value($mask,$newcodefortest); |
|
309 | + $result = check_value($mask, $newcodefortest); |
|
310 | 310 | if (is_string($result)) |
311 | 311 | { |
312 | 312 | $this->error = $result; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @var string Error code (or message) |
34 | 34 | */ |
35 | - public $error=''; |
|
35 | + public $error = ''; |
|
36 | 36 | |
37 | 37 | |
38 | 38 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * @var string Error code (or message) |
57 | 57 | */ |
58 | - public $error=''; |
|
58 | + public $error = ''; |
|
59 | 59 | |
60 | 60 | /** Return default description of numbering model |
61 | 61 | * |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | function getNom($langs) |
77 | 77 | { |
78 | - return empty($this->name)?$this->nom:$this->name; |
|
78 | + return empty($this->name) ? $this->nom : $this->name; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** Return a numbering example |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param string $type Type of barcode (EAN, ISBN, ...) |
97 | 97 | * @return string Value |
98 | 98 | */ |
99 | - function getNextValue($objproduct,$type='') |
|
99 | + function getNextValue($objproduct, $type = '') |
|
100 | 100 | { |
101 | 101 | global $langs; |
102 | 102 | return $langs->trans("Function_getNextValue_InModuleNotWorking"); |
@@ -126,53 +126,53 @@ discard block |
||
126 | 126 | * @param int $type -1=Nothing, 0=Product, 1=Service |
127 | 127 | * @return string HTML translated description |
128 | 128 | */ |
129 | - function getToolTip($langs,$soc,$type) |
|
129 | + function getToolTip($langs, $soc, $type) |
|
130 | 130 | { |
131 | 131 | global $conf; |
132 | 132 | |
133 | 133 | $langs->load("admin"); |
134 | 134 | |
135 | - $s=''; |
|
136 | - $s.=$langs->trans("Name").': <b>'.$this->name.'</b><br>'; |
|
137 | - $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
138 | - if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
139 | - $s.='<br>'; |
|
140 | - $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
|
135 | + $s = ''; |
|
136 | + $s .= $langs->trans("Name").': <b>'.$this->name.'</b><br>'; |
|
137 | + $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
138 | + if ($type != -1) $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
139 | + $s .= '<br>'; |
|
140 | + $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
|
141 | 141 | if ($type == 0) |
142 | 142 | { |
143 | - $s.=$langs->trans("RequiredIfProduct").': '; |
|
144 | - if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
145 | - $s.=yn(!$this->code_null,1,2); |
|
146 | - if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
147 | - $s.='<br>'; |
|
143 | + $s .= $langs->trans("RequiredIfProduct").': '; |
|
144 | + if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>'; |
|
145 | + $s .= yn(!$this->code_null, 1, 2); |
|
146 | + if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')'; |
|
147 | + $s .= '<br>'; |
|
148 | 148 | } |
149 | 149 | if ($type == 1) |
150 | 150 | { |
151 | - $s.=$langs->trans("RequiredIfService").': '; |
|
152 | - if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
153 | - $s.=yn(!$this->code_null,1,2); |
|
154 | - if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
155 | - $s.='<br>'; |
|
151 | + $s .= $langs->trans("RequiredIfService").': '; |
|
152 | + if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>'; |
|
153 | + $s .= yn(!$this->code_null, 1, 2); |
|
154 | + if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')'; |
|
155 | + $s .= '<br>'; |
|
156 | 156 | } |
157 | 157 | if ($type == -1) |
158 | 158 | { |
159 | - $s.=$langs->trans("Required").': '; |
|
160 | - if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
161 | - $s.=yn(!$this->code_null,1,2); |
|
162 | - if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
163 | - $s.='<br>'; |
|
159 | + $s .= $langs->trans("Required").': '; |
|
160 | + if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>'; |
|
161 | + $s .= yn(!$this->code_null, 1, 2); |
|
162 | + if (!empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')'; |
|
163 | + $s .= '<br>'; |
|
164 | 164 | } |
165 | 165 | /*$s.=$langs->trans("CanBeModifiedIfOk").': '; |
166 | 166 | $s.=yn($this->code_modifiable,1,2); |
167 | 167 | $s.='<br>'; |
168 | 168 | $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>'; |
169 | 169 | */ |
170 | - $s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>'; |
|
171 | - $s.='<br>'; |
|
170 | + $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>'; |
|
171 | + $s .= '<br>'; |
|
172 | 172 | |
173 | - $nextval=$this->getNextValue($soc,''); |
|
174 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
175 | - $s.=$langs->trans("NextValue").': <b>'.$nextval.'</b><br>'; |
|
173 | + $nextval = $this->getNextValue($soc, ''); |
|
174 | + if (empty($nextval)) $nextval = $langs->trans("Undefined"); |
|
175 | + $s .= $langs->trans("NextValue").': <b>'.$nextval.'</b><br>'; |
|
176 | 176 | |
177 | 177 | return $s; |
178 | 178 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * \ingroup ldap |
25 | 25 | * \brief File to describe and activate Ldap module |
26 | 26 | */ |
27 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
27 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
28 | 28 | |
29 | 29 | |
30 | 30 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | // Module position in the family on 2 digits ('01', '10', '20', ...) |
47 | 47 | $this->module_position = '30'; |
48 | 48 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
49 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
49 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
50 | 50 | $this->description = "Synchronisation Ldap"; |
51 | 51 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
52 | 52 | $this->version = 'dolibarr'; |
@@ -63,28 +63,28 @@ discard block |
||
63 | 63 | $this->config_page_url = array("ldap.php"); |
64 | 64 | |
65 | 65 | // Dependencies |
66 | - $this->hidden = false; // A condition to hide module |
|
67 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
68 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
69 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
70 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
66 | + $this->hidden = false; // A condition to hide module |
|
67 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
68 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
69 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
70 | + $this->phpmin = array(5, 4); // Minimum version of PHP required by module |
|
71 | 71 | |
72 | 72 | // Constants |
73 | 73 | $this->const = array( |
74 | - 0=>array('LDAP_SERVER_TYPE','chaine','openldap','',0), |
|
75 | - 1=>array('LDAP_SERVER_PROTOCOLVERSION','chaine','3','',0), |
|
76 | - 2=>array('LDAP_SERVER_HOST','chaine','localhost','',0), |
|
77 | - 3=>array('LDAP_USER_DN','chaine','ou=users,dc=example,dc=com','',0), |
|
78 | - 4=>array('LDAP_GROUP_DN','chaine','ou=groups,dc=example,dc=com','',0), |
|
79 | - 5=>array('LDAP_FILTER_CONNECTION','chaine','&(objectClass=inetOrgPerson)','',0), |
|
80 | - 6=>array('LDAP_FIELD_LOGIN','chaine','uid','',0), |
|
81 | - 7=>array('LDAP_FIELD_FULLNAME','chaine','cn','',0), |
|
82 | - 8=>array('LDAP_FIELD_NAME','chaine','sn','',0), |
|
83 | - 9=>array('LDAP_FIELD_FIRSTNAME','chaine','givenname','',0), |
|
84 | - 10=>array('LDAP_FIELD_MAIL','chaine','mail','',0), |
|
85 | - 11=>array('LDAP_FIELD_PHONE','chaine','telephonenumber','',0), |
|
86 | - 12=>array('LDAP_FIELD_FAX','chaine','facsimiletelephonenumber','',0), |
|
87 | - 13=>array('LDAP_FIELD_MOBILE','chaine','mobile','',0), |
|
74 | + 0=>array('LDAP_SERVER_TYPE', 'chaine', 'openldap', '', 0), |
|
75 | + 1=>array('LDAP_SERVER_PROTOCOLVERSION', 'chaine', '3', '', 0), |
|
76 | + 2=>array('LDAP_SERVER_HOST', 'chaine', 'localhost', '', 0), |
|
77 | + 3=>array('LDAP_USER_DN', 'chaine', 'ou=users,dc=example,dc=com', '', 0), |
|
78 | + 4=>array('LDAP_GROUP_DN', 'chaine', 'ou=groups,dc=example,dc=com', '', 0), |
|
79 | + 5=>array('LDAP_FILTER_CONNECTION', 'chaine', '&(objectClass=inetOrgPerson)', '', 0), |
|
80 | + 6=>array('LDAP_FIELD_LOGIN', 'chaine', 'uid', '', 0), |
|
81 | + 7=>array('LDAP_FIELD_FULLNAME', 'chaine', 'cn', '', 0), |
|
82 | + 8=>array('LDAP_FIELD_NAME', 'chaine', 'sn', '', 0), |
|
83 | + 9=>array('LDAP_FIELD_FIRSTNAME', 'chaine', 'givenname', '', 0), |
|
84 | + 10=>array('LDAP_FIELD_MAIL', 'chaine', 'mail', '', 0), |
|
85 | + 11=>array('LDAP_FIELD_PHONE', 'chaine', 'telephonenumber', '', 0), |
|
86 | + 12=>array('LDAP_FIELD_FAX', 'chaine', 'facsimiletelephonenumber', '', 0), |
|
87 | + 13=>array('LDAP_FIELD_MOBILE', 'chaine', 'mobile', '', 0), |
|
88 | 88 | ); |
89 | 89 | |
90 | 90 | // Boxes |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * \brief Fichier de description et activation du module Import |
25 | 25 | */ |
26 | 26 | |
27 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
27 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
28 | 28 | |
29 | 29 | |
30 | 30 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $this->family = "technic"; |
47 | 47 | $this->module_position = '70'; |
48 | 48 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
49 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
49 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
50 | 50 | $this->description = "Outils d'imports de donnees Dolibarr (via un assistant)"; |
51 | 51 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version |
52 | 52 | $this->version = 'dolibarr'; |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | $this->config_page_url = array(); |
61 | 61 | |
62 | 62 | // Dependencies |
63 | - $this->hidden = false; // A condition to hide module |
|
64 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
65 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
66 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
67 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module - Need auto_detect_line_endings php option to solve MAC pbs. |
|
63 | + $this->hidden = false; // A condition to hide module |
|
64 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
65 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
66 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
67 | + $this->phpmin = array(5, 4); // Minimum version of PHP required by module - Need auto_detect_line_endings php option to solve MAC pbs. |
|
68 | 68 | $this->phpmax = array(); |
69 | - $this->need_dolibarr_version = array(2,7,-1); // Minimum version of Dolibarr required by module |
|
69 | + $this->need_dolibarr_version = array(2, 7, -1); // Minimum version of Dolibarr required by module |
|
70 | 70 | $this->need_javascript_ajax = 1; |
71 | 71 | |
72 | 72 | // Constants |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | // Permissions |
79 | 79 | $this->rights = array(); |
80 | 80 | $this->rights_class = 'import'; |
81 | - $r=0; |
|
81 | + $r = 0; |
|
82 | 82 | |
83 | 83 | $r++; |
84 | 84 | $this->rights[$r][0] = 1251; |
@@ -90,6 +90,6 @@ discard block |
||
90 | 90 | |
91 | 91 | // Menus |
92 | 92 | //------- |
93 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
93 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
94 | 94 | } |
95 | 95 | } |
@@ -67,37 +67,37 @@ discard block |
||
67 | 67 | global $conf, $langs, $mysoc; |
68 | 68 | |
69 | 69 | // Load translation files required by the page |
70 | - $langs->loadLangs(array("main","companies")); |
|
70 | + $langs->loadLangs(array("main", "companies")); |
|
71 | 71 | |
72 | 72 | $this->db = $db; |
73 | 73 | $this->name = "ODT templates"; |
74 | 74 | $this->description = $langs->trans("DocumentModelOdt"); |
75 | - $this->scandir = 'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
75 | + $this->scandir = 'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
76 | 76 | |
77 | 77 | // Dimension page pour format A4 |
78 | 78 | $this->type = 'odt'; |
79 | 79 | $this->page_largeur = 0; |
80 | 80 | $this->page_hauteur = 0; |
81 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
82 | - $this->marge_gauche=0; |
|
83 | - $this->marge_droite=0; |
|
84 | - $this->marge_haute=0; |
|
85 | - $this->marge_basse=0; |
|
86 | - |
|
87 | - $this->option_logo = 1; // Affiche logo |
|
88 | - $this->option_tva = 0; // Gere option tva PROPALE_TVAOPTION |
|
89 | - $this->option_modereg = 0; // Affiche mode reglement |
|
90 | - $this->option_condreg = 0; // Affiche conditions reglement |
|
91 | - $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
92 | - $this->option_multilang = 1; // Dispo en plusieurs langues |
|
93 | - $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
94 | - $this->option_credit_note = 0; // Support credit notes |
|
95 | - $this->option_freetext = 1; // Support add of a personalised text |
|
96 | - $this->option_draft_watermark = 0; // Support add of a watermark on drafts |
|
81 | + $this->format = array($this->page_largeur, $this->page_hauteur); |
|
82 | + $this->marge_gauche = 0; |
|
83 | + $this->marge_droite = 0; |
|
84 | + $this->marge_haute = 0; |
|
85 | + $this->marge_basse = 0; |
|
86 | + |
|
87 | + $this->option_logo = 1; // Affiche logo |
|
88 | + $this->option_tva = 0; // Gere option tva PROPALE_TVAOPTION |
|
89 | + $this->option_modereg = 0; // Affiche mode reglement |
|
90 | + $this->option_condreg = 0; // Affiche conditions reglement |
|
91 | + $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
92 | + $this->option_multilang = 1; // Dispo en plusieurs langues |
|
93 | + $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
94 | + $this->option_credit_note = 0; // Support credit notes |
|
95 | + $this->option_freetext = 1; // Support add of a personalised text |
|
96 | + $this->option_draft_watermark = 0; // Support add of a watermark on drafts |
|
97 | 97 | |
98 | 98 | // Recupere emetteur |
99 | - $this->emetteur=$mysoc; |
|
100 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
99 | + $this->emetteur = $mysoc; |
|
100 | + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -117,106 +117,106 @@ discard block |
||
117 | 117 | $form = new Form($this->db); |
118 | 118 | |
119 | 119 | $texte = $this->description.".<br>\n"; |
120 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
121 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
122 | - $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
123 | - $texte.= '<input type="hidden" name="param1" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH">'; |
|
120 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
121 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
122 | + $texte .= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
123 | + $texte .= '<input type="hidden" name="param1" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH">'; |
|
124 | 124 | if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0) |
125 | 125 | { |
126 | - $texte.= '<input type="hidden" name="param2" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT">'; |
|
127 | - $texte.= '<input type="hidden" name="param3" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL">'; |
|
128 | - $texte.= '<input type="hidden" name="param4" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED">'; |
|
126 | + $texte .= '<input type="hidden" name="param2" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT">'; |
|
127 | + $texte .= '<input type="hidden" name="param3" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL">'; |
|
128 | + $texte .= '<input type="hidden" name="param4" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED">'; |
|
129 | 129 | } |
130 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
130 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
131 | 131 | |
132 | 132 | // List of directories area |
133 | - $texte.= '<tr><td>'; |
|
134 | - $texttitle=$langs->trans("ListOfDirectories"); |
|
135 | - $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH))); |
|
136 | - $listoffiles=array(); |
|
137 | - foreach($listofdir as $key=>$tmpdir) |
|
133 | + $texte .= '<tr><td>'; |
|
134 | + $texttitle = $langs->trans("ListOfDirectories"); |
|
135 | + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH))); |
|
136 | + $listoffiles = array(); |
|
137 | + foreach ($listofdir as $key=>$tmpdir) |
|
138 | 138 | { |
139 | - $tmpdir=trim($tmpdir); |
|
140 | - $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
|
141 | - if (! $tmpdir) { |
|
139 | + $tmpdir = trim($tmpdir); |
|
140 | + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); |
|
141 | + if (!$tmpdir) { |
|
142 | 142 | unset($listofdir[$key]); continue; |
143 | 143 | } |
144 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
144 | + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); |
|
145 | 145 | else |
146 | 146 | { |
147 | - $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
|
148 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
147 | + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); |
|
148 | + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); |
|
149 | 149 | } |
150 | 150 | } |
151 | - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
|
151 | + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); |
|
152 | 152 | // Add list of substitution keys |
153 | - $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
154 | - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
155 | - |
|
156 | - $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); |
|
157 | - $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">'; |
|
158 | - $texte.= '<textarea class="flat" cols="60" name="value1">'; |
|
159 | - $texte.=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH; |
|
160 | - $texte.= '</textarea>'; |
|
161 | - $texte.= '</div><div style="display: inline-block; vertical-align: middle;">'; |
|
162 | - $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">'; |
|
163 | - $texte.= '<br></div></div>'; |
|
153 | + $texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
154 | + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
155 | + |
|
156 | + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); |
|
157 | + $texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">'; |
|
158 | + $texte .= '<textarea class="flat" cols="60" name="value1">'; |
|
159 | + $texte .= $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH; |
|
160 | + $texte .= '</textarea>'; |
|
161 | + $texte .= '</div><div style="display: inline-block; vertical-align: middle;">'; |
|
162 | + $texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">'; |
|
163 | + $texte .= '<br></div></div>'; |
|
164 | 164 | |
165 | 165 | // Scan directories |
166 | - $nbofiles=count($listoffiles); |
|
167 | - if (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH)) |
|
166 | + $nbofiles = count($listoffiles); |
|
167 | + if (!empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH)) |
|
168 | 168 | { |
169 | - $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'; |
|
169 | + $texte .= $langs->trans("NumberOfModelFilesFound").': <b>'; |
|
170 | 170 | //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':''; |
171 | - $texte.=count($listoffiles); |
|
171 | + $texte .= count($listoffiles); |
|
172 | 172 | //$texte.=$nbofiles?'</a>':''; |
173 | - $texte.='</b>'; |
|
173 | + $texte .= '</b>'; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | if ($nbofiles) |
177 | 177 | { |
178 | - $texte.='<div id="div_'.get_class($this).'" class="hidden">'; |
|
179 | - foreach($listoffiles as $file) |
|
178 | + $texte .= '<div id="div_'.get_class($this).'" class="hidden">'; |
|
179 | + foreach ($listoffiles as $file) |
|
180 | 180 | { |
181 | - $texte.=$file['name'].'<br>'; |
|
181 | + $texte .= $file['name'].'<br>'; |
|
182 | 182 | } |
183 | - $texte.='<div id="div_'.get_class($this).'">'; |
|
183 | + $texte .= '<div id="div_'.get_class($this).'">'; |
|
184 | 184 | |
185 | 185 | if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0) |
186 | 186 | { |
187 | 187 | // Model for creation |
188 | - $liste=ModelePDFSupplierProposal::liste_modeles($this->db); |
|
189 | - $texte.= '<table width="50%;">'; |
|
190 | - $texte.= '<tr>'; |
|
191 | - $texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalCreate").'</td>'; |
|
192 | - $texte.= '<td colspan="">'; |
|
193 | - $texte.= $form->selectarray('value2',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT); |
|
194 | - $texte.= "</td></tr>"; |
|
195 | - |
|
196 | - $texte.= '<tr>'; |
|
197 | - $texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalToBill").'</td>'; |
|
198 | - $texte.= '<td colspan="">'; |
|
199 | - $texte.= $form->selectarray('value3',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL); |
|
200 | - $texte.= "</td></tr>"; |
|
201 | - $texte.= '<tr>'; |
|
202 | - |
|
203 | - $texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalClosed").'</td>'; |
|
204 | - $texte.= '<td colspan="">'; |
|
205 | - $texte.= $form->selectarray('value4',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED); |
|
206 | - $texte.= "</td></tr>"; |
|
207 | - $texte.= '</table>'; |
|
188 | + $liste = ModelePDFSupplierProposal::liste_modeles($this->db); |
|
189 | + $texte .= '<table width="50%;">'; |
|
190 | + $texte .= '<tr>'; |
|
191 | + $texte .= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalCreate").'</td>'; |
|
192 | + $texte .= '<td colspan="">'; |
|
193 | + $texte .= $form->selectarray('value2', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT); |
|
194 | + $texte .= "</td></tr>"; |
|
195 | + |
|
196 | + $texte .= '<tr>'; |
|
197 | + $texte .= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalToBill").'</td>'; |
|
198 | + $texte .= '<td colspan="">'; |
|
199 | + $texte .= $form->selectarray('value3', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL); |
|
200 | + $texte .= "</td></tr>"; |
|
201 | + $texte .= '<tr>'; |
|
202 | + |
|
203 | + $texte .= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalClosed").'</td>'; |
|
204 | + $texte .= '<td colspan="">'; |
|
205 | + $texte .= $form->selectarray('value4', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED); |
|
206 | + $texte .= "</td></tr>"; |
|
207 | + $texte .= '</table>'; |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | - $texte.= '</td>'; |
|
211 | + $texte .= '</td>'; |
|
212 | 212 | |
213 | - $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
214 | - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
215 | - $texte.= '</td>'; |
|
216 | - $texte.= '</tr>'; |
|
213 | + $texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
214 | + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
215 | + $texte .= '</td>'; |
|
216 | + $texte .= '</tr>'; |
|
217 | 217 | |
218 | - $texte.= '</table>'; |
|
219 | - $texte.= '</form>'; |
|
218 | + $texte .= '</table>'; |
|
219 | + $texte .= '</form>'; |
|
220 | 220 | |
221 | 221 | return $texte; |
222 | 222 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * @param int $hideref Do not show ref |
234 | 234 | * @return int 1 if OK, <=0 if KO |
235 | 235 | */ |
236 | - function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) |
|
236 | + function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
237 | 237 | { |
238 | 238 | // phpcs:enable |
239 | 239 | global $user, $langs, $conf, $mysoc, $hookmanager; |
@@ -245,17 +245,17 @@ discard block |
||
245 | 245 | } |
246 | 246 | |
247 | 247 | // Add odtgeneration hook |
248 | - if (! is_object($hookmanager)) |
|
248 | + if (!is_object($hookmanager)) |
|
249 | 249 | { |
250 | 250 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
251 | - $hookmanager=new HookManager($this->db); |
|
251 | + $hookmanager = new HookManager($this->db); |
|
252 | 252 | } |
253 | 253 | $hookmanager->initHooks(array('odtgeneration')); |
254 | 254 | global $action; |
255 | 255 | |
256 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
257 | - $sav_charset_output=$outputlangs->charset_output; |
|
258 | - $outputlangs->charset_output='UTF-8'; |
|
256 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
257 | + $sav_charset_output = $outputlangs->charset_output; |
|
258 | + $outputlangs->charset_output = 'UTF-8'; |
|
259 | 259 | |
260 | 260 | // Load translation files required by the page |
261 | 261 | $outputlangs->loadLangs(array("main", "companies", "bills", "dict")); |
@@ -263,28 +263,28 @@ discard block |
||
263 | 263 | if ($conf->supplier_proposal->dir_output) |
264 | 264 | { |
265 | 265 | // If $object is id instead of object |
266 | - if (! is_object($object)) |
|
266 | + if (!is_object($object)) |
|
267 | 267 | { |
268 | 268 | $id = $object; |
269 | 269 | $object = new SupplierProposal($this->db); |
270 | - $result=$object->fetch($id); |
|
270 | + $result = $object->fetch($id); |
|
271 | 271 | if ($result < 0) |
272 | 272 | { |
273 | - dol_print_error($this->db,$object->error); |
|
273 | + dol_print_error($this->db, $object->error); |
|
274 | 274 | return -1; |
275 | 275 | } |
276 | 276 | } |
277 | 277 | |
278 | 278 | $dir = $conf->supplier_proposal->dir_output; |
279 | 279 | $objectref = dol_sanitizeFileName($object->ref); |
280 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
281 | - $file = $dir . "/" . $objectref . ".odt"; |
|
280 | + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; |
|
281 | + $file = $dir."/".$objectref.".odt"; |
|
282 | 282 | |
283 | - if (! file_exists($dir)) |
|
283 | + if (!file_exists($dir)) |
|
284 | 284 | { |
285 | 285 | if (dol_mkdir($dir) < 0) |
286 | 286 | { |
287 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
287 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
288 | 288 | return -1; |
289 | 289 | } |
290 | 290 | } |
@@ -292,26 +292,26 @@ discard block |
||
292 | 292 | if (file_exists($dir)) |
293 | 293 | { |
294 | 294 | //print "srctemplatepath=".$srctemplatepath; // Src filename |
295 | - $newfile=basename($srctemplatepath); |
|
296 | - $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile); |
|
297 | - $newfiletmp=preg_replace('/template_/i','',$newfiletmp); |
|
298 | - $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); |
|
295 | + $newfile = basename($srctemplatepath); |
|
296 | + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); |
|
297 | + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); |
|
298 | + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); |
|
299 | 299 | |
300 | - $newfiletmp=$objectref.'_'.$newfiletmp; |
|
300 | + $newfiletmp = $objectref.'_'.$newfiletmp; |
|
301 | 301 | |
302 | 302 | // Get extension (ods or odt) |
303 | - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
|
304 | - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
|
303 | + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); |
|
304 | + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) |
|
305 | 305 | { |
306 | - $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
307 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
308 | - $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
|
306 | + $format = $conf->global->MAIN_DOC_USE_TIMING; |
|
307 | + if ($format == '1') $format = '%Y%m%d%H%M%S'; |
|
308 | + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; |
|
309 | 309 | } |
310 | 310 | else |
311 | 311 | { |
312 | - $filename=$newfiletmp.'.'.$newfileformat; |
|
312 | + $filename = $newfiletmp.'.'.$newfileformat; |
|
313 | 313 | } |
314 | - $file=$dir.'/'.$filename; |
|
314 | + $file = $dir.'/'.$filename; |
|
315 | 315 | //print "newdir=".$dir; |
316 | 316 | //print "newfile=".$newfile; |
317 | 317 | //print "file=".$file; |
@@ -321,28 +321,28 @@ discard block |
||
321 | 321 | |
322 | 322 | |
323 | 323 | // If BILLING contact defined on invoice, we use it |
324 | - $usecontact=false; |
|
325 | - $arrayidcontact=$object->getIdContact('external','BILLING'); |
|
324 | + $usecontact = false; |
|
325 | + $arrayidcontact = $object->getIdContact('external', 'BILLING'); |
|
326 | 326 | if (count($arrayidcontact) > 0) |
327 | 327 | { |
328 | - $usecontact=true; |
|
329 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
328 | + $usecontact = true; |
|
329 | + $result = $object->fetch_contact($arrayidcontact[0]); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | // Recipient name |
333 | - if (! empty($usecontact)) |
|
333 | + if (!empty($usecontact)) |
|
334 | 334 | { |
335 | 335 | // On peut utiliser le nom de la societe du contact |
336 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
336 | + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
337 | 337 | else $socobject = $object->thirdparty; |
338 | 338 | } |
339 | 339 | else |
340 | 340 | { |
341 | - $socobject=$object->thirdparty; |
|
341 | + $socobject = $object->thirdparty; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | // Make substitution |
345 | - $substitutionarray=array( |
|
345 | + $substitutionarray = array( |
|
346 | 346 | '__FROM_NAME__' => $this->emetteur->name, |
347 | 347 | '__FROM_EMAIL__' => $this->emetteur->email, |
348 | 348 | '__TOTAL_TTC__' => $object->total_ttc, |
@@ -351,15 +351,15 @@ discard block |
||
351 | 351 | ); |
352 | 352 | complete_substitutions_array($substitutionarray, $langs, $object); |
353 | 353 | // Call the ODTSubstitution hook |
354 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); |
|
355 | - $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
354 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); |
|
355 | + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
356 | 356 | |
357 | 357 | // Line of free text |
358 | - $newfreetext=''; |
|
359 | - $paramfreetext='SUPPLIER_PROPOSAL_FREE_TEXT'; |
|
360 | - if (! empty($conf->global->$paramfreetext)) |
|
358 | + $newfreetext = ''; |
|
359 | + $paramfreetext = 'SUPPLIER_PROPOSAL_FREE_TEXT'; |
|
360 | + if (!empty($conf->global->$paramfreetext)) |
|
361 | 361 | { |
362 | - $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); |
|
362 | + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | // Open and load template |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | $srctemplatepath, |
370 | 370 | array( |
371 | 371 | 'PATH_TO_TMP' => $conf->supplier_proposal->dir_temp, |
372 | - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
372 | + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
373 | 373 | 'DELIMITER_LEFT' => '{', |
374 | 374 | 'DELIMITER_RIGHT' => '}' |
375 | 375 | ) |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | } |
378 | 378 | catch (Exception $e) |
379 | 379 | { |
380 | - $this->error=$e->getMessage(); |
|
380 | + $this->error = $e->getMessage(); |
|
381 | 381 | dol_syslog($e->getMessage(), LOG_INFO); |
382 | 382 | return -1; |
383 | 383 | } |
@@ -399,23 +399,23 @@ discard block |
||
399 | 399 | |
400 | 400 | // Define substitution array |
401 | 401 | $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); |
402 | - $array_objet=$this->get_substitutionarray_object($object,$outputlangs); |
|
403 | - $array_user=$this->get_substitutionarray_user($user,$outputlangs); |
|
404 | - $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); |
|
405 | - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); |
|
406 | - $array_other=$this->get_substitutionarray_other($outputlangs); |
|
402 | + $array_objet = $this->get_substitutionarray_object($object, $outputlangs); |
|
403 | + $array_user = $this->get_substitutionarray_user($user, $outputlangs); |
|
404 | + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); |
|
405 | + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); |
|
406 | + $array_other = $this->get_substitutionarray_other($outputlangs); |
|
407 | 407 | |
408 | - $tmparray = array_merge($substitutionarray,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other); |
|
408 | + $tmparray = array_merge($substitutionarray, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other); |
|
409 | 409 | complete_substitutions_array($tmparray, $outputlangs, $object); |
410 | 410 | |
411 | 411 | // Call the ODTSubstitution hook |
412 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
413 | - $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
412 | + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); |
|
413 | + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
414 | 414 | |
415 | - foreach($tmparray as $key=>$value) |
|
415 | + foreach ($tmparray as $key=>$value) |
|
416 | 416 | { |
417 | 417 | try { |
418 | - if (preg_match('/logo$/',$key)) // Image |
|
418 | + if (preg_match('/logo$/', $key)) // Image |
|
419 | 419 | { |
420 | 420 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
421 | 421 | else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
426 | 426 | } |
427 | 427 | } |
428 | - catch(OdfException $e) |
|
428 | + catch (OdfException $e) |
|
429 | 429 | { |
430 | 430 | dol_syslog($e->getMessage(), LOG_INFO); |
431 | 431 | } |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | try { |
438 | 438 | $listlines = $odfHandler->setSegment('lines'); |
439 | 439 | } |
440 | - catch(OdfException $e) |
|
440 | + catch (OdfException $e) |
|
441 | 441 | { |
442 | 442 | // We may arrive here if tags for lines not present into template |
443 | 443 | $foundtagforlines = 0; |
@@ -447,22 +447,22 @@ discard block |
||
447 | 447 | { |
448 | 448 | foreach ($object->lines as $line) |
449 | 449 | { |
450 | - $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); |
|
450 | + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); |
|
451 | 451 | complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); |
452 | 452 | // Call the ODTSubstitutionLine hook |
453 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); |
|
454 | - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
455 | - foreach($tmparray as $key => $val) |
|
453 | + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); |
|
454 | + $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
455 | + foreach ($tmparray as $key => $val) |
|
456 | 456 | { |
457 | 457 | try |
458 | 458 | { |
459 | 459 | $listlines->setVars($key, $val, true, 'UTF-8'); |
460 | 460 | } |
461 | - catch(OdfException $e) |
|
461 | + catch (OdfException $e) |
|
462 | 462 | { |
463 | 463 | dol_syslog($e->getMessage(), LOG_INFO); |
464 | 464 | } |
465 | - catch(SegmentException $e) |
|
465 | + catch (SegmentException $e) |
|
466 | 466 | { |
467 | 467 | dol_syslog($e->getMessage(), LOG_INFO); |
468 | 468 | } |
@@ -472,36 +472,36 @@ discard block |
||
472 | 472 | $odfHandler->mergeSegment($listlines); |
473 | 473 | } |
474 | 474 | } |
475 | - catch(OdfException $e) |
|
475 | + catch (OdfException $e) |
|
476 | 476 | { |
477 | - $this->error=$e->getMessage(); |
|
477 | + $this->error = $e->getMessage(); |
|
478 | 478 | dol_syslog($this->error, LOG_WARNING); |
479 | 479 | return -1; |
480 | 480 | } |
481 | 481 | |
482 | 482 | // Replace labels translated |
483 | - $tmparray=$outputlangs->get_translations_for_substitutions(); |
|
484 | - foreach($tmparray as $key=>$value) |
|
483 | + $tmparray = $outputlangs->get_translations_for_substitutions(); |
|
484 | + foreach ($tmparray as $key=>$value) |
|
485 | 485 | { |
486 | 486 | try { |
487 | 487 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
488 | 488 | } |
489 | - catch(OdfException $e) |
|
489 | + catch (OdfException $e) |
|
490 | 490 | { |
491 | 491 | dol_syslog($e->getMessage(), LOG_INFO); |
492 | 492 | } |
493 | 493 | } |
494 | 494 | |
495 | 495 | // Call the beforeODTSave hook |
496 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
497 | - $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
496 | + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); |
|
497 | + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
498 | 498 | |
499 | 499 | // Write new file |
500 | 500 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
501 | 501 | try { |
502 | 502 | $odfHandler->exportAsAttachedPDF($file); |
503 | 503 | } catch (Exception $e) { |
504 | - $this->error=$e->getMessage(); |
|
504 | + $this->error = $e->getMessage(); |
|
505 | 505 | dol_syslog($e->getMessage(), LOG_INFO); |
506 | 506 | return -1; |
507 | 507 | } |
@@ -510,26 +510,26 @@ discard block |
||
510 | 510 | try { |
511 | 511 | $odfHandler->saveToDisk($file); |
512 | 512 | } catch (Exception $e) { |
513 | - $this->error=$e->getMessage(); |
|
513 | + $this->error = $e->getMessage(); |
|
514 | 514 | dol_syslog($e->getMessage(), LOG_INFO); |
515 | 515 | return -1; |
516 | 516 | } |
517 | 517 | } |
518 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
519 | - $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
518 | + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); |
|
519 | + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
520 | 520 | |
521 | - if (! empty($conf->global->MAIN_UMASK)) |
|
521 | + if (!empty($conf->global->MAIN_UMASK)) |
|
522 | 522 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
523 | 523 | |
524 | - $odfHandler=null; // Destroy object |
|
524 | + $odfHandler = null; // Destroy object |
|
525 | 525 | |
526 | 526 | $this->result = array('fullpath'=>$file); |
527 | 527 | |
528 | - return 1; // Success |
|
528 | + return 1; // Success |
|
529 | 529 | } |
530 | 530 | else |
531 | 531 | { |
532 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
532 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
533 | 533 | return -1; |
534 | 534 | } |
535 | 535 | } |
@@ -130,67 +130,67 @@ discard block |
||
130 | 130 | |
131 | 131 | // Dimension page pour format A4 |
132 | 132 | $this->type = 'pdf'; |
133 | - $formatarray=pdf_getFormat(); |
|
133 | + $formatarray = pdf_getFormat(); |
|
134 | 134 | $this->page_largeur = $formatarray['width']; |
135 | 135 | $this->page_hauteur = $formatarray['height']; |
136 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
137 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
138 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
139 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
140 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
141 | - |
|
142 | - $this->option_logo = 1; // Affiche logo |
|
143 | - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
144 | - $this->option_modereg = 1; // Affiche mode reglement |
|
145 | - $this->option_condreg = 1; // Affiche conditions reglement |
|
146 | - $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
147 | - $this->option_multilang = 1; // Dispo en plusieurs langues |
|
148 | - $this->option_escompte = 1; // Affiche si il y a eu escompte |
|
149 | - $this->option_credit_note = 1; // Support credit notes |
|
150 | - $this->option_freetext = 1; // Support add of a personalised text |
|
151 | - $this->option_draft_watermark = 1; //Support add of a watermark on drafts |
|
152 | - |
|
153 | - $this->franchise=!$mysoc->tva_assuj; |
|
136 | + $this->format = array($this->page_largeur, $this->page_hauteur); |
|
137 | + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; |
|
138 | + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; |
|
139 | + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; |
|
140 | + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; |
|
141 | + |
|
142 | + $this->option_logo = 1; // Affiche logo |
|
143 | + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
144 | + $this->option_modereg = 1; // Affiche mode reglement |
|
145 | + $this->option_condreg = 1; // Affiche conditions reglement |
|
146 | + $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
147 | + $this->option_multilang = 1; // Dispo en plusieurs langues |
|
148 | + $this->option_escompte = 1; // Affiche si il y a eu escompte |
|
149 | + $this->option_credit_note = 1; // Support credit notes |
|
150 | + $this->option_freetext = 1; // Support add of a personalised text |
|
151 | + $this->option_draft_watermark = 1; //Support add of a watermark on drafts |
|
152 | + |
|
153 | + $this->franchise = !$mysoc->tva_assuj; |
|
154 | 154 | |
155 | 155 | // Get source company |
156 | - $this->emetteur=$mysoc; |
|
157 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
156 | + $this->emetteur = $mysoc; |
|
157 | + if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined |
|
158 | 158 | |
159 | 159 | // Define position of columns |
160 | - $this->posxdesc=$this->marge_gauche+1; |
|
161 | - $this->posxdiscount=162; |
|
162 | - $this->postotalht=174; |
|
160 | + $this->posxdesc = $this->marge_gauche + 1; |
|
161 | + $this->posxdiscount = 162; |
|
162 | + $this->postotalht = 174; |
|
163 | 163 | |
164 | 164 | if ($conf->global->PRODUCT_USE_UNITS) |
165 | 165 | { |
166 | - $this->posxtva=101; |
|
167 | - $this->posxup=118; |
|
168 | - $this->posxqty=135; |
|
169 | - $this->posxunit=151; |
|
166 | + $this->posxtva = 101; |
|
167 | + $this->posxup = 118; |
|
168 | + $this->posxqty = 135; |
|
169 | + $this->posxunit = 151; |
|
170 | 170 | } else { |
171 | - $this->posxtva=102; |
|
172 | - $this->posxup=126; |
|
173 | - $this->posxqty=145; |
|
171 | + $this->posxtva = 102; |
|
172 | + $this->posxup = 126; |
|
173 | + $this->posxqty = 145; |
|
174 | 174 | } |
175 | 175 | |
176 | - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup=$this->posxtva; |
|
177 | - $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
176 | + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup = $this->posxtva; |
|
177 | + $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
178 | 178 | if ($this->page_largeur < 210) // To work with US executive format |
179 | 179 | { |
180 | - $this->posxpicture-=20; |
|
181 | - $this->posxtva-=20; |
|
182 | - $this->posxup-=20; |
|
183 | - $this->posxqty-=20; |
|
184 | - $this->posxunit-=20; |
|
185 | - $this->posxdiscount-=20; |
|
186 | - $this->postotalht-=20; |
|
180 | + $this->posxpicture -= 20; |
|
181 | + $this->posxtva -= 20; |
|
182 | + $this->posxup -= 20; |
|
183 | + $this->posxqty -= 20; |
|
184 | + $this->posxunit -= 20; |
|
185 | + $this->posxdiscount -= 20; |
|
186 | + $this->postotalht -= 20; |
|
187 | 187 | } |
188 | 188 | |
189 | - $this->tva=array(); |
|
190 | - $this->localtax1=array(); |
|
191 | - $this->localtax2=array(); |
|
192 | - $this->atleastoneratenotnull=0; |
|
193 | - $this->atleastonediscount=0; |
|
189 | + $this->tva = array(); |
|
190 | + $this->localtax1 = array(); |
|
191 | + $this->localtax2 = array(); |
|
192 | + $this->atleastoneratenotnull = 0; |
|
193 | + $this->atleastonediscount = 0; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -205,14 +205,14 @@ discard block |
||
205 | 205 | * @param int $hideref Do not show ref |
206 | 206 | * @return int 1=OK, 0=KO |
207 | 207 | */ |
208 | - function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) |
|
208 | + function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
209 | 209 | { |
210 | 210 | // phpcs:enable |
211 | - global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes; |
|
211 | + global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes; |
|
212 | 212 | |
213 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
213 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
214 | 214 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
215 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
215 | + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; |
|
216 | 216 | |
217 | 217 | // Load traductions files requiredby by page |
218 | 218 | $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "supplier_proposal")); |
@@ -220,40 +220,40 @@ discard block |
||
220 | 220 | $nblignes = count($object->lines); |
221 | 221 | |
222 | 222 | // Loop on each lines to detect if there is at least one image to show |
223 | - $realpatharray=array(); |
|
224 | - if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE)) |
|
223 | + $realpatharray = array(); |
|
224 | + if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE)) |
|
225 | 225 | { |
226 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
226 | + for ($i = 0; $i < $nblignes; $i++) |
|
227 | 227 | { |
228 | 228 | if (empty($object->lines[$i]->fk_product)) continue; |
229 | 229 | |
230 | 230 | $objphoto = new Product($this->db); |
231 | 231 | $objphoto->fetch($object->lines[$i]->fk_product); |
232 | 232 | |
233 | - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) |
|
233 | + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) |
|
234 | 234 | { |
235 | - $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; |
|
235 | + $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; |
|
236 | 236 | $dir = $conf->product->dir_output.'/'.$pdir; |
237 | 237 | } |
238 | 238 | else |
239 | 239 | { |
240 | - $pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/'; |
|
240 | + $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; |
|
241 | 241 | $dir = $conf->product->dir_output.'/'.$pdir; |
242 | 242 | } |
243 | 243 | |
244 | - $realpath=''; |
|
245 | - foreach ($objphoto->liste_photos($dir,1) as $key => $obj) |
|
244 | + $realpath = ''; |
|
245 | + foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) |
|
246 | 246 | { |
247 | - $filename=$obj['photo']; |
|
247 | + $filename = $obj['photo']; |
|
248 | 248 | //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette']; |
249 | 249 | $realpath = $dir.$filename; |
250 | 250 | break; |
251 | 251 | } |
252 | 252 | |
253 | - if ($realpath) $realpatharray[$i]=$realpath; |
|
253 | + if ($realpath) $realpatharray[$i] = $realpath; |
|
254 | 254 | } |
255 | 255 | } |
256 | - if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; |
|
256 | + if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva; |
|
257 | 257 | |
258 | 258 | if ($conf->supplier_proposal->dir_output) |
259 | 259 | { |
@@ -265,20 +265,20 @@ discard block |
||
265 | 265 | if ($object->specimen) |
266 | 266 | { |
267 | 267 | $dir = $conf->supplier_proposal->dir_output; |
268 | - $file = $dir . "/SPECIMEN.pdf"; |
|
268 | + $file = $dir."/SPECIMEN.pdf"; |
|
269 | 269 | } |
270 | 270 | else |
271 | 271 | { |
272 | 272 | $objectref = dol_sanitizeFileName($object->ref); |
273 | - $dir = $conf->supplier_proposal->dir_output . "/" . $objectref; |
|
274 | - $file = $dir . "/" . $objectref . ".pdf"; |
|
273 | + $dir = $conf->supplier_proposal->dir_output."/".$objectref; |
|
274 | + $file = $dir."/".$objectref.".pdf"; |
|
275 | 275 | } |
276 | 276 | |
277 | - if (! file_exists($dir)) |
|
277 | + if (!file_exists($dir)) |
|
278 | 278 | { |
279 | 279 | if (dol_mkdir($dir) < 0) |
280 | 280 | { |
281 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
281 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
282 | 282 | return 0; |
283 | 283 | } |
284 | 284 | } |
@@ -286,24 +286,24 @@ discard block |
||
286 | 286 | if (file_exists($dir)) |
287 | 287 | { |
288 | 288 | // Add pdfgeneration hook |
289 | - if (! is_object($hookmanager)) |
|
289 | + if (!is_object($hookmanager)) |
|
290 | 290 | { |
291 | 291 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
292 | - $hookmanager=new HookManager($this->db); |
|
292 | + $hookmanager = new HookManager($this->db); |
|
293 | 293 | } |
294 | 294 | $hookmanager->initHooks(array('pdfgeneration')); |
295 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
295 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
296 | 296 | global $action; |
297 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
297 | + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
298 | 298 | |
299 | 299 | // Create pdf instance |
300 | - $pdf=pdf_getInstance($this->format); |
|
301 | - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
302 | - $heightforinfotot = 50; // Height reserved to output the info and total part |
|
303 | - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
304 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
305 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
306 | - $pdf->SetAutoPageBreak(1,0); |
|
300 | + $pdf = pdf_getInstance($this->format); |
|
301 | + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
302 | + $heightforinfotot = 50; // Height reserved to output the info and total part |
|
303 | + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page |
|
304 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
305 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; |
|
306 | + $pdf->SetAutoPageBreak(1, 0); |
|
307 | 307 | |
308 | 308 | if (class_exists('TCPDF')) |
309 | 309 | { |
@@ -312,27 +312,27 @@ discard block |
||
312 | 312 | } |
313 | 313 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
314 | 314 | // Set path to the background PDF File |
315 | - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
315 | + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
316 | 316 | { |
317 | 317 | $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); |
318 | 318 | $tplidx = $pdf->importPage(1); |
319 | 319 | } |
320 | 320 | |
321 | 321 | $pdf->Open(); |
322 | - $pagenb=0; |
|
323 | - $pdf->SetDrawColor(128,128,128); |
|
322 | + $pagenb = 0; |
|
323 | + $pdf->SetDrawColor(128, 128, 128); |
|
324 | 324 | |
325 | 325 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
326 | 326 | $pdf->SetSubject($outputlangs->transnoentities("CommercialAsk")); |
327 | 327 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
328 | 328 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
329 | 329 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialAsk")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
330 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
330 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
331 | 331 | |
332 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
332 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
333 | 333 | |
334 | 334 | // Positionne $this->atleastonediscount si on a au moins une remise |
335 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
335 | + for ($i = 0; $i < $nblignes; $i++) |
|
336 | 336 | { |
337 | 337 | if ($object->lines[$i]->remise_percent) |
338 | 338 | { |
@@ -341,57 +341,57 @@ discard block |
||
341 | 341 | } |
342 | 342 | if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) |
343 | 343 | { |
344 | - $this->posxpicture+=($this->postotalht - $this->posxdiscount); |
|
345 | - $this->posxtva+=($this->postotalht - $this->posxdiscount); |
|
346 | - $this->posxup+=($this->postotalht - $this->posxdiscount); |
|
347 | - $this->posxqty+=($this->postotalht - $this->posxdiscount); |
|
348 | - $this->posxdiscount+=($this->postotalht - $this->posxdiscount); |
|
344 | + $this->posxpicture += ($this->postotalht - $this->posxdiscount); |
|
345 | + $this->posxtva += ($this->postotalht - $this->posxdiscount); |
|
346 | + $this->posxup += ($this->postotalht - $this->posxdiscount); |
|
347 | + $this->posxqty += ($this->postotalht - $this->posxdiscount); |
|
348 | + $this->posxdiscount += ($this->postotalht - $this->posxdiscount); |
|
349 | 349 | //$this->postotalht; |
350 | 350 | } |
351 | 351 | |
352 | 352 | // New page |
353 | 353 | $pdf->AddPage(); |
354 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
354 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
355 | 355 | $pagenb++; |
356 | 356 | $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); |
357 | - $pdf->SetFont('','', $default_font_size - 1); |
|
358 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
359 | - $pdf->SetTextColor(0,0,0); |
|
357 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
358 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
359 | + $pdf->SetTextColor(0, 0, 0); |
|
360 | 360 | |
361 | - $tab_top = 90+$top_shift; |
|
362 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); |
|
361 | + $tab_top = 90 + $top_shift; |
|
362 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); |
|
363 | 363 | |
364 | 364 | // Affiche notes |
365 | - $notetoshow=empty($object->note_public)?'':$object->note_public; |
|
366 | - if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) |
|
365 | + $notetoshow = empty($object->note_public) ? '' : $object->note_public; |
|
366 | + if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) |
|
367 | 367 | { |
368 | 368 | // Get first sale rep |
369 | 369 | if (is_object($object->thirdparty)) |
370 | 370 | { |
371 | - $salereparray=$object->thirdparty->getSalesRepresentatives($user); |
|
372 | - $salerepobj=new User($this->db); |
|
371 | + $salereparray = $object->thirdparty->getSalesRepresentatives($user); |
|
372 | + $salerepobj = new User($this->db); |
|
373 | 373 | $salerepobj->fetch($salereparray[0]['id']); |
374 | - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
374 | + if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); |
|
375 | 375 | } |
376 | 376 | } |
377 | 377 | if ($notetoshow) |
378 | 378 | { |
379 | 379 | $tab_top -= 2; |
380 | 380 | |
381 | - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); |
|
381 | + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); |
|
382 | 382 | complete_substitutions_array($substitutionarray, $outputlangs, $object); |
383 | 383 | $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); |
384 | 384 | |
385 | - $pdf->SetFont('','', $default_font_size - 1); |
|
386 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1); |
|
385 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
386 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($notetoshow), 0, 1); |
|
387 | 387 | $nexY = $pdf->GetY(); |
388 | - $height_note=$nexY-$tab_top; |
|
388 | + $height_note = $nexY - $tab_top; |
|
389 | 389 | |
390 | 390 | // Rect prend une longueur en 3eme param |
391 | - $pdf->SetDrawColor(192,192,192); |
|
392 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
391 | + $pdf->SetDrawColor(192, 192, 192); |
|
392 | + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); |
|
393 | 393 | |
394 | - $tab_top = $nexY+6; |
|
394 | + $tab_top = $nexY + 6; |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | $iniY = $tab_top + 7; |
@@ -399,105 +399,105 @@ discard block |
||
399 | 399 | $nexY = $tab_top + 7; |
400 | 400 | |
401 | 401 | // Loop on each lines |
402 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
402 | + for ($i = 0; $i < $nblignes; $i++) |
|
403 | 403 | { |
404 | 404 | $curY = $nexY; |
405 | - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
406 | - $pdf->SetTextColor(0,0,0); |
|
405 | + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage |
|
406 | + $pdf->SetTextColor(0, 0, 0); |
|
407 | 407 | |
408 | 408 | // Define size of image if we need it |
409 | - $imglinesize=array(); |
|
410 | - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
409 | + $imglinesize = array(); |
|
410 | + if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); |
|
411 | 411 | |
412 | 412 | $pdf->setTopMargin($tab_top_newpage); |
413 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
414 | - $pageposbefore=$pdf->getPage(); |
|
413 | + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
414 | + $pageposbefore = $pdf->getPage(); |
|
415 | 415 | |
416 | - $showpricebeforepagebreak=1; |
|
417 | - $posYAfterImage=0; |
|
418 | - $posYAfterDescription=0; |
|
416 | + $showpricebeforepagebreak = 1; |
|
417 | + $posYAfterImage = 0; |
|
418 | + $posYAfterDescription = 0; |
|
419 | 419 | |
420 | 420 | // We start with Photo of product line |
421 | - if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page |
|
421 | + if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page |
|
422 | 422 | { |
423 | - $pdf->AddPage('','',true); |
|
424 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
423 | + $pdf->AddPage('', '', true); |
|
424 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
425 | 425 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
426 | - $pdf->setPage($pageposbefore+1); |
|
426 | + $pdf->setPage($pageposbefore + 1); |
|
427 | 427 | |
428 | 428 | $curY = $tab_top_newpage; |
429 | - $showpricebeforepagebreak=0; |
|
429 | + $showpricebeforepagebreak = 0; |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) |
433 | 433 | { |
434 | - $curX = $this->posxpicture-1; |
|
435 | - $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi |
|
434 | + $curX = $this->posxpicture - 1; |
|
435 | + $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi |
|
436 | 436 | // $pdf->Image does not increase value return by getY, so we save it manually |
437 | - $posYAfterImage=$curY+$imglinesize['height']; |
|
437 | + $posYAfterImage = $curY + $imglinesize['height']; |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | // Description of product line |
441 | - $curX = $this->posxdesc-1; |
|
441 | + $curX = $this->posxdesc - 1; |
|
442 | 442 | |
443 | 443 | $pdf->startTransaction(); |
444 | 444 | if ($posYAfterImage > 0) |
445 | 445 | { |
446 | - $descWidth = $this->posxpicture-$curX; |
|
446 | + $descWidth = $this->posxpicture - $curX; |
|
447 | 447 | } |
448 | 448 | else |
449 | 449 | { |
450 | - $descWidth = $this->posxtva-$curX; |
|
450 | + $descWidth = $this->posxtva - $curX; |
|
451 | 451 | } |
452 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1); |
|
452 | + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1); |
|
453 | 453 | |
454 | - $pageposafter=$pdf->getPage(); |
|
454 | + $pageposafter = $pdf->getPage(); |
|
455 | 455 | if ($pageposafter > $pageposbefore) // There is a pagebreak |
456 | 456 | { |
457 | 457 | $pdf->rollbackTransaction(true); |
458 | - $pageposafter=$pageposbefore; |
|
458 | + $pageposafter = $pageposbefore; |
|
459 | 459 | //print $pageposafter.'-'.$pageposbefore;exit; |
460 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
461 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc); |
|
460 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
461 | + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc); |
|
462 | 462 | |
463 | - $pageposafter=$pdf->getPage(); |
|
464 | - $posyafter=$pdf->GetY(); |
|
463 | + $pageposafter = $pdf->getPage(); |
|
464 | + $posyafter = $pdf->GetY(); |
|
465 | 465 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
466 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
466 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text |
|
467 | 467 | { |
468 | - if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
468 | + if ($i == ($nblignes - 1)) // No more lines, and no space left to show total, so we create a new page |
|
469 | 469 | { |
470 | - $pdf->AddPage('','',true); |
|
471 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
470 | + $pdf->AddPage('', '', true); |
|
471 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
472 | 472 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
473 | - $pdf->setPage($pageposafter+1); |
|
473 | + $pdf->setPage($pageposafter + 1); |
|
474 | 474 | } |
475 | 475 | } |
476 | 476 | else |
477 | 477 | { |
478 | 478 | // We found a page break |
479 | - $showpricebeforepagebreak=0; |
|
479 | + $showpricebeforepagebreak = 0; |
|
480 | 480 | } |
481 | 481 | } |
482 | 482 | else // No pagebreak |
483 | 483 | { |
484 | 484 | $pdf->commitTransaction(); |
485 | 485 | } |
486 | - $posYAfterDescription=$pdf->GetY(); |
|
486 | + $posYAfterDescription = $pdf->GetY(); |
|
487 | 487 | |
488 | 488 | $nexY = $pdf->GetY(); |
489 | - $pageposafter=$pdf->getPage(); |
|
489 | + $pageposafter = $pdf->getPage(); |
|
490 | 490 | |
491 | 491 | $pdf->setPage($pageposbefore); |
492 | 492 | $pdf->setTopMargin($this->marge_haute); |
493 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
493 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
494 | 494 | |
495 | 495 | // We suppose that a too long description or photo were moved completely on next page |
496 | 496 | if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
497 | 497 | $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
498 | 498 | } |
499 | 499 | |
500 | - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
500 | + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut |
|
501 | 501 | |
502 | 502 | // VAT Rate |
503 | 503 | /* |
@@ -519,21 +519,21 @@ discard block |
||
519 | 519 | $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); |
520 | 520 | $pdf->SetXY($this->posxqty, $curY); |
521 | 521 | // Enough for 6 chars |
522 | - if($conf->global->PRODUCT_USE_UNITS) |
|
522 | + if ($conf->global->PRODUCT_USE_UNITS) |
|
523 | 523 | { |
524 | - $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 3, $qty, 0, 'R'); |
|
524 | + $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 3, $qty, 0, 'R'); |
|
525 | 525 | } |
526 | 526 | else |
527 | 527 | { |
528 | - $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R'); |
|
528 | + $pdf->MultiCell($this->posxdiscount - $this->posxqty - 0.8, 3, $qty, 0, 'R'); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | // Unit |
532 | - if($conf->global->PRODUCT_USE_UNITS) |
|
532 | + if ($conf->global->PRODUCT_USE_UNITS) |
|
533 | 533 | { |
534 | 534 | $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); |
535 | 535 | $pdf->SetXY($this->posxunit, $curY); |
536 | - $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L'); |
|
536 | + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L'); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | // Discount on line |
@@ -553,54 +553,54 @@ discard block |
||
553 | 553 | */ |
554 | 554 | |
555 | 555 | // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva |
556 | - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; |
|
557 | - else $tvaligne=$object->lines[$i]->total_tva; |
|
556 | + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva; |
|
557 | + else $tvaligne = $object->lines[$i]->total_tva; |
|
558 | 558 | |
559 | - $localtax1ligne=$object->lines[$i]->total_localtax1; |
|
560 | - $localtax2ligne=$object->lines[$i]->total_localtax2; |
|
561 | - $localtax1_rate=$object->lines[$i]->localtax1_tx; |
|
562 | - $localtax2_rate=$object->lines[$i]->localtax2_tx; |
|
563 | - $localtax1_type=$object->lines[$i]->localtax1_type; |
|
564 | - $localtax2_type=$object->lines[$i]->localtax2_type; |
|
559 | + $localtax1ligne = $object->lines[$i]->total_localtax1; |
|
560 | + $localtax2ligne = $object->lines[$i]->total_localtax2; |
|
561 | + $localtax1_rate = $object->lines[$i]->localtax1_tx; |
|
562 | + $localtax2_rate = $object->lines[$i]->localtax2_tx; |
|
563 | + $localtax1_type = $object->lines[$i]->localtax1_type; |
|
564 | + $localtax2_type = $object->lines[$i]->localtax2_type; |
|
565 | 565 | |
566 | - if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
567 | - if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
568 | - if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
566 | + if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100; |
|
567 | + if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100; |
|
568 | + if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100; |
|
569 | 569 | |
570 | - $vatrate=(string) $object->lines[$i]->tva_tx; |
|
570 | + $vatrate = (string) $object->lines[$i]->tva_tx; |
|
571 | 571 | |
572 | 572 | // Retrieve type from database for backward compatibility with old records |
573 | - if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined |
|
574 | - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax |
|
573 | + if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined |
|
574 | + && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax |
|
575 | 575 | { |
576 | - $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc); |
|
576 | + $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc); |
|
577 | 577 | $localtax1_type = $localtaxtmp_array[0]; |
578 | 578 | $localtax2_type = $localtaxtmp_array[2]; |
579 | 579 | } |
580 | 580 | |
581 | 581 | // retrieve global local tax |
582 | 582 | if ($localtax1_type && $localtax1ligne != 0) |
583 | - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
583 | + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; |
|
584 | 584 | if ($localtax2_type && $localtax2ligne != 0) |
585 | - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
585 | + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; |
|
586 | 586 | |
587 | - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; |
|
588 | - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; |
|
587 | + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*'; |
|
588 | + if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0; |
|
589 | 589 | $this->tva[$vatrate] += $tvaligne; |
590 | 590 | |
591 | - if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; |
|
591 | + if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage; |
|
592 | 592 | |
593 | 593 | // Add line |
594 | - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
594 | + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
595 | 595 | { |
596 | 596 | $pdf->setPage($pageposafter); |
597 | - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
597 | + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); |
|
598 | 598 | //$pdf->SetDrawColor(190,190,200); |
599 | - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); |
|
599 | + $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); |
|
600 | 600 | $pdf->SetLineStyle(array('dash'=>0)); |
601 | 601 | } |
602 | 602 | |
603 | - $nexY+=2; // Passe espace entre les lignes |
|
603 | + $nexY += 2; // Passe espace entre les lignes |
|
604 | 604 | |
605 | 605 | // Detect if some page were added automatically and output _tableau for past pages |
606 | 606 | while ($pagenb < $pageposafter) |
@@ -614,13 +614,13 @@ discard block |
||
614 | 614 | { |
615 | 615 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
616 | 616 | } |
617 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
617 | + $this->_pagefoot($pdf, $object, $outputlangs, 1); |
|
618 | 618 | $pagenb++; |
619 | 619 | $pdf->setPage($pagenb); |
620 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
620 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
621 | 621 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
622 | 622 | } |
623 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
623 | + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) |
|
624 | 624 | { |
625 | 625 | if ($pagenb == 1) |
626 | 626 | { |
@@ -630,10 +630,10 @@ discard block |
||
630 | 630 | { |
631 | 631 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
632 | 632 | } |
633 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
633 | + $this->_pagefoot($pdf, $object, $outputlangs, 1); |
|
634 | 634 | // New page |
635 | 635 | $pdf->AddPage(); |
636 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
636 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
637 | 637 | $pagenb++; |
638 | 638 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
639 | 639 | } |
@@ -643,16 +643,16 @@ discard block |
||
643 | 643 | if ($pagenb == 1) |
644 | 644 | { |
645 | 645 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
646 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
646 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
647 | 647 | } |
648 | 648 | else |
649 | 649 | { |
650 | 650 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
651 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
651 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | // Affiche zone infos |
655 | - $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); |
|
655 | + $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); |
|
656 | 656 | |
657 | 657 | // Affiche zone totaux |
658 | 658 | //$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); |
@@ -666,35 +666,35 @@ discard block |
||
666 | 666 | */ |
667 | 667 | |
668 | 668 | // Pied de page |
669 | - $this->_pagefoot($pdf,$object,$outputlangs); |
|
670 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
669 | + $this->_pagefoot($pdf, $object, $outputlangs); |
|
670 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
671 | 671 | |
672 | 672 | $pdf->Close(); |
673 | 673 | |
674 | - $pdf->Output($file,'F'); |
|
674 | + $pdf->Output($file, 'F'); |
|
675 | 675 | |
676 | 676 | //Add pdfgeneration hook |
677 | 677 | $hookmanager->initHooks(array('pdfgeneration')); |
678 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
678 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
679 | 679 | global $action; |
680 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
680 | + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
681 | 681 | |
682 | - if (! empty($conf->global->MAIN_UMASK)) |
|
682 | + if (!empty($conf->global->MAIN_UMASK)) |
|
683 | 683 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
684 | 684 | |
685 | 685 | $this->result = array('fullpath'=>$file); |
686 | 686 | |
687 | - return 1; // Pas d'erreur |
|
687 | + return 1; // Pas d'erreur |
|
688 | 688 | } |
689 | 689 | else |
690 | 690 | { |
691 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
691 | + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); |
|
692 | 692 | return 0; |
693 | 693 | } |
694 | 694 | } |
695 | 695 | else |
696 | 696 | { |
697 | - $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_PROPOSAL_OUTPUTDIR"); |
|
697 | + $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_PROPOSAL_OUTPUTDIR"); |
|
698 | 698 | return 0; |
699 | 699 | } |
700 | 700 | } |
@@ -731,37 +731,37 @@ discard block |
||
731 | 731 | global $conf; |
732 | 732 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
733 | 733 | |
734 | - $pdf->SetFont('','', $default_font_size - 1); |
|
734 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
735 | 735 | |
736 | - $posxval=52; |
|
736 | + $posxval = 52; |
|
737 | 737 | |
738 | 738 | // Show shipping date |
739 | - if (! empty($object->date_livraison)) |
|
739 | + if (!empty($object->date_livraison)) |
|
740 | 740 | { |
741 | 741 | $outputlangs->load("sendings"); |
742 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
742 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
743 | 743 | $pdf->SetXY($this->marge_gauche, $posy); |
744 | 744 | $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':'; |
745 | 745 | $pdf->MultiCell(80, 4, $titre, 0, 'L'); |
746 | - $pdf->SetFont('','', $default_font_size - 2); |
|
746 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
747 | 747 | $pdf->SetXY($posxval, $posy); |
748 | - $dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true); |
|
748 | + $dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true); |
|
749 | 749 | $pdf->MultiCell(80, 4, $dlp, 0, 'L'); |
750 | 750 | |
751 | - $posy=$pdf->GetY()+1; |
|
751 | + $posy = $pdf->GetY() + 1; |
|
752 | 752 | } |
753 | 753 | else { |
754 | 754 | $outputlangs->load("sendings"); |
755 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
755 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
756 | 756 | $pdf->SetXY($this->marge_gauche, $posy); |
757 | 757 | $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':'; |
758 | 758 | $pdf->MultiCell(80, 4, $titre, 0, 'L'); |
759 | - $pdf->SetFont('','', $default_font_size - 2); |
|
759 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
760 | 760 | $pdf->SetXY($posxval, $posy); |
761 | 761 | //$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true); |
762 | 762 | $pdf->MultiCell(80, 4, $dlp, 0, 'L'); |
763 | 763 | |
764 | - $posy=$pdf->GetY()+1; |
|
764 | + $posy = $pdf->GetY() + 1; |
|
765 | 765 | } |
766 | 766 | /* PHFAVRE |
767 | 767 | elseif ($object->availability_code || $object->availability) // Show availability conditions |
@@ -783,46 +783,46 @@ discard block |
||
783 | 783 | // Show payments conditions |
784 | 784 | if (empty($conf->global->SUPPLIER_PROPOSAL_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement)) |
785 | 785 | { |
786 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
786 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
787 | 787 | $pdf->SetXY($this->marge_gauche, $posy); |
788 | 788 | $titre = $outputlangs->transnoentities("PaymentConditions").':'; |
789 | 789 | $pdf->MultiCell(80, 4, $titre, 0, 'L'); |
790 | 790 | |
791 | - $pdf->SetFont('','', $default_font_size - 2); |
|
791 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
792 | 792 | $pdf->SetXY($posxval, $posy); |
793 | - $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc); |
|
794 | - $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement); |
|
795 | - $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L'); |
|
793 | + $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc); |
|
794 | + $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); |
|
795 | + $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L'); |
|
796 | 796 | |
797 | - $posy=$pdf->GetY()+3; |
|
797 | + $posy = $pdf->GetY() + 3; |
|
798 | 798 | } |
799 | 799 | |
800 | - if (! empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMMODE)) |
|
800 | + if (!empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMMODE)) |
|
801 | 801 | { |
802 | 802 | // Show payment mode |
803 | 803 | if ($object->mode_reglement_code |
804 | 804 | && $object->mode_reglement_code != 'CHQ' |
805 | 805 | && $object->mode_reglement_code != 'VIR') |
806 | 806 | { |
807 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
808 | - $pdf->SetXY($this->marge_gauche, $posy-2); |
|
807 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
808 | + $pdf->SetXY($this->marge_gauche, $posy - 2); |
|
809 | 809 | $titre = $outputlangs->transnoentities("PaymentMode").':'; |
810 | 810 | $pdf->MultiCell(80, 5, $titre, 0, 'L'); |
811 | - $pdf->SetFont('','', $default_font_size - 2); |
|
812 | - $pdf->SetXY($posxval, $posy-2); |
|
813 | - $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); |
|
814 | - $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); |
|
811 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
812 | + $pdf->SetXY($posxval, $posy - 2); |
|
813 | + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); |
|
814 | + $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); |
|
815 | 815 | |
816 | - $posy=$pdf->GetY()+2; |
|
816 | + $posy = $pdf->GetY() + 2; |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | // Show payment mode CHQ |
820 | 820 | if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') |
821 | 821 | { |
822 | 822 | // Si mode reglement non force ou si force a CHQ |
823 | - if (! empty($conf->global->FACTURE_CHQ_NUMBER)) |
|
823 | + if (!empty($conf->global->FACTURE_CHQ_NUMBER)) |
|
824 | 824 | { |
825 | - $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE); |
|
825 | + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); |
|
826 | 826 | |
827 | 827 | if ($conf->global->FACTURE_CHQ_NUMBER > 0) |
828 | 828 | { |
@@ -830,31 +830,31 @@ discard block |
||
830 | 830 | $account->fetch($conf->global->FACTURE_CHQ_NUMBER); |
831 | 831 | |
832 | 832 | $pdf->SetXY($this->marge_gauche, $posy); |
833 | - $pdf->SetFont('','B', $default_font_size - $diffsizetitle); |
|
834 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0); |
|
835 | - $posy=$pdf->GetY()+1; |
|
833 | + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); |
|
834 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0); |
|
835 | + $posy = $pdf->GetY() + 1; |
|
836 | 836 | |
837 | 837 | if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) |
838 | 838 | { |
839 | 839 | $pdf->SetXY($this->marge_gauche, $posy); |
840 | - $pdf->SetFont('','', $default_font_size - $diffsizetitle); |
|
840 | + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); |
|
841 | 841 | $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); |
842 | - $posy=$pdf->GetY()+2; |
|
842 | + $posy = $pdf->GetY() + 2; |
|
843 | 843 | } |
844 | 844 | } |
845 | 845 | if ($conf->global->FACTURE_CHQ_NUMBER == -1) |
846 | 846 | { |
847 | 847 | $pdf->SetXY($this->marge_gauche, $posy); |
848 | - $pdf->SetFont('','B', $default_font_size - $diffsizetitle); |
|
849 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0); |
|
850 | - $posy=$pdf->GetY()+1; |
|
848 | + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); |
|
849 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0); |
|
850 | + $posy = $pdf->GetY() + 1; |
|
851 | 851 | |
852 | 852 | if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) |
853 | 853 | { |
854 | 854 | $pdf->SetXY($this->marge_gauche, $posy); |
855 | - $pdf->SetFont('','', $default_font_size - $diffsizetitle); |
|
855 | + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); |
|
856 | 856 | $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); |
857 | - $posy=$pdf->GetY()+2; |
|
857 | + $posy = $pdf->GetY() + 2; |
|
858 | 858 | } |
859 | 859 | } |
860 | 860 | } |
@@ -863,18 +863,18 @@ discard block |
||
863 | 863 | // If payment mode not forced or forced to VIR, show payment with BAN |
864 | 864 | if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') |
865 | 865 | { |
866 | - if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER)) |
|
866 | + if (!empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) |
|
867 | 867 | { |
868 | - $bankid=(empty($object->fk_bank)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_bank); |
|
868 | + $bankid = (empty($object->fk_bank) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_bank); |
|
869 | 869 | $account = new Account($this->db); |
870 | 870 | $account->fetch($bankid); |
871 | 871 | |
872 | - $curx=$this->marge_gauche; |
|
873 | - $cury=$posy; |
|
872 | + $curx = $this->marge_gauche; |
|
873 | + $cury = $posy; |
|
874 | 874 | |
875 | - $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size); |
|
875 | + $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size); |
|
876 | 876 | |
877 | - $posy+=2; |
|
877 | + $posy += 2; |
|
878 | 878 | } |
879 | 879 | } |
880 | 880 | } |
@@ -897,40 +897,40 @@ discard block |
||
897 | 897 | function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) |
898 | 898 | { |
899 | 899 | // phpcs:enable |
900 | - global $conf,$mysoc; |
|
900 | + global $conf, $mysoc; |
|
901 | 901 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
902 | 902 | |
903 | 903 | $tab2_top = $posy; |
904 | 904 | $tab2_hl = 4; |
905 | - $pdf->SetFont('','', $default_font_size - 1); |
|
905 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
906 | 906 | |
907 | 907 | // Tableau total |
908 | 908 | $col1x = 120; $col2x = 170; |
909 | 909 | if ($this->page_largeur < 210) // To work with US executive format |
910 | 910 | { |
911 | - $col2x-=20; |
|
911 | + $col2x -= 20; |
|
912 | 912 | } |
913 | 913 | $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); |
914 | 914 | |
915 | - $useborder=0; |
|
915 | + $useborder = 0; |
|
916 | 916 | $index = 0; |
917 | 917 | |
918 | 918 | // Total HT |
919 | - $pdf->SetFillColor(255,255,255); |
|
919 | + $pdf->SetFillColor(255, 255, 255); |
|
920 | 920 | $pdf->SetXY($col1x, $tab2_top + 0); |
921 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); |
|
921 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); |
|
922 | 922 | |
923 | 923 | $pdf->SetXY($col2x, $tab2_top + 0); |
924 | - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1); |
|
924 | + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1); |
|
925 | 925 | |
926 | 926 | // Show VAT by rates and total |
927 | - $pdf->SetFillColor(248,248,248); |
|
927 | + $pdf->SetFillColor(248, 248, 248); |
|
928 | 928 | |
929 | - $this->atleastoneratenotnull=0; |
|
929 | + $this->atleastoneratenotnull = 0; |
|
930 | 930 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
931 | 931 | { |
932 | - $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); |
|
933 | - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) |
|
932 | + $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); |
|
933 | + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) |
|
934 | 934 | { |
935 | 935 | // Nothing to do |
936 | 936 | } |
@@ -939,28 +939,28 @@ discard block |
||
939 | 939 | //Local tax 1 before VAT |
940 | 940 | //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
941 | 941 | //{ |
942 | - foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
|
942 | + foreach ($this->localtax1 as $localtax_type => $localtax_rate) |
|
943 | 943 | { |
944 | - if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
|
944 | + if (in_array((string) $localtax_type, array('1', '3', '5'))) continue; |
|
945 | 945 | |
946 | - foreach( $localtax_rate as $tvakey => $tvaval ) |
|
946 | + foreach ($localtax_rate as $tvakey => $tvaval) |
|
947 | 947 | { |
948 | - if ($tvakey!=0) // On affiche pas taux 0 |
|
948 | + if ($tvakey != 0) // On affiche pas taux 0 |
|
949 | 949 | { |
950 | 950 | //$this->atleastoneratenotnull++; |
951 | 951 | |
952 | 952 | $index++; |
953 | 953 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
954 | 954 | |
955 | - $tvacompl=''; |
|
956 | - if (preg_match('/\*/',$tvakey)) |
|
955 | + $tvacompl = ''; |
|
956 | + if (preg_match('/\*/', $tvakey)) |
|
957 | 957 | { |
958 | - $tvakey=str_replace('*','',$tvakey); |
|
958 | + $tvakey = str_replace('*', '', $tvakey); |
|
959 | 959 | $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
960 | 960 | } |
961 | - $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; |
|
962 | - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
|
963 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
961 | + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; |
|
962 | + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; |
|
963 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
964 | 964 | |
965 | 965 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
966 | 966 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
@@ -971,13 +971,13 @@ discard block |
||
971 | 971 | //Local tax 2 before VAT |
972 | 972 | //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') |
973 | 973 | //{ |
974 | - foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
|
974 | + foreach ($this->localtax2 as $localtax_type => $localtax_rate) |
|
975 | 975 | { |
976 | - if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
|
976 | + if (in_array((string) $localtax_type, array('1', '3', '5'))) continue; |
|
977 | 977 | |
978 | - foreach( $localtax_rate as $tvakey => $tvaval ) |
|
978 | + foreach ($localtax_rate as $tvakey => $tvaval) |
|
979 | 979 | { |
980 | - if ($tvakey!=0) // On affiche pas taux 0 |
|
980 | + if ($tvakey != 0) // On affiche pas taux 0 |
|
981 | 981 | { |
982 | 982 | //$this->atleastoneratenotnull++; |
983 | 983 | |
@@ -986,15 +986,15 @@ discard block |
||
986 | 986 | $index++; |
987 | 987 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
988 | 988 | |
989 | - $tvacompl=''; |
|
990 | - if (preg_match('/\*/',$tvakey)) |
|
989 | + $tvacompl = ''; |
|
990 | + if (preg_match('/\*/', $tvakey)) |
|
991 | 991 | { |
992 | - $tvakey=str_replace('*','',$tvakey); |
|
992 | + $tvakey = str_replace('*', '', $tvakey); |
|
993 | 993 | $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
994 | 994 | } |
995 | 995 | $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; |
996 | - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
|
997 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
996 | + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; |
|
997 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
998 | 998 | |
999 | 999 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
1000 | 1000 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
@@ -1003,7 +1003,7 @@ discard block |
||
1003 | 1003 | } |
1004 | 1004 | //} |
1005 | 1005 | // VAT |
1006 | - foreach($this->tva as $tvakey => $tvaval) |
|
1006 | + foreach ($this->tva as $tvakey => $tvaval) |
|
1007 | 1007 | { |
1008 | 1008 | if ($tvakey > 0) // On affiche pas taux 0 |
1009 | 1009 | { |
@@ -1012,15 +1012,15 @@ discard block |
||
1012 | 1012 | $index++; |
1013 | 1013 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1014 | 1014 | |
1015 | - $tvacompl=''; |
|
1016 | - if (preg_match('/\*/',$tvakey)) |
|
1015 | + $tvacompl = ''; |
|
1016 | + if (preg_match('/\*/', $tvakey)) |
|
1017 | 1017 | { |
1018 | - $tvakey=str_replace('*','',$tvakey); |
|
1018 | + $tvakey = str_replace('*', '', $tvakey); |
|
1019 | 1019 | $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
1020 | 1020 | } |
1021 | - $totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' '; |
|
1022 | - $totalvat.=vatrate($tvakey,1).$tvacompl; |
|
1023 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
1021 | + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; |
|
1022 | + $totalvat .= vatrate($tvakey, 1).$tvacompl; |
|
1023 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
1024 | 1024 | |
1025 | 1025 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
1026 | 1026 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
@@ -1030,11 +1030,11 @@ discard block |
||
1030 | 1030 | //Local tax 1 after VAT |
1031 | 1031 | //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
1032 | 1032 | //{ |
1033 | - foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
|
1033 | + foreach ($this->localtax1 as $localtax_type => $localtax_rate) |
|
1034 | 1034 | { |
1035 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
1035 | + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; |
|
1036 | 1036 | |
1037 | - foreach( $localtax_rate as $tvakey => $tvaval ) |
|
1037 | + foreach ($localtax_rate as $tvakey => $tvaval) |
|
1038 | 1038 | { |
1039 | 1039 | if ($tvakey != 0) // On affiche pas taux 0 |
1040 | 1040 | { |
@@ -1043,16 +1043,16 @@ discard block |
||
1043 | 1043 | $index++; |
1044 | 1044 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1045 | 1045 | |
1046 | - $tvacompl=''; |
|
1047 | - if (preg_match('/\*/',$tvakey)) |
|
1046 | + $tvacompl = ''; |
|
1047 | + if (preg_match('/\*/', $tvakey)) |
|
1048 | 1048 | { |
1049 | - $tvakey=str_replace('*','',$tvakey); |
|
1049 | + $tvakey = str_replace('*', '', $tvakey); |
|
1050 | 1050 | $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
1051 | 1051 | } |
1052 | - $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; |
|
1052 | + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; |
|
1053 | 1053 | |
1054 | - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
|
1055 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
1054 | + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; |
|
1055 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
1056 | 1056 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
1057 | 1057 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
1058 | 1058 | } |
@@ -1062,11 +1062,11 @@ discard block |
||
1062 | 1062 | //Local tax 2 after VAT |
1063 | 1063 | //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') |
1064 | 1064 | //{ |
1065 | - foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
|
1065 | + foreach ($this->localtax2 as $localtax_type => $localtax_rate) |
|
1066 | 1066 | { |
1067 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
1067 | + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; |
|
1068 | 1068 | |
1069 | - foreach( $localtax_rate as $tvakey => $tvaval ) |
|
1069 | + foreach ($localtax_rate as $tvakey => $tvaval) |
|
1070 | 1070 | { |
1071 | 1071 | // retrieve global local tax |
1072 | 1072 | if ($tvakey != 0) // On affiche pas taux 0 |
@@ -1076,16 +1076,16 @@ discard block |
||
1076 | 1076 | $index++; |
1077 | 1077 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1078 | 1078 | |
1079 | - $tvacompl=''; |
|
1080 | - if (preg_match('/\*/',$tvakey)) |
|
1079 | + $tvacompl = ''; |
|
1080 | + if (preg_match('/\*/', $tvakey)) |
|
1081 | 1081 | { |
1082 | - $tvakey=str_replace('*','',$tvakey); |
|
1082 | + $tvakey = str_replace('*', '', $tvakey); |
|
1083 | 1083 | $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
1084 | 1084 | } |
1085 | - $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; |
|
1085 | + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; |
|
1086 | 1086 | |
1087 | - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
|
1088 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
1087 | + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; |
|
1088 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
1089 | 1089 | |
1090 | 1090 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
1091 | 1091 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
@@ -1097,16 +1097,16 @@ discard block |
||
1097 | 1097 | // Total TTC |
1098 | 1098 | $index++; |
1099 | 1099 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1100 | - $pdf->SetTextColor(0,0,60); |
|
1101 | - $pdf->SetFillColor(224,224,224); |
|
1102 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); |
|
1100 | + $pdf->SetTextColor(0, 0, 60); |
|
1101 | + $pdf->SetFillColor(224, 224, 224); |
|
1102 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); |
|
1103 | 1103 | |
1104 | 1104 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
1105 | 1105 | $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1); |
1106 | 1106 | } |
1107 | 1107 | } |
1108 | 1108 | |
1109 | - $pdf->SetTextColor(0,0,0); |
|
1109 | + $pdf->SetTextColor(0, 0, 0); |
|
1110 | 1110 | |
1111 | 1111 | /* |
1112 | 1112 | $resteapayer = $object->total_ttc - $deja_regle; |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | $index++; |
1119 | 1119 | |
1120 | 1120 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1121 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); |
|
1121 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); |
|
1122 | 1122 | |
1123 | 1123 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
1124 | 1124 | $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0); |
@@ -1140,16 +1140,16 @@ discard block |
||
1140 | 1140 | */ |
1141 | 1141 | |
1142 | 1142 | $index++; |
1143 | - $pdf->SetTextColor(0,0,60); |
|
1144 | - $pdf->SetFillColor(224,224,224); |
|
1143 | + $pdf->SetTextColor(0, 0, 60); |
|
1144 | + $pdf->SetFillColor(224, 224, 224); |
|
1145 | 1145 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1146 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); |
|
1146 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); |
|
1147 | 1147 | |
1148 | 1148 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
1149 | 1149 | $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1); |
1150 | 1150 | |
1151 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1152 | - $pdf->SetTextColor(0,0,0); |
|
1151 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
1152 | + $pdf->SetTextColor(0, 0, 0); |
|
1153 | 1153 | } |
1154 | 1154 | |
1155 | 1155 | $index++; |
@@ -1169,43 +1169,43 @@ discard block |
||
1169 | 1169 | * @param string $currency Currency code |
1170 | 1170 | * @return void |
1171 | 1171 | */ |
1172 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
1172 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') |
|
1173 | 1173 | { |
1174 | 1174 | global $conf; |
1175 | 1175 | |
1176 | 1176 | // Force to disable hidetop and hidebottom |
1177 | - $hidebottom=0; |
|
1178 | - if ($hidetop) $hidetop=-1; |
|
1177 | + $hidebottom = 0; |
|
1178 | + if ($hidetop) $hidetop = -1; |
|
1179 | 1179 | |
1180 | 1180 | $currency = !empty($currency) ? $currency : $conf->currency; |
1181 | 1181 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
1182 | 1182 | |
1183 | 1183 | // Amount in (at tab_top - 1) |
1184 | - $pdf->SetTextColor(0,0,0); |
|
1185 | - $pdf->SetFont('','',$default_font_size - 2); |
|
1184 | + $pdf->SetTextColor(0, 0, 0); |
|
1185 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
1186 | 1186 | |
1187 | 1187 | if (empty($hidetop)) |
1188 | 1188 | { |
1189 | - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
1190 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); |
|
1189 | + $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
1190 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); |
|
1191 | 1191 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
1192 | 1192 | |
1193 | 1193 | //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; |
1194 | - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
1194 | + if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | - $pdf->SetDrawColor(128,128,128); |
|
1198 | - $pdf->SetFont('','',$default_font_size - 1); |
|
1197 | + $pdf->SetDrawColor(128, 128, 128); |
|
1198 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
1199 | 1199 | |
1200 | 1200 | // Output Rect |
1201 | - $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param |
|
1201 | + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param |
|
1202 | 1202 | |
1203 | 1203 | if (empty($hidetop)) |
1204 | 1204 | { |
1205 | - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param |
|
1205 | + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line prend une position y en 2eme param et 4eme param |
|
1206 | 1206 | |
1207 | - $pdf->SetXY($this->posxdesc-1, $tab_top+1); |
|
1208 | - $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); |
|
1207 | + $pdf->SetXY($this->posxdesc - 1, $tab_top + 1); |
|
1208 | + $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L'); |
|
1209 | 1209 | } |
1210 | 1210 | |
1211 | 1211 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
@@ -1214,33 +1214,33 @@ discard block |
||
1214 | 1214 | //$pdf->line($this->posxtva-2, $tab_top, $this->posxtva-2, $tab_top + $tab_height); |
1215 | 1215 | if (empty($hidetop)) |
1216 | 1216 | { |
1217 | - $pdf->SetXY($this->posxtva-5, $tab_top+1); |
|
1218 | - $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C'); |
|
1217 | + $pdf->SetXY($this->posxtva - 5, $tab_top + 1); |
|
1218 | + $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C'); |
|
1219 | 1219 | } |
1220 | 1220 | } |
1221 | 1221 | |
1222 | - $pdf->line($this->posxup-3, $tab_top, $this->posxup-3, $tab_top + $tab_height); |
|
1222 | + $pdf->line($this->posxup - 3, $tab_top, $this->posxup - 3, $tab_top + $tab_height); |
|
1223 | 1223 | if (empty($hidetop)) |
1224 | 1224 | { |
1225 | - $pdf->SetXY($this->posxup-1, $tab_top+1); |
|
1226 | - $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C'); |
|
1225 | + $pdf->SetXY($this->posxup - 1, $tab_top + 1); |
|
1226 | + $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); |
|
1227 | 1227 | } |
1228 | 1228 | |
1229 | - $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); |
|
1229 | + $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height); |
|
1230 | 1230 | if (empty($hidetop)) |
1231 | 1231 | { |
1232 | - $pdf->SetXY($this->posxqty-1, $tab_top+1); |
|
1233 | - if($conf->global->PRODUCT_USE_UNITS) |
|
1232 | + $pdf->SetXY($this->posxqty - 1, $tab_top + 1); |
|
1233 | + if ($conf->global->PRODUCT_USE_UNITS) |
|
1234 | 1234 | { |
1235 | - $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
|
1235 | + $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); |
|
1236 | 1236 | } |
1237 | 1237 | else |
1238 | 1238 | { |
1239 | - $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
|
1239 | + $pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); |
|
1240 | 1240 | } |
1241 | 1241 | } |
1242 | 1242 | |
1243 | - if($conf->global->PRODUCT_USE_UNITS) { |
|
1243 | + if ($conf->global->PRODUCT_USE_UNITS) { |
|
1244 | 1244 | $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); |
1245 | 1245 | if (empty($hidetop)) { |
1246 | 1246 | $pdf->SetXY($this->posxunit - 1, $tab_top + 1); |
@@ -1249,13 +1249,13 @@ discard block |
||
1249 | 1249 | } |
1250 | 1250 | } |
1251 | 1251 | |
1252 | - $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); |
|
1252 | + $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height); |
|
1253 | 1253 | if (empty($hidetop)) |
1254 | 1254 | { |
1255 | 1255 | if ($this->atleastonediscount) |
1256 | 1256 | { |
1257 | - $pdf->SetXY($this->posxdiscount-1, $tab_top+1); |
|
1258 | - $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C'); |
|
1257 | + $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1); |
|
1258 | + $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C'); |
|
1259 | 1259 | } |
1260 | 1260 | } |
1261 | 1261 | if ($this->atleastonediscount) |
@@ -1264,8 +1264,8 @@ discard block |
||
1264 | 1264 | } |
1265 | 1265 | if (empty($hidetop)) |
1266 | 1266 | { |
1267 | - $pdf->SetXY($this->postotalht-1, $tab_top+1); |
|
1268 | - $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C'); |
|
1267 | + $pdf->SetXY($this->postotalht - 1, $tab_top + 1); |
|
1268 | + $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C'); |
|
1269 | 1269 | } |
1270 | 1270 | } |
1271 | 1271 | |
@@ -1287,67 +1287,67 @@ discard block |
||
1287 | 1287 | |
1288 | 1288 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
1289 | 1289 | |
1290 | - pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
1290 | + pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); |
|
1291 | 1291 | |
1292 | 1292 | // Show Draft Watermark |
1293 | - if($object->statut==0 && (! empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK)) ) |
|
1293 | + if ($object->statut == 0 && (!empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK))) |
|
1294 | 1294 | { |
1295 | - pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK); |
|
1295 | + pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK); |
|
1296 | 1296 | } |
1297 | 1297 | |
1298 | - $pdf->SetTextColor(0,0,60); |
|
1299 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
1298 | + $pdf->SetTextColor(0, 0, 60); |
|
1299 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
1300 | 1300 | |
1301 | - $posy=$this->marge_haute; |
|
1302 | - $posx=$this->page_largeur-$this->marge_droite-100; |
|
1301 | + $posy = $this->marge_haute; |
|
1302 | + $posx = $this->page_largeur - $this->marge_droite - 100; |
|
1303 | 1303 | |
1304 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
1304 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
1305 | 1305 | |
1306 | 1306 | // Logo |
1307 | - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
1307 | + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
1308 | 1308 | if ($this->emetteur->logo) |
1309 | 1309 | { |
1310 | 1310 | if (is_readable($logo)) |
1311 | 1311 | { |
1312 | - $height=pdf_getHeightForLogo($logo); |
|
1313 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
1312 | + $height = pdf_getHeightForLogo($logo); |
|
1313 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
1314 | 1314 | } |
1315 | 1315 | else |
1316 | 1316 | { |
1317 | - $pdf->SetTextColor(200,0,0); |
|
1318 | - $pdf->SetFont('','B',$default_font_size - 2); |
|
1319 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
1317 | + $pdf->SetTextColor(200, 0, 0); |
|
1318 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
1319 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); |
|
1320 | 1320 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
1321 | 1321 | } |
1322 | 1322 | } |
1323 | 1323 | else |
1324 | 1324 | { |
1325 | - $text=$this->emetteur->name; |
|
1325 | + $text = $this->emetteur->name; |
|
1326 | 1326 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
1327 | 1327 | } |
1328 | 1328 | |
1329 | - $pdf->SetFont('','B',$default_font_size + 3); |
|
1330 | - $pdf->SetXY($posx,$posy); |
|
1331 | - $pdf->SetTextColor(0,0,60); |
|
1332 | - $title=$outputlangs->transnoentities("CommercialAsk"); |
|
1329 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
1330 | + $pdf->SetXY($posx, $posy); |
|
1331 | + $pdf->SetTextColor(0, 0, 60); |
|
1332 | + $title = $outputlangs->transnoentities("CommercialAsk"); |
|
1333 | 1333 | $pdf->MultiCell(100, 4, $title, '', 'R'); |
1334 | 1334 | |
1335 | - $pdf->SetFont('','B',$default_font_size); |
|
1335 | + $pdf->SetFont('', 'B', $default_font_size); |
|
1336 | 1336 | |
1337 | - $posy+=5; |
|
1338 | - $pdf->SetXY($posx,$posy); |
|
1339 | - $pdf->SetTextColor(0,0,60); |
|
1340 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); |
|
1337 | + $posy += 5; |
|
1338 | + $pdf->SetXY($posx, $posy); |
|
1339 | + $pdf->SetTextColor(0, 0, 60); |
|
1340 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); |
|
1341 | 1341 | |
1342 | - $posy+=1; |
|
1343 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1342 | + $posy += 1; |
|
1343 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
1344 | 1344 | |
1345 | 1345 | if ($object->ref_client) |
1346 | 1346 | { |
1347 | - $posy+=4; |
|
1348 | - $pdf->SetXY($posx,$posy); |
|
1349 | - $pdf->SetTextColor(0,0,60); |
|
1350 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); |
|
1347 | + $posy += 4; |
|
1348 | + $pdf->SetXY($posx, $posy); |
|
1349 | + $pdf->SetTextColor(0, 0, 60); |
|
1350 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); |
|
1351 | 1351 | } |
1352 | 1352 | /* PHFAVRE |
1353 | 1353 | $posy+=4; |
@@ -1358,28 +1358,28 @@ discard block |
||
1358 | 1358 | |
1359 | 1359 | if ($object->thirdparty->code_fournisseur) |
1360 | 1360 | { |
1361 | - $posy+=4; |
|
1362 | - $pdf->SetXY($posx,$posy); |
|
1363 | - $pdf->SetTextColor(0,0,60); |
|
1364 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); |
|
1361 | + $posy += 4; |
|
1362 | + $pdf->SetXY($posx, $posy); |
|
1363 | + $pdf->SetTextColor(0, 0, 60); |
|
1364 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); |
|
1365 | 1365 | } |
1366 | 1366 | |
1367 | 1367 | // Get contact |
1368 | 1368 | if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) |
1369 | 1369 | { |
1370 | - $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); |
|
1370 | + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); |
|
1371 | 1371 | if (count($arrayidcontact) > 0) |
1372 | 1372 | { |
1373 | - $usertmp=new User($this->db); |
|
1373 | + $usertmp = new User($this->db); |
|
1374 | 1374 | $usertmp->fetch($arrayidcontact[0]); |
1375 | - $posy+=4; |
|
1376 | - $pdf->SetXY($posx,$posy); |
|
1377 | - $pdf->SetTextColor(0,0,60); |
|
1375 | + $posy += 4; |
|
1376 | + $pdf->SetXY($posx, $posy); |
|
1377 | + $pdf->SetTextColor(0, 0, 60); |
|
1378 | 1378 | $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R'); |
1379 | 1379 | } |
1380 | 1380 | } |
1381 | 1381 | |
1382 | - $posy+=2; |
|
1382 | + $posy += 2; |
|
1383 | 1383 | |
1384 | 1384 | $top_shift = 0; |
1385 | 1385 | // Show list of linked objects |
@@ -1393,96 +1393,96 @@ discard block |
||
1393 | 1393 | if ($showaddress) |
1394 | 1394 | { |
1395 | 1395 | // Sender properties |
1396 | - $carac_emetteur=''; |
|
1396 | + $carac_emetteur = ''; |
|
1397 | 1397 | // Add internal contact of proposal if defined |
1398 | - $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); |
|
1398 | + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); |
|
1399 | 1399 | if (count($arrayidcontact) > 0) |
1400 | 1400 | { |
1401 | 1401 | $object->fetch_user($arrayidcontact[0]); |
1402 | - $labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name")); |
|
1403 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
1402 | + $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); |
|
1403 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
1404 | 1404 | } |
1405 | 1405 | |
1406 | 1406 | $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); |
1407 | 1407 | |
1408 | 1408 | // Show sender |
1409 | - $posy=42+$top_shift; |
|
1410 | - $posx=$this->marge_gauche; |
|
1411 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1412 | - $hautcadre=40; |
|
1409 | + $posy = 42 + $top_shift; |
|
1410 | + $posx = $this->marge_gauche; |
|
1411 | + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; |
|
1412 | + $hautcadre = 40; |
|
1413 | 1413 | |
1414 | 1414 | // Show sender frame |
1415 | - $pdf->SetTextColor(0,0,0); |
|
1416 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1417 | - $pdf->SetXY($posx,$posy-5); |
|
1418 | - $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); |
|
1419 | - $pdf->SetXY($posx,$posy); |
|
1420 | - $pdf->SetFillColor(230,230,230); |
|
1415 | + $pdf->SetTextColor(0, 0, 0); |
|
1416 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
1417 | + $pdf->SetXY($posx, $posy - 5); |
|
1418 | + $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); |
|
1419 | + $pdf->SetXY($posx, $posy); |
|
1420 | + $pdf->SetFillColor(230, 230, 230); |
|
1421 | 1421 | $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
1422 | - $pdf->SetTextColor(0,0,60); |
|
1422 | + $pdf->SetTextColor(0, 0, 60); |
|
1423 | 1423 | |
1424 | 1424 | // Show sender name |
1425 | - $pdf->SetXY($posx+2,$posy+3); |
|
1426 | - $pdf->SetFont('','B', $default_font_size); |
|
1425 | + $pdf->SetXY($posx + 2, $posy + 3); |
|
1426 | + $pdf->SetFont('', 'B', $default_font_size); |
|
1427 | 1427 | $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
1428 | - $posy=$pdf->getY(); |
|
1428 | + $posy = $pdf->getY(); |
|
1429 | 1429 | |
1430 | 1430 | // Show sender information |
1431 | - $pdf->SetXY($posx+2,$posy); |
|
1432 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1431 | + $pdf->SetXY($posx + 2, $posy); |
|
1432 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
1433 | 1433 | $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
1434 | 1434 | |
1435 | 1435 | |
1436 | 1436 | // If CUSTOMER contact defined, we use it |
1437 | - $usecontact=false; |
|
1438 | - $arrayidcontact=$object->getIdContact('external','CUSTOMER'); |
|
1437 | + $usecontact = false; |
|
1438 | + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); |
|
1439 | 1439 | if (count($arrayidcontact) > 0) |
1440 | 1440 | { |
1441 | - $usecontact=true; |
|
1442 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
1441 | + $usecontact = true; |
|
1442 | + $result = $object->fetch_contact($arrayidcontact[0]); |
|
1443 | 1443 | } |
1444 | 1444 | |
1445 | 1445 | // Recipient name |
1446 | - if (! empty($usecontact)) |
|
1446 | + if (!empty($usecontact)) |
|
1447 | 1447 | { |
1448 | 1448 | // On peut utiliser le nom de la societe du contact |
1449 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; |
|
1449 | + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; |
|
1450 | 1450 | else $socname = $object->thirdparty->name; |
1451 | - $carac_client_name=$outputlangs->convToOutputCharset($socname); |
|
1451 | + $carac_client_name = $outputlangs->convToOutputCharset($socname); |
|
1452 | 1452 | } |
1453 | 1453 | else |
1454 | 1454 | { |
1455 | - $carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name); |
|
1455 | + $carac_client_name = $outputlangs->convToOutputCharset($object->thirdparty->name); |
|
1456 | 1456 | } |
1457 | 1457 | |
1458 | - $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object); |
|
1458 | + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); |
|
1459 | 1459 | |
1460 | 1460 | // Show recipient |
1461 | - $widthrecbox=100; |
|
1462 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1463 | - $posy=42+$top_shift; |
|
1464 | - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
|
1465 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1461 | + $widthrecbox = 100; |
|
1462 | + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format |
|
1463 | + $posy = 42 + $top_shift; |
|
1464 | + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; |
|
1465 | + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; |
|
1466 | 1466 | |
1467 | 1467 | // Show recipient frame |
1468 | - $pdf->SetTextColor(0,0,0); |
|
1469 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1470 | - $pdf->SetXY($posx+2,$posy-5); |
|
1468 | + $pdf->SetTextColor(0, 0, 0); |
|
1469 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
1470 | + $pdf->SetXY($posx + 2, $posy - 5); |
|
1471 | 1471 | $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L'); |
1472 | 1472 | $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
1473 | 1473 | |
1474 | 1474 | // Show recipient name |
1475 | - $pdf->SetXY($posx+2,$posy+3); |
|
1476 | - $pdf->SetFont('','B', $default_font_size); |
|
1475 | + $pdf->SetXY($posx + 2, $posy + 3); |
|
1476 | + $pdf->SetFont('', 'B', $default_font_size); |
|
1477 | 1477 | $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); |
1478 | 1478 | |
1479 | 1479 | // Show recipient information |
1480 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1481 | - $pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4)); |
|
1480 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
1481 | + $pdf->SetXY($posx + 2, $posy + 4 + (dol_nboflines_bis($carac_client_name, 50) * 4)); |
|
1482 | 1482 | $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); |
1483 | 1483 | } |
1484 | 1484 | |
1485 | - $pdf->SetTextColor(0,0,0); |
|
1485 | + $pdf->SetTextColor(0, 0, 0); |
|
1486 | 1486 | return $top_shift; |
1487 | 1487 | } |
1488 | 1488 | |
@@ -1495,10 +1495,10 @@ discard block |
||
1495 | 1495 | * @param int $hidefreetext 1=Hide free text |
1496 | 1496 | * @return int Return height of bottom margin including footer text |
1497 | 1497 | */ |
1498 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
1498 | + function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) |
|
1499 | 1499 | { |
1500 | 1500 | global $conf; |
1501 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1502 | - return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_PROPOSAL_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
1501 | + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1502 | + return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); |
|
1503 | 1503 | } |
1504 | 1504 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \brief File of class to manage commercial proposal numbering rules Marbre |
24 | 24 | */ |
25 | 25 | |
26 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_proposal/modules_supplier_proposal.php'; |
|
26 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_proposal/modules_supplier_proposal.php'; |
|
27 | 27 | |
28 | 28 | |
29 | 29 | /** |
@@ -35,26 +35,26 @@ discard block |
||
35 | 35 | * Dolibarr version of the loaded document |
36 | 36 | * @public string |
37 | 37 | */ |
38 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
39 | 39 | |
40 | - public $prefix='RQ'; // RQ = Request for quotation |
|
40 | + public $prefix = 'RQ'; // RQ = Request for quotation |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @var string Error code (or message) |
44 | 44 | */ |
45 | - public $error=''; |
|
45 | + public $error = ''; |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * @var string Nom du modele |
49 | 49 | * @deprecated |
50 | 50 | * @see name |
51 | 51 | */ |
52 | - public $nom='Marbre'; |
|
52 | + public $nom = 'Marbre'; |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @var string model name |
56 | 56 | */ |
57 | - public $name='Marbre'; |
|
57 | + public $name = 'Marbre'; |
|
58 | 58 | |
59 | 59 | |
60 | 60 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | function info() |
66 | 66 | { |
67 | 67 | global $langs; |
68 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
68 | + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
@@ -88,31 +88,31 @@ discard block |
||
88 | 88 | */ |
89 | 89 | function canBeActivated() |
90 | 90 | { |
91 | - global $conf,$langs,$db; |
|
91 | + global $conf, $langs, $db; |
|
92 | 92 | |
93 | - $pryymm=''; $max=''; |
|
93 | + $pryymm = ''; $max = ''; |
|
94 | 94 | |
95 | - $posindice=8; |
|
95 | + $posindice = 8; |
|
96 | 96 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
97 | - $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal"; |
|
98 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
99 | - $sql.= " AND entity = ".$conf->entity; |
|
97 | + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal"; |
|
98 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
99 | + $sql .= " AND entity = ".$conf->entity; |
|
100 | 100 | |
101 | - $resql=$db->query($sql); |
|
101 | + $resql = $db->query($sql); |
|
102 | 102 | if ($resql) |
103 | 103 | { |
104 | 104 | $row = $db->fetch_row($resql); |
105 | - if ($row) { $pryymm = substr($row[0],0,6); $max=$row[0]; } |
|
105 | + if ($row) { $pryymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
106 | 106 | } |
107 | 107 | |
108 | - if (! $pryymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$pryymm)) |
|
108 | + if (!$pryymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $pryymm)) |
|
109 | 109 | { |
110 | 110 | return true; |
111 | 111 | } |
112 | 112 | else |
113 | 113 | { |
114 | 114 | $langs->load("errors"); |
115 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
115 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
116 | 116 | return false; |
117 | 117 | } |
118 | 118 | } |
@@ -124,23 +124,23 @@ discard block |
||
124 | 124 | * @param Propal $supplier_proposal Object commercial proposal |
125 | 125 | * @return string Next value |
126 | 126 | */ |
127 | - function getNextValue($objsoc,$supplier_proposal) |
|
127 | + function getNextValue($objsoc, $supplier_proposal) |
|
128 | 128 | { |
129 | - global $db,$conf; |
|
129 | + global $db, $conf; |
|
130 | 130 | |
131 | 131 | // D'abord on recupere la valeur max |
132 | - $posindice=8; |
|
133 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
134 | - $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal"; |
|
135 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
136 | - $sql.= " AND entity = ".$conf->entity; |
|
132 | + $posindice = 8; |
|
133 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
134 | + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal"; |
|
135 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
136 | + $sql .= " AND entity = ".$conf->entity; |
|
137 | 137 | |
138 | - $resql=$db->query($sql); |
|
138 | + $resql = $db->query($sql); |
|
139 | 139 | if ($resql) |
140 | 140 | { |
141 | 141 | $obj = $db->fetch_object($resql); |
142 | 142 | if ($obj) $max = intval($obj->max); |
143 | - else $max=0; |
|
143 | + else $max = 0; |
|
144 | 144 | } |
145 | 145 | else |
146 | 146 | { |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | $date = time(); |
152 | - $yymm = strftime("%y%m",$date); |
|
152 | + $yymm = strftime("%y%m", $date); |
|
153 | 153 | |
154 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
155 | - else $num = sprintf("%04s",$max+1); |
|
154 | + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
155 | + else $num = sprintf("%04s", $max + 1); |
|
156 | 156 | |
157 | 157 | dol_syslog(get_class($this)."::getNextValue return ".$this->prefix.$yymm."-".$num); |
158 | 158 | return $this->prefix.$yymm."-".$num; |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | * @param Object $objforref Object for number to search |
166 | 166 | * @return string Next free value |
167 | 167 | */ |
168 | - function getNumRef($objsoc,$objforref) |
|
168 | + function getNumRef($objsoc, $objforref) |
|
169 | 169 | { |
170 | - return $this->getNextValue($objsoc,$objforref); |
|
170 | + return $this->getNextValue($objsoc, $objforref); |
|
171 | 171 | } |
172 | 172 | } |