fork download
  1.  
  2. /** Bookings **/
  3. function bookings() {
  4. $this->load->library('pagination');
  5. $this->load->library('table');
  6.  
  7. if ($this->session->userdata('admin_login') != 1)
  8. redirect(base_url() . 'login', 'refresh');
  9. //civility, first/last name, email, phone, hire_date, job, address, city, zip_code, status.
  10. if (empty($_POST) || $_POST['type'] == "search") {
  11. $page_data['page_name'] = 'bookings';
  12. $page_data['cars'] = $this->db->get('handi_cars')->result_array();
  13. $page_data['drivers'] = $this->db->where('job', 'driver')->get('handi_employees')->result_array();
  14. $page_data['clients'] = $this->db->get('handi_clients')->result_array();
  15. $page_data['driver_names'] = $this->driverNames($this->db->where('job', 'driver')->get('handi_employees')->result_array());
  16. $page_data['client_names'] = $this->clientNames($this->db->get('handi_clients')->result_array());
  17. $page_data['user_name'] = get_phrase('Mr. ' . $this->session->userdata('login_as'));
  18. $page_data['page_title'] = "Bookings"; //get_phrase($this->session->userdata('login_as').'_dashboard');
  19. $page_data['board1'] = $this->db->get('first_board')->result_array();
  20. //Must be last to avoid query interruption
  21. if ($_POST['type'] == "search") {
  22. $this->db->select('*');
  23. $search_word = $this->input->post('search-word');
  24. $from_period = str_replace("/", "-", $this->input->post('from_period'));
  25. $to_period = str_replace("/", "-", $this->input->post('to_period'));
  26. $status = $this->input->post('status');
  27. $nature = $this->input->post('nature');
  28. $ridetype = $this->input->post('ridetype
  29. ');
  30.  
  31. if ($search_word != "" && $search_word != "Search keyword") {
  32. $this->db->like('client', $search_word)->or_like('driver', $search_word)->or_like('origin', $search_word)->or_like('destination', $search_word);
  33. }
  34. $this->db->where('start_time >=', $from_period);
  35. $this->db->where('stop_time <=', $to_period);
  36.  
  37.  
  38. if ($status != "All status") {
  39. $this->db->where('status', $status);
  40. }
  41. if ($nature != "All nature") {
  42. $this->db->where('nature', $nature);
  43. }
  44. if ($ridetype != "All type") {
  45. $this->db->where('ridetype', $ridetype);
  46. }
  47.  
  48. $page_data['searched_word'] = $search_word;
  49. $page_data['searched_from'] = $from_period;
  50. $page_data['searched_to'] = $to_period;
  51. $page_data['searched_status'] = $status;
  52. $page_data['searched_nature'] = $nature;
  53. $page_data['searched_ridetype'] = $ridetype;
  54. }
  55. $page_data['rides'] = $this->db->get('handi_rides')->result_array();
  56. $this->load->view('admin', $page_data);
  57. }
  58.  
  59. else {
  60.  
  61. $type = $this->input->post('type');
  62. $data = array(
  63. "client" => $this->input->post('client'),
  64. "driver" => $this->input->post('driver'),
  65. "car" => $this->input->post('car'),
  66. "start_time" => str_replace("/", "-", $this->input->post('start_time')),
  67. "stop_time" => str_replace("/", "-", $this->input->post('stop_time')),
  68. "nature" => $this->input->post('nature'),
  69. "ridetype" => $this->input->post('ridetype'),
  70. "service_name" => $this->input->post('service_name'),
  71. "person_count" => $this->input->post('person_count'),
  72. "wheelchair" => $this->input->post('wheelchair'),
  73. "origin" => $this->input->post('origin'),
  74. "destination" => $this->input->post('destination'),
  75. "origin_cord" => $this->input->post('origin_cord'),
  76. "destination_cord" => $this->input->post('destination_cord'),
  77. "status" => $this->input->post('status')
  78.  
  79. );
  80.  
  81. if ($type == "add") {
  82. $this->db->insert('handi_rides', $data);
  83. } else if ($type == "delete") {
  84. $this->db->where('id', $this->input->post('id'))->delete('handi_rides');
  85. } else if ($type == "edit") {
  86. $this->db->where('id', $this->input->post('id'))->update('handi_rides', $data);
  87. }
  88.  
  89. redirect('admin/bookings');
  90. }
  91.  
  92. }
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
    /** Bookings **/
    function bookings() {
        $this->load->library('pagination');
        $this->load->library('table');

        if ($this->session->userdata('admin_login') != 1)
            redirect(base_url() . 'login', 'refresh');
        //civility, first/last name, email, phone, hire_date, job, address, city, zip_code, status.       
        if (empty($_POST) || $_POST['type'] == "search") {
            $page_data['page_name']    = 'bookings';
            $page_data['cars']         = $this->db->get('handi_cars')->result_array();
            $page_data['drivers']      = $this->db->where('job', 'driver')->get('handi_employees')->result_array();
            $page_data['clients']      = $this->db->get('handi_clients')->result_array();
            $page_data['driver_names'] = $this->driverNames($this->db->where('job', 'driver')->get('handi_employees')->result_array());
            $page_data['client_names'] = $this->clientNames($this->db->get('handi_clients')->result_array());
            $page_data['user_name']    = get_phrase('Mr. ' . $this->session->userdata('login_as'));
            $page_data['page_title']   = "Bookings"; //get_phrase($this->session->userdata('login_as').'_dashboard');
            $page_data['board1']       = $this->db->get('first_board')->result_array();
            //Must be last to avoid query interruption
            if ($_POST['type'] == "search") {
                $this->db->select('*');
                $search_word = $this->input->post('search-word');
                $from_period = str_replace("/", "-", $this->input->post('from_period'));
                $to_period   = str_replace("/", "-", $this->input->post('to_period'));
                $status      = $this->input->post('status');
                $nature      = $this->input->post('nature');
                $ridetype       = $this->input->post('ridetype 
                    ');
                
                if ($search_word != "" && $search_word != "Search keyword") {
                    $this->db->like('client', $search_word)->or_like('driver', $search_word)->or_like('origin', $search_word)->or_like('destination', $search_word);
                }
                    $this->db->where('start_time >=', $from_period);
                    $this->db->where('stop_time <=', $to_period);


                if ($status != "All status") {
                    $this->db->where('status', $status);
                }
                if ($nature != "All nature") {
                    $this->db->where('nature', $nature);
                }
                if ($ridetype != "All type") {
                    $this->db->where('ridetype', $ridetype);
                }

                $page_data['searched_word'] = $search_word;
                $page_data['searched_from'] = $from_period;
                $page_data['searched_to'] = $to_period;
                $page_data['searched_status'] = $status;
                $page_data['searched_nature'] = $nature;
                $page_data['searched_ridetype'] = $ridetype;
            }
        $page_data['rides'] = $this->db->get('handi_rides')->result_array();
            $this->load->view('admin', $page_data);
        }
        
        else {
            
            $type = $this->input->post('type');
            $data = array(
                "client" => $this->input->post('client'),
                "driver" => $this->input->post('driver'),
                "car" => $this->input->post('car'),
                "start_time" => str_replace("/", "-", $this->input->post('start_time')),
                "stop_time" => str_replace("/", "-", $this->input->post('stop_time')),
                "nature" => $this->input->post('nature'),
                "ridetype" => $this->input->post('ridetype'),
                "service_name" => $this->input->post('service_name'),
                "person_count" => $this->input->post('person_count'),
                "wheelchair" => $this->input->post('wheelchair'),
                "origin" => $this->input->post('origin'),
                "destination" => $this->input->post('destination'),
                "origin_cord" => $this->input->post('origin_cord'),
                "destination_cord" => $this->input->post('destination_cord'),                
                "status" => $this->input->post('status')
                
            );
            
            if ($type == "add") {
                $this->db->insert('handi_rides', $data);
            } else if ($type == "delete") {
                $this->db->where('id', $this->input->post('id'))->delete('handi_rides');
            } else if ($type == "edit") {
                $this->db->where('id', $this->input->post('id'))->update('handi_rides', $data);
            }
            
            redirect('admin/bookings');
        }

    }