protected static function _getData() { if (count(self::$_dateRange) === 0) { $toDate = UDate::maxDate(); } else { $toDate = self::$_dateRange['end']; } $return = array(); foreach (AccountingCode::getAll() as $accoutingCode) { $return[] = array('type' => self::_convertType($accoutingCode->getTypeId()), 'code' => $accoutingCode->getCode(), 'description' => $accoutingCode->getDescription()); } return $return; }
/** * Getting The end javascript * * @return string */ protected function _getEndJs() { $btnIdnewPO = isset($_REQUEST['btnidnewpo']) && trim($_REQUEST['btnidnewpo']) !== '' ? trim($_REQUEST['btnidnewpo']) : null; $manufacturers = array_map(create_function('$a', 'return $a->getJson();'), Manufacturer::getAll()); $suppliers = array_map(create_function('$a', 'return $a->getJson();'), Supplier::getAll()); $statuses = array_map(create_function('$a', 'return $a->getJson();'), ProductStatus::getAll()); $priceTypes = array_map(create_function('$a', 'return $a->getJson();'), ProductPriceType::getAll()); $codeTypes = array_map(create_function('$a', 'return $a->getJson();'), ProductCodeType::getAll()); $locationTypes = array_map(create_function('$a', 'return $a->getJson();'), PreferredLocationType::getAll()); $accountingCodes = array_map(create_function('$a', 'return array("id"=> $a->getId(), "code"=> $a->getCode(), "description"=> $a->getDescription(), "type"=> $a->getTypeId());'), AccountingCode::getAll()); $js = parent::_getEndJs(); $js .= "pageJs.setPreData(" . json_encode($manufacturers) . ", " . json_encode($suppliers) . ", " . json_encode($statuses) . ", " . json_encode($priceTypes) . ", " . json_encode($codeTypes) . ", " . json_encode($locationTypes) . ", " . json_encode($btnIdnewPO) . ", " . json_encode($accountingCodes) . ")"; $js .= ".setCallbackId('getCategories', '" . $this->getCategoriesBtn->getUniqueID() . "')"; $js .= ".setCallbackId('validateSKU', '" . $this->validateSKUBtn->getUniqueID() . "')"; $js .= ".load()"; $js .= ".bindAllEventNObjects()"; $js .= "._loadChosen();"; if (!AccessControl::canEditProduct(Core::getRole())) { $js .= "pageJs.readOnlyMode();"; } return $js; }
private function updateAccountingCode($description, $code) { try { Dao::beginTransaction(); $typeId = $this->leftMostNum($code); if (!empty($description) && !empty($code) && !empty($typeId)) { $accountingCode = AccountingCode::create($typeId, $code, $description); } Dao::commitTransaction(); return $accountingCode; } catch (Exception $e) { Dao::rollbackTransaction(); echo $e; exit; } }
/** * creating accountcode * * @param int $typeId * @param int $code * @param string $description * * @return Ambigous <BaseEntityAbstract, GenericDAO> */ public static function create($typeId, $code, $description = '') { $existings = AccountingCode::getAllByCriteria('code = ? AND typeId = ?', array($code, $typeId), true, 1, 1); $item = count($existings) > 0 ? $existings[0] : new AccountingCode(); return $item->setTypeId($typeId)->setCode($code)->setDescription(trim($description))->save(); }