From 023f07f89a76ef3eb7235d8e9b3d31be70f45424 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 27 Jun 2017 19:46:23 +0200 Subject: [PATCH 001/265] Manage_SQL : improve cosmetic + add error function --- html/js/infobulle.js | 7 ++ html/js/managetable.js | 15 ++- include/database/class_noalyss_sql.php | 3 +- include/lib/class_html_input.php | 11 +- include/lib/class_manage_table_sql.php | 165 ++++++++++++++++++------- 5 files changed, 149 insertions(+), 52 deletions(-) diff --git a/html/js/infobulle.js b/html/js/infobulle.js index 525585ff7..e87b19b1f 100644 --- a/html/js/infobulle.js +++ b/html/js/infobulle.js @@ -52,3 +52,10 @@ function hideBulle(p_ctl) var d=document.getElementById('bulle'); d.style.visibility="hidden"; } +function displayBulle(p_comment) { + var d=document.getElementById('bulle'); + d.innerHTML=p_comment; + d.style.top=posY+offsetY+"px"; + d.style.left=posX+offsetX+"px"; + d.style.visibility="visible"; +} \ No newline at end of file diff --git a/html/js/managetable.js b/html/js/managetable.js index 1e84a54c7..29e2f070c 100644 --- a/html/js/managetable.js +++ b/html/js/managetable.js @@ -172,16 +172,19 @@ var ManageTable = function (p_table_name) new_row.innerHTML = answer['html']; $("tb"+answer['ctl']).appendChild(new_row); } - new Effect.Highlight(answer['ctl_row'] ,{ startcolor: '#ABCBF7',endcolor: '#ffffff' }); + new Effect.Highlight(answer['ctl_row'] ,{startcolor: '#FAD4D4',endcolor: '#F78082' }); + alternate_row_color("tb"+answer['ctl']); + remove_waiting_box(); + $("dtr").hide(); } else { + remove_waiting_box(); smoke.alert("Changement impossible"); - throw "error in save"; + $("dtr").update(answer['html']); + } - alternate_row_color("tb"+answer['ctl']); - remove_waiting_box(); - $("dtr").hide(); - } catch (e) { + } + catch (e) { alert(e.message); return false; } diff --git a/include/database/class_noalyss_sql.php b/include/database/class_noalyss_sql.php index 34eb68948..35b5677cd 100644 --- a/include/database/class_noalyss_sql.php +++ b/include/database/class_noalyss_sql.php @@ -95,8 +95,7 @@ abstract class Noalyss_SQL */ public function save() { - $pk=$this->primary_key; - $count=$this->cn->get_value('select count(*) from '.$this->table.' where '.$this->primary_key.'=$1',array($this->$pk)); + $count = $this->exist(); if ($count == 0) $this->insert(); diff --git a/include/lib/class_html_input.php b/include/lib/class_html_input.php index 5fad2b752..fb6e63745 100755 --- a/include/lib/class_html_input.php +++ b/include/lib/class_html_input.php @@ -228,6 +228,15 @@ class HtmlInput $r='Δ'; return $r; } + static function errorbulle($p_comment) + { + global $g_failed; + $r=sprintf(' %s ', + $p_comment, + $p_comment, + $g_failed); + return $r; + } /** * return a string containing the html code for calling the modifyOperation */ @@ -476,7 +485,7 @@ class HtmlInput */ static function image_click($p_image,$p_js,$p_message) { - $ret=sprintf('', + $ret=sprintf('', $p_message,$p_image,$p_js); return $ret; diff --git a/include/lib/class_manage_table_sql.php b/include/lib/class_manage_table_sql.php index 1964e158c..b52259765 100644 --- a/include/lib/class_manage_table_sql.php +++ b/include/lib/class_manage_table_sql.php @@ -67,7 +67,7 @@ class Manage_Table_SQL private $row_update; //!< Flag to indicate if rows can be updated private $row_append; //!< Flag to indicate if rows can be added private $json_parameter; //!< Default parameter to add (gDossier...) - + private $aerror; //!< Array containing the error of the input data const UPDATABLE=1; const VISIBLE=2; @@ -97,8 +97,42 @@ class Manage_Table_SQL $this->callback="ajax.php"; $this->json=json_encode(array("gDossier"=>Dossier::id(), "op"=>"managetable")); + $this->aerror=[]; + } + function get_table() { + return $this->table; + } + /** + * @brief set the error message for a wrong input + * @param $p_col the column name + * @param $p_message the error message + * @see check + */ + function set_error($p_col,$p_message) + { + $this->aerror[$p_col]=$p_message; + } + /** + * @brief retrieve the error message + * @param $p_col column name + * @return string with message or empty if no error + * @see input + */ + function get_error($p_col) + { + if ( isset ($this->aerror[$p_col])) return $this->aerror[$p_col]; + return ""; + } + /** + * This function can be overrided to check the data before + * inserting , updating or removing, + * @see set_error get_error + * @return boolean + */ + function check() + { + return true; } - /** * @brief set the type of a column , it will change in the input db box , the * select must supply an array of possible values [val=> , label=>] with @@ -453,7 +487,7 @@ class Manage_Table_SQL } /** - * @brief set the id value of a data row + * @brief set the id value of a data row and load from the db */ function set_pk($p_id) { @@ -462,7 +496,9 @@ class Manage_Table_SQL } /** - * @brief get the data from http request + * @brief get the data from http request strip the not update or not visible data to their + * initial value. Before saving , it is important to set the pk and load from db + * @see set_pk */ function from_request() { @@ -471,7 +507,11 @@ class Manage_Table_SQL { $v=HtmlInput::default_value_request($this->a_order[$i], ""); $key=$this->a_order[$i]; - $this->table->$key=strip_tags($v); + if ( $this->get_property_visible($key) == TRUE + && $this->get_property_updatable($key) == TRUE ) + { + $this->table->$key=strip_tags($v); + } } } @@ -509,7 +549,7 @@ class Manage_Table_SQL $js=sprintf("%s.delete('%s','%s');", $this->object_name, $p_row[$this->table->primary_key], $this->object_name ); - echo HtmlInput::image_click("delete.gif", $js,_("effacer")); + echo HtmlInput::image_click("delete.gif", $js,_("Effacer")); } echo ""; echo ''; @@ -529,11 +569,12 @@ class Manage_Table_SQL $key=$this->a_order[$i]; $label=$this->a_label_displaid[$key]; $value=$this->table->get($key); - + $error=$this->get_error($key); + $error=($error=="")?"":HtmlInput::errorbulle($error); if ($this->get_property_visible($key)===TRUE) { // Label - echo " {$label} "; + echo " {$label} {$error}"; if ($this->get_property_updatable($key)==TRUE) { @@ -545,16 +586,29 @@ class Manage_Table_SQL $select->selected=$value; echo $select->input(); } - else + elseif ($this->a_type[$key]=="text") { $text=new IText($key); $text->value=$value; $min_size=(strlen($value)<30)?30:strlen($value)+5; $text->size=$min_size; echo $text->input(); - /* printf('', - $label, $value, $key, $key - );*/ + } + elseif ($this->a_type[$key]=="numeric") + { + $text=new INum($key); + $text->value=$value; + $min_size=(strlen($value)<10)?10:strlen($value)+1; + $text->size=$min_size; + echo $text->input(); + } + elseif ($this->a_type[$key]=="date") + { + $text=new IDate($key); + $text->value=$value; + $min_size=10; + $text->size=$min_size; + echo $text->input(); } echo ""; } @@ -584,30 +638,38 @@ class Manage_Table_SQL { // fill up object with $_REQUEST $this->from_request(); - // save the object - $this->save(); - // compose the answer - $status="OK"; - $s1=$xml->createElement("status", $status); - $ctl=$this->object_name."_".$this->table->get_pk_value(); - $s2=$xml->createElement("ctl_row", $ctl); - $s4=$xml->createElement("ctl", $this->object_name); - ob_start(); - $this->table->load(); - $array=$this->table->to_array(); - $this->display_row($array); - $html=ob_get_contents(); - ob_end_clean(); - $s3=$xml->createElement("html" ); - $t1=$xml->createTextNode($html); - $s3->appendChild($t1); - + // Check if the data are valid , if not then display the + // input values with the error message + // + if ( $this->check() == false ) { + $xml=$this->ajax_input("NOK"); + return $xml; + } else { + // Data are valid so we can save them + $this->save(); + // compose the answer + $status="OK"; + $s1=$xml->createElement("status", $status); + $ctl=$this->object_name."_".$this->table->get_pk_value(); + $s2=$xml->createElement("ctl_row", $ctl); + $s4=$xml->createElement("ctl", $this->object_name); + ob_start(); + $this->table->load(); + $array=$this->table->to_array(); + $this->display_row($array); + $html=ob_get_contents(); + ob_end_clean(); + $s3=$xml->createElement("html" ); + $t1=$xml->createTextNode($html); + $s3->appendChild($t1); + } $root=$xml->createElement("data"); $root->appendChild($s1); $root->appendChild($s2); $root->appendChild($s3); $root->appendChild($s4); + $xml->appendChild($root); } catch (Exception $ex) { @@ -621,8 +683,8 @@ class Manage_Table_SQL $root->appendChild($s2); $root->appendChild($s3); $root->appendChild($s4); + $xml->appendChild($root); } - $xml->appendChild($root); return $xml; } @@ -634,13 +696,13 @@ class Manage_Table_SQL * - content : Html answer * @return DomDocument */ - function ajax_input() + function ajax_input($p_status="OK") { $xml=new DOMDocument("1.0", "UTF-8"); - $xml->createElement("status", "OK"); + $xml->createElement("status", $p_status); try { - $status="OK"; + $status=$p_status; ob_start(); echo HtmlInput::title_box("Donnée", "dtr"); @@ -654,6 +716,8 @@ class Manage_Table_SQL echo HtmlInput::hidden("p_id", $this->table->get_pk_value()); // button Submit and cancel $close=sprintf("\$('%s').remove()", "dtr"); + // display error if any + $this->display_error(); echo ''; echo ""; - + + $html=ob_get_contents(); ob_end_clean(); @@ -756,14 +821,7 @@ class Manage_Table_SQL */ function save() { - if ($this->table->exist()==0) - { - $this->table->insert(); - } - else - { - $this->table->update(); - } + $this->table->save(); } /** @@ -795,5 +853,26 @@ class Manage_Table_SQL { $this->table->set($p_key, $p_value); } + /** + * Display a list of the error collected + * @see get_error set_error + * + */ + function display_error() + { + $nb_order=count($this->a_order); + if ( count($this->aerror) == 0)return; + echo "Liste erreurs :"; + for ($i=0; $i<$nb_order; $i++) + { + $key=$this->a_order[$i]; + $label=$this->a_label_displaid[$key]; + $error=$this->get_error($key); + $error=($error=="")?"":"".h($label)." : ".h($this->get_error($key)).""; + + echo $error; + } + echo ""; + } } From 5ca7658031af60867fd43aa90e9399a34b49ce8b Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 4 Jul 2017 00:07:31 +0200 Subject: [PATCH 002/265] Improve debug --- html/do.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/html/do.php b/html/do.php index df7396bd7..cae78fb8a 100644 --- a/html/do.php +++ b/html/do.php @@ -101,6 +101,20 @@ if ( DEBUG ) { +

$_REQUEST

+ +

$_SESSION

+ + +

$GLOBALS

+ + ', $this->object_name); } @@ -478,10 +480,10 @@ class Manage_Table_SQL echo th($this->a_label_displaid[$key]); } if ($this->can_update_row()) { - echo td(_('Modifier')); + echo th(" ",'style="width:40px"'); } if ($this->can_delete_row()) { - echo td(_('Effacer')); + echo th(" ",'style="width:40px"'); } echo ""; } From cc03a7a6d11da1386a50435fc3f5b110881a86c8 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 4 Jul 2017 00:08:40 +0200 Subject: [PATCH 004/265] HtmlInput::button_action: add icon , htmlInput : add documentation --- include/lib/class_html_input.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/lib/class_html_input.php b/include/lib/class_html_input.php index fb6e63745..c8b0d773b 100755 --- a/include/lib/class_html_input.php +++ b/include/lib/class_html_input.php @@ -463,17 +463,20 @@ class HtmlInput return $r; } /** - * button Html + * button Html with javascript *@param $action action action to perform (message) without onclick *@param $javascript javascript to execute + *@param $id is the DOM element id + *@param $p_class CSS class of the button + *@param $p_symbole raw symbole to add to the action message */ - static function button_action($action,$javascript,$id="xx",$p_class="button") + static function button_action($action,$javascript,$id="xx",$p_class="button",$p_symbole="") { if ($id=="xx"){ $id=HtmlInput::generate_id("xx"); } $r=""; - $r.=''; + $r.=''; return $r; } From 85566da94c911ac9cb16fb61d91a88e734816e75 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 5 Jul 2017 10:33:39 +0200 Subject: [PATCH 005/265] New function manage_table::set_table, and manage_table::delete --- include/lib/class_manage_table_sql.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/lib/class_manage_table_sql.php b/include/lib/class_manage_table_sql.php index 2a9bb39ab..bc8c4537f 100644 --- a/include/lib/class_manage_table_sql.php +++ b/include/lib/class_manage_table_sql.php @@ -102,6 +102,9 @@ class Manage_Table_SQL function get_table() { return $this->table; } + function set_table(Noalyss_SQL $p_noalyss_sql) { + $this->table=$p_noalyss_sql; + } /** * @brief set the error message for a wrong input * @param $p_col the column name @@ -784,7 +787,7 @@ class Manage_Table_SQL $xml=new DOMDocument('1.0', "UTF-8"); try { - $this->table->delete(); + $this->delete(); $status="OK"; $s1=$xml->createElement("status", $status); $ctl=$this->object_name."_".$this->table->get_pk_value(); From 29d9ffe4fbd6cbec746614b6147f6d6935f8b197 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 12 Jul 2017 19:29:59 +0200 Subject: [PATCH 006/265] Bug : cannot print action in profil Cannot add a export / printing in profile --- include/ajax/ajax_get_profile.php | 1 + include/class/class_profile_menu.php | 1 + include/profile.inc.php | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/ajax/ajax_get_profile.php b/include/ajax/ajax_get_profile.php index 952852b86..2ef1618df 100644 --- a/include/ajax/ajax_get_profile.php +++ b/include/ajax/ajax_get_profile.php @@ -55,6 +55,7 @@ $a_tab[$call_tab]='tabs_selected';
  •   +
  • + cn->exec_sql(" diff --git a/include/profile.inc.php b/include/profile.inc.php index 63715e893..6a1b15ffe 100644 --- a/include/profile.inc.php +++ b/include/profile.inc.php @@ -350,7 +350,7 @@ if (isset($_POST['add_menu'])||isset($_POST['add_impress'])) * Do not insert twice the same menu */ $duplicate = $cn->get_value(" select count(*) from profile_menu where " - . " pm_id_dep = $1 and me_code = $2",array($p_dep,$me_code)); + . " pm_id_dep = $1 and me_code = $2",array($pm_id_dep,$me_code)); if ( $duplicate > 0 ) { throw new Exception(_('Doublon')); } From 67ea72a02b904da4a0ffcb633e00d6e89a3743a7 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 28 Aug 2017 18:59:37 +0200 Subject: [PATCH 007/265] index.php version --- html/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/index.php b/html/index.php index 7c614fe2d..559eace39 100644 --- a/html/index.php +++ b/html/index.php @@ -261,7 +261,7 @@ if (isset ($_REQUEST['reconnect']) && isset ($_REQUEST['backurl'])) { } echo ' -version NOALYSS_VERSION - '.$my_domain.' +version 6919+3 - '.$my_domain.'

    From fa72daa9efec01a5770b70072b20001eb64c52ba Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 28 Aug 2017 19:00:11 +0200 Subject: [PATCH 008/265] noalyss_sql.class fix bug in function set --- include/database/class_noalyss_sql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/database/class_noalyss_sql.php b/include/database/class_noalyss_sql.php index 35b5677cd..9dab28e67 100644 --- a/include/database/class_noalyss_sql.php +++ b/include/database/class_noalyss_sql.php @@ -122,7 +122,7 @@ abstract class Noalyss_SQL public function set($p_string, $p_value) { if (array_key_exists($p_string, $this->type)) { - $this->$idx=$p_value; + $this->$p_string=$p_value; } else throw new Exception(__FILE__.":".__LINE__.$p_string.'Erreur attribut inexistant '.$p_string); } From ceb5427110826e49f9bf1748574fa3f3d0b3cc32 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 28 Aug 2017 19:05:17 +0200 Subject: [PATCH 009/265] Version --- html/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/index.php b/html/index.php index 559eace39..8ea2b40ca 100644 --- a/html/index.php +++ b/html/index.php @@ -261,7 +261,7 @@ if (isset ($_REQUEST['reconnect']) && isset ($_REQUEST['backurl'])) { } echo ' -version 6919+3 - '.$my_domain.' +version 6919+5 - '.$my_domain.'

    From b6b7bf6381d3c9789447475fbac085cab6daea62 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 28 Aug 2017 19:06:04 +0200 Subject: [PATCH 010/265] Version --- include/constant.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/constant.php b/include/constant.php index a2bb1317c..3396b698f 100644 --- a/include/constant.php +++ b/include/constant.php @@ -88,7 +88,7 @@ define ('SMALLX','ⵝ'); define ('BUTTONADD',"✚"); -define ('SVNINFO',NOALYSS_VERSION); +define ('SVNINFO',6919+5); if ( ! defined ('DEBUG')) { define ("DEBUG",false); } From 1879d10288d449f4bfa0cb5b272cd05518347b6d Mon Sep 17 00:00:00 2001 From: Dany DE BONTRIDDER Date: Fri, 8 Dec 2017 13:30:11 +0100 Subject: [PATCH 011/265] Fix problem with invalid unicode sequence --- html/fid_card.php | 10 +++++----- html/js/ajax_fiche.js | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/html/fid_card.php b/html/fid_card.php index fab07b321..3bc6e9112 100644 --- a/html/fid_card.php +++ b/html/fid_card.php @@ -146,13 +146,13 @@ if (sizeof($sql) != 0 ) $sql_name=$cn->execute('get_name',array($sql[$i]['f_id'],23)); if (Database::num_row($sql_name) == 1) $quick_code=Database::fetch_result($sql_name,0,0); - + $fid=htmlentities($_REQUEST['FID']); /* Highlight the found pattern with bold format */ - $name=str_ireplace($_REQUEST['FID'],''.$_REQUEST['FID'].'',h($name)); - $qcode=str_ireplace($_REQUEST['FID'],''.$_REQUEST['FID'].'',h($quick_code)); - $desc=str_ireplace($_REQUEST['FID'],''.$_REQUEST['FID'].'',h($desc)); - printf('
  • %s %s %s
  • ', + $name=str_ireplace($_REQUEST['FID'],''.$fid.'',h($name)); + $qcode=str_ireplace($_REQUEST['FID'],''.$fid.'',h($quick_code)); + $desc=str_ireplace($_REQUEST['FID'],''.$fid.'',h($desc)); + printf('
  • %s %s %s
  • ', $quick_code, $quick_code, $name, diff --git a/html/js/ajax_fiche.js b/html/js/ajax_fiche.js index 88503ed4b..28e7afb0b 100644 --- a/html/js/ajax_fiche.js +++ b/html/js/ajax_fiche.js @@ -116,6 +116,7 @@ function ajaxFid(p_ctl) } queryString=queryString+"&j="+jrn+'&gDossier='+gDossier; queryString=queryString+'&ctl='+p_ctl.id; + queryString=encodeURI(queryString); var action=new Ajax.Request ( "fid.php", From ac996a79b46d3f956095e54b898ecfe02668ae95 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 8 Dec 2017 20:11:22 +0100 Subject: [PATCH 012/265] Protect queryString with encodeURI --- html/js/acc_ledger.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 4cbc79070..656c4b555 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -162,7 +162,7 @@ function update_row(ctl) { var jrn = g('p_jrn').value; var dossier = g('gDossier').value; - var qs = 'gDossier=' + dossier + '&op=minrow&j=' + jrn + '&ctl=' + ctl; + var qs = encodeURI('gDossier=' + dossier + '&op=minrow&j=' + jrn + '&ctl=' + ctl); var action = new Ajax.Request( "ajax_misc.php", { @@ -915,7 +915,7 @@ function filter_card(obj, queryString) { queryString = queryString + '&j=' + jrn; } - return queryString; + return encodeURI(queryString); } /** *@brief to display the lettering for the operation, call @@ -1056,7 +1056,7 @@ function op_save(obj) var action = new Ajax.Request('ajax_misc.php', { method: 'post', - parameters: queryString, + parameters: encodeURI(queryString), onFailure: null, onSuccess: infodiv } From fc2760f9fce0df361150aef229da3a04b0dcc16f Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 8 Dec 2017 20:25:53 +0100 Subject: [PATCH 013/265] fix bug with filter_card : encodeURI not needed --- html/js/acc_ledger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 656c4b555..5c62bddea 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -915,7 +915,7 @@ function filter_card(obj, queryString) { queryString = queryString + '&j=' + jrn; } - return encodeURI(queryString); + return queryString; } /** *@brief to display the lettering for the operation, call From 22e589833bb07bdc9602d7271a23083e3510c45f Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 8 Dec 2017 20:27:25 +0100 Subject: [PATCH 014/265] Set version 6919.6 --- html/index.php | 2 +- include/constant.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/html/index.php b/html/index.php index 8ea2b40ca..7edff3f47 100644 --- a/html/index.php +++ b/html/index.php @@ -261,7 +261,7 @@ if (isset ($_REQUEST['reconnect']) && isset ($_REQUEST['backurl'])) { } echo ' -version 6919+5 - '.$my_domain.' +version 6919+6 - '.$my_domain.'

    diff --git a/include/constant.php b/include/constant.php index 3396b698f..155194b52 100644 --- a/include/constant.php +++ b/include/constant.php @@ -88,7 +88,7 @@ define ('SMALLX','ⵝ'); define ('BUTTONADD',"✚"); -define ('SVNINFO',6919+5); +define ('SVNINFO',6919+6); if ( ! defined ('DEBUG')) { define ("DEBUG",false); } From 163d9ce0585aa199bf7d7347920e0d4835d4eb30 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 14 Dec 2017 21:28:45 +0100 Subject: [PATCH 015/265] Accounting : error message if accounting is too large --- html/js/card.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/html/js/card.js b/html/js/card.js index 8b4fa9383..552f9c69e 100644 --- a/html/js/card.js +++ b/html/js/card.js @@ -692,9 +692,13 @@ function form_blank_card(obj) */ function save_card(obj) { - var content=$(obj).ipopup; + var accounting= $(obj)['av_text25']; + if ( accounting.value.length > 40 ) { + smoke.alert('Poste comptable trop grand'); + return false; + } // Data must be taken here - data=$('save_card').serialize(false); + var data=$('save_card').serialize(false); var content=$(obj).ipopup; $(content).innerHTML=loading(); var dossier=$('gDossier').value; From b6aaaeeb9319afa2af5623d8ff3670424fa771f4 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 14 Dec 2017 21:34:20 +0100 Subject: [PATCH 016/265] Accounting : error message if accounting is too large --- html/js/card.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/html/js/card.js b/html/js/card.js index 552f9c69e..547bd20cb 100644 --- a/html/js/card.js +++ b/html/js/card.js @@ -692,10 +692,12 @@ function form_blank_card(obj) */ function save_card(obj) { - var accounting= $(obj)['av_text25']; - if ( accounting.value.length > 40 ) { - smoke.alert('Poste comptable trop grand'); - return false; + if ($(obj)['av_text5']) { + var accounting= $(obj)['av_text5']; + if ( accounting.value.length > 40 ) { + smoke.alert('Poste comptable trop grand'); + return false; + } } // Data must be taken here var data=$('save_card').serialize(false); var content=$(obj).ipopup; From 72179995be93940274cb44e3ce39c765cc47cb51 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 14 Dec 2017 21:53:49 +0100 Subject: [PATCH 017/265] set version 6919.7 --- include/constant.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/constant.php b/include/constant.php index 155194b52..de991bcbf 100644 --- a/include/constant.php +++ b/include/constant.php @@ -88,7 +88,7 @@ define ('SMALLX','ⵝ'); define ('BUTTONADD',"✚"); -define ('SVNINFO',6919+6); +define ('SVNINFO',6919+7); if ( ! defined ('DEBUG')) { define ("DEBUG",false); } From be75a27d2e14cfdf14a7f4355879af0eb5cad355 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 12 Dec 2017 19:55:57 +0100 Subject: [PATCH 018/265] =?UTF-8?q?Task=20#0001507:=20Click=20sur=20d?= =?UTF-8?q?=C3=A9tail=20op=C3=A9rations=20appara=C3=AEt=20trop=20haut=20Us?= =?UTF-8?q?e=20the=20function=20window.pageYOffset=20instead=20of=20window?= =?UTF-8?q?.scrollY?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/js/scripts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/js/scripts.js b/html/js/scripts.js index 83054b9bb..87e9b90fa 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -1436,9 +1436,9 @@ function fixed_position(p_sx, p_sy) function calcy(p_sy) { var sy = p_sy; - if (window.scrollY) + if (window.pageYOffset) { - sy = window.scrollY + p_sy; + sy = window.pageYOffset + p_sy; } else { From 518119e9c837160d48a0919a2be4c31471a7113b Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 28 Nov 2017 19:17:40 +0100 Subject: [PATCH 019/265] Improve calc --- html/js/calc.js | 11 ++++++++--- html/js/scripts.js | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/html/js/calc.js b/html/js/calc.js index 37477c5cb..4789efcee 100644 --- a/html/js/calc.js +++ b/html/js/calc.js @@ -38,6 +38,12 @@ function cal() try { Compute(); + p_variable=p_variable.replace(/[a-z]/,''); + p_variable=p_variable.replace(/[A-Z]/,''); + p_variable=p_variable.replace(//,''); p_variable=p_variable.replace(/ /g,""); p_variable=p_variable.replace(/\+/g,"+ "); p_variable=p_variable.replace(/-/g,"- "); @@ -52,9 +58,8 @@ function cal() alert_box("Mauvaise formule\n"+p_variable); return false; } - p_history=p_history+'
    '+p_variable; - p_history+="="+result.toString(); - var str_sub="

    Total :"+p_variable+" = "+result.toString()+"

    "; + p_history=p_variable+"="+result.toString()+'
    '+p_history; + var str_sub="Total :"+p_variable+" = "+result.toString(); this.document.getElementById("sub_total").innerHTML=str_sub; this.document.getElementById("listing").innerHTML=p_history; this.document.getElementById('inp').value=""; diff --git a/html/js/scripts.js b/html/js/scripts.js index 87e9b90fa..5a4299537 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -1062,7 +1062,7 @@ function show_calc() shtml += ''; shtml += '

    Calculatrice

    '; shtml += '
    Calculatrice simplifiée: écrivez simplement les opérations que vous voulez puis la touche retour. exemple : 1+2+3*(1/5) '; - shtml += '

    Taper une formule (ex 20*5.1) puis enter
    '; + shtml += ' Taper une formule (ex 20*5.1) puis enter '; var obj = {id: sid, html: shtml, drag: true, style: '' From 5c595c6ac952424d82dc51b173e17244b05c9fed Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 14 Dec 2017 22:05:59 +0100 Subject: [PATCH 020/265] Calc : set 4 decimals --- html/js/calc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/js/calc.js b/html/js/calc.js index 4789efcee..5460a7bfb 100644 --- a/html/js/calc.js +++ b/html/js/calc.js @@ -51,7 +51,7 @@ function cal() sub=eval(p_variable); var result=parseFloat(sub); - result=Math.round(result*100)/100; + result=Math.round(result*10000)/10000; } catch(exception) { From 38b0e7f61d6addcbd01a83993bb495d9c7869763 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 16 Sep 2017 11:48:42 +0200 Subject: [PATCH 021/265] NEW : ICard , you can hide or show the accounting in the search box with the functions ICard->hide_accounting and ICard->show_accounting --- html/js/card.js | 16 +++++++++++++++- include/ajax/ajax_card.php | 3 ++- include/lib/class_icard.php | 15 ++++++++++++++- include/template/card_result.php | 9 ++++++++- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/html/js/card.js b/html/js/card.js index 547bd20cb..c8e7083bf 100644 --- a/html/js/card.js +++ b/html/js/card.js @@ -64,6 +64,7 @@ function boxsearch_card(p_dossier) * - inp input text to update with the quickcode * - label field to update with the name * - ctl the id to fill with the HTML answer (ending with _content) + * - acc 1 if accounting are visible */ function search_card(obj) { @@ -86,10 +87,17 @@ function search_card(obj) jrn=-1; } } + var accvis=obj.accvis; + if ( accvis == undefined ) { + accvis=0; + } else { + accvis=obj.accvis; + } var query=encodeJSON({'gDossier':gDossier, 'inp':inp,'label':label,'price':price,'tvaid':tvaid, 'ctl':'search_card','op2':'fs','jrn':jrn, - 'typecard':typecard,'query':string_to_search,'op':'card' + 'typecard':typecard,'query':string_to_search,'op':'card', + 'accvis':accvis }); if ( $('search_card') ) { removeDiv('search_card'); @@ -259,6 +267,12 @@ function search_get_card(obj) { queryString+="&ctl="+obj.ctl; } + if ( obj.elements['accvis'] ) + { + queryString+="&accvis="+$F(accvis); + } else { + queryString+="&accvis=0"; + } $('asearch').innerHTML=loading(); var action=new Ajax.Request ( 'ajax_misc.php', { diff --git a/include/ajax/ajax_card.php b/include/ajax/ajax_card.php index 22b9a7bd0..ca6c88787 100644 --- a/include/ajax/ajax_card.php +++ b/include/ajax/ajax_card.php @@ -51,6 +51,7 @@ * - ctl (to return) * - popup * - ref if we want to refresh the window + * - acc is accounting is visible or not *\see fiche fiche::Save constant.php */ if ( ! defined('ALLOWED')) die (_('Accès non autorisé')); @@ -350,7 +351,7 @@ case 'fs': $r.=''; $r.=dossier::hidden().HtmlInput::hidden('op','fs'); $array=array(); - foreach (array('query','inp','jrn','label','typecard','price','tvaid') as $i) + foreach (array('accvis','query','inp','jrn','label','typecard','price','tvaid') as $i) { if (isset(${$i}) ) { diff --git a/include/lib/class_icard.php b/include/lib/class_icard.php index 437f150c6..42a99c02a 100644 --- a/include/lib/class_icard.php +++ b/include/lib/class_icard.php @@ -132,6 +132,19 @@ class ICard extends HtmlInput $this->choice_create=1; $this->autocomplete=1; $this->style=' style="vertical-align:50%"'; + $this->accvis=1; //!< account_visible =1 otherwise 0 + } + /** + * @brief in the search box, the accounting will be hidden + */ + function hide_accounting() { + $this->accvis=0; + } + /** + * @brief in the search box, the accounting will be shown it is the default + */ + function show_accounting() { + $this->accvis=1; } /*!\brief set the javascript callback function * by default it is update_value called BEFORE the querystring is send @@ -297,7 +310,7 @@ class ICard extends HtmlInput if ( $this->readOnly==true) return ''; if ( ! isset($this->id )) $this->id=$this->name; $a=""; - foreach (array('typecard','jrn','label','price','tvaid') as $att) + foreach (array('typecard','jrn','label','price','tvaid','accvis') as $att) { if (isset($this->$att) ) $a.="this.".$att."='".$this->$att."';"; diff --git a/include/template/card_result.php b/include/template/card_result.php index 3bf77d4a5..6c38fad65 100644 --- a/include/template/card_result.php +++ b/include/template/card_result.php @@ -9,14 +9,21 @@ - + + + From 0a6a6399b8da535dd3742899be98edf9ee970f5f Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 18 Dec 2017 17:22:39 +0100 Subject: [PATCH 022/265] set version --- html/index.php | 2 +- include/constant.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/html/index.php b/html/index.php index 7edff3f47..37a705202 100644 --- a/html/index.php +++ b/html/index.php @@ -261,7 +261,7 @@ if (isset ($_REQUEST['reconnect']) && isset ($_REQUEST['backurl'])) { } echo ' -version 6919+6 - '.$my_domain.' +version 6919+8 - '.$my_domain.'

    diff --git a/include/constant.php b/include/constant.php index de991bcbf..06ae9944a 100644 --- a/include/constant.php +++ b/include/constant.php @@ -88,7 +88,7 @@ define ('SMALLX','ⵝ'); define ('BUTTONADD',"✚"); -define ('SVNINFO',6919+7); +define ('SVNINFO',6919+8); if ( ! defined ('DEBUG')) { define ("DEBUG",false); } From 4af03a5fa2fd81cb2490ba19dea1939c9ee4c28b Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 20 Jan 2018 12:16:54 +0100 Subject: [PATCH 023/265] Task #0001529: Icon_Action missing --- html/test.php | 1 + 1 file changed, 1 insertion(+) diff --git a/html/test.php b/html/test.php index 36ff91d5f..d5a467e75 100644 --- a/html/test.php +++ b/html/test.php @@ -34,6 +34,7 @@ include_once("lib/ac_common.php"); require_once('lib/database.class.php'); require_once ('class/dossier.class.php'); require_once('lib/html_input.class.php'); +require_once('lib/icon_action.class.php'); require_once ('lib/function_javascript.php'); require_once 'class/user.class.php'; require_once NOALYSS_INCLUDE.'/lib/http_input.class.php'; From c8d5c3537baec170f5dc0ac3ea4dc7b0d0b5cd43 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 21 Jan 2018 12:10:44 +0100 Subject: [PATCH 024/265] th.num align right --- html/style-r692.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/style-r692.css b/html/style-r692.css index b5ea98793..05e584ba1 100644 --- a/html/style-r692.css +++ b/html/style-r692.css @@ -540,7 +540,7 @@ span.action { height:3rem; } -td.num { +th.num , td.num,table.result th.num { text-align:right; } tr.priority1 { From 7f5e25e33b20678244f8d569d1aa12bba9d54a95 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 21 Jan 2018 12:36:51 +0100 Subject: [PATCH 025/265] =?UTF-8?q?Task=20#0001530:=20R=C3=A9=C3=A9criture?= =?UTF-8?q?=20PRINTJRN,=20Base=20+=20=20Sale?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/class/acc_ledger.class.php | 538 +------------ include/class/acc_ledger_history.class.php | 283 +++++++ .../acc_ledger_history_financial.class.php | 28 + .../acc_ledger_history_generic.class.php | 737 ++++++++++++++++++ .../acc_ledger_history_purchase.class.php | 26 + .../class/acc_ledger_history_sale.class.php | 222 ++++++ include/impress_jrn.inc.php | 344 ++------ .../acc_history_ledger_sale_oneline.php | 134 ++++ .../acc_ledger_history_sale_detail.php | 180 +++++ .../acc_ledger_history_sale_extended.php | 171 ++++ scenario/acc_ledger_historyTest.php | 68 ++ 11 files changed, 1911 insertions(+), 820 deletions(-) create mode 100644 include/class/acc_ledger_history.class.php create mode 100644 include/class/acc_ledger_history_financial.class.php create mode 100644 include/class/acc_ledger_history_generic.class.php create mode 100644 include/class/acc_ledger_history_purchase.class.php create mode 100644 include/class/acc_ledger_history_sale.class.php create mode 100644 include/template/acc_history_ledger_sale_oneline.php create mode 100644 include/template/acc_ledger_history_sale_detail.php create mode 100644 include/template/acc_ledger_history_sale_extended.php create mode 100644 scenario/acc_ledger_historyTest.php diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index d2d3e3ae0..1f32a0d6a 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -381,237 +381,11 @@ class Acc_Ledger extends jrn_def_sql return $ret['jrn_def_name']; } - /** - * @brief Get The data - * - * - * @paramp_from from periode - * @paramp_to to periode - * @paramp_limit starting line - * @paramp_offset number of lines - * \return Array with the asked data - * - */ - function get_row($p_from, $p_to, $p_limit=-1, $p_offset=-1) - { - global $g_user; - $periode=sql_filter_per($this->db, $p_from, $p_to, 'p_id', 'jr_tech_per'); + - $cond_limite=($p_limit!=-1)?" limit ".$p_limit." offset ".$p_offset:""; - // retrieve the type - $this->get_type(); - // Grand livre == 0 - if ($this->id!=0) - { - $Res=$this->db->exec_sql("select jr_id,j_id,j_id as int_j_id,to_char(j_date,'DD.MM.YYYY') as j_date, - jr_internal, - case j_debit when 't' then j_montant::text else ' ' end as deb_montant, - case j_debit when 'f' then j_montant::text else ' ' end as cred_montant, - j_debit as debit,j_poste as poste,j_qcode,jr_montant , ". - "case when j_text='' or j_text is null then pcm_lib else j_text end as description,j_grpt as grp, - jr_comment||' ('||jr_internal||')' as jr_comment, - jr_pj_number, - j_qcode, - jr_rapt as oc, j_tech_per as periode - from jrnx left join jrn on ". - "jr_grpt_id=j_grpt ". - " left join tmp_pcmn on pcm_val=j_poste ". - " where j_jrn_def=".$this->id. - " and ".$periode." order by j_date::date asc,substring(jr_pj_number,'[0-9]+$')::numeric asc,j_grpt,j_debit desc ". - $cond_limite); - } - else - { - $Res=$this->db->exec_sql("select jr_id,j_id,j_id as int_j_id,to_char(j_date,'DD.MM.YYYY') as j_date, - jr_internal, - case j_debit when 't' then j_montant::text else ' ' end as deb_montant, - case j_debit when 'f' then j_montant::text else ' ' end as cred_montant, - j_debit as debit,j_poste as poste,j_qcode,". - "case when j_text='' or j_text is null then pcm_lib else j_text end as description,j_grpt as grp, - jr_comment||' ('||jr_internal||')' as jr_comment, - jr_pj_number, - jr_montant, - j_qcode, - jr_rapt as oc, j_tech_per as periode from jrnx left join jrn on ". - "jr_grpt_id=j_grpt left join tmp_pcmn on pcm_val=j_poste - join jrn_def on (jr_def_id=jrn_def_id) - where ". - $g_user->get_ledger_sql()." and ". - " ".$periode." order by j_date::date,substring(jr_pj_number,'[0-9]+$') asc,j_grpt,j_debit desc ". - $cond_limite); - } + - $array=array(); - $Max=Database::num_row($Res); - if ($Max==0) - return null; - $case=""; - $tot_deb=0; - $tot_cred=0; - $row=Database::fetch_all($Res); - for ($i=0; $i<$Max; $i++) - { - $fiche=new Fiche($this->db); - $line=$row[$i]; - $mont_deb=($line['deb_montant']!=0)?sprintf("% 8.2f", - $line['deb_montant']):""; - $mont_cred=($line['cred_montant']!=0)?sprintf("% 8.2f", - $line['cred_montant']):""; - $jr_montant=($line['jr_montant']!=0)?sprintf("% 8.2f", - $line['jr_montant']):""; - $tot_deb+=$line['deb_montant']; - $tot_cred+=$line['cred_montant']; - $tot_op=$line['jr_montant']; - - /* Check first if there is a quickcode */ - if (strlen(trim($line['description']))==0&&strlen(trim($line['j_qcode'])) - !=0) - { - if ($fiche->get_by_qcode($line['j_qcode'], false)==0) - { - $line['description']=$fiche->strAttribut(ATTR_DEF_NAME); - } - } - if ($case!=$line['grp']) - { - $case=$line['grp']; - // for financial, we show if the amount is or not in negative - if ($this->type=='FIN') - { - $amount=$this->db->get_value('select qf_amount from quant_fin where jr_id=$1', - array($line['jr_id'])); - /* if nothing is found */ - if ($this->db->count()==0) - $tot_op=$jr_montant; - else if ($amount<0) - { - $tot_op=$amount; - } - } - $array[]=array( - 'jr_id'=>$line['jr_id'], - 'int_j_id'=>$line['int_j_id'], - 'j_id'=>$line['j_id'], - 'j_date'=>$line['j_date'], - 'internal'=>$line['jr_internal'], - 'deb_montant'=>'', - 'cred_montant'=>' ', - 'description'=>''.h($line['jr_comment']).' ['.$tot_op.'] ', - 'poste'=>$line['oc'], - 'j_qcode'=>$line['j_qcode'], - 'periode'=>$line['periode'], - 'jr_pj_number'=>$line ['jr_pj_number']); - - $array[]=array( - 'jr_id'=>'', - 'int_j_id'=>$line['int_j_id'], - 'j_id'=>'', - 'j_date'=>'', - 'internal'=>'', - 'deb_montant'=>$mont_deb, - 'cred_montant'=>$mont_cred, - 'description'=>$line['description'], - 'poste'=>$line['poste'], - 'j_qcode'=>$line['j_qcode'], - 'periode'=>$line['periode'], - 'jr_pj_number'=>'' - ); - } - else - { - $array[]=array( - 'jr_id'=>$line['jr_id'], - 'int_j_id'=>$line['int_j_id'], - 'j_id'=>'', - 'j_date'=>'', - 'internal'=>'', - 'deb_montant'=>$mont_deb, - 'cred_montant'=>$mont_cred, - 'description'=>$line['description'], - 'poste'=>$line['poste'], - 'j_qcode'=>$line['j_qcode'], - 'periode'=>$line['periode'], - 'jr_pj_number'=>''); - } - } - $this->row=$array; - $a=array($array, $tot_deb, $tot_cred); - return $a; - } - - /** @brief Get simplified row from ledger - * - * @param p_from periode - * @param p_to periode - * @param p_limit starting line - * @param p_offset number of lines - * @param trunc if data must be truncated (pdf export) - * - * \return an Array with the asked data - */ - function get_rowSimple($p_from, $p_to, $trunc=0, $p_limit=-1, $p_offset=-1) - { - global $g_user; - // Grand-livre : id= 0 - //--- - $jrn=($this->id==0 )?"and ".$g_user->get_ledger_sql():"and jrn_def_id = ".$this->id; - - $periode=sql_filter_per($this->db, $p_from, $p_to, 'p_id', 'jr_tech_per'); - - $cond_limite=($p_limit!=-1)?" limit ".$p_limit." offset ".$p_offset:""; - //--- - $sql=" - SELECT jrn.jr_id as jr_id , - jrn.jr_id as num , - jrn.jr_def_id as jr_def_id, - jrn.jr_montant as montant, - substr(jrn.jr_comment,1,35) as comment, - to_char(jrn.jr_date,'DD-MM-YYYY') as date, - to_char(jrn.jr_date_paid,'DD-MM-YYYY') as date_paid, - jr_pj_number, - jr_internal, - jrn.jr_grpt_id as grpt_id, - jrn.jr_pj_name as pj, - jrn_def_type, - jrn.jr_tech_per - FROM jrn join jrn_def on (jrn_def_id=jr_def_id) - WHERE $periode $jrn order by jr_date,substring(jrn.jr_pj_number,'[0-9]+$')::numeric asc $cond_limite"; - - $Res=$this->db->exec_sql($sql); - $Max=Database::num_row($Res); - if ($Max==0) - { - return null; - } - $type=$this->get_type(); - // for type ACH and Ven we take more info - if ($type=='ACH'||$type=='VEN') - { - $a_ParmCode=$this->db->get_array('select p_code,p_value from parm_code'); - $a_TVA=$this->db->get_array('select tva_id,tva_label,tva_poste - from tva_rate where tva_rate != 0 order by tva_rate,tva_label,tva_id '); - for ($i=0; $i<$Max; $i++) - { - $array[$i]=Database::fetch_array($Res, $i); - $p=$this->get_detail($array[$i], $type, $trunc, $a_TVA, - $a_ParmCode); - if ($array[$i]['dep_priv']!=0.0) - { - $array[$i]['comment'].="(priv. ".$array[$i]['dep_priv'].")"; - } - } - } - else - { - $array=Database::fetch_all($Res); - } - - return $array; - } - -// end function get_rowSimple - /** * @brief guess what the next pj should be */ @@ -626,313 +400,7 @@ class Acc_Ledger extends jrn_def_sql - /** - * @brief get_detail gives the detail of row - * this array must contains at least the field - *
      - *
    • montant
    • - *
    • grpt_id - *
    - * the following field will be added - *
      - *
    • HTVA - *
    • TVAC - *
    • TVA array with - *
        - *
      • field 0 idx - *
      • array containing tva_id,tva_label and tva_amount - *
      - *
    - * - * @paramp_array the structure is set in get_rowSimple, this array is - * modified, - @verbatim - jrn.jr_id as jr_id , - jrn.jr_id as num , - jrn.jr_def_id as jr_def_id, - jrn.jr_montant as montant, - substr(jrn.jr_comment,1,35) as comment, - to_char(jrn.jr_date,'DD-MM-YYYY') as date, - to_char(jrn.jr_date_paid,'DD-MM-YYYY') as date_paid, - jr_pj_number, - jr_internal, - jrn.jr_grpt_id as grpt_id, - jrn.jr_pj_name as pj, - jrn_def_type, - jrn.jr_tech_per - @endverbatim - * - * @param $trunc if the data must be truncated, usefull for pdf export - * @paramp_jrn_type is the type of the ledger (ACH or VEN) - * @param $a_TVA TVA Array (default null) - * @param $a_ParmCode Array (default null) - * \return p_array - */ - function get_detail(&$p_array, $p_jrn_type, $trunc=0, $a_TVA=null, - $a_ParmCode=null) - { - bcscale(2); - - if ($a_TVA==null) - { - //Load TVA array - $a_TVA=$this->db->get_array('select tva_id,tva_label,tva_poste - from tva_rate where tva_rate != 0 order by tva_rate,tva_label,tva_id'); - } - if ($a_ParmCode==null) - { - //Load Parm_code - $a_ParmCode=$this->db->get_array('select p_code,p_value from parm_code'); - } - // init - $p_array['client']=""; - $p_array['TVAC']=0; - $p_array['HTVA']=0; - $p_array['TVA']=array(); - $p_array['AMOUNT_TVA']=0.0; - $p_array['dep_priv']=0; - $p_array['dna']=0; - $p_array['tva_dna']=0; - $p_array['tva_np']=0; - $dep_priv=0.0; - - - // if using the QUANT_* tables then get there the needed info - // - if ( $this->use_quant_table($p_array['grpt_id'],$p_array['jrn_def_type']) == TRUE) - { - // Initialize amount for VAT - $nb_tva=count($a_TVA); - for ($i=0;$i<$nb_tva;$i++) { - $p_array['TVA'][$i]=array($i, - array( - $a_TVA[$i]['tva_id'], - $a_TVA[$i]['tva_label'], - 0) - ); - } - switch ($p_array['jrn_def_type']) - { - case "ACH": - $sql="select - sum(coalesce(qp_price,0)) as htva, - sum(coalesce(qp_vat)) as vat, - sum(coalesce(qp_nd_tva)) as nd_tva, - sum(coalesce(qp_nd_tva_recup)) as nd_tva_recup, - sum(coalesce(qp_dep_priv)) as dep_priv, - qp_vat_code as tva_code, - qp_supplier as fiche_id, - qp_vat_sided as tva_sided - from - quant_purchase - where - qp_internal=$1 - group by qp_supplier,qp_vat_code,qp_vat_sided "; - break; - case "VEN": - $sql="select - sum(coalesce(qs_price,0)) as htva, - sum(coalesce(qs_vat)) as vat, - sum(0) as nd_tva, - sum(0) as nd_tva_recup, - sum(0) as dep_priv, - qs_vat_code as tva_code, - qs_client as fiche_id, - qs_vat_sided as tva_sided - from - quant_sold - where - qs_internal=$1 - group by qs_client,qs_vat_code,qs_vat_sided "; - break; - - default: - break; - } - $a_detail=$this->db->get_array($sql,array($p_array['jr_internal'])); - $nb_detail=count($a_detail); - for ($x=0;$x<$nb_detail;$x++) { - $p_array['HTVA']=bcadd($p_array['HTVA'],$a_detail[$x]['htva']); - $p_array['tva_dna']=bcadd($p_array['tva_dna'],$a_detail[$x]['nd_tva_recup']); - $p_array['tva_dna']=bcadd($p_array['tva_dna'],$a_detail[$x]['nd_tva']); - $p_array['TVAC']=bcadd($p_array['TVAC'],$a_detail[$x]['htva']); - if ( $a_detail[$x]['tva_sided'] == 0) - $p_array['TVAC']=bcadd($p_array['TVAC'],$a_detail[$x]['vat']); - $p_array['TVAC']=bcadd($p_array['TVAC'],$a_detail[$x]['nd_tva']); - $p_array['TVAC']=bcadd($p_array['TVAC'],$a_detail[$x]['nd_tva_recup']); - $p_array['dep_priv']=bcadd($p_array['dep_priv'],$a_detail[$x]['dep_priv']); - $xdx=$a_detail[$x]['tva_code']; - // $p_array['TVA'][$xdx]=bcadd($p_array['TVA'][$xdx],$a_detail[$x]['vat']); - //--- Put VAT in the right place in the array $a_TVA - $nb_tva=count($a_TVA); - for ($j=0;$j<$nb_tva;$j++) { - if ( $xdx == $p_array['TVA'][$j][1][0]) { - $p_array['TVA'][$j][1][2]=bcadd($p_array['TVA'][$j][1][2],$a_detail[$x]['vat']); - - } - } - } - $fiche=new Fiche($this->db,$a_detail[0]['fiche_id']); - $p_array['client']=($trunc==0)?$fiche->getName():mb_substr($fiche->getName(),0, 20); - return $p_array; - } - // - // Retrieve data from jrnx - // Order is important for TVA autoreversed - $sql="select j_id,j_poste,j_montant, j_debit,j_qcode from jrnx where ". - " j_grpt=$1 order by 1 desc"; - $Res2=$this->db->exec_sql($sql, array($p_array['grpt_id'])); - $data_jrnx=Database::fetch_all($Res2); - $c=0; - - // Parse data from jrnx and fill diff. field - foreach ($data_jrnx as $code) - { - $idx_tva=0; - $poste=new Acc_Account_Ledger($this->db, $code['j_poste']); - - // if card retrieve name if the account is not a VAT account - if (strlen(trim($code['j_qcode']))!=0&&$poste->isTva()==0) - { - $fiche=new Fiche($this->db); - $fiche->get_by_qcode(trim($code['j_qcode']), false); - $fiche_def_id=$fiche->get_fiche_def_ref_id(); - // Customer or supplier - if ($fiche_def_id==FICHE_TYPE_CLIENT|| - $fiche_def_id==FICHE_TYPE_FOURNISSEUR||$fiche_def_id==FICHE_TYPE_ADM_TAX) - { - $p_array['TVAC']=$code['j_montant']; - - $p_array['client']=($trunc==0)?$fiche->getName():mb_substr($fiche->getName(), - 0, 20); - $p_array['reversed']=false; - if ($fiche_def_id==FICHE_TYPE_CLIENT&&$code['j_debit']=='f') - { - $p_array['reversed']=true; - $p_array['TVAC']*=-1; - } - if ($fiche_def_id==FICHE_TYPE_ADM_TAX&&$code['j_debit']=='f') - { - $p_array['reversed']=true; - $p_array['TVAC']*=-1; - } - if ($fiche_def_id==FICHE_TYPE_FOURNISSEUR&&$code['j_debit']=='t') - { - $p_array['reversed']=true; - $p_array['TVAC']*=-1; - } - } - else - { - // if we use the ledger ven / ach for others card than supplier and customer - if ($fiche_def_id!=FICHE_TYPE_VENTE&& - $fiche_def_id!=FICHE_TYPE_ACH_MAR&& - $fiche_def_id!=FICHE_TYPE_ACH_SER&& - $fiche_def_id!=FICHE_TYPE_ACH_MAT - ) - { - $p_array['TVAC']=$code['j_montant']; - - $p_array['client']=($trunc==0)?$fiche->getName():mb_substr($fiche->getName(), - 0, 20); - $p_array['reversed']=false; - if ($p_jrn_type=='ACH'&&$code['j_debit']=='t') - { - $p_array['reversed']=true; - $p_array['TVAC']*=-1; - } - if ($p_jrn_type=='VEN'&&$code['j_debit']=='f') - { - $p_array['reversed']=true; - $p_array['TVAC']*=-1; - } - } - } - } - // if TVA, load amount, tva id and rate in array - foreach ($a_TVA as $line_tva) - { - list($tva_deb, $tva_cred)=explode(',', $line_tva['tva_poste']); - if ($code['j_poste']==$tva_deb|| - $code['j_poste']==$tva_cred) - { - - // For the reversed operation - if ($p_jrn_type=='ACH'&&$code['j_debit']=='f') - { - $code['j_montant']=-1*$code['j_montant']; - } - if ($p_jrn_type=='VEN'&&$code['j_debit']=='t') - { - $code['j_montant']=-1*$code['j_montant']; - } - - $p_array['AMOUNT_TVA']+=$code['j_montant']; - - $p_array['TVA'][$c]=array($idx_tva, array($line_tva['tva_id'], - $line_tva['tva_label'], $code['j_montant'])); - $c++; - - $idx_tva++; - } - } - - // isDNA - // If operation is reversed then amount are negatif - /* if ND */ - if ($p_array['jrn_def_type']=='ACH') - { - $purchase=new Gestion_Purchase($this->db); - $purchase->search_by_jid($code['j_id']); - $purchase->load(); - $dep_priv+=$purchase->qp_dep_priv; - $p_array['dep_priv']=$dep_priv; - $p_array['dna']=bcadd($p_array['dna'], $purchase->qp_nd_amount); - $p_array['tva_dna']=bcadd($p_array['tva_dna'], - bcadd($purchase->qp_nd_tva, $purchase->qp_nd_tva_recup)); - $p_array['tva_np']=bcadd($purchase->qp_vat_sided, - $p_array['tva_np']); - } - if ($p_array['jrn_def_type']=='VEN') - { - $sold=new gestion_sold($this->db); - $sold->search_by_jid($code['j_id']); - $sold->load(); - $p_array['tva_np']=bcadd($sold->qs_vat_sided, $p_array['tva_np']); - } - } - $p_array['TVAC']=sprintf('% 10.2f', $p_array['TVAC']); - $p_array['HTVA']=sprintf('% 10.2f', - $p_array['TVAC']-$p_array['AMOUNT_TVA']-$p_array['tva_dna']); - $r=""; - $a_tva_amount=array(); - // inline TVA (used for the PDF) - foreach ($p_array['TVA'] as $linetva) - { - foreach ($a_TVA as $tva) - { - if ($tva['tva_id']==$linetva[1][0]) - { - $a=$tva['tva_id']; - $a_tva_amount[$a]=$linetva[1][2]; - } - } - } - foreach ($a_TVA as $line_tva) - { - $a=$line_tva['tva_id']; - if (isset($a_tva_amount[$a])) - { - $tmp=sprintf("% 10.2f", $a_tva_amount[$a]); - $r.="$tmp"; - } - else - $r.=sprintf("% 10.2f", 0); - } - $p_array['TVA_INLINE']=$r; - - return $p_array; - } + // retrieve data from jrnx /** diff --git a/include/class/acc_ledger_history.class.php b/include/class/acc_ledger_history.class.php new file mode 100644 index 000000000..61f0c1ba4 --- /dev/null +++ b/include/class/acc_ledger_history.class.php @@ -0,0 +1,283 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + + +/*** + * @file + * @brief Display history of operation + * + */ +require_once NOALYSS_INCLUDE."/class/acc_ledger_history_generic.class.php"; +require_once NOALYSS_INCLUDE."/class/acc_ledger_history_sale.class.php"; +/** + * @brief Display history of operation + */ +abstract class Acc_Ledger_History +{ + + protected $m_from; //!< Starting Periode : periode.p_id + protected $m_to; //!< Ending Periode : periode.p_id + protected $ma_ledger; //!< Array of ledger id : jrn_def.jrn_def_id + protected $m_mode; //!< mode of export L : one line, E accounting writing , D : Detail + public $db; //!< database connx + + function __construct(Database $cn, $pa_ledger, $p_from, $p_to, $p_mode) + { + $this->db=$cn; + $this->ma_ledger=$pa_ledger; + $this->m_from=$p_from; + $this->m_to=$p_to; + $this->m_mode=$p_mode; + } + /** + * setter / getter + * @returns m_from (periode id) + */ + public function get_from() + { + return $this->m_from; + } + /** + * setter / getter + * @returns m_to (periode id) + */ + public function get_to() + { + return $this->m_to; + } + /** + * setter / getter + * @returns ma_ledger (array) + */ + public function get_ledger() + { + return $this->ma_ledger; + } + /** + * setter / getter + * @returns m_mode (A,L,E,D) + */ + public function get_mode() + { + return $this->m_mode; + } + /** + * setter m_from (periode id) + */ + public function set_from($m_from) + { + $this->m_from=$m_from; + return $this; + } + /** + * setter m_to (periode id) + */ + public function set_to($m_to) + { + $this->m_to=$m_to; + return $this; + } + /** + * setter ma_ledger (array of jrn_def_id) + */ + public function set_a_ledger($ma_ledger) + { + if (is_array($ma_ledger)==FALSE) + throw new Exception(_("invalid parameter"), EXC_PARAM_VALUE); + $this->ma_ledger=$ma_ledger; + return $this; + } + /** + * Setter + * @param $m_mode D,A,L,E + * @return $this + * @throws Exception + */ + public function set_m_mode($m_mode) + { + if ($m_mode!='E'&&$m_mode!='D'&&$m_mode!='L'&&$m_mode!='A') + throw new Exception(_("invalid parameter"), EXC_PARAM_VALUE); + $this->m_mode=$m_mode; + return $this; + } + + /** + * Build the right object + * @return \Acc_Ledger_History_Generic|\Acc_Ledger_History_Sale|\Acc_Ledger_History_Financial|\Acc_Ledger_History_Purchase + */ + static function factory(Database $cn, $pa_ledger, $p_from, $p_to, $p_mode) + { + // For Accounting writing , we use Acc_Ledger_History + if ($p_mode=="E") + { + $ret=new Acc_Ledger_History_Generic($cn, $pa_ledger, $p_from, $p_to, + $p_mode); + return $ret; + } + $nb_ledger=count($pa_ledger); + $ledger=new Acc_Ledger($cn, $pa_ledger[0]); + $type=$ledger->get_type(); + + // If first one is ODS so Acc_Ledger_History + if ($type=="ODS") + { + $ret=new Acc_Ledger_History_Generic($cn, $pa_ledger, $p_from, $p_to, + $p_mode); + return $ret; + } + // If all of the same type then use the corresponding class + + for ($i=0; $i<$nb_ledger; $i++) + { + $ledger=new Acc_Ledger($cn, $pa_ledger[$i]); + $type_next=$ledger->get_type(); + + // If type different then we go back to the generic + if ($type_next!=$type) + { + $ret=new Acc_Ledger_History_Generic($cn, $pa_ledger, $p_from, + $p_to, $p_mode); + return $ret; + } + } + switch ($type) + { + case "ACH": + $ret=new Acc_Ledger_History_Purchase($cn, $pa_ledger, $p_from, + $p_to, $p_mode); + return $ret; + break; + case "FIN": + $ret=new Acc_Ledger_History_Financial($cn, $pa_ledger, $p_from, + $p_to, $p_mode); + return $ret; + break; + case "VEN": + $ret=new Acc_Ledger_History_Sale($cn, $pa_ledger, $p_from, + $p_to, $p_mode); + return $ret; + break; + + default: + break; + } + } + + /** + * Retrieve the third : supplier for purchase, customer for sale, bank for fin, + * @param $p_jrn_type type of the ledger FIN, VEN ACH or ODS + * @param $jr_id jrn.jr_id + * @todo duplicate function , also in Acc_Ledger::get_tiers, remove one + */ + function get_tiers($p_jrn_type, $jr_id) + { + if ($p_jrn_type=='ODS') + return ' '; + $tiers=$this->get_tiers_id($p_jrn_type, $jr_id); + if ($tiers==0) + return ""; + + $name=$this->db->get_value('select ad_value from fiche_detail where ad_id=1 and f_id=$1', + array($tiers)); + $first_name=$this->db->get_value('select ad_value from fiche_detail where ad_id=32 and f_id=$1', + array($tiers)); + return $name.' '.$first_name; + } + + /** + * @brief Return the f_id of the tiers , called by get_tiers + * @param $p_jrn_type type of the ledger FIN, VEN ACH or ODS + * @param $jr_id jrn.jr_id + */ + function get_tiers_id($p_jrn_type, $jr_id) + { + $tiers=0; + switch ($p_jrn_type) + { + case 'VEN': + $tiers=$this->db->get_value('select max(qs_client) from quant_sold join jrnx using (j_id) join jrn on (jr_grpt_id=j_grpt) where jrn.jr_id=$1', + array($jr_id)); + break; + case 'ACH': + $tiers=$this->db->get_value('select max(qp_supplier) from quant_purchase join jrnx using (j_id) join jrn on (jr_grpt_id=j_grpt) where jrn.jr_id=$1', + array($jr_id)); + + break; + case 'FIN': + $tiers=$this->db->get_value('select qf_other from quant_fin where jr_id=$1', + array($jr_id)); + break; + } + if ($this->db->count()==0) + return 0; + return $tiers; + } + + /** + * Prepare the query for fetching the linked operation + * @staticvar int $prepare + */ + protected function prepare_reconcile_date() + { + static $prepare=0; + if ($prepare==0) + { + $this->db->prepare('reconcile_date', + 'select * + from + jrn + where + jr_id in + (select + jra_concerned + from + jrn_rapt + where jr_id = $1 + union all + select + jr_id + from jrn_rapt + where jra_concerned=$1)'); + } + $prepare=1; + } + /** + * display accounting of operations m_mode=A + */ + abstract function export_accounting_html(); + /** + * display detail of operations m_mode=D + */ + abstract function export_detail_html(); + /** + * display extended details of operation m_mode=E + */ + abstract function export_extended_html(); + /** + * display operation on one line m_mode=L + */ + abstract function export_oneline_html(); + /** + * call the right function , depending of m_mode + */ + abstract function export_html(); + + abstract function get_row($p_limit, $p_offset); +} diff --git a/include/class/acc_ledger_history_financial.class.php b/include/class/acc_ledger_history_financial.class.php new file mode 100644 index 000000000..07e0ec1b8 --- /dev/null +++ b/include/class/acc_ledger_history_financial.class.php @@ -0,0 +1,28 @@ + + + +/** + * @file + * @brief + * @param type $name Descriptionara + */ +?> diff --git a/include/class/acc_ledger_history_generic.class.php b/include/class/acc_ledger_history_generic.class.php new file mode 100644 index 000000000..714dc9516 --- /dev/null +++ b/include/class/acc_ledger_history_generic.class.php @@ -0,0 +1,737 @@ + + +/** + * @file + * @brief class for Ledger's history, list of operation for MISC, FIN, ACH and VEN + * + */ + +/** + * @brief manage the list of operation when we need several ledger with a different + * type or from Misceleaneous ledger + * @include acc_ledger_historyTest.php + */ +class Acc_Ledger_History_Generic extends Acc_Ledger_History +{ + + private $data; //!< array of rows + /** + * Constructor + * @param Database $cn + * @param type $pa_ledger + * @param type $p_from + * @param type $p_to + * @param type $p_mode + * @example acc_ledger_historyTest.php + */ + function __construct(Database $cn, $pa_ledger, $p_from, $p_to, $p_mode) + { + parent::__construct($cn, $pa_ledger, $p_from, $p_to, $p_mode); + $this->data=[]; + } + + /** + * @brief get_detail gives the detail of row + * this array must contains at least the field + *
      + *
    • montant
    • + *
    • grpt_id + *
    + * the following field will be added + *
      + *
    • HTVA + *
    • TVAC + *
    • TVA array with + *
        + *
      • field 0 idx + *
      • array containing tva_id,tva_label and tva_amount + *
      + *
    + * + * @paramp_array the structure is set in get_rowSimple, this array is + * modified, + @verbatim + jrn.jr_id as jr_id , + jrn.jr_id as num , + jrn.jr_def_id as jr_def_id, + jrn.jr_montant as montant, + substr(jrn.jr_comment,1,35) as comment, + to_char(jrn.jr_date,'DD-MM-YYYY') as date, + to_char(jrn.jr_date_paid,'DD-MM-YYYY') as date_paid, + jr_pj_number, + jr_internal, + jrn.jr_grpt_id as grpt_id, + jrn.jr_pj_name as pj, + jrn_def_type, + jrn.jr_tech_per + @endverbatim + * + * @param $trunc if the data must be truncated, usefull for pdf export + * @paramp_jrn_type is the type of the ledger (ACH or VEN) + * @param $a_TVA TVA Array (default null) + * @param $a_ParmCode Array (default null) + * + * @todo useless since only 2 modes are supported : oneline and extended (accounting writing) but + * can be used for ledger before 2007 + * \return p_array + */ + function get_detail(&$p_array, $p_jrn_type, $trunc=0, $a_TVA=null, + $a_ParmCode=null) + { + bcscale(2); + + if ($a_TVA==null) + { + //Load TVA array + $a_TVA=$this->db->get_array('select tva_id,tva_label,tva_poste + from tva_rate where tva_rate != 0 order by tva_rate,tva_label,tva_id'); + } + if ($a_ParmCode==null) + { + //Load Parm_code + $a_ParmCode=$this->db->get_array('select p_code,p_value from parm_code'); + } + // init + $p_array['client']=""; + $p_array['TVAC']=0; + $p_array['HTVA']=0; + $p_array['TVA']=array(); + $p_array['AMOUNT_TVA']=0.0; + $p_array['dep_priv']=0; + $p_array['dna']=0; + $p_array['tva_dna']=0; + $p_array['tva_np']=0; + $dep_priv=0.0; + + + // if using the QUANT_* tables then get there the needed info + // + if ($this->use_quant_table($p_array['grpt_id'], $p_array['jrn_def_type']) + ==TRUE) + { + // Initialize amount for VAT + $nb_tva=count($a_TVA); + for ($i=0; $i<$nb_tva; $i++) + { + $p_array['TVA'][$i]=array($i, + array( + $a_TVA[$i]['tva_id'], + $a_TVA[$i]['tva_label'], + 0) + ); + } + switch ($p_array['jrn_def_type']) + { + case "ACH": + $sql="select + sum(coalesce(qp_price,0)) as htva, + sum(coalesce(qp_vat)) as vat, + sum(coalesce(qp_nd_tva)) as nd_tva, + sum(coalesce(qp_nd_tva_recup)) as nd_tva_recup, + sum(coalesce(qp_dep_priv)) as dep_priv, + qp_vat_code as tva_code, + qp_supplier as fiche_id, + qp_vat_sided as tva_sided + from + quant_purchase + where + qp_internal=$1 + group by qp_supplier,qp_vat_code,qp_vat_sided "; + break; + case "VEN": + $sql="select + sum(coalesce(qs_price,0)) as htva, + sum(coalesce(qs_vat)) as vat, + sum(0) as nd_tva, + sum(0) as nd_tva_recup, + sum(0) as dep_priv, + qs_vat_code as tva_code, + qs_client as fiche_id, + qs_vat_sided as tva_sided + from + quant_sold + where + qs_internal=$1 + group by qs_client,qs_vat_code,qs_vat_sided "; + break; + + default: + break; + } + $a_detail=$this->db->get_array($sql, array($p_array['jr_internal'])); + $nb_detail=count($a_detail); + for ($x=0; $x<$nb_detail; $x++) + { + $p_array['HTVA']=bcadd($p_array['HTVA'], $a_detail[$x]['htva']); + $p_array['tva_dna']=bcadd($p_array['tva_dna'], + $a_detail[$x]['nd_tva_recup']); + $p_array['tva_dna']=bcadd($p_array['tva_dna'], + $a_detail[$x]['nd_tva']); + $p_array['TVAC']=bcadd($p_array['TVAC'], $a_detail[$x]['htva']); + if ($a_detail[$x]['tva_sided']==0) + $p_array['TVAC']=bcadd($p_array['TVAC'], + $a_detail[$x]['vat']); + $p_array['TVAC']=bcadd($p_array['TVAC'], $a_detail[$x]['nd_tva']); + $p_array['TVAC']=bcadd($p_array['TVAC'], + $a_detail[$x]['nd_tva_recup']); + $p_array['dep_priv']=bcadd($p_array['dep_priv'], + $a_detail[$x]['dep_priv']); + $xdx=$a_detail[$x]['tva_code']; + // $p_array['TVA'][$xdx]=bcadd($p_array['TVA'][$xdx],$a_detail[$x]['vat']); + //--- Put VAT in the right place in the array $a_TVA + $nb_tva=count($a_TVA); + for ($j=0; $j<$nb_tva; $j++) + { + if ($xdx==$p_array['TVA'][$j][1][0]) + { + $p_array['TVA'][$j][1][2]=bcadd($p_array['TVA'][$j][1][2], + $a_detail[$x]['vat']); + } + } + } + $fiche=new Fiche($this->db, $a_detail[0]['fiche_id']); + $p_array['client']=($trunc==0)?$fiche->getName():mb_substr($fiche->getName(), + 0, 20); + return $p_array; + } + // + // Retrieve data from jrnx + // Order is important for TVA autoreversed + $sql="select j_id,j_poste,j_montant, j_debit,j_qcode from jrnx where ". + " j_grpt=$1 order by 1 desc"; + $Res2=$this->db->exec_sql($sql, array($p_array['grpt_id'])); + $data_jrnx=Database::fetch_all($Res2); + $c=0; + + // Parse data from jrnx and fill diff. field + foreach ($data_jrnx as $code) + { + $idx_tva=0; + $poste=new Acc_Account_Ledger($this->db, $code['j_poste']); + + // if card retrieve name if the account is not a VAT account + if (strlen(trim($code['j_qcode']))!=0&&$poste->isTva()==0) + { + $fiche=new Fiche($this->db); + $fiche->get_by_qcode(trim($code['j_qcode']), false); + $fiche_def_id=$fiche->get_fiche_def_ref_id(); + // Customer or supplier + if ($fiche_def_id==FICHE_TYPE_CLIENT|| + $fiche_def_id==FICHE_TYPE_FOURNISSEUR||$fiche_def_id==FICHE_TYPE_ADM_TAX) + { + $p_array['TVAC']=$code['j_montant']; + + $p_array['client']=($trunc==0)?$fiche->getName():mb_substr($fiche->getName(), + 0, 20); + $p_array['reversed']=false; + if ($fiche_def_id==FICHE_TYPE_CLIENT&&$code['j_debit']=='f') + { + $p_array['reversed']=true; + $p_array['TVAC']*=-1; + } + if ($fiche_def_id==FICHE_TYPE_ADM_TAX&&$code['j_debit']=='f') + { + $p_array['reversed']=true; + $p_array['TVAC']*=-1; + } + if ($fiche_def_id==FICHE_TYPE_FOURNISSEUR&&$code['j_debit']=='t') + { + $p_array['reversed']=true; + $p_array['TVAC']*=-1; + } + } + else + { + // if we use the ledger ven / ach for others card than supplier and customer + if ($fiche_def_id!=FICHE_TYPE_VENTE&& + $fiche_def_id!=FICHE_TYPE_ACH_MAR&& + $fiche_def_id!=FICHE_TYPE_ACH_SER&& + $fiche_def_id!=FICHE_TYPE_ACH_MAT + ) + { + $p_array['TVAC']=$code['j_montant']; + + $p_array['client']=($trunc==0)?$fiche->getName():mb_substr($fiche->getName(), + 0, 20); + $p_array['reversed']=false; + if ($p_jrn_type=='ACH'&&$code['j_debit']=='t') + { + $p_array['reversed']=true; + $p_array['TVAC']*=-1; + } + if ($p_jrn_type=='VEN'&&$code['j_debit']=='f') + { + $p_array['reversed']=true; + $p_array['TVAC']*=-1; + } + } + } + } + // if TVA, load amount, tva id and rate in array + foreach ($a_TVA as $line_tva) + { + list($tva_deb, $tva_cred)=explode(',', $line_tva['tva_poste']); + if ($code['j_poste']==$tva_deb|| + $code['j_poste']==$tva_cred) + { + + // For the reversed operation + if ($p_jrn_type=='ACH'&&$code['j_debit']=='f') + { + $code['j_montant']=-1*$code['j_montant']; + } + if ($p_jrn_type=='VEN'&&$code['j_debit']=='t') + { + $code['j_montant']=-1*$code['j_montant']; + } + + $p_array['AMOUNT_TVA']+=$code['j_montant']; + + $p_array['TVA'][$c]=array($idx_tva, array($line_tva['tva_id'], + $line_tva['tva_label'], $code['j_montant'])); + $c++; + + $idx_tva++; + } + } + + // isDNA + // If operation is reversed then amount are negatif + /* if ND */ + if ($p_array['jrn_def_type']=='ACH') + { + $purchase=new Gestion_Purchase($this->db); + $purchase->search_by_jid($code['j_id']); + $purchase->load(); + $dep_priv+=$purchase->qp_dep_priv; + $p_array['dep_priv']=$dep_priv; + $p_array['dna']=bcadd($p_array['dna'], $purchase->qp_nd_amount); + $p_array['tva_dna']=bcadd($p_array['tva_dna'], + bcadd($purchase->qp_nd_tva, $purchase->qp_nd_tva_recup)); + $p_array['tva_np']=bcadd($purchase->qp_vat_sided, + $p_array['tva_np']); + } + if ($p_array['jrn_def_type']=='VEN') + { + $sold=new gestion_sold($this->db); + $sold->search_by_jid($code['j_id']); + $sold->load(); + $p_array['tva_np']=bcadd($sold->qs_vat_sided, $p_array['tva_np']); + } + } + $p_array['TVAC']=sprintf('% 10.2f', $p_array['TVAC']); + $p_array['HTVA']=sprintf('% 10.2f', + $p_array['TVAC']-$p_array['AMOUNT_TVA']-$p_array['tva_dna']); + $r=""; + $a_tva_amount=array(); + // inline TVA (used for the PDF) + foreach ($p_array['TVA'] as $linetva) + { + foreach ($a_TVA as $tva) + { + if ($tva['tva_id']==$linetva[1][0]) + { + $a=$tva['tva_id']; + $a_tva_amount[$a]=$linetva[1][2]; + } + } + } + foreach ($a_TVA as $line_tva) + { + $a=$line_tva['tva_id']; + if (isset($a_tva_amount[$a])) + { + $tmp=sprintf("% 10.2f", $a_tva_amount[$a]); + $r.="$tmp"; + } + else + $r.=sprintf("% 10.2f", 0); + } + $p_array['TVA_INLINE']=$r; + + return $p_array; + } + + /** + * @brief depending on the mode will call the right function + * - export_oneline_html for one line (mode=L) + * - export_accounting_html for accounting (mode=A,D,E) + */ + function export_html() + { + switch ($this->m_mode) + { + case "E": + $this->export_accounting_html(); + break; + case "D": + $this->export_accounting_html(); + break; + case "L": + $this->export_oneline_html(); + break; + case "A": + $this->export_accounting_html(); + break; + default: + break; + } + } + + /** + * @brief Get simplified row from ledger + * + * @param p_from periode + * @param p_to periode + * @param p_limit starting line + * @param p_offset number of lines + * @param trunc if data must be truncated (pdf export) + * @todo Prévoir aussi les journaux sans tables quant < 2007 + * @return numbe of rows found + */ + function get_rowSimple($trunc=0, $p_limit=-1, $p_offset=-1) + { + global $g_user; + $jrn=" jrn_def_id in (".join($this->ma_ledger, ",").")" ; + + $periode=sql_filter_per($this->db, $this->m_from, $this->m_to, 'p_id', + 'jr_tech_per'); + + $cond_limite=($p_limit!=-1)?" limit ".$p_limit." offset ".$p_offset:""; + //--- + $sql=" + SELECT jrn.jr_id as jr_id , + jrn.jr_id as num , + jrn.jr_def_id as jr_def_id, + jrn.jr_montant as montant, + substr(jrn.jr_comment,1,35) as comment, + to_char(jrn.jr_date,'DD-MM-YYYY') as date, + to_char(jrn.jr_date_paid,'DD-MM-YYYY') as date_paid, + jr_pj_number, + jr_internal, + jrn.jr_grpt_id as grpt_id, + jrn.jr_pj_name as pj, + jrn_def_type, + jrn.jr_tech_per + FROM jrn join jrn_def on (jrn_def_id=jr_def_id) + WHERE $periode and $jrn order by jr_date,substring(jrn.jr_pj_number,'[0-9]+$')::numeric asc $cond_limite"; + $Res=$this->db->exec_sql($sql); + $Max=Database::num_row($Res); + if ($Max==0) + { + return 0; + } +// @todo Pas nécessaire puisqu'on ne traite que les journaux d'opération diverses, +// Il faudrait p-e prévoir un système pour les journaux avant 2007 qui n'utilisaient +// pas les tables quant +// +// $type=$this->get_type(); +// // for type ACH and Ven we take more info +// if ($type=='ACH'||$type=='VEN') +// { +// $a_ParmCode=$this->db->get_array('select p_code,p_value from parm_code'); +// $a_TVA=$this->db->get_array('select tva_id,tva_label,tva_poste +// from tva_rate where tva_rate != 0 order by tva_rate,tva_label,tva_id '); +// for ($i=0; $i<$Max; $i++) +// { +// $array[$i]=Database::fetch_array($Res, $i); +// $p=$this->get_detail($array[$i], $type, $trunc, $a_TVA, +// $a_ParmCode); +// if ($array[$i]['dep_priv']!=0.0) +// { +// $array[$i]['comment'].="(priv. ".$array[$i]['dep_priv'].")"; +// } +// } +// } +// else +// { + $array=Database::fetch_all($Res); +// } + + $this->data=$array; + return $Max; + } + + /** + * @brief set $this->data with the array of rows + * + * + * @param p_limit starting line + * @param p_offset number of lines + * @returns nb of rows found + * + */ + function get_row($p_limit=-1, $p_offset=-1) + { + global $g_user; + $periode=sql_filter_per($this->db, $this->m_from, $this->m_to, 'p_id', + 'jr_tech_per'); + + $cond_limite=($p_limit!=-1)?" limit ".$p_limit." offset ".$p_offset:""; + + $ledger_list=join($this->ma_ledger, ","); +// Grand livre == 0 + $Res=$this->db->exec_sql("select jr_id,j_id,j_id as int_j_id,to_char(j_date,'DD.MM.YYYY') as j_date, + jr_internal, + case j_debit when 't' then j_montant::text else ' ' end as deb_montant, + case j_debit when 'f' then j_montant::text else ' ' end as cred_montant, + j_debit as debit,j_poste as poste,j_qcode,jr_montant , ". + "case when j_text='' or j_text is null then pcm_lib else j_text end as description,j_grpt as grp, + jr_comment||' ('||jr_internal||')' as jr_comment, + jr_pj_number, + j_qcode, + jrn_def_type, + jr_rapt as oc, j_tech_per as periode + from jrnx left join jrn on + jr_grpt_id=j_grpt + left join tmp_pcmn on pcm_val=j_poste + join jrn_def on (jrn_def_id=jr_def_id) + where j_jrn_def in (".$ledger_list.") + and ".$periode." + order by j_date::date asc,substring(jr_pj_number,'[0-9]+$')::numeric asc,j_grpt,j_debit desc ". + $cond_limite); + + $array=array(); + $Max=Database::num_row($Res); + if ($Max==0) + return 0; + $case=""; + $tot_deb=0; + $tot_cred=0; + $row=Database::fetch_all($Res); + bcscale(2); + for ($i=0; $i<$Max; $i++) + { + + $line=$row[$i]; + $tot_deb=bcadd($tot_deb, $line['deb_montant']); + $tot_cred=bcadd($tot_cred, $line['cred_montant']); + $tot_op=$line['jr_montant']; + + /* Check first if there is a quickcode */ + if (strlen(trim($line['description']))==0&&strlen(trim($line['j_qcode'])) + !=0) + { + $fiche=new Fiche($this->db); + if ($fiche->get_by_qcode($line['j_qcode'], false)==0) + { + $line['description']=$fiche->strAttribut(ATTR_DEF_NAME); + } + } + if ($case!=$line['grp']) + { + $case=$line['grp']; + // for financial, we show if the amount is or not in negative + if ($line['jrn_def_type']=='FIN') + { + $amount=$this->db->get_value('select qf_amount from quant_fin where jr_id=$1', + array($line['jr_id'])); + /* if nothing is found */ + if ($this->db->count()==0) + $tot_op=$line['jr_montant']; + else if ($amount<0) + { + $tot_op=$amount; + } + } + $array[]=array( + 'jr_id'=>$line['jr_id'], + 'int_j_id'=>$line['int_j_id'], + 'j_id'=>$line['j_id'], + 'j_date'=>$line['j_date'], + 'internal'=>$line['jr_internal'], + 'deb_montant'=>'', + 'cred_montant'=>' ', + 'description'=>''.h($line['jr_comment']).' ['.$tot_op.'] ', + 'poste'=>$line['oc'], + 'j_qcode'=>$line['j_qcode'], + 'periode'=>$line['periode'], + 'jr_pj_number'=>$line ['jr_pj_number'], + "ledger_type"=>$line['jrn_def_type']); + + $array[]=array( + 'jr_id'=>'', + 'int_j_id'=>$line['int_j_id'], + 'j_id'=>'', + 'j_date'=>'', + 'internal'=>'', + 'deb_montant'=>$line['deb_montant'], + 'cred_montant'=>$line['cred_montant'], + 'description'=>$line['description'], + 'poste'=>$line['poste'], + 'j_qcode'=>$line['j_qcode'], + 'periode'=>$line['periode'], + 'jr_pj_number'=>'', + "ledger_type"=>$line['jrn_def_type'] + ); + } + else + { + $array[]=array( + 'jr_id'=>$line['jr_id'], + 'int_j_id'=>$line['int_j_id'], + 'j_id'=>'', + 'j_date'=>'', + 'internal'=>'', + 'deb_montant'=>$line['deb_montant'], + 'cred_montant'=>$line['cred_montant'], + 'description'=>$line['description'], + 'poste'=>$line['poste'], + 'j_qcode'=>$line['j_qcode'], + 'periode'=>$line['periode'], + 'jr_pj_number'=>'', + "ledger_type"=>$line['jrn_def_type']); + } + } + $this->data=array($array, $tot_deb, $tot_cred); + return $Max; + } + /** + * display in html the detail the list of operation + */ + public function export_detail_html() + { + $this->export_accounting_html(); + } + /** + * display in html with extended detail the list of operation + */ + public function export_extended_html() + { + $this->export_accounting_html(); + } + /** + * display in html the accounting of the list of operations + */ + public function export_accounting_html() + { + + $this->get_row(); + echo ''; +// detailled printing +//--- + foreach ($this->data[0] as $op) + { + $class=""; + if ($op['j_date']!='') + { + $class="odd"; + } + + echo ""; + + echo ""; + echo ""; + + + if ($op['internal']!='') + echo ""; + else + echo td(); + + echo "". + "". + "". + "". + ""; + }// end loop + echo "
    ".$op['j_date']."".$op['jr_pj_number']."".HtmlInput::detail_op($op['jr_id'], $op['internal'])."".$op['poste']."".$op['description']."".nbm($op['deb_montant'])."".nbm($op['cred_montant'])."
    "; + +// show the saldo +//@todo use
  • instead of
    + echo _("solde débiteur:").$this->data[1]."
    "; + echo _("solde créditeur:").$this->data[2]; + } + /** + * @brief list operation on one line per operation + */ + public function export_oneline_html() + { + $this->get_rowSimple(); + echo ''; + echo "". + th(_("Date")). + th(_("n° pièce")). + th(_("internal")). + th(_("Tiers")). + th(_("Commentaire")). + th(_("Total opération")). + ""; + // set a filter for the FIN + $i=0; $tot_amount=0; + bcscale(2); + foreach ($this->data as $line) + { + $i++; + $class=($i%2==0)?' class="even" ':' class="odd" '; + echo ""; + echo ""; + echo ""; + echo ""; + $tiers=$this->get_tiers($line['jrn_def_type'], $line['jr_id']); + echo td($tiers); + echo ""; + + + // echo ""; + // If the ledger is financial : + // the credit must be negative and written in red + // Get the jrn type + if ($line['jrn_def_type']=='FIN') + { + $positive=$this->db->get_value("select qf_amount from quant_fin where jr_id=$1", + array($line['jr_id'])); + if ($this->db->count()==0) + $positive=1; + else + $positive=($positive>0)?1:0; + + echo ""; + if ($positive==1) + { + $tot_amount=bcadd($tot_amount, $line['montant']); + } + else + { + $tot_amount=bcsub($tot_amount, $line['montant']); + } + } + else + { + echo ""; + $tot_amount=bcadd($tot_amount, $line['montant']); + } + + echo ""; + } + echo ''; + echo ''; + echo td().td().td().td(); + echo ''; + echo ''; + echo "
    ".$line['date']."".h($line['jr_pj_number'])."".HtmlInput::detail_op($line['jr_id'], + $line['jr_internal'])."".h($line['comment'])."".$line['pj'].""; + echo ( $positive==0 )?" - ".nbm($line['montant'])."":nbm($line['montant']); + echo "".nbm($line['montant'])."
    '._('Totaux').''.nbm($tot_amount).'
    "; + } + +} diff --git a/include/class/acc_ledger_history_purchase.class.php b/include/class/acc_ledger_history_purchase.class.php new file mode 100644 index 000000000..64b9b5556 --- /dev/null +++ b/include/class/acc_ledger_history_purchase.class.php @@ -0,0 +1,26 @@ + + +/** + * @file + * @brief + */ +?> diff --git a/include/class/acc_ledger_history_sale.class.php b/include/class/acc_ledger_history_sale.class.php new file mode 100644 index 000000000..217b1842e --- /dev/null +++ b/include/class/acc_ledger_history_sale.class.php @@ -0,0 +1,222 @@ + + +/** + * @file + * @brief Acc_Ledger_History : Manage the list (history) of operations for display + */ +require_once NOALYSS_INCLUDE."/class/acc_ledger_history.class.php"; + +/** + * @brief Acc_Ledger_History : Manage the list (history) of operations for display + */ +class Acc_Ledger_History_Sale extends Acc_Ledger_History +{ + + private $data; //!< Contains rows from SQL + + public function __construct(\Database $cn, $pa_ledger, $p_from, $p_to, + $p_mode) + { + parent::__construct($cn, $pa_ledger, $p_from, $p_to, $p_mode); + } + /** + * Display the operation of sales with detailled VAT + */ + public function export_detail_html() + { + $own=new Noalyss_Parameter_Folder($this->db); + + $this->get_row(); + $this->add_vat_info(); + $this->prepare_reconcile_date(); + include NOALYSS_TEMPLATE."/acc_ledger_history_sale_detail.php"; + } + /** + * @brief display the accounting + */ + public function export_accounting_html() + { + $ledger_history=new Acc_Ledger_History_Generic($this->db, + $this->ma_ledger, $this->m_from, $this->m_to, $this->m_mode); + $ledger_history->export_accounting_html(); + } + /** + * display the operation with detailled vat per item + */ + public function export_extended_html() + { + $this->get_row(); + $this->add_vat_info(); + $this->prepare_detail(); + include NOALYSS_TEMPLATE."/acc_ledger_history_sale_extended.php"; + } + /** + * Prepare the query for fetching detail of an operation + * @staticvar int $prepare + */ + private function prepare_detail() + { + static $prepare=0; + if ( $prepare == 0) + { + $this->db->prepare("detail_sale"," + with card_name as + (select f_id,ad_value as name + from fiche_detail where ad_id=1), + card_qcode as + (select f_id,ad_value as qcode + from fiche_detail where ad_id=23) + select qs_price,qs_quantite,qs_vat,qs_vat_code,qs_unit,qs_vat_sided,name,qcode,tva_label, + qs_price+qs_vat-qs_vat_sided as tvac + from + quant_sold + join jrnx using (j_id) + join card_name on (card_name.f_id=qs_fiche) + join card_qcode on (card_qcode.f_id=qs_fiche) + join tva_rate on ( qs_vat_code=tva_id) + where + qs_internal=$1 + + "); + } + $prepare=1; + } + /** + * Get the rows from jrnx and quant* tables + * @param int $p_limit max of rows to returns + * @param int $p_offset the number of rows to skip + */ + public function get_row($p_limit=-1, $p_offset="") + { + $periode=sql_filter_per($this->db, $this->m_from, $this->m_to, 'p_id', + 'jr_tech_per'); + + $cond_limite=($p_limit!=-1)?" limit ".$p_limit." offset ".$p_offset:""; + + $ledger_list=join(",", $this->ma_ledger); + $sql=" + with row_sale as + (select qs_internal, + qs_client,sum(qs_price) as novat, + sum(qs_vat) as vat , + sum(qs_vat_sided) as tva_sided + from + quant_sold group by qs_client,qs_internal), + client_detail as ( + select x.f_id as f_id, + (select ad_value from fiche_detail where ad_id=1 and f_id=x.f_id) as name, + (select ad_value from fiche_detail where ad_id=32 and f_id=x.f_id) as first_name, + (select ad_value from fiche_detail where ad_id=23 and f_id=x.f_id) as qcode + from + fiche as x) + select + name, + first_name, + qcode, + jr_id, + jr_pj_number, + jr_date, + jr_date_paid, + jr_internal, + qs_client, + jrn.jr_comment, + jr_pj_name, + vat, + tva_sided, + novat, + novat+vat-tva_sided as tvac + from + jrn + join row_sale on (qs_internal=jr_internal) + join client_detail on (qs_client=f_id) + where + jr_def_id in ({$ledger_list}) + and {$periode} + {$cond_limite}"; + $this->data=$this->db->get_array($sql); + + } + /** + * @brief preprare the query for fetching the detailed VAT of an operation + * @staticvar int $prepare + */ + private function add_vat_info() + { + static $prepare=0; + if ( $prepare==0) { + $this->db->prepare("vat_info"," + select + sum(qs_vat) vat_amount , + qs_vat_code + from + quant_sold + where + qs_internal = $1 + group by qs_vat_code,qs_internal order by qs_vat_code"); + + } + + $prepare=1; + $nb_row=count($this->data); + for ($i=0;$i<$nb_row;$i++) + { + $ret=$this->db->execute("vat_info",array($this->data[$i]["jr_internal"])); + $array=Database::fetch_all($ret); + $this->data[$i]["detail_vat"]=$array; + } + } + /** + * @brief display in HTML following the mode + */ + function export_html() + { + switch ($this->m_mode) + { + case "E": + $this->export_extended_html(); + break; + case "D": + $this->export_detail_html(); + break; + case "L": + $this->export_oneline_html(); + break; + case "A": + $this->export_accounting_html(); + break; + default: + break; + } + } + + /** + * display in HTML one operation by line + */ + public function export_oneline_html() + { + $this->get_row(); + $this->prepare_reconcile_date(); + require_once NOALYSS_TEMPLATE.'/acc_history_ledger_sale_oneline.php'; + + } + +} diff --git a/include/impress_jrn.inc.php b/include/impress_jrn.inc.php index c9589a3c3..f35949503 100644 --- a/include/impress_jrn.inc.php +++ b/include/impress_jrn.inc.php @@ -27,14 +27,21 @@ require_once NOALYSS_INCLUDE.'/lib/iselect.class.php'; require_once NOALYSS_INCLUDE.'/lib/icheckbox.class.php'; require_once NOALYSS_INCLUDE.'/class/exercice.class.php'; require_once NOALYSS_INCLUDE.'/class/dossier.class.php'; -load_all_script(); +require_once NOALYSS_INCLUDE.'/class/acc_ledger_history.class.php'; +require_once NOALYSS_INCLUDE.'/lib/database.class.php'; $gDossier = dossier::id(); global $g_user,$http; + +/** + * Get exercice + */ +$user_exercice=$g_user->get_exercice(); +$exercice =$http->get("exercice","string",$user_exercice); + + //----------------------------------------------------- // Show the ledger and date //----------------------------------------------------- -require_once NOALYSS_INCLUDE.'/lib/database.class.php'; - if ($g_user->Admin() == 0 && $g_user->is_local_admin() == 0 && $g_user->get_status_security_ledger()==1) { $sql = "select jrn_def_id,jrn_def_name @@ -44,34 +51,45 @@ if ($g_user->Admin() == 0 && $g_user->is_local_admin() == 0 && $g_user->get_sta uj_login=$1 and uj_priv in ('R','W') order by jrn_def_name + and ( jrn_enable=1 + or + exists (select 1 from jrn where jr_tech_per in (select p_id from parm_periode where p_exercice=$2)) "; - $ret = $cn->make_array($sql,0,array($g_user->login)); + $ret = $cn->make_array($sql,0,array($g_user->login,$exercice)); } else { $ret = $cn->make_array("select jrn_def_id,jrn_def_name from jrn_def join jrn_type on jrn_def_type=jrn_type_id + where + jrn_enable=1 or exists(select 1 from jrn where jr_tech_per in (select p_id from parm_periode where p_exercice=$1)) order by jrn_def_name - "); - // Count the forbidden journaux -// $NoPriv = $cn->count_sql("select jrn_def_id,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv, -// jrn_deb_max_line,jrn_cred_max_line -// from jrn_def join jrn_type on jrn_def_type=jrn_type_id -// join user_sec_jrn on uj_jrn_id=jrn_def_id -// where -// uj_login=$1 -// and uj_priv ='X' -// ",array($g_user->id)); + ",0,[$exercice]); } + /* * Show all the available ledgers */ $a = count($ret); +if (count($ret) < 1) NoAccess(); + $all = array('value' => 0, 'label' => _('Tous les journaux disponibles')); $ret[$a] = $all; -if (count($ret) < 1) - NoAccess(); -$exercice = (isset($_GET['exercice'])) ? $_GET['exercice'] : $g_user->get_exercice(); + +// Get the from_periode and to_periode +$from_periode=$http->get("from_periode","number",""); +$to_periode=$http->get("to_periode","number",""); + +// if from_periode empty, then set to first and last +// periode of the exercice (from preference) + +if ($from_periode=="" || $to_periode=="") +{ + $t_periode=new Periode($cn); + list($per_min,$per_max)=$t_periode->get_limit($exercice); + $from_periode=$per_min->p_id; + $to_periode=$per_max->p_id; +} //----------------------------------------------------- // Form @@ -108,10 +126,6 @@ print ''; print ''; // filter on the current year $filter_year = " where p_exercice='" . sql_string($exercice) . "'"; -// Get the from_periode and to_periode -$from_periode=$http->get("from_periode","number",""); -$to_periode=$http->get("to_periode","number",""); - $periode_start = $cn->make_array("select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end"); $w->selected = $from_periode ; @@ -124,16 +138,14 @@ $w->selected = $to_periode ; // By default , show last day of exercice if ($w->selected== '' ){ - $t_periode=new Periode($cn); - list($per_max,$per_min)=$t_periode->get_limit($exercice); - $w->selected=$per_min->p_id; + $w->selected=$per_max->p_id; } print td('Jusque ') . $w->input('to_periode', $periode_end); print ""; $a = array( - array('value' => 1, 'label' => _('Liste opérations')), - array('value' => 0, 'label' => _('Ecriture comptable')), - array('value' => 2, 'label' => _('Avec Détails opérations ')) + array('value' => 'L', 'label' => _('Liste opérations')), + array('value' => 'E', 'label' => _('Ecriture comptable')), + array('value' => 'D', 'label' => _('Avec Détails opérations ')) ); $w->selected = 1; print ''; @@ -157,267 +169,29 @@ echo '
    '; if (isset($_REQUEST['bt_html'])) { // Type of report : listing=1 , Accounting writing=0, detail =2 - $simple=$http->get("p_simple","number"); - + $simple=$http->get("p_simple","string"); $jrn_id=$http->get("jrn_id","number"); - require_once NOALYSS_INCLUDE.'/class/acc_ledger.class.php'; - $Jrn = new Acc_Ledger($cn, $jrn_id); - $Jrn->get_name(); - $ledger_type=$Jrn->get_type() ; - switch ($simple) - { - case "0": - // List of accounting writing - $Row = $Jrn->get_row($from_periode, $to_periode); - break; - case "1": - // simple list of operations, one row / operation - $Row = $Jrn->get_rowSimple($from_periode, $to_periode); - - case "2": - // Detail for each operation - $Row = $Jrn->get_rowSimple($from_periode, $to_periode); - break; - default: - die(__FILE__ . ":" . __LINE__ . " error unknown style [$simple ] "); - } - $rep = ""; - $hid = new IHidden(); - echo '
    '; - echo '

    ' . h($Jrn->name) . '

    '; - echo ""; - echo ''; - echo '"; + /* + * Compute an array with all the usable ledger + */ + $a_ledger=[]; + if ( $jrn_id == 0) { + $nb_ret=count($ret); + for ($i=0;$i<$nb_ret;$i++) { + if ($ret[$i]['value']!=0) + $a_ledger[$i]=$ret[$i]['value']; + } + } else { + $a_ledger=[$jrn_id]; + } + + $ledger_history=Acc_Ledger_History::factory($cn,$a_ledger,$from_periode,$to_periode,$simple); + + $ledger_history->export_html(); + - echo '"; - - echo '"; - - echo ''; - echo ""; - - echo "
    ' . dossier::hidden() . - $hid->input("type", "jrn") . $hid->input('p_action', 'impress') . "
    ' . dossier::hidden() . - HtmlInput::submit('bt_pdf', "Export PDF") . - HtmlInput::hidden('act', 'PDF:ledger') . - $hid->input("type", "jrn") . - $hid->input("jrn_id", $Jrn->id) . - $hid->input("from_periode", $from_periode) . - $hid->input("to_periode", $to_periode); - echo $hid->input("p_simple", $simple); - echo HtmlInput::get_to_hidden(array('ac', 'type')); - echo "
    ' . dossier::hidden() . - HtmlInput::submit('bt_csv', "Export CSV") . - HtmlInput::hidden('act', 'CSV:ledger') . - $hid->input("type", "jrn") . - $hid->input("jrn_id", $Jrn->id) . - $hid->input("from_periode", $from_periode) . - $hid->input("to_periode", $to_periode); - echo $hid->input("p_simple", $simple); - echo HtmlInput::get_to_hidden(array('ac', 'type')); - echo "
    '; - echo HtmlInput::print_window(); - echo '
    "; - if (count($Jrn->row) == 0 - && $Row == null) - exit; - - - - ///////////////////////////////////////////////////////////////////////////////////// - // Ecriture comptable - ///////////////////////////////////////////////////////////////////////////////////// - if ($simple== 0) - { - echo ''; - // detailled printing - //--- - foreach ($Jrn->row as $op) - { - $class = ""; - if ($op['j_date'] != '') - { - $class = "odd"; - } - - echo ""; - - echo ""; - echo ""; - - - if ($op['internal'] != '') - echo ""; - else - echo td(); - - echo "" . - "" . - "" . - "" . - ""; - }// end loop - echo "
    " . $op['j_date'] . "" . $op['jr_pj_number'] . "" . HtmlInput::detail_op($op['jr_id'], $op['internal']) . "" . $op['poste'] . "" . $op['description'] . "" . nbm($op['deb_montant']) . "" . nbm($op['cred_montant']) . "
    "; - // show the saldo - - $solde = $Jrn->get_solde($from_periode, $to_periode); - echo "solde débiteur:" . $solde[0] . "
    "; - echo "solde créditeur:" . $solde[1]; - } // if - ///////////////////////////////////////////////////////////////////////////////////// - // Liste opérations - ///////////////////////////////////////////////////////////////////////////////////// - elseif ($simple == 1) - { - if ( $Jrn->get_type() != 'ACH' && $Jrn->get_type() != 'VEN') - { - // Simple printing - //--- - echo ''; - echo "" . - "" . - "" . - "" . - th('Tiers') . - "" . - "" . - ""; - // set a filter for the FIN - $i = 0;$tot_amount=0; - bcscale(2); - foreach ($Row as $line) - { - $i++; - $class = ($i % 2 == 0) ? ' class="even" ' : ' class="odd" '; - echo ""; - echo ""; - echo ""; - echo ""; - $tiers = $Jrn->get_tiers($line['jrn_def_type'], $line['jr_id']); - echo td($tiers); - echo ""; - - - // echo ""; - // If the ledger is financial : - // the credit must be negative and written in red - // Get the jrn type - if ($line['jrn_def_type'] == 'FIN') - { - $positive = $cn->get_value("select qf_amount from quant_fin where jr_id=$1", array($line['jr_id'])); - if ($cn->count() == 0) - $positive = 1; - else - $positive = ($positive > 0) ? 1 : 0; - - echo ""; - if ( $positive == 1 ) { - $tot_amount=bcadd($tot_amount,$line['montant']); - } else { - $tot_amount=bcsub($tot_amount,$line['montant']); - } - } - else - { - echo ""; - $tot_amount=bcadd($tot_amount,$line['montant']); - } - - echo ""; - } - echo ''; - echo ''; - echo td().td().td().td(); - echo ''; - echo ''; - echo "
    Date n° de pièce internalCommentaireTotal opération
    " . $line['date'] . "" . h($line['jr_pj_number']) . "" . HtmlInput::detail_op($line['jr_id'], $line['jr_internal']) . "" . h($line['comment']) . "".$line['pj'].""; - echo ( $positive == 0 ) ? " - " . nbm($line['montant']) . "" : nbm($line['montant']); - echo "" . nbm($line['montant']) . "
    '._('Totaux').''.nbm($tot_amount).'
    "; - } else { - /* - * Ledger ACH or VEN - */ - $own=new Noalyss_Parameter_Folder($cn); - require_once NOALYSS_TEMPLATE.'/print_ledger_simple.php'; - - } - } - ///////////////////////////////////////////////////////////////////////////////////// - // Détaillé - ///////////////////////////////////////////////////////////////////////////////////// - elseif ($simple == 2) - { - foreach ($Row as $line) - { - echo '
    '; - $class = ' class="odd" style="font-stretch: expanded;font-size:1em;"'; - echo ''; - echo ""; - echo '"; - echo '"; - echo '"; - $tiers = $Jrn->get_tiers($line['jrn_def_type'], $line['jr_id']); - $ledger_name = $cn->get_value("select jrn_def_name from jrn_def where jrn_def_id=$1", array($line['jr_def_id'])); - echo ''; - echo ''; - echo '"; - echo '"; - echo ""; - echo '
    ' . $line['date'] . "' . h($line['jr_pj_number']) . "' . HtmlInput::detail_op($line['jr_id'], $line['jr_internal']) . "' . h($ledger_name) . ' ' . h($tiers) . ' ' . h($line['comment']) . "'; - if ($line['jrn_def_type'] == 'FIN') - { - $positive = $cn->get_value("select qf_amount from quant_fin where jr_id=$1", array($line['jr_id'])); - if ($cn->count() == 0) - $positive = 1; - else - $positive = ($positive > 0) ? 1 : 0; - - echo ( $positive == 0 ) ? " - " . nbm($line['montant']) . "" : nbm($line['montant']); - } - else - { - if ( isset ($line['TVAC'])) { - echo ( nbm($line['TVAC']) < 0 ) ? " - " . nbm($line['TVAC']) . "" : nbm($line['TVAC']); - } else - { - echo nbm($line['montant']) ; - } - } - echo "
    '; - ////////////////////////////////////////////////////////////////////////////////////////////////////// - // Add detail for each operation - ////////////////////////////////////////////////////////////////////////////////////////////////////// - $op = new Acc_Operation($cn); - $op->jr_id = $line['jr_id']; - $op->get(); - $obj = $op->get_quant(); - switch ($obj->signature) - { - case 'FIN': - require NOALYSS_TEMPLATE.'/operation_detail_fin.php'; - break; - case 'ACH': - require NOALYSS_TEMPLATE.'/operation_detail_ach.php'; - break; - case 'VEN': - require NOALYSS_TEMPLATE.'/operation_detail_ven.php'; - break; - case 'ODS': - require NOALYSS_TEMPLATE.'/operation_detail_misc.php'; - break; - default: - die("unknown type of ledger"); - break; - } - echo '
    '; - //echo '
    '; - } // end loop - } - - echo "
    "; - exit; } echo ''; -?> +?> \ No newline at end of file diff --git a/include/template/acc_history_ledger_sale_oneline.php b/include/template/acc_history_ledger_sale_oneline.php new file mode 100644 index 000000000..f3cfa48f8 --- /dev/null +++ b/include/template/acc_history_ledger_sale_oneline.php @@ -0,0 +1,134 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + + +/*** + * @file + * @brief + * @todo prévoir aussi pour les non assujetti : faire disparaître les montants TVA + */ + +?> + + + + + + + + + + + + +data); +$tot_amount_novat=0; +$tot_amount_vat=0; +$tot_amount_tvac=0; +for ($i=0;$i<$nb_data;$i++): + $odd=($i%2==0)?' class="even" ':' class="odd" '; + $tot_amount_novat=bcadd($tot_amount_novat,$this->data[$i]['novat']); + $tot_amount_vat=bcadd($tot_amount_vat,$this->data[$i]['vat']); + $tot_amount_vat=bcsub($tot_amount_vat,$this->data[$i]['tva_sided']); + $tot_amount_tvac=bcadd($tot_amount_tvac,$this->data[$i]['tvac']); +?> + > + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    + data[$i]['jr_date']?> + + data[$i]['jr_date_paid']?> + + data[$i]['jr_pj_number']?> + + data[$i]['jr_internal']?> + + data[$i]['qs_client'],h($this->data[$i]['name'].' '.$this->data[$i]['first_name']." [ {$this->data[$i]['qcode']} ]"))?> + + data[$i]['jr_comment'])?> + + data[$i]['novat'])?> + + data[$i]['vat'],$this->data[$i]['tva_sided']))?> + + data[$i]['tvac'])?> + + + db->execute('reconcile_date',array($this->data[$i]['jr_id'])); + $max=Database::num_row($ret_reconcile); + if ($max > 0) { + $sep=""; + for ($e=0;$e<$max;$e++) { + $row=Database::fetch_array($ret_reconcile, $e); + echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $row['jr_internal']); + $sep=' ,'; + } + } ?> +
    + +
    \ No newline at end of file diff --git a/include/template/acc_ledger_history_sale_detail.php b/include/template/acc_ledger_history_sale_detail.php new file mode 100644 index 000000000..cfa9bf2a1 --- /dev/null +++ b/include/template/acc_ledger_history_sale_detail.php @@ -0,0 +1,180 @@ + + +if (!defined('ALLOWED')) + die('Appel direct ne sont pas permis'); + +/** + * @file + * @brief from Acc_Ledger_History_Sale::export_html_oneline + * @todo prévoir aussi pour les non assujetti : faire disparaître les montants TVA + */ +?> + + + + + + + + + + + +MY_TVA_USE=='Y') + { + $a_Tva=$this->db->get_array("select tva_id,tva_label from tva_rate where tva_rate != 0.0000 order by tva_id"); + foreach($a_Tva as $line_tva) + { + $col_tva.=''; + } + } +echo $col_tva; +?> + + + +data as $line) { + $i++; + /* + * Get date of reconcile operation + */ + $ret_reconcile=$this->db->execute('reconcile_date',array($line['jr_id'])); + $class = ($i % 2 == 0) ? ' class="even" ' : ' class="odd" '; + echo ""; + + // Receipt number + echo ""; + + // Date + echo ""; + echo ""; + + // Internal with detail + echo ""; + + // find the tiers (normally in $Row ! + $tiers =HtmlInput::history_card($line['qs_client'],h($line['name'].' '.$line['first_name'])."[{$line['qcode']}]"); + + echo td($tiers); + + // Label + echo ""; + + + // HTVA amount + echo ""; + $tot['htva']=bcadd($tot['htva'], round(floatval($line['novat']),2)); + + //-------------------------------------------------------------------------- + // If VAT then display it + //-------------------------------------------------------------------------- + if ($own->MY_TVA_USE == 'Y' ) + { + $a_tva_amount=array(); + + foreach ($line['detail_vat'] as $lineTVA) + { + foreach ($a_Tva as $idx=>$line_tva) + { + + if ($line_tva['tva_id'] == $lineTVA['qs_vat_code']) + { + $a=$line_tva['tva_id']; + $a_tva_amount[$a]=$lineTVA["vat_amount"]; + } + } + } + foreach ($a_Tva as $line_tva) + { + $a=$line_tva['tva_id']; + if ( isset($a_tva_amount[$a]) && $a_tva_amount[$a] != 0) { + echo ''; + $tot['tva'][$a]=(isset($tot['tva'][$a]))?bcadd($tot['tva'][$a],round(floatval($a_tva_amount[$a]),2)):round(floatval($a_tva_amount[$a]),2); + } + else + printf(""); + } + } + + echo ''; + $tot['tvac']=bcadd($tot['tvac'], round(floatval($line['tvac']),2)); + /* + * If reconcile print them + */ + echo ''; + echo ""; +} +/** + * summary + */ +?> + + + + + + + + + MY_TVA_USE == 'Y' ): ?> + + + + + + + + + + + + +
    HTVATva '.$line_tva['tva_label'].'TVAC
    " . h($line['jr_pj_number']) . "" . smaller_date($line['jr_date']) . "" . smaller_date($line['jr_date_paid']) . "" . HtmlInput::detail_op($line['jr_id'], $line['jr_internal']) . "" . h($line['jr_comment']) . "" . nbm(round($line['novat'],2),2) . "'.nbm(round($a_tva_amount[$a],2)).''.nbm($line['tvac'],2).''; + $max=Database::num_row($ret_reconcile); + if ($max > 0) { + $sep=""; + for ($e=0;$e<$max;$e++) { + $row=Database::fetch_array($ret_reconcile, $e); + echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $row['jr_internal']); + $sep=' ,'; + } + } + echo '
    + + + +
    \ No newline at end of file diff --git a/include/template/acc_ledger_history_sale_extended.php b/include/template/acc_ledger_history_sale_extended.php new file mode 100644 index 000000000..fdaa47206 --- /dev/null +++ b/include/template/acc_ledger_history_sale_extended.php @@ -0,0 +1,171 @@ + + + +/** + * @file + * @brief detail of the list of operation with VAT and items + */ +?> + + + + + + + + + + + + +data); +$tot_amount_novat=0; +$tot_amount_vat=0; +$tot_amount_tvac=0; +for ($i=0;$i<$nb_data;$i++): + $odd=' class="odd" '; + $tot_amount_novat=bcadd($tot_amount_novat,$this->data[$i]['novat']); + $tot_amount_vat=bcadd($tot_amount_vat,$this->data[$i]['vat']); + $tot_amount_vat=bcsub($tot_amount_vat,$this->data[$i]['tva_sided']); + $tot_amount_tvac=bcadd($tot_amount_tvac,$this->data[$i]['tvac']); +?> + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    + data[$i]['jr_date']?> + + data[$i]['jr_date_paid']?> + + data[$i]['jr_pj_number']?> + + data[$i]['jr_internal']?> + + data[$i]['qs_client'],h($this->data[$i]['name'].' '.$this->data[$i]['first_name']))?> + + data[$i]['jr_comment'])?> + + data[$i]['novat'])?> + + data[$i]['vat'],$this->data[$i]['tva_sided']))?> + + data[$i]['tvac'])?> + + + db->execute('reconcile_date',array($this->data[$i]['jr_id'])); + $max=Database::num_row($ret_reconcile); + if ($max > 0) { + $sep=""; + for ($e=0;$e<$max;$e++) { + $row=Database::fetch_array($ret_reconcile, $e); + echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $row['jr_internal']); + $sep=' ,'; + } + } ?> +
    +db->execute("detail_sale",array($this->data[$i]['jr_internal'])); +$a_detail=Database::fetch_all($det); +?> + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + +
    \ No newline at end of file diff --git a/scenario/acc_ledger_historyTest.php b/scenario/acc_ledger_historyTest.php new file mode 100644 index 000000000..b0863baf2 --- /dev/null +++ b/scenario/acc_ledger_historyTest.php @@ -0,0 +1,68 @@ + + + + +/** + * @file + * @brief Test of ledger_history + */ +require_once NOALYSS_INCLUDE."/class/acc_ledger_history.class.php"; + +$ledger=[1,2,3,4]; +echo Dossier::hidden(); +global $cn, $g_user, $g_succeed, $g_failed; +$cn=Dossier::connect(); + +$ledger_history=Acc_Ledger_History::factory($cn, $ledger, 216, 217, "E"); +echo h1("Detailled Accounting"); +echo h2(_("export detail html all ledgers result = Detailled Accounting")); +$ledger_history->export_detail_html(); + +echo h2(_("Set mode to D etailled all_ledgers result = Detailled Accounting" )); +$ledger_history->set_m_mode("D"); +$ledger_history->export_html(); + +echo h2(_("Only VEN")); +$ledger_history=Acc_Ledger_History::factory($cn, [2], 216, 217, "L"); +$ledger_history->export_detail_html(); + +echo h1("One line"); +echo h2(_("Only VEN one line")); +$ledger_history->set_a_ledger([2]); +$ledger_history->set_m_mode("L"); +$ledger_history->export_html(); + +echo h2(_("Only VEN Detailled")); +$ledger_history->set_a_ledger([2]); +$ledger_history->set_m_mode("D"); +$ledger_history->export_html(); + +echo h2(_("Only VEN Extended")); +$ledger_history->set_a_ledger([2]); +$ledger_history->set_m_mode("E"); +$ledger_history->export_html(); + +echo h2("VEN + ACH"); +$ledger_history=Acc_Ledger_History::factory($cn, [3,2], 216, 217, "L"); + +$ledger_history->export_oneline_html(); + From 2e40252b7765b0095fba640f3951240870b6fc60 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 21 Jan 2018 13:56:31 +0100 Subject: [PATCH 026/265] Database : add function is_prepare() to check if pg_prepare has already run --- include/lib/database.class.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/lib/database.class.php b/include/lib/database.class.php index 393b6dc04..edddef612 100644 --- a/include/lib/database.class.php +++ b/include/lib/database.class.php @@ -1156,6 +1156,17 @@ class Database $this->lo_unlink($a_lob[$i]['oid']); } } + /** + * Check if a prepared statement already exists or not + * @param string $query_name name of the prepared query + * @return boolean false is not yet prepared + */ + function is_prepare($query_name) + { + $nb_prepared=$this->get_value("select count(*) from pg_prepared_statements where name=$1",[$query_name]); + if ( $nb_prepared==0)return FALSE; + return TRUE; + } } From 0708cd16caef2c2545afaee798b5c9db3a52ece1 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 21 Jan 2018 14:48:47 +0100 Subject: [PATCH 027/265] =?UTF-8?q?Task=20#0001530:=20R=C3=A9=C3=A9criture?= =?UTF-8?q?=20PRINTJRN=20Rename=20file=20template/acc=5Fhistory=5Fledger?= =?UTF-8?q?=5Fsale=5Foneline.php=20to=20template/acc=5Fledger=5Fhistory=5F?= =?UTF-8?q?sale=5Foneline.php=20Manage=20PURCHASE=20-=20oneline,detailled?= =?UTF-8?q?=20,=20extended=20and=20accounting=20Adapt=20test=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/class/acc_ledger_history.class.php | 8 +- .../acc_ledger_history_purchase.class.php | 207 +++++++++++++++++- .../class/acc_ledger_history_sale.class.php | 13 +- include/impress_jrn.inc.php | 10 +- .../acc_ledger_history_purchase_detail.php | 196 +++++++++++++++++ .../acc_ledger_history_purchase_extended.php | 173 +++++++++++++++ .../acc_ledger_history_purchase_oneline.php | 152 +++++++++++++ .../acc_ledger_history_sale_detail.php | 2 +- .../acc_ledger_history_sale_extended.php | 6 +- ...hp => acc_ledger_history_sale_oneline.php} | 2 +- scenario/acc_ledger_historyTest.php | 20 +- 11 files changed, 763 insertions(+), 26 deletions(-) create mode 100644 include/template/acc_ledger_history_purchase_detail.php create mode 100644 include/template/acc_ledger_history_purchase_extended.php create mode 100644 include/template/acc_ledger_history_purchase_oneline.php rename include/template/{acc_history_ledger_sale_oneline.php => acc_ledger_history_sale_oneline.php} (97%) diff --git a/include/class/acc_ledger_history.class.php b/include/class/acc_ledger_history.class.php index 61f0c1ba4..30b25da97 100644 --- a/include/class/acc_ledger_history.class.php +++ b/include/class/acc_ledger_history.class.php @@ -26,6 +26,7 @@ */ require_once NOALYSS_INCLUDE."/class/acc_ledger_history_generic.class.php"; require_once NOALYSS_INCLUDE."/class/acc_ledger_history_sale.class.php"; +require_once NOALYSS_INCLUDE."/class/acc_ledger_history_purchase.class.php"; /** * @brief Display history of operation */ @@ -125,7 +126,7 @@ abstract class Acc_Ledger_History static function factory(Database $cn, $pa_ledger, $p_from, $p_to, $p_mode) { // For Accounting writing , we use Acc_Ledger_History - if ($p_mode=="E") + if ($p_mode=="A") { $ret=new Acc_Ledger_History_Generic($cn, $pa_ledger, $p_from, $p_to, $p_mode); @@ -236,8 +237,8 @@ abstract class Acc_Ledger_History */ protected function prepare_reconcile_date() { - static $prepare=0; - if ($prepare==0) + $prepare=$this->db->is_prepare("reconcile_date"); + if ($prepare==FALSE) { $this->db->prepare('reconcile_date', 'select * @@ -256,7 +257,6 @@ abstract class Acc_Ledger_History from jrn_rapt where jra_concerned=$1)'); } - $prepare=1; } /** * display accounting of operations m_mode=A diff --git a/include/class/acc_ledger_history_purchase.class.php b/include/class/acc_ledger_history_purchase.class.php index 64b9b5556..715ffa052 100644 --- a/include/class/acc_ledger_history_purchase.class.php +++ b/include/class/acc_ledger_history_purchase.class.php @@ -21,6 +21,209 @@ /** * @file - * @brief + * @brief class Acc_Ledger_History_Purchase , list of operations */ -?> +require_once NOALYSS_INCLUDE."/class/acc_ledger_history.class.php"; + +/** + * @brief Display the operations for Purchase + */ +class Acc_Ledger_History_Purchase extends Acc_Ledger_History +{ + + private $data; //!< Contains rows from SQL + + public function __construct(\Database $cn, $pa_ledger, $p_from, $p_to, + $p_mode) + { + parent::__construct($cn, $pa_ledger, $p_from, $p_to, $p_mode); + } + + /** + * @brief display the accounting + */ + public function export_accounting_html() + { + $ledger_history=new Acc_Ledger_History_Generic($this->db, + $this->ma_ledger, $this->m_from, $this->m_to, $this->m_mode); + $ledger_history->export_accounting_html(); + } + + public function export_detail_html() + { + $own=new Noalyss_Parameter_Folder($this->db); + + $this->get_row(); + $this->add_vat_info(); + $this->prepare_reconcile_date(); + include NOALYSS_TEMPLATE."/acc_ledger_history_purchase_detail.php"; + } + + public function export_extended_html() + { + $this->get_row(); + $this->add_vat_info(); + $this->prepare_detail(); + $this->prepare_reconcile_date(); + include NOALYSS_TEMPLATE."/acc_ledger_history_purchase_extended.php"; + } + + /** + * @brief display in HTML following the mode + */ + function export_html() + { + switch ($this->m_mode) + { + case "E": + $this->export_extended_html(); + break; + case "D": + $this->export_detail_html(); + break; + case "L": + $this->export_oneline_html(); + break; + case "A": + $this->export_accounting_html(); + break; + default: + break; + } + } + + /** + * display in HTML one operation by line + */ + public function export_oneline_html() + { + $this->get_row(); + $this->prepare_reconcile_date(); + require_once NOALYSS_TEMPLATE.'/acc_ledger_history_purchase_oneline.php'; + } + + /** + * Get the rows from jrnx and quant* tables + * @param int $p_limit max of rows to returns + * @param int $p_offset the number of rows to skip + */ + public function get_row($p_limit=-1, $p_offset="") + { + $periode=sql_filter_per($this->db, $this->m_from, $this->m_to, 'p_id', + 'jr_tech_per'); + + $cond_limite=($p_limit!=-1)?" limit ".$p_limit." offset ".$p_offset:""; + + $ledger_list=join(",", $this->ma_ledger); + $sql=" + with row_sale as + (select qp_internal, + qp_supplier,sum(qp_price) as novat, + sum(qp_vat) as vat , + sum(qp_vat_sided) as tva_sided , + sum(qp_nd_amount) as noded_amount, + sum(qp_nd_tva) as noded_vat, + sum(qp_dep_priv) as private_amount + from + quant_purchase group by qp_supplier,qp_internal), + supplier_detail as ( + select x.f_id as f_id, + (select ad_value from fiche_detail where ad_id=1 and f_id=x.f_id) as name, + (select ad_value from fiche_detail where ad_id=32 and f_id=x.f_id) as first_name, + (select ad_value from fiche_detail where ad_id=23 and f_id=x.f_id) as qcode + from + fiche as x) + select + name, + first_name, + qcode, + jr_id, + jr_pj_number, + jr_date, + jr_date_paid, + jr_internal, + qp_supplier, + jrn.jr_comment, + jr_pj_name, + vat, + tva_sided, + novat, + noded_amount, + noded_vat, + private_amount, + novat+vat-tva_sided as tvac + from + jrn + join row_sale on (qp_internal=jr_internal) + join supplier_detail on (qp_supplier=f_id) + where + jr_def_id in ({$ledger_list}) + and {$periode} + {$cond_limite}"; + $this->data=$this->db->get_array($sql); + } + + /** + * @brief preprare the query for fetching the detailed VAT of an operation + * @staticvar int $prepare + */ + private function add_vat_info() + { + $prepare=$this->db->is_prepare("vat_infop"); + if ($prepare==0) + { + $this->db->prepare("vat_infop", + " + select + sum(qp_vat) vat_amount , + qp_vat_code + from + quant_purchase + where + qp_internal = $1 + group by qp_vat_code,qp_internal order by qp_vat_code"); + } + + $prepare=1; + $nb_row=count($this->data); + for ($i=0; $i<$nb_row; $i++) + { + $ret=$this->db->execute("vat_infop", + array($this->data[$i]["jr_internal"])); + $array=Database::fetch_all($ret); + $this->data[$i]["detail_vat"]=$array; + } + } + + /** + * Prepare the query for fetching detail of an operation + */ + private function prepare_detail() + { + + if ($this->db->is_prepare("detail_purchase")==FALSE) + { + $this->db->prepare("detail_purchase", + " + with card_name as + (select f_id,ad_value as name + from fiche_detail where ad_id=1), + card_qcode as + (select f_id,ad_value as qcode + from fiche_detail where ad_id=23) + select qp_price,qp_quantite,qp_vat,qp_vat_code,qp_unit,qp_vat_sided,name,qcode,tva_label, + qp_price+qp_vat-qp_vat_sided as tvac + from + quant_purchase + join jrnx using (j_id) + join card_name on (card_name.f_id=qp_fiche) + join card_qcode on (card_qcode.f_id=qp_fiche) + join tva_rate on ( qp_vat_code=tva_id) + where + qp_internal=$1 + + "); + } + } + +} diff --git a/include/class/acc_ledger_history_sale.class.php b/include/class/acc_ledger_history_sale.class.php index 217b1842e..4f1b2f6bf 100644 --- a/include/class/acc_ledger_history_sale.class.php +++ b/include/class/acc_ledger_history_sale.class.php @@ -71,12 +71,11 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History } /** * Prepare the query for fetching detail of an operation - * @staticvar int $prepare */ private function prepare_detail() { - static $prepare=0; - if ( $prepare == 0) + + if ( $this->db->is_prepare("detail_sale")== FALSE) { $this->db->prepare("detail_sale"," with card_name as @@ -98,7 +97,6 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History "); } - $prepare=1; } /** * Get the rows from jrnx and quant* tables @@ -161,8 +159,8 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History */ private function add_vat_info() { - static $prepare=0; - if ( $prepare==0) { + $prepare=$this->db->is_prepare("vat_info"); + if ( $prepare==FALSE) { $this->db->prepare("vat_info"," select sum(qs_vat) vat_amount , @@ -175,7 +173,6 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History } - $prepare=1; $nb_row=count($this->data); for ($i=0;$i<$nb_row;$i++) { @@ -215,7 +212,7 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History { $this->get_row(); $this->prepare_reconcile_date(); - require_once NOALYSS_TEMPLATE.'/acc_history_ledger_sale_oneline.php'; + require_once NOALYSS_TEMPLATE.'/acc_ledger_history_sale_oneline.php'; } diff --git a/include/impress_jrn.inc.php b/include/impress_jrn.inc.php index f35949503..a5b02b2ee 100644 --- a/include/impress_jrn.inc.php +++ b/include/impress_jrn.inc.php @@ -144,13 +144,15 @@ print td('Jusque ') . $w->input('to_periode', $periode_end); print ""; $a = array( array('value' => 'L', 'label' => _('Liste opérations')), - array('value' => 'E', 'label' => _('Ecriture comptable')), - array('value' => 'D', 'label' => _('Avec Détails opérations ')) + array('value' => 'E', 'label' => _('Liste détaillées opérations ')), + array('value' => 'A', 'label' => _('Ecriture comptable')), + array('value' => 'D', 'label' => _('Détails TVA')) ); $w->selected = 1; print ''; print ''; -$w->selected = (isset($simple)) ? $simple : '1'; +$simple=$http->get("p_simple","string","L"); +$w->selected = $simple; echo 'Style d\'impression '.Icon_Action::infobulle(32).'' . $w->input('p_simple', $a); print ""; @@ -169,7 +171,7 @@ echo '
    '; if (isset($_REQUEST['bt_html'])) { // Type of report : listing=1 , Accounting writing=0, detail =2 - $simple=$http->get("p_simple","string"); + $jrn_id=$http->get("jrn_id","number"); /* diff --git a/include/template/acc_ledger_history_purchase_detail.php b/include/template/acc_ledger_history_purchase_detail.php new file mode 100644 index 000000000..ea39c3fc7 --- /dev/null +++ b/include/template/acc_ledger_history_purchase_detail.php @@ -0,0 +1,196 @@ + + +if (!defined('ALLOWED')) + die('Appel direct ne sont pas permis'); + +/** + * @file + * @brief Display one purchase operation on one line , with the sum of VAT, ND... + */ +?> + + + + + + + + + + + + + +MY_TVA_USE=='Y') + { + echo ''; + $a_Tva=$this->db->get_array("select tva_id,tva_label from tva_rate where tva_rate != 0.0000 order by tva_id"); + foreach($a_Tva as $line_tva) + { + $col_tva.=''; + } + } +echo $col_tva; +?> + + + +data as $line) { + $i++; + /* + * Get date of reconcile operation + */ + $ret_reconcile=$this->db->execute('reconcile_date',array($line['jr_id'])); + $class = ($i % 2 == 0) ? ' class="even" ' : ' class="odd" '; + echo ""; + + // Receipt number + echo ""; + + // Date + echo ""; + echo ""; + + // Internal with detail + echo ""; + + // find the tiers (normally in $Row ! + $tiers =HtmlInput::history_card($line['qp_supplier'],h($line['name'].' '.$line['first_name'])."[{$line['qcode']}]"); + echo td($tiers); + // Label + echo ""; + + // Private expense + $private_amount=($line['private_amount']==0)?"":nbm(round($line['private_amount'],2),2); + $tot['private_amount']=bcadd($tot['private_amount'], floatval($line['private_amount'])); + + // No deductible + $noded_amount=($line['noded_amount']==0)?"":nbm(round($line['noded_amount'],2),2); + $tot['noded_amount']=bcadd($tot['noded_amount'],round(floatval($line['noded_amount'])),2); + + // HTVA amount + echo ""; + $tot['htva']=bcadd($tot['htva'], round(floatval($line['novat']),2)); + + echo ""; + echo ""; + + //-------------------------------------------------------------------------- + // If VAT then display it + //-------------------------------------------------------------------------- + if ($own->MY_TVA_USE == 'Y' ) + { + $tva_dna=($line['noded_vat']==0)?"":nbm(round($line['noded_vat']),2); + $tot['tva_nd']=bcadd($tot['tva_nd'], round(floatval($line['noded_vat']),2)); + echo ""; + $a_tva_amount=array(); + + foreach ($line['detail_vat'] as $lineTVA) + { + foreach ($a_Tva as $idx=>$line_tva) + { + + if ($line_tva['tva_id'] == $lineTVA['qp_vat_code']) + { + $a=$line_tva['tva_id']; + $a_tva_amount[$a]=$lineTVA['vat_amount']; + } + } + } + foreach ($a_Tva as $line_tva) + { + $a=$line_tva['tva_id']; + if ( isset($a_tva_amount[$a]) && $a_tva_amount[$a] != 0) { + echo ''; + $tot['tva'][$a]=(isset($tot['tva'][$a]))?bcadd($tot['tva'][$a],round(floatval($a_tva_amount[$a]),2)):round(floatval($a_tva_amount[$a]),2); + } + else + printf(""); + } + } + + echo ''; + $tot['tvac']=bcadd($tot['tvac'], round($line['tvac'],2)); + /* + * If reconcile print them + */ + echo ''; + echo ""; +} +/** + * summary + */ +?> + + + + + + + + + + + MY_TVA_USE == 'Y' ): ?> + + + + + + + + + + + + + +
    HTVAPrivéDNATVA NDTva '.$line_tva['tva_label'].'TVAC
    " . h($line['jr_pj_number']) . "" . smaller_date($line['jr_date']) . "" . smaller_date($line['jr_date_paid']) . "" . HtmlInput::detail_op($line['jr_id'], $line['jr_internal']) . "" . h($line['jr_comment']) . "" . nbm(round($line['novat'],2),2) . "" .$private_amount . "" . $noded_amount . "" . $tva_dna. "'.nbm(round($a_tva_amount[$a],2)).''.nbm($line['tvac'],2).''; + $max=Database::num_row($ret_reconcile); + if ($max > 0) { + $sep=""; + for ($e=0;$e<$max;$e++) { + $row=Database::fetch_array($ret_reconcile, $e); + echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $row['jr_internal']); + $sep=' ,'; + } + } + echo '
    + + + +
    \ No newline at end of file diff --git a/include/template/acc_ledger_history_purchase_extended.php b/include/template/acc_ledger_history_purchase_extended.php new file mode 100644 index 000000000..a30de3321 --- /dev/null +++ b/include/template/acc_ledger_history_purchase_extended.php @@ -0,0 +1,173 @@ + + + +/** + * @file + * @brief detail of the list of operation with VAT and items + */ +?> + + + + + + + + + + + + +data); +$tot_amount_novat=0; +$tot_amount_vat=0; +$tot_amount_tvac=0; +for ($i=0;$i<$nb_data;$i++): + $odd=' class="odd" '; + $tot_amount_novat=bcadd($tot_amount_novat,$this->data[$i]['novat']); + $tot_amount_vat=bcadd($tot_amount_vat,$this->data[$i]['vat']); + $tot_amount_vat=bcsub($tot_amount_vat,$this->data[$i]['tva_sided']); + $tot_amount_tvac=bcadd($tot_amount_tvac,$this->data[$i]['tvac']); +?> + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    + data[$i]['jr_date']?> + + data[$i]['jr_date_paid']?> + + data[$i]['jr_pj_number']?> + + data[$i]['jr_id'], $this->data[$i]['jr_internal'])?> + + data[$i]['qp_supplier'],h($this->data[$i]['name'].' '.$this->data[$i]['first_name']))?> + + data[$i]['jr_comment'])?> + + data[$i]['novat'])?> + + data[$i]['vat'],$this->data[$i]['tva_sided']))?> + + data[$i]['tvac'])?> + + + db->execute('reconcile_date',array($this->data[$i]['jr_id'])); + $max=Database::num_row($ret_reconcile); + if ($max > 0) { + $sep=""; + for ($e=0;$e<$max;$e++) { + $row=Database::fetch_array($ret_reconcile, $e); + echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $row['jr_internal']); + $sep=' ,'; + } + } ?> +
    +db->execute("detail_purchase",array($this->data[$i]['jr_internal'])); +$a_detail=Database::fetch_all($det); +?> + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + +
    \ No newline at end of file diff --git a/include/template/acc_ledger_history_purchase_oneline.php b/include/template/acc_ledger_history_purchase_oneline.php new file mode 100644 index 000000000..3a6d78320 --- /dev/null +++ b/include/template/acc_ledger_history_purchase_oneline.php @@ -0,0 +1,152 @@ + + +if (!defined('ALLOWED')) + die('Appel direct ne sont pas permis'); + +/** + * @file + * @brief display purchase on one line with sum of VAT, Operation, Private exp. + * @todo prévoir aussi pour les non assujetti : faire disparaître les montants TVA + */ + +?> + + + + + + + + + + + + + + +data); +$tot_amount_novat=0; +$tot_amount_vat=0; +$tot_amount_tvac=0; +$tot_amount_private=0; +$tot_nonded_vat=0; +$tot_nonded_amount=0; + +for ($i=0;$i<$nb_data;$i++): + $odd=($i%2==0)?' class="even" ':' class="odd" '; + $tot_amount_novat=bcadd($tot_amount_novat,$this->data[$i]['novat']); + $tot_amount_vat=bcadd($tot_amount_vat,$this->data[$i]['vat']); + $tot_amount_vat=bcsub($tot_amount_vat,$this->data[$i]['tva_sided']); + $tot_amount_tvac=bcadd($tot_amount_tvac,$this->data[$i]['tvac']); + $tot_nonded_amount=bcadd($tot_nonded_amount,$this->data[$i]['noded_amount']); + $tot_nonded_amount=bcadd($tot_nonded_amount,$this->data[$i]['private_amount']); + $tot_nonded_vat=bcadd($tot_nonded_vat, $this->data[$i]['noded_vat']); +?> + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + data[$i]['jr_date']?> + + data[$i]['jr_date_paid']?> + + data[$i]['jr_pj_number']?> + + data[$i]['jr_id'], $this->data[$i]['jr_internal'])?> + + data[$i]['qp_supplier'],h($this->data[$i]['name'].' '.$this->data[$i]['first_name']." [ {$this->data[$i]['qcode']} ]"))?> + + data[$i]['jr_comment'])?> + + data[$i]['novat'])?> + + data[$i]['noded_amount'],$this->data[$i]['private_amount']));?> + + data[$i]['vat'],$this->data[$i]['tva_sided']))?> + + data[$i]['tvac'])?> + + + db->execute('reconcile_date',array($this->data[$i]['jr_id'])); + $max=Database::num_row($ret_reconcile); + if ($max > 0) { + $sep=""; + for ($e=0;$e<$max;$e++) { + $row=Database::fetch_array($ret_reconcile, $e); + echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $row['jr_internal']); + $sep=' ,'; + } + } ?> +
    + +
    \ No newline at end of file diff --git a/include/template/acc_ledger_history_sale_detail.php b/include/template/acc_ledger_history_sale_detail.php index cfa9bf2a1..a48516380 100644 --- a/include/template/acc_ledger_history_sale_detail.php +++ b/include/template/acc_ledger_history_sale_detail.php @@ -83,7 +83,7 @@ foreach ($this->data as $line) { // Internal with detail echo "" . HtmlInput::detail_op($line['jr_id'], $line['jr_internal']) . ""; - // find the tiers (normally in $Row ! + // find the tiers (normally in $this->data ! $tiers =HtmlInput::history_card($line['qs_client'],h($line['name'].' '.$line['first_name'])."[{$line['qcode']}]"); echo td($tiers); diff --git a/include/template/acc_ledger_history_sale_extended.php b/include/template/acc_ledger_history_sale_extended.php index fdaa47206..effaf4365 100644 --- a/include/template/acc_ledger_history_sale_extended.php +++ b/include/template/acc_ledger_history_sale_extended.php @@ -78,7 +78,7 @@ for ($i=0;$i<$nb_data;$i++): data[$i]['jr_pj_number']?> - data[$i]['jr_internal']?> + data[$i]['jr_id'], $this->data[$i]['jr_internal'])?> data[$i]['qs_client'],h($this->data[$i]['name'].' '.$this->data[$i]['first_name']))?> @@ -111,7 +111,9 @@ for ($i=0;$i<$nb_data;$i++): - + + + db->execute("detail_sale",array($this->data[$i]['jr_internal'])); diff --git a/include/template/acc_history_ledger_sale_oneline.php b/include/template/acc_ledger_history_sale_oneline.php similarity index 97% rename from include/template/acc_history_ledger_sale_oneline.php rename to include/template/acc_ledger_history_sale_oneline.php index f3cfa48f8..45e1294b5 100644 --- a/include/template/acc_history_ledger_sale_oneline.php +++ b/include/template/acc_ledger_history_sale_oneline.php @@ -79,7 +79,7 @@ for ($i=0;$i<$nb_data;$i++): data[$i]['jr_pj_number']?> - data[$i]['jr_internal']?> + data[$i]['jr_id'], $this->data[$i]['jr_internal'])?> data[$i]['qs_client'],h($this->data[$i]['name'].' '.$this->data[$i]['first_name']." [ {$this->data[$i]['qcode']} ]"))?> diff --git a/scenario/acc_ledger_historyTest.php b/scenario/acc_ledger_historyTest.php index b0863baf2..361fef4cc 100644 --- a/scenario/acc_ledger_historyTest.php +++ b/scenario/acc_ledger_historyTest.php @@ -34,18 +34,17 @@ $cn=Dossier::connect(); $ledger_history=Acc_Ledger_History::factory($cn, $ledger, 216, 217, "E"); echo h1("Detailled Accounting"); -echo h2(_("export detail html all ledgers result = Detailled Accounting")); +echo h2(_("export detail html all ledgers result = Detailled Accounting from Acc_Ledger_History_Generic")); $ledger_history->export_detail_html(); -echo h2(_("Set mode to D etailled all_ledgers result = Detailled Accounting" )); +echo h2(_("Set mode to D etailled all_ledgers result = Detailled Accounting from Acc_Ledger_History_Generic" )); $ledger_history->set_m_mode("D"); $ledger_history->export_html(); -echo h2(_("Only VEN")); +echo h1(_("Only VEN from Acc_Ledger_History_Sale")); $ledger_history=Acc_Ledger_History::factory($cn, [2], 216, 217, "L"); $ledger_history->export_detail_html(); -echo h1("One line"); echo h2(_("Only VEN one line")); $ledger_history->set_a_ledger([2]); $ledger_history->set_m_mode("L"); @@ -66,3 +65,16 @@ $ledger_history=Acc_Ledger_History::factory($cn, [3,2], 216, 217, "L"); $ledger_history->export_oneline_html(); +echo h1("ACH from Acc_Ledger_History_Purchase"); +echo h2("Detailled accouting"); +$ledger_history=new Acc_Ledger_History_Purchase($cn,[3],216,217,"A"); +$ledger_history->export_html(); +echo h2("Ach one line"); +$ledger_history->set_m_mode("L"); +$ledger_history->export_html(); +echo h2("Ach Detail"); +$ledger_history->set_m_mode("D"); +$ledger_history->export_html(); +echo h2("Ach Extended"); +$ledger_history->set_m_mode("E"); +$ledger_history->export_html(); From f88ea644fc1cd5f53c0a8b0f3db79b2dede68707 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 21 Jan 2018 17:47:54 +0100 Subject: [PATCH 028/265] =?UTF-8?q?Task=20#0001530:=20R=C3=A9=C3=A9criture?= =?UTF-8?q?=20PRINTJRN=20Add=20Financial=20Ledger=20Adapt=20test=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/class/acc_ledger_history.class.php | 1 + .../acc_ledger_history_financial.class.php | 118 +++++++++++++++++- .../acc_ledger_history_purchase.class.php | 4 +- .../acc_ledger_history_financial_oneline.php | 81 ++++++++++++ scenario/acc_ledger_historyTest.php | 14 +++ 5 files changed, 213 insertions(+), 5 deletions(-) create mode 100644 include/template/acc_ledger_history_financial_oneline.php diff --git a/include/class/acc_ledger_history.class.php b/include/class/acc_ledger_history.class.php index 30b25da97..8cfc2545c 100644 --- a/include/class/acc_ledger_history.class.php +++ b/include/class/acc_ledger_history.class.php @@ -27,6 +27,7 @@ require_once NOALYSS_INCLUDE."/class/acc_ledger_history_generic.class.php"; require_once NOALYSS_INCLUDE."/class/acc_ledger_history_sale.class.php"; require_once NOALYSS_INCLUDE."/class/acc_ledger_history_purchase.class.php"; +require_once NOALYSS_INCLUDE."/class/acc_ledger_history_financial.class.php"; /** * @brief Display history of operation */ diff --git a/include/class/acc_ledger_history_financial.class.php b/include/class/acc_ledger_history_financial.class.php index 07e0ec1b8..289583505 100644 --- a/include/class/acc_ledger_history_financial.class.php +++ b/include/class/acc_ledger_history_financial.class.php @@ -22,7 +22,119 @@ /** * @file - * @brief - * @param type $name Descriptionara + * @brief displya financial operations + * */ -?> +require_once NOALYSS_INCLUDE."/class/acc_ledger_history.class.php"; + +class Acc_Ledger_History_Financial extends Acc_Ledger_History +{ + + /** + * @brief display the accounting + */ + public function export_accounting_html() + { + $ledger_history=new Acc_Ledger_History_Generic($this->db, + $this->ma_ledger, $this->m_from, $this->m_to, $this->m_mode); + $ledger_history->export_accounting_html(); + } + + public function export_detail_html() + { + $this->export_oneline_html(); + } + + public function export_extended_html() + { + $ledger_history=new Acc_Ledger_History_Generic($this->db, + $this->ma_ledger, $this->m_from, $this->m_to, $this->m_mode); + $ledger_history->export_accounting_html(); + } + + /** + * @brief display in HTML following the mode + */ + function export_html() + { + switch ($this->m_mode) + { + case "E": + $this->export_accounting_html(); + break; + case "D": + $this->export_oneline_html(); + break; + case "L": + $this->export_oneline_html(); + break; + case "A": + $this->export_accounting_html(); + break; + default: + break; + } + } + + /** + * display in HTML one operation by line + */ + public function export_oneline_html() + { + $this->get_row(); + $this->prepare_reconcile_date(); + require_once NOALYSS_TEMPLATE.'/acc_ledger_history_financial_oneline.php'; + + } + + /** + * Get the rows from jrnx and quant* tables + * @param int $p_limit max of rows to returns + * @param int $p_offset the number of rows to skip + */ + public function get_row($p_limit=-1, $p_offset="") + { + $periode=sql_filter_per($this->db, $this->m_from, $this->m_to, 'p_id', + 'jr_tech_per'); + + $cond_limite=($p_limit!=-1)?" limit ".$p_limit." offset ".$p_offset:""; + + $ledger_list=join(",", $this->ma_ledger); + $sql=" + with detail as ( + select x.f_id as f_id, + (select ad_value from fiche_detail where ad_id=1 and f_id=x.f_id) as name, + (select ad_value from fiche_detail where ad_id=32 and f_id=x.f_id) as first_name, + (select ad_value from fiche_detail where ad_id=23 and f_id=x.f_id) as qcode + from + fiche as x) + select + bk.f_id as bk_f_id, + bk.name as bk_name, + bk.first_name as bk_first_name, + bk.qcode as bk_qcode, + tiers.f_id as tiers_f_id, + tiers.name as tiers_name, + tiers.first_name as tiers_first_name, + tiers.qcode as tiers_qcode, + jr_id, + jr_pj_number, + jr_date, + jr_date_paid, + jr_internal, + jrn.jr_comment, + jr_pj_name, + qf_amount + from + jrn + join quant_fin using (jr_id) + join detail as tiers on (tiers.f_id=qf_other) + join detail as bk on (bk.f_id=qf_bank) + where + jr_def_id in ({$ledger_list}) + and {$periode} + {$cond_limite}"; + $this->data=$this->db->get_array($sql); + } + +} diff --git a/include/class/acc_ledger_history_purchase.class.php b/include/class/acc_ledger_history_purchase.class.php index 715ffa052..72eeb4134 100644 --- a/include/class/acc_ledger_history_purchase.class.php +++ b/include/class/acc_ledger_history_purchase.class.php @@ -116,7 +116,7 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History $ledger_list=join(",", $this->ma_ledger); $sql=" - with row_sale as + with row_purchase as (select qp_internal, qp_supplier,sum(qp_price) as novat, sum(qp_vat) as vat , @@ -154,7 +154,7 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History novat+vat-tva_sided as tvac from jrn - join row_sale on (qp_internal=jr_internal) + join row_purchase on (qp_internal=jr_internal) join supplier_detail on (qp_supplier=f_id) where jr_def_id in ({$ledger_list}) diff --git a/include/template/acc_ledger_history_financial_oneline.php b/include/template/acc_ledger_history_financial_oneline.php new file mode 100644 index 000000000..67929719b --- /dev/null +++ b/include/template/acc_ledger_history_financial_oneline.php @@ -0,0 +1,81 @@ + + +if (!defined('ALLOWED')) + die('Appel direct ne sont pas permis'); + +/** + * @file + * @brief display Financial operation , simple and detailled + */ +?> + + + + + + + + + data); + $tot_amount=0; + for ($i=0; $i<$nb_data; $i++): + $class=($i%2==0)?' class="even" ':' class="odd" '; + ?> + > + + + + + + + +
    + data[$i]['bk_qcode']; ?> + + data[$i]['tiers_f_id'], + h($this->data[$i]['tiers_first_name'].$this->data[$i]['tiers_name']."[{$this->data[$i]['tiers_qcode']}]")); + ?> + + data[$i]['jr_comment']) ?> + + data[$i]['qf_amount']) ?> + + db->execute('reconcile_date', + array($this->data[$i]['jr_id'])); + $max=Database::num_row($ret_reconcile); + if ($max>0) + { + $sep=""; + for ($e=0; $e<$max; $e++) + { + $row=Database::fetch_array($ret_reconcile, $e); + echo $sep.HtmlInput::detail_op($row['jr_id'], + $row['jr_date'].' '.$row['jr_internal']); + $sep=' ,'; + } + } + ?> +
    \ No newline at end of file diff --git a/scenario/acc_ledger_historyTest.php b/scenario/acc_ledger_historyTest.php index 361fef4cc..7337b8ca6 100644 --- a/scenario/acc_ledger_historyTest.php +++ b/scenario/acc_ledger_historyTest.php @@ -78,3 +78,17 @@ $ledger_history->export_html(); echo h2("Ach Extended"); $ledger_history->set_m_mode("E"); $ledger_history->export_html(); + +echo h1("FIN from Acc_Ledger_History_Financial"); +echo h2("Detailled accouting"); +$ledger_history=new Acc_Ledger_History_Financial($cn,[11,16],216,217,"A"); +$ledger_history->export_html(); +echo h2("FIN one line"); +$ledger_history->set_m_mode("L"); +$ledger_history->export_html(); +echo h2(">FIN Detail"); +$ledger_history->set_m_mode("D"); +$ledger_history->export_html(); +echo h2("FIN Extended"); +$ledger_history->set_m_mode("E"); +$ledger_history->export_html(); From eba7117ad6bd12a701329aa411ad0d4ee4bfd422 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 21 Jan 2018 23:11:54 +0100 Subject: [PATCH 029/265] =?UTF-8?q?Task=20#0001530:=20R=C3=A9=C3=A9criture?= =?UTF-8?q?=20PRINTJRN=20:=20export=20PDF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/class/acc_ledger.class.php | 20 +++++++++- .../acc_ledger_history_financial.class.php | 8 ++++ .../acc_ledger_history_generic.class.php | 9 ++++- .../acc_ledger_history_purchase.class.php | 8 ++++ .../class/acc_ledger_history_sale.class.php | 9 +++++ include/class/print_ledger.class.php | 37 ++++++++++++++++--- include/export/export_ledger_csv.php | 8 ++-- include/export/export_ledger_pdf.php | 2 +- include/impress_jrn.inc.php | 36 +++++++++++++++++- 9 files changed, 123 insertions(+), 14 deletions(-) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index 1f32a0d6a..5000ce72b 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -44,6 +44,7 @@ require_once NOALYSS_INCLUDE.'/class/lettering.class.php'; require_once NOALYSS_INCLUDE.'/lib/sort_table.class.php'; require_once NOALYSS_INCLUDE.'/database/jrn_def_sql.class.php'; require_once NOALYSS_INCLUDE.'/class/acc_payment.class.php'; +require_once NOALYSS_INCLUDE.'/class/acc_ledger_history.class.php'; require_once NOALYSS_INCLUDE.'/lib/http_input.class.php'; /** \file @@ -1919,6 +1920,7 @@ class Acc_Ledger extends jrn_def_sql " ,coalesce(sum(qs_vat),0) as vat ". ',0 as priv'. ',0 as tva_nd'. + ',coalesce(sum(qs_vat_sided),0) as reversed'. ',coalesce(sum(qs_vat_sided),0) as tva_np'. ' from quant_sold join jrnx using(j_id) '. " where j_date >= to_date($1,'DD.MM.YYYY') and j_date < to_date($2,'DD.MM.YYYY') ". @@ -2617,7 +2619,23 @@ class Acc_Ledger extends jrn_def_sql $array=$this->db->get_array($sql, array($p_date)); return $array; } - + /** @brief Get simplified row from ledger + * Call Acc_Ledger_History_Generic:get_rowSimple + * @param p_from periode + * @param p_to periode + * @param p_limit starting line + * @param p_offset number of lines + * @param trunc if data must be truncated (pdf export) + * + * \return an Array with the asked data + */ + function get_rowSimple($p_from, $p_to, $trunc=0, $p_limit=-1, $p_offset=-1) + { + $alh_generic=new Acc_Ledger_History_Generic($this->db, [$this->id], $p_from, $p_to, "A"); + $alh_generic->get_rowSimple($trunc,$p_limit,$p_offset); + $data=$alh_generic->get_data(); + return $data; + } /** * @brief get info from supplier to pay today */ diff --git a/include/class/acc_ledger_history_financial.class.php b/include/class/acc_ledger_history_financial.class.php index 289583505..0294bd7b9 100644 --- a/include/class/acc_ledger_history_financial.class.php +++ b/include/class/acc_ledger_history_financial.class.php @@ -136,5 +136,13 @@ class Acc_Ledger_History_Financial extends Acc_Ledger_History {$cond_limite}"; $this->data=$this->db->get_array($sql); } + /** + * To get data + * @return array of rows + */ + function get_data() + { + return $this->data; + } } diff --git a/include/class/acc_ledger_history_generic.class.php b/include/class/acc_ledger_history_generic.class.php index 714dc9516..8b8a5ce76 100644 --- a/include/class/acc_ledger_history_generic.class.php +++ b/include/class/acc_ledger_history_generic.class.php @@ -733,5 +733,12 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History echo ''; echo ""; } - + /** + * To get data + * @return array of rows + */ + function get_data() + { + return $this->data; + } } diff --git a/include/class/acc_ledger_history_purchase.class.php b/include/class/acc_ledger_history_purchase.class.php index 72eeb4134..70daa96a9 100644 --- a/include/class/acc_ledger_history_purchase.class.php +++ b/include/class/acc_ledger_history_purchase.class.php @@ -225,5 +225,13 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History "); } } + /** + * To get data + * @return array of rows + */ + function get_data() + { + return $this->data; + } } diff --git a/include/class/acc_ledger_history_sale.class.php b/include/class/acc_ledger_history_sale.class.php index 4f1b2f6bf..d75aa317f 100644 --- a/include/class/acc_ledger_history_sale.class.php +++ b/include/class/acc_ledger_history_sale.class.php @@ -67,6 +67,7 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History $this->get_row(); $this->add_vat_info(); $this->prepare_detail(); + $this->prepare_reconcile_date(); include NOALYSS_TEMPLATE."/acc_ledger_history_sale_extended.php"; } /** @@ -215,5 +216,13 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History require_once NOALYSS_TEMPLATE.'/acc_ledger_history_sale_oneline.php'; } + /** + * To get data + * @return array of rows + */ + function get_data() + { + return $this->data; + } } diff --git a/include/class/print_ledger.class.php b/include/class/print_ledger.class.php index 7503fca4d..d019f30c1 100644 --- a/include/class/print_ledger.class.php +++ b/include/class/print_ledger.class.php @@ -51,14 +51,34 @@ class Print_Ledger { */ if ($p_format_output == 'PDF') { switch ($p_type_export) { - case 0: + case 'D': + $own = new Noalyss_Parameter_Folder($cn); + $jrn_type = $p_ledger->get_type(); //--------------------------------------------- // Detailled Printing (accounting ) //--------------------------------------------- - return new Print_Ledger_Detail($cn, $p_ledger); + if ($jrn_type == 'ACH' || $jrn_type == 'VEN') { + if ( + ($jrn_type == 'ACH' && $cn->get_value('select count(qp_id) from quant_purchase') == 0) || + ($jrn_type == 'VEN' && $cn->get_value('select count(qs_id) from quant_sold') == 0) + ) { + $pdf = new Print_Ledger_Simple_without_vat($cn, $p_ledger); + $pdf->set_error(_('Ce journal ne peut être imprimé en mode simple')); + return $pdf; + } + if ($own->MY_TVA_USE == 'Y') { + $pdf = new Print_Ledger_Simple($cn, $p_ledger); + return $pdf; + } + if ($own->MY_TVA_USE == 'N') { + $pdf = new Print_Ledger_Simple_without_vat($cn, $p_ledger); + return $pdf; + } + }else + return new Print_Ledger_Detail($cn, $p_ledger); break; - case 1: + case 'L': //---------------------------------------------------------------------- // Simple Printing Purchase Ledger //--------------------------------------------------------------------- @@ -94,7 +114,7 @@ class Print_Ledger { return $pdf; } break; - case 2: + case 'E': /********************************************************** * Print Detail Operation + Item ********************************************************** */ @@ -106,7 +126,7 @@ class Print_Ledger { ; } if ($jrn_type == 'ODS' || $p_ledger->id == 0) { - $pdf = new Print_Ledger_Misc($cn, $p_ledger); + $pdf = new Print_Ledger_Detail($cn, $p_ledger); return $pdf; } if ( @@ -119,6 +139,13 @@ class Print_Ledger { } $pdf = new Print_Ledger_Detail_Item($cn,$p_ledger); return $pdf; + case 'A': + /*********************************************************** + * Accounting + */ + $pdf = new Print_Ledger_Detail($cn, $p_ledger); + return $pdf; + break; } // end switch } // end $p_format == PDF diff --git a/include/export/export_ledger_csv.php b/include/export/export_ledger_csv.php index 9041f5862..7f55dbce7 100644 --- a/include/export/export_ledger_csv.php +++ b/include/export/export_ledger_csv.php @@ -46,7 +46,7 @@ $export->send_header(); try { $get_jrn=$http->get('jrn_id',"number"); - $get_option=$http->get('p_simple',"number"); + $get_option=$http->get('p_simple',"string"); $get_from_periode= $http->get('from_periode'); $get_to_periode=$http->get('to_periode'); @@ -80,7 +80,7 @@ $jrn_type=$Jrn->get_type(); // // With Detail per item which is possible only for VEN or ACH // -if ($get_option == 2) +if ($get_option == 'D') { if ($jrn_type != 'ACH' && $jrn_type != 'VEN' || $Jrn->id == 0) { @@ -132,7 +132,7 @@ if ($get_option == 2) // Detailled printing // For miscellaneous legder or all ledgers //----------------------------------------------------------------------------- -if ( $get_option == 0 ) +if ( $get_option == 'A' ) { $Jrn->get_row( $get_from_periode, $get_to_periode ); $title=array(); @@ -180,7 +180,7 @@ if ( $get_option == 0 ) // for Misc the amount // For Financial only the tiers and the sign of the amount //----------------------------------------------------------------------------- -if ($get_option == 1) +if ($get_option == "L") { //----------------------------------------------------- diff --git a/include/export/export_ledger_pdf.php b/include/export/export_ledger_pdf.php index ea2fcc10c..2ac0a29cd 100644 --- a/include/export/export_ledger_pdf.php +++ b/include/export/export_ledger_pdf.php @@ -45,7 +45,7 @@ $periode = new Periode($cn); try { $jrn_id=$http->get('jrn_id',"number"); - $p_simple=$http->get('p_simple',"number"); + $p_simple=$http->get('p_simple',"string"); } diff --git a/include/impress_jrn.inc.php b/include/impress_jrn.inc.php index a5b02b2ee..9098511a3 100644 --- a/include/impress_jrn.inc.php +++ b/include/impress_jrn.inc.php @@ -162,7 +162,7 @@ print HtmlInput::submit('bt_html', _('Visualisation')); echo ''; echo '
    '; - + //----------------------------------------------------- // If print is asked // First time in html @@ -171,9 +171,41 @@ echo '
    '; if (isset($_REQUEST['bt_html'])) { // Type of report : listing=1 , Accounting writing=0, detail =2 - + $hid=new IHidden(); $jrn_id=$http->get("jrn_id","number"); + echo ''; + echo ''; + + echo '"; + + echo ''; + echo ""; + + echo "
    '; + echo '
    ' . dossier::hidden() . + HtmlInput::submit('bt_pdf', "Export PDF") . + HtmlInput::hidden('act', 'PDF:ledger') . + $hid->input("type", "jrn") . + $hid->input("jrn_id", $jrn_id) . + $hid->input("from_periode", $from_periode) . + $hid->input("to_periode", $to_periode); + echo $hid->input("p_simple", $simple); + echo HtmlInput::get_to_hidden(array('ac', 'type')); + echo "
    "; + echo '
    ' . dossier::hidden() . + HtmlInput::submit('bt_csv', "Export CSV") . + HtmlInput::hidden('act', 'CSV:ledger') . + $hid->input("type", "jrn") . + $hid->input("jrn_id", $jrn_id) . + $hid->input("from_periode", $from_periode) . + $hid->input("to_periode", $to_periode); + echo $hid->input("p_simple", $simple); + echo HtmlInput::get_to_hidden(array('ac', 'type')); + echo "
    '; + echo HtmlInput::print_window(); + echo '
    "; + /* * Compute an array with all the usable ledger */ From 295dc85a3836933bf83f272ffbbfed3e6f1acba1 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 22 Jan 2018 20:28:19 +0100 Subject: [PATCH 030/265] =?UTF-8?q?Task=20#0001530:=20R=C3=A9=C3=A9criture?= =?UTF-8?q?=20PRINTJRN=20:=20export=20CSV=20:=20Purchase=20List=20(L)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/class/acc_ledger_history.class.php | 3 + .../acc_ledger_history_purchase.class.php | 98 ++++++++++++++++++- include/export/export_ledger_csv.php | 93 ++---------------- .../acc_ledger_history_purchase_detail.php | 2 +- 4 files changed, 105 insertions(+), 91 deletions(-) diff --git a/include/class/acc_ledger_history.class.php b/include/class/acc_ledger_history.class.php index 8cfc2545c..94a88e328 100644 --- a/include/class/acc_ledger_history.class.php +++ b/include/class/acc_ledger_history.class.php @@ -42,6 +42,9 @@ abstract class Acc_Ledger_History function __construct(Database $cn, $pa_ledger, $p_from, $p_to, $p_mode) { + if (is_array($pa_ledger) == FALSE) { + throw new Exception (_('pa_ledger doit être un tableau'),EXC_PARAM_VALUE); + } $this->db=$cn; $this->ma_ledger=$pa_ledger; $this->m_from=$p_from; diff --git a/include/class/acc_ledger_history_purchase.class.php b/include/class/acc_ledger_history_purchase.class.php index 70daa96a9..5f813c2ae 100644 --- a/include/class/acc_ledger_history_purchase.class.php +++ b/include/class/acc_ledger_history_purchase.class.php @@ -151,11 +151,13 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History noded_amount, noded_vat, private_amount, - novat+vat-tva_sided as tvac + novat+vat-tva_sided as tvac, + n_text from jrn join row_purchase on (qp_internal=jr_internal) join supplier_detail on (qp_supplier=f_id) + left join jrn_note using (jr_id) where jr_def_id in ({$ledger_list}) and {$periode} @@ -165,12 +167,11 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History /** * @brief preprare the query for fetching the detailed VAT of an operation - * @staticvar int $prepare */ private function add_vat_info() { $prepare=$this->db->is_prepare("vat_infop"); - if ($prepare==0) + if ($prepare==FALSE) { $this->db->prepare("vat_infop", " @@ -184,7 +185,6 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History group by qp_vat_code,qp_internal order by qp_vat_code"); } - $prepare=1; $nb_row=count($this->data); for ($i=0; $i<$nb_row; $i++) { @@ -233,5 +233,95 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History { return $this->data; } + function export_csv() + { + $export=new Noalyss_Csv(_('journal')); + $export->send_header(); + + $this->get_row(); + $this->prepare_reconcile_date(); + $this->add_vat_info(); + + $own=new Noalyss_Parameter_Folder($this->db); + $title=array(); + $title[]=_('Date'); + $title[]=_("Paiement"); + $title[]=_("operation"); + $title[]=_("Pièce"); + $title[]=_("Fournisseur"); + $title[]=_("Note"); + $title[]=_("interne"); + $title[]=_("HTVA"); + $title[]=_("privé"); + $title[]=_("DNA"); + $title[]=_("tva non ded."); + $title[]=_("TVA NP"); + + if ( $own->MY_TVA_USE=='Y') + { + $a_Tva=$this->db->get_array("select tva_id,tva_label from tva_rate order by tva_rate,tva_label,tva_id"); + foreach($a_Tva as $line_tva) + { + $title[]="Tva ".$line_tva['tva_label']; + } + } + $title[]=_("TVAC/TTC"); + $title[]=_("opérations liées"); + $export->write_header($title); + + foreach ($this->data as $line) + { + $export->add($line['jr_date']); + $export->add($line['jr_date_paid']); + $export->add($line['jr_id']); + $export->add($line['jr_pj_number']); + $export->add($line['name']." ". + $line["first_name"]." ". + $line["qcode"]); // qp_supplier + $export->add($line['jr_comment']); + $export->add($line['jr_internal']); + $export->add($line['novat'],"number"); + $export->add($line['private_amount'],"number"); + $export->add($line['noded_amount'],"number"); + $export->add($line['noded_vat'],"number"); + $export->add($line['tva_sided'],"number"); + + $a_tva_amount=array(); + //- set all TVA to 0 + foreach ($a_Tva as $l) { + $t_id=$l["tva_id"]; + $a_tva_amount[$t_id]=0; + } + foreach ($line['detail_vat'] as $lineTVA) + { + $idx_tva=$lineTVA['qp_vat_code']; + $a_tva_amount[$idx_tva]=$lineTVA['vat_amount']; + } + if ($own->MY_TVA_USE == 'Y' ) + { + foreach ($a_Tva as $line_tva) + { + $a=$line_tva['tva_id']; + $export->add($a_tva_amount[$a],"number"); + } + } + $export->add($line['tvac'],"number"); + /** + * Retrieve payment if any + */ + $ret_reconcile=$this->db->execute('reconcile_date',array($line['jr_id'])); + $max=Database::num_row($ret_reconcile); + if ($max > 0) { + for ($e=0;$e<$max;$e++) { + $row=Database::fetch_array($ret_reconcile, $e); + $export->add($row['jr_date']); + $export->add($row['jr_internal']); + } + } + $export->write(); + + } + + } } diff --git a/include/export/export_ledger_csv.php b/include/export/export_ledger_csv.php index 7f55dbce7..0c1107aab 100644 --- a/include/export/export_ledger_csv.php +++ b/include/export/export_ledger_csv.php @@ -84,7 +84,7 @@ if ($get_option == 'D') { if ($jrn_type != 'ACH' && $jrn_type != 'VEN' || $Jrn->id == 0) { - $get_option = 0; + $get_option = 'A'; } else { @@ -236,92 +236,13 @@ if ($get_option == "L") // One line summary with tiers, amount VAT, DNA, tva code .... // //------------------------------------------------------------------------------ - if ( $jrn_type=='ACH' || $jrn_type=='VEN') - { - $Row=$Jrn->get_rowSimple($get_from_periode, - $get_to_periode, - 0); - $cn->prepare('reconcile_date',"select to_char(jr_date,'DD.MM.YY') as str_date,* " - . "from jrn " - . "where " - . "jr_id in (select jra_concerned from jrn_rapt where jr_id = $1 union all select jr_id from jrn_rapt where jra_concerned=$1)"); - - $own=new Noalyss_Parameter_Folder($cn); - $title=array(); - $title[]=_('Date'); - $title[]=_("Paiement"); - $title[]=_("operation"); - $title[]=_("Pièce"); - $title[]=_("Client/Fourn."); - $title[]=_("Note"); - $title[]=_("interne"); - $title[]=_("HTVA"); - $title[]=_("privé"); - $title[]=_("DNA"); - $title[]=_("tva non ded."); - $title[]=_("TVA NP"); - - if ( $own->MY_TVA_USE=='Y') - { - $a_Tva=$cn->get_array("select tva_id,tva_label from tva_rate order by tva_rate,tva_label,tva_id"); - foreach($a_Tva as $line_tva) - { - $title[]="Tva ".$line_tva['tva_label']; - } + if ( $jrn_type == "ACH") { + $acc_ledger_history=new Acc_Ledger_History_Purchase($cn,[$Jrn->id],$get_from_periode,$get_to_periode,'D'); + $acc_ledger_history->export_csv(); } - $title[]=_("TVAC"); - $title[]=_("opérations liées"); - $export->write_header($title); - - foreach ($Row as $line) - { - $export->add($line['date']); - $export->add($line['date_paid']); - $export->add($line['num']); - $export->add($line['jr_pj_number']); - $export->add($Jrn->get_tiers($line['jrn_def_type'],$line['jr_id'])); - $export->add($line['comment']); - $export->add($line['jr_internal']); - $export->add($line['HTVA'],"number"); - $export->add($line['dep_priv'],"number"); - $export->add($line['dna'],"number"); - $export->add($line['tva_dna'],"number"); - $export->add($line['tva_np'],"number"); - $a_tva_amount=array(); - //- set all TVA to 0 - foreach ($a_Tva as $l) { - $t_id=$l["tva_id"]; - $a_tva_amount[$t_id]=0; - } - foreach ($line['TVA'] as $lineTVA) - { - $idx_tva=$lineTVA[1][0]; - $a_tva_amount[$idx_tva]=$lineTVA[1][2]; - } - if ($own->MY_TVA_USE == 'Y' ) - { - foreach ($a_Tva as $line_tva) - { - $a=$line_tva['tva_id']; - $export->add($a_tva_amount[$a],"number"); - } - } - $export->add($line['TVAC'],"number"); - /** - * Retrieve payment if any - */ - $ret_reconcile=$cn->execute('reconcile_date',array($line['jr_id'])); - $max=Database::num_row($ret_reconcile); - if ($max > 0) { - for ($e=0;$e<$max;$e++) { - $row=Database::fetch_array($ret_reconcile, $e); - $export->add($row['str_date']); - $export->add($row['jr_internal']); - } - } - $export->write(); - + if ( $jrn_type == "VEN") { + $acc_ledger_history=new Acc_Ledger_History_Sale($cn,[$Jrn->id],$get_from_periode,$get_to_periode,'D'); + //@todo to implement $acc_ledger_history->export_csv(); } - } } ?> diff --git a/include/template/acc_ledger_history_purchase_detail.php b/include/template/acc_ledger_history_purchase_detail.php index ea39c3fc7..e3c5e94f2 100644 --- a/include/template/acc_ledger_history_purchase_detail.php +++ b/include/template/acc_ledger_history_purchase_detail.php @@ -116,7 +116,7 @@ foreach ($this->data as $line) { echo "" . $tva_dna. ""; $a_tva_amount=array(); - foreach ($line['detail_vat'] as $lineTVA) + foreach ($line['m'] as $lineTVA) { foreach ($a_Tva as $idx=>$line_tva) { From 49f2103403b3955947a14a5bec8097ed5c3895a6 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 22 Jan 2018 22:09:16 +0100 Subject: [PATCH 031/265] =?UTF-8?q?task=20#1531:=20Historique=20poste=20et?= =?UTF-8?q?=20fiche=20d'apr=C3=A8s=20exercice=20op=C3=A9ration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/js/acc_ledger.js | 15 +++++++++------ include/ajax/ajax_history.php | 10 ++++++---- include/balance.inc.php | 3 +-- include/class/acc_bilan.class.php | 7 +++++-- include/class/anc_grandlivre.class.php | 14 +++++++++++--- include/lib/html_input.class.php | 20 ++++++++++++++------ include/template/ledger_detail_bottom.php | 13 +++++++++---- include/template/ledger_detail_misc.php | 11 ++++++----- include/template/operation_detail_misc.php | 5 +++-- 9 files changed, 64 insertions(+), 34 deletions(-) diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 94bc14b8b..9df198f8c 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -656,13 +656,13 @@ function go_next_concerned() * @param {type} dossier * @returns {undefined} */ -function view_history_account(p_value, dossier) +function view_history_account(p_value, dossier,p_exercice) { layer++; var idbox = 'det' + layer; var popup = {'id': idbox, 'cssclass': 'inner_box', 'html': loading(), 'drag': false}; - var querystring={'gDossier':dossier,'act':'de','pcm_val':p_value,'div':idbox,'l':layer,'op':'history'}; + var querystring={'gDossier':dossier,'act':'de','pcm_val':p_value,'div':idbox,'l':layer,'op':'history','exercice':p_exercice}; waiting_box(); var action = new Ajax.Request( @@ -696,7 +696,8 @@ function update_history_account(obj) "gDossier" : obj.gDossier, "pcm_val" : obj.pcm_val , "ex" : obj.select.options[obj.select.selectedIndex].text, - "op":"history" + "op":"history", + "exercice":obj.exercice }; waiting_box(); var action = new Ajax.Request( @@ -722,7 +723,7 @@ function update_history_account(obj) /*!\brief Change the view of card history * \param p_value f_id of the card */ -function view_history_card(p_value, dossier) +function view_history_card(p_value, dossier,p_exercice) { layer++; var idbox = 'det' + layer; @@ -735,7 +736,8 @@ function view_history_card(p_value, dossier) 'f_id' : p_value , 'div' : idbox , "l" : layer, - "op":"history"}; + "op":"history", + "exercice":p_exercice}; waiting_box(); var action = new Ajax.Request( "ajax_misc.php", @@ -767,7 +769,8 @@ function update_history_card(obj) "gDossier" : obj.gDossier, "f_id" : obj.f_id , "ex" : obj.select.options[obj.select.selectedIndex].text, - "op":"history" + "op":"history", + "exercice":obj.exercice }; waiting_box(); var action = new Ajax.Request( diff --git a/include/ajax/ajax_history.php b/include/ajax/ajax_history.php index 1d9101e52..128fc6da7 100644 --- a/include/ajax/ajax_history.php +++ b/include/ajax/ajax_history.php @@ -52,7 +52,8 @@ if ( isset($_GET['f_id'])) $old=''; $f_id=$http->get('f_id',"number"); $fiche=new Fiche($cn,$f_id); - $year=$g_user->get_exercice(); + + $year=$http->get("exercice","string",$g_user->get_exercice()); if ( $year == 0 ) { $html=_("erreur aucune période par défaut, allez dans préférence pour en choisir une"); @@ -83,7 +84,7 @@ if ( isset($_GET['f_id'])) $dossier=dossier::id(); if ( $div != 'popup') { - $obj="{op:'history',div:'$div',f_id:'".$_GET['f_id']."',gDossier:'$dossier',select:this}"; + $obj="{op:'history',div:'$div',f_id:'".$_GET['f_id']."',gDossier:'$dossier',select:this,exercice:{$year}}"; $is=$exercice->select('p_exercice',$default,' onchange="update_history_card('.$obj.');"'); $old=_("Autre exercice")." ".$is->input(); } @@ -96,6 +97,7 @@ if ( isset($_GET['f_id'])) $old.=HtmlInput::hidden('act',$_GET['act']); $old.=HtmlInput::hidden('f_id',$_GET['f_id']); $old.=HtmlInput::hidden('ajax',$_GET['ajax']); + $old.=HtmlInput::hidden('exercice',$year); $old.=dossier::hidden(); $old.=HtmlInput::hidden('op','history'); $old.=''; @@ -135,7 +137,7 @@ if ( isset($_REQUEST['pcm_val'])) { $poste=new Acc_Account_Ledger($cn,$_REQUEST['pcm_val']); $poste->load(); - $year=$g_user->get_exercice(); + $year=$http->get("exercice","string",$g_user->get_exercice()); if ( $year == 0 ) { $html=_("erreur aucune période par défaut, allez dans préférence pour en choisir une"); @@ -167,7 +169,7 @@ if ( isset($_REQUEST['pcm_val'])) $dossier=dossier::id(); if ( $div != 'popup') { - $obj="{op:'history',div:'$div',pcm_val:'".$_GET['pcm_val']."',gDossier:'$dossier',select:this}"; + $obj="{op:'history',div:'$div',pcm_val:'".$_GET['pcm_val']."',gDossier:'$dossier',select:this,exercice:{$year}}"; $is=$exercice->select('p_exercice',$default,' onchange="update_history_account('.$obj.');"'); $old=_("Autre exercice")." ".$is->input(); } diff --git a/include/balance.inc.php b/include/balance.inc.php index dd2b0200d..92db13bdc 100644 --- a/include/balance.inc.php +++ b/include/balance.inc.php @@ -347,8 +347,7 @@ if ( isset($_GET['view'] ) ) $tr="even"; else $tr="odd"; - $view_history= sprintf('%s', - $r['poste'], $gDossier, $r['poste']); + $view_history=HtmlInput::history_account($r['poste'], $r['poste'], "",$exercice); /* * level x diff --git a/include/class/acc_bilan.class.php b/include/class/acc_bilan.class.php index e2b408b7a..1dff742f0 100644 --- a/include/class/acc_bilan.class.php +++ b/include/class/acc_bilan.class.php @@ -121,6 +121,9 @@ class Acc_Bilan $ret=""; $obj=new Acc_Account_Ledger($this->db,0); $sql=sql_filter_per($this->db,$this->from,$this->to,'p_id','j_tech_per'); + // Find exercice + $periode=new Periode($this->db,$this->from); + $exercice=$periode->get_exercice(); for ($i=0;$i<$nRow;$i++) { @@ -134,9 +137,9 @@ class Acc_Bilan ($solde_signed > 0 && $p_deb == 'C' ) ) { - $ret.= '
  • '.HtmlInput::history_account($line['pcm_val'],'Anomalie pour le compte '.$line['pcm_val'].' '.h($line['pcm_lib']). + $ret.= '
  • '.HtmlInput::history_account($line['pcm_val'],_('Anomalie pour le compte ').$line['pcm_val'].' '.h($line['pcm_lib']). " D: ".$line['amount_debit']. - " C: ".$line['amount_credit']." diff ".(abs($solde_signed))); + " C: ".$line['amount_credit']." diff ".(abs($solde_signed)),"",$exercice); $count++; } diff --git a/include/class/anc_grandlivre.class.php b/include/class/anc_grandlivre.class.php index 6318df941..4139b9765 100644 --- a/include/class/anc_grandlivre.class.php +++ b/include/class/anc_grandlivre.class.php @@ -85,7 +85,8 @@ class Anc_GrandLivre extends Anc_Print (select ad_value from fiche_Detail where f_id=b.f_id and ad_id=23) end as qcode, - jr_pj_number + jr_pj_number, + jr_tech_per from operation_analytique as B join poste_analytique using(po_id) left join jrnx using (j_id) left join jrn on (j_grpt=jr_grpt_id) @@ -227,10 +228,17 @@ class Anc_GrandLivre extends Anc_Print } $class = ($idx % 2 == 0) ? 'even' : 'odd'; $idx++; + // find out exercice + $exercice=""; + if ( $row['jr_tech_per'] != null ) + { + $periode=new Periode($this->db,$row['jr_tech_per']); + $exercice=$periode->get_exercice(); + } $r.=''; $detail = ($row['jr_id'] != null) ? HtmlInput::detail_op($row['jr_id'], $row['jr_internal']) : ''; - $post_detail = ($row['j_poste'] != null) ? HtmlInput::history_account($row['j_poste'], $row['j_poste']) : ''; - $card_detail = ($row['f_id'] != null) ? HtmlInput::history_card($row['f_id'], $row['qcode']) : ''; + $post_detail = ($row['j_poste'] != null) ? HtmlInput::history_account($row['j_poste'], $row['j_poste'],"",$exercice) : ''; + $card_detail = ($row['f_id'] != null) ? HtmlInput::history_card($row['f_id'], $row['qcode'],"",$exercice) : ''; $amount_deb = ($row['oa_debit'] == 't') ? $row['oa_amount'] : 0; $amount_cred = ($row['oa_debit'] == 'f') ? $row['oa_amount'] : 0; $tot_deb = bcadd($tot_deb, $amount_deb); diff --git a/include/lib/html_input.class.php b/include/lib/html_input.class.php index b048154d1..a6fbe212e 100755 --- a/include/lib/html_input.class.php +++ b/include/lib/html_input.class.php @@ -308,10 +308,14 @@ class HtmlInput /** * display a div with the history of the card */ - static function history_card($f_id, $p_mesg, $p_style="") + static function history_card($f_id, $p_mesg, $p_style="",$p_exercice="") { - $view_history=sprintf('%s', - $p_style, $f_id, dossier::id(), $p_mesg); + global $g_user; + if ( $p_exercice=="") { + $p_exercice=$g_user->get_exercice(); + } + $view_history=sprintf('%s', + $p_style, $f_id, dossier::id(),$p_exercice, $p_mesg); return $view_history; } @@ -331,10 +335,14 @@ class HtmlInput /** * display a div with the history of the account */ - static function history_account($p_account, $p_mesg, $p_style="") + static function history_account($p_account, $p_mesg, $p_style="",$p_exercice="") { - $view_history=sprintf('%s', - $p_style, $p_account, dossier::id(), $p_mesg); + global $g_user; + if ( $p_exercice=="") { + $p_exercice=$g_user->get_exercice(); + } + $view_history=sprintf('%s', + $p_style, $p_account, dossier::id(),$p_exercice, $p_mesg); return $view_history; } diff --git a/include/template/ledger_detail_bottom.php b/include/template/ledger_detail_bottom.php index cc8d521d0..713557847 100644 --- a/include/template/ledger_detail_bottom.php +++ b/include/template/ledger_detail_bottom.php @@ -10,7 +10,7 @@ * Variables : $div = popup or box (det[0-9] * */ - +$cn=Dossier::connect(); // Contains all the linked actions $a_followup = Follow_Up::get_all_operation($jr_id); // @@ -23,6 +23,11 @@ $aRap=$oRap->get(); $detail = new Acc_Misc($cn, $obj->jr_id); $detail->get(); + // find out exercice + $periode_id=new Periode($cn,$detail->det->jr_tech_per); + $exercice=$periode_id->get_exercice(); + + $nb_document=($detail->det->jr_pj_name != "")?1:0; @@ -90,14 +95,14 @@ endif; { $row = ''; $q = $detail->det->array; - $view_history = sprintf('%s', $q[$e]['j_poste'], $gDossier, $q[$e]['j_poste']); - + $view_history = HtmlInput::history_account($q[$e]['j_poste'], $q[$e]['j_poste'], "", $exercice); + $row.=td($view_history); if ($q[$e]['j_qcode'] != '') { $fiche = new Fiche($cn); $fiche->get_by_qcode($q[$e]['j_qcode']); - $view_history = sprintf('%s', $fiche->id, $gDossier, $q[$e]['j_qcode']); + $view_history = HtmlInput::history_card($fiche->id, $q[$e]['j_qcode'],"",$exercice); } else $view_history = ''; $row.=td($view_history); diff --git a/include/template/ledger_detail_misc.php b/include/template/ledger_detail_misc.php index 17176c61f..27ce89814 100644 --- a/include/template/ledger_detail_misc.php +++ b/include/template/ledger_detail_misc.php @@ -6,6 +6,10 @@ require_once NOALYSS_TEMPLATE.'/ledger_detail_top.php'; require_once NOALYSS_INCLUDE.'/class/anc_operation.class.php'; require_once NOALYSS_INCLUDE.'/class/anc_plan.class.php'; $str_anc=""; + $cn=Dossier::connect(); + // find out exercice + $periode_id=new Periode($cn,$obj->det->jr_tech_per); + $exercice=$periode_id->get_exercice(); ?> '; $amount_idx=0; for ($e=0;$edet->array);$e++) { $row=''; $q=$obj->det->array; - $view_history= sprintf('%s', - $q[$e]['j_poste'], $gDossier, $q[$e]['j_poste']); - + $view_history = HtmlInput::history_account($q[$e]['j_poste'], $q[$e]['j_poste'], "", $exercice); $row.=td($view_history); if ( $q[$e]['j_qcode'] !='') { $fiche=new Fiche($cn); $fiche->get_by_qcode($q[$e]['j_qcode']); - $view_history= sprintf('%s', - $fiche->id, $gDossier, $q[$e]['j_qcode']); + $view_history=HtmlInput::history_card($fiche->id, $q[$e]['j_qcode'], "", $exercice); } else $view_history=''; diff --git a/include/template/operation_detail_misc.php b/include/template/operation_detail_misc.php index 9b3710e12..967d99d1f 100644 --- a/include/template/operation_detail_misc.php +++ b/include/template/operation_detail_misc.php @@ -40,7 +40,7 @@ for ($e = 0; $e < count($obj->det->array); $e++) { $row = ''; $q = $obj->det->array; - $view_history = sprintf('%s', $q[$e]['j_poste'], $gDossier, $q[$e]['j_poste']); + $view_history = HtmlInput::history_account($q[$e]['j_poste'], $q[$e]['j_poste'], "", $exercice); $row.=td($view_history); @@ -48,7 +48,8 @@ for ($e = 0; $e < count($obj->det->array); $e++) { $fiche = new Fiche($cn); $fiche->get_by_qcode($q[$e]['j_qcode']); - $view_history = sprintf('%s', $fiche->id, $gDossier, $q[$e]['j_qcode']); + $view_history=HtmlInput::history_card($fiche->id, $q[$e]['j_qcode'], "", $exercice); + } else $view_history = ''; From af3febb48526c7791e4e0109871495c36f22c277 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 22 Jan 2018 22:51:07 +0100 Subject: [PATCH 032/265] typo --- include/template/acc_ledger_history_purchase_detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/template/acc_ledger_history_purchase_detail.php b/include/template/acc_ledger_history_purchase_detail.php index e3c5e94f2..ea39c3fc7 100644 --- a/include/template/acc_ledger_history_purchase_detail.php +++ b/include/template/acc_ledger_history_purchase_detail.php @@ -116,7 +116,7 @@ foreach ($this->data as $line) { echo "" . $tva_dna. ""; $a_tva_amount=array(); - foreach ($line['m'] as $lineTVA) + foreach ($line['detail_vat'] as $lineTVA) { foreach ($a_Tva as $idx=>$line_tva) { From d7f716059fe703019a069a72d1098381997eaa9a Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 23 Jan 2018 21:39:44 +0100 Subject: [PATCH 033/265] Missing import of icon_action --- include/admin_repo.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/include/admin_repo.inc.php b/include/admin_repo.inc.php index 701e52ea0..a5aedd0f0 100644 --- a/include/admin_repo.inc.php +++ b/include/admin_repo.inc.php @@ -29,6 +29,7 @@ include_once NOALYSS_INCLUDE."/lib/ac_common.php"; require_once NOALYSS_INCLUDE.'/lib/database.class.php'; require_once NOALYSS_INCLUDE."/lib/user_menu.php"; require_once NOALYSS_INCLUDE."/lib/http_input.class.php"; +require_once NOALYSS_INCLUDE."/lib/icon_action.class.php"; $http=new HttpInput(); $action = $http->request("action","string", ""); From 51b1978eb8cf2bebeb77df7355571ea404a78393 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 23 Jan 2018 22:09:17 +0100 Subject: [PATCH 034/265] =?UTF-8?q?Task=20#0001530:=20R=C3=A9=C3=A9criture?= =?UTF-8?q?=20PRINTJRN=20:=20export=20CSV?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/class/acc_ledger.class.php | 7 +- .../acc_ledger_history_generic.class.php | 65 +++- .../class/acc_ledger_history_sale.class.php | 88 ++++++ include/export/export_ledger_csv.php | 298 +++++++++++------- 4 files changed, 337 insertions(+), 121 deletions(-) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index 5000ce72b..8e5982b52 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -2629,9 +2629,12 @@ class Acc_Ledger extends jrn_def_sql * * \return an Array with the asked data */ - function get_rowSimple($p_from, $p_to, $trunc=0, $p_limit=-1, $p_offset=-1) + function get_rowSimple($p_from, $p_to, $pa_ledger=[],$trunc=0,$p_limit=-1,$p_offset=-1) { - $alh_generic=new Acc_Ledger_History_Generic($this->db, [$this->id], $p_from, $p_to, "A"); + if ( empty($pa_ledger) ) { + $pa_ledger=[$this->id]; + } + $alh_generic=new Acc_Ledger_History_Generic($this->db, $pa_ledger, $p_from, $p_to, "A"); $alh_generic->get_rowSimple($trunc,$p_limit,$p_offset); $data=$alh_generic->get_data(); return $data; diff --git a/include/class/acc_ledger_history_generic.class.php b/include/class/acc_ledger_history_generic.class.php index 8b8a5ce76..15bd2e664 100644 --- a/include/class/acc_ledger_history_generic.class.php +++ b/include/class/acc_ledger_history_generic.class.php @@ -34,6 +34,7 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History { private $data; //!< array of rows + /** * Constructor * @param Database $cn @@ -43,6 +44,7 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History * @param type $p_mode * @example acc_ledger_historyTest.php */ + function __construct(Database $cn, $pa_ledger, $p_from, $p_to, $p_mode) { parent::__construct($cn, $pa_ledger, $p_from, $p_to, $p_mode); @@ -411,7 +413,7 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History function get_rowSimple($trunc=0, $p_limit=-1, $p_offset=-1) { global $g_user; - $jrn=" jrn_def_id in (".join($this->ma_ledger, ",").")" ; + $jrn=" jrn_def_id in (".join($this->ma_ledger, ",").")"; $periode=sql_filter_per($this->db, $this->m_from, $this->m_to, 'p_id', 'jr_tech_per'); @@ -500,7 +502,8 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History jr_pj_number, j_qcode, jrn_def_type, - jr_rapt as oc, j_tech_per as periode + jr_rapt as oc, j_tech_per as periode, + j_id from jrnx left join jrn on jr_grpt_id=j_grpt left join tmp_pcmn on pcm_val=j_poste @@ -605,6 +608,7 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History $this->data=array($array, $tot_deb, $tot_cred); return $Max; } + /** * display in html the detail the list of operation */ @@ -612,6 +616,7 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History { $this->export_accounting_html(); } + /** * display in html with extended detail the list of operation */ @@ -619,12 +624,13 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History { $this->export_accounting_html(); } + /** * display in html the accounting of the list of operations */ public function export_accounting_html() { - + $this->get_row(); echo ''; // detailled printing @@ -661,6 +667,7 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History echo _("solde débiteur:").$this->data[1]."
    "; echo _("solde créditeur:").$this->data[2]; } + /** * @brief list operation on one line per operation */ @@ -733,6 +740,7 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History echo ''; echo "
    "; } + /** * To get data * @return array of rows @@ -741,4 +749,55 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History { return $this->data; } + + /** + * export CSV + */ + function export_csv() + { + $export=new Noalyss_Csv(_('journal')); + $export->send_header(); + + $this->get_row(); + $title=array(); + $title[]=_("operation"); + $title[]=_("N° Pièce"); + $title[]=_("Interne"); + $title[]=_("Date"); + $title[]=_("Poste"); + $title[]=_("QuickCode"); + $title[]=_("Libellé"); + $title[]=_("Débit"); + $title[]=_("Crédit"); + $export->write_header($title); + if (count($this->data)==0) + exit; + $old_id=""; + /** + * @todo add table headers + */ + foreach ($this->data[0] as $idx=>$op) + { + // should clean description : remove tag and '; char + $desc=$op['description']; + $desc=str_replace("", "", $desc); + $desc=str_replace("", "", $desc); + $desc=str_replace("", "", $desc); + $desc=str_replace("", "", $desc); + if ($op['j_id']!="") + $old_id=$op['j_id']; + + $export->add($old_id, "text"); + $export->add($op['jr_pj_number']); + $export->add($op['internal']); + $export->add($op['j_date']); + $export->add($op['poste']); + $export->add($op['j_qcode']); + $export->add($desc); + $export->add($op['deb_montant'], "number"); + $export->add($op['cred_montant'], "number"); + $export->write(); + } + } } + \ No newline at end of file diff --git a/include/class/acc_ledger_history_sale.class.php b/include/class/acc_ledger_history_sale.class.php index d75aa317f..aed349554 100644 --- a/include/class/acc_ledger_history_sale.class.php +++ b/include/class/acc_ledger_history_sale.class.php @@ -224,5 +224,93 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History { return $this->data; } + /** + * export in csv with detail VAT + */ + function export_csv() + { + $export=new Noalyss_Csv(_('journal')); + $export->send_header(); + + $this->get_row(); + $this->prepare_reconcile_date(); + $this->add_vat_info(); + + $own=new Noalyss_Parameter_Folder($this->db); + $title=array(); + $title[]=_('Date'); + $title[]=_("Paiement"); + $title[]=_("operation"); + $title[]=_("Pièce"); + $title[]=_("Fournisseur"); + $title[]=_("Note"); + $title[]=_("interne"); + $title[]=_("HTVA"); + $title[]=_("TVA"); + $title[]=_("TVA annulée"); + + if ( $own->MY_TVA_USE=='Y') + { + $a_Tva=$this->db->get_array("select tva_id,tva_label from tva_rate order by tva_rate,tva_label,tva_id"); + foreach($a_Tva as $line_tva) + { + $title[]="Tva ".$line_tva['tva_label']; + } + } + $title[]=_("TVAC/TTC"); + $title[]=_("opérations liées"); + $export->write_header($title); + + foreach ($this->data as $line) + { + $export->add($line['jr_date']); + $export->add($line['jr_date_paid']); + $export->add($line['jr_id']); + $export->add($line['jr_pj_number']); + $export->add($line['name']." ". + $line["first_name"]." ". + $line["qcode"]); // qp_supplier + $export->add($line['jr_comment']); + $export->add($line['jr_internal']); + $export->add($line['novat'],"number"); + $export->add($line['vat'],"number"); + $export->add($line['tva_sided'],"number"); + + $a_tva_amount=array(); + //- set all TVA to 0 + foreach ($a_Tva as $l) { + $t_id=$l["tva_id"]; + $a_tva_amount[$t_id]=0; + } + foreach ($line['detail_vat'] as $lineTVA) + { + $idx_tva=$lineTVA['qs_vat_code']; + $a_tva_amount[$idx_tva]=$lineTVA['vat_amount']; + } + if ($own->MY_TVA_USE == 'Y' ) + { + foreach ($a_Tva as $line_tva) + { + $a=$line_tva['tva_id']; + $export->add($a_tva_amount[$a],"number"); + } + } + $export->add($line['tvac'],"number"); + /** + * Retrieve payment if any + */ + $ret_reconcile=$this->db->execute('reconcile_date',array($line['jr_id'])); + $max=Database::num_row($ret_reconcile); + if ($max > 0) { + for ($e=0;$e<$max;$e++) { + $row=Database::fetch_array($ret_reconcile, $e); + $export->add($row['jr_date']); + $export->add($row['jr_internal']); + } + } + $export->write(); + + } + } } diff --git a/include/export/export_ledger_csv.php b/include/export/export_ledger_csv.php index 0c1107aab..36689fbda 100644 --- a/include/export/export_ledger_csv.php +++ b/include/export/export_ledger_csv.php @@ -1,4 +1,5 @@ send_header(); */ try { - $get_jrn=$http->get('jrn_id',"number"); - $get_option=$http->get('p_simple',"string"); - $get_from_periode= $http->get('from_periode'); - $get_to_periode=$http->get('to_periode'); - + $get_jrn=$http->get('jrn_id', "number"); + $get_option=$http->get('p_simple', "string"); + $get_from_periode=$http->get('from_periode', 'number'); + $get_to_periode=$http->get('to_periode', 'number'); } catch (Exception $exc) { @@ -58,7 +64,7 @@ catch (Exception $exc) throw $exc; } -require_once NOALYSS_INCLUDE.'/class/user.class.php'; +require_once NOALYSS_INCLUDE.'/class/user.class.php'; $g_user->Check(); $g_user->check_dossier($gDossier); @@ -66,63 +72,121 @@ $g_user->check_dossier($gDossier); // $get_jrn == 0 when request for all ledger, in that case, we must filter // the legder with the security in Acc_Ledger::get_row //---------------------------------------------------------------------------- -if ($get_jrn!=0 && $g_user->check_jrn($get_jrn) =='X') +if ($get_jrn!=0&&$g_user->check_jrn($get_jrn)=='X') { NoAccess(); exit(); } +global $g_user; +/** + * for all ledgers + */ +if ($get_jrn==0) +{ + // Find periode + $periode=new Periode($cn, $get_from_periode); + $exercice=$periode->get_exercice($get_from_periode); -$Jrn=new Acc_Ledger($cn,$get_jrn); + if ($g_user->Admin()==0&&$g_user->is_local_admin()==0&&$g_user->get_status_security_ledger() + ==1) + { + $sql="select jrn_def_id + from jrn_def join jrn_type on jrn_def_type=jrn_type_id + join user_sec_jrn on uj_jrn_id=jrn_def_id + where + uj_login=$1 + and uj_priv in ('R','W') + order by jrn_def_name + and ( jrn_enable=1 + or + exists (select 1 from jrn where jr_tech_per in (select p_id from parm_periode where p_exercice=$2)) + "; + $a_jrn=$cn->get_array($sql, array($g_user->login, $exercice)); + } + else + { + $a_jrn=$cn->get_array("select jrn_def_id + from jrn_def join jrn_type on jrn_def_type=jrn_type_id + where + jrn_enable=1 or exists(select 1 from jrn where jr_tech_per in (select p_id from parm_periode where p_exercice=$1)) + order by jrn_def_name + ", [$exercice]); + } + $a=[]; + $nb_jrn=count($a_jrn); + for ($i=0;$i< $nb_jrn;$i++){ + $a[]=$a_jrn[$i]['jrn_def_id']; + } + $a_jrn=$a; +} +else +{ + $a_jrn=$Jrn->id; +} +$Jrn=new Acc_Ledger($cn, $get_jrn); $Jrn->get_name(); $jrn_type=$Jrn->get_type(); // // With Detail per item which is possible only for VEN or ACH +// For Detailled VAT for ACH or VEN +// ODS or all ledgers becomes A +// Extended but no FIN becomes L // -if ($get_option == 'D') +if ($get_option=='D'||($jrn_type=='ODS'||$Jrn->id==0)&&$get_option=="E") { - if ($jrn_type != 'ACH' && $jrn_type != 'VEN' || $Jrn->id == 0) + if ($jrn_type=='FIN') { - $get_option = 'A'; + $get_option='L'; + } + elseif ($jrn_type=='ODS'||$Jrn->id==0) + { + $get_option='A'; } else { switch ($jrn_type) { case 'VEN': - $ledger = new Acc_Ledger_Sold($cn, $get_jrn); - $ret_detail = $ledger->get_detail_sale($get_from_periode, $get_to_periode); - $a_heading= Acc_Ledger_Sold::heading_detail_sale(); - + $ledger=new Acc_Ledger_Sold($cn, $get_jrn); + $ret_detail=$ledger->get_detail_sale($get_from_periode, + $get_to_periode); + $a_heading=Acc_Ledger_Sold::heading_detail_sale(); + break; case 'ACH': - $ledger = new Acc_Ledger_Purchase($cn, $get_jrn); - $ret_detail = $ledger->get_detail_purchase($get_from_periode, $get_to_periode); - $a_heading= Acc_Ledger_Purchase::heading_detail_purchase(); + $ledger=new Acc_Ledger_Purchase($cn, $get_jrn); + $ret_detail=$ledger->get_detail_purchase($get_from_periode, + $get_to_periode); + $a_heading=Acc_Ledger_Purchase::heading_detail_purchase(); break; default: - die(__FILE__ . ":" . __LINE__ . 'Journal invalide'); + die(__FILE__.":".__LINE__.'Journal invalide'); break; } - if ($ret_detail == null) + if ($ret_detail==null) return; - $nb = Database::num_row($ret_detail); + $nb=Database::num_row($ret_detail); $title=array(); foreach ($a_heading as $key=> $value) { $title[]=$value; } - for ($i = 0;$i < $nb ; $i++) { + for ($i=0; $i<$nb; $i++) + { $row=Database::fetch_array($ret_detail, $i); - if ( $i == 0 ) { + if ($i==0) + { $export->write_header($title); } $a_row=array(); $type="text"; - for ($j=0;$j < count($row) / 2;$j++) { - if ( $j > 18 ) $type="number"; - $export->add($row[$j],$type); + for ($j=0; $j18) + $type="number"; + $export->add($row[$j], $type); } $export->write(); } @@ -132,47 +196,12 @@ if ($get_option == 'D') // Detailled printing // For miscellaneous legder or all ledgers //----------------------------------------------------------------------------- -if ( $get_option == 'A' ) +if ($get_option=='A') { - $Jrn->get_row( $get_from_periode, $get_to_periode ); - $title=array(); - $title[]=_("operation"); - $title[]=_("N° Pièce"); - $title[]=_("Interne"); - $title[]=_("Date"); - $title[]=_("Poste"); - $title[]=_("QuickCode"); - $title[]=_("Libellé"); - $title[]=_("Débit"); - $title[]=_("Crédit"); - $export->write_header($title); - if ( count($Jrn->row) == 0) - exit; - $old_id=""; - /** - * @todo add table headers - */ - foreach ( $Jrn->row as $op ) - { - // should clean description : remove tag and '; char - $desc=$op['description']; - $desc=str_replace("","",$desc); - $desc=str_replace("","",$desc); - $desc=str_replace("","",$desc); - $desc=str_replace("","",$desc); - if ( $op['j_id'] != "") $old_id=$op['j_id']; - - $export->add($old_id,"text"); - $export->add($op['jr_pj_number']); - $export->add($op['internal']); - $export->add($op['j_date']); - $export->add($op['poste']); - $export->add($op['j_qcode']); - $export->add($desc); - $export->add($op['deb_montant'],"number"); - $export->add($op['cred_montant'],"number"); - $export->write(); - } + + $acc_ledger_history=new Acc_Ledger_History_Generic($cn, $a_jrn, + $get_from_periode, $get_to_periode, 'A'); + $acc_ledger_history->export_csv(); exit; } //----------------------------------------------------------------------------- @@ -180,15 +209,33 @@ if ( $get_option == 'A' ) // for Misc the amount // For Financial only the tiers and the sign of the amount //----------------------------------------------------------------------------- -if ($get_option == "L") +if ($get_option=="L") { - + //----------------------------------------------------- - if ( $jrn_type == 'ODS' || $jrn_type == 'FIN' || $jrn_type=='GL') - { - $Row=$Jrn->get_rowSimple($get_from_periode, - $get_to_periode, - 0); + if ($jrn_type=='ODS'||$jrn_type=='FIN'||$jrn_type=='GL') + { + if ( $get_jrn==0) { + $Row=$Jrn->get_rowSimple($get_from_periode, $get_to_periode, $a_jrn); + }else { + $Row=$Jrn->get_rowSimple($get_from_periode, $get_to_periode); + } + $cn->prepare('reconcile_date_csv', + 'select * + from + jrn + where + jr_id in + (select + jra_concerned + from + jrn_rapt + where jr_id = $1 + union all + select + jr_id + from jrn_rapt + where jra_concerned=$1)'); $title=array(); $title[]=_("operation"); $title[]=_("Date"); @@ -199,50 +246,69 @@ if ($get_option == "L") $title[]=_("internal"); $title[]=_("montant"); $export->write_header($title); - foreach ($Row as $line) - { - $tiers_id=$Jrn->get_tiers_id($line['jrn_def_type'],$line['jr_id']); - $fiche_tiers=new Fiche($cn,$tiers_id); - $tiers=$fiche_tiers->strAttribut(ATTR_DEF_NAME,0)." ".$fiche_tiers->strAttribut(ATTR_DEF_FIRST_NAME,0); - - $export->add( $line['num']); - $export->add($line['date']); - $export->add($line['jr_pj_number']); - $export->add($fiche_tiers->get_quick_code()); - $export->add($tiers); - $export->add($line['comment']); - $export->add($line['jr_internal']); - // echo "".$line['pj'].";"; - // If the ledger is financial : - // the credit must be negative and written in red - // Get the jrn type - if ( $line['jrn_def_type'] == 'FIN' ) { - $positive = $cn->get_value("select qf_amount from quant_fin ". - " where jr_id=$1",array($line['jr_id'])); + foreach ($Row as $line) + { + $tiers_id=$Jrn->get_tiers_id($line['jrn_def_type'], $line['jr_id']); + $fiche_tiers=new Fiche($cn, $tiers_id); + $tiers=$fiche_tiers->strAttribut(ATTR_DEF_NAME, 0)." ".$fiche_tiers->strAttribut(ATTR_DEF_FIRST_NAME, + 0); - $export->add($positive,"number"); - $export->add(""); - } - else - { - $export->add($line['montant'],"number"); - } + $export->add($line['num']); + $export->add($line['date']); + $export->add($line['jr_pj_number']); + $export->add($fiche_tiers->get_quick_code()); + $export->add($tiers); + $export->add($line['comment']); + $export->add($line['jr_internal']); + // echo "".$line['pj'].";"; + // If the ledger is financial : + // the credit must be negative and written in red + // Get the jrn type + if ($line['jrn_def_type']=='FIN') + { + $positive=$cn->get_value("select qf_amount from quant_fin ". + " where jr_id=$1", array($line['jr_id'])); - $export->write(); - } - } + $export->add($positive, "number"); + $export->add(""); + } + else + { + $export->add($line['montant'], "number"); + } + //------ Add reconcilied operation --------------- + $ret_reconcile=$cn->execute('reconcile_date_csv', + array($line['jr_id'])); + $max=Database::num_row($ret_reconcile); + if ($max>0) + { + for ($e=0; $e<$max; $e++) + { + $row=Database::fetch_array($ret_reconcile, $e); + $export->add($row['jr_date']); + $export->add($row['jr_internal']); + $export->add($row['jr_pj_number']); + } + } + $export->write(); + } + } //------------------------------------------------------------------------------ // One line summary with tiers, amount VAT, DNA, tva code .... // //------------------------------------------------------------------------------ - if ( $jrn_type == "ACH") { - $acc_ledger_history=new Acc_Ledger_History_Purchase($cn,[$Jrn->id],$get_from_periode,$get_to_periode,'D'); - $acc_ledger_history->export_csv(); - } - if ( $jrn_type == "VEN") { - $acc_ledger_history=new Acc_Ledger_History_Sale($cn,[$Jrn->id],$get_from_periode,$get_to_periode,'D'); - //@todo to implement $acc_ledger_history->export_csv(); - } + if ($jrn_type=="ACH") + { + $acc_ledger_history=new Acc_Ledger_History_Purchase($cn, [$Jrn->id], + $get_from_periode, $get_to_periode, 'D'); + $acc_ledger_history->export_csv(); + } + if ($jrn_type=="VEN") + { + $acc_ledger_history=new Acc_Ledger_History_Sale($cn, [$Jrn->id], + $get_from_periode, $get_to_periode, 'D'); + $acc_ledger_history->export_csv(); + } } ?> From d70852729848bb10a2d2ab9fe3b40234cd258b13 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 23 Jan 2018 22:50:57 +0100 Subject: [PATCH 035/265] Small bug in save_card --- html/js/card.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/html/js/card.js b/html/js/card.js index 33a7624fd..b744126ba 100644 --- a/html/js/card.js +++ b/html/js/card.js @@ -723,9 +723,8 @@ function form_blank_card(obj) function save_card(obj) { var content=$(obj).ipopup; - var accounting= $(obj)['av_text25']; - var accounting= $(obj)['av_text5']; - if ( accounting.value.length > 40 ) { + var accounting= $(obj)['av_text5']; + if ( accounting && accounting.value.length > 40 ) { smoke.alert('Poste comptable trop grand'); return false; } From 553717b0766c738ca737bee122dfea28abc0e0be Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 23 Jan 2018 23:05:14 +0100 Subject: [PATCH 036/265] Small bug in clean card --- include/lib/icard.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/lib/icard.class.php b/include/lib/icard.class.php index 8eac38fcb..b228295fa 100644 --- a/include/lib/icard.class.php +++ b/include/lib/icard.class.php @@ -236,7 +236,7 @@ class ICard extends HtmlInput $e=sprintf(' ondblclick="%s" ', $this->dblclick); $this->dblclick=$e; } - $input=Icon_Action::clean_zone(uniqid("remove"),"{$this->id}=''"); + $input=Icon_Action::clean_zone(uniqid("remove"),"$('{$this->id}').value=''"); $input.=sprintf(' ', From 576f5983a7d82ca506335d5564e81e8704e995d7 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 23 Jan 2018 23:09:54 +0100 Subject: [PATCH 037/265] esthetic --- html/js/scripts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/js/scripts.js b/html/js/scripts.js index 38310dc52..8d2c3074c 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -2875,7 +2875,7 @@ function create_anchor_up() function init_scroll() { var up=new Element('div',{"class":"inner_box", - "style":"padding:5px;left:auto;width:auto;height: auto;display:none;position:fixed;top:25px;right:50px;text-align:center", + "style":"padding:5px;left:auto;width:auto;height: auto;display:none;position:fixed;bottom:25px;right:50px;text-align:center", id:"go_up" }); up.innerHTML=' '; @@ -2883,7 +2883,7 @@ function init_scroll() window.onscroll=function () { if ( document.viewport.getScrollOffsets().top> 0) { if ($('go_up').visible() == false) { - $('go_up').setOpacity(0.70); + $('go_up').setOpacity(0.80); $('go_up').show(); $('go_up').style.zIndex=99; } From c157929c84c4eb9b2c87bcdd8215187593c4d63d Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 24 Jan 2018 19:06:55 +0100 Subject: [PATCH 038/265] before deleting a card , check if it is not used as an attribute in another card --- include/class/fiche.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php index 86c525375..ecc0b5704 100644 --- a/include/class/fiche.class.php +++ b/include/class/fiche.class.php @@ -1984,6 +1984,16 @@ class Fiche [$this->id]); if ( $count > 0 ) return TRUE; + $count=$this->cn->get_value("select count(*) + select count(*) + from attr_def + join fiche_detail using (ad_id) + where ad_type='card' + and ad_value=$1" + ,[$qcode]); + + if ( $count > 0 ) return TRUE; + return FALSE; } /*\brief remove a card without verification */ From 5794634ea02d7a98ce49246ac0363aa1fda1e6f4 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 24 Jan 2018 19:08:09 +0100 Subject: [PATCH 039/265] before deleting a card , check if it is not used as an attribute in another card --- include/class/fiche.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php index ecc0b5704..1da11c7f7 100644 --- a/include/class/fiche.class.php +++ b/include/class/fiche.class.php @@ -1985,7 +1985,6 @@ class Fiche if ( $count > 0 ) return TRUE; $count=$this->cn->get_value("select count(*) - select count(*) from attr_def join fiche_detail using (ad_id) where ad_type='card' From ae33c4d8c46fdfc5060d24503fd473ce2ee2f296 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 24 Jan 2018 19:25:23 +0100 Subject: [PATCH 040/265] =?UTF-8?q?task=20#1531:=20Historique=20poste=20et?= =?UTF-8?q?=20fiche=20d'apr=C3=A8s=20exercice=20op=C3=A9ration=20Fait=20au?= =?UTF-8?q?ssi=20pour=20le=20bouton=20historique?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/lib/html_input.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/lib/html_input.class.php b/include/lib/html_input.class.php index a6fbe212e..f7a0e1a39 100755 --- a/include/lib/html_input.class.php +++ b/include/lib/html_input.class.php @@ -322,12 +322,16 @@ class HtmlInput /** * display a div with the history of the card */ - static function history_card_button($f_id, $p_mesg) + static function history_card_button($f_id, $p_mesg,$p_exercice="") { static $e=0; $e++; - $js=sprintf('onclick="view_history_card(\'%s\',\'%s\')"', $f_id, - dossier::id()); + global $g_user; + if ( $p_exercice=="") { + $p_exercice=$g_user->get_exercice(); + } + $js=sprintf('onclick="view_history_card(\'%s\',\'%s\',\'%s\')"', $f_id, + dossier::id(),$p_exercice); $view_history=HtmlInput::button("hcb"+$e, $p_mesg, $js); return $view_history; } From 3a75262184cd7d0f222552d4c087d67b0c4d4b35 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 25 Jan 2018 09:49:32 +0100 Subject: [PATCH 041/265] =?UTF-8?q?Esth=C3=A9tique=20Recherche=20action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/template/action_search.php | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/include/template/action_search.php b/include/template/action_search.php index 5e1550309..703ac3b9b 100644 --- a/include/template/action_search.php +++ b/include/template/action_search.php @@ -26,22 +26,18 @@ * */ ?> - -