noalyss Version-9
Public Member Functions | Static Public Member Functions | Private Attributes
Forecast_Item_MTable Class Reference

display the item for forecast More...

+ Inheritance diagram for Forecast_Item_MTable:
+ Collaboration diagram for Forecast_Item_MTable:

Public Member Functions

 __construct (Data_SQL $p_table)
 
 check ()
 
 count_category ()
 
 display_row ($p_row)
 display a data row in the table, with the order defined in a_order and depending of the visibility of the column, all the rows contains the attribute ctl_pk_id , to retrieve in javascript , ie with the function afterSaveFct (see managetable.js) More...
 
 display_table ($p_string="", $p_array=NULL)
 Display list of items, if there is no category the list is empty and you cannot add new ones. More...
 
 from_request ()
 forecast_id: 14 p_id: 143 action: save ctl: tbl6058da883ded6 fc_id: 88 fi_text: Gérant fi_account: [4160%]-[4890%] fi_amount: 3000.0000 fi_pid: 0 More...
 
 get_forecast_id ()
 
 input ()
 display into a dialog box the datarow in order to be appended or modified. More...
 
 set_forecast_id (int $forecast_id)
 
- Public Member Functions inherited from Manage_Table_SQL
 __construct (Data_SQL $p_table)
 
 add_json_param ($p_attribute, $p_value)
 Add json parameter to the current one. More...
 
 ajax_delete ()
 Delete a record and return an XML answer for ajax. More...
 
 ajax_input ($p_status="OK")
 send an xml with input of the object, create an xml answer. More...
 
 ajax_save ()
 Save the record from Request into the DB and returns an XML to update the Html Element. More...
 
 can_append_row ()
 return false if the append of the row is forbidden More...
 
 can_delete_row ()
 return false if the delete of the row is forbidden More...
 
 can_update_row ()
 return false if the update of the row is forbidden More...
 
 check ()
 
 count_error ()
 returns the nb of errors found More...
 
 create_js_script ()
 we must create first the javascript if we want to update, insert or delete rows. More...
 
 delete ()
 delete a datarow , the id must be have set before More...
 
 display_error ()
 Display a list of the error collected. More...
 
 display_icon_custom ($p_row)
 usually contain a link and calls another page, it must be overriden More...
 
 display_icon_del ($p_row)
 
 display_icon_mod ($p_row)
 
 display_row ($p_row)
 display a data row in the table, with the order defined in a_order and depending of the visibility of the column, all the rows contains the attribute ctl_pk_id , to retrieve in javascript , ie with the function afterSaveFct (see managetable.js) More...
 
 display_row_custom ($p_key, $p_value, $p_id=0)
 When displaying a row, if a column has the type "custom" , we can call this function to display properly the value including the tag "<td>". More...
 
 display_table ($p_order="", $p_array=NULL)
 display the data of the table More...
 
 display_table_header ()
 display the column header excepted the not visible one and in the order defined with $this->a_order More...
 
 execute_query ($p_order="", $p_array=NULL)
 execute the query (Data_SQL.seek), called by display_table More...
 
 from_request ()
 get the data from http request strip the not update or not visible data to their initial value. More...
 
 get_button_add_top ()
 
 get_col_option ($p_key)
 add extra to column, normally class , javascript or style More...
 
 get_col_sort ()
 When adding an element , it is column we checked to insert before,. More...
 
 get_col_type ($p_key)
 return the type of a column More...
 
 get_current_pos ($p_key)
 get the position of a column More...
 
 get_current_row ()
 Return the current row printed in display_row. More...
 
 get_dialog_box ()
 
 get_dialogbox_style ()
 return the db_style More...
 
 get_error ($p_col)
 retrieve the error message More...
 
 get_header_option ($p_key)
 add extra to column Header, normally class , javascript or style More...
 
 get_icon_del ()
 
 get_icon_mod ()
 
 get_js_variable ()
 Get the object name. More...
 
 get_json ()
 
 get_object_name ()
 
 get_order ()
 
 get_property_updatable ($p_key)
 return True if the column is updatable otherwise false More...
 
 get_property_visible ($p_key)
 return True if the column is visible otherwise false More...
 
 get_search_table ()
 Get if we can search in the table. More...
 
 get_sort_column ()
 return the column to sort More...
 
 get_table ()
 
 getCssClass ()
 
 getTitle ()
 
 input ()
 display into a dialog box the datarow in order to be appended or modified. More...
 
 input_custom ($p_key, $p_value)
 this function let you create your own input , for example for a ITEXT , a IRADIO , ... it must be override , there is not default More...
 
 insert ()
 insert a new value More...
 
 move ($p_key, $p_idx)
 if we change a column order , the order of the other columns is impacted. More...
 
 param_set ($p_json)
 Set the parameter of the object (gDossier, ac, plugin_code...) @detail By default , only gDossier will be set . More...
 
 save ()
 save the Data_SQL Object The noalyss_SQL is not empty More...
 
 send_header ()
 send the XML headers for the ajax call More...
 
 set_append_row ($p_value)
 Enable or disable the appending of rows. More...
 
 set_button_add_top ($button_add_top)
 
 set_callback ($p_file)
 set the callback function that is passed to javascript More...
 
 set_col_label ($p_key, $p_display)
 set the name to display for a column More...
 
 set_col_option ($p_key, $p_value)
 add extra to column, normally class or style More...
 
 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 to append. More...
 
 set_col_tips ($p_key, $p_comment)
 Set the info for a column, use Icon_Action::infobulle the message are in message_javascript.php. More...
 
 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 possible values [val=> , label=>] with the variable $this->key_name->a_value More...
 
 set_current_row ($current_row)
 set the current row printed in display_row More...
 
 set_delete_row ($p_value)
 Enable or disable the deletion of rows. More...
 
 set_dialog_box ($dialog_box)
 
 set_dialogbox_style ($db_style)
 Dialog box style , by default {position: "fixed", top: '15', width: "auto", "margin-left": "20%"}. More...
 
 set_error ($p_col, $p_message)
 set the error message for a wrong input More...
 
 set_header_option ($p_key, $p_value)
 add extra to column Header, normally class or style More...
 
 set_icon_del ($pString)
 Set the icon to delete at the right or left of the row. More...
 
 set_icon_mod ($pString)
 Set the icon to modify at the right ,the first col or left of the row, if the mod if custom , you have to override the function display_icon_custom. More...
 
 set_json ($p_json)
 Set the parameter of the object (gDossier, ac, plugin_code...) @detail By default , only gDossier will be set . More...
 
 set_object_name ($p_object_name)
 Set the object_name. More...
 
 set_order ($p_order)
 
 set_pk ($p_id)
 set the id value of a data row and load from the db More...
 
 set_property_updatable ($p_key, $p_value)
 set a column of the data row updatable or not More...
 
 set_property_visible ($p_key, $p_value)
 set a column of the data row visible or not More...
 
 set_search_table ($search_table)
 Set the table searchable or not. More...
 
 set_sort_column ($p_col)
 set the column to sort by default More...
 
 set_table (Data_SQL $p_noalyss_sql)
 
 set_update_row ($p_value)
 Enable or disable the updating of rows. More...
 
 set_value ($p_key, $p_value)
 
 setCssClass ($p_class)
 
 setTitle ($p_title)
 Set the title of the diabox , default is Donnée. More...
 
 show_error ($p_col)
 
 update ()
 

