Esempio n. 1
0
 /**
  * Returns a new ChildSecondPartyQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return ChildSecondPartyQuery
  */
 public static function create($modelAlias = null, Criteria $criteria = null)
 {
     if ($criteria instanceof ChildSecondPartyQuery) {
         return $criteria;
     }
     $query = new ChildSecondPartyQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Esempio n. 2
0
 public static function supplier($params, $currentUser, $con)
 {
     $suppliers = SecondPartyQuery::create()->filterByStatus('Active')->filterByType('Supplier')->orderBy('name', 'ASC');
     if (isset($params->query)) {
         $suppliers->where('SecondParty.Name like ?', "%{$params->query}%");
     }
     $suppliers = $suppliers->select(array('id', 'name'))->limit(20)->find($con);
     $data = [];
     foreach ($suppliers as $supplier) {
         $data[] = $supplier;
     }
     $results['success'] = true;
     $results['data'] = $data;
     return $results;
 }
Esempio n. 3
0
 public static function update($params, $currentUser, $con)
 {
     // check role's permission
     $permission = RolePermissionQuery::create()->select('update_second_party')->findOneById($currentUser->role_id, $con);
     if (!$permission || $permission != 1) {
         throw new \Exception('Akses ditolak. Anda tidak mempunyai izin untuk melakukan operasi ini.');
     }
     $supplier = SecondPartyQuery::create()->filterByStatus('Active')->findOneById($params->id, $con);
     if (!$supplier) {
         throw new \Exception('Data tidak ditemukan');
     }
     $supplier->setName($params->name)->setAddress($params->address)->setPhone($params->phone)->save($con);
     $rowHistory = new RowHistory();
     $rowHistory->setRowId($params->id)->setData('supplier')->setTime(time())->setOperation('update')->setUserId($currentUser->id)->save($con);
     $results['success'] = true;
     $results['data'] = $params;
     return $results;
 }
Esempio n. 4
0
 /**
  * Performs an INSERT on the database, given a SecondParty or Criteria object.
  *
  * @param mixed               $criteria Criteria or SecondParty object containing data that is used to create the INSERT statement.
  * @param ConnectionInterface $con the ConnectionInterface connection to use
  * @return mixed           The new primary key.
  * @throws PropelException Any exceptions caught during processing will be
  *                         rethrown wrapped into a PropelException.
  */
 public static function doInsert($criteria, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(SecondPartyTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from SecondParty object
     }
     if ($criteria->containsKey(SecondPartyTableMap::COL_ID) && $criteria->keyContainsValue(SecondPartyTableMap::COL_ID)) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . SecondPartyTableMap::COL_ID . ')');
     }
     // Set the correct dbName
     $query = SecondPartyQuery::create()->mergeWith($criteria);
     // use transaction because $criteria could contain info
     // for more than one table (I guess, conceivably)
     return $con->transaction(function () use($con, $query) {
         return $query->doInsert($con);
     });
 }
Esempio n. 5
0
 /**
  * Get the associated ChildSecondParty object
  *
  * @param  ConnectionInterface $con Optional Connection object.
  * @return ChildSecondParty The associated ChildSecondParty object.
  * @throws PropelException
  */
 public function getSecondParty(ConnectionInterface $con = null)
 {
     if ($this->aSecondParty === null && ($this->second_party_id !== "" && $this->second_party_id !== null)) {
         $this->aSecondParty = ChildSecondPartyQuery::create()->findPk($this->second_party_id, $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->aSecondParty->addSaless($this);
            */
     }
     return $this->aSecondParty;
 }