Files
opensourcepos/application/controllers/suppliers.php
jekkos-t520 6c8cea9846 Merge branch 'master' of https://github.com/pappastech/ospos into ospos
Fixed customer + supplier search box width + spinner position under linux
Fonts set to relative browser size
Dutch language files updated (missing labels added)

Conflicts:
	WHATS_NEW.txt
	application/config/autoload.php
	application/config/config.php
	application/config/migration.php
	application/config/routes.php
	application/controllers/giftcards.php
	application/controllers/items.php
	application/controllers/person_controller.php
	application/controllers/receivings.php
	application/controllers/reports.php
	application/controllers/sales.php
	application/controllers/suppliers.php
	application/helpers/table_helper.php
	application/hooks/load_config.php
	application/language/english/common_lang.php
	application/language/english/config_lang.php
	application/language/english/customers_lang.php
	application/language/english/employees_lang.php
	application/language/english/error_lang.php
	application/language/english/giftcards_lang.php
	application/language/english/index.html
	application/language/english/items_lang.php
	application/language/english/login_lang.php
	application/language/english/module_lang.php
	application/language/english/receivings_lang.php
	application/language/english/reports_lang.php
	application/language/english/sales_lang.php
	application/language/english/suppliers_lang.php
	application/libraries/Receiving_lib.php
	application/libraries/ofc-library/JSON.php
	application/libraries/ofc-library/README.txt
	application/libraries/ofc-library/dot_base.php
	application/libraries/ofc-library/json_format.php
	application/libraries/ofc-library/ofc_area_base.php
	application/libraries/ofc-library/ofc_area_hollow.php
	application/libraries/ofc-library/ofc_area_line.php
	application/libraries/ofc-library/ofc_arrow.php
	application/libraries/ofc-library/ofc_bar.php
	application/libraries/ofc-library/ofc_bar_3d.php
	application/libraries/ofc-library/ofc_bar_base.php
	application/libraries/ofc-library/ofc_bar_filled.php
	application/libraries/ofc-library/ofc_bar_glass.php
	application/libraries/ofc-library/ofc_bar_sketch.php
	application/libraries/ofc-library/ofc_bar_stack.php
	application/libraries/ofc-library/ofc_candle.php
	application/libraries/ofc-library/ofc_hbar.php
	application/libraries/ofc-library/ofc_line.php
	application/libraries/ofc-library/ofc_line_base.php
	application/libraries/ofc-library/ofc_line_dot.php
	application/libraries/ofc-library/ofc_line_hollow.php
	application/libraries/ofc-library/ofc_line_style.php
	application/libraries/ofc-library/ofc_menu.php
	application/libraries/ofc-library/ofc_pie.php
	application/libraries/ofc-library/ofc_radar_axis.php
	application/libraries/ofc-library/ofc_radar_axis_labels.php
	application/libraries/ofc-library/ofc_radar_spoke_labels.php
	application/libraries/ofc-library/ofc_scatter.php
	application/libraries/ofc-library/ofc_scatter_line.php
	application/libraries/ofc-library/ofc_shape.php
	application/libraries/ofc-library/ofc_sugar.php
	application/libraries/ofc-library/ofc_tags.php
	application/libraries/ofc-library/ofc_title.php
	application/libraries/ofc-library/ofc_tooltip.php
	application/libraries/ofc-library/ofc_x_axis.php
	application/libraries/ofc-library/ofc_x_axis_label.php
	application/libraries/ofc-library/ofc_x_axis_labels.php
	application/libraries/ofc-library/ofc_x_legend.php
	application/libraries/ofc-library/ofc_y_axis.php
	application/libraries/ofc-library/ofc_y_axis_base.php
	application/libraries/ofc-library/ofc_y_axis_label.php
	application/libraries/ofc-library/ofc_y_axis_labels.php
	application/libraries/ofc-library/ofc_y_axis_right.php
	application/libraries/ofc-library/ofc_y_legend.php
	application/libraries/ofc-library/open-flash-chart-object.php
	application/libraries/ofc-library/open-flash-chart.php
	application/models/giftcard.php
	application/models/item.php
	application/models/person.php
	application/models/receiving.php
	application/models/sale.php
	application/models/supplier.php
	application/views/config.php
	application/views/items/form.php
	application/views/items/form_bulk.php
	application/views/items/manage.php
	application/views/receivings/receiving.php
	application/views/reports/date_input.php
	application/views/reports/listing.php
	application/views/reports/tabular_details.php
	application/views/sales/edit.php
	application/views/sales/register.php
	application/views/suppliers/form.php
	css/reports.css
	css/tables.css
	database/database.sql
	import_items.csv
	index.php
	js/jquery.ajax_queue.js
	js/jquery.metadata.js
	license/license.txt
2014-03-03 22:19:14 +01:00

131 lines
3.8 KiB
PHP

<?php
require_once ("person_controller.php");
class Suppliers extends Person_controller
{
function __construct()
{
parent::__construct('suppliers');
}
function index()
{
$config['base_url'] = site_url('/suppliers/index');
$config['total_rows'] = $this->Supplier->count_all();
$config['per_page'] = '20';
$config['uri_segment'] = 3;
$this->pagination->initialize($config);
$data['controller_name']=strtolower(get_class());
$data['form_width']=$this->get_form_width();
$data['manage_table']=get_supplier_manage_table( $this->Supplier->get_all( $config['per_page'], $this->uri->segment( $config['uri_segment'] ) ), $this );
$this->load->view('suppliers/manage',$data);
}
/*
Returns supplier table data rows. This will be called with AJAX.
*/
function search()
{
$search=$this->input->post('search');
$data_rows=get_supplier_manage_table_data_rows($this->Supplier->search($search),$this);
echo $data_rows;
}
/*
Gives search suggestions based on what is being searched for
*/
function suggest()
{
$suggestions = $this->Supplier->get_search_suggestions($this->input->post('q'),$this->input->post('limit'));
echo implode("\n",$suggestions);
}
/*
Loads the supplier edit form
*/
function view($supplier_id=-1)
{
$data['person_info']=$this->Supplier->get_info($supplier_id);
$this->load->view("suppliers/form",$data);
}
/*
Inserts/updates a supplier
*/
function save($supplier_id=-1)
{
$person_data = array(
'first_name'=>$this->input->post('first_name'),
'last_name'=>$this->input->post('last_name'),
'email'=>$this->input->post('email'),
'phone_number'=>$this->input->post('phone_number'),
'address_1'=>$this->input->post('address_1'),
'address_2'=>$this->input->post('address_2'),
'city'=>$this->input->post('city'),
'state'=>$this->input->post('state'),
'zip'=>$this->input->post('zip'),
'country'=>$this->input->post('country'),
'comments'=>$this->input->post('comments')
);
$supplier_data=array(
'company_name'=>$this->input->post('company_name'),
'account_number'=>$this->input->post('account_number')=='' ? null:$this->input->post('account_number'),
);
if($this->Supplier->save($person_data,$supplier_data,$supplier_id))
{
//New supplier
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']));
}
else //previous supplier
{
echo json_encode(array('success'=>true,'message'=>$this->lang->line('suppliers_successful_updating').' '.
$supplier_data['company_name'],'person_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));
}
}
/*
This deletes suppliers from the suppliers table
*/
function delete()
{
$suppliers_to_delete=$this->input->post('ids');
if($this->Supplier->delete_list($suppliers_to_delete))
{
echo json_encode(array('success'=>true,'message'=>$this->lang->line('suppliers_successful_deleted').' '.
count($suppliers_to_delete).' '.$this->lang->line('suppliers_one_or_multiple')));
}
else
{
echo json_encode(array('success'=>false,'message'=>$this->lang->line('suppliers_cannot_be_deleted')));
}
}
/*
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;
}
/*
get the width for the add/edit form
*/
function get_form_width()
{
return 360;
}
}
?>