public function addQuantity() { $id = $this->input->post('txtItemID'); $stocks = Stocks_model::find($id); $details = array("quantity" => $stocks->quantity + $this->input->post('txtQuantity'), "date_last_restocked" => $this->input->post('txtDateRestock')); $stocks->update_attributes($details); }
public function insertStocks() { $this->form_validation->set_rules('txtItemID', 'Item ID', 'trim|required'); $this->form_validation->set_rules('txtItemName', 'Item Name', 'trim|required'); $this->form_validation->set_rules('txtCategory', 'Category', 'trim|required'); $this->form_validation->set_rules('txtPrice', 'Price', 'trim|required'); if ($this->form_validation->run()) { $details = Stock_info_model::stocksDetails(); if (Stock_info_model::create($details)) { Stocks_model::newStocks(); $this->session->set_userdata('added', 1); Audit_trail_model::auditNewItem($details); redirect('ams/view_inventory'); } } }
public function recordRestock() { $this->form_validation->set_rules('txtItemID', 'Item ID', 'trim|required'); $this->form_validation->set_rules('txtQuantity', 'Quantity', 'trim|required'); $this->form_validation->set_rules('txtVendor', 'Vendor', 'trim|required'); $this->form_validation->set_rules('txtDateRestock', 'Date Restock', 'trim|required'); if ($this->form_validation->run()) { $details = array('item_id' => $this->input->post('txtItemID'), 'quantity' => $this->input->post('txtQuantity'), 'vendor_id' => $this->input->post('txtVendor'), 'date_restock' => $this->input->post('txtDateRestock')); if (Restock_model::create($details)) { Stocks_model::addQuantity(); $this->session->set_userdata('edited', 1); Audit_trail_model::auditRestock($details); redirect('ams/view_inventory'); } } }
public function insertMaterials() { $this->form_validation->set_rules('txtItemID', 'Item ID', 'trim|required'); $this->form_validation->set_rules('txtQuantity', 'Quantity', 'trim|required'); $this->form_validation->set_rules('txtProjectID', 'Project ID', 'trim|required'); $this->form_validation->set_rules('txtDateIssued', 'Date Issued', 'trim|required'); if ($this->form_validation->run()) { $item_id = $this->input->post('txtItemID'); $quantity = $this->input->post('txtQuantity'); $stock = Stock_info_model::find($item_id); //insert into materials table $data = array('item_id' => $item_id, 'quantity' => $quantity, 'price' => $stock->price, 'project_id' => $this->input->post('txtProjectID'), 'date_issued' => $this->input->post('txtDateIssued')); if (Materials_model::create($data)) { $row = Stocks_model::find($item_id); $row->quantity -= $quantity; $row->save(); $this->session->set_userdata('added', 1); redirect('ams/view_all_materials'); } } }
public function calcPumpReadingForMonth() { require 'models/Stocks_model.php'; $model = new Stocks_model(); echo json_encode($model->calcPumpReadingForMonth()); }