noalyss Version-9
anc_od.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 *
24 *
25 * \brief Misc Operation for analytic accountancy
26 *
27 */
28if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
29
30global $g_user;
32
35$m=$pa->get_list();
36if ( ! $m )
37{
38
39 echo '<div ><h2 class="error">'._('Aucun plan analytique défini').'</h2></div>';
40 return;
41}
42
44
45
46echo '
47<div class="menu2">
48';
49
50//----------------------------------------------------------------------
51// show the menu
52//----------------------------------------------------------------------
53echo ShowItem(array(
54 array(
55 "?".http_build_query(["ac"=>$http->request("ac"),"new"=>1,"gDossier"=>$dossier_id]),
56 _("Nouveau"),
57 _("Nouvelle opération")
58 ),
59 array (
60 "?".http_build_query(["ac"=>$http->request("ac"),"see"=>1,"gDossier"=>$dossier_id]),
61 _("Liste"),
62 _("Liste opérations")
63 )
64), "H", "nav-item", "nav-link", "", "nav nav-pills nav-level3");
65
66
67//----------------------------------------------------------------------
68// the pa_id is set
69//
70//----------------------------------------------------------------------
71if ( isset($_GET['see']))
72{
73
74 // Show the list for the period
75 // and exit
76 //-----------------------------
77 $a=new Anc_Operation($cn);
78
79 echo '
80 <div class="content" >
81 <form method= "get">
82 ';
83
84 echo dossier::hidden();
85 $hid=new IHidden();
86 $exercice=$http->request("exercice","number",0);
87 if ($exercice == 0 ){
88 $exercice=$g_user->get_exercice();
89 }
90 $ex=new Exercice($cn);
91 $js=sprintf("updatePeriode(%d,'%s','%s')",Dossier::id(),'exercice','p_periode');
92 $wex=$ex->select('exercice',$exercice,' onchange="'.$js.'"');
93 echo $wex->input();
94 $hid->name="ac";
95 $hid->value=$http->request("ac");
96 echo $hid->input();
97
98 $hid->name="see";
99 $hid->value="";
100 echo $hid->input();
101
102 $w=new ISelect();
103 $w->name="p_periode";
104// filter on the current year
105 $filter_year=" where p_exercice='".$g_user->get_exercice()."'";
106
107 $periode_start=$cn->make_array("select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode
108 where p_exercice=$1 order by p_start,p_end",1,[$exercice]);
109 $g_user=new Noalyss_user($cn);
110 $current=$http->get("p_periode","number",$g_user->get_periode());
111 $w->value=$periode_start;
112 $w->selected=$current;
113 echo _('Filtrer par période').":".$w->input().HtmlInput::submit('gl_submit','Valider').'</form>';
114 echo '<hr>';
115
116 echo '<div class="content" >';
117 echo $a->html_table($current);
118 echo '</div>';
119 return;
120}
121if ( isset($_POST['save']))
122{
123 // record the operation and exit
124 // and exit
125 //-----------------------------
126 echo '<div class="redcontent" >'.
127 _('Opération sauvée');
129
130 $a->get_from_array($_POST);
131
132 $a->save();
133 echo $a->show();
134 echo '</div>';
135 return;
136}
137
138if ( isset($_GET['new']))
139{
140 //show the form for entering a new Anc_Operation
141 //------------------------------------------
143
144 $wSubmit=new IHidden("p_action","ca_od");
145 $wSubmit->table=0;
146 echo '<div class="redcontent" >';
147 echo '<form id="anc_od_frm" method="post" onsubmit="return validate_anc(\'anc_od_frm\');return false;">';
148 echo dossier::hidden();
149 echo $wSubmit->input();
150 echo $a->form();
151 echo HtmlInput::submit("save",_("Sauver"));
152 echo '</form>';
153 echo '<div class="info">';
154 echo _('Débit').' = <span id="totalDeb"></span>';
155 echo _('Crédit').' = <span id="totalCred"></span>';
156 echo _('Difference').' = <span id="totalDiff"></span>
157 </div>
158 ';
159
160 echo '</div>';
161 $msg_comment=_("Commentaire vide");
162 $msg_date=_("Date invalide");
163echo <<<EOF
164<script>
165 function validate_anc(p_frm_id) {
166 try {
167 if ($('pdesc').value.length==0) {
168 smoke.alert('$msg_comment');
169 return false;
170 }
171 if ( ! check_date($(p_frm_id)['pdate'].value) ) {
172 smoke.alert('$msg_date');
173 return false;
174 }
175 } catch (e) {
176 smoke.alert(e.message);
177 }
178 return ;
179 }
180
181</script>;
182
183EOF;
184
185 return;
186}
187
188?>
189<div class="redcontent">
ShowItem($p_array, $p_dir='V', $class="nav-item", $class_ref="nav-link", $default="", $p_extra="nav nav-pills nav-fill")
store the string which print the content of p_array in a table used to display the menu
Definition: ac_common.php:535
catch(Exception $e) $exercice
foreach($array as $idx=> $m) $w
$m
Definition: anc_od.inc.php:35
$str_dossier
Definition: anc_od.inc.php:33
global $g_user
Definition: anc_od.inc.php:30
$pa
Definition: anc_od.inc.php:34
$http
Definition: anc_od.inc.php:31
if(! $m) $dossier_id
Definition: anc_od.inc.php:43
$wex
Definition: balance.inc.php:47
$ex
Definition: balance.inc.php:45
$_GET['qcode']
group of object operations, used for misc operation
this class is used to show the form for entering an operation only FOR analytic operation to save it,...
Concerns the Analytic plan (table plan_analytique)
static get()
return a string to put to gDossier into a GET
static id()
return the 'gDossier' value after a check
about the accountancy period (usually 1 year starting in January until december) = exercice
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
manage the http input (get , post, request) and extract from an array
Html Input.
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
$_POST['ac']
Definition: do.php:310
$periode_start
Definition: fiche.inc.php:50
check_date($p_date, $p_format)
Definition: format_date.php:22