noalyss Version-9
anc_pa.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/*!\file
24 *
25 *\brief Plan Analytique
26 *
27 */
28if (!defined('ALLOWED'))
29 die('Appel direct ne sont pas permis');
30require_once NOALYSS_INCLUDE.'/database/poste_analytique_sql.class.php';
31
34
35global $http;
36
37$sa=$http->request("sa", "string", "anc_menu");
38//---------------------------------------------------------------------------
39// action
40// Compute the redcontent div
41//---------------------------------------------------------------------------
42// show the form for adding a pa
43if ($sa=="add_pa")
44{
45 $new=new Anc_Plan($cn);
46 if ($new->isAppend()==true)
47 {
48 $ret.= '<div style="position:absolute;top:25%" id="anc_div_add" class="inner_box">';
49 $ret.=HtmlInput::title_box(_('Nouveau plan'), 'anc_div_add', 'hide');
50 $ret.= '<form method="post">';
51 $ret.=dossier::hidden();
52 $ret.= $new->form_new();
53 $ret.= HtmlInput::hidden("sa", "pa_write");
54 $ret.=HtmlInput::submit("submit", _("Enregistre"));
55 $ret.=HtmlInput::button_hide("anc_div_add");
56 $ret.= '</form>';
57 $ret.= '</div>';
58 }
59 else
60 {
61 $ret.= '<div class="content">'.
62 '<h2 class="notice">'.
63 _("Maximum de plan analytique est atteint").
64 "</h2></div>";
65 }
66 $sa="anc_menu";
67}
68// Add
69if ($sa=="pa_write")
70{
71 $new=new Anc_Plan($cn);
72
73
74 if ($new->isAppend()==false)
75 {
76 $ret.= '<h2 class="notice">'.
77 _("Maximum de plan analytique est atteint").
78 "</h2>";
79 }
80 else
81 {
82 $new=new Anc_Plan($cn);
83 $new->name=$http->post("pa_name");
84 $new->description=$http->post("pa_description");
85 $new->add();
86 }
87 $sa="anc_menu";
88}
89
90
91/* delete pa */
92if ($sa=="pa_delete")
93{
94 $pa_id=$http->get("pa_id","number");
95
96 $delete=new Anc_Plan($cn, $pa_id);
97 $delete->delete();
98 $sa="anc_menu";
99}
100//--------------------------------------------------------------------------------------------------
101// show the detail of an analytic axis (=plan)
102//
103//--------------------------------------------------------------------------------------------------
104if ($sa=="pa_detail")
105{
106 $pa_id=$http->get("pa_id","number");
107
108 $new=new Anc_Plan($cn, $pa_id);
109
110 $new->get();
111
112 $ret.= '<div class="content">';
113
114 $ret.= $new->form();
115 // Export in CSV
116 $ret.='<form method="GET" action="export.php" style="display:inline">';
118 $ret.=HtmlInput::hidden("act",'CSV:Analytic_Axis');
119 $ret.=HtmlInput::hidden("pa_id",$pa_id);
120 $ret.=HtmlInput::submit('export_analytic_axis',_("Export CSV"));
121 $ret.='</form>';
122 $ret.=HtmlInput::button_anchor(_('Efface ce plan'), '', 'remove_analytic_plan',
123 'onclick="return confirm_box(\'remove_analytic_plan\',\'Effacer ?\',function () {window.location=\'do.php?ac='.$_REQUEST['ac'].'&pa_id='.$_GET['pa_id'].'&sa=pa_delete&'.$str_dossier.'\';})"',
124 'smallbutton');
125
126 $ret.='</div>';
127
128 //---------------------------------------------------------------------
129 // Detail now
130 // Use Manage_Table
131 //---------------------------------------------------------------------
132 $count=0;
133
134 $new=new Anc_Plan($cn, $pa_id);
135 $new->get();
136 $ret.='<div class="content" style="margin-top:1rem">';
137 $anc=new Poste_analytique_SQL($cn);
138 $anc->pa_id=$pa_id;
139 $accounting=new Anc_Account_Table($anc);
140 $accounting->set_callback("ajax_misc.php");
141 $accounting->add_json_param("op", "anc_accounting");
142 $accounting->add_json_param("pa_id", $pa_id);
143 $accounting->set_sort_column("po_name");
144 ob_start();
145 $accounting->create_js_script();
146 $accounting->display_table(" where pa_id = $1 order by po_name ",array($pa_id));
147 $ret.=ob_get_clean();
148 $ret.= '</div>';
149}
150
151//---------------------------------------------------------------------------
152// Show lmenu
153//
154//---------------------------------------------------------------------------
155if ($sa=='anc_menu')
156{
157
158 $obj=new Anc_Plan($cn);
159 $list=$obj->get_list();
160
161
162 $ac=$http->request("ac");
163
164 if (empty($list))
165 {
166 $url=http_build_query(array("sa"=>"add_pa","ac"=>$ac,
167 "gDossier"=>Dossier::id()));
168 echo '<div class="content">';
169 echo '<TABLE class="vert_mtitle">';
170 echo '<TR><TD class="first">';
171 echo '<a href="?'.$url.'">'._("Ajout d'un plan analytique").'</a>';
172 echo '</TD></TR>';
173 echo '</TABLE>';
174
175 echo '</div>';
176 if (!isset($_REQUEST['sa']))
177 echo '<div class="notice">'.
178 _("Aucun plan analytique n'est défini").
179 '</div>';
180 }
181 else
182 {
183 $url=http_build_query(array("sa"=>"add_pa","ac"=>$ac,
184 "gDossier"=>Dossier::id()));
185 echo '<div class="content">';
186
187 echo '<table class="vert_mtitle">';
188 if ($obj->isAppend()==true)
189 {
190 echo '<TR><TD class="first">';
191 echo '<a href="?'.$url.'">'._("Ajout d'un plan analytique").'</a>';
192 echo '</TD></TR>';
193 }
194 foreach ($list as $line)
195 {
196 $url=http_build_query(array("sa"=>"pa_detail","ac"=>$ac,"pa_id"=>$line['id'],
197 "gDossier"=>Dossier::id()));
198 echo '<TR>';
199 echo '<TD>'.
200 '<a href="?'.$url.'">'.
201 h($line['name']);
202 echo "&nbsp;";
203 echo h($line['description'])."</a>";
204 echo "</td>";
205 echo "</TR>\n";
206 }
207 echo '</TABLE>';
208
209
210 echo '</div>';
211 }
212}
213//---------------------------------------------------------------------------
214// show the content part
215//
216//
217//---------------------------------------------------------------------------
218
219echo $ret;
$anc pa_id
$_REQUEST['ac']
$str_dossier
Definition: anc_pa.inc.php:33
global $http
Definition: anc_pa.inc.php:35
$sa
Definition: anc_pa.inc.php:37
$ret
Definition: anc_pa.inc.php:32
$from_poste name
else $card content[$j]['j_montant']
$_GET['qcode']
Concerns the Analytic plan (table plan_analytique)
static get()
return a string to put to gDossier into a GET
static hidden()
return a string to set gDossier into a FORM
static button_hide($div_name)
Hide the HTML popup.
static hidden($p_name, $p_value, $p_id="")
static title_box($p_name, $p_div, $p_mod="close", $p_js="", $p_draggable="n", $p_enlarge='n')
Title for boxes, you can customize the symbol thanks symbol with the mode "custom".
static button_anchor($p_label, $p_value, $p_name="", $p_javascript="", $p_class="smallbutton")
create a button with a ref
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")