noalyss Version-9
Public Member Functions | Static Public Member Functions | Data Fields | Private Attributes
Pre_operation Class Reference

manage the predefined operation, link to the table op_def and op_def_detail More...

+ Collaboration diagram for Pre_operation:

Public Member Functions

 __construct ($cn, $p_id=0)
 
 blank ()
 create a blank object to insert it later More...
 
 choose_ledger ($p_ledger_type, $p_default)
 Build the select list for choosing the ledger. More...
 
 compute_array ()
 
 count ()
 count the number of pred operation for a ledger More...
 
 delete ()
 delete a template operation and children More...
 
 display ()
 display the detail of predefined operation, normally everything is loaded More...
 
 display_list_operation ($p_url)
 show the button for selecting a predefined operation More...
 
 form_get ($p_url)
 show a form to use pre_op More...
 
 get_db ()
 
 get_description ()
 
 get_detail ()
 
 get_jrn_type ()
 
 get_list_ledger ()
 get the list of the predef. operation of a ledger More...
 
 get_name ()
 
 get_nb_item ()
 
 get_od_direct ()
 
 get_od_id ()
 
 get_operation ()
 
 get_post ()
 fill the object with the $_POST variable More...
 
 load ()
 load the data from the database and return an array More...
 
 save ()
 
 save_insert ()
 save the predef check first is the name is unique More...
 
 save_update ()
 
 set_db ($db)
 
 set_description ($description)
 
 set_detail (Pre_operation_detail $detail)
 
 set_jrn_type ($jrn_type)
 
 set_name ($name)
 
 set_nb_item ($nb_item)
 
 set_od_direct ($od_direct)
 
 set_od_id ($od_id)
 
 set_p_jrn ($p_jrn)
 set the ledger More...
 
 show_button_deprecated ()
 show the button for selecting a predefined operation More...
 

Static Public Member Functions

static save_propose ()
 Propose to save the operation into a predefined operation. More...
 

Data Fields

 $od_direct
 

Private Attributes

 $db
 
 $description
 
 $detail
 
 $isloaded
 
 $jrn_type
 
 $name
 
 $nb_item
 
 $od_id
 
 $p_jrn
 

Detailed Description

manage the predefined operation, link to the table op_def and op_def_detail

Definition at line 30 of file pre_operation.class.php.

Constructor & Destructor Documentation

◆ __construct()

Pre_operation::__construct (   $cn,
  $p_id = 0 
)

Definition at line 42 of file pre_operation.class.php.

43 {
44 $this->db=$cn;
45 $this->od_direct='f';
46 $this->od_id=$p_id;
47 $this->p_jrn=0;
48 $this->jrn_type='x';
49 $this->name='';
50 $this->isloaded=false;
51 $this->description="";
52
53 }
$from_poste name
$SecUser db

References $cn, $p_id, db, and name.

Member Function Documentation

◆ blank()

Pre_operation::blank ( )

create a blank object to insert it later

Parameters
$p_ledger_id
Exceptions
Exception

Definition at line 212 of file pre_operation.class.php.

212 {
213 $array["od_id"]=-1;
214 $array['jrn_def_id']=0;
215 $array['od_name']="";
216 $array['od_item']=2;
217 $array['od_jrn_type']=$this->get_jrn_type();
218 $array['od_description']="";
219 foreach (array('jrn_def_id','od_name','od_item','od_jrn_type','od_description') as $field) {
220 $this->$field=$array[$field];
221 }
222 $this->od_jrn_type=$array['od_jrn_type'];
223
224 $this->detail = Pre_operation_detail::build_detail($array['od_jrn_type'], $this->db);
225 $darray[0]=$array;
226 return $darray;
227 }
static build_detail($p_jrn_type, Database $database)

References $array, Pre_operation_detail\build_detail(), db, and get_jrn_type().

Referenced by compute_array(), and load().

+ Here is the call graph for this function:

◆ choose_ledger()

Pre_operation::choose_ledger (   $p_ledger_type,
  $p_default 
)

