<?php

class Payment_model extends CI_Model {

    public $rules_in=array(
	'payment_type' => array('field' => 'payment_type', 'label' => 'Payment Type','rules' => 'trim|required'),
	'sending_code' => array('field' => 'sending_code', 'label' => 'Sending Code','rules' => 'trim|required'),
	'date_of_sending' => array('field' => 'date_of_sending', 'label' => 'Date Of Sending','rules' => 'trim|required'),
	'sender_fullname' => array('field' => 'sender_fullname', 'label' => 'Sender Fullname','rules' => 'trim|required'),
	'shipping_city' => array('field' => 'shipping_city', 'label' => 'Shipping City','rules' => 'trim|required'),
	'sender_phone' => array('field' => 'sender_phone', 'label' => 'Sender Phone','rules' => 'trim|required'),
	'payable_amount' => array('field' => 'payable_amount', 'label' => 'Payable Amount','rules' => 'trim|required'),
	'secret_question' => array('field' => 'secret_question', 'label' => 'Secret Question','rules' => 'trim|required'),
	'secret_answer' => array('field' => 'secret_answer', 'label' => 'Secret Answer','rules' => 'trim|required'),
	'recipent_fullname' => array('field' => 'recipent_fullname', 'label' => 'Recipent Fullname','rules' => 'trim|required'),
	'recipent_passport' => array('field' => 'recipent_passport', 'label' => 'Recipent Passport','rules' => 'trim|required'),
	'passport_exp_date' => array('field' => 'passport_exp_date', 'label' => 'Passport Exp Date','rules' => 'trim|required'),
	'payment_city' => array('field' => 'payment_city', 'label' => 'Payment City','rules' => 'trim|required'),	
	'Recipient_Phone' => array('field' => 'Recipient_Phone', 'label' => 'Recipient Phone','rules' => 'trim|required'),
	'paying_date' => array('field' => 'paying_date', 'label' => 'Paying Date','rules' => 'trim|required'),
	'agent_id' => array('field' => 'agent_id', 'label' => 'Agent Id','rules' => 'trim|required'));

	public $rules_org=array(
	'payment_type' => array('field' => 'payment_type', 'label' => 'Payment Type','rules' => 'trim|required'),
	'sending_code' => array('field' => 'sending_code', 'label' => 'Sending Code','rules' => 'trim|required'),
	'date_of_sending' => array('field' => 'date_of_sending', 'label' => 'Date Of Sending','rules' => 'trim|required'),
	'sender_fullname' => array('field' => 'sender_fullname', 'label' => 'Sender Fullname','rules' => 'trim|required'),
	'payable_amount' => array('field' => 'payable_amount', 'label' => 'Payable Amount','rules' => 'trim|required'),
	'recipent_fullname' => array('field' => 'recipent_fullname', 'label' => 'Recipent Fullname','rules' => 'trim|required'),
	'Recipient_CNI' => array('field' => 'Recipient_CNI', 'label' => 'Recipient CNI','rules' => 'trim|required'),
	'Recipient_Phone' => array('field' => 'Recipient_Phone', 'label' => 'Recipient Phone','rules' => 'trim|required'),
	'Recipient_address' => array('field' => 'Recipient_address', 'label' => 'Recipient Address','rules' => 'trim|required'),
	'Distribution_Number' => array('field' => 'Distribution_Number', 'label' => 'Distribution Number','rules' => 'trim|required'),
	'Name_of_project' => array('field' => 'Name_of_project', 'label' => 'Name Of Project','rules' => 'trim|required'),
	'paying_date' => array('field' => 'paying_date', 'label' => 'Paying Date','rules' => 'trim|required'),
	'agent_id' => array('field' => 'agent_id', 'label' => 'Agent Id','rules' => 'trim|required'));
	
	public function get_all(){
	$query = $this->db->get('payment');
	return $query->result();
	}
	
	public function get_all_invoice(){
	$this->db->select('*');
	  $this->db->from('payment');
	  $this->db->where('trash','no');
	  if(user_type()!="admin"){
	  $this->db->where('agent_id',$this->session->userdata("id"));
	  }
	  $query=  $this->db->get();
	  return $query->result();
	}
	
	public function get_by($id){
	  $this->db->select('*');
	  $this->db->from('payment');
	  $this->db->where('id',$id);
	  $query=  $this->db->get();
	  return $query->row();
	}

}