Exemplo n.º 1
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 getModifiedBy()
 {
     $this->__load();
     return parent::getModifiedBy();
 }
 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->setVolumePerUnitNet($form_values['volume_per_unit_net']);
     $stakeholder_item_pack->setPrePrintedBarcode($form_values['pre_printed_barcode']);
     $this->_em->persist($stakeholder_item_pack);
     $this->_em->flush();
 }
 public function ajaxUpdateBarcodeAction()
 {
     $this->_helper->layout->setLayout('ajax');
     $stakeholder_item_pack = new StakeholderItemPackSizes();
     $barcode_type_id = $this->_request->getParam('barcode_type_id');
     $form = new Form_Iadmin_SetupBarcode();
     /* if ($barcode_type_id != Model_StakeholderItemPackSizes::NON_GSI) {
        $form->readOnlyFields();
        $form->gtin->setValue(Model_StakeholderItemPackSizes::GTIN);
        $form->batch->setValue(Model_StakeholderItemPackSizes::BATCH);
        $form->expiry->setValue(Model_StakeholderItemPackSizes::EXPIRY);
        $form->gtin_start_position->setValue(Model_StakeholderItemPackSizes::GTIN_START);
        $form->batch_no_start_position->setValue(Model_StakeholderItemPackSizes::BATCH_START);
        $form->expiry_date_start_position->setValue(Model_StakeholderItemPackSizes::EXPIRY_START);
        $form->gtin_end_position->setValue(Model_StakeholderItemPackSizes::GTIN_END);
        $form->batch_no_end_position->setValue(Model_StakeholderItemPackSizes::BATCH_END);
        $form->expiry_date_end_position->setValue(Model_StakeholderItemPackSizes::EXPIRY_END);
        } else { */
     $form->gtin->setValue($stakeholder_item_pack->getGtin());
     $form->batch->setValue($stakeholder_item_pack->getBatch());
     $form->expiry->setValue($stakeholder_item_pack->getExpiry());
     $form->gtin_start_position->setValue($stakeholder_item_pack->getGtinStartPosition());
     $form->batch_no_start_position->setValue($stakeholder_item_pack->getBatchNoStartPosition());
     $form->expiry_date_start_position->setValue($stakeholder_item_pack->getExpiryDateStartPosition());
     $form->gtin_end_position->setValue($stakeholder_item_pack->getGtinEndPosition());
     $form->batch_no_end_position->setValue($stakeholder_item_pack->getBatchNoEndPosition());
     $form->expiry_date_end_position->setValue($stakeholder_item_pack->getExpiryDateEndPosition());
     //}
     $this->view->form = $form;
 }
Exemplo n.º 5
0
 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;
     }
 }
 public function getPackagingLevel()
 {
     $this->__load();
     return parent::getPackagingLevel();
 }
 public function stakeholderItemsAction()
 {
     $form = new Form_Iadmin_StakeholderItem();
     if ($this->_request->isPost()) {
         $form_values = $this->_request->getPost();
         $stakeholder_id = $form_values['stakeholder'];
         $stakeholders = new Model_Stakeholders();
         $stakeholder_item_id = $this->_em->getRepository("StakeholderItemPackSizes")->findBy(array('stakeholder' => $stakeholder_id));
         foreach ($stakeholder_item_id as $stakeholder_id_a) {
             $stk_id = $this->_em->find('StakeholderItemPackSizes', $stakeholder_id_a->getPkId());
             $this->_em->remove($stk_id);
             $this->_em->flush();
         }
         foreach ($form_values['items'] as $stakeholderItemId) {
             $stakeholder_items = new StakeholderItemPackSizes();
             $item_pack_size_id = $this->_em->find('ItemPackSizes', $stakeholderItemId);
             $stakeholder_items->setItemPackSize($item_pack_size_id);
             $stakeholders = $this->_em->find('Stakeholders', $stakeholder_id);
             $stakeholder_items->setStakeholder($stakeholders);
             $this->_em->persist($stakeholder_items);
             $this->_em->flush();
         }
         $this->_redirect("/iadmin/manage-stakeholders/stakeholder-items?e=1");
     }
     $this->view->form = $form;
 }
Exemplo n.º 8
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;
     }
 }