I really want to thank the work done in this project! I would be interested to collaborate and be part of it .
I am currently trying to generate a control product stock . I’ve managed to include in the product load the stock available , but I 've worked in the query to check stock when creating the invoice.
Need to validate when storing the stock placed in the quantity field is less than or equal to field stock that have crept into the table ip_product
On the other hand you need to subtract the aggregate in the "quantity " field in the creation of invoce amount .
And my next goal is to warn those responsible of stock product An alert via run -mail when the stock is below X quantity .
My main problem now is I can not validate the quantity of products placed on the quantity field with those who are in the table ip_products
Now, my code in invoice/controller/ajax.php is:
foreach ($items as $item) {
$this->load->model('products/mdl_products');
$cantidad = $this->mdl_products->where('product_id',$item->product_id)->get()->result();
if ($cantidad['product_id'] != $item->item_quantity){
$this->form_validation->set_rules('item_quantity', lang('quantity'), 'required');
$this->form_validation->run();
$response = array(
'success' => 0,
'validation_errors' => array(
'item_quantity' => form_error('item_quantity', '','')
)
);
echo json_encode($response);
exit;
When I call the product model brings me an empty value.
Share below function model
public function check_stock($item_id){
$this->db->select('stock');
$this->db->where('product_id', $item_id);
}
when stock is the name of column. I try to return data… but… nothing is happend.
If you can help me… I’ll be very greatful
and if you need some help, please contact me.
Regards