예제 #1
0
 public static function create($params, $currentUser, $con)
 {
     // check role's permission
     $permission = RolePermissionQuery::create()->select('create_user')->findOneById($currentUser->role_id, $con);
     if (!$permission || $permission != 1) {
         throw new \Exception('Akses ditolak. Anda tidak mempunyai izin untuk melakukan operasi ini.');
     }
     // check if picked username is already used by anyone
     $user = UserQuery::create()->filterByUser($params->user)->count($con);
     if ($user != 0) {
         throw new \Exception('User ID sudah terpakai. Pilih User ID lainnya.');
     }
     // create new user
     $user = new User();
     $user->setUser($params->user)->setPassword(hash('sha512', $params->user))->setRoleId($params->role_id)->setStatus('Active')->save($con);
     // create user detail
     $userDetail = new UserDetail();
     $userDetail->setId($user->getId())->setName($params->name)->setAddress($params->address)->setPhone($params->phone)->save($con);
     // insert into row_history table
     $rowHistory = new RowHistory();
     $rowHistory->setRowId($user->getId())->setData('user')->setTime(time())->setOperation('create')->setUserId($currentUser->id)->save($con);
     $results['success'] = true;
     $results['id'] = $user->getId();
     return $results;
 }
예제 #2
0
 /**
  * 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->aUserDetail) {
         $this->aUserDetail->removeHistory($this);
     }
     $this->id = null;
     $this->data = null;
     $this->row_id = null;
     $this->time = null;
     $this->operation = null;
     $this->user_id = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
예제 #3
0
 /**
  * Filter the query by a related \ORM\UserDetail object
  *
  * @param \ORM\UserDetail|ObjectCollection $userDetail The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildCreditPaymentQuery The current query, for fluid interface
  */
 public function filterByCashier($userDetail, $comparison = null)
 {
     if ($userDetail instanceof \ORM\UserDetail) {
         return $this->addUsingAlias(CreditPaymentTableMap::COL_CASHIER_ID, $userDetail->getId(), $comparison);
     } elseif ($userDetail instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(CreditPaymentTableMap::COL_CASHIER_ID, $userDetail->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByCashier() only accepts arguments of type \\ORM\\UserDetail or Collection');
     }
 }
예제 #4
0
 /**
  * Exclude object from result
  *
  * @param   ChildUserDetail $userDetail Object to remove from the list of results
  *
  * @return $this|ChildUserDetailQuery The current query, for fluid interface
  */
 public function prune($userDetail = null)
 {
     if ($userDetail) {
         $this->addUsingAlias(UserDetailTableMap::COL_ID, $userDetail->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
예제 #5
0
 /**
  * Filter the query by a related \ORM\UserDetail object
  *
  * @param \ORM\UserDetail|ObjectCollection $userDetail  the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildUserQuery The current query, for fluid interface
  */
 public function filterByDetail($userDetail, $comparison = null)
 {
     if ($userDetail instanceof \ORM\UserDetail) {
         return $this->addUsingAlias(UserTableMap::COL_ID, $userDetail->getId(), $comparison);
     } elseif ($userDetail instanceof ObjectCollection) {
         return $this->useDetailQuery()->filterByPrimaryKeys($userDetail->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByDetail() only accepts arguments of type \\ORM\\UserDetail or Collection');
     }
 }
예제 #6
0
 /**
  * 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->aDebit) {
         $this->aDebit->removePayment($this);
     }
     if (null !== $this->aCashier) {
         $this->aCashier->removeDebitPayment($this);
     }
     $this->id = null;
     $this->date = null;
     $this->debit_id = null;
     $this->cashier_id = null;
     $this->paid = null;
     $this->status = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
예제 #7
0
파일: Sales.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->aSecondParty) {
         $this->aSecondParty->removeSales($this);
     }
     if (null !== $this->aCashier) {
         $this->aCashier->removeSales($this);
     }
     $this->id = null;
     $this->date = null;
     $this->second_party_id = null;
     $this->buy_price = null;
     $this->total_price = null;
     $this->paid = null;
     $this->cashier_id = null;
     $this->note = null;
     $this->status = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
예제 #8
0
파일: User.php 프로젝트: AlvaCorp/POS-2
 /**
  * Sets a single ChildUserDetail object as related to this object by a one-to-one relationship.
  *
  * @param  ChildUserDetail $v ChildUserDetail
  * @return $this|\ORM\User The current object (for fluent API support)
  * @throws PropelException
  */
 public function setDetail(ChildUserDetail $v = null)
 {
     $this->singleDetail = $v;
     // Make sure that that the passed-in ChildUserDetail isn't already associated with this object
     if ($v !== null && $v->getUser(null, false) === null) {
         $v->setUser($this);
     }
     return $this;
 }