noalyss Version-9
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 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
109 try {
110 $internal = $Ledger->insert($_POST);
111 } catch (\Exception $e) {
112 if ( $e->getCode()==EXC_BALANCE)
113 echo_warning(_("enregistrement annulé: balance , voyer le fichier log"));
114 else
115 echo_warning($e->getMessage());
116 return;
117 }
118
119
120 /* Save the predefined operation */
121 if ( isset($_POST['opd_name']) && trim($_POST['opd_name']) != "" )
122 {
123 $opd = new Pre_operation($cn);
124 $opd->get_post();
125 $opd->save();
126 }
127
128 /* Show button */
129 $jr_id = $cn->get_value('select jr_id from jrn where jr_internal=$1', array($internal));
130
131 echo '<h1> '._('Enregistrement').' </h1>';
132 /* Save the additional information into jrn_info */
133 $obj = new Acc_Ledger_Info($cn);
134 $obj->save_extra($Ledger->jr_id, $_POST);
135
136 /* save followup */
137 $Ledger->save_followup($http->request("action_gestion","string",""));
138
139 // Feedback
140 echo $Ledger->confirm($_POST, true);
141 if (isset($Ledger->doc))
142 {
143 echo '<h2>'._('Document').'</h2>';
144 echo $Ledger->doc;
145 }
146 // extourne
147 if (isset($_POST['reverse_ck']))
148 {
149 $p_date=$http->post('reverse_date','string', '');
150 $p_msg=$http->post("ext_label");
151 if (isDate($p_date)==$p_date)
152 {
153 // reverse the operation
154 try
155 {
156 $Ledger->reverse($p_date,$p_msg);
157 echo '<p>';
158 printf ( _('Extourné au %s'),$p_date);
159 echo '</p>';
160 }
161 catch (Exception $e)
162 {
163 echo '<p class="error">'.
164 _('Opération non extournée').
165 " ".
166 $e->getMessage().
167 '</p>';
168 }
169 }
170 else
171 {
172 // warning because date is invalid
173 echo '<span class="warning">'._('Date invalide, opération non extournée').'</span>';
174 }
175 }
176 echo '<ul class="aligned-block">';
177 echo "<li>";
178 echo $Ledger->button_new_operation();
179 echo "</li>";
180 echo "<li>";
181 echo $Ledger->button_copy_operation();
182 echo "</li>";
183 echo "</ul>";
184 echo '</div>';
185 return;
186 }
187}
188// ------------------------------------------------------------
189/* Display a blank form or a form with predef operation */
190/* or a form for correcting */
191// -------------------------------------------------------------
192
193echo '<div class="content">';
194//
195
196
197$array = (isset($_POST['correct']) || isset($correct)) ? $_POST : null;
199
200
201if (!isset($_REQUEST ['p_jrn']))
202{
203 $def_ledger = $Ledger->get_first('ach',2);
204 if ( empty ($def_ledger))
205 {
206 exit(_('Pas de journal disponible'));
207 }
208 $Ledger->id = $def_ledger['jrn_def_id'];
209}
210else if (isset($_REQUEST ['p_jrn']))
211 $Ledger->id = $request_jrn;
212else if (isset ($_REQUEST['p_jrn_predef'])){
213 $Ledger->id=$http->request('p_jrn_predef');
214}
215// pre defined operation
216//
217
218echo '</div>';
219
220echo '<div class="content">';
221
222if ( $p_msg !="" ) echo '<span class="warning">'.$p_msg.'</span>';
223
224try
225{
226 $payment=$http->request("e_mp", "string",0);
227 $date_payment=$http->request("mp_date", "string","");
228 $comm_payment=$http->request("e_comm_paiement", "string","");
229 $acompte=$http->request("acompte", "string",0);
230
231 echo "<FORM class=\"print\"NAME=\"form_detail\" METHOD=\"POST\" >";
232 echo HtmlInput::hidden("ac", $ac);
233 /* request for a predefined operation */
234 if (isset($_REQUEST['pre_def'])&&!isset($_POST['correct']) && ! isset($correct) )
235 {
236 // used a predefined operation
237 $predef=$http->request("pre_def","string", "0");
238 $p_jrn_predef=$http->request("p_jrn_predef","string", "0");
239 $op=new Pre_operation($cn);
240 $op->set_od_id($predef);
241 $p_post=$op->compute_array();
242 $Ledger->id=$p_jrn_predef;
243 $p_post['p_jrn']=$Ledger->id;
244 echo $Ledger->input($p_post);
245 echo '<div class="content">';
246 echo $Ledger->input_paid($payment,$acompte,$date_payment,$comm_payment);
247 echo '</div>';
248 echo '<script>';
249 echo 'compute_all_ledger();';
250 echo '</script>';
251 }
252 else if (isset($_GET['create_feenote']))
253 {
254 $action_id=$http->get('ag_id',"number");
255 $cp=$http->get('cp','number',0);
256 $array=$Ledger->convert_from_follow($action_id,$cp);
257 echo HtmlInput::hidden("ledger_type", "VEN");
258 echo HtmlInput::hidden("ac",$http->get('ac'));
259 echo HtmlInput::hidden("sa", "p");
260 echo HtmlInput::hidden("action_gestion",$action_id);
261 echo $Ledger->input($array);
262 echo '<div class="content">';
263 echo $Ledger->input_paid($payment,$acompte,$date_payment,$comm_payment);
264 echo '</div>';
265 echo '<script>';
266 echo 'compute_all_ledger();';
267 echo '</script>';
268 }
269 else
270 {
271 echo $Ledger->input($array);
272 echo HtmlInput::hidden("p_action", "ach");
273 echo HtmlInput::hidden("sa", "p");
274 echo '<div class="content">';
275 echo $Ledger->input_paid($payment,$acompte,$date_payment,$comm_payment);
276 echo '</div>';
277 echo '<script>';
278 echo 'compute_all_ledger();';
279 echo '</script>';
280 }
281 echo '<div class="content">';
282 echo HtmlInput::button('act', _('Actualiser'),
283 'onClick="compute_all_ledger();"');
284 echo HtmlInput::submit("view_invoice", _("Enregistrer"));
285 echo HtmlInput::reset(_('Effacer '));
286 echo '</div>';
287 echo "</FORM>";
288}
289catch (Exception $e)
290{
291 alert($e->getMessage());
292 return;
293}
294$e_date=$http->request("e_date","string","");
295
296if ($e_date=="" && $g_parameter->MY_DATE_SUGGEST=='Y')
297 {
298 echo create_script(" get_last_date()");
299 }
300echo create_script(" update_name()");
301echo '</div>';
302
303
304return;
305// end record invoice
306?>
span($p_string, $p_extra='')
Definition ac_common.php:43
isDate($p_date)
echo_warning($p_string)
warns
h1($p_string, $p_class="")
Definition ac_common.php:72
NoAccess($js=1)
Echo no access and stop.
alert($p_msg, $buffer=false)
alert in javascript
global $g_parameter
global $g_user
if no group available , then stop
$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,...
Handle the ledger of purchase,.
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
$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:349
$_POST['ac']
Definition do.php:312
for($e=0; $e< count($afiche); $e++) exit
create_script($p_string)
create the HTML for adding the script tags around of the script