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();