diff --git a/application/controllers/Giftcards.php b/application/controllers/Giftcards.php
index 6f6b406d4..1d9d314f8 100644
--- a/application/controllers/Giftcards.php
+++ b/application/controllers/Giftcards.php
@@ -11,11 +11,10 @@ class Giftcards extends Secure_area implements iData_controller
function index($limit_from=0)
{
+
$data['controller_name'] = $this->get_controller_name();
- $lines_per_page = $this->Appconfig->get('lines_per_page');
- $giftcards = $this->Giftcard->get_all($lines_per_page, $limit_from);
- $data['links'] = $this->_initialize_pagination($this->Giftcard, $lines_per_page, $limit_from);
- $data['manage_table'] = get_giftcards_manage_table($giftcards, $this);
+ $data['table_headers'] = get_giftcards_manage_table_headers();
+
$this->load->view('giftcards/manage', $data);
}
@@ -24,16 +23,21 @@ class Giftcards extends Secure_area implements iData_controller
*/
function search()
{
- $search = $this->input->post('search') != '' ? $this->input->post('search') : null;
- $limit_from = $this->input->post('limit_from');
+ $search = $this->input->get('search');
+ $limit = $this->input->get('limit');
+ $offset = $this->input->get('offset');
$lines_per_page = $this->Appconfig->get('lines_per_page');
- $giftcards = $this->Giftcard->search($search, $lines_per_page, $limit_from);
+ $giftcards = $this->Giftcard->search($search, $offset, $limit);
$total_rows = $this->Giftcard->get_found_rows($search);
- $links = $this->_initialize_pagination($this->Giftcard, $lines_per_page, $limit_from, $total_rows);
- $data_rows = get_giftcards_manage_table_data_rows($giftcards, $this);
- echo json_encode(array('total_rows' => $total_rows, 'rows' => $data_rows, 'pagination' => $links));
+ $links = $this->_initialize_pagination($this->Giftcard, $lines_per_page, $limit, $total_rows);
+ $data_rows = array();
+ foreach($giftcards->result() as $giftcard)
+ {
+ $data_rows[] = get_giftcard_data_row($giftcard, $this);
+ }
+ echo json_encode(array('total' => $total_rows, 'rows' => $data_rows));
}
/*
@@ -45,11 +49,10 @@ class Giftcards extends Secure_area implements iData_controller
echo json_encode($suggestions);
}
- function get_row()
+ function get_row($row_id)
{
- $giftcard_id = $this->input->post('row_id');
- $data_row = get_giftcard_data_row($this->Giftcard->get_info($giftcard_id), $this);
- echo $data_row;
+ $data_row = get_giftcard_data_row($this->Giftcard->get_info($row_id), $this);
+ echo json_encode($data_row);
}
function view($giftcard_id=-1)
@@ -78,19 +81,19 @@ class Giftcards extends Secure_area implements iData_controller
if($giftcard_id==-1)
{
echo json_encode(array('success'=>true, 'message'=>$this->lang->line('giftcards_successful_adding').' '.
- $giftcard_data['giftcard_number'], 'giftcard_id'=>$giftcard_data['giftcard_id']));
+ $giftcard_data['giftcard_number'], 'id'=>$giftcard_data['giftcard_id']));
$giftcard_id = $giftcard_data['giftcard_id'];
}
else //previous giftcard
{
echo json_encode(array('success'=>true, 'message'=>$this->lang->line('giftcards_successful_updating').' '.
- $giftcard_data['giftcard_number'], 'giftcard_id'=>$giftcard_id));
+ $giftcard_data['giftcard_number'], 'id'=>$giftcard_id));
}
}
else//failure
{
echo json_encode(array('success'=>false,'message'=>$this->lang->line('giftcards_error_adding_updating').' '.
- $giftcard_data['giftcard_number'], 'giftcard_id'=>-1));
+ $giftcard_data['giftcard_number'], 'id'=>-1));
}
}
diff --git a/application/helpers/table_helper.php b/application/helpers/table_helper.php
index c140b84da..59ac9dde2 100644
--- a/application/helpers/table_helper.php
+++ b/application/helpers/table_helper.php
@@ -333,69 +333,36 @@ function get_item_data_row($item,$controller)
return $table_data_row;
}
-/*
-Gets the html table to manage giftcards.
-*/
-function get_giftcards_manage_table( $giftcards, $controller )
+function get_giftcards_manage_table_headers()
{
$CI =& get_instance();
- $table='
';
- return $table;
+ $headers = array(
+ array('checkbox' => 'select'),
+ array('id' => $CI->lang->line('common_id')),
+ array('last_name' => $CI->lang->line('common_last_name')),
+ array('first_name' => $CI->lang->line('common_first_name')),
+ array('giftcard_number' => $CI->lang->line('giftcards_giftcard_number')),
+ array('giftcard_value' => $CI->lang->line('giftcards_card_value')),
+ array('edit' => '')
+ );
+
+ return transform_headers($headers);
}
-/*
-Gets the html data rows for the giftcard.
-*/
-function get_giftcards_manage_table_data_rows( $giftcards, $controller )
-{
- $CI =& get_instance();
- $table_data_rows='';
-
- foreach($giftcards->result() as $giftcard)
- {
- $table_data_rows.=get_giftcard_data_row( $giftcard, $controller );
- }
-
- if($giftcards->num_rows()==0)
- {
- $table_data_rows.="".$CI->lang->line('giftcards_no_giftcards_to_display')." |
";
- }
-
- return $table_data_rows;
-}
-
-function get_giftcard_data_row($giftcard,$controller)
-{
+function get_giftcard_data_row($giftcard, $controller) {
$CI =& get_instance();
$controller_name=strtolower(get_class($CI));
- $table_data_row='';
- $table_data_row.=" | ";
- $table_data_row.=''.$giftcard->last_name.' | ';
- $table_data_row.=''.$giftcard->first_name.' | ';
- $table_data_row.=''.$giftcard->giftcard_number.' | ';
- $table_data_row.=''.to_currency($giftcard->value).' | ';
- $table_data_row.=''.anchor($controller_name."/view/$giftcard->giftcard_id", '', array('class'=>"modal-dlg modal-btn-submit",'title'=>$CI->lang->line($controller_name.'_update'))).' | ';
- $table_data_row.='
';
-
- return $table_data_row;
+ return array (
+ 'id' => $giftcard->giftcard_id,
+ 'last_name' => character_limiter($giftcard->last_name,13),
+ 'first_name' => character_limiter($giftcard->first_name,13),
+ 'giftcard_number' => $giftcard->giftcard_number,
+ 'giftcard_value' => to_currency($giftcard->value),
+ 'edit' => anchor($controller_name."/view/$giftcard->giftcard_id", '',
+ array('class'=>"modal-dlg modal-btn-submit", 'title'=>$CI->lang->line($controller_name.'_update'))
+ ));
}
/*
diff --git a/application/models/Giftcard.php b/application/models/Giftcard.php
index 2706bf41a..dd9a923e4 100644
--- a/application/models/Giftcard.php
+++ b/application/models/Giftcard.php
@@ -217,8 +217,8 @@ class Giftcard extends CI_Model
{
$this->db->from('giftcards');
$this->db->join('people', 'giftcards.person_id=people.person_id', 'left');
- $this->db->like('first_name', $this->db->escape_like_str($search));
$this->db->or_group_start();
+ $this->db->like('first_name', $this->db->escape_like_str($search));
$this->db->or_like('last_name', $this->db->escape_like_str($search));
$this->db->or_like('CONCAT(first_name, " ", last_name)', $this->db->escape_like_str($search));
$this->db->or_like('giftcard_number', $this->db->escape_like_str($search));
@@ -239,8 +239,8 @@ class Giftcard extends CI_Model
{
$this->db->from('giftcards');
$this->db->join('people', 'giftcards.person_id=people.person_id', 'left');
- $this->db->like('first_name', $this->db->escape_like_str($search));
$this->db->or_group_start();
+ $this->db->like('first_name', $this->db->escape_like_str($search));
$this->db->or_like('last_name', $this->db->escape_like_str($search));
$this->db->or_like('CONCAT(first_name, " ", last_name)', $this->db->escape_like_str($search));
$this->db->or_like('giftcard_number', $this->db->escape_like_str($search));
diff --git a/application/views/giftcards/form.php b/application/views/giftcards/form.php
index 3d408ad87..2c7271a06 100644
--- a/application/views/giftcards/form.php
+++ b/application/views/giftcards/form.php
@@ -80,11 +80,11 @@ $(document).ready(function()
success:function(response)
{
dialog_support.hide();
- post_giftcard_form_submit(response);
+ table_support.handle_submit('', response);
},
error: function(jqXHR, textStatus, errorThrown)
{
- post_giftcard_form_submit({message: errorThrown});
+ table_support.handle_submit('', {message: errorThrown});
},
dataType:'json'
});
diff --git a/application/views/giftcards/manage.php b/application/views/giftcards/manage.php
index dd2d31735..6e35f20ac 100644
--- a/application/views/giftcards/manage.php
+++ b/application/views/giftcards/manage.php
@@ -2,85 +2,27 @@
-
-
-
- " . $this->lang->line($controller_name . '_new') . "
",
- array('class'=>'modal-dlg modal-btn-submit', 'title'=>$this->lang->line($controller_name.'_new'))); ?>
+
+
-'search_form', 'class'=>'form-horizontal')); ?>
-
-
+
load->view("partial/footer"); ?>
\ No newline at end of file