/**
  * Filter the query by a related Supplier object
  *
  * @param   Supplier|PropelObjectCollection $supplier The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 BarangMasukQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterBySupplier($supplier, $comparison = null)
 {
     if ($supplier instanceof Supplier) {
         return $this->addUsingAlias(BarangMasukPeer::ID_SUPPLIER, $supplier->getId(), $comparison);
     } elseif ($supplier instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(BarangMasukPeer::ID_SUPPLIER, $supplier->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterBySupplier() only accepts arguments of type Supplier or PropelCollection');
     }
 }
예제 #2
0
 /**
  * Declares an association between this object and a Supplier object.
  *
  * @param                  Supplier $v
  * @return BarangMasuk The current object (for fluent API support)
  * @throws PropelException
  */
 public function setSupplier(Supplier $v = null)
 {
     if ($v === null) {
         $this->setIdSupplier(NULL);
     } else {
         $this->setIdSupplier($v->getId());
     }
     $this->aSupplier = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Supplier object, it will not be re-added.
     if ($v !== null) {
         $v->addBarangMasuk($this);
     }
     return $this;
 }
예제 #3
0
 /**
  * Creating a supplier code
  *
  * @param Product  $product
  * @param Supplier $supplier
  * @param string   $code
  *
  * @return SupplierCode
  */
 public static function create(Product $product, Supplier $supplier, $code, $canSupplyQty = 0)
 {
     $class = __CLASS__;
     $objects = self::getAllByCriteria('productId = ? and supplierId = ? and code like ?', array($product->getId(), $supplier->getId(), trim($code)), true, 1, 1);
     $obj = count($objects) > 0 ? $objects[0] : new $class();
     return $obj->setProduct($product)->setSupplier($supplier)->setCode(trim($code))->save();
 }
 /**
  * Exclude object from result
  *
  * @param   Supplier $supplier Object to remove from the list of results
  *
  * @return SupplierQuery The current query, for fluid interface
  */
 public function prune($supplier = null)
 {
     if ($supplier) {
         $this->addUsingAlias(SupplierPeer::ID, $supplier->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
예제 #5
0
 public static function create(Supplier $supplier, $manufacturer = null, $category = null, $priceMatchRule = null)
 {
     if ($manufacturer !== null && !$manufacturer instanceof Manufacturer) {
         throw new Exception('Invalid manufacture passed in. It must be a null or instance of Manufacturer. "' . $manufacturer . '" passed in.');
     }
     if ($category !== null && !$category instanceof ProductCategory) {
         throw new Exception('Invalid category passed in. It must be a null or instance of ProductCategory. "' . $category . '" passed in.');
     }
     if ($priceMatchRule !== null && !$priceMatchRule instanceof ProductPriceMatchRule) {
         throw new Exception('Invalid priceMatchRule passed in. It must be a null or instance of ProductPriceMatchRule. "' . $priceMatchRule . '" passed in.');
     }
     $existObj = self::getAllByCriteria('supplierId = ? and manufacturerId = ? and categoryId = ?', array($supplier->getId(), $manufacturer instanceof Manufacturer ? $manufacturer->getId() : null, $priceMatchRule instanceof ProductPriceMatchRule ? $priceMatchRule->getId() : null), false, 1, 1, array('id' => 'desc'));
     $obj = $existObj > 0 ? $existObj[0] : new self();
     $obj->setSupplier($supplier)->setmanufacturer($manufacturer)->setCategory($category)->setpriceMatchRule($priceMatchRule)->setActive(true)->save();
     return $obj;
 }
예제 #6
0
 /**
  * removing the suppler
  *
  * @param ProductPriceType $type
  *
  * @return Product
  */
 public function removeSupplier(Supplier $supplier, $supplierCode = '')
 {
     $where = 'productId = ? and suplierId = ?';
     $params = array($this->getId(), $supplier->getId());
     if (trim($supplierCode) !== '') {
         $where .= ' AND code like = ?';
         $params[] = trim($supplierCode);
     }
     SupplierCode::updateByCriteria('active = 0', $where, $params);
     return $this;
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param Supplier $obj A Supplier object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         SupplierPeer::$instances[$key] = $obj;
     }
 }