From cbe2a6a56526ad79d32520fe2fd6eed0fb58ba9c Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 14 May 2011 19:23:06 +0000 Subject: [PATCH] ANC List --- include/class_anc_acc_list.php | 483 +++++++++++++++++++++++++++++++++ 1 file changed, 483 insertions(+) create mode 100644 include/class_anc_acc_list.php diff --git a/include/class_anc_acc_list.php b/include/class_anc_acc_list.php new file mode 100644 index 000000000..add41b3b7 --- /dev/null +++ b/include/class_anc_acc_list.php @@ -0,0 +1,483 @@ +value=array( + array('value'=>1,'label'=>'Par fiche /Poste Analytique'), + array('value'=>2,'label'=>'Par poste comptable/Poste Analytique'), + array('value'=>3,'label'=>'Par poste Analytique/Fiche'), + array('value'=>4,'label'=>'Par poste Analytique/Poste Comptable') + + ); + + $icard->selected=$this->card_poste; + $r.=$icard->input(); + return $r; + } + /** + * load the data + * does not return anything but give a value to this->aheader and this->arow + */ + function load_anc_account() + { + $date=$this->set_sql_filter(); + $date=($date != '')?" $date":''; + $sql_from_poste=($this->from_poste!='')?" and po.po_name >= upper('".Database::escape_string($this->from_poste)."')":''; + $sql_to_poste=($this->to_poste!='')?" and po.po_name <= upper('".Database::escape_string($this->to_poste)."')":''; + $this->arow=$this->db->get_array(" SELECT po_id, pa_id, po_name, po_description, sum_amount, j_poste, name + FROM v_table_analytic_account + where + pa_id=$1 ".$date.$sql_from_poste.$sql_to_poste." order by po_id,j_poste",array($this->pa_id)); + + } + /** + * load the data + * does not return anything but give a value to this->aheader and this->arow + */ + function load_anc_card() + { + $date=$this->set_sql_filter(); + $date=($date != '')?" $date":''; + $sql_from_poste=($this->from_poste!='')?" and po.po_name >= upper('".Database::escape_string($this->from_poste)."')":''; + $sql_to_poste=($this->to_poste!='')?" and po.po_name <= upper('".Database::escape_string($this->to_poste)."')":''; + + $this->arow=$this->db->get_array(" SELECT po_id, pa_id, po_name, po_description, oa_date, sum_amount, f_id, + j_qcode, name + FROM v_table_analytic_card + where + pa_id=$1 ".$date.$sql_from_poste.$sql_to_poste." order by po_id,name",array($this->pa_id)); + + } + + /** + * load the data + * does not return anything but give a value to this->aheader and this->arow + */ + function load_poste() + { + $date=$this->set_sql_filter(); + $date=($date != '')?" $date":''; + $sql_from_poste=($this->from_poste!='')?" and po.po_name >= upper('".Database::escape_string($this->from_poste)."')":''; + $sql_to_poste=($this->to_poste!='')?" and po.po_name <= upper('".Database::escape_string($this->to_poste)."')":''; + $this->arow=$this->db->get_array(" SELECT po_id, pa_id, po_name, po_description, sum_amount, j_poste, name + FROM v_table_analytic_account + where + pa_id=$1 ".$date.$sql_from_poste.$sql_to_poste." order by j_poste,po_name",array($this->pa_id)); + + } + + /** + * load the data + * does not return anything but give a value to this->aheader and this->arow + */ + function load_card() + { + $date=$this->set_sql_filter(); + $date=($date != '')?" $date":''; + $sql_from_poste=($this->from_poste!='')?" and po.po_name >= upper('".Database::escape_string($this->from_poste)."')":''; + $sql_to_poste=($this->to_poste!='')?" and po.po_name <= upper('".Database::escape_string($this->to_poste)."')":''; + + $this->arow=$this->db->get_array(" SELECT po_id, pa_id, po_name, po_description, oa_date, sum_amount, f_id, + j_qcode, name + FROM v_table_analytic_card + where + pa_id=$1 ".$date.$sql_from_poste.$sql_to_poste." order by name,po_name",array($this->pa_id)); + + } + /** + *@brief display the button export CSV + *@param $p_hidden is a string containing hidden items + *@return html string + */ + function show_button($p_hidden) + { + $r=""; + $r.= '
'; + $r.= HtmlInput::hidden("act","CSV/AncAccList"); + $r.= HtmlInput::hidden("to",$this->to); + $r.= HtmlInput::hidden("from",$this->from); + $r.= HtmlInput::hidden("pa_id",$this->pa_id); + $r.= HtmlInput::hidden("from_poste",$this->from_poste); + $r.= HtmlInput::hidden("to_poste",$this->to_poste); + $r.= HtmlInput::hidden("card_poste",$this->card_poste); + + $r.= $p_hidden; + $r.= dossier::hidden(); + $r.=HtmlInput::submit('bt_csv',"Export en CSV"); + $r.= '
'; + return $r; + } + function display_html() + { + bcscale(2); + //--------------------------------------------------------------------------- + // Card - Acc + //--------------------------------------------------------------------------- + + if ( $this->card_poste=='1') + { + $this->load_card(); + + /* + * Show all the result + */ + $tot_card=0;$prev=''; + echo ''; + $tot_glob=0; + for ($i=0;$iarow);$i++) + { + if ( $i == 0 ) + { + $prev=$this->arow[$i]['f_id']; + echo ''; + } + $style= ( $i % 2 == 0)?' class="odd" ':' class="even" '; + if ( $i != 0 && $prev != $this->arow[$i]['f_id']) + { + echo td('Total'); + echo td(nbm($tot_card),' class="num"'); + echo ''; + echo ''; + $tot_card=0; + $prev = $this->arow[$i]['f_id']; + } + + echo ''; + $amount=$this->arow[$i]['sum_amount']; + if ($amount==null)$amount=0; + + $tot_card=bcadd($tot_card,$amount); + $tot_glob=bcadd($tot_glob,$amount); + echo td($this->arow[$i]['po_name']." ". + $this->arow[$i]['po_description'],'style="padding-left:10"'); + echo td(nbm($amount),' class="num" '); + echo ''; + + } + echo ''; + echo td('Total'); + echo td(nbm($tot_card),' class="num"'); + echo ''; + + echo '
'.HtmlInput::history_card ($this->arow[$i]['f_id'],$this->arow[$i]['j_qcode'].' '.$this->arow[$i]['name'],' display:inline').'
'.HtmlInput::history_card($this->arow[$i]['f_id'],$this->arow[$i]['j_qcode'].' '.$this->arow[$i]['name'],' display:inline ').'
'; + echo '

Résultat global '.nbm($tot_glob).'

'; + } + //--------------------------------------------------------------------------- + // Accountancy - Analytic + //--------------------------------------------------------------------------- + + if ( $this->card_poste=='2') + { + $this->load_poste(); + /* + * Show all the result + */ + $tot_card=0;$prev=''; + echo ''; + $tot_glob=0; + for ($i=0;$iarow);$i++) + { + if ( $i == 0 ) + { + $prev=$this->arow[$i]['j_poste']; + echo ''; + } + $style= ( $i % 2 == 0)?' class="odd" ':' class="even" '; + if ( $i != 0 && $prev != $this->arow[$i]['j_poste']) + { + echo td('Total'); + echo td(nbm($tot_card),' class="num"'); + echo ''; + echo ''; + $tot_card=0; + $prev = $this->arow[$i]['j_poste']; + } + + echo ''; + $amount=$this->arow[$i]['sum_amount']; + if ($amount==null)$amount=0; + + $tot_card=bcadd($tot_card,$amount); + $tot_glob=bcadd($tot_glob,$amount); + + + echo td($this->arow[$i]['po_name']." ". + $this->arow[$i]['po_description'],'style="padding-left:10"'); + echo td(nbm($amount),' class="num" '); + echo ''; + + } + echo ''; + echo td('Total'); + echo td(nbm($tot_card),' class="num"'); + echo ''; + + echo '
'.HtmlInput::history_account ($this->arow[$i]['j_poste'],$this->arow[$i]['j_poste'].' '.$this->arow[$i]['name'],' display:inline').'
'.HtmlInput::history_card($this->arow[$i]['j_poste'],$this->arow[$i]['j_poste'].' '.$this->arow[$i]['name'],' display:inline ').'
'; + echo td(nbm($tot_card),' class="num"'); + } + //--------------------------------------------------------------------------- + // Acc after card + //--------------------------------------------------------------------------- + if ( $this->card_poste=='3') + { + $this->load_anc_card(); + /* + * Show all the result + */ + $tot_card=0;$prev=''; + echo ''; + $tot_glob=0; + for ($i=0;$iarow);$i++) + { + if ( $i == 0 ) + { + $prev=$this->arow[$i]['po_id']; + echo ''; + + } + $style= ( $i % 2 == 0)?' class="odd" ':' class="even" '; + if ( $i != 0 && $prev != $this->arow[$i]['po_id']) + { + echo td('Total'); + echo td(nbm($tot_card),' class="num"'); + echo ''; + echo ''; + + $tot_card=0; + $prev = $this->arow[$i]['po_id']; + } + + echo ''; + $amount=$this->arow[$i]['sum_amount']; + if ($amount==null)$amount=0; + + $tot_card=bcadd($tot_card,$amount); + $tot_glob=bcadd($tot_glob,$amount); + echo ''; + + echo td(nbm($amount),' class="num" '); + echo ''; + + } + echo ''; + echo td('Total'); + echo td(nbm($tot_card),' class="num"'); + echo ''; + + echo '
'.$this->arow[$i]['po_name']." ".$this->arow[$i]['po_description'].'
'.$this->arow[$i]['po_name']." ".$this->arow[$i]['po_description'].'
'.HtmlInput::history_card ($this->arow[$i]['f_id'],$this->arow[$i]['f_id'].' '.$this->arow[$i]['name'],' display:inline').'
'; + echo td(nbm($tot_card),' class="num"'); + } + //--------------------------------------------------------------------------- + // Analytic - Accountancy + //--------------------------------------------------------------------------- + + + if ( $this->card_poste=='4') + { + $this->load_anc_account(); + + /* + * Show all the result + */ + $tot_card=0;$prev=''; + echo ''; + $tot_glob=0; + for ($i=0;$iarow);$i++) + { + if ( $i == 0 ) + { + $prev=$this->arow[$i]['po_id']; + echo ''; + } + $style= ( $i % 2 == 0)?' class="odd" ':' class="even" '; + if ( $i != 0 && $prev != $this->arow[$i]['po_id']) + { + echo td('Total'); + echo td(nbm($tot_card),' class="num"'); + echo ''; + + $tot_card=0; + $prev = $this->arow[$i]['po_id']; + echo ''; + + } + + echo ''; + $amount=$this->arow[$i]['sum_amount']; + if ($amount==null)$amount=0; + + $tot_card=bcadd($tot_card,$amount); + $tot_glob=bcadd($tot_glob,$amount); + echo ''; + echo td(nbm($amount),' class="num" '); + echo ''; + + } + echo ''; + echo td('Total'); + echo td(nbm($tot_card),' class="num"'); + echo ''; + + echo '
'.$this->arow[$i]['po_name']." ".$this->arow[$i]['po_description'].'
'.$this->arow[$i]['po_name']." ".$this->arow[$i]['po_description'].'
'.HtmlInput::history_account ($this->arow[$i]['j_poste'],$this->arow[$i]['j_poste'].' '.$this->arow[$i]['name'],' display:inline').'
'; + echo '

Résultat global '.nbm($tot_glob).'

'; + } + + } + function export_csv() + { + bcscale(2); + + //--------------------------------------------------------------------------- + // Card - Acc + //--------------------------------------------------------------------------- + + if ( $this->card_poste=='1') + { + $this->load_card(); + + /* + * Show all the result + */ + $prev=''; + + + for ($i=0;$iarow);$i++) + { + printf('"%s";" %s"', $this->arow[$i]['j_qcode'],$this->arow[$i]['name']); + + $amount=$this->arow[$i]['sum_amount']; + if ($amount==null)$amount=0; + + printf(';"%s";" %s";', + $this->arow[$i]['po_name'], + $this->arow[$i]['po_description']); + printf("%s",nb($amount)); + printf("\r\n"); + } + } + //--------------------------------------------------------------------------- + // Accountancy - Analytic + //--------------------------------------------------------------------------- + + if ( $this->card_poste=='2') + { + $this->load_poste(); + /* + * Show all the result + */ + for ($i=0;$iarow);$i++) + { + printf('"%s";" %s"', $this->arow[$i]['j_poste'],$this->arow[$i]['name']); + + $amount=$this->arow[$i]['sum_amount']; + if ($amount==null)$amount=0; + + printf(';"%s";" %s";', + $this->arow[$i]['po_name'], + $this->arow[$i]['po_description']); + printf("%s",nb($amount)); + printf("\r\n"); + + + } + + } + //--------------------------------------------------------------------------- + // Acc after card + //--------------------------------------------------------------------------- + if ( $this->card_poste=='3') + { + $this->load_anc_card(); + /* + * Show all the result + */ + for ($i=0;$iarow);$i++) + { + printf('"%s";" %s";', $this->arow[$i]['po_name'],$this->arow[$i]['po_description']); + + $amount=$this->arow[$i]['sum_amount']; + if ($amount==null)$amount=0; + + printf('"%s";"%s";', + $this->arow[$i]['j_qcode'], + $this->arow[$i]['name']); + printf("%s",nb($amount)); + printf("\r\n"); + + + } + } + //--------------------------------------------------------------------------- + // Analytic - Accountancy + //--------------------------------------------------------------------------- + + + if ( $this->card_poste=='4') + { + $this->load_anc_account(); + + /* + * Show all the result + */ + for ($i=0;$iarow);$i++) + { + printf('"%s";"%s";', $this->arow[$i]['po_name'],$this->arow[$i]['po_description']); + + $amount=$this->arow[$i]['sum_amount']; + if ($amount==null)$amount=0; + + printf('"%s";"%s";', + $this->arow[$i]['j_poste'], + $this->arow[$i]['name']); + printf("%s",nb($amount)); + printf("\r\n"); + + + } + } + + + + + } + +} \ No newline at end of file