Build the select list for choosing the ledger.

Parameters
string$p_stringledger type ACH VEN or ODS
$p_defaultselected ledger , -1 if none
Returns
ISelect

Definition at line 508 of file pre_operation.class.php.

508 {
509 $select_ledger=new ISelect("p_jrn");
510 $select_ledger->value=$this->db->make_array("select jrn_def_id,jrn_def_name
511 from jrn_def where jrn_def_type=$1 order by 2",
512 0,
513 [$p_ledger_type]);
514 $select_ledger->selected=$p_default;
515 return $select_ledger;
516 }
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...

References db.

Referenced by display().

◆ compute_array()

Pre_operation::compute_array ( )

Definition at line 229 of file pre_operation.class.php.

230 {
231 if ($this->od_id > 0) {
232 $p_array = $this->load();
233 } else {
234 $p_array=$this->blank();
235 }
236 $array=array(
237 "e_comm"=>$p_array[0]["od_name"],
238 "nb_item"=>(($p_array[0]["od_item"]<10)?10:$p_array[0]["od_item"]) ,
239 "p_jrn"=>$p_array[0]["jrn_def_id"],
240 "jrn_type"=>$p_array[0]["od_jrn_type"],
241 "od_description"=>$p_array['0']['od_description']
242 );
243 $this->detail = Pre_operation_detail::build_detail($this->od_jrn_type, $this->db);
244 $array += $this->detail->compute_array($this->od_id);
245 return $array;
246
247 }
blank()
create a blank object to insert it later
load()
load the data from the database and return an array

References $array, $p_array, blank(), Pre_operation_detail\build_detail(), db, and load().

Referenced by display().

+ Here is the call graph for this function:

◆ count()

Pre_operation::count ( )

count the number of pred operation for a ledger

Definition at line 268 of file pre_operation.class.php.

269 {
270 $a=$this->db->count_sql("select od_id,od_name from op_predef ".
271 " where jrn_def_id= $1 ".
272 " and od_direct = $2 ".
273 " order by od_name",array($this->p_jrn,$this->od_direct));
274 return $a;
275 }

References $a, and db.

Referenced by display_list_operation(), and save_insert().

◆ delete()

Pre_operation::delete ( )

delete a template operation and children

Definition at line 117 of file pre_operation.class.php.

118 {
119 $sql="delete from op_predef where od_id=$1";
120 $this->db->exec_sql($sql,array($this->od_id));
121 }

References $sql, and db.

◆ display()

Pre_operation::display ( )

display the detail of predefined operation, normally everything is loaded

Definition at line 295 of file pre_operation.class.php.

296 {
297 $array=$this->compute_array();
298 $select_ledger=$this->choose_ledger($array['jrn_type'],$array['p_jrn']);
299
300 require NOALYSS_TEMPLATE."/pre_operation_display.php";
301 echo $this->detail->display($array);
302 }
choose_ledger($p_ledger_type, $p_default)
Build the select list for choosing the ledger.

References $array, choose_ledger(), and compute_array().

+ Here is the call graph for this function:

◆ display_list_operation()

Pre_operation::display_list_operation (   $p_url)

show the button for selecting a predefined operation

Definition at line 324 of file pre_operation.class.php.

325 {
326
327
328 $value=$this->db->get_array("select od_id,od_name,od_description from op_predef ".
329 " where jrn_def_id=$1".
330 " order by od_name",
331 array($this->p_jrn));
332
333 if ( $this->p_jrn=='') $value=array();
334
335 $r="";
336 if (count($value)==0) {
337 $r.=_("Vous n'avez encore sauvé aucun modèle");
338 return $r;
339 }
340 $r.=_('Cherche').' '.HtmlInput::filter_table('modele_op_tab', '0,1', '0');
341 $r.='<table style="width:100%" id="modele_op_tab">';
342 for ($i=0;$i<count($value);$i++) {
343 $r.='<tr class="'.(($i%2==0)?"even":"odd").'">';
344 $r.='<td style="font-weight:bold;vertical-align:top;text-decoration:underline">';
345 $r.=sprintf('<a href="%s&pre_def=%s" onclick="waiting_box()">%s</a> ',
346 $p_url,$value[$i]['od_id'],$value[$i]['od_name']);
347 $r.='</td>';
348 $r.='<td>'.h($value[$i]['od_description']).'</td>';
349 $r.='</tr>';
350 }
351 $r.='</table>';
352 return $r;
353 }
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
static filter_table($p_table_id, $p_col, $start_row)
filter the rows in a table and keep the colored row in alternance
count()
count the number of pred operation for a ledger
$p_url

