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