Example #1
0
 public function addRefrigerator()
 {
     $form_values = $this->form_values;
     $cold_chain = new ColdChain();
     $cold_chain->setAssetId($form_values['asset_id']);
     $source_id = $this->_em->getRepository('Stakeholders')->find($form_values['source_id']);
     $cold_chain->setSource($source_id);
     $model_id = $this->_em->getRepository('CcmModels')->find($form_values['catalogue_id']);
     $cold_chain->setCcmModel($model_id);
     $asset_type = $this->_em->getRepository('CcmAssetTypes')->find($model_id->getCcmAssetType()->getPkId());
     $cold_chain->setCcmAssetType($asset_type);
     if (!empty($form_values['temperature_monitor'])) {
         $temperature_monitor = $this->_em->getRepository('ListDetail')->find($form_values['temperature_monitor']);
         $cold_chain->setTemperatureMonitor($temperature_monitor);
     }
     $cold_chain->setSerialNumber($form_values['serial_number']);
     $cold_chain->setWorkingSince(new \DateTime(App_Controller_Functions::dateToDbFormat($form_values['working_since'])));
     $auto_gen_id = App_Controller_Functions::generateCcemUniqueAssetId(Model_CcmAssetTypes::REFRIGERATOR);
     $cold_chain->setAutoAssetId($auto_gen_id);
     $user_id = $this->_em->getRepository('Users')->find($this->_user_id);
     $cold_chain->setCreatedBy($user_id);
     $cold_chain->setCreatedDate(new \DateTime(App_Controller_Functions::dateToDbFormat(date("d/m/Y"))));
     if (!empty($form_values['warehouse']) && $form_values['placed_at'] == 1) {
         $wh_id = $this->_em->getRepository('Warehouses')->find($form_values['warehouse']);
         $cold_chain->setWarehouse($wh_id);
     }
     $this->_em->persist($cold_chain);
     $this->_em->flush();
     $ccm_id = $cold_chain->getPkId();
     // if (!empty($form_values['warehouse']) && $form_values['placed_at'] == 1) {
     $ccm_status_history = new CcmStatusHistory();
     $ccm_status_history->setStatusDate(new \DateTime(date("Y-m-d h:i")));
     $cold_chian_id = $this->_em->getRepository('ColdChain')->find($ccm_id);
     $ccm_status_history->setCcm($cold_chian_id);
     if (!empty($form_values['warehouse']) && $form_values['placed_at'] == 1) {
         $warehouse_id = $this->_em->getRepository('Warehouses')->find($form_values['warehouse']);
         $ccm_status_history->setWarehouse($warehouse_id);
     } else {
         $warehouse_id = $this->_em->getRepository('Warehouses')->find($this->_identity->getWarehouseId());
         $ccm_status_history->setWarehouse($warehouse_id);
     }
     $ccm_status_list_id = $this->_em->getRepository('CcmStatusList')->find($form_values['ccm_status_list_id']);
     $ccm_status_history->setCcmStatusList($ccm_status_list_id);
     $asset_id = $this->_em->getRepository('CcmAssetTypes')->find(Model_CcmAssetTypes::REFRIGERATOR);
     $ccm_status_history->setCcmAssetType($asset_id);
     if (!empty($form_values['reason'])) {
         $reason = $this->_em->getRepository('CcmStatusList')->find($form_values['reason']);
         $ccm_status_history->setReason($reason);
     }
     if (!empty($form_values['utilization'])) {
         $utilization = $this->_em->getRepository('CcmStatusList')->find($form_values['utilization']);
         $ccm_status_history->setUtilization($utilization);
     }
     $this->_em->persist($ccm_status_history);
     $this->_em->flush();
     $ccm_history_id = $ccm_status_history->getPkId();
     $this->updateCcmStatusHistory($ccm_id, $ccm_history_id);
     //  }
     $placements_locations = new PlacementLocations();
     $location_type = $this->_em->getRepository('ListDetail')->find(Model_PlacementLocations::LOCATIONTYPE_CCM);
     $placements_locations->setLocationType($location_type);
     $placements_locations->setLocationBarcode($auto_gen_id);
     $placements_locations->setLocationId($ccm_id);
     $this->_em->persist($placements_locations);
     $this->_em->flush();
     $ware_house = $form_values['warehouse'];
     if (!empty($ware_house)) {
         $qry = "SELECT REPUpdateCapacity({$ware_house}) from DUAL";
         $row = $this->_em->getConnection()->prepare($qry);
         $row->execute();
         $qry1 = "SELECT REPUpdateRequirement({$ware_house}) from DUAL";
         $row1 = $this->_em->getConnection()->prepare($qry1);
         $row1->execute();
     }
 }
 public function setLocationId($locationId)
 {
     $this->__load();
     return parent::setLocationId($locationId);
 }
 public function addColdRoom()
 {
     // App_Controller_Functions::pr($this->form_values);
     $form_values = $this->form_values;
     $ccm_model = $this->_em->getRepository('CcmModels')->find($form_values['ccm_model_id']);
     $ccm_model->setAssetDimensionLength($form_values['asset_dimension_length']);
     $ccm_model->setAssetDimensionWidth($form_values['asset_dimension_width']);
     $ccm_model->setAssetDimensionHeight($form_values['asset_dimension_height']);
     if ($form_values['ccm_asset_sub_type_id'] == Model_CcmAssetTypes::SUBFREEZERROOM) {
         //for -20'C Freezer room
         $ccm_model->setTemperatureType(1);
         $ccm_model->setNetCapacity20($form_values['net_capacity']);
         $ccm_model->setGrossCapacity20($form_values['gross_capacity']);
     } elseif ($form_values['ccm_asset_sub_type_id'] == Model_CcmAssetTypes::SUBCOLDROOM) {
         //for +4'C Cold room
         $ccm_model->setTemperatureType(0);
         $ccm_model->setNetCapacity4($form_values['net_capacity']);
         $ccm_model->setGrossCapacity4($form_values['gross_capacity']);
     }
     $user_id = $this->_em->getRepository('Users')->find($this->_user_id);
     $ccm_model->setCreatedBy($user_id);
     $ccm_model->setCreatedDate(App_Tools_Time::now());
     $ccm_model->setModifiedBy($user_id);
     $ccm_model->setModifiedDate(App_Tools_Time::now());
     $this->_em->persist($ccm_model);
     $this->_em->flush();
     //        $cold_chain = new ColdChain();
     //        $cold_chain->setAssetId($form_values['asset_id']);
     //      //  $cold_chain->setAutoAssetId(App_Controller_Functions::generateCcemUniqueAssetId($form_values['ccm_asset_sub_type_id']));
     //        //$status_list = $this->_em->getRepository('CcmStatusList')->find($form_values['ccm_status_list_id']);
     //        //$cold_chain->setCcmStatusList($status_list);
     //        $model_id = $this->_em->getRepository('CcmModels')->find($form_values['ccm_model_id']);
     //        $cold_chain->setCcmModel($model_id);
     //        $asset_type = $this->_em->getRepository('CcmAssetTypes')->find($form_values['ccm_asset_sub_type_id']);
     //        $cold_chain->setCcmAssetType($asset_type);
     //        $auto_gen_id = App_Controller_Functions::generateCcemUniqueAssetId(Model_CcmAssetTypes::COLDROOM);
     //        $cold_chain->setAutoAssetId($auto_gen_id);
     //
     //        $cold_chain->setWorkingSince(new \DateTime(App_Controller_Functions::dateToDbFormat($form_values['working_since'])));
     //        $user_id_1 = $this->_em->getRepository('Users')->find($this->_user_id);
     //        $cold_chain->setCreatedBy($user_id_1);
     //        $cold_chain->setCreatedDate(App_Tools_Time::now());
     //        if (!empty($form_values['warehouse']) && $form_values['placed_at'] == 1) {
     //            $wh_id = $this->_em->getRepository('Warehouses')->find($form_values['warehouse']);
     //            $cold_chain->setWarehouse($wh_id);
     //        }
     //        $this->_em->persist($cold_chain);
     //        $this->_em->flush();
     $cold_chain = new ColdChain();
     $cold_chain->setAssetId($form_values['asset_id']);
     $model_id = $this->_em->getRepository('CcmModels')->find($form_values['ccm_model_id']);
     $cold_chain->setCcmModel($model_id);
     $asset_type = $this->_em->getRepository('CcmAssetTypes')->find($form_values['ccm_asset_sub_type_id']);
     $cold_chain->setCcmAssetType($asset_type);
     // $cold_chain->setSerialNumber($form_values['serial_number']);
     $cold_chain->setWorkingSince(new \DateTime(App_Controller_Functions::dateToDbFormat($form_values['working_since'])));
     $auto_gen_id = App_Controller_Functions::generateCcemUniqueAssetId(Model_CcmAssetTypes::COLDROOM);
     $cold_chain->setAutoAssetId($auto_gen_id);
     $source_id = $this->_em->getRepository('Stakeholders')->find($form_values['source_id']);
     $cold_chain->setSource($source_id);
     if (!empty($form_values['warehouse']) && $form_values['placed_at'] == 1) {
         $wh_id = $this->_em->getRepository('Warehouses')->find($form_values['warehouse']);
         $cold_chain->setWarehouse($wh_id);
     }
     $created_by = $this->_em->getRepository('Users')->find($this->_user_id);
     $cold_chain->setCreatedBy($created_by);
     $cold_chain->setCreatedDate(App_Tools_Time::now());
     $cold_chain->setModifiedBy($created_by);
     $cold_chain->setModifiedDate(App_Tools_Time::now());
     $this->_em->persist($cold_chain);
     $this->_em->flush();
     $last_ccm_id = $cold_chain->getPkId();
     // App_Controller_Functions::pr($this->form_values);
     $cold_rooms = new CcmColdRooms();
     $backup_generator = $this->_em->getRepository('ListDetail')->find($form_values['backup_generator']);
     $cold_rooms->setBackupGenerator($backup_generator);
     $ccm_id = $this->_em->getRepository('ColdChain')->find($last_ccm_id);
     $cold_rooms->setCcm($ccm_id);
     $asset_sub_type_id = $this->_em->getRepository('CcmAssetTypes')->find($form_values['ccm_asset_sub_type_id']);
     $cold_rooms->setCcmAssetSubType($asset_sub_type_id);
     $cold_rooms->setCoolingSystem($form_values['cooling_system']);
     $cold_rooms->setCreatedBy($user_id);
     $cold_rooms->setCreatedDate(App_Tools_Time::now());
     $cold_rooms->setHasVoltage($form_values['has_voltage']);
     $cold_rooms->setModifiedBy($user_id);
     $cold_rooms->setModifiedDate(App_Tools_Time::now());
     if (!empty($form_values['refrigerator_gas_type'])) {
         $refrigerator_gas_type = $this->_em->getRepository('ListDetail')->find($form_values['refrigerator_gas_type']);
         $cold_rooms->setRefrigeratorGasType($refrigerator_gas_type);
     }
     if (!empty($form_values['temperature_recording_system'])) {
         $temperature_recording_system = $this->_em->getRepository('ListDetail')->find($form_values['temperature_recording_system']);
         $cold_rooms->setTemperatureRecordingSystem($temperature_recording_system);
     }
     if (!empty($form_values['type_recording_system'])) {
         $type_recording_system = $this->_em->getRepository('ListDetail')->find($form_values['type_recording_system']);
         $cold_rooms->setTypeRecordingSystem($type_recording_system);
     }
     $cold_rooms->setCreatedBy($user_id);
     $cold_rooms->setCreatedDate(App_Tools_Time::now());
     $cold_rooms->setModifiedBy($user_id);
     $cold_rooms->setModifiedDate(App_Tools_Time::now());
     $this->_em->persist($cold_rooms);
     $this->_em->flush();
     $ccm_status_history = new CcmStatusHistory();
     $ccm_status_history->setStatusDate(new \DateTime(date("Y-m-d h:i")));
     $cold_chian_id = $this->_em->getRepository('ColdChain')->find($last_ccm_id);
     $ccm_status_history->setCcm($cold_chian_id);
     if (!empty($form_values['warehouse']) && $form_values['placed_at'] == 1) {
         $warehouse_id = $this->_em->getRepository('Warehouses')->find($form_values['warehouse']);
         $ccm_status_history->setWarehouse($warehouse_id);
     } else {
         $warehouse_id = $this->_em->getRepository('Warehouses')->find($this->_identity->getWarehouseId());
         $ccm_status_history->setWarehouse($warehouse_id);
     }
     $ccm_status_list_id = $this->_em->getRepository('CcmStatusList')->find($form_values['ccm_status_list_id']);
     $ccm_status_history->setCcmStatusList($ccm_status_list_id);
     $asset_id = $this->_em->getRepository('CcmAssetTypes')->find(Model_CcmAssetTypes::COLDROOM);
     $ccm_status_history->setCcmAssetType($asset_id);
     if (!empty($form_values['reason'])) {
         $reason = $this->_em->getRepository('CcmStatusList')->find($form_values['reason']);
         $ccm_status_history->setReason($reason);
     }
     if (!empty($form_values['utilization'])) {
         $utilization = $this->_em->getRepository('CcmStatusList')->find($form_values['utilization']);
         $ccm_status_history->setUtilization($utilization);
     }
     $ccm_status_history->setCreatedBy($user_id);
     $ccm_status_history->setCreatedDate(App_Tools_Time::now());
     $ccm_status_history->setModifiedBy($user_id);
     $ccm_status_history->setModifiedDate(App_Tools_Time::now());
     $this->_em->persist($ccm_status_history);
     $this->_em->flush();
     $ccm_history_id = $ccm_status_history->getPkId();
     $cold_chain_model = new Model_ColdChain();
     $cold_chain_model->updateCcmStatusHistory($last_ccm_id, $ccm_history_id);
     $placements_locations = new PlacementLocations();
     $location_type = $this->_em->getRepository('ListDetail')->find(Model_PlacementLocations::LOCATIONTYPE_CCM);
     $placements_locations->setLocationType($location_type);
     $placements_locations->setLocationBarcode($auto_gen_id);
     $placements_locations->setLocationId($last_ccm_id);
     $placements_locations->setCreatedBy($user_id);
     $placements_locations->setCreatedDate(App_Tools_Time::now());
     $placements_locations->setModifiedBy($user_id);
     $placements_locations->setModifiedDate(App_Tools_Time::now());
     $this->_em->persist($placements_locations);
     $this->_em->flush();
     $ware_house = $form_values['warehouse'];
     if (!empty($ware_house)) {
         $qry = "SELECT REPUpdateCapacity({$ware_house}) from DUAL";
         $row = $this->_em->getConnection()->prepare($qry);
         $row->execute();
         $qry1 = "SELECT REPUpdateRequirement({$ware_house}) from DUAL";
         $row1 = $this->_em->getConnection()->prepare($qry1);
         $row1->execute();
     }
 }
 public function updatePlacement()
 {
     $form_values = $this->form_values;
     $non_ccm_location = $this->_table->find($form_values['placement_id']);
     $area = $this->_em->find("ListDetail", $form_values['area']);
     $row = $this->_em->find("ListDetail", $form_values['row']);
     $rack = $this->_em->find("ListDetail", $form_values['rack']);
     $rack_information_id = $this->_em->find("RackInformation", $form_values['rack_information_id']);
     $pallet = $this->_em->find("ListDetail", $form_values['pallet']);
     $level = $this->_em->find("ListDetail", $form_values['level']);
     $non_ccm_location->setArea($area);
     $non_ccm_location->setRow($row);
     $non_ccm_location->setRack($rack);
     $non_ccm_location->setRackInformation($rack_information_id);
     $non_ccm_location->setPallet($pallet);
     $non_ccm_location->setLevel($level);
     $locationName = $area->getListValue() . $row->getListValue() . $rack->getListValue() . $pallet->getListValue() . $level->getListValue();
     $non_ccm_location->setLocationName($locationName);
     $str_sql = $this->_em->createQueryBuilder()->select('ncl.locationName')->from("NonCcmLocations", "ncl")->where("ncl.locationName = '{$locationName}'");
     $result = $str_sql->getQuery()->getResult();
     if (count($result) > 0) {
         return 0;
     } else {
         $non_ccm_location->setLocationName($locationName);
         $warehouse_id = $this->_identity->getWarehouseId();
         $warehouse_id = $this->_em->find("Warehouses", $warehouse_id);
         $non_ccm_location->setWarehouse($warehouse_id);
         $this->_em->persist($non_ccm_location);
         $this->_em->flush();
         $location_id = $non_ccm_location->getPkId();
         $placement_location = new PlacementLocations();
         $placement_location->setLocationId($location_id);
         $placement_location->setLocationBarcode($locationName);
         $loctype_id = $this->_em->find("ListDetail", Model_PlacementLocations::LOCATIONTYPE_NONCCM);
         $placement_location->setLocationType($loctype_id);
         $this->_em->persist($non_ccm_location);
         $this->_em->flush();
         return 1;
     }
 }