mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-12 09:45:12 -04:00
Requisition is now registered as receiving for destination stock and return for source stock
Remove specific requisition report and code Adapt receivings report to show requisitions in a generic way
This commit is contained in:
@@ -109,7 +109,7 @@ $autoload['language'] = array();
|
||||
|
|
||||
*/
|
||||
|
||||
$autoload['model'] = array('Appconfig','Person','Customer','Employee','Module','Item', 'Item_taxes', 'Sale', 'Sale_suspended', 'Supplier','Inventory','Receiving','Giftcard', 'Item_kit', 'Item_kit_items','Item_unit','Stock_locations','Item_quantities');
|
||||
$autoload['model'] = array('Appconfig','Person','Customer','Employee','Module','Item', 'Item_taxes', 'Sale', 'Sale_suspended', 'Supplier','Inventory','Receiving','Giftcard', 'Item_kit', 'Item_kit_items','Stock_locations','Item_quantities');
|
||||
|
||||
|
||||
/* End of file autoload.php */
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
|
||||
|
|
||||
*/
|
||||
$config['application_version'] = '2.2.1';
|
||||
$config['application_version'] = '2.3';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -51,8 +51,6 @@ $route['reports/(detailed_sales)/(:any)/(:any)'] = "reports/$1/$2/$3";
|
||||
$route['reports/detailed_sales'] = "reports/date_input";
|
||||
$route['reports/(detailed_receivings)/(:any)/(:any)'] = "reports/$1/$2/$3";
|
||||
$route['reports/detailed_receivings'] = "reports/date_input_recv";
|
||||
$route['reports/(detailed_requisition)/(:any)/(:any)'] = "reports/$1/$2/$3";
|
||||
$route['reports/detailed_requisition'] = "reports/date_input_reqs";
|
||||
$route['reports/(specific_:any)/(:any)/(:any)/(:any)'] = "reports/$1/$2/$3/$4";
|
||||
$route['reports/specific_customer'] = "reports/specific_customer_input";
|
||||
$route['reports/specific_employee'] = "reports/specific_employee_input";
|
||||
|
||||
@@ -69,18 +69,8 @@ class Receivings extends Secure_area
|
||||
}
|
||||
else
|
||||
{
|
||||
if($mode == 'requisition')
|
||||
{
|
||||
// FIXME need to review this part
|
||||
if(!$this->receiving_lib->add_item_unit($item_id_or_number_or_item_kit_or_receipt,$item_location))
|
||||
$data['error']=$this->lang->line('reqs_unable_to_add_item');
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$this->receiving_lib->add_item($item_id_or_number_or_item_kit_or_receipt,$quantity,$item_location))
|
||||
$data['error']=$this->lang->line('recvs_unable_to_add_item');
|
||||
}
|
||||
|
||||
if(!$this->receiving_lib->add_item($item_id_or_number_or_item_kit_or_receipt,$quantity,$item_location))
|
||||
$data['error']=$this->lang->line('recvs_unable_to_add_item');
|
||||
}
|
||||
$this->_reload($data);
|
||||
}
|
||||
@@ -185,52 +175,31 @@ class Receivings extends Secure_area
|
||||
|
||||
function requisition_complete()
|
||||
{
|
||||
$data['cart']=$this->receiving_lib->get_cart();
|
||||
$data['receipt_title']=$this->lang->line('reqs_receipt');
|
||||
$data['transaction_time']= date('m/d/Y h:i:s a');
|
||||
|
||||
$employee_id=$this->Employee->get_logged_in_employee_info()->person_id;
|
||||
$emp_info=$this->Employee->get_info($employee_id);
|
||||
$data['employee']=$emp_info->first_name.' '.$emp_info->last_name;
|
||||
|
||||
$comment = $this->input->post('comment');
|
||||
|
||||
//SAVE requisition to database
|
||||
$data['requisition_id']='REQS '.$this->Receiving->save_requisition($data['cart'],$employee_id,$comment);
|
||||
|
||||
if ($data['requisition_id'] == 'REQS -1')
|
||||
{
|
||||
$data['error_message'] = $this->lang->line('reqs_transaction_failed');
|
||||
}
|
||||
|
||||
$this->load->view("receivings/requisition_receipt",$data);
|
||||
$this->receiving_lib->clear_all();
|
||||
if ($this->receiving_lib->get_stock_source() != $this->receiving_lib->get_stock_destination())
|
||||
{
|
||||
foreach($this->receiving_lib->get_cart() as $item)
|
||||
{
|
||||
$this->receiving_lib->delete_item($item['line']);
|
||||
$this->receiving_lib->add_item($item['item_id'],$item['quantity'],$this->receiving_lib->get_stock_destination());
|
||||
$this->receiving_lib->add_item($item['item_id'],-$item['quantity'],$this->receiving_lib->get_stock_source());
|
||||
}
|
||||
|
||||
$this->complete();
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['error']=$this->lang->line('recvs_error_requisition');
|
||||
$this->_reload($data);
|
||||
}
|
||||
}
|
||||
|
||||
function requisition_receipt($requisition_id)
|
||||
{
|
||||
$requisition_info = $this->Receiving->get_requisition_info($requisition_id)->row_array();
|
||||
$this->receiving_lib->copy_entire_requisition($requisition_id);
|
||||
|
||||
$data['cart']=$this->receiving_lib->get_cart();
|
||||
$data['receipt_title']=$this->lang->line('reqs_receipt');
|
||||
$data['transaction_time']= date('m/d/Y h:i:s a');
|
||||
|
||||
$employee_id=$this->Employee->get_logged_in_employee_info()->person_id;
|
||||
$emp_info=$this->Employee->get_info($employee_id);
|
||||
$data['employee']=$emp_info->first_name.' '.$emp_info->last_name;
|
||||
|
||||
$data['requisition_id']='REQS '.$requisition_id;
|
||||
$this->load->view("receivings/requisition_receipt",$data);
|
||||
$this->receiving_lib->clear_all();
|
||||
}
|
||||
|
||||
function receipt($receiving_id)
|
||||
{
|
||||
$receiving_info = $this->Receiving->get_info($receiving_id)->row_array();
|
||||
$this->receiving_lib->copy_entire_receiving($receiving_id);
|
||||
$data['cart']=$this->receiving_lib->get_cart();
|
||||
$data['total']=$this->receiving_lib->get_total();
|
||||
$data['mode']=$this->receiving_lib->get_mode();
|
||||
$data['receipt_title']=$this->lang->line('recvs_receipt');
|
||||
$data['transaction_time']= date('m/d/Y h:i:s a', strtotime($receiving_info['receiving_time']));
|
||||
$supplier_id=$this->receiving_lib->get_supplier();
|
||||
|
||||
@@ -36,4 +36,5 @@ $lang['reqs_unable_to_add_item']='Unable to add item to requisition';
|
||||
$lang['recvs_stock_source']='Stock source';
|
||||
$lang['recvs_stock_destination']='Stock destination';
|
||||
$lang['recvs_stock_locaiton']='Stock location';
|
||||
$lang['recvs_error_requisition']='Unable to move inventory from and to the same stock location';
|
||||
?>
|
||||
|
||||
@@ -89,16 +89,7 @@ $lang['reports_all'] = 'All';
|
||||
$lang['reports_returns'] = 'Returns';
|
||||
$lang['reports_discount'] = 'Discounts';
|
||||
$lang['reports_sales'] = 'Sales';
|
||||
$lang['reports_requisition'] = 'Requisition';
|
||||
$lang['reports_requisitions'] = 'Requisitions';
|
||||
$lang['reports_receiving_id'] = 'Receiving ID';
|
||||
$lang['reports_requisition_id'] = 'Requisition ID';
|
||||
$lang['reports_requisition_by'] = 'Requisition by';
|
||||
$lang['reports_requisition_item'] = 'Name';
|
||||
$lang['reports_requisition_item_quantity'] = 'Requisition qty.';
|
||||
$lang['reports_requisition_related_item'] = 'Related item';
|
||||
$lang['reports_requisition_related_item_unit_quantity'] = 'Unit qty.';
|
||||
$lang['reports_requisition_related_item_total_quantity'] = 'Total qty.';
|
||||
$lang['reports_detailed_requisition_report'] = 'Detailed Requisitions Report';
|
||||
|
||||
$lang['reports_stock_location'] = 'Stock location';
|
||||
?>
|
||||
|
||||
@@ -79,11 +79,6 @@ class Receiving_lib
|
||||
$this->CI->session->set_userdata('recv_stock_destination',$stock_destination);
|
||||
}
|
||||
|
||||
function get_location_id_from_stock_location($location)
|
||||
{
|
||||
return substr($location, 6);
|
||||
}
|
||||
|
||||
function add_item($item_id,$quantity=1,$item_location,$discount=0,$price=null,$description=null,$serialnumber=null)
|
||||
{
|
||||
//make sure item exists in database.
|
||||
@@ -165,98 +160,6 @@ class Receiving_lib
|
||||
|
||||
}
|
||||
|
||||
function add_item_unit($item_id,$quantity=1, $description=null)
|
||||
{
|
||||
//make sure item exists in database.
|
||||
if(!$this->CI->Item->exists($item_id))
|
||||
{
|
||||
//try to get item id given an item_number
|
||||
$item_id = $this->CI->Item->get_item_id($item_id);
|
||||
|
||||
if(!$item_id)
|
||||
return false;
|
||||
}
|
||||
|
||||
$related_item_number = $this->CI->Item_unit->get_info($item_id)->related_number;
|
||||
if($related_item_number!= null && !$this->CI->Item->is_warehouse_item_exist($related_item_number))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Get items in the requisition so far.
|
||||
$items = $this->get_cart();
|
||||
|
||||
//We need to loop through all items in the cart.
|
||||
//If the item is already there, get it's key($updatekey).
|
||||
//We also need to get the next key that we are going to use in case we need to add the
|
||||
//item to the list. Since items can be deleted, we can't use a count. we use the highest key + 1.
|
||||
|
||||
$maxkey=0; //Highest key so far
|
||||
$itemalreadyinsale=FALSE; //We did not find the item yet.
|
||||
$insertkey=0; //Key to use for new entry.
|
||||
$updatekey=0; //Key to use to update(quantity)
|
||||
|
||||
foreach ($items as $item)
|
||||
{
|
||||
//We primed the loop so maxkey is 0 the first time.
|
||||
//Also, we have stored the key in the element itself so we can compare.
|
||||
//There is an array function to get the associated key for an element, but I like it better
|
||||
//like that!
|
||||
|
||||
if($maxkey <= $item['line'])
|
||||
{
|
||||
$maxkey = $item['line'];
|
||||
}
|
||||
|
||||
if($item['item_id']==$item_id)
|
||||
{
|
||||
$itemalreadyinsale=TRUE;
|
||||
$updatekey=$item['line'];
|
||||
}
|
||||
}
|
||||
|
||||
$insertkey=$maxkey+1;
|
||||
|
||||
|
||||
//array records are identified by $insertkey and item_id is just another field.
|
||||
$item = array(($insertkey)=>
|
||||
array(
|
||||
'item_id'=>$item_id,
|
||||
'line'=>$insertkey,
|
||||
'name'=>$this->CI->Item->get_info($item_id)->name,
|
||||
'description'=>$description!=null ? $description: $this->CI->Item->get_info($item_id)->description,
|
||||
'quantity'=>$quantity
|
||||
)
|
||||
);
|
||||
|
||||
$item[$insertkey]['unit_quantity']= $this->CI->Item_unit->get_info($item_id)->unit_quantity;
|
||||
$related_item_id = $this->CI->Item->get_item_id($related_item_number,'warehouse');
|
||||
if($related_item_id == null)
|
||||
{
|
||||
$related_item_id = $this->CI->Item->get_item_id($related_item_number,'sale_stock');
|
||||
if($related_item_id == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$item[$insertkey]['related_item'] = $this->CI->Item->get_info($related_item_id)->name;
|
||||
|
||||
//Item already exists
|
||||
if($itemalreadyinsale)
|
||||
{
|
||||
$items[$updatekey]['quantity']+=$quantity;
|
||||
}
|
||||
else
|
||||
{
|
||||
//add to existing array
|
||||
$items+=$item;
|
||||
}
|
||||
|
||||
$this->set_cart($items);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function edit_item($line,$description,$serialnumber,$quantity,$discount,$price)
|
||||
{
|
||||
$items = $this->get_cart();
|
||||
@@ -273,18 +176,6 @@ class Receiving_lib
|
||||
return false;
|
||||
}
|
||||
|
||||
function edit_item_unit($line,$description,$quantity,$unit_quantity,$related_item)
|
||||
{
|
||||
$items = $this->get_cart();
|
||||
if(isset($items[$line]))
|
||||
{
|
||||
$items[$line]['quantity'] = $quantity;
|
||||
$this->set_cart($items);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_valid_receipt($receipt_receiving_id)
|
||||
{
|
||||
//RECV #
|
||||
@@ -339,14 +230,14 @@ class Receiving_lib
|
||||
}
|
||||
}
|
||||
|
||||
function copy_entire_receiving($receiving_id,$item_location)
|
||||
function copy_entire_receiving($receiving_id)
|
||||
{
|
||||
$this->empty_cart();
|
||||
$this->delete_supplier();
|
||||
|
||||
foreach($this->CI->Receiving->get_receiving_items($receiving_id)->result() as $row)
|
||||
{
|
||||
$this->add_item($row->item_id,$row->quantity_purchased,$item_location,$row->discount_percent,$row->item_unit_price,$row->description,$row->serialnumber);
|
||||
$this->add_item($row->item_id,$row->quantity_purchased,$row->item_location,$row->discount_percent,$row->item_unit_price,$row->description,$row->serialnumber);
|
||||
}
|
||||
$this->set_supplier($this->CI->Receiving->get_supplier($receiving_id)->person_id);
|
||||
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
class Item_unit extends CI_Model
|
||||
{
|
||||
/*
|
||||
Gets item info for a particular item
|
||||
*/
|
||||
function get_info($item_id)
|
||||
{
|
||||
$this->db->from('item_unit');
|
||||
$this->db->where('item_id',$item_id);
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
if($query->num_rows()==1)
|
||||
{
|
||||
return $query->row();
|
||||
}
|
||||
else
|
||||
{
|
||||
//Get empty base parent object, as $item_id is NOT an item
|
||||
$item_obj=new stdClass();
|
||||
|
||||
//Get all the fields from items table
|
||||
$fields = $this->db->list_fields('item_unit');
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$item_obj->$field='';
|
||||
}
|
||||
|
||||
return $item_obj;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Inserts or updates an item's unit
|
||||
*/
|
||||
function save(&$items_unit_data, $item_id)
|
||||
{
|
||||
//Run these queries as a transaction, we want to make sure we do all or nothing
|
||||
$this->db->trans_start();
|
||||
|
||||
$this->delete($item_id);
|
||||
|
||||
$this->db->insert('item_unit',$items_unit_data);
|
||||
|
||||
|
||||
$this->db->trans_complete();
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Deletes unit given an item
|
||||
*/
|
||||
function delete($item_id)
|
||||
{
|
||||
return $this->db->delete('item_unit', array('item_id' => $item_id));
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -8,13 +8,6 @@ class Receiving extends CI_Model
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
function get_requisition_info($requisition_id)
|
||||
{
|
||||
$this->db->from('requisitions');
|
||||
$this->db->where('requisition_id',$requisition_id);
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
function exists($receiving_id)
|
||||
{
|
||||
$this->db->from('receivings');
|
||||
@@ -57,7 +50,8 @@ class Receiving extends CI_Model
|
||||
'quantity_purchased'=>$item['quantity'],
|
||||
'discount_percent'=>$item['discount'],
|
||||
'item_cost_price' => $cur_item_info->cost_price,
|
||||
'item_unit_price'=>$item['price']
|
||||
'item_unit_price'=>$item['price'],
|
||||
'item_location'=>$item['item_location']
|
||||
);
|
||||
|
||||
$this->db->insert('receivings_items',$receivings_items_data);
|
||||
@@ -66,7 +60,7 @@ class Receiving extends CI_Model
|
||||
$item_quantity = $this->Item_quantities->get_item_quantity($item['item_id'], $item['item_location']);
|
||||
$this->Item_quantities->save(array('quantity'=>$item_quantity->quantity + $item['quantity'],
|
||||
'item_id'=>$item['item_id'],
|
||||
'location_id'=>$item['item_location']), $item_quantity->item_quantity_id);
|
||||
'location_id'=>$item['item_location']), $item['item_id'], $item['item_location']);
|
||||
|
||||
|
||||
$qty_recv = $item['quantity'];
|
||||
@@ -94,165 +88,6 @@ class Receiving extends CI_Model
|
||||
return $receiving_id;
|
||||
}
|
||||
|
||||
function save_requisition ($items,$employee_id,$comment,$receiving_id=false)
|
||||
{
|
||||
if(count($items)==0)
|
||||
return -1;
|
||||
|
||||
$requisition_data = array(
|
||||
'employee_id'=>$employee_id,
|
||||
'comment'=>$comment
|
||||
);
|
||||
|
||||
//Run these queries as a transaction, we want to make sure we do all or nothing
|
||||
$this->db->trans_start();
|
||||
|
||||
$this->db->insert('requisitions',$requisition_data);
|
||||
|
||||
$requisition_id = $this->db->insert_id();
|
||||
|
||||
|
||||
foreach($items as $line=>$item)
|
||||
{
|
||||
$cur_item_info = $this->Item->get_info($item['item_id']);
|
||||
$related_item_unit_quantity = $this->Item_unit->get_info($item['item_id'])->unit_quantity;
|
||||
$related_item_total_quantity = $item['quantity']*$related_item_unit_quantity;
|
||||
$related_item_id;
|
||||
//Update stock quantity
|
||||
$related_item_data = array();
|
||||
if((strlen($related_item_number) == 0) or ($related_item_number == $cur_item_info->item_number))
|
||||
{
|
||||
if($this->Item->is_sale_store_item_exist($cur_item_info->item_number))
|
||||
{
|
||||
$related_item_id = $this->Item->get_item_id($cur_item_info->item_number,'sale_stock');
|
||||
$related_item_data = array('quantity'=>$this->Item->get_info($related_item_id)->quantity + $related_item_total_quantity);
|
||||
$this->Item->save($related_item_data,$related_item_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$related_item_data = array(
|
||||
'name'=>$cur_item_info->name,
|
||||
'description'=>$cur_item_info->description,
|
||||
'category'=>$cur_item_info->category,
|
||||
'supplier_id'=>$cur_item_info->supplier_id,
|
||||
'item_number'=>$cur_item_info->item_number,
|
||||
'cost_price'=>$cur_item_info->cost_price,
|
||||
'unit_price'=>$cur_item_info->unit_price,
|
||||
'quantity'=>$related_item_total_quantity,
|
||||
'reorder_level'=>$cur_item_info->reorder_level,
|
||||
'allow_alt_description'=>$cur_item_info->allow_alt_description,
|
||||
'is_serialized'=>$cur_item_info->is_serialized,
|
||||
'custom1'=>$cur_item_info->custom1, /**GARRISON ADDED 4/21/2013**/
|
||||
'custom2'=>$cur_item_info->custom2,/**GARRISON ADDED 4/21/2013**/
|
||||
'custom3'=>$cur_item_info->custom3,/**GARRISON ADDED 4/21/2013**/
|
||||
'custom4'=>$cur_item_info->custom4,/**GARRISON ADDED 4/21/2013**/
|
||||
'custom5'=>$cur_item_info->custom5,/**GARRISON ADDED 4/21/2013**/
|
||||
'custom6'=>$cur_item_info->custom6,/**GARRISON ADDED 4/21/2013**/
|
||||
'custom7'=>$cur_item_info->custom7,/**GARRISON ADDED 4/21/2013**/
|
||||
'custom8'=>$cur_item_info->custom8,/**GARRISON ADDED 4/21/2013**/
|
||||
'custom9'=>$cur_item_info->custom9,/**GARRISON ADDED 4/21/2013**/
|
||||
'custom10'=>$cur_item_info->custom10/**GARRISON ADDED 4/21/2013**/
|
||||
);
|
||||
$this->Item->save($related_item_data);
|
||||
$related_item_id = $related_item_data[item_id];
|
||||
}
|
||||
|
||||
}
|
||||
else if($this->Item->is_sale_store_item_exist($related_item_number))
|
||||
{
|
||||
$related_item_id = $this->Item->get_item_id($related_item_number,'sale_stock');
|
||||
$related_item_data = array('quantity'=>$this->Item->get_info($related_item_id)->quantity + $related_item_total_quantity);
|
||||
$this->Item->save($related_item_data,$related_item_id);
|
||||
}
|
||||
else if($this->Item->is_warehouse_item_exist($related_item_number))
|
||||
{
|
||||
$related_item_id = $this->Item->get_item_id($related_item_number,'warehouse');
|
||||
$item_data_temp= $this->Item->get_info($related_item_id,'warehouse');
|
||||
$related_item_data = array(
|
||||
'name'=>$item_data_temp->name,
|
||||
'description'=>$item_data_temp->description,
|
||||
'category'=>$item_data_temp->category,
|
||||
'supplier_id'=>$item_data_temp->supplier_id,
|
||||
'item_number'=>$item_data_temp->item_number,
|
||||
'cost_price'=>$item_data_temp->cost_price,
|
||||
'unit_price'=>$item_data_temp->unit_price,
|
||||
'quantity'=>$related_item_total_quantity,
|
||||
'reorder_level'=>$item_data_temp->reorder_level,
|
||||
'location'=>$item_data_temp->location,
|
||||
'allow_alt_description'=>$item_data_temp->allow_alt_description,
|
||||
'is_serialized'=>$item_data_temp->is_serialized,
|
||||
'custom1'=>$item_data_temp->custom1, /**GARRISON ADDED 4/21/2013**/
|
||||
'custom2'=>$item_data_temp->custom2,/**GARRISON ADDED 4/21/2013**/
|
||||
'custom3'=>$item_data_temp->custom3,/**GARRISON ADDED 4/21/2013**/
|
||||
'custom4'=>$item_data_temp->custom4,/**GARRISON ADDED 4/21/2013**/
|
||||
'custom5'=>$item_data_temp->custom5,/**GARRISON ADDED 4/21/2013**/
|
||||
'custom6'=>$item_data_temp->custom6,/**GARRISON ADDED 4/21/2013**/
|
||||
'custom7'=>$item_data_temp->custom7,/**GARRISON ADDED 4/21/2013**/
|
||||
'custom8'=>$item_data_temp->custom8,/**GARRISON ADDED 4/21/2013**/
|
||||
'custom9'=>$item_data_temp->custom9,/**GARRISON ADDED 4/21/2013**/
|
||||
'custom10'=>$item_data_temp->custom10/**GARRISON ADDED 4/21/2013**/
|
||||
);
|
||||
$this->Item->save($related_item_data);
|
||||
$related_item_id = $related_item_data[item_id];
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$item_data = array('quantity'=>$cur_item_info->quantity - $item['quantity']);
|
||||
$this->Item->save($item_data,$item['item_id']);
|
||||
|
||||
//update requisition item
|
||||
$requisition_items_data = array
|
||||
(
|
||||
'requisition_id'=>$requisition_id,
|
||||
'item_id'=>$item['item_id'],
|
||||
'line'=>$item['line'],
|
||||
'requisition_quantity'=>$item['quantity'],
|
||||
'related_item_id'=>$related_item_id,
|
||||
'related_item_quantity'=>$related_item_unit_quantity,
|
||||
'related_item_total_quantity' => $item['quantity']*$related_item_unit_quantity
|
||||
);
|
||||
|
||||
$this->db->insert('requisitions_items',$requisition_items_data);
|
||||
|
||||
//update inventory
|
||||
$qty_recv = $item['quantity']*(-1);
|
||||
$recv_remarks ='REQS '.$requisition_id;
|
||||
$inv_data = array
|
||||
(
|
||||
'trans_date'=>date('Y-m-d H:i:s'),
|
||||
'trans_items'=>$item['item_id'],
|
||||
'trans_user'=>$employee_id,
|
||||
'trans_comment'=>$recv_remarks,
|
||||
'trans_inventory'=>$qty_recv
|
||||
);
|
||||
$this->Inventory->insert($inv_data);
|
||||
|
||||
$related_item_qty_recv = $requisition_items_data['related_item_total_quantity'];
|
||||
$recv_remarks ='REQS '.$requisition_id;
|
||||
$related_item_inv_data = array
|
||||
(
|
||||
'trans_date'=>date('Y-m-d H:i:s'),
|
||||
'trans_items'=>$related_item_id,
|
||||
'trans_user'=>$employee_id,
|
||||
'trans_comment'=>$recv_remarks,
|
||||
'trans_inventory'=>$related_item_qty_recv
|
||||
);
|
||||
$this->Inventory->insert($related_item_inv_data);
|
||||
|
||||
}
|
||||
$this->db->trans_complete();
|
||||
|
||||
if ($this->db->trans_status() === FALSE)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return $requisition_id;
|
||||
}
|
||||
|
||||
function get_receiving_items($receiving_id)
|
||||
{
|
||||
$this->db->from('receivings_items');
|
||||
@@ -260,13 +95,6 @@ class Receiving extends CI_Model
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
function get_requisition_items($requisition_id)
|
||||
{
|
||||
$this->db->from('requisitions_items');
|
||||
$this->db->where('requisition_id',$requisition_id);
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
function get_supplier($receiving_id)
|
||||
{
|
||||
$this->db->from('receivings');
|
||||
@@ -289,18 +117,6 @@ class Receiving extends CI_Model
|
||||
INNER JOIN ".$this->db->dbprefix('items')." ON ".$this->db->dbprefix('receivings_items').'.item_id='.$this->db->dbprefix('items').'.item_id'."
|
||||
GROUP BY receiving_id, item_id, line)");
|
||||
}
|
||||
|
||||
public function create_requisition_items_temp_table()
|
||||
{
|
||||
$this->db->query("CREATE TEMPORARY TABLE ".$this->db->dbprefix('requisition_items_temp')."
|
||||
(SELECT date(requisition_time) as requisition_date, ".$this->db->dbprefix('requisitions_items').".requisition_id, comment, employee_id,
|
||||
".$this->db->dbprefix('items').".item_id, related_item_id, requisition_quantity, related_item_quantity,
|
||||
related_item_total_quantity, ".$this->db->dbprefix('requisitions_items').".line as line
|
||||
FROM ".$this->db->dbprefix('requisitions_items')."
|
||||
INNER JOIN ".$this->db->dbprefix('requisitions')." ON ".$this->db->dbprefix('requisitions_items').'.requisition_id='.$this->db->dbprefix('requisitions').'.requisition_id'."
|
||||
INNER JOIN ".$this->db->dbprefix('items')." ON ".$this->db->dbprefix('requisitions_items').'.item_id='.$this->db->dbprefix('items').'.item_id'."
|
||||
GROUP BY requisition_id, item_id, line)");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -29,6 +29,10 @@ class Detailed_receivings extends Report
|
||||
{
|
||||
$this->db->where('quantity_purchased < 0');
|
||||
}
|
||||
elseif ($inputs['receiving_type'] == 'requisition')
|
||||
{
|
||||
$this->db->where('quantity_purchased = 0');
|
||||
}
|
||||
$this->db->group_by('receiving_id');
|
||||
$this->db->order_by('receiving_date');
|
||||
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
require_once("report.php");
|
||||
class Detailed_requisition extends Report
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getDataColumns()
|
||||
{
|
||||
return array('summary' => array($this->lang->line('reports_requisition_id'),
|
||||
$this->lang->line('reports_date'),
|
||||
$this->lang->line('reports_requisition_by'),
|
||||
$this->lang->line('reports_comments')),
|
||||
'details' => array($this->lang->line('reports_requisition_item'),
|
||||
$this->lang->line('reports_requisition_item_quantity'),
|
||||
$this->lang->line('reports_requisition_related_item'),
|
||||
$this->lang->line('reports_requisition_related_item_unit_quantity'),
|
||||
$this->lang->line('reports_requisition_related_item_total_quantity'))
|
||||
);
|
||||
}
|
||||
|
||||
public function getData(array $inputs)
|
||||
{
|
||||
$this->db->select('requisition_id, requisition_date, CONCAT(employee.first_name," ",employee.last_name) as employee_name, comment', false);
|
||||
$this->db->from('requisition_items_temp');
|
||||
$this->db->join('people as employee', 'requisition_items_temp.employee_id = employee.person_id');
|
||||
$this->db->where('requisition_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
|
||||
|
||||
$this->db->group_by('requisition_id');
|
||||
$this->db->order_by('requisition_date');
|
||||
|
||||
$data = array();
|
||||
$data['summary'] = $this->db->get()->result_array();
|
||||
$data['details'] = array();
|
||||
|
||||
foreach($data['summary'] as $key=>$value)
|
||||
{
|
||||
$this->db->select('name, requisition_quantity, related_item_id, related_item_quantity, related_item_total_quantity');
|
||||
$this->db->from('requisition_items_temp');
|
||||
$this->db->join('items', 'requisition_items_temp.item_id = items.item_id');
|
||||
$this->db->where('requisition_id = '.$value['requisition_id']);
|
||||
$data['details'][$key] = $this->db->get()->result_array();
|
||||
|
||||
foreach($data['details'][$key] as $arr_index=>$deatil_reqs)
|
||||
{
|
||||
$related_item_name = $this->Item->get_info($deatil_reqs['related_item_id'])->name;
|
||||
$data['details'][$key][$arr_index]['related_item_id'] = $related_item_name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getSummaryData(array $inputs)
|
||||
{
|
||||
//Do nothing
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -14,7 +14,6 @@ abstract class Report extends CI_Model
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Sale->create_sales_items_temp_table();
|
||||
$this->Receiving->create_receivings_items_temp_table();
|
||||
$this->Receiving->create_requisition_items_temp_table();
|
||||
}
|
||||
|
||||
//Returns the column names used for the report
|
||||
|
||||
@@ -98,7 +98,7 @@ class Sale extends CI_Model
|
||||
$item_quantity = $this->Item_quantities->get_item_quantity($item['item_id'], $item['item_location']);
|
||||
$this->Item_quantities->save(array('quantity'=>$item_quantity->quantity - $item['quantity'],
|
||||
'item_id'=>$item['item_id'],
|
||||
'location_id'=>$item['item_location']), $item_quantity->item_quantity_id);
|
||||
'location_id'=>$item['item_location']), $item['item_id'], $item['item_location']);
|
||||
|
||||
|
||||
//Ramel Inventory Tracking
|
||||
|
||||
@@ -84,7 +84,8 @@ class Sale_suspended extends CI_Model
|
||||
'quantity_purchased'=>$item['quantity'],
|
||||
'discount_percent'=>$item['discount'],
|
||||
'item_cost_price' => $cur_item_info->cost_price,
|
||||
'item_unit_price'=>$item['price']
|
||||
'item_unit_price'=>$item['price'],
|
||||
'item_location'=>$item['item_location']
|
||||
);
|
||||
|
||||
$this->db->insert('sales_suspended_items',$sales_items_data);
|
||||
|
||||
@@ -58,11 +58,17 @@ if (isset($error_message))
|
||||
<td colspan="3" style='text-align:right;'><?php echo $this->lang->line('sales_total'); ?></td>
|
||||
<td colspan="2" style='text-align:right'><?php echo to_currency($total); ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
if($mode=='requisition')
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="3" style='text-align:right;'><?php echo $this->lang->line('sales_payment'); ?></td>
|
||||
<td colspan="2" style='text-align:right'><?php echo $payment_type; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if(isset($amount_change))
|
||||
{
|
||||
|
||||
@@ -63,23 +63,9 @@ if(isset($error))
|
||||
<tr>
|
||||
<th style="width:11%;"><?php echo $this->lang->line('common_delete'); ?></th>
|
||||
<th style="width:30%;"><?php echo $this->lang->line('recvs_item_name'); ?></th>
|
||||
<?php
|
||||
if($mode!='requisition')
|
||||
{
|
||||
?>
|
||||
<th style="width:11%;"><?php echo $this->lang->line('recvs_cost'); ?></th>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<th style="width:11%;"><?php echo $this->lang->line('recvs_quantity'); ?></th>
|
||||
<?php
|
||||
if($mode!='requisition')
|
||||
{
|
||||
?>
|
||||
<th style="width:11%;"><?php echo $this->lang->line('recvs_discount'); ?></th>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<th style="width:15%;"><?php echo $this->lang->line('recvs_total'); ?></th>
|
||||
<th style="width:11%;"><?php echo $this->lang->line('recvs_edit'); ?></th>
|
||||
</tr>
|
||||
@@ -98,72 +84,58 @@ else
|
||||
{
|
||||
foreach(array_reverse($cart, true) as $line=>$item)
|
||||
{
|
||||
if($mode == 'requisition')
|
||||
{
|
||||
echo form_open("receivings/edit_item_unit/$line");
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo anchor("receivings/delete_item/$line",'['.$this->lang->line('common_delete').']');?></td>
|
||||
<td style="align:center;"><?php echo $item['name']; ?><br /> [<?php echo $item['in_stock']; ?> in <?php echo $item['stock_name']; ?>]
|
||||
<?php echo form_hidden('location', $item['item_location']); ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php
|
||||
echo form_input(array('name'=>'quantity','value'=>$item['quantity'],'size'=>'2'));
|
||||
?>
|
||||
|
||||
</td>
|
||||
<td><?php echo $item['related_item']; ?></td>
|
||||
<td><?php echo $item['unit_quantity']; ?></td>
|
||||
<td><?php echo $item['unit_quantity']*$item['quantity']; ?></td>
|
||||
<td><?php echo form_submit("edit_item_unit", $this->lang->line('sales_edit_item'));?></td>
|
||||
</tr>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
echo form_open("receivings/edit_item/$line");
|
||||
echo form_open("receivings/edit_item/$line");
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo anchor("receivings/delete_item/$line",'['.$this->lang->line('common_delete').']');?></td>
|
||||
<td style="align:center;"><?php echo $item['name']; ?><br /> [<?php echo $item['in_stock']; ?> in <?php echo $item['stock_name']; ?>]</td>
|
||||
<tr>
|
||||
<td><?php echo anchor("receivings/delete_item/$line",'['.$this->lang->line('common_delete').']');?></td>
|
||||
<td style="align:center;"><?php echo $item['name']; ?><br /> [<?php echo $item['in_stock']; ?> in <?php echo $item['stock_name']; ?>]</td>
|
||||
<?php echo form_hidden('location', $item['item_location']); ?>
|
||||
|
||||
<?php
|
||||
echo $item['description'];
|
||||
echo form_hidden('description',$item['description']);
|
||||
?>
|
||||
<br />
|
||||
|
||||
<?php if ($items_module_allowed)
|
||||
<?php if ($items_module_allowed && !$mode=='requisition')
|
||||
{
|
||||
?>
|
||||
<td><?php echo form_input(array('name'=>'price','value'=>$item['price'],'size'=>'6'));?></td>
|
||||
<td><?php echo form_input(array('name'=>'price','value'=>$item['price'],'size'=>'6'));?></td>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
<td><?php echo $item['price']; ?></td>
|
||||
<?php echo form_hidden('price',$item['price']); ?>
|
||||
<td><?php echo $item['price']; ?></td>
|
||||
<?php echo form_hidden('price',$item['price']); ?>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<td>
|
||||
<td>
|
||||
<?php
|
||||
echo form_input(array('name'=>'quantity','value'=>$item['quantity'],'size'=>'2'));
|
||||
?>
|
||||
</td>
|
||||
</td>
|
||||
|
||||
<?php if ($items_module_allowed && !$mode=='requisition')
|
||||
{
|
||||
?>
|
||||
<td><?php echo form_input(array('name'=>'discount','value'=>$item['discount'],'size'=>'3'));?></td>
|
||||
<td><?php echo to_currency($item['price']*$item['quantity']-$item['price']*$item['quantity']*$item['discount']/100); ?></td>
|
||||
<td><?php echo form_submit("edit_item", $this->lang->line('sales_edit_item'));?></td>
|
||||
</tr>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
<td><?php echo $item['discount']; ?></td>
|
||||
<?php echo form_hidden('discount',$item['discount']); ?>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<td><?php echo to_currency($item['price']*$item['quantity']-$item['price']*$item['quantity']*$item['discount']/100); ?></td>
|
||||
<td><?php echo form_submit("edit_item", $this->lang->line('sales_edit_item'));?></td>
|
||||
</tr>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php $this->load->view("partial/header"); ?>
|
||||
<?php
|
||||
if (isset($error_message))
|
||||
{
|
||||
echo '<h1 style="text-align: center;">'.$error_message.'</h1>';
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<div id="receipt_wrapper">
|
||||
<div id="receipt_header">
|
||||
<div id="company_name"><?php echo $this->config->item('company'); ?></div>
|
||||
<div id="company_address"><?php echo nl2br($this->config->item('address')); ?></div>
|
||||
<div id="company_phone"><?php echo $this->config->item('phone'); ?></div>
|
||||
<div id="sale_receipt"><?php echo $receipt_title; ?></div>
|
||||
<div id="sale_time"><?php echo $transaction_time ?></div>
|
||||
</div>
|
||||
<div id="receipt_general_info">
|
||||
<div id="sale_id"><?php echo $this->lang->line('recvs_id').": ".$receiving_id; ?></div>
|
||||
<div id="employee"><?php echo $this->lang->line('employees_employee').": ".$employee; ?></div>
|
||||
</div>
|
||||
|
||||
<table id="receipt_items">
|
||||
<tr>
|
||||
<th style="width:25%;"><?php echo $this->lang->line('items_item'); ?></th>
|
||||
<th style="width:16%;text-align:center;"><?php echo $this->lang->line('reqs_quantity'); ?></th>
|
||||
<th style="width:25%;text-align:center;"><?php echo $this->lang->line('reqs_related_item'); ?></th>
|
||||
<th style="width:17%;text-align:center;"><?php echo $this->lang->line('reqs_unit_quantity'); ?></th>
|
||||
<th style="width:17%;text-align:center;"><?php echo $this->lang->line('reqs_related_item_quantity'); ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
foreach(array_reverse($cart, true) as $line=>$item)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td><span class='long_name'><?php echo $item['name']; ?></span><span class='short_name'><?php echo character_limiter($item['name'],10); ?></span></td>
|
||||
<td style='text-align:center;'><?php echo $item['quantity']; ?></td>
|
||||
<td style='text-align:center;'><?php echo $item['related_item']; ?></td>
|
||||
<td style='text-align:center;'><?php echo $item['unit_quantity']; ?></td>
|
||||
<?php
|
||||
$related_item_id = $this->Item->get_item_id($this->Item_unit->get_info($item['item_id'])->related_number,'sale_stock');
|
||||
$total_related_item_qty = $this->Item->get_info($related_item_id)->quantity;
|
||||
?>
|
||||
<td style='text-align:center;'><?php echo $total_related_item_qty; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<td colspan="2" align="center"><?php echo $item['description']; ?></td>
|
||||
<td colspan="2" ><?php echo $item['serialnumber']; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</table>
|
||||
|
||||
<div id="sale_return_policy">
|
||||
<?php echo nl2br($this->config->item('return_policy')); ?>
|
||||
</div>
|
||||
<div id='barcode'>
|
||||
<?php echo "<img src='index.php?c=barcode&barcode=$receiving_id&text=$receiving_id&width=250&height=50' />"; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php $this->load->view("partial/footer"); ?>
|
||||
|
||||
<?php if ($this->Appconfig->get('print_after_sale'))
|
||||
{
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$(window).load(function()
|
||||
{
|
||||
window.print();
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
@@ -59,7 +59,8 @@ if(isset($error))
|
||||
<div id='report_receiving_type'>
|
||||
<?php echo form_dropdown('receiving_type',array('all' => $this->lang->line('reports_all'),
|
||||
'receiving' => $this->lang->line('reports_receivings'),
|
||||
'returns' => $this->lang->line('reports_returns')), 'all', 'id="input_type"'); ?>
|
||||
'returns' => $this->lang->line('reports_returns'),
|
||||
'requisitions' => $this->lang->line('reports_requisitions')), 'all', 'id="input_type"'); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
<ul>
|
||||
<li><a href="<?php echo site_url('reports/detailed_sales');?>"><?php echo $this->lang->line('reports_sales'); ?></a></li>
|
||||
<li><a href="<?php echo site_url('reports/detailed_receivings');?>"><?php echo $this->lang->line('reports_receivings'); ?></a></li>
|
||||
<li><a href="<?php echo site_url('reports/detailed_requisition');?>"><?php echo $this->lang->line('reports_requisition'); ?></a></li>
|
||||
<li><a href="<?php echo site_url('reports/specific_customer');?>"><?php echo $this->lang->line('reports_customer'); ?></a></li>
|
||||
<li><a href="<?php echo site_url('reports/specific_discount');?>"><?php echo $this->lang->line('reports_discount'); ?></a></li>
|
||||
<li><a href="<?php echo site_url('reports/specific_employee');?>"><?php echo $this->lang->line('reports_employee'); ?></a></li>
|
||||
|
||||
Reference in New Issue
Block a user