noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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
29$div=$http->request('div');
30mb_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);
83 $dossier=dossier::id();
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',$http->get('act'));
97 $old.=HtmlInput::hidden('f_id',$http->get('f_id'));
98 $old.=HtmlInput::hidden('ajax',$http->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->get_attribute(ATTR_DEF_QUICKCODE),$fiche->getName()." ".$fiche->get_attribute(ATTR_DEF_FIRST_NAME,0));
114 echo h2( $fiche->getName().'['.$fiche->get_attribute(ATTR_DEF_QUICKCODE).']',' class="title" ');
115 echo '<p style="text-align:center;">'.$detail_card.'</p>';
116
117 if ( $result ==-1){
118 print '<div class="content">';
119 echo h2(_("Aucune opération pour l'exercice courant"),'class="error"');
121 } else {
122 print '<div class="content">';
123 echo $fiche->filter_history("tb".$div);
124 echo $old;
125 echo $table;
127 echo $fiche->button_csv($array['from_periode'],$array['to_periode']);
128 echo $fiche->button_pdf($array['from_periode'],$array['to_periode']);
129 }
130
131 echo $old;
132 print "</div>";
133
134 $html=ob_get_contents();
135 ob_end_clean();
136 }
137 }
138///////////////////////////////////////////////////////////////////////////
139// for an account
140///////////////////////////////////////////////////////////////////////////
141if ( isset($_REQUEST['pcm_val']))
142 {
144 $pcm_val=$http->request("pcm_val");
145 $poste=new Acc_Account_Ledger($cn,$pcm_val);
146 $poste->load();
147 $year=$http->get("exercice","string","");
148 if ( $year == "") $year=$g_user->get_exercice();
149 if ( $year == 0 )
150 {
151 $html=_("erreur aucune période par défaut, allez dans préférence pour en choisir une");
152 }
153 else
154 {
155 $old='';
156 $per=new Periode($cn);
157 $limit_periode=$per->get_limit($year);
158 $array['from_periode']=$limit_periode[0]->first_day();
159 $array['to_periode']=$limit_periode[1]->last_day();
160 if (isset($_GET['ex']))
161 {
162 $ex=$http->get("ex","string");
163 $other_year=$exercice->exercice_from_label($ex);
164 $limit_periode=$per->get_limit($other_year);
165 if ( $other_year < $year)
166 $array['from_periode']=$limit_periode[0]->first_day();
167 else
168 $array['to_periode']=$limit_periode[1]->last_day();
169
170 }
171 /*
172 * Add button to select another year
173 */
174 if ($exercice->count() > 1 )
175 {
176 $default_ex=$http->get("ex","string",$year);
177
178 $default=$exercice->exercice_from_label($default_ex);
179 $dossier=dossier::id();
180 if ( $div != 'popup')
181 {
182 $obj="{op:'history',div:'$div',pcm_val:'".$pcm_val."',gDossier:'$dossier',select:this,exercice:{$year}}";
183 $is=$exercice->select('p_exercice',$default,' onchange="update_history_account('.$obj.');"');
184 $old=_("Autre exercice")." ".$is->input();
185 }
186 else
187 {
188 $old='<form method="get" style="display:inline" action="popup.php">';
189 $is=$exercice->select('ex',$default,'onchange = "submit(this)"');
190 $old.=_("Autre exercice")." ".$is->input();
191 $old.=HtmlInput::hidden('div','popup');
192 $old.=HtmlInput::hidden('act',$http->get('act'));
193 $old.=HtmlInput::hidden('pcm_val',$http->get('pcm_val'));
194 $old.=HtmlInput::hidden('ajax',$http->get('ajax'));
195 $old.=dossier::hidden();
196 $old.=HtmlInput::hidden('op','history');
197 $old.='</form>';
198 }
199
200 }
201 ob_start();
202 $result=$poste->HtmlTable($array,0,$from_div);
203 $table=ob_get_contents();
204 ob_end_clean();
205
206 ob_start();
207
208 require_once NOALYSS_TEMPLATE.'/history_top.php';
209 echo h2( $poste->id." ".h($poste->label),' class="title" ');
210
211
212 if ( $result == -1)
213 {
214 echo h2(_("Aucune opération pour l'exercice courant"),'class="error"');
216 } else {
217 echo $poste->filter_history('tb'.$div);
218 echo $old;
219 echo $table;
221 echo $poste->button_csv($array['from_periode'],$array['to_periode']);
222 echo $poste->button_pdf($array['from_periode'],$array['to_periode']);
223 }
224 echo $old;
225
226 $html=ob_get_contents();
227 ob_end_clean();
228 }
229 }
231if (DEBUGNOALYSS > 0 && headers_sent()) {
232 echo $html;return;
233}
234header('Content-type: text/xml; charset=UTF-8');
235echo <<<EOF
236<?xml version="1.0" encoding="UTF-8"?>
237<data>
238<ctl>$div</ctl>
239<code>$xml</code>
240</data>
241EOF;
h2($p_string, $p_class="", $raw="")
Definition ac_common.php:68
global $g_user
if no group available , then stop
switch($op2) $xml
catch(Exception $e) $obj
if(headers_sent() &&DEBUGNOALYSS > 0) $html
h( $row[ 'oa_description'])
catch(Exception $e) $exercice
$from_div
$clean_lettering
$_REQUEST['ac']
_("actif, passif,charge,...")
$ex
$limit_periode
$_GET['qcode']
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...
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...
const ATTR_DEF_FIRST_NAME
Definition constant.php:245
const ATTR_DEF_QUICKCODE
Definition constant.php:244
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,...
print
Type of printing.
$table
Definition menu.inc.php:104