noalyss Version-9
cfgledger.inc.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * NOALYSS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with NOALYSS; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21// Copyright Author Dany De Bontridder danydb@aevalys.eu
22
23/**
24 * @file
25 *
26 * @brief Create, update and delete ledgers
27 *
28 */
29if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
30require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
31require_once NOALYSS_INCLUDE.'/lib/user_menu.php';
32
34global $cn;
35
38
39
42
43$sa=$http->request("sa","string","");
44
45//////////////////////////////////////////////////////////////////////////
46// Perform request action : update
47//////////////////////////////////////////////////////////////////////////
48$action_frm = $http->post("action_frm","string","");
49if ( $action_frm == 'update')
50{
51 try
52 {
53 $ledger->set_ledger_id($http->post('p_jrn',"number"));
54 if ( $ledger->load() == false ) throw new Exception (_('Journal inexistant'));
55 $ledger->verify_ledger($_POST);
56 $ledger->update($_POST);
57 $show_menu=1;
58 } catch (Exception $e)
59 {
60 record_log($e->getMessage());
62 alert($e->getMessage());
63 }
64}
65
66//////////////////////////////////////////////////////////////////////////
67// Perform request action : delete
68//////////////////////////////////////////////////////////////////////////
69if ($action_frm == 'delete' )
70{
71 $ledger->set_ledger_id($http->post('p_jrn',"number"));
72 $ledger->load();
73 $name=$ledger->get_name();
74 try {
75 $ledger->delete_ledger();
76 $sa="";
77 echo '<div id="jrn_name_div">';
78 echo '<h1 id="jrn_name">';
79 printf(_(" %s est effacé"),h($name));
80 echo "</h1>";
81 echo '</div>';
82 $show_menu=1;
83 }
84 catch (Exception $e)
85 {
86 record_log($e->getMessage());
88 alert ($e->getMessage());
89 }
90
91}
92
93//////////////////////////////////////////////////////////////////////////
94// Perform request action : add
95//////////////////////////////////////////////////////////////////////////
96if (isset($_POST['add']))
97{
98 try
99 {
100 $ledger->verify_ledger($_POST);
101 $ledger->save_new($_POST);
102 $sa="detail";
103 $a[]=["key"=>'p_jrn',"value"=>$ledger->get_ledger_id()];
104 put_global($a);
105 $show_menu=1;
106 }
107 catch (Exception $e)
108 {
109 record_log($e->getMessage());
110 record_log($e);
111 alert($e->getMessage());
112 }
113}
114
115
116
117
118
119//////////////////////////////////////////////////////////////////////////
120//Display detail of ledger
121//////////////////////////////////////////////////////////////////////////
122
123switch ($sa)
124{
125 case 'detail': /* detail of a ledger */
126 try
127 {
128 $ledger->set_ledger_id($http->request('p_jrn',"number"));
129 echo '<div class="content">';
130 echo '<form id="cfg_ledger_frm" method="POST">';
131 echo $ledger->display_ledger();
132 echo HtmlInput::hidden('action_frm','');
133 echo '<INPUT TYPE="SUBMIT" class="smallbutton" VALUE="'._("Sauve").'" name="update" onClick="$(\'action_frm\').value=\'update\';return confirm_box(\'cfg_ledger_frm\',\'Valider ?\')">
134 <INPUT TYPE="RESET" class="smallbutton" VALUE="Reset">
135 <INPUT TYPE="submit" class="smallbutton" name="efface" value="'._("Efface").'" onClick="$(\'action_frm\').value=\'delete\';return confirm_box(\'cfg_ledger_frm\',\'Vous effacez ce journal ?\')">';
136 $href=http_build_query(array('ac'=>$http->request('ac'),'gDossier'=>$http->request('gDossier',"number")));
137 echo '<a style="display:inline" class="smallbutton" href="do.php?'.$href.'">'._('Retour').'</a>';
138 echo '</FORM>';
139 echo "</div>";
140 $show_menu=0;
141 }
142 catch (Exception $e)
143 {
144 record_log($e->getMessage());
145 record_log($e);
146 alert($e->getMessage());
147 }
148 break;
149 case 'add': /* Add a new ledger */
150 echo '<div class="content">';
151 echo '<FORM METHOD="POST">';
152 $ledger->input_new();
153 echo HtmlInput::submit('add',_('Sauver'));
154 echo '<INPUT TYPE="RESET" class="smallbutton" VALUE="Reset">';
155 echo '</FORM>';
156 echo "</DIV>";
157 $show_menu=0;
158}
159
160//////////////////////////////////////////////////////////////////////////
161// Display list of ledgers
162//////////////////////////////////////////////////////////////////////////
163if ( $show_menu == 1 ) {
164 echo '<span style="float:right;margin-top:10px">';
165 echo HtmlInput::anchor_action(_("Tout"), 'show_all_row(\'cfgledger_table_id\')','ledger_all_bt','smallbutton ');
166 echo HtmlInput::anchor_action(_("Financier"), 'show_only_row(\'cfgledger_table_id\',\'ledger_type\',\'FIN\')','ledger_fin_bt','smallbutton ');
167 echo HtmlInput::anchor_action(_("Achat"), 'show_only_row(\'cfgledger_table_id\',\'ledger_type\',\'ACH\')','ledger_ach_bt','smallbutton ');
168 echo HtmlInput::anchor_action(_("Opérations Diverses"), 'show_only_row(\'cfgledger_table_id\',\'ledger_type\',\'ODS\')','ledger_ods_bt','smallbutton ');
169 echo HtmlInput::anchor_action(_("Vente"), 'show_only_row(\'cfgledger_table_id\',\'ledger_type\',\'VEN\')','ledger_ven_bt','smallbutton ');
170 echo '</span>';
171 echo '<div class="content">';
172 echo $ledger->listing();
173 echo '</div>';
174}
175
176
178
179
180
181?>
put_global($array)
Put in superglobal (get,post,request) the value contained in the parameter field (me_parameter)
Definition: ac_common.php:1233
html_page_stop()
end tag
Definition: ac_common.php:468
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342
alert($p_msg, $buffer=false)
alert in javascript
Definition: ac_common.php:738
$href
Definition: adm.inc.php:31
h( $row[ 'oa_description'])
$input_from id
Definition: balance.inc.php:63
$gDossier
$ledger
global $cn
$action_frm
$http
$show_menu
global $g_parameter
static hidden($p_name, $p_value, $p_id="")
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
static anchor_action($action, $javascript, $id=NULL, $p_class="button", $p_symbole="")
Anchor Html with javascript.
manage the http input (get , post, request) and extract from an array
$_POST['ac']
Definition: do.php:310