noalyss Version-9
Public Member Functions
Pre_Op_Advanced Class Reference

concerns the predefined operation for the operation from 'Ecriture direct' More...

+ Inheritance diagram for Pre_Op_Advanced:
+ Collaboration diagram for Pre_Op_Advanced:

Public Member Functions

 __construct ($cn)
 
 compute_array ($p_od_id)
 compute an array accordingly with the FormVenView function More...
 
 display ($p_array)
 Display the form for modifying or adding new predefined operation. More...
 
 get_post ()
 get the post and stove them into data member , before saving them in the db More...
 
 load ($p_od_id)
 load the data from the database and return an array More...
 
 save ($p_od_id, $p_nb_item)
 save the detail and op in the database More...
 
 __construct ($p_cn)
 

Additional Inherited Members

- Static Public Member Functions inherited from Pre_operation_detail
static build_detail ($p_jrn_type, Database $database)
 

Detailed Description

concerns the predefined operation for the operation from 'Ecriture direct'

Definition at line 29 of file pre_op_advanced.class.php.

Constructor & Destructor Documentation

◆ __construct()

Pre_Op_Advanced::__construct (   $cn)

Reimplemented from Pre_operation_detail.

Definition at line 31 of file pre_op_advanced.class.php.

32 {
33 parent::__construct($cn);
34 }

References $cn.

Member Function Documentation

◆ compute_array()

Pre_Op_Advanced::compute_array (   $p_od_id)

compute an array accordingly with the FormVenView function

Definition at line 108 of file pre_op_advanced.class.php.

109 {
110 $count=0;
111 $array=array();
112 $p_array=$this->load($p_od_id);
113 if (empty($p_array)) return array();
114 foreach ($p_array as $row)
115 {
116 $tmp_array=array("qc_".$count=>'',
117 "poste".$count=>'',
118 "amount".$count=>$row['opd_amount'],
119 'ck'.$count=>$row['opd_debit'],
120 "ld".$count=>$row['opd_comment']
121 );
122
123 if ( $row['opd_qc'] == 't' )
124 $tmp_array['qc_'.$count]=$row['opd_poste'];
125 else
126 $tmp_array['poste'.$count]=$row['opd_poste'];
127
128
129 if ( $row['opd_debit'] == 'f' )
130 unset ($tmp_array['ck'.$count]);
131
132 $array+=$tmp_array;
133 $count++;
134
135 }
136
137 return $array;
138 }
load($p_od_id)
load the data from the database and return an array
$count

References $array, $count, $p_array, $row, and load().

+ Here is the call graph for this function:

◆ display()

Pre_Op_Advanced::display (   $p_array)

Display the form for modifying or adding new predefined operation.

Parameters
array$p_arrayis the result of compute_array or blank
Returns
string containing HTML code of the form
Exceptions
Exception
See also
compute_array
load

Definition at line 161 of file pre_op_advanced.class.php.

