noalyss Version-9
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
30
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 $a= $Ledger->insert($_POST);
120 echo '<h1>'._('Enregistrement').' </h1>';
121 echo '<div class="content">';
122 echo $a;
123 echo '</div>';
124
125 echo '</div>';
126 echo $Ledger->button_new_operation();
127 return;
128 }
129}
130//----------------------------------------
131// Correct the operations
132//----------------------------------------
133if ( isset($_POST['correct']))
134{
135 $correct=1;
136}
137//----------------------------------------
138// Blank form
139//----------------------------------------
140if ( $p_msg !="" ) echo '<span class="warning">'.$p_msg.'</span>';
141
142echo '<form class="print" name="form_detail" enctype="multipart/form-data" class="print" METHOD="POST">';
143echo HtmlInput::hidden('ledger_type','fin');
144echo HtmlInput::hidden('ac',$http->request("ac"));
145$array=( isset($correct))?$_POST:null;
146
147// show select ledger
148try
149{
150 echo $Ledger->input($array);
151
153 echo HtmlInput::submit('save',_('Sauve'));
154 echo HtmlInput::reset(_('Effacer'));
155
156 $script="update_name();";
157 $e_date=$http->request("e_date","string","");
158
159 if ($e_date=="" && $g_parameter->MY_DATE_SUGGEST=='Y'){
160 $script.=" get_last_date();";
161
162 }
163
164 if ( ! isset ($_REQUEST['first_sold']) ) {
165 $script.=" ajax_saldo('first_sold');";
166 }
168} catch (Exception $ex) {
169 echo $ex->getMessage();
170}
171return;
echo_warning($p_string)
warns
Definition: ac_common.php:589
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
$_REQUEST['ac']
$ex
Definition: balance.inc.php:45
the class Acc_Ledger_Fin inherits from Acc_Ledger, this object permit to manage the financial ledger
static connect()
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
$p_msg
if(empty($def_ledger)) $Ledger id
$gDossier
$jrn_priv
$menu_action
global $g_user
$Ledger
global $g_parameter
if( $g_parameter->MY_PJ_SUGGEST=='Y') $e_date
$_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
$script
Definition: popup.php:125