<?php 
namespace App\Modules\Home\Controllers;
ini_set("memory_limit","512M");
error_reporting(E_ALL ^ E_NOTICE);



use App\Modules\generic\Models\Mdl_generic;

use App\Modules\Home\Models\Mdl_home;

use CodeIgniter\Controller;

class Home extends Controller
{
   private $db;
 protected  $viewFile;
 protected  $email;
 protected  $captcha; 
 protected  $isLogin;
 
    /**
     * Constructor.
     */
    public function __construct()
    {
        //$db = \Config\Database::connect();
        $this->Mdl_home = new Mdl_home();
    }

    function index(){	
        //parent::Controller();
		$query_1 = 'SELECT * FROM banner WHERE status = "1" ORDER BY createdDate desc';
		$data['banners'] = $this->Mdl_home->customQuery($query_1);

		// $query_2 = 'SELECT title, slug, SubString(content, 1, 80) AS content FROM announcement WHERE status = "1" ORDER BY createdDate desc LIMIT 3';
		// $data['announcement'] = $this->Mdl_home->customQuery($query_2);

		$query_2 = 'SELECT SubString(name, 1, 80)AS name, post_date  FROM circulars WHERE status = "1" ORDER BY post_date desc LIMIT 3';
		$data['announcement'] = $this->Mdl_home->customQuery($query_2);
		// echo '<pre>';
		// print_r($data['announcement']);exit;
		// $data['announcement'] = "No Data";

		$query_3 = 'SELECT country, SubString(enquiry, 1, 80) AS enquiry FROM business_leads WHERE status = "1" ORDER BY createdDate desc LIMIT 3';
		$data['business'] = $this->Mdl_home->customQuery($query_3);

		$query_3 = 'SELECT * FROM advertise WHERE status = "1" ORDER BY createdDate desc';
		$data['advertise'] = $this->Mdl_home->customQuery($query_3);

        //$data['magazine'] = $this->Mdl_home->getByValue("e_magazine","id",1);
        $data['magazine'] = $this->Mdl_home->getByValue("magazine","id",1);

		$template = 'home';
		$data['country'] = $this->Mdl_home->getAllRecords("country");
		$data['seo'] = $this->Mdl_home->getByValue("seo","page","home");
		$data['view'] = 'home';
		$data['scriptFile'] = 'home';
		$data['module'] = "template";
			$data['viewFile'] = 'template/includes/home';
		
		$template = 'home';
		
		//echo Modules::run('template/'.$template, $data); 
		return view('template/'.$template, $data);
	}
	

}
