50 $this->isloaded=
false;
51 $this->description=
"";
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();
66 $opd_description->style=
' class="itextarea" style="width:30em;height:4em;vertical-align:top"';
68 $r.=
'<p class="decale">';
69 $r.= _(
'Description (max 50 car.)');
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');
100 $this->description=
$http->post(
'od_description');
101 if ( $this->
name==
"")
103 $n=$this->
db->get_next_seq(
'op_def_op_seq');
104 $this->
name=$this->jrn_type.$n;
111 $this->detail->get_post();
119 $sql=
"delete from op_predef where od_id=$1";
120 $this->
db->exec_sql(
$sql,array($this->od_id));
124 if ($this->od_id < 1) {
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));
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);
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)
151 $this->
name=
"copy_".$this->name.
"_".microtime(
true);
155 echo
'<span class="notice">'.(
"Vous avez atteint le max. d'opération prédéfinie, désolé").
'</span>';
160 $sql=
'insert into op_predef (jrn_def_id,od_name,od_item,od_jrn_type,od_direct,od_description) '.
162 "($1,$2,$3,$4,$5 ,$6)".
164 $this->od_id= $this->
db->get_value(
$sql,array($this->p_jrn,
173 $this->detail->save($this->od_id,$this->nb_item);
175 }
catch (Exception
$e) {
176 record_log(
"PROP139.Failed save predefined operation ");
177 $this->
db->rollback();
187 $this->isloaded=
true;
191 if ($this->od_id == -1 ) {
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 ".
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];
204 $array+=$this->detail->load($this->od_id);
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];
222 $this->od_jrn_type=
$array[
'od_jrn_type'];
231 if ($this->od_id > 0) {
240 "jrn_type"=>
$p_array[0][
"od_jrn_type"],
241 "od_description"=>
$p_array[
'0'][
'od_description']
244 $array += $this->detail->compute_array($this->od_id);
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");
261 if ( empty(
$value)==
true)
return "";
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));
281 $sql=
"select od_id,od_name,od_description from op_predef ".
282 " where jrn_def_id= $1 ".
283 " and od_direct = $2 ".
285 $res=$this->
db->exec_sql(
$sql,array($this->p_jrn,$this->od_direct));
300 require NOALYSS_TEMPLATE.
"/pre_operation_display.php";
301 echo $this->detail->display(
$array);
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">';
312 $r.=
$hid->input(
"action",
"use_opd");
313 $r.=
$hid->input(
"jrn_type",$this->jrn_type);
315 $r.=
' <p style="text-align: center">'.
328 $value=$this->
db->get_array(
"select od_id,od_name,od_description from op_predef ".
329 " where jrn_def_id=$1".
331 array($this->p_jrn));
333 if ( $this->p_jrn==
'')
$value=array();
337 $r.=_(
"Vous n'avez encore sauvé aucun modèle");
341 $r.=
'<table style="width:100%" id="modele_op_tab">';
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> ',
348 $r.=
'<td>'.h(
$value[
$i][
'od_description']).
'</td>';
357 $value=$this->
db->make_array(
"select od_id,od_name from op_predef ".
359 " and od_direct ='".
sql_string($this->od_direct).
"'".
360 " order by od_name",1);
414 if ( ! in_array (
$jrn_type,[
'ACH',
'FIN',
'VEN',
'ODS'] ))
throw new Exception(
'prop03.invalid ledger type');
469 if ( ! in_array(
$od_direct,[
'f',
't']))
throw new Exception(
'prop02.invalid od_direct');
498 $this->jrn_type=$this->
db->get_value(
"select jrn_def_type from jrn_def where jrn_def_id=$1",[
$p_jrn]);
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",
514 $select_ledger->selected=$p_default;
515 return $select_ledger;
533 switch ($p_jrn_type) {
538 $detail=
new Pre_Op_ven($database);
541 $detail=
new Pre_op_advanced($database);
544 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.
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
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