Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.60 KB | None | 0 0
  1. <?php
  2.  
  3. class AmPlanning extends CI_Controller
  4. {
  5.     function __construct()
  6.     {
  7.         parent::__construct();
  8.         $this->load->model('M_planning');
  9.         // $this->load->library('uuid');
  10.     }
  11.  
  12.     public function index()
  13.     {
  14.         $this->form_validation->set_rules('date', 'Date', 'required');
  15.         $this->form_validation->set_rules('cust_segment', 'Customer Segment', 'required');
  16.         $this->form_validation->set_rules('cust_name', 'Customer Name', 'required');
  17.         $this->form_validation->set_rules('date', 'Date Meeting', 'required');
  18.         $this->form_validation->set_rules('location', 'Location Meeting', 'required');
  19.         $this->form_validation->set_rules('status', 'Status', 'required');
  20.  
  21.         if ($this->form_validation->run() == false) {
  22.             $pageId  = 'am_planning'; /*Change_this*/
  23.             $pagePath = 'pages/' . $pageId;
  24.             $data['pageId'] = $pageId;
  25.             $data['pageTitle'] = "AM Planning"; /*Change_this*/
  26.             $data['pageContent'] = $this->load->view($pagePath . '/view', '', TRUE);
  27.             $data['pageStyle'] = $this->load->view($pagePath . '/style', '', TRUE);
  28.             $data['pageScript'] = $this->load->view($pagePath . '/script', '', TRUE);
  29.             $this->load->view('layout/v_layout', $data);
  30.         } else {
  31.             $this->insert();
  32.         }
  33.     }
  34.  
  35.     private function insert()
  36.     {
  37.  
  38.         $data_planning = [
  39.             // "id_panning" =>
  40.             "date_created_am" => date('Y-m-d', strtotime($this->input->post('date', true))),
  41.             "cust_segment" => $this->input->post('cust_segment', true),
  42.             // "cust_name" => $this->input->post('cust_name', true),
  43.             // "date_meet" => date('Y-m-d', strtotime($this->input->post('date', true))),
  44.             // "location" => $this->input->post('location', true),
  45.             // "status" => $this->input->post('status', true),
  46.         ];
  47.  
  48.         $data_customer = [
  49.             "cust_name" => $this->input->post('cust_name[]', true),
  50.             "date_meet" => date('Y-m-d', strtotime($this->input->post('date[]', true))),
  51.             "meet_location" => $this->input->post('location[]', true),
  52.             "status" => $this->input->post('status[]', true),
  53.         ];
  54.  
  55.         // $uuid_planning = $this->db->set('id_planning', 'UUID()', FALSE);
  56.         // $uuid_customer = $this->db->set('id_customer', 'UUID()', FALSE);
  57.         $insert = $this->M_planning->insert_table($data_planning, $data_customer);
  58.         if ($insert) {
  59.             // // $uuid_customer = $this->db->set('id_customer','UUID()',FALSE);
  60.             // // $id = $uuid_planning;
  61.             // // var_dump($uuid_planning);
  62.             // // echo $uuid_planning;
  63.  
  64.             // // $this->db->set('id_planning', $uuid_planning);
  65.             // $insert1 = $this->M_planning->create('customer',$data_customer);
  66.             // if($insert1){
  67.             //     $this->session->set_flashdata('message', '<div class="alert alert-success" style="text-align:center;">Success</div>');
  68.             // // redirect('index.php/PagesRoute/am_planning');
  69.             // echo "berhasil";
  70.             // }
  71.             // $this->session->set_flashdata('message', '<div class="alert alert-success" style="text-align:center;">Success</div>');
  72.             // redirect('PagesRoute/am_planning');
  73.             echo "berhasil";
  74.         } else {
  75.             $this->session->set_flashdata('message', '<div class="alert alert-danger" style="text-align:center;">Fail to save data</div>');
  76.             // redirect('index.php/PagesRoute/am_planning');
  77.             echo "gagal";
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement