Beispiel #1
0
 /**
  * Filter the query by a related \ORM\PurchaseHistory object
  *
  * @param \ORM\PurchaseHistory|ObjectCollection $purchaseHistory  the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildPurchaseQuery The current query, for fluid interface
  */
 public function filterByHistory($purchaseHistory, $comparison = null)
 {
     if ($purchaseHistory instanceof \ORM\PurchaseHistory) {
         return $this->addUsingAlias(PurchaseTableMap::COL_ID, $purchaseHistory->getPurchaseId(), $comparison);
     } elseif ($purchaseHistory instanceof ObjectCollection) {
         return $this->useHistoryQuery()->filterByPrimaryKeys($purchaseHistory->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByHistory() only accepts arguments of type \\ORM\\PurchaseHistory or Collection');
     }
 }
 /**
  * Exclude object from result
  *
  * @param   ChildPurchaseHistory $purchaseHistory Object to remove from the list of results
  *
  * @return $this|ChildPurchaseHistoryQuery The current query, for fluid interface
  */
 public function prune($purchaseHistory = null)
 {
     if ($purchaseHistory) {
         $this->addUsingAlias(PurchaseHistoryTableMap::COL_ID, $purchaseHistory->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Beispiel #3
0
 /**
  * @param ChildPurchaseHistory $history The ChildPurchaseHistory object to add.
  */
 protected function doAddHistory(ChildPurchaseHistory $history)
 {
     $this->collHistories[] = $history;
     $history->setPurchase($this);
 }
Beispiel #4
0
 /**
  * @param ChildPurchaseHistory $purchaseHistory The ChildPurchaseHistory object to add.
  */
 protected function doAddPurchaseHistory(ChildPurchaseHistory $purchaseHistory)
 {
     $this->collPurchaseHistories[] = $purchaseHistory;
     $purchaseHistory->setUserDetail($this);
 }
Beispiel #5
0
 public static function viewDetail($params, $currentUser, $con)
 {
     // check role's permission
     $permission = RolePermissionQuery::create()->select('read_sales')->findOneById($currentUser->role_id, $con);
     if (!$permission || $permission != 1) {
         throw new \Exception('Akses ditolak. Anda tidak mempunyai izin untuk melakukan operasi ini.');
     }
     $purchase = Purchases::seeker($params, $currentUser, $con);
     $logData['data'] = $purchase['data'];
     $logData['detail'] = $purchase['detail'];
     // log history
     $purchaseHistory = new PurchaseHistory();
     $purchaseHistory->setUserId($currentUser->id)->setPurchaseId($params->id)->setTime(time())->setOperation('viewDetail')->setData(json_encode($logData))->save($con);
     $results['success'] = true;
     $results['data'] = $purchase['data'];
     $results['detail'] = $purchase['detail'];
     return $results;
 }