<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * Created by PhpStorm.
 * User: capp
 * Date: 29/05/2018
 * Time: 15:49
 */


class Opening_account_model extends CI_Model
{
	public function getCountRequests($network_id , $validating_agent_id, $state){
		$query = $this->db->from('customer_account_opening_requests')->where('status',$state);
		if(!empty($validating_agent_id)){
			$query = $query->where('validating_agent_id', $validating_agent_id);
		}

		if(!empty($network_id)){
			$query = $query->where('network_id', $network_id);
		}
		return $query->count_all_results();
	}

	public function getInfosOpeningAccountRequestId($requestId){
		return $this->db->get_where('infos_customer_account_opening_requests',['id' => $requestId])->first_row();
	}

	public function getOpeningAccountRequestDocuments($requestId){
		return $this->db->get_where('customer_account_request_documents',['request_id' => $requestId])->result();
	}
}
