From 608c564fbe9714f79ef768084adfed48cf434fcc Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 15 Oct 2018 21:49:54 +0200 Subject: [PATCH 01/27] Improve debug info --- html/do.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/html/do.php b/html/do.php index 73669e6db..0278416f6 100644 --- a/html/do.php +++ b/html/do.php @@ -1,5 +1,4 @@ \ No newline at end of file + + From 14ea453731c65f90cffdd7ba429217bd3374c7c0 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 23 Nov 2018 23:10:50 +0100 Subject: [PATCH 21/27] http_input : fix bug with array --- include/lib/http_input.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/lib/http_input.class.php b/include/lib/http_input.class.php index 35922702a..5a5be5f6e 100644 --- a/include/lib/http_input.class.php +++ b/include/lib/http_input.class.php @@ -80,7 +80,9 @@ class HttpInput throw new Exception(_("Type invalide")."[ $p_name ] = {$this->array[$p_name]}" , EXC_PARAM_TYPE); } - $this->array[$p_name]=h($this->array[$p_name]); + if (is_string($this->array )) { + $this->array[$p_name]=h($this->array[$p_name]); + } }else { throw new Exception(_("Unknown type")); } From 3a534aa1cb69d1242f89aa58e215b821a4059ae4 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 23 Nov 2018 23:11:04 +0100 Subject: [PATCH 22/27] Document : replace properly value in the OOo file --- include/class/document.class.php | 87 +++++++++++++++++++------------- 1 file changed, 52 insertions(+), 35 deletions(-) diff --git a/include/class/document.class.php b/include/class/document.class.php index 03258cf34..3f0327fa3 100644 --- a/include/class/document.class.php +++ b/include/class/document.class.php @@ -237,7 +237,6 @@ class Document $lt="<"; $gt=">"; } - //read the file while(! feof($h)) { @@ -270,33 +269,8 @@ class Document * Change type of cell to numeric * allow numeric cel in ODT for the formatting and formula */ - if ( is_numeric($value) && $p_type=='OOo') - { - // For libreOffice <=4 - $searched='/office:value-type="string">'.$pattern.'/i'; - $replaced='office:value-type="float" office:value="'.$value.'">'.$pattern; - $buffer=preg_replace($searched, $replaced, $buffer,1); - // For libreOffice >=4 - $searched='/office:value-type="string" calcext:value-type="string">'.$pattern.'/i'; - $replaced='office:value-type="float" office:value="'.$value.'" calcext:value-type="float">'.$pattern; - $buffer=preg_replace($searched, $replaced, $buffer,1); - } - // replace into the $buffer - // take the position in the buffer - $pos=strpos($buffer,$to_remove); - // get the length of the string to remove - $len=strlen($to_remove); - if ( $p_type=='OOo' ) - { - $value=str_replace('&','&',$value); - $value=str_replace('<','<',$value); - $value=str_replace('>','>',$value); - $value=str_replace('"','"',$value); - $value=str_replace("'",''',$value); - } - $buffer=substr_replace($buffer,$value,$pos,$len); - - // if the pattern if found we replace it + + $buffer=\Document::replace_value($buffer,$pattern, $value, 1,$p_type); } } } @@ -1111,9 +1085,9 @@ class Document } $sell=${'e_march'.$i.'_price'}; $qt=${'e_quant'.$i}; - $tot=bcmul($sell,$qt); - $tot=bcadd($tot,$tva_amount); - $sum=bcadd($sum,$tot); + $tot=bcmul($sell,$qt); + $tot=bcadd($tot,$tva_amount); + $sum=bcadd($sum,$tot); } $r=round($sum,2); @@ -1125,10 +1099,10 @@ class Document { $tva='e_march'.$i.'_tva_amount'; if (! isset(${$tva})) $tva_amount=0.0; - else $tva_amount=$ - { - $tva - }; + else { + $tva_amount=${$tva}; + $tva_amount=($tva_amount=="")?0:$tva_amount; + } $sum+=$tva_amount; $sum=round($sum,2); } @@ -1303,5 +1277,48 @@ class Document $this->db->exec_sql('update document set d_description = $1 where d_id=$2', array($p_desc,$this->d_id)); } + /** + * Replace a pattern with a value in the buffer , handle the change for OOo type file and amount + * + * @param string $p_buffer + * @param string $_pattern + * @param mixed $p_value + */ + static function replace_value($p_buffer, $p_pattern, $p_value,$p_limit=-1,$p_type='OOo') + { + $check=$p_pattern; + $check=str_replace(['<','>','<','>','='], "", $check); + if ( preg_replace('/[^[:alnum:]^_]/', '', $check) != $check) + { + throw new Exception(sprintf(_("chaine à remplacer [%s] contient un caractère interdit"), $p_pattern)); + } + $count=0; + if (is_numeric($p_value) && $p_type == 'OOo') + { + /* -- works only with OOo Calc -- */ + $searched='/office:value-type="string">'.$p_pattern.'/i'; + $replaced='office:value-type="float" office:value="'.$p_value.'">'.$p_value; + $p_buffer=preg_replace($searched, $replaced, $p_buffer,$p_limit,$count); + if ( $count == 0) { + /* -- work with libreOffice > 5 -- */ + $searched='/office:value-type="string" calcext:value-type="string">'.$p_pattern.'/i'; + $replaced='office:value-type="float" office:value="'.$p_value.'" calcext:value-type="float">'.$p_value; + $p_buffer=preg_replace($searched, $replaced, $p_buffer,$p_limit,$count); + } + } + if ($count == 0) + { + if ( $p_type=='OOo' ) + { + $p_value=str_replace('&','&',$p_value); + $p_value=str_replace('<','<',$p_value); + $p_value=str_replace('>','>',$p_value); + $p_value=str_replace('"','"',$p_value); + $p_value=str_replace("'",''',$p_value); + } + $p_buffer=preg_replace('/'.$p_pattern.'/i', $p_value, $p_buffer,$p_limit); + } + return $p_buffer; + } } From a1789c6b74213b49029e516c23f4c78f8950c098 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 24 Nov 2018 09:49:32 +0100 Subject: [PATCH 23/27] css : force a.inline to be inline ! --- html/style-classic7.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/html/style-classic7.css b/html/style-classic7.css index 60c7e2aed..718a7dd59 100644 --- a/html/style-classic7.css +++ b/html/style-classic7.css @@ -1072,16 +1072,16 @@ ul { a.line,div.content a.line { text-decoration:underline; - display:inline; + display:inline !important; /* color: #0000FF; */ cursor:pointer; } a.line:hover,div_content a.line { text-decoration:underline; - display:inline; - color: #FFFFFF; - background-color:#336699; + display:inline !important; + color: #FFFFFF !important; + background-color:#336699 !important; cursor:pointer; } From 085a67098c98148007f8e5e05d0a2273a963da3a Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 24 Nov 2018 12:28:08 +0100 Subject: [PATCH 24/27] CSS : print number align to right --- html/style-print.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/html/style-print.css b/html/style-print.css index baca9b6e5..7cc014c31 100644 --- a/html/style-print.css +++ b/html/style-print.css @@ -319,4 +319,7 @@ span.inplace_edit span.inplace_edit_input { text-decoration: none; +} +.inum { + text-align: right; } \ No newline at end of file From e335451028fd0b3c69a9bb6eac8874080ac464c6 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 24 Nov 2018 13:32:17 +0100 Subject: [PATCH 25/27] Document::replace_value handle space before numeric --- include/class/document.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/class/document.class.php b/include/class/document.class.php index 3f0327fa3..a703f7b7e 100644 --- a/include/class/document.class.php +++ b/include/class/document.class.php @@ -1301,7 +1301,7 @@ class Document $p_buffer=preg_replace($searched, $replaced, $p_buffer,$p_limit,$count); if ( $count == 0) { /* -- work with libreOffice > 5 -- */ - $searched='/office:value-type="string" calcext:value-type="string">'.$p_pattern.'/i'; + $searched='/office:value-type="string" calcext:value-type="string">()*'.$p_pattern.'/i'; $replaced='office:value-type="float" office:value="'.$p_value.'" calcext:value-type="float">'.$p_value; $p_buffer=preg_replace($searched, $replaced, $p_buffer,$p_limit,$count); } From 59eb0ce03a0474c81e2e18852c969f12f5c06318 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 25 Nov 2018 01:43:37 +0100 Subject: [PATCH 26/27] cosmetic --- html/style-classic7.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/style-classic7.css b/html/style-classic7.css index 718a7dd59..e8a3bb7ed 100644 --- a/html/style-classic7.css +++ b/html/style-classic7.css @@ -315,7 +315,7 @@ td.selectedcell{ /*color:#FFFFFF;*/ width:250px; text-align:center; - background-color: lightskyblue; + background-color: #002ba3; border-style: solid; border-width: 1px; border-color:white; From 2d0da8b05b1a98823eab06ddc6fd23ca74d3d5ac Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 26 Nov 2018 15:18:15 +0100 Subject: [PATCH 27/27] Exception rethrow --- html/do.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/html/do.php b/html/do.php index 0278416f6..71f687dca 100644 --- a/html/do.php +++ b/html/do.php @@ -311,10 +311,12 @@ if (isset($_REQUEST['ac'])) echo ''; echo _('Retour'); echo ''; + return; } else { alert($e->getMessage()); record_log($e->getTraceAsString()); + throw $e; } } } @@ -345,6 +347,7 @@ else { echo $exc->getMessage(); record_log($exc->getTraceAsString()); + throw $e; } }