<?php 

class Cetak extends CI_Controller{

	function __construct(){
		parent::__construct();
	 	
		$this->load->model('m_kontak');/* sesuaikan dengan nama file pada model */
		$this->load->model('m_login'); 
		$this->load->model('m_admin'); 
		$this->load->model('m_kasir');
		$this->load->model('m_metode');
		$this->load->model('m_member');
		$this->load->model('m_barang');
		$this->load->model('m_kantor');
		$this->load->model('m_supliyer'); 
		$this->load->model('m_transaksi'); 
		$this->load->library('session');
		$this->load->library('upload');
		 
		$this->load->helper(array('form', 'url','tanggal'));
		if($this->session->userdata('status') != "loginbro"  and empty($this->session->userdata('email')) ){
			$this->session->set_flashdata('msg','<div class="alert alert-danger alert-dismissible">
						<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
						<strong> Admin Bukan Admin </strong>Ulangi Kembali
						</div> ');

			redirect(base_url("")); 
			
		}
	 
	}

	 
	 
 
	public function form_cetak($id){
		
		$data['kontak'] = $this->m_kontak->kontak(); 
		$username = $this->session->userdata("username");  
		$this->db->where('username',$username);
		$query = $this->db->get('tb_admin');
		$row = $query->row();
		$data['id_admin']= $row->id;
		$data['nama_admin']= $row->nama_admin;
		$data['id_kantor']= $row->id_kantor;
		$id_admin = $row->id;
		$level = $row->level;
		$id_kantor = $row->id_kantor;

		$id_transaksi =  $this->uri->segment(3);
		$this->db->where('id_transaksi',$id_transaksi);
		$query2 = $this->db->get('tb_transaksi');
		$row2 = $query2->row();
		$id_barang = $row2->id_barang;
		$id_member = $row2->id_member;
		$id_metode = $row2->metode_bayar;
		$id_admin = $row2->id_admin;

		//record dara
		$data['transaksi'] = $this->m_transaksi->struk($id_transaksi);  
		$data['admin'] = $this->m_admin->struk($id_admin);
		$data['barang'] = $this->m_barang->struk($id_barang); 
		$data['t_item'] = $this->m_transaksi->jumlah_item($id_transaksi); 
		$data['member'] = $this->m_member->struk($id_member); 
		$data['data_pembelian'] = $this->m_transaksi->struk_detail($id_transaksi); 
		$data['sub_total_hemat'] = $this->m_transaksi->sub_total_pembelian_hemat($id_transaksi);
		$data['metode'] = $this->m_transaksi->struk_metode($id_metode); 

	 	$this->load->view('master/kasir/print_nota',$data);
	     
		
	 


			 
	} 
	 public function form_kosong($id){
		
		
		
	    $this->load->view('master/kasir/form_kosong');
	}
	 
}