diff --git a/application/config/autoload.php b/application/config/autoload.php index 051567985..6f237f4ef 100644 --- a/application/config/autoload.php +++ b/application/config/autoload.php @@ -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 */ diff --git a/application/config/config.php b/application/config/config.php index c59d11d95..315d10762 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -9,7 +9,7 @@ | | */ -$config['application_version'] = '2.2.1'; +$config['application_version'] = '2.3'; /* |-------------------------------------------------------------------------- diff --git a/application/config/routes.php b/application/config/routes.php index e3715274a..f5fe358a1 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -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"; diff --git a/application/controllers/receivings.php b/application/controllers/receivings.php index c5e57004a..be3466658 100644 --- a/application/controllers/receivings.php +++ b/application/controllers/receivings.php @@ -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(); diff --git a/application/language/en/receivings_lang.php b/application/language/en/receivings_lang.php index 763123dc6..e3546689e 100644 --- a/application/language/en/receivings_lang.php +++ b/application/language/en/receivings_lang.php @@ -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'; ?> diff --git a/application/language/en/reports_lang.php b/application/language/en/reports_lang.php index 495142f12..e380f931a 100644 --- a/application/language/en/reports_lang.php +++ b/application/language/en/reports_lang.php @@ -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'; ?> diff --git a/application/libraries/Receiving_lib.php b/application/libraries/Receiving_lib.php index f48273587..55f45c695 100644 --- a/application/libraries/Receiving_lib.php +++ b/application/libraries/Receiving_lib.php @@ -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); diff --git a/application/models/item_unit.php b/application/models/item_unit.php deleted file mode 100644 index 782f3e9ca..000000000 --- a/application/models/item_unit.php +++ /dev/null @@ -1,60 +0,0 @@ -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)); - } -} -?> diff --git a/application/models/receiving.php b/application/models/receiving.php index 067a7cb69..95cedbd0d 100644 --- a/application/models/receiving.php +++ b/application/models/receiving.php @@ -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)"); - } - + } ?> diff --git a/application/models/reports/detailed_receivings.php b/application/models/reports/detailed_receivings.php index 0b3990102..fb5fb23a9 100644 --- a/application/models/reports/detailed_receivings.php +++ b/application/models/reports/detailed_receivings.php @@ -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'); diff --git a/application/models/reports/detailed_requisition.php b/application/models/reports/detailed_requisition.php deleted file mode 100644 index 0d7a332e5..000000000 --- a/application/models/reports/detailed_requisition.php +++ /dev/null @@ -1,62 +0,0 @@ - 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 - } -} -?> \ No newline at end of file diff --git a/application/models/reports/report.php b/application/models/reports/report.php index 51b251ab2..0a7f6e31a 100644 --- a/application/models/reports/report.php +++ b/application/models/reports/report.php @@ -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 diff --git a/application/models/sale.php b/application/models/sale.php index 4e518125b..f00a2b21a 100644 --- a/application/models/sale.php +++ b/application/models/sale.php @@ -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 diff --git a/application/models/sale_suspended.php b/application/models/sale_suspended.php index 3c46b6274..78bfd453c 100644 --- a/application/models/sale_suspended.php +++ b/application/models/sale_suspended.php @@ -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); diff --git a/application/views/receivings/receipt.php b/application/views/receivings/receipt.php index f8d3cf4cd..fcf6f42c5 100644 --- a/application/views/receivings/receipt.php +++ b/application/views/receivings/receipt.php @@ -58,11 +58,17 @@ if (isset($error_message))
| lang->line('items_item'); ?> | -lang->line('reqs_quantity'); ?> | -lang->line('reqs_related_item'); ?> | -lang->line('reqs_unit_quantity'); ?> | -lang->line('reqs_related_item_quantity'); ?> | -
|---|---|---|---|---|
| - | - | - | - 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; - ?> - | - |
| - | - | |||