00001 <?php
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once FASTFRAME_ROOT . 'lib/FastFrame/Model.php';
00026
00027
00028
00029
00042
00043 class FF_Model_Inventory extends FF_Model {
00044
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
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
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
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
00155
00162 function remove()
00163 {
00164 return $this->o_dataAccess->remove(1, 1);
00165 }
00166
00167
00168
00169
00176 function &process()
00177 {
00178 return $this->o_dataAccess->process();
00179 }
00180
00181
00182
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
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
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
00245
00252 function getLoadedItems()
00253 {
00254 return $this->items;
00255 }
00256
00257
00258
00259
00260 function getItemId()
00261 {
00262 return $this->itemId;
00263 }
00264
00265
00266
00267
00268 function setItemId($in_value)
00269 {
00270 $this->itemId = $in_value;
00271 }
00272
00273
00274
00275
00276 function getItemName()
00277 {
00278 return $this->itemName;
00279 }
00280
00281
00282
00283
00284 function setItemName($in_value)
00285 {
00286 $this->itemName = $in_value;
00287 }
00288
00289
00290
00291
00292 function getItemBarcode()
00293 {
00294 return $this->itemBarcode;
00295 }
00296
00297
00298
00299
00300 function setItemBarcode($in_value)
00301 {
00302 $this->itemBarcode = $in_value;
00303 }
00304
00305
00306
00307
00314 function getFormattedEnteredDate()
00315 {
00316 return date('m/d/Y H:i:s', $this->enteredDate);
00317 }
00318
00319
00320
00321
00322 function getEnteredDate()
00323 {
00324 return $this->enteredDate;
00325 }
00326
00327
00328
00329
00330 function setEnteredDate($in_value)
00331 {
00332 $this->enteredDate = $in_value;
00333 }
00334
00335
00336
00337
00344 function getUserFullName()
00345 {
00346 $o_profileDataAccess =& FF_DataAccess::factory('Profile', 'profile');
00347 return $o_profileDataAccess->getFullNameById($this->getUserId());
00348 }
00349
00350
00351
00352
00353 function getUserId()
00354 {
00355 return $this->userId;
00356 }
00357
00358
00359
00360
00361 function setUserId($in_value)
00362 {
00363 $this->userId = $in_value;
00364 }
00365
00366
00367
00368
00375 function _initDataAccess()
00376 {
00377 $this->o_dataAccess =& FF_DataAccess::factory('Inventory');
00378 }
00379
00380
00381 }
00382 ?>