예제 #1
0
 public function addBudgetAllocation($id, $function)
 {
     if (!$this->session->userdata('user_id')) {
         redirect('/users/login', 'location');
     }
     if ($function == 0) {
         $form_message = '';
     } elseif ($function == 1) {
         $form_message = '<div class="kode-alert kode-alert kode-alert-icon kode-alert-click alert3"><i class="fa fa-lock"></i>Save Succeeded!<a href="#" class="closed">&times;</a></div>';
     } elseif ($function == 2) {
         $form_message = '<div class="kode-alert kode-alert kode-alert-icon kode-alert-click alert4"><i class="fa fa-lock"></i>Update Succeeded!<a href="#" class="closed">&times;</a></div>';
     } elseif ($function == 3) {
         $form_message = '<div class="kode-alert kode-alert kode-alert-icon kode-alert-click alert6"><i class="fa fa-lock"></i>Delete Succeeded!<a href="#" class="closed">&times;</a></div>';
     }
     $budgetallocation_model = new budgetallocation_model();
     $sectorDropDown = $budgetallocation_model->get_sector();
     $profile_id = $budgetallocation_model->getLSWDOprofile($id);
     $this->validateAddForm();
     if (!$this->form_validation->run()) {
         $this->load->view('header');
         $this->load->view('nav');
         $this->load->view('sidebar');
         $rpmb['sector_id'] = $sectorDropDown;
         $rpmb['form_message'] = $form_message;
         $this->load->view('budgetallocation_add', $rpmb);
         $this->load->view('footer');
     } else {
         $budgetallocation_model = new budgetallocation_model();
         //$profile_id = $this->input->post('profile_id');//mglv
         $sector_id = $this->input->post('sector_id');
         $year_indicated = $this->input->post('year_indicated');
         $budget_previous_year = preg_replace('/[^0-9.]*/', '', $this->input->post('budget_previous_year'));
         $budget_present_year = preg_replace('/[^0-9.]*/', '', $this->input->post('budget_present_year'));
         $utilization = preg_replace('/[^0-9.]*/', '', $this->input->post('utilization'));
         $no_bene_served = $this->input->post('no_bene_served');
         $no_target_bene = $this->input->post('no_target_bene');
         $created_by = $this->session->userdata('user_id');
         $date_created = 'NOW()';
         $checkDupli = $budgetallocation_model->checkDuplicate($id, $sector_id);
         if ($checkDupli->countProf == 0) {
             $addResult = $budgetallocation_model->insertBudgetAllocation($id, $sector_id, $year_indicated, $budget_previous_year, $budget_present_year, $utilization, $no_bene_served, $no_target_bene, $created_by, $date_created);
             if ($addResult) {
                 $form_message = 'Add Succeeded!';
                 $this->load->view('header');
                 $rpmb['form_message'] = $form_message;
                 $this->load->view('nav');
                 $this->load->view('sidebar');
                 $this->load->view('budgetallocation_add', array('sector_id' => $sector_id, 'budgetallocation_data' => $budgetallocation_model->getBudgetAllocation($id), 'profile_id' => $id, 'form_message' => $form_message));
                 $this->load->view('footer');
                 $this->redirectIndex($id, 1);
             }
         } else {
             $sectorName = $budgetallocation_model->sectorName($sector_id);
             $form_message = '<div class="kode-alert kode-alert kode-alert-icon kode-alert-click alert6"><i class="fa fa-lock"></i>' . $sectorName->sector_name . ' already exist<a href="#" class="closed">&times;</a></div>';
             $rpmb['sector_id'] = $sectorDropDown;
             $rpmb['form_message'] = $form_message;
             $this->load->view('header');
             $this->load->view('nav');
             $this->load->view('sidebar');
             $this->load->view('budgetallocation_add', $rpmb);
             $this->load->view('footer');
         }
     }
 }