noalyss Version-9
ajax_history.php
Go to the documentation of this file.
1<?php
2 /*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20 // Copyright Author Dany De Bontridder danydb@aevalys.eu
21
22 /*!\file
23 * \brief show the history of a card of an accounting
24 * for the card f_id is set and for an accounting : pcm_val
25 */
26if ( ! defined('ALLOWED')) die (_('Accès interdit'));
27
28$div=$http->request('div');
29mb_internal_encoding("UTF-8");
31/**
32 *if $_SESSION[SESSION_KEY.'g_user'] is not set : echo a warning
33 */
34/* security */
35if ( $g_user->check_dossier(dossier::id(),true) == 'X' ) exit();
36
37$from_div = (isset($_REQUEST['ajax'])) ? 1 : $div;
39$clean_lettering->remove_incoherent();
40
41///////////////////////////////////////////////////////////////////////////
42/* first detail for a card */
43///////////////////////////////////////////////////////////////////////////
44if ( isset($_GET['f_id']))
45 {
47 $old='';
48 $f_id=$http->get('f_id',"number");
49 $fiche=new Fiche($cn,$f_id);
50
51 $year=$http->get("exercice","string","");
52 if ( $year == "") $year=$g_user->get_exercice();
53
54 if ( $year == "" )
55 {
56 $html=_("erreur aucune période par défaut, allez dans préférence pour en choisir une");
57 }
58 else
59 {
60 $per=new Periode($cn);
61 $limit_periode=$per->get_limit($year);
62 $array['from_periode']=$limit_periode[0]->first_day();
63 $array['to_periode']=$limit_periode[1]->last_day();
64 if (isset($_GET['ex']))
65 {
66 $ex=$http->get('ex','string');
67 $other_year=$exercice->exercice_from_label($ex);
68 $limit_periode=$per->get_limit($other_year);
69 if ( $other_year < $year)
70 $array['from_periode']=$limit_periode[0]->first_day();
71 else
72 $array['to_periode']=$limit_periode[1]->last_day();
73
74 }
75
76 /*
77 * Add button to select another year
78 */
79 if ($exercice->count() > 1 )
80 {
81 $default_ex=$http->get("ex","string",$year);
82 $default=$exercice->exercice_from_label($default_ex);
84 if ( $div != 'popup')
85 {
86 $obj="{op:'history',div:'$div',f_id:'".$f_id."',gDossier:'$dossier',select:this,exercice:{$year}}";
87 $is=$exercice->select('p_exercice',$default,' onchange="update_history_card('.$obj.');"');
88 $old=_("Autre exercice")." ".$is->input();
89 }
90 else
91 {
92 $old='<form method="get" style="display:inline" action="popup.php">';
93 $is=$exercice->select('ex',$default,'onchange = "submit(this)"');
94 $old.=_("Autre exercice")." ".$is->input();
95 $old.=HtmlInput::hidden('div','popup');
96 $old.=HtmlInput::hidden('act',$_GET['act']);
97 $old.=HtmlInput::hidden('f_id',$_GET['f_id']);
98 $old.=HtmlInput::hidden('ajax',$_GET['ajax']);
99 $old.=HtmlInput::hidden('exercice',$year);
100 $old.=dossier::hidden();
101 $old.=HtmlInput::hidden('op','history');
102 $old.='</form>';
103 }
104 }
105 ob_start();
106 $result=$fiche->HtmlTable($array,0,$from_div);
107 $table=ob_get_contents();
108 ob_end_clean();
109
110
111 ob_start();
112 require_once NOALYSS_TEMPLATE.'/history_top.php';
113 $detail_card=HtmlInput::card_detail($fiche->strAttribut(ATTR_DEF_QUICKCODE),$fiche->getName()." ".$fiche->strAttribut(ATTR_DEF_FIRST_NAME,0));
114 echo h2( $fiche->getName().'['.$fiche->strAttribut(ATTR_DEF_QUICKCODE).']',' class="title" ');
115 echo '<p style="text-align:center;">'.$detail_card.'</p>';
116
117 if ( $result ==-1){
118 echo h2(_("Aucune opération pour l'exercice courant"),'class="error"');
120 } else {
121 echo $fiche->filter_history("tb".$div);
122 echo $table;
124 echo $fiche->button_csv($array['from_periode'],$array['to_periode']);
125 echo $fiche->button_pdf($array['from_periode'],$array['to_periode']);
126 }
127
128 echo $old;
129
130 $html=ob_get_contents();
131 ob_end_clean();
132 }
133 }
134///////////////////////////////////////////////////////////////////////////
135// for an account
136///////////////////////////////////////////////////////////////////////////
137if ( isset($_REQUEST['pcm_val']))
138 {
140 $pcm_val=$http->request("pcm_val");
141 $poste=new Acc_Account_Ledger($cn,$pcm_val);
142 $poste->load();
143 $year=$http->get("exercice","string","");
144 if ( $year == "") $year=$g_user->get_exercice();
145 if ( $year == 0 )
146 {
147 $html=_("erreur aucune période par défaut, allez dans préférence pour en choisir une");
148 }
149 else
150 {
151 $old='';
152 $per=new Periode($cn);
153 $limit_periode=$per->get_limit($year);
154 $array['from_periode']=$limit_periode[0]->first_day();
155 $array['to_periode']=$limit_periode[1]->last_day();
156 if (isset($_GET['ex']))
157 {
158 $ex=$http->get("ex","string");
159 $other_year=$exercice->exercice_from_label($ex);
160 $limit_periode=$per->get_limit($other_year);
161 if ( $other_year < $year)
162 $array['from_periode']=$limit_periode[0]->first_day();
163 else
164 $array['to_periode']=$limit_periode[1]->last_day();
165
166 }
167 /*
168 * Add button to select another year
169 */
170 if ($exercice->count() > 1 )
171 {
172 $default_ex=$http->get("ex","string",$year);
173
174 $default=$exercice->exercice_from_label($default_ex);
176 if ( $div != 'popup')
177 {
178 $obj="{op:'history',div:'$div',pcm_val:'".$pcm_val."',gDossier:'$dossier',select:this,exercice:{$year}}";
179 $is=$exercice->select('p_exercice',$default,' onchange="update_history_account('.$obj.');"');
180 $old=_("Autre exercice")." ".$is->input();
181 }
182 else
183 {
184 $old='<form method="get" style="display:inline" action="popup.php">';
185 $is=$exercice->select('ex',$default,'onchange = "submit(this)"');
186 $old.=_("Autre exercice")." ".$is->input();
187 $old.=HtmlInput::hidden('div','popup');
188 $old.=HtmlInput::hidden('act',$_GET['act']);
189 $old.=HtmlInput::hidden('pcm_val',$_GET['pcm_val']);
190 $old.=HtmlInput::hidden('ajax',$_GET['ajax']);
191 $old.=dossier::hidden();
192 $old.=HtmlInput::hidden('op','history');
193 $old.='</form>';
194 }
195
196 }
197 ob_start();
198 $result=$poste->HtmlTable($array,0,$from_div);
199 $table=ob_get_contents();
200 ob_end_clean();
201
202 ob_start();
203
204 require_once NOALYSS_TEMPLATE.'/history_top.php';
205 echo h2( $poste->id." ".h($poste->label),' class="title" ');
206
207
208 if ( $result == -1)
209 {
210 echo h2(_("Aucune opération pour l'exercice courant"),'class="error"');
212 } else {
213 echo $poste->filter_history('tb'.$div);
214 echo $table;
216 echo $poste->button_csv($array['from_periode'],$array['to_periode']);
217 echo $poste->button_pdf($array['from_periode'],$array['to_periode']);
218 }
219 echo $old;
220
221 $html=ob_get_contents();
222 ob_end_clean();
223 }
224 }
226if (DEBUGNOALYSS > 0 && headers_sent()) {
227 echo $html;return;
228}
229header('Content-type: text/xml; charset=UTF-8');
230echo <<<EOF
231<?xml version="1.0" encoding="UTF-8"?>
232<data>
233<ctl>$div</ctl>
234<code>$xml</code>
235</data>
236EOF;
h2($p_string, $p_class="", $raw="")
Definition: ac_common.php:68
global $g_user
if no group available , then stop
if(headers_sent() &&DEBUGNOALYSS > 0) $html
h( $row[ 'oa_description'])
catch(Exception $e) $exercice
$from_div
$http
if(isset( $_GET[ 'f_id'])) if(isset($_REQUEST['pcm_val'])) $xml
$div
$clean_lettering
$_REQUEST['ac']
$input_from id
Definition: balance.inc.php:63
$ex
Definition: balance.inc.php:45
$limit_periode
$_GET['qcode']
$dossier
Manage the account from the table jrn, jrnx or tmp_pcmn.
about the accountancy period (usually 1 year starting in January until december) = exercice
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
Definition: fiche.class.php:38
static button_close($div_name, $class='smallbutton')
close button for the HTML popup
static card_detail($p_qcode, $pname='', $p_style="", $p_nohistory=false, $nofollowup=false)
show the detail of a card
static hidden($p_name, $p_value, $p_id="")
manage the http input (get , post, request) and extract from an array
mother class for the lettering by account and by card use the tables jnt_letter, letter_deb and lette...
For the periode tables parm_periode and jrn_periode.
const ATTR_DEF_FIRST_NAME
Definition: constant.php:238
const ATTR_DEF_QUICKCODE
Definition: constant.php:237
for($e=0; $e< count($afiche); $e++) exit
escape_xml($p_xml)
When data are transfered thanks ajax in a xml document, the xml can not contains some character,...
$table
Definition: menu.inc.php:103