noalyss Version-9
operation_predef_mtable.class.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19// Copyright Author Dany De Bontridder danydb@aevalys.eu
20/*!
21 * \file
22 * \brief Class to manage predefined operation thanks the class Manage Table
23 * Display a table and allow to change the predefined operation, insert or delete. Used the
24 * class Manage_Table_SQL and the SQL Object for the tables op_predef and op_predef_detail.
25 */
26require_once NOALYSS_INCLUDE."/database/op_predef_sql.class.php";
27
28/*!
29 * \class Operation_Predef_MTable
30 * \brief Display a table and allow to change the predefined operation, insert or delete. Used the
31 * class Manage_Table_SQL and the SQL Object for the tables op_predef and op_predef_detail.
32 *
33 * @see include/preod.inc.php
34 * @see include/ajax/ajax_save_predf_op.php
35 */
36
38{
40 private $force_ledger_type; //!< When adding , the ledger must be set
41 function __construct(Op_Predef_SQL $p_table)
42 {
43 parent::__construct($p_table);
44
45 $this->set_property_visible("od_id",false);
46 $this->set_property_visible("od_direct",false);
47 $this->set_property_visible("od_item",false);
48 $this->set_col_label("jrn_def_id",_("Journal"));
49 $this->set_col_label("od_name",_("Nom"));
50 $this->set_col_label("od_jrn_type",_("Type de journal"));
51 $this->set_col_label("od_description",_("Description"));
52
53 $aLedger=$p_table->cn->make_array("select jrn_def_id,jrn_def_name from jrn_def order by jrn_def_name asc");
54
55 $this->set_sort_column("od_name");
56 $this->set_col_sort(1);
57 $this->set_order(array("jrn_def_id","od_name","od_description","od_jrn_type"));
58 $this->set_col_type("jrn_def_id","select",$aLedger);
59
60 $this->set_callback("ajax_misc.php");
61 $this->set_property_updatable("jrn_def_id",false);
62 $this->set_property_updatable("od_jrn_type",false);
63 $this->pre_operation=null;
64 // create our own "Append button"
65 $this->set_append_row(false);
66 $this->set_dialog_box("prdfop");
67 }
68
69 /**
70 * @return mixed
71 */
72 public function get_force_ledger_type()
73 {
75 }
76
77 /**
78 * When adding the ledger_type must be set
79 * if p_id == -2 then type ACH , 3 for VEN and 4 for ODS
80 * @param mixed $force_ledger_type
81 */
83 {
84 $aLedger=array(-2=>'ACH',-3=>'VEN',-4=>'ODS');
85 $this->force_ledger_type = $aLedger[$force_ledger_type];
86 return $this;
87 }
88
89 /**
90 * Display the form
91 * @throws Exception
92 */
93 function input()
94 {
95 $obj=$this->get_table();
96 $od_id=$obj->get("od_id");
97 if ($od_id > 0 ) {
98 $this->pre_operation = new Pre_operation($obj->cn);
99 $this->pre_operation->set_od_id($obj->get("od_id"));
100 $this->pre_operation->display();
101 } else {
102 // display blanck operation type ledger = ACH
103 $this->pre_operation = new Pre_operation($obj->cn);
104 // new operation od_id = -1
105 $this->pre_operation->set_od_id(-1);
106 $this->pre_operation->set_jrn_type($this->get_force_ledger_type());
107 $this->pre_operation->display();
108
109 }
110 }
111
112 /**
113 * Get values from the request
114 * - table is the sql table
115 * - ctl_id is the dialog box id
116 * - p_id = predef_op.od_id
117 *
118 * @code
119 * json = {"table":"public.op_predef",
120 "ctl_id":"dtr",
121 "ac":"COMPTA/ADV/PREDOP",
122 "op":"save_predf",
123 "gDossier":["28", "28"],
124 "p_id":"15",
125 "action":"save",
126 "ctl":"tbl5f6a1d09035f2",
127 "nb_item":"10",
128 "e_client":"",
129 "p_jrn":"2",
130 "e_march0":"MARCHA",
131 "e_march0_price":"102.0000",
132 "e_quant0":"1.0000",
133 "htva_march0":"0",
134 "e_march0_tva_id":"4",
135 "bt_e_march0_tva_id":"+TVA+",
136 "e_march0_tva_amount":"0.0000",
137 "tva_march0":"0","tvac_march0":"0",
138 "jrn_type":"VEN",
139 "5f6a1d0b23242_ledger":"O","
140 5f6a1d0b23242":"1",
141 "update":"OK",
142 "5f6a1d5b70997_ledger":"O",
143 "5f6a1d5b70997":"1"}
144 * @endcode
145 */
146 function from_request()
147 {
148 $http=new HttpInput();
149 $obj=$this->get_table();
150 $this->pre_operation=new Pre_operation($obj->cn);
151 $this->pre_operation->get_post();
152 $this->pre_operation->set_od_id($http->post("p_id","number"));
153 }
154
155 function save()
156 {
157 $this->pre_operation->save();
158 $this->set_pk($this->pre_operation->get_od_id());
159 }
160
161 /**
162 * Display a button to choose a type of operation and call a dialog box for adding
163 */
165 {
166 $select=new Select_Box(uniqid(),_("Ajout"));
167 $select->set_position('in-absolute');
168 $select->add_javascript(_("Achat"),sprintf("%s.input('-2','%s')",
169 $this->get_object_name(),
170 $this->get_object_name(), "xx", "smallbutton", BUTTONADD));
171
172 $select->add_javascript(_("Vente"),sprintf("%s.input('-3','%s')",
173 $this->get_object_name(),
174 $this->get_object_name(), "xx", "smallbutton", BUTTONADD));
175
176 $select->add_javascript(_("Opérations Diverses"),sprintf("%s.input('-4','%s')",
177 $this->get_object_name(),
178 $this->get_object_name(), "xx", "smallbutton", BUTTONADD));
179 echo $select->input();
180 }
181}
manage the http input (get , post, request) and extract from an array
Purpose is to propose a librairy to display a table content and allow to update and delete row ,...
set_append_row($p_value)
Enable or disable the appending of rows.
set_col_sort($p_num)
When adding an element ,we place it thanks the DOM Attribute sort_value set it to -1 if you want one ...
set_property_updatable($p_key, $p_value)
set a column of the data row updatable or not
set_col_type($p_key, $p_value, $p_array=NULL)
set the type of a column , it will change in the input db box , the select must supply an array of po...
set_pk($p_id)
set the id value of a data row and load from the db
set_sort_column($p_col)
set the column to sort by default
set_callback($p_file)
set the callback function that is passed to javascript
set_property_visible($p_key, $p_value)
set a column of the data row visible or not
set_col_label($p_key, $p_display)
set the name to display for a column
ORM abstract of the table public.op_predef.
Display a table and allow to change the predefined operation, insert or delete. Used the class Manage...
set_force_ledger_type($force_ledger_type)
When adding the ledger_type must be set if p_id == -2 then type ACH , 3 for VEN and 4 for ODS.
from_request()
Get values from the request.
$force_ledger_type
When adding , the ledger must be set.
save()
save the Data_SQL Object The noalyss_SQL is not empty
display_button_add()
Display a button to choose a type of operation and call a dialog box for adding.
manage the predefined operation, link to the table op_def and op_def_detail
Display a kind of select.
const BUTTONADD
Definition: constant.php:102