コード例 #1
0
ファイル: Units.php プロジェクト: iHunt101/POS-ws-server
 public static function create($params, $currentUser, $con)
 {
     // check role's permission
     $permission = RolePermissionQuery::create()->select('create_unit')->findOneById($currentUser->role_id, $con);
     if (!$permission || $permission != 1) {
         throw new \Exception('Akses ditolak. Anda tidak mempunyai izin untuk melakukan operasi ini.');
     }
     // check whether unit is already exist
     $unit = UnitQuery::create()->filterByStatus('Active')->filterByName($params->name)->count($con);
     if ($unit != 0) {
         throw new \Exception('Satuan ' . $params->name . ' sudah ada dalam data');
     }
     // create new record
     $unit = new Unit();
     $unit->setName($params->name)->setStatus('Active')->save($con);
     // log history
     $rowHistory = new RowHistory();
     $rowHistory->setRowId($unit->getId())->setData('unit')->setTime(time())->setOperation('create')->setUserId($currentUser->id)->save($con);
     $params->id = $unit->getId();
     $results['success'] = true;
     $results['data'] = $params;
     return $results;
 }
コード例 #2
0
ファイル: Stock.php プロジェクト: AlvaCorp/POS-2
 /**
  * Clears the current object, sets all attributes to their default values and removes
  * outgoing references as well as back-references (from other objects to this one. Results probably in a database
  * change of those foreign objects when you call `save` there).
  */
 public function clear()
 {
     if (null !== $this->aProduct) {
         $this->aProduct->removeStock($this);
     }
     if (null !== $this->aUnit) {
         $this->aUnit->removeStock($this);
     }
     $this->id = null;
     $this->product_id = null;
     $this->amount = null;
     $this->unit_id = null;
     $this->buy = null;
     $this->sell_public = null;
     $this->sell_distributor = null;
     $this->sell_misc = null;
     $this->discount = null;
     $this->unlimited = null;
     $this->status = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
コード例 #3
0
ファイル: StockQuery.php プロジェクト: AlvaCorp/POS-2
 /**
  * Filter the query by a related \ORM\Unit object
  *
  * @param \ORM\Unit|ObjectCollection $unit The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildStockQuery The current query, for fluid interface
  */
 public function filterByUnit($unit, $comparison = null)
 {
     if ($unit instanceof \ORM\Unit) {
         return $this->addUsingAlias(StockTableMap::COL_UNIT_ID, $unit->getId(), $comparison);
     } elseif ($unit instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(StockTableMap::COL_UNIT_ID, $unit->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByUnit() only accepts arguments of type \\ORM\\Unit or Collection');
     }
 }
コード例 #4
0
ファイル: UnitQuery.php プロジェクト: AlvaCorp/POS-2
 /**
  * Exclude object from result
  *
  * @param   ChildUnit $unit Object to remove from the list of results
  *
  * @return $this|ChildUnitQuery The current query, for fluid interface
  */
 public function prune($unit = null)
 {
     if ($unit) {
         $this->addUsingAlias(UnitTableMap::COL_ID, $unit->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }