Model/Inventory.php

Go to the documentation of this file.
00001 <?php
00003 // {{{ license
00004 
00005 // +----------------------------------------------------------------------+
00006 // | FastFrame Application Framework                                      |
00007 // +----------------------------------------------------------------------+
00008 // | Copyright (c) 2002-2006 The Codejanitor Group                        |
00009 // +----------------------------------------------------------------------+
00010 // | This source file is subject to the GNU Lesser Public License (LGPL), |
00011 // | that is bundled with this package in the file LICENSE, and is        |
00012 // | available at through the world-wide-web at                           |
00013 // | http://www.fsf.org/copyleft/lesser.html                              |
00014 // | If you did not receive a copy of the LGPL and are unable to          |
00015 // | obtain it through the world-wide-web, you can get it by writing the  |
00016 // | Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
00017 // | MA 02111-1307, USA.                                                  |
00018 // +----------------------------------------------------------------------+
00019 // | Authors: Jason Rust <jrust@codejanitor.com>                          |
00020 // +----------------------------------------------------------------------+
00021 
00022 // }}}
00023 // {{{ requires
00024 
00025 require_once FASTFRAME_ROOT . 'lib/FastFrame/Model.php';
00026 
00027 // }}}
00028 // {{{ class FF_Model_Inventory
00029 
00042 // }}}
00043 class FF_Model_Inventory extends FF_Model {
00044     // {{{ properties
00045 
00050     var $itemId;
00051 
00056     var $itemName;
00057 
00062     var $itemBarcode;
00063 
00068     var $enteredDate;
00069     
00074     var $userId;
00075 
00080     var $items = array();
00081 
00082     // }}}
00083     // {{{ reset()
00084 
00091     function reset()
00092     {
00093         $this->itemId = null;
00094         $this->itemName = null;
00095         $this->itemBarcode = null;
00096         $this->inventoryDate = null;
00097         $this->userId = null;
00098         $this->items = array();
00099     }
00100 
00101     // }}}
00102     // {{{ importFromArray()
00103 
00112     function importFromArray($in_data)
00113     {
00114         $this->setItemId($in_data['item_id']);
00115         $this->setEnteredDate($in_data['entered_date']);
00116         $this->setUserId($in_data['user_id']);
00117         if (isset($in_data['name'])) {
00118             $this->setItemName($in_data['name']);
00119         }
00120 
00121         if (isset($in_data['barcode'])) {
00122             $this->setItemBarcode($in_data['barcode']);
00123         }
00124 
00125         if (isset($in_data['items'])) {
00126             $this->items = $in_data['items'];
00127         }
00128     }
00129 
00130     // }}}
00131     // {{{ exportToArray()
00132 
00141     function exportToArray()
00142     {
00143         $a_data = array();
00144         $a_data['item_id'] = $this->getItemId();
00145         $a_data['name'] = $this->getItemName();
00146         $a_data['barcode'] = $this->getItemBarcode();
00147         $a_data['entered_date'] = $this->getEnteredDate();
00148         $a_data['user_id'] = $this->getUserId();
00149         $a_data['items'] = $this->items;
00150         return $a_data;
00151     }
00152 
00153     // }}}
00154     // {{{ remove()
00155 
00162     function remove()
00163     {
00164         return $this->o_dataAccess->remove(1, 1);
00165     }
00166 
00167     // }}}
00168     // {{{ process()
00169 
00176     function &process()
00177     {
00178         return $this->o_dataAccess->process();
00179     }
00180 
00181     // }}}
00182     // {{{ setItemsFromString()
00183 
00193     function setItemsFromString($in_string)
00194     {
00195         if (!FastFrame::isEmpty($in_string, false)) {
00196             require_once dirname(__FILE__) . '/Item.php';
00197             $o_itemModel =& new FF_Model_Item();
00198             $a_items = preg_split('/\s/', $in_string, -1, PREG_SPLIT_NO_EMPTY);
00199             foreach ($a_items as $s_item) {
00200                 $this->addItem($o_itemModel->getItemIdByBarcode($s_item), $s_item);
00201             }
00202         }
00203     }
00204 
00205     // }}}
00206     // {{{ addItem()
00207 
00217     function addItem($in_itemId, $in_barcode = null)
00218     {
00219         $this->items[] = array('item_id' => $in_itemId, 'barcode' => $in_barcode);
00220     }
00221 
00222     // }}}
00223     // {{{ getItemList()
00224 
00231     function getItemList()
00232     {
00233         $s_items = '';
00234         foreach ($this->getLoadedItems() as $a_item) {
00235             if (!is_null($a_item['barcode'])) {
00236                 $s_items .= $a_item['barcode'] . ' ';
00237             }
00238         }
00239 
00240         return $s_items;
00241     }
00242 
00243     // }}}
00244     // {{{ getLoadedItems()
00245 
00252     function getLoadedItems()
00253     {
00254         return $this->items;
00255     }
00256 
00257     // }}}
00258     // {{{ getItemId()
00259 
00260     function getItemId()
00261     {
00262         return $this->itemId;
00263     }
00264 
00265     // }}}
00266     // {{{ setItemId()
00267 
00268     function setItemId($in_value)
00269     {
00270         $this->itemId = $in_value;
00271     }
00272 
00273     // }}}
00274     // {{{ getItemName()
00275 
00276     function getItemName()
00277     {
00278         return $this->itemName;
00279     }
00280 
00281     // }}}
00282     // {{{ setItemName()
00283 
00284     function setItemName($in_value)
00285     {
00286         $this->itemName = $in_value;
00287     }
00288 
00289     // }}}
00290     // {{{ getItemBarcode()
00291 
00292     function getItemBarcode()
00293     {
00294         return $this->itemBarcode;
00295     }
00296 
00297     // }}}
00298     // {{{ setItemBarcode()
00299 
00300     function setItemBarcode($in_value)
00301     {
00302         $this->itemBarcode = $in_value;
00303     }
00304 
00305     // }}}
00306     // {{{ getFormattedEnteredDate()
00307 
00314     function getFormattedEnteredDate()
00315     {
00316         return date('m/d/Y H:i:s', $this->enteredDate);
00317     }
00318 
00319     // }}}
00320     // {{{ getEnteredDate()
00321 
00322     function getEnteredDate()
00323     {
00324         return $this->enteredDate;
00325     }
00326 
00327     // }}}
00328     // {{{ setEnteredDate()
00329 
00330     function setEnteredDate($in_value)
00331     {
00332         $this->enteredDate = $in_value;
00333     }
00334 
00335     // }}}
00336     // {{{ getUserFullName()
00337 
00344     function getUserFullName()
00345     {
00346         $o_profileDataAccess =& FF_DataAccess::factory('Profile', 'profile');
00347         return $o_profileDataAccess->getFullNameById($this->getUserId());
00348     }
00349 
00350     // }}}
00351     // {{{ getUserId()
00352 
00353     function getUserId()
00354     {
00355         return $this->userId;
00356     }
00357 
00358     // }}}
00359     // {{{ setUserId()
00360 
00361     function setUserId($in_value)
00362     {
00363         $this->userId = $in_value;
00364     }
00365 
00366     // }}}
00367     // {{{ _initDataAccess()
00368 
00375     function _initDataAccess()
00376     {
00377         $this->o_dataAccess =& FF_DataAccess::factory('Inventory');
00378     }
00379 
00380     // }}}
00381 }
00382 ?>

Generated on Fri Jun 23 11:38:16 2006 for FastFrame by  doxygen 1.4.4