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 
28 if (!defined('ALLOWED'))
29  die('Appel direct ne sont pas permis');
30 
32 
33 try {
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());
41  record_log($e);
42  return;
43 }
44 
45 $exercice=$g_user->get_exercice();
46 if ($g_user->check_module("LETCARD")==0 && $g_user->check_module("LETACC")==0)
47  exit();
49 list($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();
75 if (isset($_REQUEST['ac']))
76  $r.=HtmlInput::hidden('ac', $http->request('ac'));
77 if (isset($_REQUEST['sa']))
78  $r.=HtmlInput::hidden('sa', $http->request('sa'));
79 if (isset($_REQUEST['acc']))
80  $r.=HtmlInput::hidden('acc', $http->request('acc'));
81 
82 $r.=HtmlInput::hidden('j_id', $j_id);
83 $r.=HtmlInput::hidden('op', $op);
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'];
91 $min_amount=(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'];
98 $max_amount=(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 */
108 if (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 
124 if (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  */
150 if (!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 }
167 else
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
189 if ($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 }
205 else 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 }
220 else
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 
234 header('Content-type: text/xml; charset=UTF-8');
235 echo <<<EOF
236 <?xml version="1.0" encoding="UTF-8"?>
237 <data>
238 <code>detail</code>
239 <value>$html</value>
240 </data>
241 EOF;
242 ?>
$detail
$detail
Definition: ajax_display_letter.php:65
$min_amount
$min_amount
Definition: ajax_display_letter.php:91
h
h( $row[ 'oa_description'])
Definition: ajax_anc_detail_operation.php:46
$ret
$ret
Definition: ajax_display_letter.php:51
$html
$html
Definition: ajax_display_letter.php:229
$e
$e
Definition: result_cat_card_summary.php:26
Periode
For the periode tables parm_periode and jrn_periode.
Definition: periode.class.php:32
INum
This class handles only the numeric input, the input will call a javascript to change comma to period...
Definition: inum.class.php:41
$exercice
catch(Exception $e) $exercice
Definition: ajax_display_letter.php:45
value
$min value
Definition: ajax_display_letter.php:90
HttpInput
manage the http input (get , post, request) and extract from an array
Definition: http_input.class.php:37
$r
$r
Definition: ajax_display_letter.php:61
tr
tr($p_string, $p_extra='')
Definition: ac_common.php:88
$start
$start
Definition: ajax_display_letter.php:104
$http
$http
Definition: ajax_display_letter.php:31
$op
$op
Definition: ajax_display_letter.php:36
$max
$max
Definition: ajax_display_letter.php:96
IDate
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:33
$date_error
$date_error
Definition: ajax_display_letter.php:102
isDate
isDate($p_date)
Definition: ac_common.php:239
$periode
$periode
Definition: ajax_display_letter.php:48
$max_amount
$max_amount
Definition: ajax_display_letter.php:98
Lettering_Card
only for operation retrieved thanks a quick_code manage the accounting entries for a given card
Definition: lettering.class.php:583
$arow
$arow
Definition: ajax_display_letter.php:59
$g_user
global $g_user
Find the default module or the first one.
Definition: action.inc.php:24
$end
$end
Definition: ajax_display_letter.php:120
$side
$side
Definition: letter_prop.php:157
$obj
$obj
Definition: ajax_accounting.php:43
$iside
$iside
Definition: ajax_display_letter.php:137
Lettering_Account
only for operation retrieved thanks a account (jrnx.j_poste) manage the accounting entries for a give...
Definition: lettering.class.php:404
HtmlInput\submit
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
Definition: html_input.class.php:199
$row
$row
Definition: ajax_display_letter.php:60
$line
$line
Definition: ajax_display_letter.php:88
$_REQUEST
$_REQUEST['ac']
Definition: ajax_search_action.php:26
escape_xml
escape_xml($p_xml)
When data are transfered thanks ajax in a xml document, the xml can not contains some character,...
Definition: function_javascript.php:2720
exit
for($e=0; $e< count($afiche); $e++) exit
Definition: export_fiche_balance_csv.php:109
$search_start
$search_start
Definition: ajax_display_letter.php:105
$cn
$cn
Definition: ajax_anc_accounting.php:30
IButton
Html Input.
Definition: ibutton.class.php:30
alert
alert($p_msg, $buffer=false)
alert in javascript
Definition: ac_common.php:731
HtmlInput\array_to_hidden
static array_to_hidden($array, $global_array)
transform request data to hidden
Definition: html_input.class.php:582
$search_end
$search_end
Definition: ajax_display_letter.php:122
$j_id
$j_id
Definition: ajax_display_letter.php:35
td
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
$min
$min
Definition: ajax_display_letter.php:89
HtmlInput\hidden
static hidden($p_name, $p_value, $p_id="")
Definition: html_input.class.php:218
$form
$form
Definition: ajax_display_letter.php:181
ISelect
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
Definition: iselect.class.php:39
record_log
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1400
$gDossier
$gDossier
Definition: ajax_get_profile.php:39
$sql
$sql
Definition: ajax_display_letter.php:56