noalyss Version-9
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');
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 $internal=$Ledger->insert($_POST);
126
127 /* Save the predefined operation */
128 if ( isset($_POST['opd_name']) && trim($_POST['opd_name']) != "" )
129 {
130 $opd=new Pre_operation($cn);
131 $opd->get_post();
132 $opd->save();
133 }
134
135 /* Show button */
136 echo '<h1> Enregistrement </h1>';
137
138 echo $Ledger->confirm($_POST,true);
139 /* Show link for Invoice */
140 if (isset ($Ledger->doc) )
141 {
142 echo '<h2>'._('Document').' </h2>';
143 echo $Ledger->doc;
144 }
145
146
147 /* Save the additional information into jrn_info */
149 $obj->save_extra($Ledger->jr_id,$_POST);
150
151 /* save followup */
152 $Ledger->save_followup($http->request("action_gestion","string",""));
153
154 // extourne
155 if (isset($_POST['reverse_ck']))
156 {
157 $p_date=$http->post('reverse_date', "string",'');
158 $p_msg=$http->post("ext_label");
159 if (isDate($p_date)==$p_date)
160 {
161 // reverse the operation
162 try
163 {
164 $Ledger->reverse($p_date,$p_msg);
165 echo '<p>';
166 echo _('Extourné au ').$p_date;
167 echo '</p>';
168
169 }
170 catch (Exception $e)
171 {
172 echo '<span class="warning">'._('Opération non extournée').
173 $e->getMessage().
174 '</span>';
175 }
176 }
177 else
178 {
179 // warning because date is invalid
180 echo '<span class="warning">'._('Date invalide, opération non extournée').'</span>';
181 }
182 }
183 echo '<ul class="aligned-block">';
184 echo "<li>";
185 echo $Ledger->button_new_operation();
186 echo "</li>";
187 echo "<li>";
188 echo $Ledger->button_copy_operation();
189 echo "</li>";
190 echo "</ul>";
191 echo '</div>';
192 return;
193 }
194}
195// ------------------------------
196/* Display a blank form or a form with predef operation */
197// ------------------------------
198
199$array=(isset($_POST['correct'])||isset ($correct))?$_POST:null;
201//
202// pre defined operation
203//
204echo '<div class="content">';
205
206if (!isset($_REQUEST ['p_jrn']))
207{
208 $def_ledger=$Ledger->get_first('ven', 2);
209 if (empty($def_ledger))
210 {
211 exit(_('Pas de journal disponible'));
212 }
213 $Ledger->id=$def_ledger['jrn_def_id'];
214}
215else if ( isset($_REQUEST ['p_jrn']) ) {
216 $Ledger->id=$http->request('p_jrn','number');
217}
218else if (isset($_REQUEST['p_jrn_predef']))
219{
220 $Ledger->id=$http->request('p_jrn_predef','number');
221}
222
223
224
225echo '<div class="content">';
226if ($p_msg!="")
227{
228 echo '<span class="warning">'.$p_msg.'</span>';
229}
230try
231{
232 $payment=$http->request("e_mp","string", 0);
233 $date_payment=$http->request("mp_date", "string","");
234 $comm_payment=$http->request("e_comm_paiement", "string","");
235 $acompte=$http->request("acompte", "string",0);
236
237 echo "<FORM class=\"print\" NAME=\"form_detail\" METHOD=\"POST\" >";
238 /* request for a predefined operation */
239 if (isset($_REQUEST['pre_def'])&&!isset($_POST['correct']) && ! isset($correct))
240 {
241 // used a predefined operation
242 //
243 $op=new Pre_operation($cn);
244 $op->set_od_id($http->request('pre_def'));
245 $p_post=$op->compute_array();
246 $Ledger->id=$http->request('p_jrn_predef');
247
248 echo $Ledger->input($p_post);
249 echo '<div class="content">';
250 echo $Ledger->input_paid($payment);
251 echo '</div>';
252 echo '<script>';
253 echo 'compute_all_ledger();';
254 echo '</script>';
255 }
256 else if (isset($_GET['create_invoice']))
257 {
258 $action_id=$http->get('ag_id',"number");
259 $array=$Ledger->convert_from_follow($action_id);
260 echo HtmlInput::hidden("ledger_type", "VEN");
261 echo HtmlInput::hidden("ac", $http->get('ac'));
262 echo HtmlInput::hidden("sa", "p");
263 echo HtmlInput::hidden("action_gestion",$action_id);
264 echo $Ledger->input($array);
265 echo '<div class="content">';
266 echo $Ledger->input_paid($payment,$acompte,$date_payment,$comm_payment);
267 echo '</div>';
268 echo '<script>';
269 echo 'compute_all_ledger();';
270 echo '</script>';
271 }
272 else
273 {
274 echo HtmlInput::hidden("ledger_type", "VEN");
275 echo HtmlInput::hidden("ac", $strac);
276 echo HtmlInput::hidden("sa", "p");
277 $action_id=$http->get('ag_id',"string","");
278 echo HtmlInput::hidden("action_gestion",$action_id);
279 echo $Ledger->input($array);
280 echo '<div class="content">';
281 echo $Ledger->input_paid($payment,$acompte,$date_payment,$comm_payment);
282 echo '</div>';
283 echo '<script>';
284 echo 'compute_all_ledger();';
285 echo '</script>';
286 }
287}
288catch (Exception $e)
289{
290 alert($e->getMessage());
291 return;
292}
293echo '<div class="content">';
294
295
296 echo HtmlInput::button('act',_('Actualiser'),'onClick="compute_all_ledger();"');
297 echo HtmlInput::submit("view_invoice",_("Enregistrer"));
298 echo HtmlInput::reset(_('Effacer '));
299 echo '</div>';
300 echo "</FORM>";
301
302 /* if we suggest the pj n# the run the script */
303 if ( $g_parameter->MY_PJ_SUGGEST=='Y')
304 {
305 echo '<script> update_pj()</script>';
306 }
307$e_date=$http->request("e_date","string","");
308
309if ($e_date=="" && $g_parameter->MY_DATE_SUGGEST=='Y')
310{
311 echo create_script(" get_last_date()");
312}
313
314
315echo create_script(" update_name()");
316return;
317?>
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
is_msie()
Check if we use IE 8 or 9.
Definition: ac_common.php:1328
global $g_user
if no group available , then stop
$op
Definition: ajax_admin.php:38
$_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 sold,.
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
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
$p_msg
$gDossier
$str_dossier
$comm_payment
$acompte
$date_payment
$strac
$Ledger
global $g_parameter
if( $g_parameter->MY_PJ_SUGGEST=='Y') $e_date
$post_jrn
if(isset($_REQUEST['p_jrn']) && $g_user->check_jrn($http->request("p_jrn","number")) !='W') if(isset( $_POST[ 'view_invoice'])) if(isset($_POST['record'])) $array
$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