Static Public Member Functions

static build ($p_id=-1)
 

Private Attributes

 $forecast_id
 

Additional Inherited Members

- Data Fields inherited from Manage_Table_SQL
const UPDATABLE =1
 
const VISIBLE =2
 
- Protected Attributes inherited from Manage_Table_SQL
 $a_col_option
 in display_row and display_custom_row, it is the current row which is used More...
 
 $a_header_option
 Extra to add to the column Header : CSS Style , CSS class, javascript ,... More...
 
 $a_info
 Array with the infotip. More...
 
 $a_label_displaid
 Label of the col. of the datarow. More...
 
 $a_order
 order of the col More...
 
 $a_prop
 property for each col. More...
 
 $a_select
 Possible value if a_type is a SELECT. More...
 
 $a_type
 Type of the column : date , select ... Only in input. More...
 
 $aerror
 Array containing the error of the input data. More...
 
 $button_add_top
 place of the button add on the top, by default true More...
 
 $callback
 Callback function. More...
 
 $col_sort
 when inserting, it is the column to sort,-1 to disable it and append only More...
 
 $cssclass
 < give the title of the diabox , default is Data More...
 
 $current_row
 CSS class for the dialog box. More...
 
 $dialog_box
 ID of the dialog box which display the result of the ajax calls. More...
 
 $dialogbox_style
 style of the dialog box More...
 
 $icon_del
 place of right or left the icon update or mod, default right, accepted value=left,right More...
 
 $icon_mod
 place of right or left the icon update or mod, default right, accepted value=left,right,first,custom column for mod More...
 
 $json_parameter
 Default parameter to add (gDossier...), sent to the ajax callback. More...
 
 $object_name
 Object_name is used for the javascript , it is the row id to update or delete. More...
 
 $row_append
 Flag to indicate if rows can be added. More...
 
 $row_delete
 Flag to indicate if rows can be deleted. More...
 
 $row_update
 Flag to indicate if rows can be updated. More...
 
 $search_table
 boolean , by default true ,it is possible to search in the table, More...
 
 $sort_column
 javascript sort on this column , if empty there is no js sort More...
 
 $table
 Object Data_SQL. More...
 
 $title
 

Detailed Description

display the item for forecast

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

Constructor & Destructor Documentation

◆ __construct()

Forecast_Item_MTable::__construct ( Data_SQL  $p_table)

Reimplemented from Manage_Table_SQL.

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

44 {
45 parent::__construct($p_table);
46 $this->forecast_id = -1;
47 }

Member Function Documentation

◆ build()

static Forecast_Item_MTable::build (   $p_id = -1)
static

Definition at line 49 of file forecast_item_mtable.class.php.

50 {
54 $forecast_item->add_json_param('ac', 'FORECAST');
55 $forecast_item->add_json_param("op", "forecast_item");
56 $forecast_item->set_callback("ajax_misc.php");
57 if ( $p_id != -1 ) {
58 $forecast_id=$cn->get_value("select f_id
59 from forecast_item fi
60 join forecast_category fc on (fi.fc_id=fc.fc_id)
61 where
62 fi_id=$1",array($p_id));
63 $forecast_item->set_forecast_id($forecast_id);
64 }
65 return $forecast_item;
66
67 }
catch(Exception $e) $forecast_item
static connect()
display the item for forecast
ORM abstract of the table public.forecast_item.

References $cn, $forecast_id, $forecast_item, $forecast_sql, $p_id, and Dossier\connect().

Referenced by Anticipation\input_form().

+ Here is the call graph for this function:

◆ check()

Forecast_Item_MTable::check ( )
   @brief This function can be overrided to check the data before 
   inserting , updating or removing, above an example of an overidden check.

   Usually , you get the row of the table (get_table) , you check the conditions
   if an condition is not met then you set the error with $this->set_error 

   if there are error (returns false otherwise true

   @see set_error get_error count_error
   @return boolean
function check()
{
global $cn;
$table=$this->get_table();
$is_error=0;
$insert=false;
// sect_codename must be unique
if ( $table->exist() > 0) {
$insert=1;
}
$count=$cn->get_value(" select count(*) from syndicat.treasurer where tr_login=$1 and sect_id=$2 and tr_id<>$3",
array(
$table->tr_login,
$table->section_full_name,
$table->tr_id
));
if ($count > 0 ) {
$this->set_error("section_full_name",_("Ce trésorier a déjà accès à cette section"));
$is_error++;
}
if ( $is_error > 0 ) return false;
return true;
}
set_error($p_col, $p_message)
set the error message for a wrong input
$count

Reimplemented from Manage_Table_SQL.

Definition at line 197 of file forecast_item_mtable.class.php.

198 {
199 $object=$this->get_table();
200 if ( trim($object->getp("fi_text") ) == "") {
201 $this->set_error("fi_text", _("Intitulé est vide"));
202 }
203 if ( trim ($object->getp("fi_account"))=="") {
204 $this->set_error("fi_account", _("Formule est vide"));
205 }
206 if ( trim ($object->getp("fi_account"))=="") {
207 $this->set_error("fi_account", _("Formule est vide"));
208 }
209 if ( ! Impress::check_formula($object->getp("fi_account"))) {
210 $this->set_error("fi_account", _("Formule invalide"));
211 }
212 if ( $this->count_error()==0) return true;
213 return false;
214 }
catch(Exception $e) $object
static check_formula($p_string)
count_error()
returns the nb of errors found

References $object, Impress\check_formula(), Manage_Table_SQL\count_error(), Manage_Table_SQL\get_table(), and Manage_Table_SQL\set_error().

+ Here is the call graph for this function:

◆ count_category()

Forecast_Item_MTable::count_category ( )

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

86 {
87 $object=$this->get_table();
88 $nCategory = $object->cn->get_value("select count(*) from forecast_category where f_id=$1",[$this->forecast_id]);
89 return $nCategory;
90
91 }

References $object, and Manage_Table_SQL\get_table().

Referenced by input().

+ Here is the call graph for this function:

◆ display_row()

Forecast_Item_MTable::display_row (   $p_row)

display a data row in the table, with the order defined in a_order and depending of the visibility of the column, all the rows contains the attribute ctl_pk_id , to retrieve in javascript , ie with the function afterSaveFct (see managetable.js)

Parameters
array$p_rowcontains a row from the database
See also
set_col_type
input_custom
display_table
display_row_custom
managetable.js

From database

Reimplemented from Manage_Table_SQL.

Definition at line 112 of file forecast_item_mtable.class.php.

113 {
114 if ( ! isset($p_row['fc_desc'])) {
115 $cn=$this->get_table()->cn;
116 $sql= "select fi_id,fi_text,fi_account,
117 fi_account str_account_card,
118 fc_desc,
119 fi.fi_amount ,
120 (select p_start from parm_periode pp where pp.p_id=fi.fi_pid) as str_periode
121 from forecast_item fi join forecast_category fc on (fi.fc_id=fc.fc_id)
122 where fi_id=$1";
123 $p_row=$cn->get_row($sql,[$p_row['fi_id']]);
124
125 }
126 if ( ! isset ($p_row['str_account_card'])) {
127 $p_row['str_account_card']="";
128 }
129 if ( !isset ($p_row['str_periode'])){
130 $p_row['str_periode']="";
131 }
132 printf('<tr id="%s_%s">', $this->object_name, $p_row['fi_id']);
133 print td($p_row['fc_desc']);
134 print td($p_row['fi_text']);
135 print td($p_row['str_account_card']);
136 print td(nbm($p_row['fi_amount']));
137 print td($p_row['str_periode']);
138
139
140 $jsdel = sprintf("%s.remove('%s','%s');",
141 $this->object_name,
142 $p_row['fi_id'],
143 $this->object_name
144 );
145 $jsupd = sprintf("%s.input('%s','%s');",
146 $this->object_name,
147 $p_row['fi_id'],
148 $this->object_name
149 );
150 echo '<td>' . Icon_Action::modify(uniqid(), $jsupd);
151 echo '</td>';
152 echo '<td>';
153 echo Icon_Action::trash(uniqid(), $jsdel);
154 echo '</td>';
155 echo '</tr>';
156
157 }
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
nbm($p_number, $p_dec=2)
format the number with a sep.
Definition: ac_common.php:137
static modify($p_id, $p_javascript)
Display the icon to modify a idem.
static trash($p_id, $p_javascript)
Display the icon of a trashbin.
print
Type of printing.

References $cn, $sql, Manage_Table_SQL\get_table(), Icon_Action\modify(), nbm(), print, td(), and Icon_Action\trash().

+ Here is the call graph for this function:

◆ display_table()

Forecast_Item_MTable::display_table (   $p_string = "",
  $p_array = NULL 
)

Display list of items, if there is no category the list is empty and you cannot add new ones.

Parameters
type$p_string
type$p_array

Reimplemented from Manage_Table_SQL.

Definition at line 97 of file forecast_item_mtable.class.php.

98 {
99
100 $sql = "select fi_id,fi_text,fi_account,
101 fi_account str_account_card,
102 fc_desc,
103 fi.fi_amount ,
104 (select p_start from parm_periode pp where pp.p_id=fi.fi_pid) as str_periode
105 from forecast_item fi join forecast_category fc on (fi.fc_id=fc.fc_id)
106 where fc.f_id =$1
107 order by fc_desc,fi_text ";
108 $a_row = $this->get_table()->cn->get_array($sql, array($this->forecast_id));
109 require_once NOALYSS_TEMPLATE . "/forecast_item_mtable-display_table.php";
110 }

References $a_row, $sql, and Manage_Table_SQL\get_table().

+ Here is the call graph for this function:

◆ from_request()

Forecast_Item_MTable::from_request ( )

forecast_id: 14 p_id: 143 action: save ctl: tbl6058da883ded6 fc_id: 88 fi_text: Gérant fi_account: [4160%]-[4890%] fi_amount: 3000.0000 fi_pid: 0

Reimplemented from Manage_Table_SQL.

Definition at line 182 of file forecast_item_mtable.class.php.

183 {
184 $http=new HttpInput();
185 $this->set_forecast_id($http->post("forecast_id","number"));
186 $object_sql=$this->get_table();
187 $object_sql->setp("fi_text",$http->post("fi_text"));
188 $object_sql->setp("fc_id",$http->post('fc_id',"number"));
189 $object_sql->setp("fi_account",$http->post('fi_account'));
190 $object_sql->setp("fi_amount",$http->post('fi_amount',"number"));
191 $object_sql->setp("fi_pid",$http->post('fi_pid',"number"));
192 $object_sql->setp("fi_amount_initial",$http->post("fi_amount_initial","number"));
193
194
195
196 }
manage the http input (get , post, request) and extract from an array

References $http, Manage_Table_SQL\get_table(), and set_forecast_id().

+ Here is the call graph for this function:

◆ get_forecast_id()

Forecast_Item_MTable::get_forecast_id ( )
Returns
int

Definition at line 72 of file forecast_item_mtable.class.php.

72 : int
73 {
74 return $this->forecast_id;
75 }

References $forecast_id.

◆ input()

Forecast_Item_MTable::input ( )

display into a dialog box the datarow in order to be appended or modified.

Can be override if you need a more complex form or add elements with "set_order" before calling this function. This function does not add the form , only the table.

It returns true , if it is not readyonly and the form will have a "save" button, if it returns nothing or false then there is no save button, nor form, the content is then readonly

See also
get_error , set_error

Reimplemented from Manage_Table_SQL.

Definition at line 159 of file forecast_item_mtable.class.php.

160 {
161 $object=$this->get_table();
162 if ( $this->count_category() == 0 ) {
163 echo span(_("Sans catégorie il n'est pas possible d'ajouter de nouveaux éléments"),'class="notice"');
164 return false;
165 }
166
167 require_once NOALYSS_TEMPLATE."/forecast_item_mtable-input.php";
168 return true;
169 }
span($p_string, $p_extra='')
Definition: ac_common.php:43

References $object, count_category(), Manage_Table_SQL\get_table(), and span().

+ Here is the call graph for this function:

◆ set_forecast_id()

Forecast_Item_MTable::set_forecast_id ( int  $forecast_id)
Parameters
int$forecast_id

Definition at line 80 of file forecast_item_mtable.class.php.

81 {
82 $this->forecast_id = $forecast_id;
83 $this->add_json_param("forecast_id", $forecast_id);
84 }
add_json_param($p_attribute, $p_value)
Add json parameter to the current one.

References $forecast_id, and Manage_Table_SQL\add_json_param().

Referenced by from_request().

+ Here is the call graph for this function:

Field Documentation

◆ $forecast_id

Forecast_Item_MTable::$forecast_id
private

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

Referenced by build(), get_forecast_id(), and set_forecast_id().


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