<?php
require_once("report.php");
class Specific_duesupplier extends Report
{
	function __construct()
	{
		parent::__construct();
	}

	public function getDataColumns()
	{
		$col_data_final=array();

		$col_data_final[]="Date Time";
		$col_data_final[]="Payment Type";
		$col_data_final[]="Payment Amount";
		$col_data_final[]="Product Received Amount";
		return $col_data_final;
	}

	public function getData(array $inputs)
	{
		$this->db->select('trans_date,paytype,(CASE WHEN product_receive_amount < "0" THEN product_receive_amount*(-1) ELSE "" END) AS payment,(CASE WHEN product_receive_amount > "0" THEN product_receive_amount ELSE "" END) AS product_received', false);
		$this->db->from('supplier_trans_details');
		$this->db->where('trans_date BETWEEN "'. $inputs['start_date']. ' 00:00:00" and "'. $inputs['end_date'].' 23:59:59" and supplier_id='.$inputs['supplier_id'].' and product_receive_amount<>'."0".' and deleted='."0");
		$this->db->order_by('id',"DESC");
		$data= $this->db->get()->result_array();
		return $data;
	}

	public function getSummaryData(array $inputs)
	{
		$this->db->select('sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit');
		$this->db->from('sales_items_temp');
		$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'" and customer_id='.$inputs['customer_id']);
		if ($inputs['sale_type'] == 'sales')
		{
			$this->db->where('quantity_purchased > 0');
		}
		elseif ($inputs['sale_type'] == 'returns')
		{
			$this->db->where('quantity_purchased < 0');
		}
		return $this->db->get()->row_array();
	}
}
?>