示例#1
0
 /**
  * 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;
 }
示例#2
0
 /**
  *
  * @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);
 }