/** * (non-PHPdoc) * @see CRUDPageAbstract::_getEndJs() */ protected function _getEndJs() { $statusOptions = RMA::getAllStatuses(); $js = parent::_getEndJs(); $js .= "pageJs._statusOptions=" . json_encode($statusOptions) . ";"; $js .= "pageJs._bindSearchKey()"; $js .= ".setCallbackId('deactivateItems', '" . $this->deactivateItemBtn->getUniqueID() . "')"; $js .= ".getResults(true, " . $this->pageSize . ");"; return $js; }
/** * get RMA Items by RMA * * @param RMA|string $rma * @return Ambigous <NULL, unknown> */ public static function getByRMA($rma) { $rma = $rma instanceof RMA ? $rma : RMA::get(trim($rma)); $rma = $rma instanceof RMA ? $rma : (count($rmas = RMA::getAllByCriteria('RMAId = ?', array(trim($rma)), true, 1, 1)) > 0 ? $rmas[0] : null); return $rma instanceof RMA ? count($items = self::getAllByCriteria('RMAId = ?', array($rma->getId()), true)) > 0 ? $items : null : null; }
/** * Creating a RMA * * @param Customer $customer * * @return RMA */ public static function create(Customer $customer, $description = '') { $ra = new RMA(); return $ra->setCustomer($customer)->setDescription(trim($description))->save(); }
/** * * @param unknown $sender * @param unknown $params */ public function addComments($sender, $params) { $results = $errors = array(); try { Dao::beginTransaction(); if (!isset($params->CallbackParameter->RMA) || !($RMA = RMA::get($params->CallbackParameter->RMA->id)) instanceof RMA) { throw new Exception('System Error: invalid CreditNote passed in!'); } if (!isset($params->CallbackParameter->comments) || ($comments = trim($params->CallbackParameter->comments)) === '') { throw new Exception('System Error: invalid comments passed in!'); } $comment = Comments::addComments($RMA, $comments, Comments::TYPE_NORMAL); $results = $comment->getJson(); Dao::commitTransaction(); } catch (Exception $ex) { Dao::rollbackTransaction(); $errors[] = $ex->getMessage(); } $params->ResponseData = StringUtilsAbstract::getJson($results, $errors); }