diff --git a/application/controllers/Suppliers.php b/application/controllers/Suppliers.php
index 7553a1349..5797e20bd 100644
--- a/application/controllers/Suppliers.php
+++ b/application/controllers/Suppliers.php
@@ -10,12 +10,9 @@ class Suppliers extends Person_controller
function index($limit_from=0)
{
$data['controller_name'] = $this->get_controller_name();
- $lines_per_page = $this->Appconfig->get('lines_per_page');
- $suppliers = $this->Supplier->get_all($lines_per_page);
-
- $data['links'] = $this->_initialize_pagination($this->Supplier, $lines_per_page, $limit_from);
- $data['manage_table'] = get_supplier_manage_table($suppliers, $this);
- $this->load->view('suppliers/manage', $data);
+ $data['table_headers'] = get_suppliers_manage_table_headers();
+
+ $this->load->view('people/manage', $data);
}
/*
@@ -23,16 +20,20 @@ class Suppliers extends Person_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');
- $suppliers = $this->Supplier->search($search, $lines_per_page, $limit_from);
+ $suppliers = $this->Supplier->search($search, $offset, $limit);
$total_rows = $this->Supplier->get_found_rows($search);
- $links = $this->_initialize_pagination($this->Supplier, $lines_per_page, $limit_from, $total_rows);
- $data_rows = get_supplier_manage_table_data_rows($suppliers, $this);
-
- echo json_encode(array('total_rows' => $total_rows, 'rows' => $data_rows, 'pagination' => $links));
+ $links = $this->_initialize_pagination($this->Employee, $lines_per_page, $limit, $total_rows);
+ $data_rows = array();
+ foreach($suppliers->result() as $supplier)
+ {
+ $data_rows[] = get_supplier_data_row($supplier, $this);
+ }
+ echo json_encode(array('total' => $total_rows, 'rows' => $data_rows));
}
/*
@@ -89,18 +90,18 @@ class Suppliers extends Person_controller
if($supplier_id==-1)
{
echo json_encode(array('success'=>true,'message'=>$this->lang->line('suppliers_successful_adding').' '.
- $supplier_data['company_name'],'person_id'=>$supplier_data['person_id']));
+ $supplier_data['company_name'],'id'=>$supplier_data['person_id']));
}
else //previous supplier
{
echo json_encode(array('success'=>true,'message'=>$this->lang->line('suppliers_successful_updating').' '.
- $supplier_data['company_name'],'person_id'=>$supplier_id));
+ $supplier_data['company_name'],'id'=>$supplier_id));
}
}
else//failure
{
echo json_encode(array('success'=>false,'message'=>$this->lang->line('suppliers_error_adding_updating').' '.
- $supplier_data['company_name'],'person_id'=>-1));
+ $supplier_data['company_name'],'id'=>-1));
}
}
@@ -122,14 +123,5 @@ class Suppliers extends Person_controller
}
}
- /*
- Gets one row for a supplier manage table. This is called using AJAX to update one row.
- */
- function get_row()
- {
- $person_id = $this->input->post('row_id');
- $data_row=get_supplier_data_row($this->Supplier->get_info($person_id),$this);
- echo $data_row;
- }
}
?>
\ No newline at end of file
diff --git a/application/helpers/table_helper.php b/application/helpers/table_helper.php
index c0c303d72..c140b84da 100644
--- a/application/helpers/table_helper.php
+++ b/application/helpers/table_helper.php
@@ -143,9 +143,6 @@ function transform_headers($array)
}, $array));
}
-/*
-Gets the html table to manage people.
-*/
function get_people_manage_table_headers()
{
$CI =& get_instance();
@@ -195,87 +192,46 @@ function get_detailed_data_row($row, $controller)
return $table_data_row;
}
-/*
-Gets the html table to manage suppliers.
-*/
-function get_supplier_manage_table($suppliers,$controller)
-{
- $CI =& get_instance();
- $table='
';
-
- $headers = array('',
- $CI->lang->line('suppliers_company_name'),
- $CI->lang->line('suppliers_agency_name'),
- $CI->lang->line('common_last_name'),
- $CI->lang->line('common_first_name'),
- $CI->lang->line('common_email'),
- $CI->lang->line('common_phone_number'),
- $CI->lang->line('common_id'),
- ' ');
+function get_suppliers_manage_table_headers()
if($CI->Employee->has_grant('messages', $CI->session->userdata('person_id')))
{
$headers[] = ' ';
}
-
- $table.='';
- foreach($headers as $header)
- {
- $table.="| $header | ";
- }
- $table.='
';
- $table.=get_supplier_manage_table_data_rows($suppliers,$controller);
- $table.='
';
-
- return $table;
-}
-
-/*
-Gets the html data rows for the supplier.
-*/
-function get_supplier_manage_table_data_rows($suppliers,$controller)
{
$CI =& get_instance();
- $table_data_rows='';
-
- foreach($suppliers->result() as $supplier)
- {
- $table_data_rows.=get_supplier_data_row($supplier,$controller);
- }
-
- if($suppliers->num_rows()==0)
- {
- $table_data_rows.="".$CI->lang->line('common_no_persons_to_display')." |
";
- }
-
- return $table_data_rows;
+
+ $headers = array(
+ array('checkbox' => 'select'),
+ array('id' => $CI->lang->line('common_id')),
+ array('company_name' => $CI->lang->line('suppliers_company_name')),
+ array('agency_name' => $CI->lang->line('suppliers_agency_name')),
+ array('last_name' => $CI->lang->line('common_last_name')),
+ array('first_name' => $CI->lang->line('common_first_name')),
+ array('email' => $CI->lang->line('common_email')),
+ array('phone_number' => $CI->lang->line('common_phone_number')),
+ array('edit' => '')
+ );
+
+ return transform_headers($headers);
}
-function get_supplier_data_row($supplier,$controller)
-{
+function get_supplier_data_row($supplier, $controller) {
$CI =& get_instance();
$controller_name=strtolower(get_class($CI));
- $table_data_row='';
- $table_data_row.=" | ";
- $table_data_row.=''.character_limiter($supplier->company_name,13).' | ';
- $table_data_row.=''.character_limiter($supplier->agency_name,13).' | ';
- $table_data_row.=''.character_limiter($supplier->last_name,13).' | ';
- $table_data_row.=''.character_limiter($supplier->first_name,13).' | ';
- $table_data_row.=''.mailto($supplier->email,character_limiter($supplier->email,22)).' | ';
- $table_data_row.=''.character_limiter($supplier->phone_number,13).' | ';
- $table_data_row.=''.character_limiter($supplier->person_id,5).' | ';
- if($CI->Employee->has_grant('messages', $CI->session->userdata('person_id')))
- {
- $table_data_row.=''.anchor("Messages/view/$supplier->person_id", '', array('class'=>"modal-dlg modal-btn-submit", 'title'=>$CI->lang->line('messages_sms_send'))).' | ';
- $table_data_row.=''.anchor($controller_name."/view/$supplier->person_id", '', array('class'=>"modal-dlg modal-btn-submit",'title'=>$CI->lang->line($controller_name.'_update'))).' | ';
- }
- else
- {
- $table_data_row.=''.anchor($controller_name."/view/$supplier->person_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' => $supplier->person_id,
+ 'company_name' => character_limiter($supplier->company_name,13),
+ 'agency_name' => character_limiter($supplier->agency_name,13),
+ 'last_name' => character_limiter($supplier->last_name,13),
+ 'first_name' => character_limiter($supplier->first_name,13),
+ 'email' => empty($supplier->email) ? '' : mailto($supplier->email,character_limiter($supplier->email,22)),
+ 'phone_number' => character_limiter($supplier->phone_number,13),
+ 'messages' => anchor("Messages/view/$supplier->person_id", '',
+ array('class'=>"modal-dlg modal-btn-submit", 'title'=>$CI->lang->line('messages_sms_send'))),
+ 'edit' => anchor($controller_name."/view/$supplier->person_id", '',
+ array('class'=>"modal-dlg modal-btn-submit", 'title'=>$CI->lang->line($controller_name.'_update'))
+ ));
}
/*
diff --git a/application/views/people/manage.php b/application/views/people/manage.php
index 261872f16..9e10c5fdd 100644
--- a/application/views/people/manage.php
+++ b/application/views/people/manage.php
@@ -3,10 +3,8 @@
@@ -20,22 +18,13 @@ $(document).ready(function()
title='lang->line('customers_import_items_excel'); ?>'>
lang->line('common_import_excel'); ?>
+
-
-
-
-
-'search_form', 'class'=>'form-horizontal')); ?>
-
-
-
-
-
-
-
-load->view("partial/footer"); ?>
\ No newline at end of file