noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
ajax_history.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 show the history of a card of an accounting
00024    * for the card f_id is set and for an accounting : pcm_val
00025    */
00026 if ( ! defined('ALLOWED')) define ('ALLOWED',1);
00027 
00028 require_once '../include/constant.php';
00029 require_once('class_database.php');
00030 require_once('class_user.php');
00031 require_once('class_dossier.php');
00032 require_once('class_periode.php');
00033 require_once('class_html_input.php');
00034 require_once('class_acc_account.php');
00035 require_once('class_exercice.php');
00036 $div=$_REQUEST['div'];
00037 mb_internal_encoding("UTF-8");
00038 
00039 /**
00040  *if $_SESSION['g_user'] is not set : echo a warning
00041  */
00042 ajax_disconnected($div);
00043 global $g_user,$cn;
00044 $cn=new Database(dossier::id());
00045 $g_user=new User($cn);
00046 /* security */
00047 if ( $g_user->check_dossier(dossier::id(),true) == 'X' ) exit();
00048 
00049 $from_div = (isset($_REQUEST['ajax'])) ? 1 : $_GET['l'];
00050 if ( LOGINPUT)
00051     {
00052         $file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php','a+');
00053         fwrite ($file_loginput,"<?php \n");
00054         fwrite ($file_loginput,"//@description:\n");
00055         fwrite($file_loginput, '$_GET='.var_export($_GET,true));
00056         fwrite($file_loginput,";\n");
00057         fwrite($file_loginput, '$_POST='.var_export($_POST,true));
00058         fwrite($file_loginput,";\n");
00059         fwrite($file_loginput, '$_POST[\'gDossier\']=$gDossierLogInput;');
00060         fwrite($file_loginput,"\n");
00061         fwrite($file_loginput, '$_GET[\'gDossier\']=$gDossierLogInput;');
00062         fwrite($file_loginput,"\n");
00063         fwrite($file_loginput,' $_REQUEST=array_merge($_GET,$_POST);');
00064         fwrite($file_loginput,"\n");
00065         fwrite($file_loginput,"include '".basename(__FILE__)."';\n");
00066         fclose($file_loginput);
00067     }
00068 ///////////////////////////////////////////////////////////////////////////
00069 /* first detail for a card */
00070 ///////////////////////////////////////////////////////////////////////////
00071 if ( isset($_GET['f_id']))
00072   {
00073     $exercice=new Exercice($cn);
00074     $old='';
00075     $fiche=new Fiche($cn,$_GET['f_id']);
00076     $year=$g_user->get_exercice();
00077     if ( $year == 0 )
00078       {
00079         $html=_("erreur aucune période par défaut, allez dans préférence pour en choisir une");
00080       }
00081     else
00082       {
00083         $per=new Periode($cn);
00084         $limit_periode=$per->get_limit($year);
00085         $array['from_periode']=$limit_periode[0]->first_day();
00086         $array['to_periode']=$limit_periode[1]->last_day();
00087         if (isset($_GET['ex']))
00088           {
00089             $limit_periode=$per->get_limit($_GET['ex']);
00090             if ( $_GET['ex'] < $year)
00091               $array['from_periode']=$limit_periode[0]->first_day();
00092             else
00093               $array['to_periode']=$limit_periode[1]->last_day();
00094 
00095           }
00096 
00097         /*
00098          * Add button to select another year
00099          */
00100         if ($exercice->count() > 1 )
00101           {
00102             $default=(isset($_GET['ex']))?$_GET['ex']:$year;
00103             $dossier=dossier::id();
00104             if ( $div != 'popup')
00105               {
00106                 $obj="{div:'$div',f_id:'".$_GET['f_id']."',gDossier:'$dossier',select:this}";
00107                 $is=$exercice->select('p_exercice',$default,' onchange="update_history_card('.$obj.');"');
00108                 $old=_("Autre exercice")." ".$is->input();
00109               }
00110             else
00111               {
00112                 $old='<form method="get" action="popup.php">';
00113                 $is=$exercice->select('ex',$default,'onchange = "submit(this)"');
00114                 $old.=_("Autre exercice")." ".$is->input();
00115                 $old.=HtmlInput::hidden('div','popup');
00116                 $old.=HtmlInput::hidden('act',$_GET['act']);
00117                 $old.=HtmlInput::hidden('f_id',$_GET['f_id']);
00118                 $old.=HtmlInput::hidden('ajax',$_GET['ajax']);
00119                 $old.=dossier::hidden();
00120                 $old.='</form>';
00121               }
00122           }
00123 
00124         ob_start();
00125         require_once('template/history_top.php');
00126         $detail_card=HtmlInput::card_detail($fiche->strAttribut(ATTR_DEF_QUICKCODE),$fiche->getName());
00127         echo h2(  $fiche->getName().'['.$fiche->strAttribut(ATTR_DEF_QUICKCODE).']',' class="title" ');
00128         echo '<p style="text-align:center;">'.$detail_card.'</p>';
00129 
00130         if (   $fiche->HtmlTable($array,0,$from_div)==-1){
00131           echo h2(_("Aucune opération pour l'exercice courant"),'class="error"');
00132         }
00133 
00134         echo $old;
00135 
00136         $html=ob_get_contents();
00137         ob_end_clean();
00138       }
00139   }
00140 ///////////////////////////////////////////////////////////////////////////
00141 // for an account
00142 ///////////////////////////////////////////////////////////////////////////
00143 if ( isset($_REQUEST['pcm_val']))
00144   {
00145     $poste=new Acc_Account_Ledger($cn,$_REQUEST['pcm_val']);
00146     $year=$g_user->get_exercice();
00147     if ( $year == 0 )
00148       {
00149         $html=_("erreur aucune période par défaut, allez dans préférence pour en choisir une");
00150       }
00151     else
00152       {
00153         $exercice=new Exercice($cn);
00154         $old='';
00155         $per=new Periode($cn);
00156         $limit_periode=$per->get_limit($year);
00157         $array['from_periode']=$limit_periode[0]->first_day();
00158         $array['to_periode']=$limit_periode[1]->last_day();
00159         if (isset($_GET['ex']))
00160           {
00161             $limit_periode=$per->get_limit($_GET['ex']);
00162             if ( $_GET['ex'] < $year)
00163               $array['from_periode']=$limit_periode[0]->first_day();
00164             else
00165               $array['to_periode']=$limit_periode[1]->last_day();
00166 
00167           }
00168         /*
00169          * Add button to select another year
00170          */
00171         if ($exercice->count() > 1 )
00172           {
00173             $default=(isset($_GET['ex']))?$_GET['ex']:$year;
00174             $dossier=dossier::id();
00175             if ( $div != 'popup')
00176               {
00177                 $obj="{div:'$div',pcm_val:'".$_GET['pcm_val']."',gDossier:'$dossier',select:this}";
00178                 $is=$exercice->select('p_exercice',$default,' onchange="update_history_account('.$obj.');"');
00179                 $old=_("Autre exercice")." ".$is->input();
00180               }
00181             else
00182               {
00183                 $old='<form method="get" action="popup.php">';
00184                 $is=$exercice->select('ex',$default,'onchange = "submit(this)"');
00185                 $old.=_("Autre exercice")." ".$is->input();
00186                 $old.=HtmlInput::hidden('div','popup');
00187                 $old.=HtmlInput::hidden('act',$_GET['act']);
00188                 $old.=HtmlInput::hidden('pcm_val',$_GET['pcm_val']);
00189                 $old.=HtmlInput::hidden('ajax',$_GET['ajax']);
00190                 $old.=dossier::hidden();
00191                 $old.='</form>';
00192               }
00193 
00194           }
00195 
00196         ob_start();
00197         require_once('template/history_top.php');
00198 
00199         if ( $poste->HtmlTable($array) == -1)
00200           {
00201             echo h2($poste->id." ".$poste->name,' class="title"');
00202             echo h2(_("Aucune opération pour l'exercice courant"),'class="error"');
00203           }
00204         echo $old;
00205 
00206         $html=ob_get_contents();
00207         ob_end_clean();
00208       }
00209   }
00210 $xml=escape_xml($html);
00211 if (DEBUG && headers_sent()) {
00212     echo $html;return;
00213 }
00214 header('Content-type: text/xml; charset=UTF-8');
00215 echo <<<EOF
00216 <?xml version="1.0" encoding="UTF-8"?>
00217 <data>
00218 <ctl>$div</ctl>
00219 <code>$xml</code>
00220 </data>
00221 EOF;
 All Data Structures Namespaces Files Functions Variables Enumerations