store_update_stock Table
Code: Select all
+-----------------+------------+-----------------+
| update_stock_id | old_row_id | transfer_status |
+-----------------+------------+-----------------+
| 1 | 0 | Approved |
| 2 | 0 | Approved |
| 3 | 1 | Issue |
| 4 | 2 | Issue |
+-----------------+------------+-----------------+
Code: Select all
+-------------------------+-----------------+------+-----+------------+
| update_stock_details_id | update_stock_id | item | qty | unit_price |
+-------------------------+-----------------+------+-----+------------+
| 1 | 1 | 400 | 1 | 10.00 |
| 2 | 2 | 400 | 2 | 10.00 |
| 3 | 2 | 401 | 2 | 10.50 |
| 4 | 2 | 402 | 4 | 11.00 |
| 5 | 3 | 400 | 2 | 10.00 |
+-------------------------+-----------------+------+-----+------------+
Code: Select all
+-----------------+------------+-----------------+
| update_stock_id | old_row_id | transfer_status |
+-----------------+------------+-----------------+
| 1 | 0 | Verified |
| 2 | 0 | Verified |
| 3 | 1 | Issue |
| 4 | 2 | Issue |
+-----------------+------------+-----------------+
Code: Select all
public function verifyItemReqFromHD($id=null)
{
if ($this->form_validation->run() == true) {
$count = count($this->input->post('item_id'));
$items = $this->input->post('item_id');
$qts = $this->input->post('qty');
$unit_price = $this->input->post('unit_price');
$usid = $this->input->post('update_stock_id');
$total = 0;
for ($x = 0; $x < $count; $x++) {
$details[$x]['update_stock_id'] = null;
$details[$x]['item'] = $items[$x];
$details[$x]['qty'] = (-1)*$qts[$x];
$details[$x]['unit_price'] = $unit_price[$x];
}
$stock = array(
'old_row_id' => $usid,
'transfer_status' => 'Issue'
);
if ($this->Item_model->addItemReqFromHD($stock, $details, $id)) {
$this->session->set_flashdata('message', 'Successfully Issued..!!');
redirect('item/approvedItemsToIssue');
}
} else {
$this->session->set_flashdata('error', validation_errors());
$this->render('item/viewItemtoIssued', $meta, $this->data);
}
}
Code: Select all
function addItemReqFromHD($data,$details,$id)
{
$this->db->trans_start();
if ($this->db->insert('store_update_stock', $data)) {
$id = $this->db->insert_id();
foreach ($details as $detail) {
$detail['update_stock_id'] = $id;
$this->db->insert('store_update_stock_details', $detail);
}
}
$this->db->update('store_update_stock', array('transfer_status' => 'Verified'), array($id => $array['update_stock_id']));
$this->db->trans_complete();
if ($this->db->trans_status() === true) {
return true;
}
return false;
}
Mobile version