class_anc_listing.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of PhpCompta.
00004  *
00005  *   PhpCompta is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   PhpCompta is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with PhpCompta; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 /* $Revision: 4373 $ */
00020 
00021 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00022 
00023 /*!\file
00024  * \brief definition of Anc_Listing
00025  */
00026 
00027 require_once("class_ihidden.php");
00028 require_once ('class_anc_plan.php');
00029 require_once ('class_anc_print.php');
00030 require_once ('class_anc_operation.php');
00031 /*!
00032  * \brief manage the CA listing
00033  *
00034  * \return
00035  */
00036 
00037 class Anc_Listing extends Anc_Print
00038 {
00039     function display_form($p_string="")
00040     {
00041         echo '<form method="get">';
00042         $r=parent::display_form($p_string);
00043         $r.=HtmlInput::submit('result','Afficher');
00044         $r.= '</form>';
00045         return $r;
00046 
00047     }
00048     /*!
00049      * \brief complete the object with the data in $_REQUEST
00050      */
00051 
00052     function get_request()
00053     {
00054         parent::get_request();
00055         $this->pa_id=(isset($_REQUEST['pa_id']))?$_REQUEST['pa_id']:"";
00056     }
00057     /*!
00058      * \brief compute the html display
00059      *
00060      *
00061      * \return string
00062      */
00063 
00064     function display_html()
00065     {
00066         $r="";
00067         //---Html
00068         $array=$this->load();
00069         if ( is_array($array) == false )
00070         {
00071             return $array;
00072 
00073         }
00074 
00075         if ( empty($array) )
00076         {
00077             $r.= _("aucune donnée");
00078             return $r;
00079         }
00080         $r.= '<table class="result" style="width=100%">';
00081         $r.= '<tr>'.
00082              '<th>'._('Date').'</th>'.
00083              '<th>'._('Poste').'</th>'.
00084              '<th>'._('Quick_code').'</th>'.
00085              '<th>'._('Analytique').'</th>'.
00086           th(_('Description')).
00087              '<th>'._('libelle').'</th>'.
00088              '<th>'._('Num.interne').'</th>'.
00089              '<th>'._('Montant').'</th>'.
00090              '<th>'._('D/C').'</th>'.
00091              '</tr>';
00092         foreach ( $array as $row )
00093         {
00094             $r.= '<tr>';
00095             $detail=($row['jr_id'] != null)?HtmlInput::detail_op($row['jr_id'],$row['jr_internal']):'';
00096             $post_detail=($row['j_poste'] != null)?HtmlInput::history_account($row['j_poste'],$row['j_poste']):'';
00097             $card_detail=($row['f_id'] != null)?HtmlInput::history_card($row['f_id'],$row['qcode']):'';
00098 
00099             $r.=
00100                 '<td>'.$row['oa_date'].'</td>'.
00101               td($post_detail).
00102               td($card_detail).
00103               '<td>'.h($row['po_name']).'</td>'.
00104               '<td>'.h($row['oa_description']).'</td>'.
00105               td($row['jr_comment']).
00106               '<td>'.$detail.'</td>'.
00107               '<td class="num">'.nbm($row['oa_amount']).'</td>'.
00108                 '<td>'.(($row['oa_debit']=='f')?'CREDIT':'DEBIT').'</td>';
00109             $r.= '</tr>';
00110         }
00111         $r.= '</table>';
00112         return $r;
00113     }
00114     /*!
00115      * \brief load the data from the database
00116      *
00117      * \return array
00118      */
00119     function load()
00120     {
00121         $op=new Anc_Operation ($this->db);
00122         $op->pa_id=$this->pa_id;
00123         $array=$op->get_list($this->from,$this->to,$this->from_poste,$this->to_poste);
00124         return $array;
00125     }
00126     /*!
00127      * \brief Compute the csv export
00128      * \return string with the csv
00129      */
00130 
00131     function display_csv()
00132     {
00133         $array=$this->load($this->from,$this->to,$this->from_poste,$this->to_poste);
00134         if ( empty($array) == true )
00135         {
00136             return $array;
00137 
00138         }
00139         $r="";
00140         foreach ( $array as $row)
00141         {
00142             // the name and po_id
00143             $r.=sprintf('"%s";',$row['oa_date']);
00144             $r.=sprintf('"%s";',$row['j_poste']);
00145             $r.=sprintf('"%s";',$row['qcode']);
00146             $r.=sprintf('"%s";',$row['po_name']);
00147             $r.=sprintf('"%s";',$row['oa_description']);
00148             $r.=sprintf('"%s";',$row['oa_description']);
00149 
00150             $r.=sprintf("%12.2f;",$row['oa_amount']);
00151             $r.=sprintf("'%s'",(($row['oa_debit']=='f')?'CREDIT':'DEBIT'));
00152             $r.="\r\n";
00153         }
00154         return $r;
00155 
00156     }
00157 
00158     /*!
00159      * \brief show the export button to pdf and CSV
00160      * \param $p_string string containing some HTML tag as hidden field
00161      * \param
00162      * \param
00163      *
00164      *
00165      * \return string containing the html code
00166      */
00167     function show_button($p_string='')
00168     {
00169         $r="";
00170         $submit=HtmlInput::submit('','');
00171         $hidden=new IHidden();
00172         /* for the export in PDF
00173          * Not yet needed, the html print should be enough
00174         $r.= '<form method="GET" action="ca_list_pdf.php" style="display:inline">';
00175         $r.= $p_string;
00176         $r.= dossier::hidden();
00177         $r.= $hidden->input("to",$this->to);
00178         $r.= $hidden->input("from",$this->from);
00179         $r.= $hidden->input("pa_id",$this->pa_id);
00180         $r.= $hidden->input("from_poste",$this->from_poste);
00181         $r.= $hidden->input("to_poste",$this->to_poste);
00182         $r.=HtmlInput::submit('bt_pdf',"Export en PDF");
00183         $r.= '</form>';
00184         */
00185 
00186         $r.= '<form method="GET" action="export.php"  style="display:inline">';
00187         $r.= HtmlInput::hidden("to",$this->to);
00188         $r.= HtmlInput::hidden("from",$this->from);
00189         $r.= HtmlInput::hidden("pa_id",$this->pa_id);
00190         $r.= HtmlInput::hidden("from_poste",$this->from_poste);
00191         $r.= HtmlInput::hidden("to_poste",$this->to_poste);
00192         $r.=HtmlInput::hidden('act','CSV:AncList');
00193         $r.=HtmlInput::hidden('ac',$_REQUEST['ac']);
00194         $r.= $p_string;
00195         $r.= dossier::hidden();
00196         $r.=HtmlInput::submit('bt_csv',"Export en CSV");
00197         $r.= '</form>';
00198         return $r;
00199 
00200     }
00201     /*!
00202      * \brief debugging and test function for dev. only
00203      * \param
00204      * \param
00205      * \param
00206      *
00207      *
00208      * \return
00209      */
00210     static  function test_me()
00211     {
00212     }
00213 }