mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-31 11:48:39 -04:00
Requisition options is only shown when multiple stock locations are configured Fix stock locations config in the configuration page Rename item_quantitys to item_quantities Fix a missing label (need to check if present in master) Fix display of the stock quantities in items/manage view git-svn-id: svn+ssh://svn.code.sf.net/p/opensourcepos/code/@119 c3eb156b-1dc0-44e1-88ae-e38439141b53
50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
class Item_quantities extends CI_Model
|
|
{
|
|
function exists($item_quantity_id)
|
|
{
|
|
$this->db->from('item_quantities');
|
|
$this->db->where('item_quantity_id',$item_quantity_id);
|
|
$query = $this->db->get();
|
|
|
|
return ($query->num_rows()==1);
|
|
}
|
|
|
|
function save($location_detail, $item_quantity_id=false)
|
|
{
|
|
if (!$item_quantity_id or !$this->exists($item_quantity_id))
|
|
{
|
|
if($this->db->insert('item_quantities',$location_detail))
|
|
{
|
|
$location_detail['item_quantity_id']=$this->db->insert_id();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
$this->db->where('item_quantity_id', $item_quantity_id);
|
|
return $this->db->update('item_quantities',$location_detail);
|
|
}
|
|
|
|
function get_item_quantity($item_id, $location_id)
|
|
{
|
|
$this->db->from('item_quantities');
|
|
$this->db->where('item_id',$item_id);
|
|
$this->db->where('location_id',$location_id);
|
|
$result = $this->db->get()->row();
|
|
if(empty($result) == true)
|
|
{
|
|
//Get empty base parent object, as $item_id is NOT an item
|
|
$result=new stdClass();
|
|
//Get all the fields from items table (TODO to be reviewed)
|
|
$fields = $this->db->list_fields('item_quantities');
|
|
foreach ($fields as $field)
|
|
{
|
|
$result->$field='';
|
|
}
|
|
$result->quantity = 0;
|
|
}
|
|
return $result;
|
|
}
|
|
}
|
|
?>
|