Files
opensourcepos/application/models/item_unit.php
jekkos 6ff1cb007c requisition receipt fixed
database.sql script merged with current ospos one
remaining problems in reporting (sale_type to add in sales_temp query?)
data model should be refactored to allow more genericity for custom item locations (2+)
inventory tracking should be adapted to use multiple locations (instead of duplicating items for different locations)

git-svn-id: svn+ssh://svn.code.sf.net/p/opensourcepos/code/@113 c3eb156b-1dc0-44e1-88ae-e38439141b53
2014-08-19 19:55:13 +00:00

61 lines
1.3 KiB
PHP

<?php
class Item_unit extends CI_Model
{
/*
Gets item info for a particular item
*/
function get_info($item_id)
{
$this->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));
}
}
?>