Exemplo n.º 1
0
 public function addTransport()
 {
     date_default_timezone_set('Asia/karachi');
     $form_values = $this->form_values;
     // App_Controller_Functions::pr($form_values);
     $user_id = $this->_em->getRepository('Users')->find($this->_user_id);
     $cold_chain = new ColdChain();
     //$asset_type = $this->_em->getRepository('CcmAssetTypes')->find(11);
     $cold_chain->setAssetId($form_values['asset_id']);
     $cold_chain->setAutoAssetId(App_Controller_Functions::generateCcemUniqueAssetId(Model_CcmAssetTypes::TRANSPORT));
     //$status_list = $this->_em->getRepository('CcmStatusList')->find($form_values['ccm_status_list_id']);
     //$cold_chain->setCcmStatusList($status_list);
     //$cold_chain->setStakeholderId($stakeholder);
     $stakeholder = $this->_em->getRepository('Stakeholders')->find($form_values['source_id']);
     $cold_chain->setSource($stakeholder);
     if ($form_values['ccm_asset_sub_type_id']) {
         $asset_type = $this->_em->getRepository('CcmAssetTypes')->find(Model_CcmAssetTypes::TRANSPORT);
         $cold_chain->setCcmAssetType($asset_type);
     }
     $model_id = $this->_em->getRepository('CcmModels')->find($form_values['ccm_model_id']);
     $cold_chain->setCcmModel($model_id);
     $cold_chain->setManufactureYear(new \DateTime(App_Controller_Functions::dateToDbFormat($form_values['manufacture_year'])));
     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);
     }
     $cold_chain->setCreatedBy($user_id);
     $cold_chain->setCreatedDate(App_Tools_Time::now());
     $cold_chain->setModifiedBy($user_id);
     $cold_chain->setModifiedDate(App_Tools_Time::now());
     $this->_em->persist($cold_chain);
     $this->_em->flush();
     $last_ccm_id = $cold_chain->getPkId();
     $ccm_vehicles = new CcmVehicles();
     $cold_chain_id = $this->_em->getRepository('ColdChain')->find($last_ccm_id);
     $ccm_vehicles->setCcm($cold_chain_id);
     $ccm_asset_sub_type = $this->_em->getRepository('CcmAssetTypes')->find($form_values['ccm_asset_sub_type_id']);
     $ccm_vehicles->setCcmAssetSubType($ccm_asset_sub_type);
     $ccm_vehicles->setRegistrationNo($form_values['registration_no']);
     $ccm_vehicles->setUsedForEpi($form_values['used_for_epi']);
     if ($form_values['fuel_type_id']) {
         $fuel_type_id = $this->_em->getRepository('ListDetail')->find($form_values['fuel_type_id']);
         $ccm_vehicles->setFuelType($fuel_type_id);
     }
     $ccm_vehicles->setComments($form_values['comments']);
     $ccm_vehicles->setCreatedBy($user_id);
     $ccm_vehicles->setCreatedDate(App_Tools_Time::now());
     $ccm_vehicles->setModifiedBy($user_id);
     $ccm_vehicles->setModifiedDate(App_Tools_Time::now());
     $this->_em->persist($ccm_vehicles);
     $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::TRANSPORT);
     $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['reason'])) {
         $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(30);
     //        $placements_locations->setLocationType($location_type);
     //        $placements_locations->setLocationId(Model_CcmAssetTypes::TRANSPORT);
     //        $this->_em->persist($placements_locations);
     //        $this->_em->flush();
 }
 public function updateColdChainStatus()
 {
     date_default_timezone_set('Asia/karachi');
     $cc_id = $this->form_values['ccm_id'];
     $created_by = $this->_em->find('Users', $this->_user_id);
     foreach ($cc_id as $index => $ccm_id) {
         $working_status = $this->form_values['working_status'];
         $temperature = $this->form_values['temperature'];
         $ccmAssetId = $this->form_values['asset_id'];
         $reason = $this->form_values['reason'];
         $utilization = $this->form_values['utilization'];
         $wh_id = $this->form_values['wh_id'];
         $ccm_status_history = new CcmStatusHistory();
         $ccm_status_history->setTemperatureAlarm($temperature[$index]);
         $cold_chain_id = $this->_em->getRepository('ColdChain')->find($ccm_id);
         $ccm_status_history->setCcm($cold_chain_id);
         $ccm_status_history->setStatusDate(new \DateTime(date("Y-m-d h:i")));
         $warehouse_id = $this->_em->getRepository('Warehouses')->find($wh_id);
         $ccm_status_history->setWarehouse($warehouse_id);
         $work_status = $this->_em->getRepository('CcmStatusList')->find($working_status[$index]);
         $ccm_status_history->setCcmStatusList($work_status);
         $ccm_asset_type = $this->_em->getRepository('CcmAssetTypes')->find($ccmAssetId[$index]);
         $ccm_status_history->setCcmAssetType($ccm_asset_type);
         if (empty($reason[$index])) {
             $reason_id = $this->_em->getRepository('CcmStatusList')->find(1);
             $ccm_status_history->setReason($reason_id);
         } else {
             $reason_id = $this->_em->getRepository('CcmStatusList')->find($reason[$index]);
             $ccm_status_history->setReason($reason_id);
         }
         if (empty($utilization[$index])) {
             $utilization_id = $this->_em->getRepository('CcmStatusList')->find(1);
             $ccm_status_history->setUtilization($utilization_id);
         } else {
             $utilization_id = $this->_em->getRepository('CcmStatusList')->find($utilization[$index]);
             $ccm_status_history->setUtilization($utilization_id);
         }
         $ccm_status_history->setCreatedBy($created_by);
         $ccm_status_history->setModifiedBy($created_by);
         $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 = new Model_ColdChain();
         $cold_chain->updateCcmStatusHistory($ccm_id, $ccm_history_id);
     }
     $ccm_id_q = $this->form_values['ccm_id_q'];
     foreach ($ccm_id_q as $index => $ccm_id_quantity) {
         $work_quantity = $this->form_values['work_quantity'];
         $comments = $this->form_values['comments'];
         $asset_id_q = $this->form_values['asset_id_q'];
         $wh_id = $this->form_values['wh_id'];
         $ccm_status = new CcmStatusHistory();
         $cold_chain_id_q = $this->_em->getRepository('ColdChain')->find($ccm_id_quantity);
         $ccm_status->setCcm($cold_chain_id_q);
         $ccm_status->setWorkingQuantity($work_quantity[$index]);
         $ccm_status->setComments($comments[$index]);
         $ccm_status->setStatusDate(new \DateTime(date("Y-m-d h:i")));
         $warehouse_id = $this->_em->getRepository('Warehouses')->find($wh_id);
         $ccm_status->setWarehouse($warehouse_id);
         $ccm_asset_type_q = $this->_em->getRepository('CcmAssetTypes')->find($asset_id_q[$index]);
         $ccm_status->setCcmAssetType($ccm_asset_type_q);
         $ccm_status->setCreatedBy($created_by);
         $ccm_status->setModifiedBy($created_by);
         $ccm_status->setModifiedDate(App_Tools_Time::now());
         $this->_em->persist($ccm_status);
         $this->_em->flush();
         $history_id = $ccm_status->getPkId();
         $cold_chain = new Model_ColdChain();
         $cold_chain->updateCcmStatusHistory($ccm_id_quantity, $history_id);
     }
     $ccm_id_histroy = $this->form_values['ccm_id_q'];
     foreach ($ccm_id_histroy as $index => $ccm_id_quantity) {
         $work_quantity = $this->form_values['work_quantity'];
         $total_quantity = $this->form_values['total_quantity'];
         $wh_id = $this->form_values['wh_id'];
         $ccm_history = new CcmHistory();
         $quantity = $total_quantity[$index] - $work_quantity[$index];
         $ccm_history->setQuantity($quantity);
         $ccm_history->setCreatedDate(new \DateTime(date("Y-m-d")));
         $action_id = $this->_em->getRepository('ListDetail')->find(26);
         $ccm_history->setAction($action_id);
         $ccm_id = $this->_em->getRepository('ColdChain')->find($ccm_id_quantity);
         $ccm_history->setCcm($ccm_id);
         $user_id = $this->_em->getRepository('Users')->find($this->_user_id);
         $ccm_history->setCreatedBy($user_id);
         $warehouse_id = $this->_em->getRepository('Warehouses')->find($wh_id);
         $ccm_history->setWarehouse($warehouse_id);
         $ccm_history->setCreatedBy($created_by);
         $ccm_history->setModifiedBy($created_by);
         $ccm_history->setModifiedDate(App_Tools_Time::now());
         $this->_em->persist($ccm_history);
     }
     $this->_em->flush();
 }
