@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | // Turning on or off the ssl target certificate |
| 87 | 87 | if ($ssl_verifypeer < 0) { |
| 88 | 88 | global $dolibarr_main_prod; |
| 89 | - $ssl_verifypeer = ($dolibarr_main_prod ? true : false); |
|
| 89 | + $ssl_verifypeer = ($dolibarr_main_prod ? true : false); |
|
| 90 | 90 | } |
| 91 | 91 | if (getDolGlobalString('MAIN_CURL_DISABLE_VERIFYPEER')) { |
| 92 | 92 | $ssl_verifypeer = 0; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | // limit size of downloaded files. |
| 124 | 124 | $maxsize = getDolGlobalInt('MAIN_SECURITY_MAXFILESIZE_DOWNLOADED'); |
| 125 | 125 | if ($maxsize && defined('CURLOPT_MAXFILESIZE_LARGE')) { |
| 126 | - curl_setopt($ch, CURLOPT_MAXFILESIZE_LARGE, $maxsize); // @phan-suppress-current-line PhanTypeMismatchArgumentNullableInternal |
|
| 126 | + curl_setopt($ch, CURLOPT_MAXFILESIZE_LARGE, $maxsize); // @phan-suppress-current-line PhanTypeMismatchArgumentNullableInternal |
|
| 127 | 127 | } |
| 128 | 128 | if ($maxsize && defined('CURLOPT_MAXFILESIZE')) { |
| 129 | 129 | curl_setopt($ch, CURLOPT_MAXFILESIZE, $maxsize); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | $array_param = null; |
| 142 | 142 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT' |
| 143 | 143 | if (!is_array($param)) { |
| 144 | - parse_str($param, $array_param); // @phan-suppress-current-line PhanPluginConstantVariableNull |
|
| 144 | + parse_str($param, $array_param); // @phan-suppress-current-line PhanPluginConstantVariableNull |
|
| 145 | 145 | } else { |
| 146 | 146 | dol_syslog("parameter param must be a string", LOG_WARNING); |
| 147 | 147 | $array_param = $param; |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | |
| 245 | 245 | // Getting response from server |
| 246 | - $response = curl_exec($ch); // return false on error, result on success |
|
| 246 | + $response = curl_exec($ch); // return false on error, result on success |
|
| 247 | 247 | |
| 248 | 248 | $info = curl_getinfo($ch); // Reading of request must be done after sending request |
| 249 | 249 | $http_code = $info['http_code']; |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | class Odf |
| 32 | 32 | { |
| 33 | 33 | protected $config = array( |
| 34 | - 'ZIP_PROXY' => 'PclZipProxy', // PclZipProxy, PhpZipProxy |
|
| 34 | + 'ZIP_PROXY' => 'PclZipProxy', // PclZipProxy, PhpZipProxy |
|
| 35 | 35 | 'DELIMITER_LEFT' => '{', |
| 36 | 36 | 'DELIMITER_RIGHT' => '}', |
| 37 | 37 | 'PATH_TO_TMP' => '/tmp' |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | { |
| 107 | 107 | clearstatcache(); |
| 108 | 108 | |
| 109 | - if (! is_array($config)) { |
|
| 109 | + if (!is_array($config)) { |
|
| 110 | 110 | throw new OdfException('Configuration data must be provided as array'); |
| 111 | 111 | } |
| 112 | 112 | foreach ($config as $configKey => $configValue) { |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | $md5uniqid = md5(uniqid()); |
| 119 | - if ($this->config['PATH_TO_TMP']) $this->tmpdir = preg_replace('|[\/]$|', '', $this->config['PATH_TO_TMP']); // Remove last \ or / |
|
| 120 | - $this->tmpdir .= ($this->tmpdir?'/':'').$md5uniqid; |
|
| 121 | - $this->tmpfile = $this->tmpdir.'/'.$md5uniqid.'.odt'; // We keep .odt extension to allow OpenOffice usage during debug. |
|
| 119 | + if ($this->config['PATH_TO_TMP']) $this->tmpdir = preg_replace('|[\/]$|', '', $this->config['PATH_TO_TMP']); // Remove last \ or / |
|
| 120 | + $this->tmpdir .= ($this->tmpdir ? '/' : '').$md5uniqid; |
|
| 121 | + $this->tmpfile = $this->tmpdir.'/'.$md5uniqid.'.odt'; // We keep .odt extension to allow OpenOffice usage during debug. |
|
| 122 | 122 | |
| 123 | 123 | // A working directory is required for some zip proxy like PclZipProxy |
| 124 | - if (in_array($this->config['ZIP_PROXY'], array('PclZipProxy')) && ! is_dir($this->config['PATH_TO_TMP'])) { |
|
| 124 | + if (in_array($this->config['ZIP_PROXY'], array('PclZipProxy')) && !is_dir($this->config['PATH_TO_TMP'])) { |
|
| 125 | 125 | throw new OdfException('Temporary directory '.$this->config['PATH_TO_TMP'].' must exists'); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | $zipHandler = $this->config['ZIP_PROXY']; |
| 135 | 135 | if (!defined('PCLZIP_TEMPORARY_DIR')) define('PCLZIP_TEMPORARY_DIR', $this->tmpdir); |
| 136 | 136 | include_once 'zip/'.$zipHandler.'.php'; |
| 137 | - if (! class_exists($this->config['ZIP_PROXY'])) { |
|
| 138 | - throw new OdfException($this->config['ZIP_PROXY'] . ' class not found - check your php settings'); |
|
| 137 | + if (!class_exists($this->config['ZIP_PROXY'])) { |
|
| 138 | + throw new OdfException($this->config['ZIP_PROXY'].' class not found - check your php settings'); |
|
| 139 | 139 | } |
| 140 | 140 | $this->file = new $zipHandler($this->tmpdir); |
| 141 | 141 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | public function setVars($key, $value, $encode = true, $charset = 'ISO-8859') |
| 184 | 184 | { |
| 185 | - $tag = $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']; |
|
| 185 | + $tag = $this->config['DELIMITER_LEFT'].$key.$this->config['DELIMITER_RIGHT']; |
|
| 186 | 186 | |
| 187 | 187 | // TODO Warning string may be: |
| 188 | 188 | // <text:span text:style-name="T13">{</text:span><text:span text:style-name="T12">aaa</text:span><text:span text:style-name="T13">}</text:span> |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | |
| 218 | 218 | // Check if the value includes html tags |
| 219 | 219 | if ($this->_hasHtmlTag($value) === true) { |
| 220 | - $value = strip_tags($value, '<br><strong><b><i><em><u><s><sub><sup><span>'); // remove html tags except the one into the list in second parameter |
|
| 220 | + $value = strip_tags($value, '<br><strong><b><i><em><u><s><sub><sup><span>'); // remove html tags except the one into the list in second parameter |
|
| 221 | 221 | |
| 222 | 222 | // Default styles for strong/b, i/em, u, s, sub & sup |
| 223 | 223 | $automaticStyles = array( |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | $convertedValue = $this->_replaceHtmlWithOdtTag($this->_getDataFromHtml($value), $customStyles, $fontDeclarations, $encode, $charset); |
| 236 | 236 | |
| 237 | 237 | foreach ($customStyles as $key => $val) { |
| 238 | - array_push($automaticStyles, '<style:style style:name="customStyle' . $key . '" style:family="text">' . $val . '</style:style>'); |
|
| 238 | + array_push($automaticStyles, '<style:style style:name="customStyle'.$key.'" style:family="text">'.$val.'</style:style>'); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | // Join the styles and add them to the content xml |
@@ -245,16 +245,16 @@ discard block |
||
| 245 | 245 | $styles .= $style; |
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | - $this->contentXml = str_replace('</office:automatic-styles>', $styles . '</office:automatic-styles>', $this->contentXml); |
|
| 248 | + $this->contentXml = str_replace('</office:automatic-styles>', $styles.'</office:automatic-styles>', $this->contentXml); |
|
| 249 | 249 | |
| 250 | 250 | // Join the font declarations and add them to the content xml |
| 251 | 251 | $fonts = ''; |
| 252 | 252 | foreach ($fontDeclarations as $font) { |
| 253 | - if (strpos($this->contentXml, 'style:name="' . $font . '"') === false) { |
|
| 254 | - $fonts .= '<style:font-face style:name="' . $font . '" svg:font-family="\'' . $font . '\'" />'; |
|
| 253 | + if (strpos($this->contentXml, 'style:name="'.$font.'"') === false) { |
|
| 254 | + $fonts .= '<style:font-face style:name="'.$font.'" svg:font-family="\''.$font.'\'" />'; |
|
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | - $this->contentXml = str_replace('</office:font-face-decls>', $fonts . '</office:font-face-decls>', $this->contentXml); |
|
| 257 | + $this->contentXml = str_replace('</office:font-face-decls>', $fonts.'</office:font-face-decls>', $this->contentXml); |
|
| 258 | 258 | } else { |
| 259 | 259 | $convertedValue = $this->encode_chars($convertedValue, $encode, $charset); |
| 260 | 260 | $convertedValue = preg_replace('/(\r\n|\r|\n)/i', "<text:line-break/>", $convertedValue); |
@@ -291,23 +291,23 @@ discard block |
||
| 291 | 291 | break; |
| 292 | 292 | case 'strong': |
| 293 | 293 | case 'b': |
| 294 | - $odtResult .= '<text:span text:style-name="boldText">' . ($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)) . '</text:span>'; |
|
| 294 | + $odtResult .= '<text:span text:style-name="boldText">'.($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)).'</text:span>'; |
|
| 295 | 295 | break; |
| 296 | 296 | case 'i': |
| 297 | 297 | case 'em': |
| 298 | - $odtResult .= '<text:span text:style-name="italicText">' . ($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)) . '</text:span>'; |
|
| 298 | + $odtResult .= '<text:span text:style-name="italicText">'.($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)).'</text:span>'; |
|
| 299 | 299 | break; |
| 300 | 300 | case 'u': |
| 301 | - $odtResult .= '<text:span text:style-name="underlineText">' . ($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)) . '</text:span>'; |
|
| 301 | + $odtResult .= '<text:span text:style-name="underlineText">'.($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)).'</text:span>'; |
|
| 302 | 302 | break; |
| 303 | 303 | case 's': |
| 304 | - $odtResult .= '<text:span text:style-name="strikethroughText">' . ($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)) . '</text:span>'; |
|
| 304 | + $odtResult .= '<text:span text:style-name="strikethroughText">'.($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)).'</text:span>'; |
|
| 305 | 305 | break; |
| 306 | 306 | case 'sub': |
| 307 | - $odtResult .= '<text:span text:style-name="subText">' . ($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)) . '</text:span>'; |
|
| 307 | + $odtResult .= '<text:span text:style-name="subText">'.($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)).'</text:span>'; |
|
| 308 | 308 | break; |
| 309 | 309 | case 'sup': |
| 310 | - $odtResult .= '<text:span text:style-name="supText">' . ($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)) . '</text:span>'; |
|
| 310 | + $odtResult .= '<text:span text:style-name="supText">'.($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)).'</text:span>'; |
|
| 311 | 311 | break; |
| 312 | 312 | case 'span': |
| 313 | 313 | if (isset($tag['attributes']['style'])) { |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | if (!in_array($fontName, $fontDeclarations)) { |
| 323 | 323 | array_push($fontDeclarations, $fontName); |
| 324 | 324 | } |
| 325 | - $odtStyles .= '<style:text-properties style:font-name="' . $fontName . '" />'; |
|
| 325 | + $odtStyles .= '<style:text-properties style:font-name="'.$fontName.'" />'; |
|
| 326 | 326 | break; |
| 327 | 327 | case 'font-size': |
| 328 | 328 | if (preg_match('/([0-9]+)\s?(px|pt)/', $styleValue, $matches)) { |
@@ -330,21 +330,21 @@ discard block |
||
| 330 | 330 | if ($matches[2] == 'px') { |
| 331 | 331 | $fontSize = round($fontSize * 0.75); |
| 332 | 332 | } |
| 333 | - $odtStyles .= '<style:text-properties fo:font-size="' . $fontSize . 'pt" style:font-size-asian="' . $fontSize . 'pt" style:font-size-complex="' . $fontSize . 'pt" />'; |
|
| 333 | + $odtStyles .= '<style:text-properties fo:font-size="'.$fontSize.'pt" style:font-size-asian="'.$fontSize.'pt" style:font-size-complex="'.$fontSize.'pt" />'; |
|
| 334 | 334 | } |
| 335 | 335 | break; |
| 336 | 336 | case 'color': |
| 337 | 337 | if (preg_match('/#[0-9A-Fa-f]{3}(?:[0-9A-Fa-f]{3})?/', $styleValue)) { |
| 338 | - $odtStyles .= '<style:text-properties fo:color="' . $styleValue . '" />'; |
|
| 338 | + $odtStyles .= '<style:text-properties fo:color="'.$styleValue.'" />'; |
|
| 339 | 339 | } |
| 340 | 340 | break; |
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | if (strlen($odtStyles) > 0) { |
| 344 | 344 | // Generate a unique id for the style (using microtime and random because some CPUs are really fast...) |
| 345 | - $key = str_replace('.', '', (string) microtime(true)) . uniqid(mt_rand()); |
|
| 345 | + $key = str_replace('.', '', (string) microtime(true)).uniqid(mt_rand()); |
|
| 346 | 346 | $customStyles[$key] = $odtStyles; |
| 347 | - $odtResult .= '<text:span text:style-name="customStyle' . $key . '">' . ($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)) . '</text:span>'; |
|
| 347 | + $odtResult .= '<text:span text:style-name="customStyle'.$key.'">'.($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)).'</text:span>'; |
|
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | break; |
@@ -483,24 +483,24 @@ discard block |
||
| 483 | 483 | public function htmlToUTFAndPreOdf($value) |
| 484 | 484 | { |
| 485 | 485 | // We decode into utf8, entities |
| 486 | - $value=dol_html_entity_decode($value, ENT_QUOTES|ENT_HTML5); |
|
| 486 | + $value = dol_html_entity_decode($value, ENT_QUOTES | ENT_HTML5); |
|
| 487 | 487 | |
| 488 | 488 | // We convert html tags |
| 489 | - $ishtml=dol_textishtml($value); |
|
| 489 | + $ishtml = dol_textishtml($value); |
|
| 490 | 490 | if ($ishtml) { |
| 491 | 491 | // If string is "MYPODUCT - Desc <strong>bold</strong> with é accent<br />\n<br />\nUn texto en español ?" |
| 492 | 492 | // Result after clean must be "MYPODUCT - Desc bold with é accent\n\nUn texto en español ?" |
| 493 | 493 | |
| 494 | 494 | // We want to ignore \n and we want all <br> to be \n |
| 495 | - $value=preg_replace('/(\r\n|\r|\n)/i', '', $value); |
|
| 496 | - $value=preg_replace('/<br>/i', "\n", $value); |
|
| 497 | - $value=preg_replace('/<br\s+[^<>\/]*>/i', "\n", $value); |
|
| 498 | - $value=preg_replace('/<br\s+[^<>\/]*\/>/i', "\n", $value); |
|
| 495 | + $value = preg_replace('/(\r\n|\r|\n)/i', '', $value); |
|
| 496 | + $value = preg_replace('/<br>/i', "\n", $value); |
|
| 497 | + $value = preg_replace('/<br\s+[^<>\/]*>/i', "\n", $value); |
|
| 498 | + $value = preg_replace('/<br\s+[^<>\/]*\/>/i', "\n", $value); |
|
| 499 | 499 | |
| 500 | 500 | //$value=preg_replace('/<strong>/','__lt__text:p text:style-name=__quot__bold__quot____gt__',$value); |
| 501 | 501 | //$value=preg_replace('/<\/strong>/','__lt__/text:p__gt__',$value); |
| 502 | 502 | |
| 503 | - $value=dol_string_nohtmltag($value, 0); |
|
| 503 | + $value = dol_string_nohtmltag($value, 0); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | return $value; |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | * @throws OdfException |
| 534 | 534 | * @return odf |
| 535 | 535 | */ |
| 536 | - public function setImage($key, $value, float $ratio=1) |
|
| 536 | + public function setImage($key, $value, float $ratio = 1) |
|
| 537 | 537 | { |
| 538 | 538 | $filename = strtok(strrchr($value, '/'), '/.'); |
| 539 | 539 | $file = substr(strrchr($value, '/'), 1); |
@@ -577,10 +577,10 @@ discard block |
||
| 577 | 577 | $balise = str_replace('row.', '', $matches2[1]); |
| 578 | 578 | // Move segment tags around the row |
| 579 | 579 | $replace = array( |
| 580 | - '[!-- BEGIN ' . $matches2[1] . ' --]' => '', |
|
| 581 | - '[!-- END ' . $matches2[1] . ' --]' => '', |
|
| 582 | - '<table:table-row' => '[!-- BEGIN ' . $balise . ' --]<table:table-row', |
|
| 583 | - '</table:table-row>' => '</table:table-row>[!-- END ' . $balise . ' --]' |
|
| 580 | + '[!-- BEGIN '.$matches2[1].' --]' => '', |
|
| 581 | + '[!-- END '.$matches2[1].' --]' => '', |
|
| 582 | + '<table:table-row' => '[!-- BEGIN '.$balise.' --]<table:table-row', |
|
| 583 | + '</table:table-row>' => '</table:table-row>[!-- END '.$balise.' --]' |
|
| 584 | 584 | ); |
| 585 | 585 | $replacedXML = str_replace(array_keys($replace), array_values($replace), $matches[0][$i]); |
| 586 | 586 | $this->contentXml = str_replace($matches[0][$i], $replacedXML, $this->contentXml); |
@@ -603,13 +603,13 @@ discard block |
||
| 603 | 603 | else return; |
| 604 | 604 | |
| 605 | 605 | // Search all tags found into condition to complete $this->vars, so we will proceed all tests even if not defined |
| 606 | - $reg='@\[!--\sIF\s([\[\]{}a-zA-Z0-9\.\,_]+)\s--\]@smU'; |
|
| 606 | + $reg = '@\[!--\sIF\s([\[\]{}a-zA-Z0-9\.\,_]+)\s--\]@smU'; |
|
| 607 | 607 | $matches = array(); |
| 608 | 608 | preg_match_all($reg, $xml, $matches, PREG_SET_ORDER); |
| 609 | 609 | |
| 610 | 610 | foreach ($matches as $match) { // For each match, if there is no entry into this->vars, we add it |
| 611 | - if (! empty($match[1]) && ! isset($this->vars[$match[1]])) { |
|
| 612 | - $this->vars[$match[1]] = ''; // Not defined, so we set it to '', we just need entry into this->vars for next loop |
|
| 611 | + if (!empty($match[1]) && !isset($this->vars[$match[1]])) { |
|
| 612 | + $this->vars[$match[1]] = ''; // Not defined, so we set it to '', we just need entry into this->vars for next loop |
|
| 613 | 613 | } |
| 614 | 614 | } |
| 615 | 615 | |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | // Remove the IF tag |
| 624 | 624 | $xml = str_replace('[!-- IF '.$key.' --]', '', $xml); |
| 625 | 625 | // Remove everything between the ELSE tag (if it exists) and the ENDIF tag |
| 626 | - $reg = '@(\[!--\sELSE\s' . preg_quote($key, '@') . '\s--\](.*))?\[!--\sENDIF\s' . preg_quote($key, '@') . '\s--\]@smU'; // U modifier = all quantifiers are non-greedy |
|
| 626 | + $reg = '@(\[!--\sELSE\s'.preg_quote($key, '@').'\s--\](.*))?\[!--\sENDIF\s'.preg_quote($key, '@').'\s--\]@smU'; // U modifier = all quantifiers are non-greedy |
|
| 627 | 627 | $xml = preg_replace($reg, '', $xml); |
| 628 | 628 | /*if ($sav != $xml) |
| 629 | 629 | { |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | //dol_syslog("Var ".$key." is not defined, we remove the IF, ELSE and ENDIF "); |
| 637 | 637 | //$sav=$xml; |
| 638 | 638 | // Find all conditional blocks for this variable: from IF to ELSE and to ENDIF |
| 639 | - $reg = '@\[!--\sIF\s' . preg_quote($key, '@') . '\s--\](.*)(\[!--\sELSE\s' . preg_quote($key, '@') . '\s--\](.*))?\[!--\sENDIF\s' . preg_quote($key, '@') . '\s--\]@smU'; // U modifier = all quantifiers are non-greedy |
|
| 639 | + $reg = '@\[!--\sIF\s'.preg_quote($key, '@').'\s--\](.*)(\[!--\sELSE\s'.preg_quote($key, '@').'\s--\](.*))?\[!--\sENDIF\s'.preg_quote($key, '@').'\s--\]@smU'; // U modifier = all quantifiers are non-greedy |
|
| 640 | 640 | preg_match_all($reg, $xml, $matches, PREG_SET_ORDER); |
| 641 | 641 | foreach ($matches as $match) { // For each match, if there is an ELSE clause, we replace the whole block by the value in the ELSE clause |
| 642 | 642 | if (!empty($match[3])) $xml = str_replace($match[0], $match[3], $xml); |
@@ -664,12 +664,12 @@ discard block |
||
| 664 | 664 | */ |
| 665 | 665 | public function mergeSegment(Segment $segment) |
| 666 | 666 | { |
| 667 | - if (! array_key_exists($segment->getName(), $this->segments)) { |
|
| 668 | - throw new OdfException($segment->getName() . 'cannot be parsed, has it been set yet ?'); |
|
| 667 | + if (!array_key_exists($segment->getName(), $this->segments)) { |
|
| 668 | + throw new OdfException($segment->getName().'cannot be parsed, has it been set yet ?'); |
|
| 669 | 669 | } |
| 670 | 670 | $string = $segment->getName(); |
| 671 | 671 | // $reg = '@<text:p[^>]*>\[!--\sBEGIN\s' . $string . '\s--\](.*)\[!--.+END\s' . $string . '\s--\]<\/text:p>@smU'; |
| 672 | - $reg = '@\[!--\sBEGIN\s' . $string . '\s--\](.*)\[!--.+END\s' . $string . '\s--\]@smU'; |
|
| 672 | + $reg = '@\[!--\sBEGIN\s'.$string.'\s--\](.*)\[!--.+END\s'.$string.'\s--\]@smU'; |
|
| 673 | 673 | $this->contentXml = preg_replace($reg, $segment->getXmlParsed(), $this->contentXml); |
| 674 | 674 | return $this; |
| 675 | 675 | } |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | */ |
| 682 | 682 | public function printVars() |
| 683 | 683 | { |
| 684 | - return print_r('<pre>' . print_r($this->vars, true) . '</pre>', true); |
|
| 684 | + return print_r('<pre>'.print_r($this->vars, true).'</pre>', true); |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | /** |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | */ |
| 703 | 703 | public function printDeclaredSegments() |
| 704 | 704 | { |
| 705 | - return '<pre>' . print_r(implode(' ', array_keys($this->segments)), true) . '</pre>'; |
|
| 705 | + return '<pre>'.print_r(implode(' ', array_keys($this->segments)), true).'</pre>'; |
|
| 706 | 706 | } |
| 707 | 707 | |
| 708 | 708 | /** |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | { |
| 739 | 739 | if ($file !== null && is_string($file)) { |
| 740 | 740 | if (file_exists($file) && !(is_file($file) && is_writable($file))) { |
| 741 | - throw new OdfException('Permission denied : can\'t create ' . $file); |
|
| 741 | + throw new OdfException('Permission denied : can\'t create '.$file); |
|
| 742 | 742 | } |
| 743 | 743 | $this->_save(); |
| 744 | 744 | copy($this->tmpfile, $file); |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | */ |
| 756 | 756 | private function _save() |
| 757 | 757 | { |
| 758 | - $res=$this->file->open($this->tmpfile); // tmpfile is odt template |
|
| 758 | + $res = $this->file->open($this->tmpfile); // tmpfile is odt template |
|
| 759 | 759 | $this->_parse('content'); |
| 760 | 760 | $this->_parse('styles'); |
| 761 | 761 | $this->_parse('meta'); |
@@ -763,23 +763,23 @@ discard block |
||
| 763 | 763 | $this->setMetaData(); |
| 764 | 764 | //print $this->metaXml;exit; |
| 765 | 765 | |
| 766 | - if (! $this->file->addFromString('content.xml', $this->contentXml)) { |
|
| 766 | + if (!$this->file->addFromString('content.xml', $this->contentXml)) { |
|
| 767 | 767 | throw new OdfException('Error during file export addFromString content'); |
| 768 | 768 | } |
| 769 | - if (! $this->file->addFromString('meta.xml', $this->metaXml)) { |
|
| 769 | + if (!$this->file->addFromString('meta.xml', $this->metaXml)) { |
|
| 770 | 770 | throw new OdfException('Error during file export addFromString meta'); |
| 771 | 771 | } |
| 772 | - if (! $this->file->addFromString('styles.xml', $this->stylesXml)) { |
|
| 772 | + if (!$this->file->addFromString('styles.xml', $this->stylesXml)) { |
|
| 773 | 773 | throw new OdfException('Error during file export addFromString styles'); |
| 774 | 774 | } |
| 775 | 775 | |
| 776 | 776 | foreach ($this->images as $imageKey => $imageValue) { |
| 777 | 777 | // Add the image inside the ODT document |
| 778 | - $this->file->addFile($imageKey, 'Pictures/' . $imageValue); |
|
| 778 | + $this->file->addFile($imageKey, 'Pictures/'.$imageValue); |
|
| 779 | 779 | // Add the image to the Manifest (which maintains a list of images, necessary to avoid "Corrupt ODT file. Repair?" when opening the file with LibreOffice) |
| 780 | 780 | $this->addImageToManifest($imageValue); |
| 781 | 781 | } |
| 782 | - if (! $this->file->addFromString('META-INF/manifest.xml', $this->manifestXml)) { |
|
| 782 | + if (!$this->file->addFromString('META-INF/manifest.xml', $this->manifestXml)) { |
|
| 783 | 783 | throw new OdfException('Error during file export: manifest.xml'); |
| 784 | 784 | } |
| 785 | 785 | $this->file->close(); |
@@ -793,7 +793,7 @@ discard block |
||
| 793 | 793 | */ |
| 794 | 794 | public function setMetaData() |
| 795 | 795 | { |
| 796 | - if (empty($this->creator)) $this->creator=''; |
|
| 796 | + if (empty($this->creator)) $this->creator = ''; |
|
| 797 | 797 | |
| 798 | 798 | $this->metaXml = preg_replace('/<dc:date>.*<\/dc:date>/', '<dc:date>'.gmdate("Y-m-d\TH:i:s").'</dc:date>', $this->metaXml); |
| 799 | 799 | $this->metaXml = preg_replace('/<dc:creator>.*<\/dc:creator>/', '<dc:creator>'.htmlspecialchars($this->creator).'</dc:creator>', $this->metaXml); |
@@ -842,8 +842,8 @@ discard block |
||
| 842 | 842 | throw new OdfException("headers already sent ($filename at $linenum)"); |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - if ( $name == "" ) { |
|
| 846 | - $name = md5(uniqid()) . ".odt"; |
|
| 845 | + if ($name == "") { |
|
| 846 | + $name = md5(uniqid()).".odt"; |
|
| 847 | 847 | } |
| 848 | 848 | |
| 849 | 849 | header('Content-type: application/vnd.oasis.opendocument.text'); |
@@ -864,18 +864,18 @@ discard block |
||
| 864 | 864 | { |
| 865 | 865 | global $conf; |
| 866 | 866 | |
| 867 | - if ( $name == "" ) $name = "temp".md5(uniqid()); |
|
| 867 | + if ($name == "") $name = "temp".md5(uniqid()); |
|
| 868 | 868 | |
| 869 | 869 | dol_syslog(get_class($this).'::exportAsAttachedPDF $name='.$name, LOG_DEBUG); |
| 870 | 870 | $this->saveToDisk($name); |
| 871 | 871 | |
| 872 | - $execmethod = (getDolGlobalString('MAIN_EXEC_USE_POPEN') ? 2 : 1); // 1 or 2 |
|
| 872 | + $execmethod = (getDolGlobalString('MAIN_EXEC_USE_POPEN') ? 2 : 1); // 1 or 2 |
|
| 873 | 873 | // Method 1 sometimes hang the server. |
| 874 | 874 | |
| 875 | 875 | |
| 876 | 876 | // Export to PDF using LibreOffice |
| 877 | 877 | if (getDolGlobalString('MAIN_ODT_AS_PDF') == 'libreoffice') { |
| 878 | - dol_mkdir($conf->user->dir_temp); // We must be sure the directory exists and is writable |
|
| 878 | + dol_mkdir($conf->user->dir_temp); // We must be sure the directory exists and is writable |
|
| 879 | 879 | |
| 880 | 880 | // We delete and recreate a subdir because the soffice may have change pemrissions on it |
| 881 | 881 | $countdeleted = 0; |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | // using windows libreoffice that must be in path |
| 887 | 887 | // using linux/mac libreoffice that must be in path |
| 888 | 888 | // Note PHP Config "fastcgi.impersonate=0" must set to 0 - Default is 1 |
| 889 | - $command ='soffice --headless -env:UserInstallation=file:'.(getDolGlobalString('MAIN_ODT_ADD_SLASH_FOR_WINDOWS') ? '///' : '').'\''.$conf->user->dir_temp.'/odtaspdf\' --convert-to pdf --outdir '. escapeshellarg(dirname($name)). " ".escapeshellarg($name); |
|
| 889 | + $command = 'soffice --headless -env:UserInstallation=file:'.(getDolGlobalString('MAIN_ODT_ADD_SLASH_FOR_WINDOWS') ? '///' : '').'\''.$conf->user->dir_temp.'/odtaspdf\' --convert-to pdf --outdir '.escapeshellarg(dirname($name))." ".escapeshellarg($name); |
|
| 890 | 890 | } elseif (preg_match('/unoconv/', getDolGlobalString('MAIN_ODT_AS_PDF'))) { |
| 891 | 891 | // If issue with unoconv, see https://github.com/dagwieers/unoconv/issues/87 |
| 892 | 892 | |
@@ -916,13 +916,13 @@ discard block |
||
| 916 | 916 | //$command = '/usr/bin/unoconv -vvv '.escapeshellcmd($name); |
| 917 | 917 | } else { |
| 918 | 918 | // deprecated old method using odt2pdf.sh (native, jodconverter, ...) |
| 919 | - $tmpname=preg_replace('/\.odt/i', '', $name); |
|
| 919 | + $tmpname = preg_replace('/\.odt/i', '', $name); |
|
| 920 | 920 | |
| 921 | 921 | if (getDolGlobalString('MAIN_DOL_SCRIPTS_ROOT')) { |
| 922 | - $command = getDolGlobalString('MAIN_DOL_SCRIPTS_ROOT').'/scripts/odt2pdf/odt2pdf.sh '.escapeshellcmd($tmpname).' '.(is_numeric(getDolGlobalString('MAIN_ODT_AS_PDF'))?'jodconverter':getDolGlobalString('MAIN_ODT_AS_PDF')); |
|
| 922 | + $command = getDolGlobalString('MAIN_DOL_SCRIPTS_ROOT').'/scripts/odt2pdf/odt2pdf.sh '.escapeshellcmd($tmpname).' '.(is_numeric(getDolGlobalString('MAIN_ODT_AS_PDF')) ? 'jodconverter' : getDolGlobalString('MAIN_ODT_AS_PDF')); |
|
| 923 | 923 | } else { |
| 924 | 924 | dol_syslog(get_class($this).'::exportAsAttachedPDF is used but the constant MAIN_DOL_SCRIPTS_ROOT with path to script directory was not defined.', LOG_WARNING); |
| 925 | - $command = '../../scripts/odt2pdf/odt2pdf.sh '.escapeshellcmd($tmpname).' '.(is_numeric(getDolGlobalString('MAIN_ODT_AS_PDF'))?'jodconverter':getDolGlobalString('MAIN_ODT_AS_PDF')); |
|
| 925 | + $command = '../../scripts/odt2pdf/odt2pdf.sh '.escapeshellcmd($tmpname).' '.(is_numeric(getDolGlobalString('MAIN_ODT_AS_PDF')) ? 'jodconverter' : getDolGlobalString('MAIN_ODT_AS_PDF')); |
|
| 926 | 926 | } |
| 927 | 927 | } |
| 928 | 928 | |
@@ -935,14 +935,14 @@ discard block |
||
| 935 | 935 | // $result = $utils->executeCLI($command, $outputfile); and replace test on $execmethod. |
| 936 | 936 | // $retval will be $result['result'] |
| 937 | 937 | // $errorstring will be $result['output'] |
| 938 | - $retval=0; $output_arr=array(); |
|
| 938 | + $retval = 0; $output_arr = array(); |
|
| 939 | 939 | if ($execmethod == 1) { |
| 940 | 940 | exec($command, $output_arr, $retval); |
| 941 | 941 | } |
| 942 | 942 | if ($execmethod == 2) { |
| 943 | 943 | $outputfile = DOL_DATA_ROOT.'/odt2pdf.log'; |
| 944 | 944 | |
| 945 | - $ok=0; |
|
| 945 | + $ok = 0; |
|
| 946 | 946 | $handle = fopen($outputfile, 'w'); |
| 947 | 947 | if ($handle) { |
| 948 | 948 | dol_syslog(get_class($this)."Run command ".$command, LOG_DEBUG); |
@@ -951,7 +951,7 @@ discard block |
||
| 951 | 951 | while (!feof($handlein)) { |
| 952 | 952 | $read = fgets($handlein); |
| 953 | 953 | fwrite($handle, $read); |
| 954 | - $output_arr[]=$read; |
|
| 954 | + $output_arr[] = $read; |
|
| 955 | 955 | } |
| 956 | 956 | pclose($handlein); |
| 957 | 957 | fclose($handle); |
@@ -961,7 +961,7 @@ discard block |
||
| 961 | 961 | |
| 962 | 962 | if ($retval == 0) { |
| 963 | 963 | dol_syslog(get_class($this).'::exportAsAttachedPDF $ret_val='.$retval, LOG_DEBUG); |
| 964 | - $filename=''; $linenum=0; |
|
| 964 | + $filename = ''; $linenum = 0; |
|
| 965 | 965 | |
| 966 | 966 | if (php_sapi_name() != 'cli') { // If we are in a web context (not into CLI context) |
| 967 | 967 | if (headers_sent($filename, $linenum)) { |
@@ -969,7 +969,7 @@ discard block |
||
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | if (getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { |
| 972 | - $name=preg_replace('/\.od(x|t)/i', '', $name); |
|
| 972 | + $name = preg_replace('/\.od(x|t)/i', '', $name); |
|
| 973 | 973 | header('Content-type: application/pdf'); |
| 974 | 974 | header('Content-Disposition: attachment; filename="'.basename($name).'.pdf"'); |
| 975 | 975 | readfile($name.".pdf"); |
@@ -984,13 +984,13 @@ discard block |
||
| 984 | 984 | dol_syslog(get_class($this).'::exportAsAttachedPDF $output_arr='.var_export($output_arr, true), LOG_DEBUG); |
| 985 | 985 | |
| 986 | 986 | if ($retval == 126) { |
| 987 | - throw new OdfException('Permission execute convert script : ' . $command); |
|
| 987 | + throw new OdfException('Permission execute convert script : '.$command); |
|
| 988 | 988 | } else { |
| 989 | - $errorstring=''; |
|
| 989 | + $errorstring = ''; |
|
| 990 | 990 | foreach ($output_arr as $line) { |
| 991 | - $errorstring.= $line."<br>"; |
|
| 991 | + $errorstring .= $line."<br>"; |
|
| 992 | 992 | } |
| 993 | - throw new OdfException('ODT to PDF convert fail (option MAIN_ODT_AS_PDF is '.$conf->global->MAIN_ODT_AS_PDF.', command was '.$command.', retval='.$retval.') : ' . $errorstring); |
|
| 993 | + throw new OdfException('ODT to PDF convert fail (option MAIN_ODT_AS_PDF is '.$conf->global->MAIN_ODT_AS_PDF.', command was '.$command.', retval='.$retval.') : '.$errorstring); |
|
| 994 | 994 | } |
| 995 | 995 | } |
| 996 | 996 | } |
@@ -1044,11 +1044,11 @@ discard block |
||
| 1044 | 1044 | if ($handle = opendir($dir)) { |
| 1045 | 1045 | while (($file = readdir($handle)) !== false) { |
| 1046 | 1046 | if ($file != '.' && $file != '..') { |
| 1047 | - if (is_dir($dir . '/' . $file)) { |
|
| 1048 | - $this->_rrmdir($dir . '/' . $file); |
|
| 1049 | - rmdir($dir . '/' . $file); |
|
| 1047 | + if (is_dir($dir.'/'.$file)) { |
|
| 1048 | + $this->_rrmdir($dir.'/'.$file); |
|
| 1049 | + rmdir($dir.'/'.$file); |
|
| 1050 | 1050 | } else { |
| 1051 | - unlink($dir . '/' . $file); |
|
| 1051 | + unlink($dir.'/'.$file); |
|
| 1052 | 1052 | } |
| 1053 | 1053 | } |
| 1054 | 1054 | } |
@@ -1064,7 +1064,7 @@ discard block |
||
| 1064 | 1064 | */ |
| 1065 | 1065 | public function getvalue($valuename) |
| 1066 | 1066 | { |
| 1067 | - $searchreg="/\\[".$valuename."\\](.*)\\[\\/".$valuename."\\]/"; |
|
| 1067 | + $searchreg = "/\\[".$valuename."\\](.*)\\[\\/".$valuename."\\]/"; |
|
| 1068 | 1068 | $matches = array(); |
| 1069 | 1069 | preg_match($searchreg, $this->contentXml, $matches); |
| 1070 | 1070 | $this->contentXml = preg_replace($searchreg, "", $this->contentXml); |
@@ -546,7 +546,7 @@ |
||
| 546 | 546 | $height *= self::PIXEL_TO_CM * $ratio; |
| 547 | 547 | $xml = <<<IMG |
| 548 | 548 | <draw:frame draw:style-name="fr1" draw:name="$filename" text:anchor-type="aschar" svg:width="{$width}cm" svg:height="{$height}cm" draw:z-index="3"><draw:image xlink:href="Pictures/$file" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame> |
| 549 | -IMG; |
|
| 549 | +img; |
|
| 550 | 550 | $this->images[$value] = $file; |
| 551 | 551 | $this->setVars($key, $xml, false); |
| 552 | 552 | return $this; |
@@ -106,21 +106,21 @@ discard block |
||
| 106 | 106 | { |
| 107 | 107 | // To provide debug information on line number processed |
| 108 | 108 | global $count; |
| 109 | - if (empty($count)) $count=1; |
|
| 109 | + if (empty($count)) $count = 1; |
|
| 110 | 110 | else $count++; |
| 111 | 111 | |
| 112 | - if (empty($this->savxml)) $this->savxml = $this->xml; // Sav content of line at first line merged, so we will reuse original for next steps |
|
| 112 | + if (empty($this->savxml)) $this->savxml = $this->xml; // Sav content of line at first line merged, so we will reuse original for next steps |
|
| 113 | 113 | $this->xml = $this->savxml; |
| 114 | - $tmpvars = $this->vars; // Store into $tmpvars so we won't modify this->vars when completing data with empty values |
|
| 114 | + $tmpvars = $this->vars; // Store into $tmpvars so we won't modify this->vars when completing data with empty values |
|
| 115 | 115 | |
| 116 | 116 | // Search all tags fou into condition to complete $tmpvars, so we will proceed all tests even if not defined |
| 117 | - $reg='@\[!--\sIF\s([{}a-zA-Z0-9\.\,_]+)\s--\]@smU'; |
|
| 117 | + $reg = '@\[!--\sIF\s([{}a-zA-Z0-9\.\,_]+)\s--\]@smU'; |
|
| 118 | 118 | $matches = array(); |
| 119 | 119 | preg_match_all($reg, $this->xml, $matches, PREG_SET_ORDER); |
| 120 | 120 | //var_dump($tmpvars);exit; |
| 121 | 121 | foreach ($matches as $match) { // For each match, if there is no entry into this->vars, we add it |
| 122 | - if (! empty($match[1]) && ! isset($tmpvars[$match[1]])) { |
|
| 123 | - $tmpvars[$match[1]] = ''; // Not defined, so we set it to '', we just need entry into this->vars for next loop |
|
| 122 | + if (!empty($match[1]) && !isset($tmpvars[$match[1]])) { |
|
| 123 | + $tmpvars[$match[1]] = ''; // Not defined, so we set it to '', we just need entry into this->vars for next loop |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
@@ -132,13 +132,13 @@ discard block |
||
| 132 | 132 | // Remove the IF tag |
| 133 | 133 | $this->xml = str_replace('[!-- IF '.$key.' --]', '', $this->xml); |
| 134 | 134 | // Remove everything between the ELSE tag (if it exists) and the ENDIF tag |
| 135 | - $reg = '@(\[!--\sELSE\s' . preg_quote($key, '@') . '\s--\](.*))?\[!--\sENDIF\s' . preg_quote($key, '@') . '\s--\]@smU'; // U modifier = all quantifiers are non-greedy |
|
| 135 | + $reg = '@(\[!--\sELSE\s'.preg_quote($key, '@').'\s--\](.*))?\[!--\sENDIF\s'.preg_quote($key, '@').'\s--\]@smU'; // U modifier = all quantifiers are non-greedy |
|
| 136 | 136 | $this->xml = preg_replace($reg, '', $this->xml); |
| 137 | 137 | } |
| 138 | 138 | // Else the value is false, then two cases: no ELSE and we're done, or there is at least one place where there is an ELSE clause, then we replace it |
| 139 | 139 | else { |
| 140 | 140 | // Find all conditional blocks for this variable: from IF to ELSE and to ENDIF |
| 141 | - $reg = '@\[!--\sIF\s' . preg_quote($key, '@') . '\s--\](.*)(\[!--\sELSE\s' . preg_quote($key, '@') . '\s--\](.*))?\[!--\sENDIF\s' . preg_quote($key, '@') . '\s--\]@smU'; // U modifier = all quantifiers are non-greedy |
|
| 141 | + $reg = '@\[!--\sIF\s'.preg_quote($key, '@').'\s--\](.*)(\[!--\sELSE\s'.preg_quote($key, '@').'\s--\](.*))?\[!--\sENDIF\s'.preg_quote($key, '@').'\s--\]@smU'; // U modifier = all quantifiers are non-greedy |
|
| 142 | 142 | preg_match_all($reg, $this->xml, $matches, PREG_SET_ORDER); |
| 143 | 143 | foreach ($matches as $match) { // For each match, if there is an ELSE clause, we replace the whole block by the value in the ELSE clause |
| 144 | 144 | if (!empty($match[3])) $this->xml = str_replace($match[0], $match[3], $this->xml); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $this->xmlParsed .= str_replace(array_keys($tmpvars), array_values($tmpvars), $this->xml); |
| 152 | 152 | if ($this->hasChildren()) { |
| 153 | 153 | foreach ($this->children as $child) { |
| 154 | - $this->xmlParsed = str_replace($child->xml, ($child->xmlParsed=="")?$child->merge():$child->xmlParsed, $this->xmlParsed); |
|
| 154 | + $this->xmlParsed = str_replace($child->xml, ($child->xmlParsed == "") ? $child->merge() : $child->xmlParsed, $this->xmlParsed); |
|
| 155 | 155 | $child->xmlParsed = ''; |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -161,9 +161,9 @@ discard block |
||
| 161 | 161 | $this->xmlParsed = $this->macroReplace($this->xmlParsed); |
| 162 | 162 | $this->file->open($this->odf->getTmpfile()); |
| 163 | 163 | foreach ($this->images as $imageKey => $imageValue) { |
| 164 | - if ($this->file->getFromName('Pictures/' . $imageValue) === false) { |
|
| 164 | + if ($this->file->getFromName('Pictures/'.$imageValue) === false) { |
|
| 165 | 165 | // Add the image inside the ODT document |
| 166 | - $this->file->addFile($imageKey, 'Pictures/' . $imageValue); |
|
| 166 | + $this->file->addFile($imageKey, 'Pictures/'.$imageValue); |
|
| 167 | 167 | // Add the image to the Manifest (which maintains a list of images, necessary to avoid "Corrupt ODT file. Repair?" when opening the file with LibreOffice) |
| 168 | 168 | $this->odf->addImageToManifest($imageValue); |
| 169 | 169 | } |
@@ -194,16 +194,16 @@ discard block |
||
| 194 | 194 | $dateinonemontharray = dol_get_next_month($hoy['mon'], $hoy['year']); |
| 195 | 195 | $nextMonth = $dateinonemontharray['month']; |
| 196 | 196 | |
| 197 | - $patterns=array( '/__CURRENTDAY__/u','/__CURENTWEEKDAY__/u', |
|
| 198 | - '/__CURRENTMONTH__/u','/__CURRENTMONTHLONG__/u', |
|
| 199 | - '/__NEXTMONTH__/u','/__NEXTMONTHLONG__/u', |
|
| 200 | - '/__CURRENTYEAR__/u','/__NEXTYEAR__/u' ); |
|
| 201 | - $values=array( $hoy['mday'], $langs->transnoentitiesnoconv($hoy['wday']), |
|
| 197 | + $patterns = array('/__CURRENTDAY__/u', '/__CURENTWEEKDAY__/u', |
|
| 198 | + '/__CURRENTMONTH__/u', '/__CURRENTMONTHLONG__/u', |
|
| 199 | + '/__NEXTMONTH__/u', '/__NEXTMONTHLONG__/u', |
|
| 200 | + '/__CURRENTYEAR__/u', '/__NEXTYEAR__/u'); |
|
| 201 | + $values = array($hoy['mday'], $langs->transnoentitiesnoconv($hoy['wday']), |
|
| 202 | 202 | $hoy['mon'], monthArray($langs)[$hoy['mon']], |
| 203 | 203 | $nextMonth, monthArray($langs)[$nextMonth], |
| 204 | - $hoy['year'], $hoy['year']+1 ); |
|
| 204 | + $hoy['year'], $hoy['year'] + 1); |
|
| 205 | 205 | |
| 206 | - $text=preg_replace($patterns, $values, $text); |
|
| 206 | + $text = preg_replace($patterns, $values, $text); |
|
| 207 | 207 | |
| 208 | 208 | return $text; |
| 209 | 209 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public function setVars($key, $value, $encode = true, $charset = 'ISO-8859') |
| 243 | 243 | { |
| 244 | - $tag = $this->odf->getConfig('DELIMITER_LEFT') . $key . $this->odf->getConfig('DELIMITER_RIGHT'); |
|
| 244 | + $tag = $this->odf->getConfig('DELIMITER_LEFT').$key.$this->odf->getConfig('DELIMITER_RIGHT'); |
|
| 245 | 245 | |
| 246 | 246 | if (strpos($this->xml, $tag) === false) { |
| 247 | 247 | //throw new SegmentException("var $key not found in {$this->getName()}"); |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | * @throws OdfException |
| 262 | 262 | * @return Segment |
| 263 | 263 | */ |
| 264 | - public function setImage($key, $value, float $ratio=1) |
|
| 264 | + public function setImage($key, $value, float $ratio = 1) |
|
| 265 | 265 | { |
| 266 | 266 | $filename = strtok(strrchr($value, '/'), '/.'); |
| 267 | 267 | $file = substr(strrchr($value, '/'), 1); |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | if (array_key_exists($prop, $this->children)) { |
| 297 | 297 | return $this->children[$prop]; |
| 298 | 298 | } else { |
| 299 | - throw new SegmentException('child ' . $prop . ' does not exist'); |
|
| 299 | + throw new SegmentException('child '.$prop.' does not exist'); |
|
| 300 | 300 | } |
| 301 | 301 | } |
| 302 | 302 | /** |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | use Luracast\Restler\RestException; |
| 23 | 23 | |
| 24 | -require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; |
|
| 24 | +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * API class for accounts |
@@ -78,12 +78,12 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | $sql = "SELECT t.rowid FROM ".MAIN_DB_PREFIX."bank_account AS t LEFT JOIN ".MAIN_DB_PREFIX."bank_account_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields |
| 80 | 80 | if ($category > 0) { |
| 81 | - $sql .= ", " . MAIN_DB_PREFIX . "categorie_account as c"; |
|
| 81 | + $sql .= ", ".MAIN_DB_PREFIX."categorie_account as c"; |
|
| 82 | 82 | } |
| 83 | - $sql .= ' WHERE t.entity IN (' . getEntity('bank_account') . ')'; |
|
| 83 | + $sql .= ' WHERE t.entity IN ('.getEntity('bank_account').')'; |
|
| 84 | 84 | // Select accounts of given category |
| 85 | 85 | if ($category > 0) { |
| 86 | - $sql .= " AND c.fk_categorie = " . ((int) $category) . " AND c.fk_account = t.rowid"; |
|
| 86 | + $sql .= " AND c.fk_categorie = ".((int) $category)." AND c.fk_account = t.rowid"; |
|
| 87 | 87 | } |
| 88 | 88 | // Add sql filters |
| 89 | 89 | if ($sqlfilters) { |
@@ -114,12 +114,12 @@ discard block |
||
| 114 | 114 | $obj = $this->db->fetch_object($result); |
| 115 | 115 | $account = new Account($this->db); |
| 116 | 116 | if ($account->fetch($obj->rowid) > 0) { |
| 117 | - $account->balance = $account->solde(1); // 1=Exclude future operation date |
|
| 117 | + $account->balance = $account->solde(1); // 1=Exclude future operation date |
|
| 118 | 118 | $list[] = $this->_filterObjectProperties($this->_cleanObjectDatas($account), $properties); |
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | } else { |
| 122 | - throw new RestException(503, 'Error when retrieving list of accounts: ' . $this->db->lasterror()); |
|
| 122 | + throw new RestException(503, 'Error when retrieving list of accounts: '.$this->db->lasterror()); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | return $list; |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | throw new RestException(403); |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; |
|
| 219 | + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
|
| 220 | 220 | |
| 221 | 221 | $accountfrom = new Account($this->db); |
| 222 | 222 | $resultAccountFrom = $accountfrom->fetch($bankaccount_from_id); |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | * Creating links between bank line record and its source |
| 293 | 293 | */ |
| 294 | 294 | |
| 295 | - $url = DOL_URL_ROOT . '/compta/bank/line.php?rowid='; |
|
| 295 | + $url = DOL_URL_ROOT.'/compta/bank/line.php?rowid='; |
|
| 296 | 296 | $label = '(banktransfert)'; |
| 297 | 297 | $type = 'banktransfert'; |
| 298 | 298 | |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | ); |
| 324 | 324 | } else { |
| 325 | 325 | $this->db->rollback(); |
| 326 | - throw new RestException(500, $accountfrom->error . ' ' . $accountto->error); |
|
| 326 | + throw new RestException(500, $accountfrom->error.' '.$accountto->error); |
|
| 327 | 327 | } |
| 328 | 328 | } |
| 329 | 329 | |
@@ -472,8 +472,8 @@ discard block |
||
| 472 | 472 | throw new RestException(404, 'account not found'); |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "bank "; |
|
| 476 | - $sql .= " WHERE fk_account = " . ((int) $id); |
|
| 475 | + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."bank "; |
|
| 476 | + $sql .= " WHERE fk_account = ".((int) $id); |
|
| 477 | 477 | |
| 478 | 478 | // Add sql filters |
| 479 | 479 | if ($sqlfilters) { |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | } |
| 499 | 499 | } |
| 500 | 500 | } else { |
| 501 | - throw new RestException(503, 'Error when retrieving list of account lines: ' . $this->db->lasterror()); |
|
| 501 | + throw new RestException(503, 'Error when retrieving list of account lines: '.$this->db->lasterror()); |
|
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | return $list; |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | $num_releve |
| 559 | 559 | ); |
| 560 | 560 | if ($result < 0) { |
| 561 | - throw new RestException(503, 'Error when adding line to account: ' . $account->error); |
|
| 561 | + throw new RestException(503, 'Error when adding line to account: '.$account->error); |
|
| 562 | 562 | } |
| 563 | 563 | return $result; |
| 564 | 564 | } |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | |
| 601 | 601 | $result = $account->add_url_line($line_id, $url_id, $url, $label, $type); |
| 602 | 602 | if ($result < 0) { |
| 603 | - throw new RestException(503, 'Error when adding link to account line: ' . $account->error); |
|
| 603 | + throw new RestException(503, 'Error when adding link to account line: '.$account->error); |
|
| 604 | 604 | } |
| 605 | 605 | return $result; |
| 606 | 606 | } |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | |
| 673 | 673 | $result = $accountLine->updateLabel(); |
| 674 | 674 | if ($result < 0) { |
| 675 | - throw new RestException(503, 'Error when updating link to account line: ' . $accountLine->error); |
|
| 675 | + throw new RestException(503, 'Error when updating link to account line: '.$accountLine->error); |
|
| 676 | 676 | } |
| 677 | 677 | return $accountLine->id; |
| 678 | 678 | } |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | if (!$result) { |
| 740 | 740 | throw new RestException(404, 'account not found'); |
| 741 | 741 | } |
| 742 | - $balance = $account->solde(1); //1=Exclude future operation date (this is to exclude input made in advance and have real account sold) |
|
| 742 | + $balance = $account->solde(1); //1=Exclude future operation date (this is to exclude input made in advance and have real account sold) |
|
| 743 | 743 | return $balance; |
| 744 | 744 | } |
| 745 | 745 | } |
@@ -91,14 +91,14 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // General $Variables |
| 94 | -$id = (GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('facid')); // For backward compatibility |
|
| 94 | +$id = (GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('facid')); // For backward compatibility |
|
| 95 | 95 | $ref = GETPOST('ref', 'alpha'); |
| 96 | 96 | $socid = GETPOSTINT('socid'); |
| 97 | 97 | $action = GETPOST('action', 'aZ09'); |
| 98 | 98 | $confirm = GETPOST('confirm', 'alpha'); |
| 99 | 99 | $cancel = GETPOST('cancel', 'alpha'); |
| 100 | -$backtopage = GETPOST('backtopage', 'alpha'); // if not set, a default page will be used |
|
| 101 | -$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); // if not set, $backtopage will be used |
|
| 100 | +$backtopage = GETPOST('backtopage', 'alpha'); // if not set, a default page will be used |
|
| 101 | +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); // if not set, $backtopage will be used |
|
| 102 | 102 | $lineid = GETPOSTINT('lineid'); |
| 103 | 103 | $userid = GETPOSTINT('userid'); |
| 104 | 104 | $search_ref = GETPOST('sf_ref', 'alpha') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | setEventMessages('', $warningMsgLineList, 'warnings'); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result); |
|
| 270 | + header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result); |
|
| 271 | 271 | exit(); |
| 272 | 272 | } else { |
| 273 | 273 | $langs->load("errors"); |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | // Validation |
| 359 | 359 | $object->fetch($id); |
| 360 | 360 | |
| 361 | - if ((preg_match('/^[\(]?PROV/i', $object->ref) || empty($object->ref)) && // empty should not happened, but when it occurs, the test save life |
|
| 361 | + if ((preg_match('/^[\(]?PROV/i', $object->ref) || empty($object->ref)) && // empty should not happened, but when it occurs, the test save life |
|
| 362 | 362 | getDolGlobalString('FAC_FORCE_DATE_VALIDATION') // If option enabled, we force invoice date |
| 363 | 363 | ) { |
| 364 | 364 | $object->date = dol_now(); |
@@ -778,8 +778,8 @@ discard block |
||
| 778 | 778 | // We check if invoice has payments |
| 779 | 779 | $totalpaid = 0; |
| 780 | 780 | $sql = 'SELECT pf.amount'; |
| 781 | - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'paiement_facture as pf'; |
|
| 782 | - $sql .= ' WHERE pf.fk_facture = ' . ((int) $object->id); |
|
| 781 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf'; |
|
| 782 | + $sql .= ' WHERE pf.fk_facture = '.((int) $object->id); |
|
| 783 | 783 | |
| 784 | 784 | $result = $db->query($sql); |
| 785 | 785 | if ($result) { |
@@ -1087,7 +1087,7 @@ discard block |
||
| 1087 | 1087 | $error++; |
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | - $dateinvoice = dol_mktime(0, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server |
|
| 1090 | + $dateinvoice = dol_mktime(0, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server |
|
| 1091 | 1091 | $date_pointoftax = dol_mktime(0, 0, 0, GETPOSTINT('date_pointoftaxmonth'), GETPOSTINT('date_pointoftaxday'), GETPOSTINT('date_pointoftaxyear'), 'tzserver'); |
| 1092 | 1092 | |
| 1093 | 1093 | // Replacement invoice |
@@ -1119,7 +1119,7 @@ discard block |
||
| 1119 | 1119 | $object->note_private = trim(GETPOST('note_private', 'restricthtml')); |
| 1120 | 1120 | $object->ref_client = GETPOST('ref_client', 'alphanohtml'); |
| 1121 | 1121 | $object->ref_customer = GETPOST('ref_client', 'alphanohtml'); |
| 1122 | - $object->model_pdf = GETPOST('model', 'alphanohtml'); |
|
| 1122 | + $object->model_pdf = GETPOST('model', 'alphanohtml'); |
|
| 1123 | 1123 | $object->fk_project = GETPOSTINT('projectid'); |
| 1124 | 1124 | $object->cond_reglement_id = GETPOSTINT('cond_reglement_id'); |
| 1125 | 1125 | $object->mode_reglement_id = GETPOSTINT('mode_reglement_id'); |
@@ -1180,9 +1180,9 @@ discard block |
||
| 1180 | 1180 | $object->note_private = trim(GETPOST('note_private', 'restricthtml')); |
| 1181 | 1181 | $object->ref_client = GETPOST('ref_client', 'alphanohtml'); |
| 1182 | 1182 | $object->ref_customer = GETPOST('ref_client', 'alphanohtml'); |
| 1183 | - $object->model_pdf = GETPOST('model'); |
|
| 1183 | + $object->model_pdf = GETPOST('model'); |
|
| 1184 | 1184 | $object->fk_project = GETPOSTINT('projectid'); |
| 1185 | - $object->cond_reglement_id = 0; // No payment term for a credit note |
|
| 1185 | + $object->cond_reglement_id = 0; // No payment term for a credit note |
|
| 1186 | 1186 | $object->mode_reglement_id = GETPOSTINT('mode_reglement_id'); |
| 1187 | 1187 | $object->fk_account = GETPOSTINT('fk_account'); |
| 1188 | 1188 | //$object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU'); |
@@ -1505,7 +1505,7 @@ discard block |
||
| 1505 | 1505 | $object->note_public = trim(GETPOST('note_public', 'restricthtml')); |
| 1506 | 1506 | $object->note_private = trim(GETPOST('note_private', 'restricthtml')); |
| 1507 | 1507 | $object->ref_client = GETPOST('ref_client'); |
| 1508 | - $object->ref_customer = GETPOST('ref_client'); |
|
| 1508 | + $object->ref_customer = GETPOST('ref_client'); |
|
| 1509 | 1509 | $object->model_pdf = GETPOST('model'); |
| 1510 | 1510 | $object->fk_project = GETPOSTINT('projectid'); |
| 1511 | 1511 | $object->cond_reglement_id = (GETPOSTINT('type') == 3 ? 1 : GETPOST('cond_reglement_id')); |
@@ -1569,7 +1569,7 @@ discard block |
||
| 1569 | 1569 | $element = $subelement = 'expedition'; |
| 1570 | 1570 | } |
| 1571 | 1571 | |
| 1572 | - $object->origin = $origin; // deprecated |
|
| 1572 | + $object->origin = $origin; // deprecated |
|
| 1573 | 1573 | $object->origin_type = $origin; |
| 1574 | 1574 | $object->origin_id = $originid; |
| 1575 | 1575 | |
@@ -1604,7 +1604,7 @@ discard block |
||
| 1604 | 1604 | dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines or deposit lines"); |
| 1605 | 1605 | $result = $srcobject->fetch($object->origin_id); |
| 1606 | 1606 | |
| 1607 | - $i = -1; // Ensure initialised for static analysis, but with invalid idx. |
|
| 1607 | + $i = -1; // Ensure initialised for static analysis, but with invalid idx. |
|
| 1608 | 1608 | // If deposit invoice - down payment with 1 line (fixed amount or percent) |
| 1609 | 1609 | if (GETPOST('type') == Facture::TYPE_DEPOSIT && in_array($typeamount, array('amount', 'variable'))) { |
| 1610 | 1610 | // Define the array $amountdeposit |
@@ -2007,7 +2007,7 @@ discard block |
||
| 2007 | 2007 | if (!empty($origin) && !empty($originid)) { |
| 2008 | 2008 | include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; |
| 2009 | 2009 | |
| 2010 | - $object->origin = $origin; // deprecated |
|
| 2010 | + $object->origin = $origin; // deprecated |
|
| 2011 | 2011 | $object->origin_type = $origin; |
| 2012 | 2012 | $object->origin_id = $originid; |
| 2013 | 2013 | |
@@ -2033,7 +2033,7 @@ discard block |
||
| 2033 | 2033 | $line->fk_prev_id = $line->id; |
| 2034 | 2034 | $line->fetch_optionals(); |
| 2035 | 2035 | if (getDolGlobalInt('INVOICE_USE_SITUATION') == 2) { |
| 2036 | - $line->situation_percent = 0; // New situation percent must be 0 (No cumulative) |
|
| 2036 | + $line->situation_percent = 0; // New situation percent must be 0 (No cumulative) |
|
| 2037 | 2037 | } else { |
| 2038 | 2038 | $line->situation_percent = $line->get_prev_progress($object->id); // get good progress including credit note |
| 2039 | 2039 | } |
@@ -2150,7 +2150,7 @@ discard block |
||
| 2150 | 2150 | } else { |
| 2151 | 2151 | $db->rollback(); |
| 2152 | 2152 | $action = 'create'; |
| 2153 | - $_GET["origin"] = $_POST["origin"]; // Keep GET and POST here ? |
|
| 2153 | + $_GET["origin"] = $_POST["origin"]; // Keep GET and POST here ? |
|
| 2154 | 2154 | $_GET["originid"] = $_POST["originid"]; // Keep GET and POST here ? |
| 2155 | 2155 | setEventMessages($object->error, $object->errors, 'errors'); |
| 2156 | 2156 | } |
@@ -2705,7 +2705,7 @@ discard block |
||
| 2705 | 2705 | // Define special_code for special lines |
| 2706 | 2706 | $special_code = GETPOSTINT('special_code'); |
| 2707 | 2707 | if ($special_code == 3) { |
| 2708 | - $special_code = 0; // Options should not exists on invoices |
|
| 2708 | + $special_code = 0; // Options should not exists on invoices |
|
| 2709 | 2709 | } |
| 2710 | 2710 | |
| 2711 | 2711 | $line = new FactureLigne($db); |
@@ -3152,7 +3152,7 @@ discard block |
||
| 3152 | 3152 | |
| 3153 | 3153 | |
| 3154 | 3154 | if ($action == 'update_extras' && $usercancreate) { |
| 3155 | - $object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty |
|
| 3155 | + $object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty |
|
| 3156 | 3156 | $attribute_name = GETPOST('attribute', 'restricthtml'); |
| 3157 | 3157 | |
| 3158 | 3158 | // Fill array 'array_options' with data from add form |
@@ -3269,7 +3269,7 @@ discard block |
||
| 3269 | 3269 | $fk_account = GETPOSTINT('fk_account'); |
| 3270 | 3270 | |
| 3271 | 3271 | // Load objectsrc |
| 3272 | - $objectsrc = null; // Initialise |
|
| 3272 | + $objectsrc = null; // Initialise |
|
| 3273 | 3273 | //$remise_absolue = 0; |
| 3274 | 3274 | if (!empty($origin) && !empty($originid)) { |
| 3275 | 3275 | // Parse element/subelement (ex: project_task) |
@@ -3280,7 +3280,7 @@ discard block |
||
| 3280 | 3280 | $subelement = $regs[2]; |
| 3281 | 3281 | } |
| 3282 | 3282 | |
| 3283 | - $dateinvoice = dol_mktime(0, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server |
|
| 3283 | + $dateinvoice = dol_mktime(0, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server |
|
| 3284 | 3284 | $date_pointoftax = dol_mktime(0, 0, 0, GETPOSTINT('date_pointoftaxmonth'), GETPOSTINT('date_pointoftaxday'), GETPOSTINT('date_pointoftaxyear'), 'tzserver'); |
| 3285 | 3285 | |
| 3286 | 3286 | if ($element == 'project') { |
@@ -3358,8 +3358,8 @@ discard block |
||
| 3358 | 3358 | $fk_account = (!empty($expesrc->fk_account) ? $expesrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); |
| 3359 | 3359 | |
| 3360 | 3360 | if (isModEnabled('multicurrency')) { |
| 3361 | - $currency_code = (!empty($expesrc->multicurrency_code) ? $expesrc->multicurrency_code : (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : $objectsrc->multicurrency_code)); |
|
| 3362 | - $currency_tx = (!empty($expesrc->multicurrency_tx) ? $expesrc->multicurrency_tx : (!empty($soc->multicurrency_tx) ? $soc->multicurrency_tx : $objectsrc->multicurrency_tx)); |
|
| 3361 | + $currency_code = (!empty($expesrc->multicurrency_code) ? $expesrc->multicurrency_code : (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : $objectsrc->multicurrency_code)); |
|
| 3362 | + $currency_tx = (!empty($expesrc->multicurrency_tx) ? $expesrc->multicurrency_tx : (!empty($soc->multicurrency_tx) ? $soc->multicurrency_tx : $objectsrc->multicurrency_tx)); |
|
| 3363 | 3363 | } |
| 3364 | 3364 | |
| 3365 | 3365 | //Replicate extrafields |
@@ -3452,7 +3452,7 @@ discard block |
||
| 3452 | 3452 | print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST" id="formtocreate" name="formtocreate">'; |
| 3453 | 3453 | print '<input type="hidden" name="token" value="'.newToken().'">'; |
| 3454 | 3454 | print '<input type="hidden" name="action" id="formtocreateaction" value="add">'; |
| 3455 | - print '<input type="hidden" name="changecompany" value="0">'; // will be set to 1 by javascript so we know post is done after a company change |
|
| 3455 | + print '<input type="hidden" name="changecompany" value="0">'; // will be set to 1 by javascript so we know post is done after a company change |
|
| 3456 | 3456 | if ($soc->id > 0) { |
| 3457 | 3457 | print '<input type="hidden" name="socid" value="'.$soc->id.'">'."\n"; |
| 3458 | 3458 | } |
@@ -3634,7 +3634,7 @@ discard block |
||
| 3634 | 3634 | print $form->selectarray('typestandard', $arraylist, GETPOST('typestandard', 'aZ09'), 0, 0, 0, '', 1); |
| 3635 | 3635 | print '</td>';*/ |
| 3636 | 3636 | if (!getDolGlobalInt('INVOICE_DEPOSIT_INVOICE_ONLY_SAME_LINES')) { |
| 3637 | - print '<span class="opacitymedium marginleftonly">' . $langs->trans('PercentOfOriginalObject') . '</span>:<input class="right" placeholder="100%" type="text" id="valuestandardinvoice" name="valuestandardinvoice" size="3" value="' . (GETPOSTISSET('valuestandardinvoice') ? GETPOST('valuestandardinvoice', 'alpha') : '100%') . '"/>'; |
|
| 3637 | + print '<span class="opacitymedium marginleftonly">'.$langs->trans('PercentOfOriginalObject').'</span>:<input class="right" placeholder="100%" type="text" id="valuestandardinvoice" name="valuestandardinvoice" size="3" value="'.(GETPOSTISSET('valuestandardinvoice') ? GETPOST('valuestandardinvoice', 'alpha') : '100%').'"/>'; |
|
| 3638 | 3638 | } |
| 3639 | 3639 | } |
| 3640 | 3640 | print '</div></div>'."\n"; |
@@ -3988,8 +3988,8 @@ discard block |
||
| 3988 | 3988 | if ($socid > 0) { |
| 3989 | 3989 | print '<tr><td>'.$langs->trans('DiscountStillRemaining').'</td><td colspan="2">'; |
| 3990 | 3990 | |
| 3991 | - $thirdparty = $soc; // used by object_discounts.tpl.php |
|
| 3992 | - $discount_type = 0; // used by object_discounts.tpl.php |
|
| 3991 | + $thirdparty = $soc; // used by object_discounts.tpl.php |
|
| 3992 | + $discount_type = 0; // used by object_discounts.tpl.php |
|
| 3993 | 3993 | $backtopage = $_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.urlencode((string) (GETPOST('origin'))).'&originid='.urlencode((string) (GETPOSTINT('originid'))); |
| 3994 | 3994 | include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; |
| 3995 | 3995 | |
@@ -4030,7 +4030,7 @@ discard block |
||
| 4030 | 4030 | if (empty($retained_warranty)) { |
| 4031 | 4031 | if ($objectsrc !== null && property_exists($objectsrc, 'retained_warranty') && !empty($objectsrc->retained_warranty)) { // use previous situation value |
| 4032 | 4032 | // Facture->retained_warranty (does not exist on Expedition) |
| 4033 | - $retained_warranty = $objectsrc->retained_warranty; // @phan-suppress-current-line PhanUndeclaredProperty |
|
| 4033 | + $retained_warranty = $objectsrc->retained_warranty; // @phan-suppress-current-line PhanUndeclaredProperty |
|
| 4034 | 4034 | } |
| 4035 | 4035 | } |
| 4036 | 4036 | $retained_warranty_js_default = !empty($retained_warranty) ? $retained_warranty : getDolGlobalString('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT'); |
@@ -4525,7 +4525,7 @@ discard block |
||
| 4525 | 4525 | $nbMandated = 0; |
| 4526 | 4526 | foreach ($object->lines as $line) { |
| 4527 | 4527 | $res = $line->fetch_product(); |
| 4528 | - if ($res > 0) { |
|
| 4528 | + if ($res > 0) { |
|
| 4529 | 4529 | if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end))) { |
| 4530 | 4530 | $nbMandated++; |
| 4531 | 4531 | break; |
@@ -4737,7 +4737,7 @@ discard block |
||
| 4737 | 4737 | } |
| 4738 | 4738 | // Ref customer |
| 4739 | 4739 | $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_customer, $object, (int) $usercancreate, 'string', '', 0, 1); |
| 4740 | - $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_customer, $object, (int) $usercancreate, 'string'.(getDolGlobalString('THIRDPARTY_REF_INPUT_SIZE') ? ':' . getDolGlobalString('THIRDPARTY_REF_INPUT_SIZE') : ''), '', null, null, '', 1); |
|
| 4740 | + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_customer, $object, (int) $usercancreate, 'string'.(getDolGlobalString('THIRDPARTY_REF_INPUT_SIZE') ? ':'.getDolGlobalString('THIRDPARTY_REF_INPUT_SIZE') : ''), '', null, null, '', 1); |
|
| 4741 | 4741 | // Thirdparty |
| 4742 | 4742 | $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'customer'); |
| 4743 | 4743 | if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { |
@@ -5167,45 +5167,45 @@ discard block |
||
| 5167 | 5167 | } |
| 5168 | 5168 | print '<tr>'; |
| 5169 | 5169 | // Amount HT |
| 5170 | - print '<td class="titlefieldmiddle">' . $langs->trans('AmountHT') . '</td>'; |
|
| 5171 | - print '<td class="nowrap amountcard right">' . price($sign * $object->total_ht, 0, $langs, 0, -1, -1, $conf->currency) . '</td>'; |
|
| 5170 | + print '<td class="titlefieldmiddle">'.$langs->trans('AmountHT').'</td>'; |
|
| 5171 | + print '<td class="nowrap amountcard right">'.price($sign * $object->total_ht, 0, $langs, 0, -1, -1, $conf->currency).'</td>'; |
|
| 5172 | 5172 | if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { |
| 5173 | 5173 | // Multicurrency Amount HT |
| 5174 | - print '<td class="nowrap amountcard right">' . price($sign * $object->multicurrency_total_ht, 0, $langs, 0, -1, -1, $object->multicurrency_code) . '</td>'; |
|
| 5174 | + print '<td class="nowrap amountcard right">'.price($sign * $object->multicurrency_total_ht, 0, $langs, 0, -1, -1, $object->multicurrency_code).'</td>'; |
|
| 5175 | 5175 | } |
| 5176 | 5176 | print '</tr>'; |
| 5177 | 5177 | |
| 5178 | 5178 | print '<tr>'; |
| 5179 | 5179 | // Amount VAT |
| 5180 | - print '<td>' . $langs->trans('AmountVAT') . '</td>'; |
|
| 5181 | - print '<td class="nowrap amountcard right">' . price($sign * $object->total_tva, 0, $langs, 0, -1, -1, $conf->currency) . '</td>'; |
|
| 5180 | + print '<td>'.$langs->trans('AmountVAT').'</td>'; |
|
| 5181 | + print '<td class="nowrap amountcard right">'.price($sign * $object->total_tva, 0, $langs, 0, -1, -1, $conf->currency).'</td>'; |
|
| 5182 | 5182 | if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { |
| 5183 | 5183 | // Multicurrency Amount VAT |
| 5184 | - print '<td class="nowrap amountcard right">' . price($sign * $object->multicurrency_total_tva, 0, $langs, 0, -1, -1, $object->multicurrency_code) . '</td>'; |
|
| 5184 | + print '<td class="nowrap amountcard right">'.price($sign * $object->multicurrency_total_tva, 0, $langs, 0, -1, -1, $object->multicurrency_code).'</td>'; |
|
| 5185 | 5185 | } |
| 5186 | 5186 | print '</tr>'; |
| 5187 | 5187 | |
| 5188 | 5188 | // Amount Local Taxes |
| 5189 | 5189 | if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) { |
| 5190 | 5190 | print '<tr>'; |
| 5191 | - print '<td class="titlefieldmiddle">' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>'; |
|
| 5192 | - print '<td class="nowrap amountcard right">' . price($sign * $object->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency) . '</td>'; |
|
| 5191 | + print '<td class="titlefieldmiddle">'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>'; |
|
| 5192 | + print '<td class="nowrap amountcard right">'.price($sign * $object->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency).'</td>'; |
|
| 5193 | 5193 | if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { |
| 5194 | 5194 | $object->multicurrency_total_localtax1 = (float) price2num($object->total_localtax1 * $object->multicurrency_tx, 'MT'); |
| 5195 | 5195 | |
| 5196 | - print '<td class="nowrap amountcard right">' . price($sign * $object->multicurrency_total_localtax1, 0, $langs, 0, -1, -1, $object->multicurrency_code) . '</td>'; |
|
| 5196 | + print '<td class="nowrap amountcard right">'.price($sign * $object->multicurrency_total_localtax1, 0, $langs, 0, -1, -1, $object->multicurrency_code).'</td>'; |
|
| 5197 | 5197 | } |
| 5198 | 5198 | print '</tr>'; |
| 5199 | 5199 | } |
| 5200 | 5200 | |
| 5201 | 5201 | if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) { |
| 5202 | 5202 | print '<tr>'; |
| 5203 | - print '<td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>'; |
|
| 5204 | - print '<td class="nowrap amountcard right">' . price($sign * $object->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency) . '</td>'; |
|
| 5203 | + print '<td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>'; |
|
| 5204 | + print '<td class="nowrap amountcard right">'.price($sign * $object->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency).'</td>'; |
|
| 5205 | 5205 | if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { |
| 5206 | 5206 | $object->multicurrency_total_localtax2 = (float) price2num($object->total_localtax2 * $object->multicurrency_tx, 'MT'); |
| 5207 | 5207 | |
| 5208 | - print '<td class="nowrap amountcard right">' . price($sign * $object->multicurrency_total_localtax2, 0, $langs, 0, -1, -1, $object->multicurrency_code) . '</td>'; |
|
| 5208 | + print '<td class="nowrap amountcard right">'.price($sign * $object->multicurrency_total_localtax2, 0, $langs, 0, -1, -1, $object->multicurrency_code).'</td>'; |
|
| 5209 | 5209 | } |
| 5210 | 5210 | print '</tr>'; |
| 5211 | 5211 | } |
@@ -5265,11 +5265,11 @@ discard block |
||
| 5265 | 5265 | |
| 5266 | 5266 | print '<tr>'; |
| 5267 | 5267 | // Amount TTC |
| 5268 | - print '<td>' . $langs->trans('AmountTTC') . '</td>'; |
|
| 5269 | - print '<td class="nowrap amountcard right">' . price($sign * $object->total_ttc, 0, $langs, 0, -1, -1, $conf->currency) . '</td>'; |
|
| 5268 | + print '<td>'.$langs->trans('AmountTTC').'</td>'; |
|
| 5269 | + print '<td class="nowrap amountcard right">'.price($sign * $object->total_ttc, 0, $langs, 0, -1, -1, $conf->currency).'</td>'; |
|
| 5270 | 5270 | if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { |
| 5271 | 5271 | // Multicurrency Amount TTC |
| 5272 | - print '<td class="nowrap amountcard right">' . price($sign * $object->multicurrency_total_ttc, 0, $langs, 0, -1, -1, $object->multicurrency_code) . '</td>'; |
|
| 5272 | + print '<td class="nowrap amountcard right">'.price($sign * $object->multicurrency_total_ttc, 0, $langs, 0, -1, -1, $object->multicurrency_code).'</td>'; |
|
| 5273 | 5273 | } |
| 5274 | 5274 | print '</tr>'; |
| 5275 | 5275 | |
@@ -5899,10 +5899,10 @@ discard block |
||
| 5899 | 5899 | if (!$objectidnext && $object->is_last_in_cycle()) { |
| 5900 | 5900 | if ($usercanunvalidate) { |
| 5901 | 5901 | unset($params['attr']['title']); |
| 5902 | - print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'] . '?facid=' . $object->id . '&action=modif&token=' . newToken(), '', true, $params); |
|
| 5902 | + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif&token='.newToken(), '', true, $params); |
|
| 5903 | 5903 | } else { |
| 5904 | 5904 | $params['attr']['title'] = $langs->trans('NotEnoughPermissions'); |
| 5905 | - print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'] . '?facid=' . $object->id . '&action=modif&token=' . newToken(), '', false, $params); |
|
| 5905 | + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif&token='.newToken(), '', false, $params); |
|
| 5906 | 5906 | } |
| 5907 | 5907 | } elseif (!$object->is_last_in_cycle()) { |
| 5908 | 5908 | $params['attr']['title'] = $langs->trans('NotLastInCycle'); |
@@ -5943,7 +5943,7 @@ discard block |
||
| 5943 | 5943 | $langs->load("contracts"); |
| 5944 | 5944 | |
| 5945 | 5945 | if ($usercancreatecontract) { |
| 5946 | - print '<a class="butAction" href="' . DOL_URL_ROOT . '/contrat/card.php?action=create&origin=' . $object->element . '&originid=' . $object->id . '&socid=' . $object->socid . '">' . $langs->trans('AddContract') . '</a>'; |
|
| 5946 | + print '<a class="butAction" href="'.DOL_URL_ROOT.'/contrat/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans('AddContract').'</a>'; |
|
| 5947 | 5947 | } |
| 5948 | 5948 | } |
| 5949 | 5949 | } |
@@ -6169,7 +6169,7 @@ discard block |
||
| 6169 | 6169 | if ($usercandelete || ($usercancreate && $isErasable == 1)) { // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions) |
| 6170 | 6170 | $enableDelete = false; |
| 6171 | 6171 | $deleteHref = '#'; |
| 6172 | - if ($isErasable > 0 && ! $objectidnext) { |
|
| 6172 | + if ($isErasable > 0 && !$objectidnext) { |
|
| 6173 | 6173 | $deleteHref = $_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=delete&token='.newToken(); |
| 6174 | 6174 | $enableDelete = true; |
| 6175 | 6175 | } |
@@ -111,9 +111,9 @@ discard block |
||
| 111 | 111 | $maxprod = GETPOSTINT("max_prod"); |
| 112 | 112 | |
| 113 | 113 | for ($i = 0; $i < $maxprod; $i++) { |
| 114 | - $qty = price2num(GETPOST("prod_qty_" . $i, 'alpha'), 'MS'); |
|
| 114 | + $qty = price2num(GETPOST("prod_qty_".$i, 'alpha'), 'MS'); |
|
| 115 | 115 | if ($qty > 0) { |
| 116 | - if ($object->add_sousproduit($id, GETPOSTINT("prod_id_" . $i), (float) $qty, GETPOSTINT("prod_incdec_" . $i)) > 0) { |
|
| 116 | + if ($object->add_sousproduit($id, GETPOSTINT("prod_id_".$i), (float) $qty, GETPOSTINT("prod_incdec_".$i)) > 0) { |
|
| 117 | 117 | //var_dump($i.' '.GETPOST("prod_id_".$i, 'int'), $qty, GETPOST("prod_incdec_".$i, 'int')); |
| 118 | 118 | $action = 'edit'; |
| 119 | 119 | } else { |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | } else { |
| 129 | - if ($object->del_sousproduit($id, GETPOSTINT("prod_id_" . $i)) > 0) { |
|
| 129 | + if ($object->del_sousproduit($id, GETPOSTINT("prod_id_".$i)) > 0) { |
|
| 130 | 130 | $action = 'edit'; |
| 131 | 131 | } else { |
| 132 | 132 | $error++; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | if (!$error) { |
| 140 | - header("Location: " . $_SERVER["PHP_SELF"] . '?id=' . $object->id); |
|
| 140 | + header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id); |
|
| 141 | 141 | exit; |
| 142 | 142 | } |
| 143 | 143 | } elseif ($action === 'save_composed_product') { |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | setEventMessages('RecordSaved', null); |
| 154 | 154 | } |
| 155 | 155 | $action = ''; |
| 156 | - header("Location: " . $_SERVER["PHP_SELF"] . '?id=' . $object->id); |
|
| 156 | + header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id); |
|
| 157 | 157 | exit; |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | $nboflines = $prods_arbo; |
| 326 | 326 | $table_element_line = 'product_association'; |
| 327 | 327 | |
| 328 | - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; |
|
| 328 | + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; |
|
| 329 | 329 | } |
| 330 | 330 | $id = $tmpid; |
| 331 | 331 | |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | |
| 375 | 375 | print '<div class="fichecenter">'; |
| 376 | 376 | |
| 377 | - $atleastonenotdefined = 0; // at least on buying price not defined |
|
| 377 | + $atleastonenotdefined = 0; // at least on buying price not defined |
|
| 378 | 378 | |
| 379 | 379 | $tmpurlforbutton = 'javascript:void(0);'; |
| 380 | 380 | $newButtonParams = [ |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | $rowspan++; |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - print '<form action="'.DOL_URL_ROOT.'/product/composition/card.php?id='.$id.'" method="POST" class="formtoaddinkit'.($action != 'search' ?' hideobject' : '').'" name="formtoaddinkit" id="formtoaddinkit">'; |
|
| 399 | + print '<form action="'.DOL_URL_ROOT.'/product/composition/card.php?id='.$id.'" method="POST" class="formtoaddinkit'.($action != 'search' ? ' hideobject' : '').'" name="formtoaddinkit" id="formtoaddinkit">'; |
|
| 400 | 400 | print '<input type="hidden" name="token" value="'.newToken().'">'; |
| 401 | 401 | print '<input type="hidden" name="action" value="search">'; |
| 402 | 402 | print '<input type="hidden" name="id" value="'.$id.'">'; |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | |
| 627 | 627 | $unitline = price2num(($fourn_unitprice * (1 - ($fourn_remise_percent / 100)) - $fourn_remise), 'MU'); |
| 628 | 628 | $totalline = price2num($value['nb'] * ($fourn_unitprice * (1 - ($fourn_remise_percent / 100)) - $fourn_remise), 'MT'); |
| 629 | - $total += $totalline; |
|
| 629 | + $total += $totalline; |
|
| 630 | 630 | |
| 631 | 631 | print '<td class="right nowraponall">'; |
| 632 | 632 | print($notdefined ? '' : ($value['nb'] > 1 ? $value['nb'].'x ' : '').'<span class="amount">'.price($unitline, 0, '', 0, 0, -1, $conf->currency)).'</span>'; |