30 $array=$cn->get_array(
"select b_id, b_name,
33 case when b_type = 'OPER' then 'Opérationnel'
34 when b_type = 'PREV' then 'Prévisionnel' else 'inconnu' end as str_type,
40 require_once
'template/budget_list.php';
48 if ($this->
b_id ==
'')
throw new Exception(
"Aucun budget demandé");
49 $array=$cn->get_array(
"select b_id,b_name,b_amount,
51 from coprop.budget where b_id=$1",array($this->
b_id));
52 if ($cn->count() == 1)
54 $this->b_name=
$array[0][
'b_name'];
55 $this->b_exercice=
$array[0][
'b_exercice'];
56 $this->b_type=
$array[0][
'b_type'];
57 $this->b_amount=
$array[0][
'b_amount'];
60 throw new Exception (
'Aucun budget trouvé');
61 }
catch (Exception $e)
63 echo $e->getTraceAsString();
78 if ( ! isset ($this->
b_id)|| trim($this->
b_id)==
'')
79 throw new Exception (
"Aucun budget demandé");
80 $name=
new IText(
'b_name');
85 $name->value=$this->b_name;
87 $exercice->value=$cn->make_array(
"select distinct p_exercice,p_exercice from parm_periode
91 $type=
new ISelect(
'b_type');
93 array(
"value"=>
"OPER",
"label"=>
"Opérationnel"),
94 array(
"value"=>
"PREV",
"label"=>
"Prévisionnel")
96 $type->selected=$this->b_type;
98 $amount=
new INum(
'b_amount',round($this->b_amount,2));
102 $exercice->value=$cn->make_array(
"select distinct p_exercice,p_exercice from parm_periode
105 $type=
new ISelect(
'b_type');
107 array(
"value"=>
"OPER",
"label"=>
"Opérationnel"),
108 array(
"value"=>
"PREV",
"label"=>
"Prévisionnel")
110 $amount=
new INum(
'b_amount',0);
113 $amount->javascript=
'onchange="format_number(this,2);compute_budget();"';
116 echo HtmlInput::hidden(
"b_id",$this->
b_id);
117 echo HtmlInput::request_to_hidden(array(
'gDossier',
'ac',
'plugin_code',
'sa'));
118 require_once
'template/budget.php';
120 $array=$cn->get_array(
"select bt_label,
121 bt_id,bt_amount,f_id,vw_name,quick_code,cr_name,cr_id
122 from coprop.budget_detail
123 join coprop.clef_repartition using (cr_id)
124 join vw_fiche_attr using (f_id)
125 where b_id=$1",array($this->
b_id));
127 $fiche_dep=$cn->make_list(
"select fd_id from fiche_def where fd_id=".$g_copro_parameter->categorie_charge);
129 $a_key=$cn->make_array(
" select cr_id,cr_name from coprop.clef_repartition order by cr_name");
137 $filter=$cn->make_list(
"select fd_id from fiche_def where fd_id=".$g_copro_parameter->categorie_charge);
138 $f_add_button->javascript=
" this.filter='$filter';this.jrn=-1;select_card_type(this);";
142 $label=
new IText(
'bt_label[]');
143 $label->value=($i>=
$max)?
"":
$array[$i][
'bt_label'];
145 $card=
new ICard(
'f_id'.$i);
146 $card->value=($i>=
$max)?
"":
$array[$i][
'quick_code'];
150 $card->set_attribute(
'label',
'w_card_label'.$i);
153 $card->set_attribute(
'typecard',$fiche_dep);
155 $card->extra=$fiche_dep;
158 $card->set_callback(
'filter_card');
159 $card->set_attribute(
'ipopup',
'ipopcard');
161 $card->set_function(
'fill_data');
165 $card->javascript=sprintf(
' onchange="fill_data_onchange(\'%s\');" ',
167 $card->set_dblclick(
"fill_ipopcard(this);");
169 $card_label=
new ISpan();
170 $card_label->table=0;
171 $f_card_label=$card_label->input(
"w_card_label".$i,
"");
174 $f_card_bt=$card->search();
176 $amount=
new INum(
"bt_amount[]");
178 $amount->javascript=
'onchange="format_number(this,2);compute_budget();"';
179 $hidden=($i>=
$max)?HtmlInput::hidden(
"bt_id[]",0):HtmlInput::hidden(
"bt_id[]",
$array[$i][
"bt_id"]);
182 $ikey=
new ISelect(
"key[]");
184 $ikey->selected=($i>=
$max)?0:
$array[$i][
'cr_id'];
186 $a_input[$i][
"amount"]=
$amount->input();
187 $a_input[$i][
"hidden"]=
$hidden;
188 $a_input[$i][
"card"]=$card->input().$f_card_bt;
189 $a_input[$i][
"card_label"]=$label->input();
191 $a_input[$i][
'key']=$ikey->input();
194 require_once
'template/bud_detail.php';
195 echo create_script(
"compute_budget()");
199 $e->getTraceAsString();
220 $this->
b_id=$p_array[
'b_id'];
221 if ( $p_array[
'b_id'] == 0 )
230 catch( Exception $e){
243 $cn->exec_sql(
"update coprop.budget set b_name=$1,
258 catch (Exception $exc) {
259 echo $exc->getTraceAsString();
273 $this->
b_id=$cn->get_value(
"insert into coprop.budget (b_name,b_exercice,b_type,b_amount)
287 catch (Exception $exc) {
288 echo $exc->getTraceAsString();
305 if ( strlen(trim(${
'f_id'.$i})) != 0)
307 $f_id=$cn->get_value(
"select f_id from vw_fiche_attr where quick_code=upper(trim($1))",
308 array(${
'f_id'.$i}));
311 $cn->exec_sql(
"insert into coprop.budget_detail (bt_label,f_id,b_id,bt_amount,cr_id) ".
312 " values ($1,$2,$3,$4,$5)",
314 strip_tags($bt_label[$i]),
327 if ( strlen(trim(${
'f_id'.$i})) != 0)
329 $f_id=$cn->get_value(
"select f_id from vw_fiche_attr where quick_code=upper(trim($1))",
330 array(${
'f_id'.$i}));
332 $cn->exec_sql(
"update coprop.budget_detail set bt_label=$1,f_id=$2,bt_amount=$3,cr_id=$4 ".
335 strip_tags($bt_label[$i]),
345 $cn->exec_sql(
"delete from coprop.budget_detail where bt_id=$1",array($bt_id[$i]));
353 catch (Exception $exc)
355 echo $exc->getTraceAsString();
363 $array=$cn->get_array(
"select * from coprop.budget_detail where b_id=$1",
$type
Retrouve le type de row si == 3.
global $g_copro_parameter
detail()
Detail d'un budget avec les détails, pour mettre à jour type $cn.
if(isset($_POST['remove'])) $array
save($p_array)
insert or update a new budget
update($p_array)
update budget
insert($p_array)
insert budget