Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.12 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class C_sewa extends CI_Controller {
  5.  
  6.  
  7.     public function index(){
  8.         $this->load->view('home/header');
  9.         $this->load->view('booking/index');
  10.         $this->load->view('home/footer');
  11.     }
  12.  
  13.     public function list_mobil(){
  14.         $data['tampilmobil'] = $this->model_rental->tampil_datambl();
  15.         $this->load->view('home/header');
  16.         $this->load->view('booking/vlist_mobil',$data);
  17.         $this->load->view('home/footer');
  18.     }
  19.  
  20.  
  21.     public function isi_datadiri($id){
  22.         $data['getmobil']=$this->model_rental->getmobilBYID($id);
  23.         $this->load->view('home/header');
  24.         $this->load->view('booking/visi_datadiri',$data);
  25.         $this->load->view('home/footer');
  26.     }
  27.     public function insertdatasementara(){
  28.  
  29.         $this->form_validation->set_rules('nama', 'Nama','required|trim');
  30.         $this->form_validation->set_rules('tanggal_lahir', 'Name','required|trim');
  31.         $this->form_validation->set_rules('telepon', 'No Telepon','required|trim');
  32.         $this->form_validation->set_rules('email', 'E-mail','required|trim');
  33.         $this->form_validation->set_rules('alamat', 'Alamat','required|trim');
  34.         $this->form_validation->set_rules('tandapengenal', 'Tanda Pengenal','required|trim');
  35.         $this->form_validation->set_rules('no_pengenal', 'No Tanda Pengenal','required|trim');
  36.         $this->form_validation->set_rules('suratjaminan', 'Surat Jaminan','required|trim');
  37.  
  38.         if ($this->form_validation->run()==true)
  39.         {
  40.             $data=
  41.                 [ // untuk memasukkan data ke database
  42.                 /*htmlspecialchars() berfungsi untuk filter dari karakter aneh*/
  43.                 'cut_nama'              =>htmlspecialchars($this->input->post('nama',true)),
  44.                 'cut_tgllahir'          =>$this->input->post('tanggal_lahir',true),
  45.                 'cut_telepon'           =>$this->input->post('telepon',true),
  46.                 'cut_email'             =>$this->input->post('email',true),
  47.                 'cut_data_created'      =>time(),
  48.                 'cut_alamat'            =>htmlspecialchars($this->input->post('alamat',true))
  49.             ];
  50.             $this->db->insert('3_customer',$data);
  51.  
  52.             $data2=
  53.             [
  54.                 'trans_nama'                =>htmlspecialchars($this->input->post('nama',true)),
  55.                 'trans_alamat'              =>htmlspecialchars($this->input->post('alamat',true)),
  56.                 'trans_telepon'             =>htmlspecialchars($this->input->post('telepon',true)),
  57.                 'trans_merk_mobil'          =>$this->input->post('get_merkmobil',true),
  58.                 'trans_plat'                =>$this->input->post('get_platmobil',true),
  59.                 'trans_harga'               =>$this->input->post('hargasewa',true),
  60.                 'trans_data_created'        =>time(),
  61.                 'trans_tanggalpesan'        =>$this->input->post('tanggal_sewa',true),
  62.                 'trans_hari'                =>htmlspecialchars($this->input->post('lamasewa',true)),
  63.                 'trans_totalbayar'          =>htmlspecialchars($this->input->post('jumlah',true)),
  64.                 'trans_tanpeng'             =>htmlspecialchars($this->input->post('tandapengenal',true)),
  65.                 'trans_notanpeng'           =>htmlspecialchars($this->input->post('no_pengenal',true)),
  66.                 'trans_fottanpeng'          =>$this->_uploadImage1(),
  67.                 'trans_surja'               =>htmlspecialchars($this->input->post('suratjaminan',true)),
  68.                 'trans_fosurja'             =>$this->_uploadImage2()
  69.             ];
  70.             $this->db->insert('4_transaksi',$data2);
  71.  
  72.  
  73.             $nama   =$this->input->post('nama');
  74.             $id      = $this->db->get_where('4_transaksi',['trans_nama'=>$nama])->row_array();
  75.  
  76.             $datasession=['kode1'=>$id['trans_nama']];
  77.             $this->session->set_userdata($datasession);
  78.  
  79.             $datadata['namaa']=$this->input->post('nama');
  80.             $datadata['tlp']=$this->input->post('telepon');
  81.             $datadata['alamatt']=$this->input->post('alamat');
  82.             $datadata['mbl']=$this->input->post('get_merkmobil');
  83.             $datadata['plat']=$this->input->post('get_platmobil');
  84.             $datadata['tgl']=$this->input->post('tanggal_sewa');
  85.             $datadata['tagihan']=$this->input->post('jumlah');
  86.             $datadata['lamasewa']=$this->input->post('lamasewa');
  87.             $datadata['surja']=$this->input->post('suratjaminan');
  88.  
  89.             $this->load->view('home/header');
  90.             $this->load->view('booking/vdata_diri',$datadata);
  91.             $this->load->view('home/footer');
  92.         }else{
  93.             $this->isi_datadiri($id);
  94.         }
  95.     }
  96.    
  97.     private function _uploadImage1()
  98.     {
  99.         $config['upload_path']          = './assets/img/datacustomer/';
  100.         $config['allowed_types']        = 'gif|jpg|png';
  101.         $config['max_size']             = 100000;  // max 10 mb
  102.         $config['max_width']            = 10200004;
  103.         $config['max_height']           = 7680000;
  104.         $this->load->library('upload', $config);
  105.         if ($this->upload->do_upload('upftp')) {
  106.             return $this->upload->data("file_name");
  107.         }
  108.         return "default.jpg";
  109.     }
  110.  
  111.     private function _uploadImage2()
  112.     {
  113.         $config['upload_path']          = './assets/img/datacustomer/';
  114.         $config['allowed_types']        = 'gif|jpg|png';
  115.         $config['max_size']             = 100000;  // max 10 mb
  116.         $config['max_width']            = 10200004;
  117.         $config['max_height']           = 7680000;
  118.         $this->load->library('upload', $config);
  119.         if ($this->upload->do_upload('upsurja')) {
  120.             return $this->upload->data("file_name");
  121.         }
  122.         return "default.jpg";
  123.     }
  124.  
  125.  
  126.     public function view_mobil($id){
  127.         $data['getmobil']=$this->model_rental->getmobilBYID($id);
  128.  
  129.         $this->load->view('home/header',$data);
  130.         $this->load->view('booking/vreview_mobil',$data);
  131.         $this->load->view('home/footer',$data);
  132.     }
  133.  
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement