Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class AmPlanning extends CI_Controller
- {
- function __construct()
- {
- parent::__construct();
- $this->load->model('M_planning');
- // $this->load->library('uuid');
- }
- public function index()
- {
- $this->form_validation->set_rules('date', 'Date', 'required');
- $this->form_validation->set_rules('cust_segment', 'Customer Segment', 'required');
- $this->form_validation->set_rules('cust_name', 'Customer Name', 'required');
- $this->form_validation->set_rules('date', 'Date Meeting', 'required');
- $this->form_validation->set_rules('location', 'Location Meeting', 'required');
- $this->form_validation->set_rules('status', 'Status', 'required');
- if ($this->form_validation->run() == false) {
- $pageId = 'am_planning'; /*Change_this*/
- $pagePath = 'pages/' . $pageId;
- $data['pageId'] = $pageId;
- $data['pageTitle'] = "AM Planning"; /*Change_this*/
- $data['pageContent'] = $this->load->view($pagePath . '/view', '', TRUE);
- $data['pageStyle'] = $this->load->view($pagePath . '/style', '', TRUE);
- $data['pageScript'] = $this->load->view($pagePath . '/script', '', TRUE);
- $this->load->view('layout/v_layout', $data);
- } else {
- $this->insert();
- }
- }
- private function insert()
- {
- $data_planning = [
- // "id_panning" =>
- "date_created_am" => date('Y-m-d', strtotime($this->input->post('date', true))),
- "cust_segment" => $this->input->post('cust_segment', true),
- // "cust_name" => $this->input->post('cust_name', true),
- // "date_meet" => date('Y-m-d', strtotime($this->input->post('date', true))),
- // "location" => $this->input->post('location', true),
- // "status" => $this->input->post('status', true),
- ];
- $data_customer = [
- "cust_name" => $this->input->post('cust_name[]', true),
- "date_meet" => date('Y-m-d', strtotime($this->input->post('date[]', true))),
- "meet_location" => $this->input->post('location[]', true),
- "status" => $this->input->post('status[]', true),
- ];
- // $uuid_planning = $this->db->set('id_planning', 'UUID()', FALSE);
- // $uuid_customer = $this->db->set('id_customer', 'UUID()', FALSE);
- $insert = $this->M_planning->insert_table($data_planning, $data_customer);
- if ($insert) {
- // // $uuid_customer = $this->db->set('id_customer','UUID()',FALSE);
- // // $id = $uuid_planning;
- // // var_dump($uuid_planning);
- // // echo $uuid_planning;
- // // $this->db->set('id_planning', $uuid_planning);
- // $insert1 = $this->M_planning->create('customer',$data_customer);
- // if($insert1){
- // $this->session->set_flashdata('message', '<div class="alert alert-success" style="text-align:center;">Success</div>');
- // // redirect('index.php/PagesRoute/am_planning');
- // echo "berhasil";
- // }
- // $this->session->set_flashdata('message', '<div class="alert alert-success" style="text-align:center;">Success</div>');
- // redirect('PagesRoute/am_planning');
- echo "berhasil";
- } else {
- $this->session->set_flashdata('message', '<div class="alert alert-danger" style="text-align:center;">Fail to save data</div>');
- // redirect('index.php/PagesRoute/am_planning');
- echo "gagal";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement