noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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
 
 choose_ledger ($p_ledger_type, $p_default)
 Build the select list for choosing the ledger.
 
 compute_array ()
 
 count ()
 count the number of pred operation for a ledger
 
 delete ()
 delete a template operation and children
 
 display ()
 display the detail of predefined operation, normally everything is loaded
 
 display_list_operation ($p_url)
 show the button for selecting a predefined operation
 
 form_get ($p_url)
 show a form to use pre_op
 
 get_db ()
 
 get_description ()
 
 get_detail ()
 
 get_jrn_type ()
 
 get_list_ledger ()
 get the list of the predef. operation of a ledger
 
 get_name ()
 
 get_nb_item ()
 
 get_od_direct ()
 
 get_od_id ()
 
 get_operation ()
 
 get_post ()
 fill the object with the $_POST variable
 
 load ()
 load the data from the database and return an array
 
 save ()
 
 save_insert ()
 save the predef check first is the name is unique
 
 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
 
 show_button_deprecated ()
 show the button for selecting a predefined operation
 

Static Public Member Functions

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

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 31 of file pre_operation.class.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

44 {
45 $this->db=$cn;
46 $this->od_direct='f';
47 $this->od_id=$p_id;
48 $this->p_jrn=0;
49 $this->jrn_type='x';
50 $this->name='';
51 $this->isloaded=false;
52 $this->description="";
53
54 }
$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 213 of file pre_operation.class.php.

213 {
214 $array["od_id"]=-1;
215 $array['jrn_def_id']=0;
216 $array['od_name']="";
217 $array['od_item']=2;
218 $array['od_jrn_type']=$this->get_jrn_type();
219 $array['od_description']="";
220 foreach (array('jrn_def_id','od_name','od_item','od_jrn_type','od_description') as $field) {
221 $this->$field=$array[$field];
222 }
223 $this->od_jrn_type=$array['od_jrn_type'];
224
225 $this->detail = Pre_operation_detail::build_detail($array['od_jrn_type'], $this->db);
226 $darray[0]=$array;
227 return $darray;
228 }
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 509 of file pre_operation.class.php.

509 {
510 $select_ledger=new ISelect("p_jrn");
511 $select_ledger->value=$this->db->make_array("select jrn_def_id,jrn_def_name
512 from jrn_def where jrn_def_type=$1 order by 2",
513 0,
514 [$p_ledger_type]);
515 $select_ledger->selected=$p_default;
516 return $select_ledger;
517 }

References db.

Referenced by display().

◆ compute_array()

Pre_operation::compute_array ( )

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

231 {
232 if ($this->od_id > 0) {
233 $p_array = $this->load();
234 } else {
235 $p_array=$this->blank();
236 }
237 $array=array(
238 "e_comm"=>$p_array[0]["od_name"],
239 "nb_item"=>(($p_array[0]["od_item"]<10)?10:$p_array[0]["od_item"]) ,
240 "p_jrn"=>$p_array[0]["jrn_def_id"],
241 "jrn_type"=>$p_array[0]["od_jrn_type"],
242 "od_description"=>$p_array['0']['od_description']
243 );
244 $this->detail = Pre_operation_detail::build_detail($this->od_jrn_type, $this->db);
245 $array += $this->detail->compute_array($this->od_id);
246 return $array;
247
248 }
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 269 of file pre_operation.class.php.

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

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 118 of file pre_operation.class.php.

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

References $sql, and db.

◆ display()

Pre_operation::display ( )

display the detail of predefined operation, normally everything is loaded

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

297 {
298 $array=$this->compute_array();
299 $select_ledger=$this->choose_ledger($array['jrn_type'],$array['p_jrn']);
300
301 require NOALYSS_TEMPLATE."/pre_operation_display.php";
302 echo $this->detail->display($array);
303 }
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 325 of file pre_operation.class.php.

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

References $i, $p_url, $r, $value, _, count(), and db.

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 306 of file pre_operation.class.php.

