noalyss Version-9
compta_ach.inc.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 Author Dany De Bontridder danydb@aevalys.eu
22
23/**
24 *\file
25 * \brief file included include the purchase operation
26 */
27if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
31
33//menu = show a list of ledger
34$str_dossier = dossier::get();
35$ac=$http->request("ac");
36
37$request_jrn=$http->request("p_jrn", "string","");
38// Check privilege
39if ($request_jrn !="" &&
40 $g_user->check_jrn($request_jrn) != 'W')
41{
42 NoAccess();
43 exit - 1;
44}
46$post_jrn=$http->post("p_jrn", "string","");
47/* if a new invoice is encoded, we display a form for confirmation */
48if (isset($_POST['view_invoice']))
49{
51 try
52 {
53 $Ledger->verify_operation($_POST);
54 }
55 catch (Exception $e)
56 {
57 alert($e->getMessage());
58 $p_msg=$e->getMessage();
59 $correct = 1;
60 }
61 // if correct is not set it means it is correct
62 if (!isset($correct))
63 {
64 echo '<div class="content">';
65 echo '<div id="confirm_div_id" style="width: 47%; float: left;">';
66 echo h1(_("Confirmation"));
67 echo span(_("Vous devez encore confirmer"),' class="notice"');
68 echo '</div>';
69
70 echo '<div id="confirm_div_id" style="width: 100%; float: left;">';
71 echo '<form enctype="multipart/form-data" method="post" class="print">';
72 echo dossier::hidden();
73
74 echo $Ledger->confirm($_POST);
75 echo HtmlInput::hidden('ac', $ac);
76 $Ledger->input_extra_info();
77 echo HtmlInput::submit("record", _("Enregistrement"), 'onClick="return verify_ca(\'\');"');
78 echo HtmlInput::submit('correct', _("Corriger"));
79 echo '</form>';
80 echo '</div>';
81 if (DEBUGNOALYSS>1) { echo "<!-- confirm_div_id -->";}
82 return;
83 }
84}
85//------------------------------
86/* Record the invoice */
87//------------------------------
88
89if (isset($_POST['record']))
90{
92 try
93 {
94 $Ledger->verify_operation($_POST);
95 }
96 catch (Exception $e)
97 {
98 alert($e->getMessage());
99 $p_msg=$e->getMessage();
100 $correct = 1;
101 }
102 // record the invoice
103 if (!isset($correct))
104 {
105 echo '<div class="content">';
106
108 $internal = $Ledger->insert($_POST);
109
110
111 /* Save the predefined operation */
112 if ( isset($_POST['opd_name']) && trim($_POST['opd_name']) != "" )
113 {
114 $opd = new Pre_operation($cn);
115 $opd->get_post();
116 $opd->save();
117 }
118
119 /* Show button */
120 $jr_id = $cn->get_value('select jr_id from jrn where jr_internal=$1', array($internal));
121
122 echo '<h1> '._('Enregistrement').' </h1>';
123 /* Save the additional information into jrn_info */
124 $obj = new Acc_Ledger_Info($cn);
125 $obj->save_extra($Ledger->jr_id, $_POST);
126
127 /* save followup */
128 $Ledger->save_followup($http->request("action_gestion","string",""));
129
130 // Feedback
131 echo $Ledger->confirm($_POST, true);
132 if (isset($Ledger->doc))
133 {
134 echo '<h2>'._('Document').'</h2>';
135 echo $Ledger->doc;
136 }
137 // extourne
138 if (isset($_POST['reverse_ck']))
139 {
140 $p_date=$http->post('reverse_date','string', '');
141 $p_msg=$http->post("ext_label");
142 if (isDate($p_date)==$p_date)
143 {
144 // reverse the operation
145 try
146 {
147 $Ledger->reverse($p_date,$p_msg);
148 echo '<p>';
149 printf ( _('Extourné au %s'),$p_date);
150 echo '</p>';
151 }
152 catch (Exception $e)
153 {
154 echo '<p class="notice">'.
155 _('Opération non extournée').
156 $e->getMessage().
157 '</p>';
158 }
159 }
160 else
161 {
162 // warning because date is invalid
163 echo '<span class="warning">'._('Date invalide, opération non extournée').'</span>';
164 }
165 }
166 echo '<ul class="aligned-block">';
167 echo "<li>";
168 echo $Ledger->button_new_operation();
169 echo "</li>";
170 echo "<li>";
171 echo $Ledger->button_copy_operation();
172 echo "</li>";
173 echo "</ul>";
174 echo '</div>';
175 return;
176 }
177}
178// ------------------------------------------------------------
179/* Display a blank form or a form with predef operation */
180/* or a form for correcting */
181// -------------------------------------------------------------
182
183echo '<div class="content">';
184//
185
186
187$array = (isset($_POST['correct']) || isset($correct)) ? $_POST : null;
189
190
191if (!isset($_REQUEST ['p_jrn']))
192{
193 $def_ledger = $Ledger->get_first('ach',2);
194 if ( empty ($def_ledger))
195 {
196 exit(_('Pas de journal disponible'));
197 }
198 $Ledger->id = $def_ledger['jrn_def_id'];
199}
200else if (isset($_REQUEST ['p_jrn']))
201 $Ledger->id = $request_jrn;
202else if (isset ($_REQUEST['p_jrn_predef'])){
203 $Ledger->id=$http->request('p_jrn_predef');
204}
205// pre defined operation
206//
207
208echo '</div>';
209
210echo '<div class="content">';
211
212if ( $p_msg !="" ) echo '<span class="warning">'.$p_msg.'</span>';
213
214try
215{
216 $payment=$http->request("e_mp", "string",0);
217 $date_payment=$http->request("mp_date", "string","");
218 $comm_payment=$http->request("e_comm_paiement", "string","");
219 $acompte=$http->request("acompte", "string",0);
220
221 echo "<FORM class=\"print\"NAME=\"form_detail\" METHOD=\"POST\" >";
222 echo HtmlInput::hidden("ac", $ac);
223 /* request for a predefined operation */
224 if (isset($_REQUEST['pre_def'])&&!isset($_POST['correct']) && ! isset($correct) )
225 {
226 // used a predefined operation
227 $predef=$http->request("pre_def","string", "0");
228 $p_jrn_predef=$http->request("p_jrn_predef","string", "0");
229 $op=new Pre_operation($cn);
230 $op->set_od_id($predef);
231 $p_post=$op->compute_array();
232 $Ledger->id=$p_jrn_predef;
233 $p_post['p_jrn']=$Ledger->id;
234 echo $Ledger->input($p_post);
235 echo '<div class="content">';
236 echo $Ledger->input_paid($payment,$acompte,$date_payment,$comm_payment);
237 echo '</div>';
238 echo '<script>';
239 echo 'compute_all_ledger();';
240 echo '</script>';
241 }
242 else if (isset($_GET['create_feenote']))
243 {
244 $action_id=$http->get('ag_id',"number");
245 $array=$Ledger->convert_from_follow($action_id);
246 echo HtmlInput::hidden("ledger_type", "VEN");
247 echo HtmlInput::hidden("ac",$http->get('ac'));
248 echo HtmlInput::hidden("sa", "p");
249 echo HtmlInput::hidden("action_gestion",$action_id);
250 echo $Ledger->input($array);
251 echo '<div class="content">';
252 echo $Ledger->input_paid($payment,$acompte,$date_payment,$comm_payment);
253 echo '</div>';
254 echo '<script>';
255 echo 'compute_all_ledger();';
256 echo '</script>';
257 }
258 else
259 {
260 echo $Ledger->input($array);
261 echo HtmlInput::hidden("p_action", "ach");
262 echo HtmlInput::hidden("sa", "p");
263 echo '<div class="content">';
264 echo $Ledger->input_paid($payment,$acompte,$date_payment,$comm_payment);
265 echo '</div>';
266 echo '<script>';
267 echo 'compute_all_ledger();';
268 echo '</script>';
269 }
270 echo '<div class="content">';
271 echo HtmlInput::button('act', _('Actualiser'),
272 'onClick="compute_all_ledger();"');
273 echo HtmlInput::submit("view_invoice", _("Enregistrer"));
274 echo HtmlInput::reset(_('Effacer '));
275 echo '</div>';
276 echo "</FORM>";
277}
278catch (Exception $e)
279{
280 alert($e->getMessage());
281 return;
282}
283$e_date=$http->request("e_date","string","");
284
285if ($e_date=="" && $g_parameter->MY_DATE_SUGGEST=='Y')
286 {
287 echo create_script(" get_last_date()");
288 }
289echo create_script(" update_name()");
290echo '</div>';
291
292
293return;
294// end record invoice
295?>
span($p_string, $p_extra='')
Definition: ac_common.php:43
isDate($p_date)
Definition: ac_common.php:236
h1($p_string, $p_class="")
Definition: ac_common.php:72
NoAccess($js=1)
Echo no access and stop.
Definition: ac_common.php:480
alert($p_msg, $buffer=false)
alert in javascript
Definition: ac_common.php:738
global $g_user
if no group available , then stop
$op
Definition: ajax_admin.php:38
$jr_id
Definition: ajax_ledger.php:44
$_REQUEST['ac']
$input_from id
Definition: balance.inc.php:63
$_GET['qcode']
Manage the additionnal info for operation (from jrn), when an invoice is generated,...
Handle the ledger of purchase,.
static connect()
static button($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
static reset($p_value)
static hidden($p_name, $p_value, $p_id="")
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
manage the http input (get , post, request) and extract from an array
manage the predefined operation, link to the table op_def and op_def_detail
$gDossier
if($request_jrn !="" && $g_user->check_jrn($request_jrn) !='W') $p_msg
$str_dossier
$request_jrn
global $g_parameter
$post_jrn
$comm_payment
$acompte
$date_payment
if( $g_parameter->MY_PJ_SUGGEST=='Y') $e_date
$action_id
$_POST['ac']
Definition: do.php:310
for($e=0; $e< count($afiche); $e++) exit
create_script($p_string)
create the HTML for adding the script tags around of the script