X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=inline;f=includes%2Fui%2Fsimple_crud_class.inc;h=40c8ebea6b29b5653b2a746284015329473dee33;hb=4d12907d400d8b7a9a5150b260a30c19a53d1010;hp=2f0d76711a63253d2d8e28ba8b7d570fe35e1c30;hpb=3665b8d9d8899fbbfa17932423c8d98c8dec8d85;p=fa-stable.git diff --git a/includes/ui/simple_crud_class.inc b/includes/ui/simple_crud_class.inc index 2f0d7671..40c8ebea 100644 --- a/includes/ui/simple_crud_class.inc +++ b/includes/ui/simple_crud_class.inc @@ -19,14 +19,14 @@ class simple_crud { var $_none = ''; // selector value when no item is selected var $pre_handlers; // control buttons and related methods called before view display var $views; - var $data; + var $data = array(); var $fields; var $tool_buttons; var $options; var $dec; // // - function simple_crud($name, $fields = null) + function __construct($name, $fields = null) { $this->name = $name; $this->pre_handlers = array( @@ -106,8 +106,6 @@ class simple_crud { { global $Ajax; - $sel_name = $this->name.'_id'; - // list controls lookup foreach (array_keys($this->pre_handlers) as $m) { if (isset($_POST[$this->name.$m])) { @@ -118,7 +116,13 @@ class simple_crud { return $m; } } - return get_post($this->name.'Mode', ''); + $mod = get_post($this->name.'Mode', ''); + if ($mod) { + $val = @key($mod); + $this->selected_id = $val!==null ? @quoted_printable_decode($val) : $this->_none; + return $mod[$val]; + } + return ''; } // @@ -137,25 +141,30 @@ class simple_crud { // // Update record after edition // - function _update() + function _update($mode) { $this->get_posts(); if ($this->update_check()) { - if ($this->db_update()) + if ($this->db_update()) { $this->selected_id = $this->_none; $this->Mode = ''; + return; + } } + $this->Mode = $mode; } // // Add new record // - function _add() + function _add($mode) { $this->get_posts(); if ($this->insert_check()) { $this->db_insert(); $this->_cancel(); + return; } + $this->Mode = $mode; } // // Delete selected record @@ -200,9 +209,9 @@ class simple_crud { if ($async === 'both') { $async = 'default'; $cancel = 'cancel'; } - else if ($async === 'default') + elseif ($async === 'default') $cancel = true; - else if ($async === 'cancel') + elseif ($async === 'cancel') $async = true; echo "