public function setupBarcode()
 {
     $form_values = $this->form_values;
     $stakeholder_item_pack = new StakeholderItemPackSizes();
     if (!empty($form_values['item_pack_size_id'])) {
         $item_pack = $this->_em->find("ItemPackSizes", $form_values['item_pack_size_id']);
         $stakeholder_item_pack->setItemPackSize($item_pack);
     }
     if (!empty($form_values['stakeholder_id'])) {
         $stakeholder = $this->_em->find("Stakeholders", $form_values['stakeholder_id']);
         $stakeholder_item_pack->setStakeholder($stakeholder);
     }
     if (!empty($form_values['packaging_level'])) {
         $packaging_level = $this->_em->find("ListDetail", $form_values['packaging_level']);
         $stakeholder_item_pack->setPackagingLevel($packaging_level);
     }
     //        if (!empty($form_values['batch_length'])) {
     //
     //            $stakeholder_item_pack->setBatchLength($form_values['batch_length']);
     //        }
     $stakeholder_item_pack->setItemGtin($form_values['item_gtin']);
     //        $stakeholder_item_pack->setGtin($form_values['gtin']);
     //        $stakeholder_item_pack->setBatch($form_values['batch']);
     //        $stakeholder_item_pack->setExpiry($form_values['expiry']);
     //        $stakeholder_item_pack->setGtinStartPosition($form_values['gtin_start_position']);
     //        $stakeholder_item_pack->setBatchNoStartPosition($form_values['batch_no_start_position']);
     //        $stakeholder_item_pack->setExpiryDateStartPosition($form_values['expiry_date_start_position']);
     //        $stakeholder_item_pack->setGtinEndPosition($form_values['gtin_end_position']);
     //        $stakeholder_item_pack->setBatchNoEndPosition($form_values['batch_no_end_position']);
     //        $stakeholder_item_pack->setExpiryDateEndPosition($form_values['expiry_date_end_position']);
     $stakeholder_item_pack->setPackSizeDescription($form_values['pack_size_description']);
     $stakeholder_item_pack->setLength($form_values['length']);
     $stakeholder_item_pack->setWidth($form_values['width']);
     $stakeholder_item_pack->setHeight($form_values['height']);
     //        if (!empty($form_values['expiry_date_format'])) {
     //            //$expiry_date_format = $this->_em->find("ListDetail", $form_values['expiry_date_format']);
     //            $stakeholder_item_pack->setExpiryDateFormat($form_values['expiry_date_format']);
     //        }
     $stakeholder_item_pack->setQuantityPerPack($form_values['quantity_per_pack']);
     $stakeholder_item_pack->setVolumPerVial($form_values['volume_per_unit_net']);
     //        $stakeholder_item_pack->setPrePrintedBarcode($form_values['pre_printed_barcode']);
     $user_id = $this->_em->getRepository('Users')->find($this->_user_id);
     $stakeholder_item_pack->setCreatedBy($user_id);
     $stakeholder_item_pack->setCreatedDate(App_Tools_Time::now());
     $stakeholder_item_pack->setModifiedBy($user_id);
     $stakeholder_item_pack->setModifiedDate(App_Tools_Time::now());
     $this->_em->persist($stakeholder_item_pack);
     $this->_em->flush();
 }
Exemplo n.º 2
0
 public function addStakeholder()
 {
     $data = $this->form_values;
     //  App_Controller_Functions::pr($data);
     $id = $this->checkManufacturer();
     if ($id == false) {
         $stakeholder = new Stakeholders();
         $stakeholder->setStakeholderName($data['name']);
         $type = $this->_em->getRepository("StakeholderTypes")->findOneBy(array("stakeholderTypeName" => 'Manufacturer'));
         $stakeholder->setStakeholderType($type);
         $main_stakeholder = $this->_em->getRepository("Stakeholders")->findOneBy(array("stakeholderName" => 'EPI Program'));
         $stakeholder->setMainStakeholder($main_stakeholder);
         $stakeholder_activity = $this->_em->getRepository("StakeholderActivities")->findOneBy(array("activity" => 'Routine'));
         $stakeholder->setStakeholderActivity($stakeholder_activity);
         $geo_level = $this->_em->getRepository("GeoLevels")->find("1");
         $stakeholder->setGeoLevel($geo_level);
         $stakeholder->setParent($main_stakeholder);
         $sector = $this->_em->find("StakeholderSectors", 1);
         $stakeholder->setStakeholderSector($sector);
         $this->_em->persist($stakeholder);
         $this->_em->flush();
         $id = $stakeholder->getPkId();
     }
     $check_stak_items = $this->_em->getRepository("StakeholderItemPackSizes")->findOneBy(array("stakeholder" => $id, "itemPackSize" => $data['item_id']));
     if (count($check_stak_items) == 0) {
         $stakeholder_items = new StakeholderItemPackSizes();
         $stakeholder_id = $this->_em->getRepository("Stakeholders")->find($id);
         $stakeholder_items->setStakeholder($stakeholder_id);
         $stakeholder_items->setQuantityPerPack($data['quantity']);
         $item_id = $this->_em->getRepository("ItemPackSizes")->find($data['item_id']);
         $stakeholder_items->setItemPackSize($item_id);
         $pck_id = $this->_em->getRepository("ListDetail")->find('140');
         $stakeholder_items->setPackagingLevel($pck_id);
         $this->_em->persist($stakeholder_items);
         $this->_em->flush();
     }
     return true;
 }
 public function setQuantityPerPack($quantityPerPack)
 {
     $this->__load();
     return parent::setQuantityPerPack($quantityPerPack);
 }
Exemplo n.º 4
0
 public function createBatch($array)
 {
     $batchid = $this->checkBatch($array);
     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'])));
         $item_id = $this->_em->getRepository('ItemPackSizes')->find($array['item_id']);
         $stock_batch->setItemPackSize($item_id);
         $stock_batch->setQuantity(str_replace(",", "", $array['quantity']));
         $stock_batch->setStatus(self::STACKED);
         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']);
         $warehouse_id = $this->_em->getRepository('Warehouses')->find($wh_id);
         $stock_batch->setWarehouse($warehouse_id);
         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']) {
                 $stock_batch->setStakeholderItemPackSize($stakeholder_item_pack_size);
             } 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) {
                     $stock_batch->setStakeholderItemPackSize($check_sips);
                 } else {
                     $add_sips = new StakeholderItemPackSizes();
                     $add_sips->setQuantityPerPack($stakeholder_item_pack_size->getQuantityPerPack());
                     $add_sips->setStatus($stakeholder_item_pack_size->getStatus());
                     $add_sips->setListRank($stakeholder_item_pack_size->getListRank());
                     $add_sips->setVolumPerVial($stakeholder_item_pack_size->getVolumPerVial());
                     $add_sips->setGtin($stakeholder_item_pack_size->getGtin());
                     $add_sips->setItemGtin($stakeholder_item_pack_size->getItemGtin());
                     $add_sips->setPackagingLevel($stakeholder_item_pack_size->getPackagingLevel());
                     $add_sips->setStakeholder($stakeholder_item_pack_size->getStakeholder());
                     $add_sips->setItemPackSize($item_id);
                     $this->_em->persist($add_sips);
                     $this->_em->flush();
                     $stock_batch->setStakeholderItemPackSize($add_sips);
                 }
             }
         }
         $this->_em->persist($stock_batch);
         $this->_em->flush();
         $batchid = $stock_batch->getPkId();
         if ($wh_id == Model_Warehouses::FEDERAL_WHID) {
             $stock_batch->setBatchMasterId($batchid);
             $this->_em->persist($stock_batch);
             $this->_em->flush();
         }
         if ($batchid) {
             return $batchid;
         } else {
             return false;
         }
     } else {
         return $batchid;
     }
 }