public function setQuantityPerPack($quantityPerPack) { $this->__load(); return parent::setQuantityPerPack($quantityPerPack); }
public function createBatch($array) { $batchid = $this->checkBatch($array); $created_by = $this->_em->getRepository('Users')->find($this->_user_id); if ($batchid === 0) { $wh_id = $this->_identity->getWarehouseId(); $stock_batch = new StockBatch(); $stock_batch->setNumber(strtoupper($array['number'])); $stock_batch->setExpiryDate(new \DateTime(App_Controller_Functions::dateToDbFormat($array['expiry_date']))); if (!empty($array['production_date'])) { $stock_batch->setProductionDate(new \DateTime(App_Controller_Functions::dateToDbFormat($array['production_date']))); } if (!empty($array['vvm_type_id'])) { $vvm_type_id = $this->_em->getRepository('VvmTypes')->find($array['vvm_type_id']); $stock_batch->setVvmType($vvm_type_id); } $stock_batch->setUnitPrice($array['unit_price']); if (!empty($array['manufacturer_id'])) { $stakeholder_item_pack_size = $this->_em->getRepository('StakeholderItemPackSizes')->find($array['manufacturer_id']); if ($stakeholder_item_pack_size->getItemPackSize()->getPkId() == $array['item_id']) { $pack_info_id = $this->_em->getRepository('PackInfo')->findOneBy(array("stakeholderItemPackSize" => $stakeholder_item_pack_size->getPkId(), "packagingLevel" => '140')); $stock_batch->setPackInfo($pack_info_id); } else { $check_sips = $this->_em->getRepository('StakeholderItemPackSizes')->findOneBy(array("stakeholder" => $stakeholder_item_pack_size->getStakeholder()->getPkId(), "itemPackSize" => $array['item_id'])); if (count($check_sips) > 0) { // echo $check_sips->getPkId(); // exit; $pack_info_id = $this->_em->getRepository('PackInfo')->findOneBy(array("stakeholderItemPackSize" => $check_sips->getPkId(), "packagingLevel" => '140')); $stock_batch->setPackInfo($pack_info_id); } else { $add_sips = new StakeholderItemPackSizes(); $add_sips->setStakeholder($stakeholder_item_pack_size->getStakeholder()); $item_pack_size_id = $this->_em->getRepository('ItemPackSizes')->find($array['item_id']); $add_sips->setItemPackSize($item_pack_size_id); $add_sips->setModifiedBy($created_by); $add_sips->setModifiedDate(App_Tools_Time::now()); $add_sips->setCreatedBy($created_by); $add_sips->setCreatedDate(App_Tools_Time::now()); $this->_em->persist($add_sips); $this->_em->flush(); $sips_id = $add_sips->getPkId(); $pack_info_id_add = $this->_em->getRepository('PackInfo')->findOneBy(array("stakeholderItemPackSize" => $stakeholder_item_pack_size->getPkId(), "packagingLevel" => '140')); $pack_info = new PackInfo(); $stakholder_item_pack_id = $this->_em->getRepository('StakeholderItemPackSizes')->find($sips_id); $pack_info->setStakeholderItemPackSize($stakholder_item_pack_id); $pack_info->setQuantityPerPack($pack_info_id_add->getQuantityPerPack()); $pack_info->setStatus($pack_info_id_add->getStatus()); $pack_info->setListRank($pack_info_id_add->getListRank()); $pack_info->setVolumPerVial($pack_info_id_add->getVolumPerVial()); $pack_info->setItemGtin($pack_info_id_add->getItemGtin()); $pack_info->setPackagingLevel($pack_info_id_add->getPackagingLevel()); $pack_info->setModifiedBy($created_by); $pack_info->setModifiedDate(App_Tools_Time::now()); $pack_info->setCreatedBy($created_by); $pack_info->setCreatedDate(App_Tools_Time::now()); $this->_em->persist($pack_info); $this->_em->flush(); $stock_batch->setPackInfo($pack_info); } } } $stock_batch->setModifiedBy($created_by); $stock_batch->setModifiedDate(App_Tools_Time::now()); $stock_batch->setCreatedBy($created_by); $stock_batch->setCreatedDate(App_Tools_Time::now()); $this->_em->persist($stock_batch); $this->_em->flush(); $batchid = $stock_batch->getPkId(); $stock_batch_warehouses = new StockBatchWarehouses(); $stock_batch_warehouses->setQuantity(str_replace(",", "", $array['quantity'])); $stock_batch_warehouses->setStatus(self::STACKED); $warehouse_id = $this->_em->getRepository('Warehouses')->find($wh_id); $stock_batch_warehouses->setWarehouse($warehouse_id); $stock_batch_id = $this->_em->getRepository('StockBatch')->find($batchid); $stock_batch_warehouses->setStockBatch($stock_batch_id); $stock_batch_warehouses->setModifiedBy($created_by); $stock_batch_warehouses->setModifiedDate(App_Tools_Time::now()); $stock_batch_warehouses->setCreatedBy($created_by); $stock_batch_warehouses->setCreatedDate(App_Tools_Time::now()); $this->_em->persist($stock_batch_warehouses); $this->_em->flush(); $stockBatchWarehousId = $stock_batch_warehouses->getPkId(); if ($stockBatchWarehousId) { return $stockBatchWarehousId; } else { return false; } } else { return $batchid; } }