public static function create($params, $currentUser, $con) { // check role's permission $permission = RolePermissionQuery::create()->select('create_second_party')->findOneById($currentUser->role_id, $con); if (!$permission || $permission != 1) { throw new \Exception('Akses ditolak. Anda tidak mempunyai izin untuk melakukan operasi ini.'); } // create new record $supplier = new SecondParty(); $supplier->setRegisteredDate(Date('Y-m-d'))->setName($params->name)->setAddress($params->address)->setPhone($params->phone)->setType('Supplier')->setStatus('Active')->save($con); // log history $rowHistory = new RowHistory(); $rowHistory->setRowId($supplier->getId())->setData('supplier')->setTime(time())->setOperation('create')->setUserId($currentUser->id)->save($con); $params->id = $supplier->getId(); $results['success'] = true; $results['data'] = $params; return $results; }
/** * Exclude object from result * * @param ChildSecondParty $secondParty Object to remove from the list of results * * @return $this|ChildSecondPartyQuery The current query, for fluid interface */ public function prune($secondParty = null) { if ($secondParty) { $this->addUsingAlias(SecondPartyTableMap::COL_ID, $secondParty->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Filter the query by a related \ORM\SecondParty object * * @param \ORM\SecondParty|ObjectCollection $secondParty The related object(s) 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 filterBySecondParty($secondParty, $comparison = null) { if ($secondParty instanceof \ORM\SecondParty) { return $this->addUsingAlias(PurchaseTableMap::COL_SECOND_PARTY_ID, $secondParty->getId(), $comparison); } elseif ($secondParty instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(PurchaseTableMap::COL_SECOND_PARTY_ID, $secondParty->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterBySecondParty() only accepts arguments of type \\ORM\\SecondParty or Collection'); } }
/** * 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); }