mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-03 05:12:50 -04:00
Add Supplier Category (#2088)
This commit is contained in:
@@ -43,7 +43,9 @@ class Suppliers extends Persons
|
||||
$data_rows = array();
|
||||
foreach($suppliers->result() as $supplier)
|
||||
{
|
||||
$data_rows[] = $this->xss_clean(get_supplier_data_row($supplier));
|
||||
$row = $this->xss_clean(get_supplier_data_row($supplier));
|
||||
$row['category'] = $this->Supplier->get_category_name($row['category']);
|
||||
$data_rows[] = $row;
|
||||
}
|
||||
|
||||
echo json_encode(array('total' => $total_rows, 'rows' => $data_rows));
|
||||
@@ -77,6 +79,7 @@ class Suppliers extends Persons
|
||||
$info->$property = $this->xss_clean($value);
|
||||
}
|
||||
$data['person_info'] = $info;
|
||||
$data['categories'] = $this->Supplier->get_categories();
|
||||
|
||||
$this->load->view("suppliers/form", $data);
|
||||
}
|
||||
@@ -112,6 +115,7 @@ class Suppliers extends Persons
|
||||
$supplier_data = array(
|
||||
'company_name' => $this->input->post('company_name'),
|
||||
'agency_name' => $this->input->post('agency_name'),
|
||||
'category' => $this->input->post('category'),
|
||||
'account_number' => $this->input->post('account_number') == '' ? NULL : $this->input->post('account_number')
|
||||
);
|
||||
|
||||
|
||||
@@ -274,6 +274,7 @@ function get_suppliers_manage_table_headers()
|
||||
array('people.person_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('category' => $CI->lang->line('suppliers_category')),
|
||||
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')),
|
||||
@@ -300,6 +301,7 @@ function get_supplier_data_row($supplier)
|
||||
'people.person_id' => $supplier->person_id,
|
||||
'company_name' => $supplier->company_name,
|
||||
'agency_name' => $supplier->agency_name,
|
||||
'category' => $supplier->category,
|
||||
'last_name' => $supplier->last_name,
|
||||
'first_name' => $supplier->first_name,
|
||||
'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
|
||||
|
||||
@@ -3,11 +3,14 @@
|
||||
$lang["suppliers_account_number"] = "Account #";
|
||||
$lang["suppliers_agency_name"] = "Agency Name";
|
||||
$lang["suppliers_cannot_be_deleted"] = "Could not delete the selected Supplier(s). One or more have Sales";
|
||||
$lang["suppliers_category"] = "Category";
|
||||
$lang["suppliers_cost"] = "Cost Supplier";
|
||||
$lang["suppliers_company_name"] = "Company Name";
|
||||
$lang["suppliers_company_name_required"] = "Company Name is a required field";
|
||||
$lang["suppliers_confirm_delete"] = "Are you sure you want to delete the selected Supplier(s)?";
|
||||
$lang["suppliers_confirm_restore"] = "Are you sure you want to restore the selected Supplier(s)?";
|
||||
$lang["suppliers_error_adding_updating"] = "Supplier update or add failed";
|
||||
$lang["suppliers_goods"] = "Goods Supplier";
|
||||
$lang["suppliers_new"] = "New Supplier";
|
||||
$lang["suppliers_none_selected"] = "You have not selected any Supplier(s) to delete";
|
||||
$lang["suppliers_one_or_multiple"] = "Supplier(s)";
|
||||
|
||||
@@ -3,11 +3,14 @@
|
||||
$lang["suppliers_account_number"] = "Account Number";
|
||||
$lang["suppliers_agency_name"] = "Agency Name";
|
||||
$lang["suppliers_cannot_be_deleted"] = "Could not delete selected Supplier(s). One or more have Sales.";
|
||||
$lang["suppliers_category"] = "Category";
|
||||
$lang["suppliers_cost"] = "Cost Supplier";
|
||||
$lang["suppliers_company_name"] = "Company Name";
|
||||
$lang["suppliers_company_name_required"] = "Company Name is a required field.";
|
||||
$lang["suppliers_confirm_delete"] = "Are you sure you want to delete the selected Supplier(s)?";
|
||||
$lang["suppliers_confirm_restore"] = "Are you sure you want to restore selected Supplier(s)?";
|
||||
$lang["suppliers_error_adding_updating"] = "Supplier update or add failed.";
|
||||
$lang["suppliers_goods"] = "Goods Supplier";
|
||||
$lang["suppliers_new"] = "New Supplier";
|
||||
$lang["suppliers_none_selected"] = "You have not selected Supplier(s) to delete.";
|
||||
$lang["suppliers_one_or_multiple"] = "Supplier(s)";
|
||||
|
||||
@@ -37,7 +37,6 @@ ALTER TABLE `ospos_receivings_items`
|
||||
CHANGE COLUMN `discount_percent` `discount` DECIMAL(15,2) NOT NULL DEFAULT 0 AFTER `item_unit_price`,
|
||||
ADD COLUMN `discount_type` TINYINT(2) NOT NULL DEFAULT '0' AFTER `discount`;
|
||||
|
||||
|
||||
--
|
||||
-- Add support for module cashups
|
||||
--
|
||||
@@ -102,3 +101,13 @@ ALTER TABLE ospos_expenses CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci
|
||||
|
||||
ALTER TABLE `ospos_cash_up`
|
||||
ADD `closed_amount_due` decimal(15,2) NOT NULL;
|
||||
|
||||
--
|
||||
-- Add Suppliers category
|
||||
--
|
||||
|
||||
ALTER TABLE `ospos_suppliers`
|
||||
ADD COLUMN `category` TINYINT NOT NULL;
|
||||
|
||||
UPDATE `ospos_suppliers`
|
||||
SET `category` = 0;
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
*/
|
||||
|
||||
class Supplier extends Person
|
||||
{
|
||||
{
|
||||
const GOODS_SUPPLIER = 0;
|
||||
const COST_SUPPLIER = 1;
|
||||
|
||||
/*
|
||||
Determines if a given person_id is a customer
|
||||
*/
|
||||
@@ -32,10 +35,11 @@ class Supplier extends Person
|
||||
/*
|
||||
Returns all the suppliers
|
||||
*/
|
||||
public function get_all($limit_from = 0, $rows = 0)
|
||||
public function get_all($category = self::GOODS_SUPPLIER, $limit_from = 0, $rows = 0)
|
||||
{
|
||||
$this->db->from('suppliers');
|
||||
$this->db->join('people', 'suppliers.person_id = people.person_id');
|
||||
$this->db->join('people', 'suppliers.person_id = people.person_id');
|
||||
$this->db->where('category', $category);
|
||||
$this->db->where('deleted', 0);
|
||||
$this->db->order_by('company_name', 'asc');
|
||||
if($rows > 0)
|
||||
@@ -273,5 +277,31 @@ class Supplier extends Person
|
||||
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
/*
|
||||
Return supplier categories
|
||||
*/
|
||||
public function get_categories()
|
||||
{
|
||||
return array(
|
||||
self::GOODS_SUPPLIER => $this->lang->line('suppliers_goods'),
|
||||
self::COST_SUPPLIER => $this->lang->line('suppliers_cost')
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
Return a category name given its id
|
||||
*/
|
||||
public function get_category_name($id)
|
||||
{
|
||||
if($id == self::GOODS_SUPPLIER)
|
||||
{
|
||||
return $this->lang->line('suppliers_goods');
|
||||
}
|
||||
elseif($id == self::COST_SUPPLIER)
|
||||
{
|
||||
return $this->lang->line('suppliers_cost');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -16,6 +16,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('suppliers_category'), 'category', array('class'=>'required control-label col-xs-3')); ?>
|
||||
<div class='col-xs-6'>
|
||||
<?php echo form_dropdown('category', $categories, $person_info->category, array('class'=>'form-control', 'id'=>'category'));?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('suppliers_agency_name'), 'agency_name', array('class'=>'control-label col-xs-3')); ?>
|
||||
<div class='col-xs-8'>
|
||||
|
||||
Reference in New Issue
Block a user