noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
compta_ven.inc.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21
22/*!\file
23 * \brief file included to manage all the operations for the ledger of sales
24 */
25if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
27$gDossier=dossier::id();
28$cn=Dossier::connect();
29//menu = show a list of ledger
30$str_dossier=dossier::get();
33$strac=$http->request('ac');
34$ac="ac=".$strac;
36$post_jrn=$http->post("p_jrn", "string","");
37//----------------------------------------------------------------------
38// Encode a new invoice
39// empty form for encoding
40//----------------------------------------------------------------------
41
43
44// Check privilege
45if ( isset($_REQUEST['p_jrn']) &&
46 $g_user->check_jrn($http->request("p_jrn","number")) != 'W' )
47{
48
49 NoAccess();
50 exit -1;
51}
52
53/* if a new invoice is encoded, we display a form for confirmation */
54if ( isset ($_POST['view_invoice'] ) )
55{
56 $p_jrn=$http->post("p_jrn","number");
58 try
59 {
60 $Ledger->verify_operation($_POST);
61 }
62 catch (Exception $e)
63 {
64 alert($e->getMessage());
65 $p_msg=$e->getMessage();
66 $correct=1;
67 }
68 // if correct is not set it means it is correct
69 if ( ! isset($correct))
70 {
71 echo '<div class="content">';
72
73 echo '<div id="confirm_div_id" style="width: 47%; float: left;">';
74 echo h1(_("Confirmation"));
75 echo span(_("Vous devez encore confirmer"),' class="notice"');
76 echo '</div>';
77
78 echo '<div id="confirm_div_id" style="width: 100%; float: left;">';
79 echo '<form class="print" enctype="multipart/form-data" method="post">';
80 echo dossier::hidden();
81 echo $Ledger->confirm($_POST );
82 echo HtmlInput::hidden('ac',$strac);
83 $Ledger->input_extra_info();
84 echo HtmlInput::submit("record", _("Enregistrement"), 'onClick="return verify_ca(\'\');"');
85 echo HtmlInput::submit('correct', _("Corriger"));
86 echo '</form>';
87 echo '</div>';
88 if (DEBUGNOALYSS>1) { echo "<!-- confirm_div_id -->";}
89 return;
90 }
91}
92//------------------------------
93/* Record the invoice */
94//------------------------------
95
96if ( isset($_POST['record']) )
97{
98// Check privilege
99 if ( $g_user->check_jrn($post_jrn) != 'W' )
100 {
101
102 NoAccess();
103 exit -1;
104 }
105
107 try
108 {
109 $Ledger->verify_operation($_POST);
110 }
111 catch (Exception $e)
112 {
113 alert($e->getMessage());
114 $correct=1;
115 }
116
117 if ( ! isset($correct))
118 {
119 if ( is_msie() == 0 )
120 echo '<div style="position:absolute" class="content">';
121 else
122 echo '<div class="content">';
123
124 $Ledger=new Acc_Ledger_Sale($cn,$_POST['p_jrn']);
125 try {
126 $internal=$Ledger->insert($_POST);
127
128 }
129 catch (\Exception $e) {
130 if ( $e->getCode()==EXC_BALANCE)
131 echo_warning(_("enregistrement annulé: balance , voyer le fichier log"));
132 else
133 echo_warning($e->getMessage());
134 return;
135 }
136
137
138 /* Save the predefined operation */
139 if ( isset($_POST['opd_name']) && trim($_POST['opd_name']) != "" )
140 {
141 $opd=new Pre_operation($cn);
142 $opd->get_post();
143 $opd->save();
144 }
145
146 /* Show button */
147 echo '<h1> Enregistrement </h1>';
148
149 echo $Ledger->confirm($_POST,true);
150 /* Show link for Invoice */
151 if (isset ($Ledger->doc) )
152 {
153 echo '<h2 class="h-section">'._('Document').' </h2>';
154 echo $Ledger->doc;
155 }
156
157
158 /* Save the additional information into jrn_info */
160 $obj->save_extra($Ledger->jr_id,$_POST);
161
162 /* save followup */
163 $Ledger->save_followup($http->request("action_gestion","string",""));
164
165 // extourne
166 if (isset($_POST['reverse_ck']))
167 {
168 $p_date=$http->post('reverse_date', "string",'');
169 $p_msg=$http->post("ext_label");
170 if (isDate($p_date)==$p_date)
171 {
172 // reverse the operation
173 try
174 {
175 $Ledger->reverse($p_date,$p_msg);
176 echo '<p>';
177 echo _('Extourné au ').$p_date;
178 echo '</p>';
179
180 }
181 catch (Exception $e)
182 {
183 echo '<span class="warning">'._('Opération non extournée').
184 $e->getMessage().
185 '</span>';
186 }
187 }
188 else
189 {
190 // warning because date is invalid
191 echo '<span class="warning">'._('Date invalide, opération non extournée').'</span>';
192 }
193 }
194 echo '<ul class="aligned-block">';
195 echo "<li>";
196 echo $Ledger->button_new_operation();
197 echo "</li>";
198 echo "<li>";
199 echo $Ledger->button_copy_operation();
200 echo "</li>";
201 echo "</ul>";
202 echo '</div>';
203 return;
204 }
205}
206// ------------------------------
207/* Display a blank form or a form with predef operation */
208// ------------------------------
209
210$array=(isset($_POST['correct'])||isset ($correct))?$_POST:null;
212//
213// pre defined operation
214//
215echo '<div class="content">';
216
217if (!isset($_REQUEST ['p_jrn']))
218{
219 $def_ledger=$Ledger->get_first('ven', 2);
220 if (empty($def_ledger))
221 {
222 exit(_('Pas de journal disponible'));
223 }
224 $Ledger->id=$def_ledger['jrn_def_id'];
225}
226else if ( isset($_REQUEST ['p_jrn']) ) {
227 $Ledger->id=$http->request('p_jrn','number');
228}
229else if (isset($_REQUEST['p_jrn_predef']))
230{
231 $Ledger->id=$http->request('p_jrn_predef','number');
232}
233
234
235
236echo '<div class="content">';
237if ($p_msg!="")
238{
239 echo '<span class="warning">'.$p_msg.'</span>';
240}
241try
242{
243 $payment=$http->request("e_mp","string", 0);
244 $date_payment=$http->request("mp_date", "string","");
245 $comm_payment=$http->request("e_comm_paiement", "string","");
246 $acompte=$http->request("acompte", "string",0);
247
248 echo "<FORM class=\"print\" NAME=\"form_detail\" METHOD=\"POST\" >";
249 /* request for a predefined operation */
250 if (isset($_REQUEST['pre_def'])&&!isset($_POST['correct']) && ! isset($correct))
251 {
252 // used a predefined operation
253 //
254 $op=new Pre_operation($cn);
255 $op->set_od_id($http->request('pre_def'));
256 $p_post=$op->compute_array();
257 $Ledger->id=$http->request('p_jrn_predef');
258
259 echo $Ledger->input($p_post);
260 echo '<div class="content">';
261 echo $Ledger->input_paid($payment);
262 echo '</div>';
263 echo '<script>';
264 echo 'compute_all_ledger();';
265 echo '</script>';
266 }
267 else if (isset($_GET['create_invoice']))
268 {
269 $action_id=$http->get('ag_id',"number");
270 $cp=$http->get('cp','number',0);
271 $array=$Ledger->convert_from_follow($action_id,$cp);
272 echo HtmlInput::hidden("ledger_type", "VEN");
273 echo HtmlInput::hidden("ac", $http->get('ac'));
274 echo HtmlInput::hidden("sa", "p");
275 echo HtmlInput::hidden("action_gestion",$action_id);
276 echo $Ledger->input($array);
277 echo '<div class="content">';
278 echo $Ledger->input_paid($payment,$acompte,$date_payment,$comm_payment);
279 echo '</div>';
280 echo '<script>';
281 echo 'compute_all_ledger();';
282 echo '</script>';
283 }
284 else
285 {
286 echo HtmlInput::hidden("ledger_type", "VEN");
287 echo HtmlInput::hidden("ac", $strac);
288 echo HtmlInput::hidden("sa", "p");
289 $action_id=$http->get('ag_id',"string","");
290 echo HtmlInput::hidden("action_gestion",$action_id);
291 echo $Ledger->input($array);
292 echo '<div class="content">';
293 echo $Ledger->input_paid($payment,$acompte,$date_payment,$comm_payment);
294 echo '</div>';
295 echo '<script>';
296 echo 'compute_all_ledger();';
297 echo '</script>';
298 }
299}
300catch (Exception $e)
301{
302 alert($e->getMessage());
303 return;
304}
305echo '<div class="content">';
306
307
308 echo HtmlInput::button('act',_('Actualiser'),'onClick="compute_all_ledger();"');
309 echo HtmlInput::submit("view_invoice",_("Enregistrer"));
310 echo HtmlInput::reset(_('Effacer '));
311 echo '</div>';
312 echo "</FORM>";
313
314 /* if we suggest the pj n# the run the script */
315 if ( $g_parameter->MY_PJ_SUGGEST=='Y')
316 {
317 echo '<script> update_receipt()</script>';
318 }
319$e_date=$http->request("e_date","string","");
320
321if ($e_date=="" && $g_parameter->MY_DATE_SUGGEST=='Y')
322{
323 echo create_script(" get_last_date()");
324}
325
326
327echo create_script(" update_name()");
328return;
329?>
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
is_msie()
Check if we use IE 8 or 9.
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
$_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 sold,.
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
static echo_file($msg, $print=true)
display the file
Definition dbg.php:88
manage the predefined operation, link to the table op_def and op_def_detail
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