162 {
163 global $g_parameter, $g_user;
164 $legder=new Acc_Ledger($this->db,$p_array['p_jrn']);
165
166 $legder->nb=$legder->get_min_row();
167
168 $add_js = "";
169
170 $ret = "";
171 if ($g_user->check_action(FICADD) == 1)
172 {
173 /* Add button */
174 $f_add_button = new IButton('add_card');
175 $f_add_button->label = _('Créer une nouvelle fiche');
176 $f_add_button->set_attribute('ipopup', 'ipop_newcard');
177 $f_add_button->set_attribute('jrn', $legder->id);
178 $f_add_button->javascript = " this.jrn=\$('p_jrn').value;select_card_type(this);";
179 $f_add_button->input();
180 }
181
182 $nb_row = (isset($p_array['nb_item']) ) ? $p_array['nb_item' ]: $legder->nb;
183
184 $ret.=HtmlInput::hidden('nb_item', $nb_row);
185 $ret.=dossier::hidden();
186
187 $ret.=dossier::hidden();
188
189 $ret.=HtmlInput::hidden('jrn_type', "ODS");
190 $info = Icon_Action::infobulle(0);
191 $info_poste = Icon_Action::infobulle(9);
192 if ($g_user->check_action(FICADD) == 1) $ret.=$f_add_button->input();
193 $ret.='<div class="fieldset" style="overflow:auto;height:400px">';
194 $ret.='<table id="quick_item" style="width:100%">';
195 $ret.='<tr>' .
196 '<th style="text-align:left">Quickcode' . $info . '</th>' .
197 '<th style="text-align:left">' . _('Poste') . $info_poste . '</th>' .
198 '<th style="text-align:left">' . _('Libellé') . '</th>' .
199 '<th style="text-align:left">' . _('Montant') . '</th>' .
200 '<th style="text-align:left">' . _('Débit') . '</th>' .
201 '</tr>';
202
203
204 for ($i = 0; $i < $nb_row; $i++)
205 {
206 // Quick Code
207 $quick_code = new ICard('qc_' . $i);
208 $quick_code->set_dblclick("fill_ipopcard(this);");
209 $quick_code->set_attribute('ipopup', 'ipopcard');
210
211 // name of the field to update with the name of the card
212 $quick_code->set_attribute('label', "ld" . $i);
213 $quick_code->set_attribute('jrn', $legder->id);
214
215 // name of the field to update with the name of the card
216 $quick_code->set_attribute('typecard', 'filter');
217
218 // Add the callback function to filter the card on the jrn
219 $quick_code->set_callback('filter_card');
220 $quick_code->set_function('fill_data');
221 $quick_code->javascript = sprintf(' onchange="fill_data_onchange(\'%s\');" ', $quick_code->name);
222
223 $quick_code->jrn = $legder->id;
224 $quick_code->value = (isset($p_array['qc_' . $i])) ? $p_array['qc_' . $i]: "";
225
226 $label = '';
227 if ($quick_code->value != '')
228 {
229 $Fiche = new Fiche($legder->db);
230 $Fiche->get_by_qcode($quick_code->value);
231 $label = $Fiche->strAttribut(ATTR_DEF_NAME);
232 }
233
234
235 // Account
236 $poste = new IPoste();
237 $poste->name = 'poste' . $i;
238 $poste->set_attribute('jrn', $legder->id);
239 $poste->set_attribute('ipopup', 'ipop_account');
240 $poste->set_attribute('label', 'ld' . $i);
241 $poste->set_attribute('account', 'poste' . $i);
242 $poste->set_attribute('dossier', Dossier::id());
243
244 $poste->value = (isset($p_array['poste' . $i])) ?$p_array['poste' . $i]: ''
245 ;
246 $poste->dbl_click_history();
247
248
249 if ($poste->value != '')
250 {
251 $Poste = new Acc_Account($legder->db);
252 $Poste->find_by_value($poste->value);
253 $label = $Poste->get_lib();
254 }
255
256 // Description of the line
257 $line_desc = new IText();
258 $line_desc->name = 'ld' . $i;
259 $line_desc->size = 30;
260 $line_desc->value = (isset($p_array["ld" . $i])) ? $p_array["ld" . $i] :
261 $label;
262
263 // Amount
264 $amount = new INum();
265 $amount->size = 10;
266 $amount->name = 'amount' . $i;
267 $amount->value = (isset($p_array['amount' . $i])) ?$p_array['amount' . $i] : ''
268 ;
269 $amount->javascript = ' onChange="format_number(this);checkTotalDirect()"';
270 // D/C
271 $deb = new ICheckBox();
272 $deb->name = 'ck' . $i;
273 $deb->selected = (isset($p_array['ck' . $i])) ? true : false;
274 $deb->javascript = ' onChange="checkTotalDirect()"';
275
276 $ret.='<tr>';
277 $ret.='<td>' . $quick_code->input() . $quick_code->search() . '</td>';
278 $ret.='<td>' . $poste->input() .
279 '<script> document.getElementById(\'poste' . $i . '\').onblur=function(){ if (trim(this.value) !=\'\') {document.getElementById(\'qc_' . $i . '\').value="";}}</script>' .
280 '</td>';
281 $ret.='<td>' . $line_desc->input() . '</td>';
282 $ret.='<td>' . $amount->input() . '</td>';
283 $ret.='<td>' . $deb->input() . '</td>';
284 $ret.='</tr>';
285 // If readonly == 1 then show CA
286 }
287 $ret.='</table>';
288 $ret.="</div>";
289 $ret.=Html_Input_Noalyss::ledger_add_item("M");
290 return $ret;
291 }
tr($p_string, $p_extra='')
Definition: ac_common.php:88
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
global $g_parameter
global $g_user
if no group available , then stop
Manage the account from the table tmp_pcmn.
static id()
return the 'gDossier' value after a check
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
Definition: fiche.class.php:38
static hidden($p_name, $p_value, $p_id="")
Html Input.
Input HTML for the card show buttons, in the file, you have to add card.js How to use :
Html Input.
This class handles only the numeric input, the input will call a javascript to change comma to period...
Definition: inum.class.php:42
show a button, for selecting a account and a input text for manually inserting an account the differe...
Html Input.
Definition: itext.class.php:30
static infobulle($p_comment)
Display a info in a bubble, text is in message_javascript.
$all table
const ATTR_DEF_NAME
Definition: constant.php:216
const FICADD
$SecUser db
for($i=0;$i< $nb_jrn;$i++) $deb

