30#[AllowDynamicProperties]
51 $this->isloaded=
false;
52 $this->description=
"";
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();
67 $opd_description->style=
' class="itextarea" style="width:30em;height:4em;vertical-align:top"';
69 $r.=
'<p class="decale">';
70 $r.=
_(
'Description (max 50 car.)');
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');
101 $this->description=
$http->post(
'od_description');
102 if ( $this->
name==
"")
104 $n=$this->
db->get_next_seq(
'op_def_op_seq');
105 $this->
name=$this->jrn_type.$n;
112 $this->detail->get_post();
120 $sql=
"delete from op_predef where od_id=$1";
121 $this->
db->exec_sql(
$sql,array($this->od_id));
125 if ($this->od_id < 1) {
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));
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);
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)
152 $this->
name=
"copy_".$this->name.
"_".microtime(
true);
156 echo
'<span class="notice">'.(
"Vous avez atteint le max. d'opération prédéfinie, désolé").
'</span>';
161 $sql=
'insert into op_predef (jrn_def_id,od_name,od_item,od_jrn_type,od_direct,od_description) '.
163 "($1,$2,$3,$4,$5 ,$6)".
165 $this->od_id= $this->
db->get_value(
$sql,array($this->p_jrn,
174 $this->detail->save($this->od_id,$this->nb_item);
176 }
catch (Exception
$e) {
177 record_log(
"PROP139.Failed save predefined operation ");
178 $this->
db->rollback();
188 $this->isloaded=
true;
192 if ($this->od_id == -1 ) {
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 ".
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];
205 $array+=$this->detail->load($this->od_id);
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];
223 $this->od_jrn_type=
$array[
'od_jrn_type'];
232 if ($this->od_id > 0) {
241 "jrn_type"=>
$p_array[0][
"od_jrn_type"],
242 "od_description"=>
$p_array[
'0'][
'od_description']
245 $array += $this->detail->compute_array($this->od_id);
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");
262 if ( empty(
$value)==
true)
return "";
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));
282 $sql=
"select od_id,od_name,od_description from op_predef ".
283 " where jrn_def_id= $1 ".
284 " and od_direct = $2 ".
286 $res=$this->
db->exec_sql(
$sql,array($this->p_jrn,$this->od_direct));
301 require NOALYSS_TEMPLATE.
"/pre_operation_display.php";
302 echo $this->detail->display(
$array);
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");
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').
329 $value=$this->
db->get_array(
"select od_id,od_name,od_description from op_predef ".
330 " where jrn_def_id=$1".
332 array($this->p_jrn));
334 if ( $this->p_jrn==
'')
$value=array();
338 $r.=
_(
"Vous n'avez encore sauvé aucun modèle");
341 $r.=
_(
'Cherche').
' '.HtmlInput::filter_table(
'modele_op_tab',
'0,1',
'0');
342 $r.=
'<table style="width:100%" id="modele_op_tab">';
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> ',
349 $r.=
'<td>'.h(
$value[
$i][
'od_description']).
'</td>';
358 $value=$this->
db->make_array(
"select od_id,od_name from op_predef ".
360 " and od_direct ='".
sql_string($this->od_direct).
"'".
361 " order by od_name",1);
415 if ( ! in_array (
$jrn_type,[
'ACH',
'FIN',
'VEN',
'ODS'] ))
throw new Exception(
'prop03.invalid ledger type');
470 if ( ! in_array(
$od_direct,[
'f',
't']))
throw new Exception(
'prop02.invalid od_direct');
499 $this->jrn_type=$this->
db->get_value(
"select jrn_def_type from jrn_def where jrn_def_id=$1",[
$p_jrn]);
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",
515 $select_ledger->selected=$p_default;
516 return $select_ledger;
527#[AllowDynamicProperties]
539 switch ($p_jrn_type) {
544 $detail=
new Pre_Op_ven($database);
547 $detail=
new Pre_op_advanced($database);
550 throw new Exception(sprintf(
_(
'Echec PreOperation chargement %s'),$p_jrn_type));
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...
sql_string($p_string)
Fix the problem with the quote char for the database.
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
_("actif, passif,charge,...")
static fetch_all($ret)
wrapper for the function pg_fetch_all
contains the class for connecting to Noalyss
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
Manage the TEXTAREA html element.
concerns the predefined operation for ACH ledger
mother of the pre_op_XXX, it contains only one data : an object Pre_Operation. The child class contai...
static build_detail($p_jrn_type, Database $database)
manage the predefined operation, link to the table op_def and op_def_detail
form_get($p_url)
show a form to use pre_op
get_post()
fill the object with the $_POST variable
count()
count the number of pred operation for a ledger
display_list_operation($p_url)
show the button for selecting a predefined operation
blank()
create a blank object to insert it later
get_list_ledger()
get the list of the predef. operation of a ledger
choose_ledger($p_ledger_type, $p_default)
Build the select list for choosing the ledger.
set_detail(Pre_operation_detail $detail)
set_p_jrn($p_jrn)
set the ledger
set_od_direct($od_direct)
set_description($description)
__construct($cn, $p_id=0)
load()
load the data from the database and return an array
show_button_deprecated()
show the button for selecting a predefined operation
static save_propose()
Propose to save the operation into a predefined operation.
save_insert()
save the predef check first is the name is unique
display()
display the detail of predefined operation, normally everything is loaded
const MAX_PREDEFINED_OPERATION