Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class C_sewa extends CI_Controller {
- public function index(){
- $this->load->view('home/header');
- $this->load->view('booking/index');
- $this->load->view('home/footer');
- }
- public function list_mobil(){
- $data['tampilmobil'] = $this->model_rental->tampil_datambl();
- $this->load->view('home/header');
- $this->load->view('booking/vlist_mobil',$data);
- $this->load->view('home/footer');
- }
- public function isi_datadiri($id){
- $data['getmobil']=$this->model_rental->getmobilBYID($id);
- $this->load->view('home/header');
- $this->load->view('booking/visi_datadiri',$data);
- $this->load->view('home/footer');
- }
- public function insertdatasementara(){
- $this->form_validation->set_rules('nama', 'Nama','required|trim');
- $this->form_validation->set_rules('tanggal_lahir', 'Name','required|trim');
- $this->form_validation->set_rules('telepon', 'No Telepon','required|trim');
- $this->form_validation->set_rules('email', 'E-mail','required|trim');
- $this->form_validation->set_rules('alamat', 'Alamat','required|trim');
- $this->form_validation->set_rules('tandapengenal', 'Tanda Pengenal','required|trim');
- $this->form_validation->set_rules('no_pengenal', 'No Tanda Pengenal','required|trim');
- $this->form_validation->set_rules('suratjaminan', 'Surat Jaminan','required|trim');
- if ($this->form_validation->run()==true)
- {
- $data=
- [ // untuk memasukkan data ke database
- /*htmlspecialchars() berfungsi untuk filter dari karakter aneh*/
- 'cut_nama' =>htmlspecialchars($this->input->post('nama',true)),
- 'cut_tgllahir' =>$this->input->post('tanggal_lahir',true),
- 'cut_telepon' =>$this->input->post('telepon',true),
- 'cut_email' =>$this->input->post('email',true),
- 'cut_data_created' =>time(),
- 'cut_alamat' =>htmlspecialchars($this->input->post('alamat',true))
- ];
- $this->db->insert('3_customer',$data);
- $data2=
- [
- 'trans_nama' =>htmlspecialchars($this->input->post('nama',true)),
- 'trans_alamat' =>htmlspecialchars($this->input->post('alamat',true)),
- 'trans_telepon' =>htmlspecialchars($this->input->post('telepon',true)),
- 'trans_merk_mobil' =>$this->input->post('get_merkmobil',true),
- 'trans_plat' =>$this->input->post('get_platmobil',true),
- 'trans_harga' =>$this->input->post('hargasewa',true),
- 'trans_data_created' =>time(),
- 'trans_tanggalpesan' =>$this->input->post('tanggal_sewa',true),
- 'trans_hari' =>htmlspecialchars($this->input->post('lamasewa',true)),
- 'trans_totalbayar' =>htmlspecialchars($this->input->post('jumlah',true)),
- 'trans_tanpeng' =>htmlspecialchars($this->input->post('tandapengenal',true)),
- 'trans_notanpeng' =>htmlspecialchars($this->input->post('no_pengenal',true)),
- 'trans_fottanpeng' =>$this->_uploadImage1(),
- 'trans_surja' =>htmlspecialchars($this->input->post('suratjaminan',true)),
- 'trans_fosurja' =>$this->_uploadImage2()
- ];
- $this->db->insert('4_transaksi',$data2);
- $nama =$this->input->post('nama');
- $id = $this->db->get_where('4_transaksi',['trans_nama'=>$nama])->row_array();
- $datasession=['kode1'=>$id['trans_nama']];
- $this->session->set_userdata($datasession);
- $datadata['namaa']=$this->input->post('nama');
- $datadata['tlp']=$this->input->post('telepon');
- $datadata['alamatt']=$this->input->post('alamat');
- $datadata['mbl']=$this->input->post('get_merkmobil');
- $datadata['plat']=$this->input->post('get_platmobil');
- $datadata['tgl']=$this->input->post('tanggal_sewa');
- $datadata['tagihan']=$this->input->post('jumlah');
- $datadata['lamasewa']=$this->input->post('lamasewa');
- $datadata['surja']=$this->input->post('suratjaminan');
- $this->load->view('home/header');
- $this->load->view('booking/vdata_diri',$datadata);
- $this->load->view('home/footer');
- }else{
- $this->isi_datadiri($id);
- }
- }
- private function _uploadImage1()
- {
- $config['upload_path'] = './assets/img/datacustomer/';
- $config['allowed_types'] = 'gif|jpg|png';
- $config['max_size'] = 100000; // max 10 mb
- $config['max_width'] = 10200004;
- $config['max_height'] = 7680000;
- $this->load->library('upload', $config);
- if ($this->upload->do_upload('upftp')) {
- return $this->upload->data("file_name");
- }
- return "default.jpg";
- }
- private function _uploadImage2()
- {
- $config['upload_path'] = './assets/img/datacustomer/';
- $config['allowed_types'] = 'gif|jpg|png';
- $config['max_size'] = 100000; // max 10 mb
- $config['max_width'] = 10200004;
- $config['max_height'] = 7680000;
- $this->load->library('upload', $config);
- if ($this->upload->do_upload('upsurja')) {
- return $this->upload->data("file_name");
- }
- return "default.jpg";
- }
- public function view_mobil($id){
- $data['getmobil']=$this->model_rental->getmobilBYID($id);
- $this->load->view('home/header',$data);
- $this->load->view('booking/vreview_mobil',$data);
- $this->load->view('home/footer',$data);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement