noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
periode.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// Copyright Author Dany De Bontridder danydb@aevalys.eu
20/*! \file
21 * \brief add, modify, close or delete a period
22 */
23if (!defined('ALLOWED'))
24 die('Appel direct ne sont pas permis');
25$gDossier=dossier::id();
26echo '<div class="content">';
27$cn=Dossier::connect();
28//-----------------------------------------------------
29// Periode
30//-----------------------------------------------------
32
33$p_ledger_id=$http->request("jrn_def_id", "number", 0);
34?>
35<script>
36 var jsper = new Periode(<?php echo $p_ledger_id; ?>);
37 jsper.set_callback("ajax_misc.php");
38 jsper.set_js_obj_name("jsper");
39 jsper.set_dossier('<?php echo Dossier::id(); ?>');
40
41</script>
42<?php
43//-------------------------------------------------------------------
44//Modify exercice label
45//-------------------------------------------------------------------
46if ( isset($_POST['mod_exercice_label_bt'])) {
47 $err = 0;
48 $p_exercice_label=$http->post("p_exercice_label");
49 $p_exercice=$http->post("p_exercice");
50 if (empty(trim($p_exercice_label))) {
51 echo_warning(_("Libellé exercice ne peut pas être vide"));
52 $err =1;
53 }
54 if ($err == 0 && $cn->get_value("select count(*) from parm_periode where p_exercice_label=$1 and p_exercice <>$2",
55 [$p_exercice_label,$p_exercice]) > 0)
56 {
57 echo_warning(_("Le même libellé ne peut pas être utilisé pour 2 exercices"));
58 $err=1;
59 }
60
61 if ($err == 0) {
62 try
63 {
64 $cn->start();
65 /**
66 * @todo
67 * Rewrite : split table parm_periode into parm_periode and parm_exercice
68 * disabling temporarily a trigger is not the right solution ,
69 * but make the trigger more flexible and less secure
70 * is worst. The trigger is disable in a transaction means it is still enable
71 * for other session.
72 */
73 $cn->exec_sql("alter table parm_periode disable trigger parm_periode_check_periode_trg");
74 $cn->exec_sql("update parm_periode set p_exercice_label=$1 where p_exercice=$2",
75 [$p_exercice_label,$p_exercice]);
76 $cn->exec_sql("alter table parm_periode enable trigger parm_periode_check_periode_trg");
77 $cn->commit();
78
79 }
80 catch (Exception $exc)
81 {
82 echo_warning( $exc->getMessage());
83 record_log($exc);
84 $cn->rollback();
85 }
86
87 }
88}
89//--------------------------------------------------------------------
90// Add an exercice
91// receive nb_exercice
92//--------------------------------------------------------------------
93if (isset($_POST['add_exercice']))
94{
95 $obj=new Periode($cn);
96 try
97 {
98 $p_exercice=$http->post("p_exercice", "number");
99 $p_exercice_label=$http->post("p_exercice_label", "string");
100 $p_year=$http->post("p_year", "number");
101 $nb_month=$http->post("nb_month", "number");
102 $from_month=$http->post("from_month", "number");
103 $day_opening=$http->post("day_opening", "string", 0);
104 $day_closing=$http->post("day_closing", "string", 0);
105 $exercice=new Periode($cn);
106 $exercice->insert_exercice($p_exercice, $p_year, $from_month, $nb_month,
107 $day_opening, $day_closing,$p_exercice_label);
108 }
109 catch (Exception $ex)
110 {
111 echo_warning($ex->getMessage());
112 record_log($exc);
113 }
114}
115//-------------------------------------------------------------------
116// Select a ledger or global
117//-------------------------------------------------------------------
118echo '<form method="GET" >';
119echo dossier::hidden();
120$sel_jrn=$cn->make_array("select jrn_def_id, jrn_def_name from ".
121 " jrn_def order by jrn_def_name");
122$sel_jrn[]=array('value'=>0, 'label'=>_('Global : periode pour tous les journaux'));
125$wSel->name='jrn_def_id';
127echo _("Choisissez global ou uniquement le journal à fermer").$wSel->input();
128echo HtmlInput::hidden('ac', $http->request('ac'));
129// display a filter by exercice
130echo _("Montrer l'exercice");
131$max_exercice=$cn->get_value("select max(p_exercice) from parm_periode");
132$p_exercice=$http->request("p_exercice_sel","string",$max_exercice);
133Periode::filter_exercice($p_exercice);
134$js_close_selected="jsper.close_selected()";
135
136echo HtmlInput::submit('choose', 'Valider');
137echo "</form>";
138
139echo HtmlInput::button_action(_("Fermer les périodes sélectionnées"),
141
142/*
143 * Display all the periode for all ledgers
144 */
145if ($p_ledger_id==0)
146{
147 echo HtmlInput::button_action(_("Ajout exercice"),
148 "\$('exercice_add').show()");
149//-------------------------------------------------------------------
150// Add a new Exercice
151//-------------------------------------------------------------------
152 echo '<div id="exercice_add" style="display:none" class="inner_box">';
153 Periode::form_exercice_add();
154 echo '</div>';
155//-------------------------------------------------------------------
156// Add a new Periode
157//-------------------------------------------------------------------
158 echo HtmlInput::button_action(_("Ajout période"), "\$('periode_add').show()");
159 echo '<div id="periode_add" style="display:none;width:auto" class="inner_box">';
160 Periode::form_periode_add("jsper");
161 echo '</div>';
162//-------------------------------------------------------------------
163// Change label of Exercice
164//-------------------------------------------------------------------
165 echo HtmlInput::button_action(_("Modifie libellé exercice"), "\$('exercice_label_div').show()");
166 echo '<div id="exercice_label_div" style="display:none;width:60ch" class="inner_box">';
167 Periode::form_exercice_label("jsper");
168 echo '</div>';
169
170//-------------------------------------------------------------------
171// List of Periode
172//-------------------------------------------------------------------
173 $periode=new Parm_Periode_SQL($cn);
174 Periode::display_periode_global("jsper");
175}
176else
177{
178 echo '<p class="info">'._("Pour ajouter, effacer ou modifier une période, il faut choisir global").'</p>';
180 echo h2($ledger->get_name());
181
183 $ret=$periode_ledger->get_resource_periode_ledger($p_ledger_id);
184 $periode_ledger->display_table($ret, "jsper");
185}
186
187echo '</div>';
188?>
189<script>
190 Periode.filter_exercice('periode_tbl');
191 activate_checkbox_range("sel_per_close_ck");
192</script>
h2($p_string, $p_class="", $raw="")
Definition ac_common.php:68
echo_warning($p_string)
warns
record_log($p_message)
Record an error message into the log file of the server or in the log folder of NOALYSS Record also t...
catch(Exception $e) $obj
catch(Exception $e) $exercice
_("actif, passif,charge,...")
$ex
Class for jrn, class acc_ledger for manipulating the ledger AND some acc.
manage the http input (get , post, request) and extract from an array
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
Display the periode per ledger: close : reopen ... the close , open must be done thanks Periode.
$_POST['ac']
Definition do.php:323
$p_exercice
$p_ledger_id
$wSel
$max_exercice
$js_close_selected
$periode_ledger
$sel_jrn