noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
compta_fin.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 this file is to be included to handle the financial ledger
24 */
25if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
27
28$gDossier=dossier::id();
30
31$cn=Dossier::connect();
32$menu_action="?ledger_type=fin&ac=".$http->request('ac')."&".dossier::get();
33
35
36//--------------------------------------------------------------------------------
37// Encode a new financial operation
38//--------------------------------------------------------------------------------
39
40if ( isset($_REQUEST['p_jrn'] ) )
41{
42 $Ledger->id=$http->request('p_jrn',"number");
43}
44else
45{
46 $def_ledger=$Ledger->get_first('fin');
47 if ( empty ($def_ledger))
48 {
49 exit(_('Pas de journal disponible'));
50 }
51 $Ledger->id=$def_ledger['jrn_def_id'];
52}
53
54$jrn_priv=$g_user->get_ledger_access($Ledger->id);
55// Check privilege
56if ( $jrn_priv == 'X')
57{
58 NoAccess();
59 exit -1;
60}
61
62$Ledger->load();
63
65//----------------------------------------
66// Confirm the operations
67//----------------------------------------
68if ( isset($_POST['save']))
69{
70 try
71 {
72 $Ledger->verify_operation($_POST);
73 }
74 catch (Exception $e)
75 {
76 alert($e->getMessage());
77 $p_msg=$e->getMessage();
78 $correct=1;
79 }
80 if ( ! isset ($correct ))
81 {
82 echo '<div class="content">';
83 echo h1(_('Confirmation'),'');
84 echo_warning(_("Attention, cette opération n'est pas encore sauvée : vous devez encore confirmer"));
85 echo '<form name="form_detail" class="print" enctype="multipart/form-data" class="print" METHOD="POST">';
86 echo HtmlInput::hidden('ac',$_REQUEST['ac']);
87 echo $Ledger->confirm($_POST);
88 echo '<div class="bt-center">';
89 echo '<ul class="aligned-block">';
90 echo '<li>';
91 echo HtmlInput::submit("confirm", _("Confirmer"), 'onClick="return verify_ca(\'\');"', p_class: "button");
92 echo '</li>';
93 echo '<li>';
94 echo HtmlInput::submit('correct', _("Corriger"), p_class: "button");
95 echo '</li>';
96 echo '</ul>';
97 echo '</div>';
98 echo '</form>';
99 echo '</div>';
100 return;
101 }
102}
103//----------------------------------------
104// Confirm and save the operations
105// into the database
106//----------------------------------------
107if ( isset($_POST['confirm']))
108{
109 try
110 {
111 $Ledger->verify_operation($_POST);
112 }
113 catch (Exception $e)
114 {
115 alert($e->getMessage());
116 $p_msg=$e->getMessage();
117 $correct=1;
118 }
119 if ( !isset($correct))
120 {
121 echo '<div id="jrn_name_div">';
122 echo '<h1 id="jrn_name" style="display:inline">' . $Ledger->get_name() . '</h1>';
123 echo '</div>';
124
125 echo '<div class="content">';
126 try {
127 $a= $Ledger->insert($_POST);
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 echo '<h1>'._('Enregistrement').' </h1>';
137 echo '<div class="content">';
138 echo $a;
139 echo '</div>';
140
141 echo '</div>';
142 echo '<div class="bt-center">';
143 echo '<ul class="aligned-block">';
144 echo '<li>';
145 echo $Ledger->button_new_operation();
146 echo '</li>';
147 echo '</ul>';
148 echo '</div>';
149 return;
150 }
151}
152//----------------------------------------
153// Correct the operations
154//----------------------------------------
155if ( isset($_POST['correct']))
156{
157 $correct=1;
158}
159//----------------------------------------
160// Blank form
161//----------------------------------------
162echo '<div class="content">';
163if ( $p_msg !="" ) echo '<span class="warning">'.$p_msg.'</span>';
164echo '<form class="print" name="form_detail" enctype="multipart/form-data" class="print" METHOD="POST">';
165echo HtmlInput::hidden('ledger_type','fin');
166echo HtmlInput::hidden('ac',$http->request("ac"));
167$array=( isset($correct))?$_POST:null;
168
169// show select ledger
170try
171{
172 echo $Ledger->input($array);
173
175 echo '<div class="bt-center">';
176 echo '<ul class="aligned-block">';
177/* echo '<li>';
178 echo HtmlInput::button('act', _('Actualiser'), 'onClick="checkTotalDirect()();"', p_class: "button");
179 echo '</li>';*/
180 echo '<li>';
181 echo HtmlInput::submit("save", _("Enregistrer"), p_class: "button");
182 echo '</li>';
183 echo '<li>';
184 echo HtmlInput::reset(_('Effacer '), p_class: "button");
185 echo '</li>';
186 echo '</ul>';
187 echo '</div>';
188
189 $script="update_name();";
190 $e_date=$http->request("e_date","string","");
191
192 if ($e_date=="" && $g_parameter->MY_DATE_SUGGEST=='Y'){
193 $script.=" get_last_date();";
194
195 }
196
197 if ( ! isset ($_REQUEST['first_sold']) ) {
198 $script.=" ajax_saldo('first_sold');";
199 }
201} catch (Exception $ex) {
202 echo $ex->getMessage();
203}
204echo '</div>';
205return;
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
foreach(array( 'l', 'gDossier') as $a) if(is_numeric($l)==false) $Ledger
$_REQUEST['ac']
_("actif, passif,charge,...")
$ex
the class Acc_Ledger_Fin inherits from Acc_Ledger, this object permit to manage the financial ledger
static ledger_add_item($p_ledger)
Build a HTML string for adding multiple rows.
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
if($request_jrn !="" && $g_user->check_jrn($request_jrn) !='W' $p_msg)
$jrn_priv
$menu_action
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
$script
Definition popup.php:131