noalyss Version-9
ajax_display_letter.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * NOALYSS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with NOALYSS; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21// Copyright 2015 Author Dany De Bontridder danydb@aevalys.eu
22
23 /**
24 *@file
25 *@brief show the lettered operation
26 */
27
28if (!defined('ALLOWED'))
29 die('Appel direct ne sont pas permis');
30
32
33try {
34 $obj_type=$http->get("obj_type");
35 $j_id=$http->get("j_id","number");
36 $op=$http->get("op");
37
38}catch (Exception $e )
39{
40 record_log($e->getMessage());
42 return;
43}
44
45$exercice=$g_user->get_exercice();
46if ($g_user->check_module("LETCARD")==0 && $g_user->check_module("LETACC")==0)
47 exit();
49list($first_per, $last_per)=$periode->get_limit($exercice);
50
51$ret=new IButton('return');
52$ret->label=_('Retour');
53$ret->javascript="$('detail').hide();$('list').show();$('search').show();";
54
55// retrieve info for the given j_id (date, amount,side and comment)
56$sql="select j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,J_POSTE,j_qcode,jr_id,
57 jr_comment,j_montant, j_debit,jr_internal from jrnx join jrn on (j_grpt=jr_grpt_id)
58 where j_id=$1";
59$arow=$cn->get_array($sql, array($j_id));
61$r='';
62$r.='<fieldset><legend>'._('Lettrage').'</legend>';
63$r.=_('Poste')." ".$row['j_poste'].' '.$row['j_qcode'].'<br>';
64
65$detail="<A class=\"detail\" style=\"display:inline\" HREF=\"javascript:modifyOperation('".$row['jr_id']."',".$gDossier.")\" > ".$row['jr_internal']."</A>";
66
67$r.=_('Date').' : '.$row['j_date_fmt'].' ref :'.$detail.' <br> ';
68$r.=h($row['jr_comment'])." "._("montant")." : ".($row['j_montant'])." ".(($row['j_debit']=='t')?'D':'C');
69$r.='</fieldset>';
70$r.='<div id="filtre" style="float:left;display:block">';
71$r.='<form method="get" id="search_form" onsubmit="search_letter(this);return false">';
72$r.='<div style="float:left;">';
73// needed hidden var
74$r.=dossier::hidden();
75if (isset($_REQUEST['ac']))
76 $r.=HtmlInput::hidden('ac', $http->request('ac'));
77if (isset($_REQUEST['sa']))
78 $r.=HtmlInput::hidden('sa', $http->request('sa'));
79if (isset($_REQUEST['acc']))
80 $r.=HtmlInput::hidden('acc', $http->request('acc'));
81
82$r.=HtmlInput::hidden('j_id', $j_id);
84$r.=HtmlInput::hidden('obj_type', $obj_type);
85
86$r.='<table>';
87//min amount
88$line=td(_('Montant min. '));
89$min=new INum('min_amount');
90$min->value=(isset($min_amount))?$min_amount:$row['j_montant'];
92
93$line.=td($min->input());
94// max amount
95$line.=td(_('Montant max. '));
96$max=new INum('max_amount');
97$max->value=(isset($max_amount))?$max_amount:$row['j_montant'];
99$line.=td($max->input());
100$r.=tr($line);
101
103// start date
104$start=new IDate('search_start');
105$search_start=$http->get("search_start");
106
107/* check if date are valid */
108if (isset($search_start)&&isDate($search_start)==null)
109{
110 ob_start();
111 alert(_('Date malformée'));
112 $date_error=ob_get_contents();
113 ob_end_clean();
114 $search_start=$first_per->first_day();
115}
116$start->value=(isset($search_start))?$search_start:$first_per->first_day();
117
118$line=td(_('Date Début')).td($start->input());
119// end date
120$end=new IDate('search_end');
121/* check if date are valid */
122$search_end=$http->get("search_end","date");
123
124if (isset($search_end)&&isDate($search_end)==null)
125{
126 ob_start();
127 alert(_('Date malformée'));
128 $date_error=ob_get_contents();
129 ob_end_clean();
130 $search_end=$last_per->last_day();
131}
132$end->value=(isset($search_end))?$search_end:$last_per->last_day();
133$line.=td(_('Date Fin')).td($end->input());
134$r.=tr($line);
135// Side
136$line=td(_('Debit / Credit'));
137$iside=new ISelect('side');
138$iside->value=array(
139 array('label'=>_('Debit'), 'value'=>0),
140 array('label'=>_('Credit'), 'value'=>1),
141 array('label'=>_('Les 2'), 'value'=>3)
142);
143/**
144 *
145 * if $side is not then
146 * - if jl_id exist and is > 0 show by default all the operation (=3)
147 * - if jl_id does not exist or is < 0 then show by default the opposite
148 * side
149 */
150if (!isset($side))
151{
152 // find the jl_id of the j_id
153 $jl_id=$cn->get_value('select comptaproc.get_letter_jnt($1)', array($j_id));
154 if ($jl_id==null)
155 {
156 // get the other side
157 $iside->selected=(isset($side))?$side:(($row['j_debit']=='t')?1:0);
158 $side=(isset($side))?$side:(($row['j_debit']=='t')?1:0);
159 }
160 else
161 {
162 // show everything
163 $iside->selected=3;
164 $side=3;
165 }
166}
167else
168{
169 $iside->selected=$side;
170}
171
172$r.=tr($line.td($iside->input()));
173$r.='</table>';
174$r.='</div>';
175$r.='<div style="float:left;padding-left:100">';
176$r.=HtmlInput::submit('search', 'Rechercher');
177$r.='</div>';
178$r.='</form>';
179$r.='</div>';
180
181$form='<div id="result" style="float:top;clear:both">';
182
183$form.='<FORM id="letter_form" METHOD="post">';
184$form.=dossier::hidden();
185
186$form.=HtmlInput::array_to_hidden(['p_action','sa','acc','sc','sb','f_id'],$_REQUEST);
187
188// display a list of operation from the other side + box button
189if ($obj_type=='account')
190{
191 $obj=new Lettering_Account($cn, $row['j_poste']);
192 if (isset($search_start))
193 $obj->start=$search_start;
194 if (isset($search_end))
195 $obj->end=$search_end;
196 if (isset($max_amount))
197 $obj->fil_amount_max=$max_amount;
198 if (isset($min_amount))
199 $obj->fil_amount_min=$min_amount;
200 if (isset($side))
201 $obj->fil_deb=$side;
202
203 $form.=$obj->show_letter($j_id);
204}
205else if ($obj_type=='card')
206{
207 $obj=new Lettering_Card($cn, $row['j_qcode']);
208 if (isset($search_start))
209 $obj->start=$search_start;
210 if (isset($search_end))
211 $obj->end=$search_end;
212 if (isset($max_amount))
213 $obj->fil_amount_max=$max_amount;
214 if (isset($min_amount))
215 $obj->fil_amount_min=$min_amount;
216 if (isset($side))
217 $obj->fil_deb=$side;
218 $form.=$obj->show_letter($j_id);
219}
220else
221{
222 $form.=_('Mauvais type objet');
223}
224
225$form.=HtmlInput::submit('record', _('Sauver')).$ret->input();
226$form.='</FORM>';
227$form.='</div>';
228
229$html=$r.$form;
231// echo $html;exit;
233
234header('Content-type: text/xml; charset=UTF-8');
235echo <<<EOF
236<?xml version="1.0" encoding="UTF-8"?>
237<data>
238<code>detail</code>
240</data>
241EOF;
242?>
isDate($p_date)
Definition: ac_common.php:236
tr($p_string, $p_extra='')
Definition: ac_common.php:88
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
alert($p_msg, $buffer=false)
alert in javascript
Definition: ac_common.php:738
global $g_user
if no group available , then stop
h( $row[ 'oa_description'])
$min value
catch(Exception $e) $exercice
$_REQUEST['ac']
static hidden($p_name, $p_value, $p_id="")
static array_to_hidden($array, $global_array)
transform request data to hidden
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
manage the http input (get , post, request) and extract from an array
Html Input.
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
Definition: idate.class.php:34
This class handles only the numeric input, the input will call a javascript to change comma to period...
Definition: inum.class.php:42
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
only for operation retrieved thanks a account (jrnx.j_poste) manage the accounting entries for a give...
only for operation retrieved thanks a quick_code manage the accounting entries for a given card
For the periode tables parm_periode and jrn_periode.
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,...
$side