307 {
308 $r=HtmlInput::button_action(_("Modèle d'opérations"),
309 ' $(\'modele_op_div\').style.display=\'block\';if ( $(\'lk_modele_op_tab\')) { $(\'lk_modele_op_tab\').focus();}');
310 $r.='<div id="modele_op_div" class="noprint">';
311 $r.=HtmlInput::title_box(_("Modèle d'opérations"), 'modele_op_div', 'hide',"","n");
312 $hid=new IHidden();
313 $r.=$hid->input("action","use_opd");
314 $r.=$hid->input("jrn_type",$this->jrn_type);
316 $r.=' <p style="text-align: center">'.
317 HtmlInput::button_hide('modele_op_div').
318 '</p>';
319 $r.='</div>';
320 return $r;
321
322 }
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', $raw="")
Title for boxes, you can customize the symbol thanks symbol with the mode "custom".
display_list_operation($p_url)
show the button for selecting a predefined operation

References $hid, $p_url, $r, _, and display_list_operation().

+ Here is the call graph for this function:

◆ get_db()

Pre_operation::get_db ( )
Returns
mixed

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

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

References $db.

◆ get_description()

Pre_operation::get_description ( )
Returns
string

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

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

References $description.

◆ get_detail()

Pre_operation::get_detail ( )
Returns
array

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

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

References $detail.

◆ get_jrn_type()

Pre_operation::get_jrn_type ( )
Returns
string

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

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

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 280 of file pre_operation.class.php.

281 {
282 $sql="select od_id,od_name,od_description from op_predef ".
283 " where jrn_def_id= $1 ".
284 " and od_direct = $2 ".
285 " order by od_name";
286 $res=$this->db->exec_sql($sql,array($this->p_jrn,$this->od_direct));
288 return $all;
289 }
static fetch_all($ret)
wrapper for the function pg_fetch_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 423 of file pre_operation.class.php.

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

References $name.

◆ get_nb_item()

Pre_operation::get_nb_item ( )
Returns
mixed

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

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

References $nb_item.

◆ get_od_direct()

Pre_operation::get_od_direct ( )
Returns
string

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

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

References $od_direct.

◆ get_od_id()

Pre_operation::get_od_id ( )
Returns
int|mixed

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

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

References $od_id.

◆ get_operation()

Pre_operation::get_operation ( )

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

356 {
357 if ( $this->jrn_def_id=='') return array();
358 $value=$this->db->make_array("select od_id,od_name from op_predef ".
359 " where jrn_def_id=".sql_string($this->jrn_def_id).
360 " and od_direct ='".sql_string($this->od_direct)."'".
361 " order by od_name",1);
362 return $value;
363 }
sql_string($p_string)
Fix the problem with the quote char for the database.
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 93 of file pre_operation.class.php.

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

References $http, $n, 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 186 of file pre_operation.class.php.

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

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 123 of file pre_operation.class.php.

124 {
125 if ($this->od_id < 1) {
126 $this->save_insert();
127 } else {
128 $this->save_update();
129 }
130
131 }
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 144 of file pre_operation.class.php.

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

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 60 of file pre_operation.class.php.

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

References $opd_description, $r, and _.

◆ save_update()

Pre_operation::save_update ( )

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

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

References $sql, db, and name.

Referenced by save().

◆ set_db()

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

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

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

References $db, and db.

◆ set_description()

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

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

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

References $description.

◆ set_detail()

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

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

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

References $detail.

◆ set_jrn_type()

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

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

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

References $jrn_type.

◆ set_name()

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

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

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

References $name, and name.

◆ set_nb_item()

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

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

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

References $nb_item.

◆ set_od_direct()

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

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

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

References $od_direct.

◆ set_od_id()

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

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

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

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 496 of file pre_operation.class.php.

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

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 253 of file pre_operation.class.php.

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

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

Field Documentation

◆ $db

Pre_operation::$db
private

$db database connection

Definition at line 33 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 42 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 38 of file pre_operation.class.php.

Referenced by get_detail(), and set_detail().

◆ $isloaded

Pre_operation::$isloaded
private

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

◆ $jrn_type

Pre_operation::$jrn_type
private

$jrn_type

Definition at line 36 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 37 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 34 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 39 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 40 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 35 of file pre_operation.class.php.

Referenced by set_p_jrn().


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