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'); } }
/** * Declares an association between this object and a ChildSecondParty object. * * @param ChildSecondParty $v * @return $this|\ORM\Sales The current object (for fluent API support) * @throws PropelException */ public function setSecondParty(ChildSecondParty $v = null) { if ($v === null) { $this->setSecondPartyId(NULL); } else { $this->setSecondPartyId($v->getId()); } $this->aSecondParty = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildSecondParty object, it will not be re-added. if ($v !== null) { $v->addSales($this); } return $this; }