References $i, $p_url, $r, $value, count(), db, and HtmlInput\filter_table().

Referenced by form_get().

+ Here is the call graph for this function:

◆ form_get()

Pre_operation::form_get (   $p_url)

show a form to use pre_op

Definition at line 305 of file pre_operation.class.php.

306 {
307 $r=HtmlInput::button_action(_("Modèle d'opérations"),
308 ' $(\'modele_op_div\').style.display=\'block\';if ( $(\'lk_modele_op_tab\')) { $(\'lk_modele_op_tab\').focus();}');
309 $r.='<div id="modele_op_div" class="noprint">';
310 $r.=HtmlInput::title_box(_("Modèle d'opérations"), 'modele_op_div', 'hide',"","n");
311 $hid=new IHidden();
312 $r.=$hid->input("action","use_opd");
313 $r.=$hid->input("jrn_type",$this->jrn_type);
315 $r.=' <p style="text-align: center">'.
316 HtmlInput::button_hide('modele_op_div').
317 '</p>';
318 $r.='</div>';
319 return $r;
320
321 }
static button_hide($div_name)
Hide the HTML popup.
static button_action($action, $javascript, $id=NULL, $p_class="button", $p_symbole="")
button Html with javascript
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".
Html Input.
display_list_operation($p_url)
show the button for selecting a predefined operation

References $hid, $p_url, $r, HtmlInput\button_action(), HtmlInput\button_hide(), display_list_operation(), and HtmlInput\title_box().

+ Here is the call graph for this function:

◆ get_db()

Pre_operation::get_db ( )
Returns
mixed

Definition at line 367 of file pre_operation.class.php.

368 {
369 return $this->db;
370 return $this;
371 }

References $db.

◆ get_description()

Pre_operation::get_description ( )
Returns
string

Definition at line 78 of file pre_operation.class.php.

79 {
80 return $this->description;
81 }/**

References $description.

◆ get_detail()

Pre_operation::get_detail ( )
Returns
array

Definition at line 440 of file pre_operation.class.php.

441 {
442 return $this->detail;
443 return $this;
444 }

References $detail.

◆ get_jrn_type()

Pre_operation::get_jrn_type ( )
Returns
string

Definition at line 403 of file pre_operation.class.php.

404 {
405 return $this->jrn_type;
406 }

References $jrn_type.

Referenced by blank().

◆ get_list_ledger()

Pre_operation::get_list_ledger ( )

get the list of the predef. operation of a ledger

Returns
string

Definition at line 279 of file pre_operation.class.php.

280 {
281 $sql="select od_id,od_name,od_description from op_predef ".
282 " where jrn_def_id= $1 ".
283 " and od_direct = $2 ".
284 " order by od_name";
285 $res=$this->db->exec_sql($sql,array($this->p_jrn,$this->od_direct));
287 return $all;
288 }
static fetch_all($ret)
wrapper for the function pg_fetch_all
$all

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

+ Here is the call graph for this function:

◆ get_name()

Pre_operation::get_name ( )
Returns
string

Definition at line 422 of file pre_operation.class.php.

423 {
424 return $this->name;
425 return $this;
426 }

References $name.

◆ get_nb_item()

Pre_operation::get_nb_item ( )
Returns
mixed

Definition at line 385 of file pre_operation.class.php.

386 {
387 return $this->nb_item;
388 return $this;
389 }

References $nb_item.

◆ get_od_direct()

Pre_operation::get_od_direct ( )
Returns
string

Definition at line 458 of file pre_operation.class.php.

459 {
460 return $this->od_direct;
461 return $this;
462 }

References $od_direct.

◆ get_od_id()

Pre_operation::get_od_id ( )
Returns
int|mixed

Definition at line 477 of file pre_operation.class.php.

478 {
479 return $this->od_id;
480 }

References $od_id.

◆ get_operation()

Pre_operation::get_operation ( )

Definition at line 354 of file pre_operation.class.php.

355 {
356 if ( $this->jrn_def_id=='') return array();
357 $value=$this->db->make_array("select od_id,od_name from op_predef ".
358 " where jrn_def_id=".sql_string($this->jrn_def_id).
359 " and od_direct ='".sql_string($this->od_direct)."'".
360 " order by od_name",1);
361 return $value;
362 }
sql_string($p_string)
Fix the problem with the quote char for the database.
Definition: ac_common.php:511
margin jrn_def_id

References $value, db, jrn_def_id, and sql_string().

+ Here is the call graph for this function:

◆ get_post()

Pre_operation::get_post ( )

fill the object with the $_POST variable

Definition at line 92 of file pre_operation.class.php.

93 {
94 $http=new HttpInput();
95 $this->nb_item=$http->post('nb_item',"number");
96 $this->p_jrn=$http->request('p_jrn',"number");
97 $this->jrn_type=$http->post('jrn_type');
98 $this->name=$http->post('opd_name');
99
100 $this->description= $http->post('od_description');
101 if ( $this->name=="")
102 {
103 $n=$this->db->get_next_seq('op_def_op_seq');
104 $this->name=$this->jrn_type.$n;
105
106 }
107
108 // get also info for the details
109 // common value
110 $this->detail=Pre_operation_detail::build_detail($this->jrn_type,$this->db);
111 $this->detail->get_post();
112 }
manage the http input (get , post, request) and extract from an array

References $http, Pre_operation_detail\build_detail(), db, and name.

+ Here is the call graph for this function:

◆ load()

Pre_operation::load ( )

load the data from the database and return an array

Returns
an double array containing all the data from database

Definition at line 185 of file pre_operation.class.php.

185 :array
186 {
187 $this->isloaded=true;
188 //------------------------------------------
189 // if new , then od_id == 0 and we need to use blank()
190 //------------------------------------------
191 if ($this->od_id == -1 ) {
192 $array=$this->blank($this->p_jrn);
193 return $array;
194 }
195 $sql="select od_id,jrn_def_id,od_name,od_item,od_jrn_type,od_description".
196 " from op_predef where od_id=$1 ".
197 " order by od_name";
198 $res=$this->db->exec_sql($sql,[$this->od_id]);
200 foreach (array('jrn_def_id','od_name','od_item','od_jrn_type','od_description') as $field) {
201 $this->$field=$array[0][$field];
202 }
203 $this->detail = Pre_operation_detail::build_detail($this->od_jrn_type, $this->db);
204 $array+=$this->detail->load($this->od_id);
205 return $array;
206 }

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

Referenced by compute_array().

+ Here is the call graph for this function:

◆ save()

Pre_operation::save ( )

Definition at line 122 of file pre_operation.class.php.

123 {
124 if ($this->od_id < 1) {
125 $this->save_insert();
126 } else {
127 $this->save_update();
128 }
129
130 }
save_insert()
save the predef check first is the name is unique

References save_insert(), and save_update().

+ Here is the call graph for this function:

◆ save_insert()

Pre_operation::save_insert ( )

save the predef check first is the name is unique

Returns
true op.success otherwise false

Definition at line 143 of file pre_operation.class.php.

144 {
145
146 if ( $this->db->count_sql("select * from op_predef ".
147 "where upper(od_name)=upper('".Database::escape_string($this->name)."')".
148 "and jrn_def_id=".$this->p_jrn." and od_id <> ".$this->od_id)
149 != 0 )
150 {
151 $this->name="copy_".$this->name."_".microtime(true);
152 }
153 if ( $this->count() > MAX_PREDEFINED_OPERATION )
154 {
155 echo '<span class="notice">'.("Vous avez atteint le max. d'opération prédéfinie, désolé").'</span>';
156 return false;
157 }
158 try {
159 $this->db->start();
160 $sql='insert into op_predef (jrn_def_id,od_name,od_item,od_jrn_type,od_direct,od_description) '.
161 ' values '.
162 "($1,$2,$3,$4,$5 ,$6)".
163 'returning od_id';
164 $this->od_id= $this->db->get_value($sql,array($this->p_jrn,
165 $this->name,
166 $this->nb_item,
167 $this->jrn_type,
168 $this->od_direct,
169 $this->description,
170 ));
171
172
173 $this->detail->save($this->od_id,$this->nb_item);
174 $this->db->commit();
175 } catch (Exception $e) {
176 record_log("PROP139.Failed save predefined operation ");
177 $this->db->rollback();
178 }
179
180 return true;
181 }
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342
const MAX_PREDEFINED_OPERATION
Definition: constant.php:138

References $e, $sql, count(), db, MAX_PREDEFINED_OPERATION, name, and record_log().

Referenced by save().

+ Here is the call graph for this function:

◆ save_propose()

static Pre_operation::save_propose ( )
static

Propose to save the operation into a predefined operation.

Returns
HTML string

Definition at line 59 of file pre_operation.class.php.

59 {
60 $r="";
61 $r.= '<p class="decale">';
62 $r.= _("Donnez un nom pour sauver cette opération comme modèle")." <br>";
63 $opd_name = new IText('opd_name');
64 $r.=_( "Nom du modèle " ) . $opd_name->input();
65 $opd_description=new ITextarea('od_description');
66 $opd_description->style=' class="itextarea" style="width:30em;height:4em;vertical-align:top"';
67 $r.='</p>';
68 $r.= '<p class="decale">';
69 $r.= _('Description (max 50 car.)');
70 $r.='<br>';
71 $r.=$opd_description->input();
72 $r.='</p>';
73 return $r;
74 }
$opd_description
Html Input.
Definition: itext.class.php:30
Manage the TEXTAREA html element.

References $opd_description, and $r.

◆ save_update()

Pre_operation::save_update ( )

Definition at line 131 of file pre_operation.class.php.

132 {
133 $sql = "update op_predef set jrn_def_id = $1 , od_name = $2 ,
134 od_item =$3, od_description = $4 where od_id=$5";
135 $this->db->exec_sql($sql,array($this->p_jrn,$this->name,$this->nb_item,$this->description,$this->od_id));
136 // delete detail&
137 $this->db->exec_sql("delete from op_predef_detail where od_id = $1",array($this->od_id));
138 $this->detail->save($this->od_id,$this->nb_item);
139 }

References $sql, db, and name.

Referenced by save().

◆ set_db()

Pre_operation::set_db (   $db)
Parameters
mixed$db

Definition at line 376 of file pre_operation.class.php.

377 {
378 $this->db = $db;
379 return $this;
380 }

References $db, and db.

◆ set_description()

Pre_operation::set_description (   $description)
Parameters
string$description

Definition at line 84 of file pre_operation.class.php.

85 {
86 $this->description = $description;
87 return $this;
88 }

References $description.

◆ set_detail()

Pre_operation::set_detail ( Pre_operation_detail  $detail)
Parameters
array$detail

Definition at line 449 of file pre_operation.class.php.

450 {
451 $this->detail = $detail;
452 return $this;
453 }

References $detail.

◆ set_jrn_type()

Pre_operation::set_jrn_type (   $jrn_type)
Parameters
string$jrn_type

Definition at line 411 of file pre_operation.class.php.

412 {
413 $jrn_type=strtoupper($jrn_type);
414 if ( ! in_array ($jrn_type,['ACH','FIN','VEN','ODS'] )) throw new Exception('prop03.invalid ledger type');
415 $this->jrn_type = $jrn_type;
416 return $this;
417 }

References $jrn_type.

◆ set_name()

Pre_operation::set_name (   $name)
Parameters
string$name

Definition at line 431 of file pre_operation.class.php.

432 {
433 $this->name = $name;
434 return $this;
435 }

References $name, and name.

◆ set_nb_item()

Pre_operation::set_nb_item (   $nb_item)
Parameters
mixed$nb_item

Definition at line 394 of file pre_operation.class.php.

395 {
396 $this->nb_item = $nb_item;
397 return $this;
398 }

References $nb_item.

◆ set_od_direct()

Pre_operation::set_od_direct (   $od_direct)
Parameters
string$od_direct

Definition at line 467 of file pre_operation.class.php.

468 {
469 if ( ! in_array($od_direct,['f','t'])) throw new Exception('prop02.invalid od_direct');
470 $this->od_direct = $od_direct;
471 return $this;
472 }

References $od_direct.

◆ set_od_id()

Pre_operation::set_od_id (   $od_id)
Parameters
int | mixed$od_id

Definition at line 485 of file pre_operation.class.php.

486 {
487 $this->od_id = $od_id;
488 return $this;
489 }

References $od_id.

◆ set_p_jrn()

Pre_operation::set_p_jrn (   $p_jrn)

set the ledger

Parameters
$p_jrnis the ledger (jrn_id)

Definition at line 495 of file pre_operation.class.php.

496 {
497 $this->p_jrn=$p_jrn;
498 $this->jrn_type=$this->db->get_value("select jrn_def_type from jrn_def where jrn_def_id=$1",[$p_jrn]);
499 return $this;
500 }

References $p_jrn, and db.

◆ show_button_deprecated()

Pre_operation::show_button_deprecated ( )

show the button for selecting a predefined operation

Deprecated:

Definition at line 252 of file pre_operation.class.php.

253 {
254
255 $select=new ISelect();
256 $value=$this->db->make_array("select od_id,od_name from op_predef ".
257 " where jrn_def_id=".$this->p_jrn.
258 " and od_direct ='".$this->od_direct."'".
259 " order by od_name");
260
261 if ( empty($value)==true) return "";
262 $select->value=$value;
263 $r=$select->input("pre_def");
264
265 return $r;
266 }

References $r, $select, $value, and db.

Field Documentation

◆ $db

Pre_operation::$db
private

$db database connection

Definition at line 32 of file pre_operation.class.php.

Referenced by get_db(), and set_db().

◆ $description

Pre_operation::$description
private

description of the predefined operation

Definition at line 41 of file pre_operation.class.php.

Referenced by get_description(), and set_description().

◆ $detail

Pre_operation::$detail
private

Pre_operation_detail object

Definition at line 37 of file pre_operation.class.php.

Referenced by get_detail(), and set_detail().

◆ $isloaded

Pre_operation::$isloaded
private

Definition at line 40 of file pre_operation.class.php.

◆ $jrn_type

Pre_operation::$jrn_type
private

$jrn_type

Definition at line 35 of file pre_operation.class.php.

Referenced by get_jrn_type(), and set_jrn_type().

◆ $name

Pre_operation::$name
private

$name name of the predef. operation

Definition at line 36 of file pre_operation.class.php.

Referenced by get_name(), and set_name().

◆ $nb_item

Pre_operation::$nb_item
private

$nb_item nb of item

Definition at line 33 of file pre_operation.class.php.

Referenced by get_nb_item(), and set_nb_item().

◆ $od_direct

Pre_operation::$od_direct

Compatibility for ACH in direct mode, only for ODS

Definition at line 38 of file pre_operation.class.php.

Referenced by get_od_direct(), and set_od_direct().

◆ $od_id

Pre_operation::$od_id
private

id of the Predefined Operation

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

Referenced by get_od_id(), and set_od_id().

◆ $p_jrn

Pre_operation::$p_jrn
private

$p_jrn jrn_def_id

Definition at line 34 of file pre_operation.class.php.

Referenced by set_p_jrn().


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