noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
impress_gl_comptes.inc.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 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00020 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00021 require_once("class_ispan.php");
00022 require_once("class_icard.php");
00023 require_once("class_iselect.php");
00024 require_once("class_icheckbox.php");
00025 require_once('class_acc_operation.php');
00026 /*! \file
00027  * \brief Print account (html or pdf)
00028  *        file included from user_impress
00029  *
00030  * some variable are already defined $cn, $g_user ...
00031  *
00032  */
00033 //-----------------------------------------------------
00034 // Show the jrn and date
00035 //-----------------------------------------------------
00036 require_once('class_database.php');
00037 global $g_user;
00038 //-----------------------------------------------------
00039 // Form
00040 //-----------------------------------------------------
00041 echo '<div class="content">';
00042 
00043 echo '<FORM action="?" METHOD="GET">';
00044 echo HtmlInput::hidden('ac',$_REQUEST['ac']);
00045 echo HtmlInput::hidden('type','gl_comptes');
00046 echo dossier::hidden();
00047 echo '<TABLE><TR>';
00048 
00049 $cn=new Database(dossier::id());
00050 $periode=new Periode($cn);
00051 $a=$periode->get_limit($g_user->get_exercice());
00052 // $a is an array
00053 $first_day=$a[0]->first_day();
00054 $last_day=$a[1]->last_day();
00055 
00056 // filter on period
00057 $date_from=new IDate('from_periode');
00058 $date_to=new IDate('to_periode');
00059 $year=$g_user->get_exercice();
00060 $date_from->value=(isset($_REQUEST['from_periode'])&& isDate($_REQUEST['from_periode'])!=0)?$_REQUEST['from_periode']:$first_day;
00061 $date_to->value=(isset($_REQUEST['to_periode']) && isDate($_REQUEST['to_periode']) !=0  )?$_REQUEST['to_periode']:$last_day;
00062 echo td(_('Depuis').$date_from->input());
00063 echo td(_('Jusque ').$date_to->input());
00064 
00065 $letter=new ICheckbox('letter');
00066 $letter->selected=(isset($_REQUEST['letter']))?true:false;
00067 
00068 $from_poste=new IPoste('from_poste');
00069 $from_poste->value=HtmlInput::default_value('from_poste','',$_REQUEST);
00070 $from_poste->set_attribute('account','from_poste');
00071 
00072 $to_poste=new IPoste('to_poste');
00073 $to_poste->value=HtmlInput::default_value('to_poste','',$_REQUEST);
00074 $to_poste->set_attribute('account','to_poste');
00075 
00076 $solded=new ICheckbox('solded');
00077 $solded->selected=(isset($_REQUEST['solded']))?true:false;
00078 
00079 echo '<tr>';
00080 echo td(_('Depuis le poste')).td($from_poste->input());
00081 echo '</tr>';
00082 
00083 echo '<tr>';
00084 echo td(_("Jusqu'au poste")).td($to_poste->input());
00085 echo '</tr>';
00086 
00087 echo '<tr>';
00088 echo td('Uniquement les opérations non lettrées');
00089 echo td($letter->input());
00090 echo '</tr>';
00091 
00092 echo '<tr>';
00093 echo td('Uniquement les comptes non soldés');
00094 echo td($solded->input());
00095 echo '</tr>';
00096 
00097 
00098 //
00099 echo '</TABLE>';
00100 print HtmlInput::submit('bt_html','Visualisation');
00101 
00102 echo '</FORM>';
00103 echo '<hr>';
00104 echo '</div>';
00105 
00106 //-----------------------------------------------------
00107 // If print is asked
00108 // First time in html
00109 // after in pdf or cvs
00110 //-----------------------------------------------------
00111 if ( isset( $_REQUEST['bt_html'] ) )
00112 {
00113   require_once("class_acc_account_ledger.php");
00114   echo '<div class="content">';
00115     echo Acc_Account_Ledger::HtmlTableHeader("gl_comptes");
00116     echo '</div>';
00117     $sql='select pcm_val from tmp_pcmn ';
00118     $cond_poste='';
00119 
00120     if ($from_poste->value != '')
00121       {
00122                 $cond_poste = '  where ';
00123                 $cond_poste .=' pcm_val >= upper (\''.Database::escape_string($from_poste->value).'\')';
00124       }
00125 
00126     if ( $to_poste->value != '')
00127       {
00128         if  ( $cond_poste == '')
00129           {
00130             $cond_poste =  ' where pcm_val <= upper (\''.Database::escape_string($to_poste->value).'\')';
00131           }
00132         else
00133           {
00134             $cond_poste.=' and pcm_val <= upper (\''.Database::escape_string($to_poste->value).'\')';
00135           }
00136       }
00137 
00138     $sql=$sql.$cond_poste.'  order by pcm_val::text';
00139 
00140     $a_poste=$cn->get_array($sql);
00141 
00142     if ( sizeof($a_poste) == 0 )
00143     {
00144         die("Nothing here. Strange.");
00145         exit;
00146     }
00147     if ( isDate($_REQUEST['from_periode'])==null || isDate($_REQUEST['to_periode'])==null)
00148     {
00149         echo alert('Date malformée, désolée');
00150         exit();
00151     }
00152     echo '<div class="content">';
00153 
00154 
00155     echo '<table class="result">';
00156         $l=(isset($_REQUEST['letter']))?2:0;
00157         $s=(isset($_REQUEST['solded']))?1:0;
00158 
00159     foreach ($a_poste as $poste_id )
00160     {
00161         $Poste=new Acc_Account_Ledger ($cn, $poste_id['pcm_val']);
00162         $Poste->load();
00163 
00164 
00165         $Poste->get_row_date( $_GET['from_periode'], $_GET['to_periode'],$l,$s);
00166         if ( empty($Poste->row))
00167         {
00168             continue;
00169         }
00170 
00171 
00172         echo '<tr >
00173         <td colspan="8" style="width:auto">
00174         <h2 class="info">'. $poste_id['pcm_val'].' '.h($Poste->label).'</h2>
00175         </td>
00176         </tr>';
00177 
00178         echo '<tr>
00179         <td>Date</td>
00180         <td>R&eacute;f&eacute;rence</td>
00181         <td>Libell&eacute;</td>
00182         <td>Pi&egrave;ce</td>
00183         <td align="right">D&eacute;bit</td>
00184         <td align="right">Cr&eacute;dit</td>
00185         <td align="right">Solde</td>
00186         <td align="right">Let.</td>
00187         </tr>';
00188 
00189         $solde = 0.0;
00190         $solde_d = 0.0;
00191         $solde_c = 0.0;
00192         bcscale(2);
00193         $i=0;
00194         foreach ($Poste->row as $detail)
00195         {
00196 
00197             if ($detail['cred_montant'] > 0)
00198             {
00199               $solde=bcsub($solde, $detail['cred_montant']);
00200               $solde_c=bcadd($solde_c,$detail['cred_montant']);
00201             }
00202             if ($detail['deb_montant'] > 0)
00203             {
00204               $solde   = bcadd($solde,$detail['deb_montant']);
00205               $solde_d = bcadd($solde_d,$detail['deb_montant']);
00206             }
00207                         $side="&nbsp;".$Poste->get_amount_side($solde);
00208             $letter="";
00209                 $html_let="";
00210                 if ($detail['letter']!=-1) {
00211                         $letter=strtoupper(base_convert($detail['letter'],10,36));
00212                         $html_let = HtmlInput::show_reconcile("", $letter);
00213                 }
00214                 $i++;
00215                 if (($i % 2 ) == 0) $class="odd"; else $class="even";
00216             echo '<tr name="tr_'.$letter.'_" class="'.$class.'">
00217             <td>'.$detail['j_date_fmt'].'</td>
00218             <td>'.HtmlInput::detail_op($detail['jr_id'],$detail['jr_internal']).'</td>
00219             <td>'.$detail['description'].'</td>
00220             <td>'.$detail['jr_pj_number'].'</td>
00221             <td align="right">'.($detail['deb_montant']  > 0 ? nbm($detail['deb_montant'])  : '').'</td>
00222             <td align="right">'.($detail['cred_montant'] > 0 ? nbm($detail['cred_montant']) : '').'</td>
00223             <td align="right">'.nbm(abs($solde)).$side.'</td>
00224             <td  style="text-align:right;color:red">'.$html_let.'</td>
00225             </tr>';
00226         }
00227         echo '<tr >
00228         <td>'.''.'</td>
00229         <td>'.''.'</td>
00230         <td>'.'<b>'.'Total du compte '.$poste_id['pcm_val'].'</b>'.'</td>
00231         <td>'.''.'</td>
00232         <td align="right">'.'<b>'.($solde_d  > 0 ? nbm( $solde_d)  : '').'</b>'.'</td>
00233         <td align="right">'.'<b>'.($solde_c  > 0 ? nbm( $solde_c)  : '').'</b>'.'</td>
00234         <td align="right">'.'<b>'.nbm( abs($solde_c-$solde_d)).'</b>'.'</td>
00235         <td>';
00236         if ($solde_c > $solde_d ) echo "Crédit";
00237         if ($solde_c < $solde_d )  echo "Débit";
00238         if ($solde_c == $solde_d )  echo "=";
00239 
00240       echo '</td>'.
00241         '</tr>';
00242     }
00243     echo '</table>';
00244     echo Acc_Account_Ledger::HtmlTableHeader("gl_comptes");
00245     echo "</div>";
00246     exit;
00247 }
00248 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations