noalyss Version-9
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 HtmlInput::submit('confirm',_('Confirmer'));
89 echo HtmlInput::submit('correct',_('Corriger'));
90
91 echo '</form>';
92 echo '</div>';
93 return;
94 }
95}
96//----------------------------------------
97// Confirm and save the operations
98// into the database
99//----------------------------------------
100if ( isset($_POST['confirm']))
101{
102 try
103 {
104 $Ledger->verify_operation($_POST);
105 }
106 catch (Exception $e)
107 {
108 alert($e->getMessage());
109 $p_msg=$e->getMessage();
110 $correct=1;
111 }
112 if ( !isset($correct))
113 {
114 echo '<div id="jrn_name_div">';
115 echo '<h1 id="jrn_name" style="display:inline">' . $Ledger->get_name() . '</h1>';
116 echo '</div>';
117
118 echo '<div class="content">';
119 try {
120 $a= $Ledger->insert($_POST);
121
122 } catch (\Exception $e) {
123 if ( $e->getCode()==EXC_BALANCE)
124 echo_warning(_("enregistrement annulé: balance , voyer le fichier log"));
125 else
126 echo_warning($e->getMessage());
127 return;
128 }
129 echo '<h1>'._('Enregistrement').' </h1>';
130 echo '<div class="content">';
131 echo $a;
132 echo '</div>';
133
134 echo '</div>';
135 echo $Ledger->button_new_operation();
136 return;
137 }
138}
139//----------------------------------------
140// Correct the operations
141//----------------------------------------
142if ( isset($_POST['correct']))
143{
144 $correct=1;
145}
146//----------------------------------------
147// Blank form
148//----------------------------------------
149if ( $p_msg !="" ) echo '<span class="warning">'.$p_msg.'</span>';
150
151echo '<form class="print" name="form_detail" enctype="multipart/form-data" class="print" METHOD="POST">';
152echo HtmlInput::hidden('ledger_type','fin');
153echo HtmlInput::hidden('ac',$http->request("ac"));
154$array=( isset($correct))?$_POST:null;
155
156// show select ledger
157try
158{
159 echo $Ledger->input($array);
160
162 echo HtmlInput::submit('save',_('Sauve'));
163 echo HtmlInput::reset(_('Effacer'));
164
165 $script="update_name();";
166 $e_date=$http->request("e_date","string","");
167
168 if ($e_date=="" && $g_parameter->MY_DATE_SUGGEST=='Y'){
169 $script.=" get_last_date();";
170
171 }
172
173 if ( ! isset ($_REQUEST['first_sold']) ) {
174 $script.=" ajax_saldo('first_sold');";
175 }
177} catch (Exception $ex) {
178 echo $ex->getMessage();
179}
180return;
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)
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: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
$script
Definition popup.php:125