<?php
defined('BASEPATH') or exit('No direct script access allowed');

class Kendaraan extends CI_Controller
{

	public function __construct()
	{
		parent::__construct();
		$this->load->model('Mmasuk');
	}

	public function index()
	{
		$data["kendaraan"] = $this->db->get("kendaraan")->result_array();
		$this->load->view('formkendaraan', $data);
	}

	public function tambah()
	{
		$id = $this->input->post("id_tabel");
		$data = [
			"no_kendaraan" => $this->input->post("no_kendaraan"),
			"nama_supir" => $this->input->post("nama_supir"),
			"alamat" => $this->input->post("alamat"),
		];
		if ($id == "0") {
			$this->db->insert("kendaraan", $data);
			echo "1";
		} else {
			$this->db->where("id", $id)->update("kendaraan", $data);
			echo "2";
		}
	}

	public function hapus()
	{
		$this->db->where("id", $this->input->post("id"))->delete("kendaraan");
		echo "3";
	}
}

/* End of file Masuk.php */
/* Location: ./application/controllers/Masuk.php */