Exemplo n.º 3
0
 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();
     }
 }
Exemplo n.º 4
0
 public function addIcePack()
 {
     // App_Controller_Functions::pr($this->form_values);
     $ccm_model_id = $this->form_values['ccm_model_id'];
     foreach ($ccm_model_id as $index => $model_id) {
         $form_values = $this->form_values;
         $quantity = $this->form_values['quantity'];
         $cold_chain = new ColdChain();
         $cold_chain->setQuantity($quantity[$index]);
         $asset_id = $this->_em->getRepository('CcmAssetTypes')->find(Model_CcmAssetTypes::ICEPACKS);
         $cold_chain->setCcmAssetType($asset_id);
         $m_id = $this->_em->getRepository('CcmModels')->find($model_id);
         $cold_chain->setCcmModel($m_id);
         $created_by = $this->_em->getRepository('Users')->find($this->_user_id);
         if (!empty($this->form_values['warehouse'])) {
             $w_id = $this->form_values['warehouse'];
             $warehouse = $this->_em->getRepository('Warehouses')->find($w_id);
             $cold_chain->setWarehouse($warehouse);
         }
         $cold_chain->setCreatedBy($created_by);
         $cold_chain->setCreatedDate(new \DateTime(date("Y-m-d")));
         $cold_chain->setModifiedBy($created_by);
         $cold_chain->setModifiedDate(App_Tools_Time::now());
         $this->_em->persist($cold_chain);
         $this->_em->flush();
         $cold_chain_id = $cold_chain->getPkId();
         $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($cold_chain_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);
         }
         $asset1_id = $this->_em->getRepository('CcmAssetTypes')->find(Model_CcmAssetTypes::ICEPACKS);
         $ccm_status_history->setCcmAssetType($asset1_id);
         $ccm_status_history->setWorkingQuantity($quantity[$index]);
         $ccm_status_history->setCreatedBy($created_by);
         $ccm_status_history->setCreatedDate(App_Tools_Time::now());
         $ccm_status_history->setModifiedBy($created_by);
         $ccm_status_history->setModifiedDate(App_Tools_Time::now());
         $this->_em->persist($ccm_status_history);
         $this->_em->flush();
         $cold_chain_model = new Model_ColdChain();
         $ccm_history_id = $ccm_status_history->getPkId();
         $cold_chain_model->updateCcmStatusHistory($cold_chain_id, $ccm_history_id);
     }
     //        $placements_locations = new PlacementLocations();
     //        $location_type = $this->_em->getRepository('ListDetail')->find(30);
     //        $placements_locations->setLocationType($location_type);
     //        $placements_locations->setLocationId(Model_CcmAssetTypes::ICEPACKS);
     //        $this->_em->persist($placements_locations);
     //        $this->_em->flush();
 }
Exemplo n.º 5
0
 public function addVoltageRegulator()
 {
     //$ccm_model = new CcmModels();
     $form_values = $this->form_values;
     // App_Controller_Functions::pr($form_values);
     $cold_chain = new ColdChain();
     $model_id = $this->_em->getRepository('CcmModels')->find($form_values['catalogue_id']);
     $cold_chain->setCcmModel($model_id);
     $asset_type = $this->_em->getRepository('CcmAssetTypes')->find(Model_CcmAssetTypes::VOLTAGEREGULATOR);
     $cold_chain->setCcmAssetType($asset_type);
     $cold_chain->setQuantity($form_values['quantity']);
     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);
     }
     $user_id = $this->_em->getRepository('Users')->find($this->_user_id);
     $cold_chain->setCreatedBy($user_id);
     $cold_chain->setCreatedDate(App_Tools_Time::now());
     $cold_chain->setModifiedBy($user_id);
     $cold_chain->setModifiedDate(App_Tools_Time::now());
     $this->_em->persist($cold_chain);
     $this->_em->flush();
     $cold_chain_id = $cold_chain->getPkId();
     $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($cold_chain_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);
     }
     $asset1_id = $this->_em->getRepository('CcmAssetTypes')->find(Model_CcmAssetTypes::VOLTAGEREGULATOR);
     $ccm_status_history->setCcmAssetType($asset1_id);
     $ccm_status_history->setWorkingQuantity($form_values['quantity']);
     $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();
     $cold_chain_model = new Model_ColdChain();
     $ccm_history_id = $ccm_status_history->getPkId();
     $cold_chain_model->updateCcmStatusHistory($cold_chain_id, $ccm_history_id);
 }