References $amount, $deb, $Fiche, $g_parameter, $g_user, $i, $label, $nb_row, $p_array, $poste, $quick_code, $ret, ATTR_DEF_NAME, db, FICADD, HtmlInput\hidden(), Dossier\id(), Icon_Action\infobulle(), table, td(), tr(), and value.

+ Here is the call graph for this function:

◆ get_post()

Pre_Op_Advanced::get_post ( )

get the post and stove them into data member , before saving them in the db

See also
save

Definition at line 39 of file pre_op_advanced.class.php.

40 {
41 $http = new \HttpInput();
42 $nb = $http->post("nb_item", "number");
43
44 for ($i=0;$i<$nb;$i++)
45 {
46 $poste=$http->post("poste".$i,"string", null);
47 $qcode=$http->post("qc_".$i,"string", null);
48
49 if ( $poste == null && $qcode == null ) continue;
50
51 if ($poste != null && trim ($poste) != "")
52 {
53 $this->{'poste'.$i}=$poste;
54 $this->{'isqc'.$i}='f';
55 }
56
57 if ( $qcode != null && trim ($qcode) != "") {
58 $this->{'isqc'.$i}=(trim($http->post('qc_'.$i)) != "")?'t':'f';
59 $this->{'poste'.$i}=trim ($qcode);
60 }
61 $http->set_empty(0);
62 $this->{"amount".$i}=$http->post('amount'.$i);
63 $http->set_empty("");
64 $this->{"ld".$i}=$http->post("ld".$i);
65
66 $this->{"ck".$i}=(isset($_POST['ck'.$i]))?'t':'f';
67
68 }
69 }
$_POST['ac']
Definition: do.php:310

References $_POST, $http, $i, $nb, $poste, and $qcode.

◆ load()

Pre_Op_Advanced::load (   $p_od_id)

load the data from the database and return an array

Returns
an array

Definition at line 142 of file pre_op_advanced.class.php.

143 {
144 $sql="select opd_id,opd_poste,opd_amount,opd_debit,opd_comment,".
145 " opd_qc from op_predef_detail where od_id=$1 ".
146 " order by opd_id";
147 $res=$this->db->exec_sql($sql,[$p_od_id]);
149 if ($array == false ) return array();
150 return $array;
151 }
static fetch_all($ret)
wrapper for the function pg_fetch_all

References $array, $res, $sql, db, and DatabaseCore\fetch_all().

Referenced by compute_array().

+ Here is the call graph for this function:

◆ save()

Pre_Op_Advanced::save (   $p_od_id,
  $p_nb_item 
)

save the detail and op in the database

Definition at line 74 of file pre_op_advanced.class.php.

75 {
76 try
77 {
78 // save the selling
79 for ($i=0;$i<$p_nb_item;$i++)
80 {
81 if ( ! isset ($this->{"poste".$i}))
82 continue;
83
84 $sql=sprintf('insert into op_predef_detail (opd_poste,opd_amount,'.
85 'opd_debit,od_id,opd_qc,opd_comment)'.
86 ' values($1,$2,$3,$4,$5,$6) '
87 );
88
89 $this->db->exec_sql($sql,[$this->{"poste".$i},
90 $this->{"amount".$i},
91 $this->{"ck".$i},
92 $p_od_id,
93 $this->{'isqc'.$i},
94 $this->{"ld".$i}]);
95
96 }
97
98 }
99 catch (Exception $e)
100 {
101 record_log($e->getMessage().$e->getTraceAsString());
102 throw $e;
103 }
104
105 }
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342

References $e, $i, $sql, db, and record_log().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: