<?php namespace App\Controllers;

class News_details extends FrontController
{	 
	public function index(){		
		$data['meta_data']['title'] = "News Details";
		$data['meta_data']['description'] = "News Details";
		$data['meta_data']['keywords'] = "News Details";
		// $data['news_detail_data'] = $this->get_news_detail();
		$data['news_detail'] = $this->get_news_detail();

		$data['news_list_data'] = $this->get_news_list();

		// $data['footer_includes'] = ['career_js'];
			
		echo $this->view_inner_template('news_details',$data);
	}
	
	private function get_column_values(){
		$data['title'] = $this->request->getPost('title');
		$data['news_deails_id'] = $this->request->getPost('news_deails_id');
		return $data;
	}

	private function get_news_detail(){
		$builder = $this->cmObj->get_table_builder('news AS mt');
		$builder->join('news_ln AS ln',"mt.news_id=ln.news_id AND ln.language_code='".$this->project->default_lang_code."'","inner");
		$query  = $builder->select('mt.news_id,ln.title,mt.photo_image,
			mt.last_updated_date,mt.news_url,mt.publisher_name,mt.publish_date,ln.description')
				->where('mt.is_deleted','No')
				->where('mt.status','Active')
			->where('mt.news_id','ln.news_id')
			->get();
		return $query->getRowArray();
	}
	
	private function get_news_list(){
		$builder = $this->cmObj->get_table_builder('news AS mt');
		$builder->join('news_ln AS ln',"mt.news_id=ln.news_id AND ln.language_code='".$this->project->default_lang_code."'","inner");
		$query  = $builder->select('mt.news_id,ln.title,mt.photo_image,
			mt.last_updated_date,mt.news_url,mt.publisher_name,mt.publish_date,ln.description')
				->where('mt.is_deleted','No')
				->where('mt.status','Active')
				->get();
		
		return $query->getResultArray();
	}
	
}