Exemplo n.º 6
0
 public function addGenerator()
 {
     $form_values = $this->form_values;
     //   App_Controller_Functions::pr($form_values);
     $ccm_model = $this->_em->getRepository('CcmModels')->find($form_values['ccm_model_id']);
     $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());
     $ccm_model->setNoOfPhases($form_values['no_of_phases']);
     $this->_em->persist($ccm_model);
     $this->_em->flush();
     $cold_chain = new ColdChain();
     $cold_chain->setAssetId($form_values['asset_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(Model_CcmAssetTypes::GENERATOR);
     $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'])));
     $cold_chain->setCreatedBy($user_id);
     $source_id = $this->_em->getRepository('Stakeholders')->find($form_values['source_id']);
     $cold_chain->setSource($source_id);
     $auto_gen_id = App_Controller_Functions::generateCcemUniqueAssetId(Model_CcmAssetTypes::GENERATOR);
     $cold_chain->setAutoAssetId($auto_gen_id);
     $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);
     }
     $user_id = $this->_em->getRepository('Users')->find($this->_user_id);
     $cold_chain->setCreatedBy($user_id);
     $cold_chain->setCreatedDate(App_Tools_Time::now());
     $cold_chain->setModifiedBy($user_id);
     $cold_chain->setModifiedDate(App_Tools_Time::now());
     $this->_em->persist($cold_chain);
     $this->_em->flush();
     $last_ccm_id = $cold_chain->getPkId();
     $generators = new CcmGenerators();
     $power_source = $this->_em->getRepository('ListDetail')->find($form_values['power_source']);
     $generators->setPowerSource($power_source);
     $generators->setPowerRating($form_values['power_rating']);
     $generators->setUseFor($form_values['use_for']);
     $generators->setAutomaticStartMechanism($form_values['automatic_start']);
     $ccm_id = $this->_em->getRepository('ColdChain')->find($last_ccm_id);
     $generators->setCcm($ccm_id);
     $generators->setCreatedBy($user_id);
     $generators->setCreatedDate(App_Tools_Time::now());
     $generators->setModifiedBy($user_id);
     $generators->setModifiedDate(App_Tools_Time::now());
     $this->_em->persist($generators);
     $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::GENERATOR);
     $ccm_status_history->setCcmAssetType($asset_id);
     if (!empty($form_values['reasons'])) {
         $reason = $this->_em->getRepository('CcmStatusList')->find($form_values['reasons']);
         $ccm_status_history->setReason($reason);
     }
     if (!empty($form_values['utilizations'])) {
         $utilization = $this->_em->getRepository('CcmStatusList')->find($form_values['utilizations']);
         $ccm_status_history->setUtilization($utilization);
     }
     $user_id = $this->_em->getRepository('Users')->find($this->_user_id);
     $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(30);
     //         $placements_locations->setLocationType($location_type);
     //        $placements_locations->setLocationId(Model_CcmAssetTypes::GENERATOR);
     //        $this->_em->persist($placements_locations);
     //        $this->_em->flush();
 }