From 25cda2ef7c35af14b65d0b717ac4d12bb2fe8f65 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 15 Oct 2015 10:37:37 +0200 Subject: [PATCH] Put a button export CSV & PDF into the inner windows for the history of card and accounting --- include/ajax/ajax_history.php | 19 +++++-- include/class/class_acc_account_ledger.php | 66 ++++++++++++++++++---- include/class/class_fiche.php | 44 +++++++++++++++ 3 files changed, 113 insertions(+), 16 deletions(-) diff --git a/include/ajax/ajax_history.php b/include/ajax/ajax_history.php index 3fd225ef0..cb2119e25 100644 --- a/include/ajax/ajax_history.php +++ b/include/ajax/ajax_history.php @@ -87,7 +87,7 @@ if ( isset($_GET['f_id'])) } else { - $old='
'; + $old=''; $is=$exercice->select('ex',$default,'onchange = "submit(this)"'); $old.=_("Autre exercice")." ".$is->input(); $old.=HtmlInput::hidden('div','popup'); @@ -108,7 +108,10 @@ if ( isset($_GET['f_id'])) if ( $fiche->HtmlTable($array,0,$from_div)==-1){ echo h2(_("Aucune opération pour l'exercice courant"),'class="error"'); - } + } else { + echo $fiche->button_csv($array['from_periode'],$array['to_periode']); + echo $fiche->button_pdf($array['from_periode'],$array['to_periode']); + } echo $old; @@ -159,7 +162,7 @@ if ( isset($_REQUEST['pcm_val'])) } else { - $old=''; + $old=''; $is=$exercice->select('ex',$default,'onchange = "submit(this)"'); $old.=_("Autre exercice")." ".$is->input(); $old.=HtmlInput::hidden('div','popup'); @@ -175,12 +178,18 @@ if ( isset($_REQUEST['pcm_val'])) ob_start(); require_once NOALYSS_INCLUDE.'/template/history_top.php'; - + + + if ( $poste->HtmlTable($array) == -1) { echo h2($poste->id." ".$poste->name,' class="title"'); echo h2(_("Aucune opération pour l'exercice courant"),'class="error"'); - } + } else { + + echo $poste->button_csv($array['from_periode'],$array['to_periode']); + echo $poste->button_pdf($array['from_periode'],$array['to_periode']); + } echo $old; $html=ob_get_contents(); diff --git a/include/class/class_acc_account_ledger.php b/include/class/class_acc_account_ledger.php index 274039d64..f35a93983 100644 --- a/include/class/class_acc_account_ledger.php +++ b/include/class/class_acc_account_ledger.php @@ -635,17 +635,61 @@ class Acc_Account_Ledger $sql=substr($sql,0,strlen($sql)-2); return $sql; } - /** - * Find the id of the cards which are using the current account - * - * @return an array of f_id - */ - function find_card() - { - $sql="select f_id from fiche_detail where ad_id=$1 and ad_value=$2"; - $account=$this->db->get_array($sql,array(ATTR_DEF_ACCOUNT,$this->id)); - return $account; - } + /** + * Find the id of the cards which are using the current account + * + * @return an array of f_id + */ + function find_card() + { + $sql="select f_id from fiche_detail where ad_id=$1 and ad_value=$2"; + $account=$this->db->get_array($sql,array(ATTR_DEF_ACCOUNT,$this->id)); + return $account; + } + /** + * @brief Return a string with the HTML code to display a button to export the + * history in CSV + * @param type $p_from from date (DD.MM.YYYY) + * @param type $p_to to date (DD.MM.YYYY) + * @return HTML string + */ + function button_csv($p_from,$p_to) { + $href="export.php?".http_build_query( + array( + "gDossier"=>Dossier::id(), + "poste_id"=>$this->id, + "ople"=>0, + "type"=>"poste", + "from_periode"=>$p_from, + "to_periode"=>$p_to, + "act"=>"CSV:postedetail" + ) + ); + return ''._("Export CSV").''; + + } + /** + * @brief Return a string with the HTML code to display a button to export the + * history in PDF + * @param type $p_from from date (DD.MM.YYYY) + * @param type $p_to to date (DD.MM.YYYY) + * @return HTML string + */ + function button_pdf($p_from,$p_to) { + $href="export.php?".http_build_query( + array( + "gDossier"=>Dossier::id(), + "poste_id"=>$this->id, + "ople"=>0, + "type"=>"poste", + "from_periode"=>$p_from, + "to_periode"=>$p_to, + "act"=>"PDF:postedetail" + ) + ); + return ''._("Export PDF").''; + + } static function test_me() { $cn=Dossier::connect(); diff --git a/include/class/class_fiche.php b/include/class/class_fiche.php index 6e7e211e0..d6ab88762 100644 --- a/include/class/class_fiche.php +++ b/include/class/class_fiche.php @@ -1987,6 +1987,50 @@ class Fiche { } + /** + * @brief Return a string with the HTML code to display a button to export the + * history in CSV + * @param type $p_from from date (DD.MM.YYYY) + * @param type $p_to to date (DD.MM.YYYY) + * @return HTML string + */ + function button_csv($p_from,$p_to) { + $href="export.php?".http_build_query( + array( + "gDossier"=>Dossier::id(), + "f_id"=>$this->id, + "ople"=>0, + "type"=>"poste", + "from_periode"=>$p_from, + "to_periode"=>$p_to, + "act"=>"CSV:fichedetail" + ) + ); + return ''._("Export CSV").''; + + } + /** + * @brief Return a string with the HTML code to display a button to export the + * history in PDF + * @param type $p_from from date (DD.MM.YYYY) + * @param type $p_to to date (DD.MM.YYYY) + * @return HTML string + */ + function button_pdf($p_from,$p_to) { + $href="export.php?".http_build_query( + array( + "gDossier"=>Dossier::id(), + "f_id"=>$this->id, + "ople"=>0, + "type"=>"poste", + "from_periode"=>$p_from, + "to_periode"=>$p_to, + "act"=>"PDF:fichedetail" + ) + ); + return ''._("Export PDF").''; + + } } ?>