noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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');
28$gDossier = dossier::id();
31
32$cn = Dossier::connect();
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 '<div class="bt-center">';
78 echo '<ul class="aligned-block">';
79 echo '<li>';
80 echo HtmlInput::submit("record", _("Confirmer"), 'onClick="return verify_ca(\'\');"', p_class: "button");
81 echo '</li>';
82 echo '<li>';
83 echo HtmlInput::submit('correct', _("Corriger"), p_class: "button");
84 echo '</li>';
85 echo '</ul>';
86 echo '</div>';
87 echo '</form>';
88 echo '</div>';
89 if (DEBUGNOALYSS>1) { echo "<!-- confirm_div_id -->";}
90 return;
91 }
92}
93//------------------------------
94/* Record the invoice */
95//------------------------------
96
97if (isset($_POST['record']))
98{
100 try
101 {
102 $Ledger->verify_operation($_POST);
103 }
104 catch (Exception $e)
105 {
106 alert($e->getMessage());
107 $p_msg=$e->getMessage();
108 $correct = 1;
109 }
110 // record the invoice
111 if (!isset($correct))
112 {
113 echo '<div class="content">';
114
116
117 try {
118 $internal = $Ledger->insert($_POST);
119 $Ledger->upload_supplemental_document($Ledger->jr_id);
120 } catch (\Exception $e) {
121 if ( $e->getCode()==EXC_BALANCE)
122 {
124 echo_warning(_("enregistrement annulé: balance , voyer le fichier log"));
125 }
126 else
127 {
128 echo_warning($e->getMessage());
129 }
130 return;
131 }
132
133
134 /* Save the predefined operation */
135 if ( isset($_POST['opd_name']) && trim($_POST['opd_name']) != "" )
136 {
137 $opd = new Pre_operation($cn);
138 $opd->get_post();
139 $opd->save();
140 }
141
142 /* Show button */
143 $jr_id = $cn->get_value('select jr_id from jrn where jr_internal=$1', array($internal));
144
145 echo '<h1> '._('Enregistrement').' </h1>';
146 /* Save the additional information into jrn_info */
147 $obj = new Acc_Ledger_Info($cn);
148 $obj->save_extra($Ledger->jr_id, $_POST);
149
150 /* save followup */
151 $Ledger->save_followup($http->request("action_gestion","string",""));
152
153 // Feedback
154 echo $Ledger->confirm($_POST, true);
155 if (isset($Ledger->doc))
156 {
157 echo '<h2>'._('Document').'</h2>';
158 echo $Ledger->doc;
159 }
160 // extourne
161 if (isset($_POST['reverse_ck']))
162 {
163 $p_date=$http->post('reverse_date','string', '');
164 $p_msg=$http->post("ext_label");
165 if (isDate($p_date)==$p_date)
166 {
167 // reverse the operation
168 try
169 {
170 $Ledger->reverse($p_date,$p_msg);
171 echo '<p>';
172 printf ( _('Extourné au %s'),$p_date);
173 echo '</p>';
174 }
175 catch (Exception $e)
176 {
177 echo '<p class="error">'.
178 _('Opération non extournée').
179 " ".
180 $e->getMessage().
181 '</p>';
182 }
183 }
184 else
185 {
186 // warning because date is invalid
187 echo '<span class="warning">'._('Date invalide, opération non extournée').'</span>';
188 }
189 }
190 echo '<div class="bt-center">';
191 echo '<ul class="aligned-block">';
192 echo "<li>";
193 echo $Ledger->button_new_operation();
194 echo "</li>";
195 echo "<li>";
196 echo $Ledger->button_copy_operation();
197 echo "</li>";
198 echo "</ul>";
199 echo '</div>';
200 echo '</div>';
201 return;
202 }
203}
204// ------------------------------------------------------------
205/* Display a blank form or a form with predef operation */
206/* or a form for correcting */
207// -------------------------------------------------------------
208
209//
210
211
212$array = (isset($_POST['correct']) || isset($correct)) ? $_POST : null;
214
215
216if (!isset($_REQUEST ['p_jrn']))
217{
218 $def_ledger = $Ledger->get_first('ach',2);
219 if ( empty ($def_ledger))
220 {
221 exit(_('Pas de journal disponible'));
222 }
223 $Ledger->id = $def_ledger['jrn_def_id'];
224}
225else if (isset($_REQUEST ['p_jrn']))
226 $Ledger->id = $request_jrn;
227else if (isset ($_REQUEST['p_jrn_predef'])){
228 $Ledger->id=$http->request('p_jrn_predef');
229}
230// pre defined operation
231//
232
233
234echo '<div class="content">';
235
236if ( $p_msg !="" ) echo '<span class="warning">'.$p_msg.'</span>';
237
238try
239{
240 $payment=$http->request("e_mp", "string",0);
241 $date_payment=$http->request("mp_date", "string","");
242 $comm_payment=$http->request("e_comm_paiement", "string","");
243 $acompte=$http->request("acompte", "string",0);
244
245 echo "<FORM class=\"print\"NAME=\"form_detail\" METHOD=\"POST\" >";
246 echo HtmlInput::hidden("ac", $ac);
247 /* request for a predefined operation */
248 if (isset($_REQUEST['pre_def'])&&!isset($_POST['correct']) && ! isset($correct) )
249 {
250 // used a predefined operation
251 $predef=$http->request("pre_def","string", "0");
252 $p_jrn_predef=$http->request("p_jrn_predef","string", "0");
253 $op=new Pre_operation($cn);
254 $op->set_od_id($predef);
255 $p_post=$op->compute_array();
256 $Ledger->id=$p_jrn_predef;
257 $p_post['p_jrn']=$Ledger->id;
258 echo $Ledger->input($p_post);
259 echo '<div class="content">';
260 echo $Ledger->input_paid($payment,$acompte,$date_payment,$comm_payment);
261 echo '</div>';
262 echo '<script>';
263 echo 'compute_all_ledger();';
264 echo '</script>';
265 }
266 else if (isset($_GET['create_feenote']))
267 {
268 $action_id=$http->get('ag_id',"number");
269 $cp=$http->get('cp','number',0);
270 $array=$Ledger->convert_from_follow($action_id,$cp);
271 echo HtmlInput::hidden("ledger_type", "VEN");
272 echo HtmlInput::hidden("ac",$http->get('ac'));
273 echo HtmlInput::hidden("sa", "p");
274 echo HtmlInput::hidden("action_gestion",$action_id);
275 echo $Ledger->input($array);
276 echo '<div class="content">';
277 echo $Ledger->input_paid($payment,$acompte,$date_payment,$comm_payment);
278 echo '</div>';
279 echo '<script>';
280 echo 'compute_all_ledger();';
281 echo '</script>';
282 }
283 else
284 {
285 echo $Ledger->input($array);
286 echo HtmlInput::hidden("p_action", "ach");
287 echo HtmlInput::hidden("sa", "p");
288 echo '<div class="content">';
289 echo $Ledger->input_paid($payment,$acompte,$date_payment,$comm_payment);
290 echo '</div>';
291 echo '<script>';
292 echo 'compute_all_ledger();';
293 echo '</script>';
294 }
295 echo '<div class="content">';
296 echo '<div class="bt-center">';
297 echo '<ul class="aligned-block">';
298 echo '<li>';
299 echo HtmlInput::button('act', _('Actualiser'), 'onClick="compute_all_ledger();"', p_class: "button");
300 echo '</li>';
301 echo '<li>';
302 echo HtmlInput::submit("view_invoice", _("Enregistrer"), p_class: "button");
303 echo '</li>';
304 echo '<li>';
305 echo HtmlInput::reset(_('Effacer '), p_class: "button");
306 echo '</li>';
307 echo '</ul>';
308 echo '</div>';
309
310 echo '</div>';
311 echo "</FORM>";
312}
313catch (Exception $e)
314{
315 alert($e->getMessage());
316 return;
317}
318$e_date=$http->request("e_date","string","");
319
320if ($e_date=="" && $g_parameter->MY_DATE_SUGGEST=='Y')
321 {
322 echo create_script(" get_last_date()");
323 }
324echo create_script(" update_name()");
325echo '</div>';
326
327
328return;
329// end record invoice
330?>
span($p_string, $p_extra='')
Definition ac_common.php:43
isDate($p_date)
Verifie qu'une date est bien formaté en d.m.y et est valable.
echo_warning($p_string)
warns
h1($p_string, $p_class="")
Definition ac_common.php:72
NoAccess($js=1)
Echo no access and stop.
record_log($p_message)
Record an error message into the log file of the server or in the log folder of NOALYSS Record also t...
alert($p_msg, $buffer=false)
alert in javascript
global $g_parameter
global $g_user
if no group available , then stop
catch(Exception $e) $obj
$op
foreach(array( 'l', 'gDossier') as $a) if(is_numeric($l)==false) $Ledger
$jr_id
$_REQUEST['ac']
if(isset( $_REQUEST[ 'show'])) if(isset($_REQUEST['del'])) $ac
$str_dossier
_("actif, passif,charge,...")
$_GET['qcode']
Manage the additionnal info for operation (from jrn), when an invoice is generated,...
: input, confirm and save new operations in edger of purchase the $_POST data is an array with these ...
static button($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
static reset($p_value, $p_class="smallbutton")
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
$request_jrn
if($request_jrn !="" && $g_user->check_jrn($request_jrn) !='W' $p_msg)
$post_jrn
$comm_payment
$date_payment
if( $g_parameter->MY_PJ_SUGGEST=='Y') $e_date
const EXC_BALANCE
Definition constant.php:362
$_POST['ac']
Definition do.php:323
for($e=0; $e< count($afiche); $e++) exit
create_script($p_string)
create the HTML for adding the script tags around of the script