<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Home extends CI_Controller {
	public function __construct() {
		parent::__construct();
		$this->load->model('Home_model');
		$this->load->model('admin/Seo_admin_model');
		$this->load->library('form_validation');
		$this->load->library("pagination");
		$this->load->helper('cookie');
	}

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see https://codeigniter.com/userguide3/general/urls.html
	 */
	public function index()
	{  
	      $slug = current_url();
	    //  print_r($slug);exit;
		$metas = $this->customer->pageMetas($slug);
		if($metas != ''){
			$data['metatitle'] = $metas->title;
			$data['metakeyword'] = $metas->metakeyword;
			$data['metadescription'] = $metas->metadescription;
		}else{
			$data['metatitle'] = "home page";
			$data['metakeyword'] = "home page";
			$data['metadescription'] = "home page";
		} //print_r($data);exit;
		$data['result'] = $this->Home_model->get_home();
		$data1['teams'] = $this->Home_model->get_teams();
		$array = json_decode(json_encode($data1), true);
		foreach ($data1 as $value) 
    $array[] = (array)$value;
		//$data['results'] = $this->Home_model->get_review();
		
		/*$data['metatitle'] = $data['result']['metatitle'];
		$data['metakeyword'] = $data['result']['metakeyword'];
		$data['metadescription'] = $data['result']['metadescription'];*/
		$data['banner'] = $data['result']['banners'];
		//echo '<pre>';print_r( $data['result']['banners']);exit();
		/* $data['teamname']=$array['teams'][0]['name'];
		 $data['image']=$array['teams'][0]['image'];
		 $data['designation']=$array['teams'][0]['designation'];
		 $data['fb_link']=$array['teams'][0]['fb_link'];
		 $data['twitter_link']=$array['teams'][0]['twitter_link'];
		 $data['insta_link']=$array['teams'][0]['insta_link'];
		 $data['linkedin_link']=$array['teams'][0]['linkedin_link'];*/
		//echo $data['teamname'];exit();
		$this->load->view('front/home/Home',$data);
	}
	public function about()
	{
	    		$data['client'] = $this->Home_model->get_clients();

   // print_r($data);exit;
        $slug = current_url();
		$metas = $this->customer->pageMetas($slug);
		if($metas != ''){
			$data['metatitle'] = $metas->title;
			$data['metakeyword'] = $metas->metakeyword;
			$data['metadescription'] = $metas->metadescription;
		}else{
			$data['metatitle'] = "About Us";
			$data['metakeyword'] = "About Us";
			$data['metadescription'] = "About Us";
		} //print_r($data);exit;
		$this->load->view('front/home/about-us',$data);
	}
// 	public function blog()
// 	{   	$data['client'] = $this->Home_model->get_clients();
       
// 		$this->load->view('front/home/blog',$data);
// 	}
	public function contact_us()
	{
 $slug = current_url();
    print_r($slug);exit;
        
		$this->load->view('front/home/contact-us');
	}
	
		public function seo_newss()
	{
//  $slug = current_url();
//     print_r($slug);exit;
        
		$this->load->view('front/home/seo-new');
	}
		public function socialmedia()
	{
	//	$slug = $this->uri->segment(1);
    // print_r($slug);exit;
    $id=60;
     $slug = current_url();
		$metas = $this->customer->pageMetas($slug);
		if($metas != ''){
			$data['metatitle'] = $metas->title;
			$data['metakeyword'] = $metas->metakeyword;
			$data['metadescription'] = $metas->metadescription;
		}else{
			$data['metatitle'] = "SMO";
			$data['metakeyword'] = "SMO";
			$data['metadescription'] = "SMO";
		}
    $data['packname'] = $this->Home_model->get_packName($id);
        	$data['client'] = $this->Home_model->get_clients();
		$this->load->view('front/home/social-media',$data);
	}
		public function privacy()
	{
	//	$slug = $this->uri->segment(1);
    // print_r($slug);exit;
    // $data['packname'] = $this->Home_model->get_packName(60);
    //     	$data['client'] = $this->Home_model->get_clients();
		$this->load->view('front/home/privacy-policy');
	}
	
	 public function seor() { 
         /*Load the URL helper*/ 
         $this->load->helper('url'); 
         redirect('https://wedigitalindia.com/seo-company-in-delhi'); 
      } 
      
      public function newseo() { 
         /*Load the URL helper*/ 
         $this->load->helper('url'); 
         $id=1;
// 	$data['seo_banner'] = $this->Seo_admin_model->seo_banner($id);    
    $data['banner'] = $this->Home_model->seo_banner();
    $data['seo'] = $this->Home_model->seo();
        $data['faq'] = $this->Home_model->faq();


// 	print_r($data);

	$this->load->view('front/home/new-seo',$data);

      } 
	
		public function seonew()
	{
	$data['result'] = $this->Home_model->get_seo();
	$data['client'] = $this->Home_model->get_clients();
	$array = json_decode(json_encode($data), true);
		foreach ($data['result']['service'] as $value) 
    $array1[] = (array)$value;
    //print_r($array1);exit;
		$data['id'] = $array1[0]['id'];
			$data['name'] = $array1[0]['name'];
			//$data['heading'] = $array1[0]['heading'];
			$data['parent_id'] = $array1[0]['parent_id'];
			$data['short_description'] = $array1[0]['short_description'];
			$data['description'] = $array1[0]['description'];
			
			$data['Requirement'] = $array1[0]['Requirement'];
			$data['Prototype'] = $array1[0]['Prototype'];
		//	$data['Deployment'] = $array1['Deployment'];
			$data['Maintenance'] = $array1[0]['Maintenance'];
			 // $data['slug']=       $slug;
			$data['icon'] = $array1[0]['icon'];
			$data['image'] = $array1[0]['image'];
			$data['banner_image'] = $array1[0]['banner_image'];
			$data['metatitle'] = $array1[0]['metatitle'];
			$data['metakeyword'] = $array1[0]['metakeyword'];
			$data['metadescription'] = $array1[0]['metadescription'];
		$this->load->view('front/home/seo-new',$data);
	}
	
	
		public function term()
	{
	//	$slug = $this->uri->segment(1);
    // print_r($slug);exit;
    // $data['packname'] = $this->Home_model->get_packName(60);
    //     	$data['client'] = $this->Home_model->get_clients();
		$this->load->view('front/home/terms-conditions');
	}
	public function mission_vision_goals()
	{
	     $slug = current_url();
		$metas = $this->customer->pageMetas($slug);
		if($metas != ''){
			$data['metatitle'] = $metas->title;
			$data['metakeyword'] = $metas->metakeyword;
			$data['metadescription'] = $metas->metadescription;
		}else{
			$data['metatitle'] = "Mission Vession Goal";
			$data['metakeyword'] = "About Us";
			$data['metadescription'] = "About Us";
		}
	    
       	$data['client'] = $this->Home_model->get_clients();
		$this->load->view('front/home/mission-vision-goals',$data);
	}
	public function our_team()
	{
	     $slug = current_url();
		$metas = $this->customer->pageMetas($slug);
		if($metas != ''){
			$data['metatitle'] = $metas->title;
			$data['metakeyword'] = $metas->metakeyword;
			$data['metadescription'] = $metas->metadescription;
		}else{
			$data['metatitle'] = "Our Team";
			$data['metakeyword'] = "Our Team";
			$data['metadescription'] = "Our team";
		}
	    	$data['teams'] = $this->Home_model->get_teams();
     	$data['client'] = $this->Home_model->get_clients(); 
		$this->load->view('front/home/our-team',$data);
	}

	public function our_testimonial()
	{
	    	$data['testimonials'] = $this->Home_model->get_testimonials();
      	$data['client'] = $this->Home_model->get_clients();
		$this->load->view('front/home/our-testimonial',$data);
	}
	public function error()
	{
		$this->load->view('front/home/404');
	}
	public function seo()
	{	$data['result'] = $this->Home_model->get_seo();
	$data['client'] = $this->Home_model->get_clients();
	$array = json_decode(json_encode($data), true);
		foreach ($data['result']['service'] as $value) 
    $array1[] = (array)$value;
    //print_r($array1);exit;
		$data['id'] = $array1[0]['id'];
			$data['name'] = $array1[0]['name'];
			//$data['heading'] = $array1[0]['heading'];
			$data['parent_id'] = $array1[0]['parent_id'];
			$data['short_description'] = $array1[0]['short_description'];
			$data['description'] = $array1[0]['description'];
			
			$data['Requirement'] = $array1[0]['Requirement'];
			$data['Prototype'] = $array1[0]['Prototype'];
		//	$data['Deployment'] = $array1['Deployment'];
			$data['Maintenance'] = $array1[0]['Maintenance'];
			 // $data['slug']=       $slug;
			$data['icon'] = $array1[0]['icon'];
			$data['image'] = $array1[0]['image'];
			$data['banner_image'] = $array1[0]['banner_image'];
			$data['metatitle'] = $array1[0]['metatitle'];
			$data['metakeyword'] = $array1[0]['metakeyword'];
			$data['metadescription'] = $array1[0]['metadescription'];
      
		$this->load->view('front/home/seo',$data);
	}
	public function graphic()
	{
	     $slug = current_url();
		$metas = $this->customer->pageMetas($slug);
		if($metas != ''){
			$data['metatitle'] = $metas->title;
			$data['metakeyword'] = $metas->metakeyword;
			$data['metadescription'] = $metas->metadescription;
		}else{
			$data['metatitle'] = "Graphic";
			$data['metakeyword'] = "Graphic";
			$data['metadescription'] = "Graphic";
		}
      
		$this->load->view('front/home/graphic');
	}
	public function term_conditions()
	{
      
		$this->load->view('front/home/terms-conditions');
	}
	public function website()
	{	$slug = $this->uri->segment(1);
		if($this->customer->isCategory($slug)){
			$config = $this->customer->isCategory($slug);
			
			$data['id'] = $config['id'];
			$data['name'] = $config['name'];
			$data['heading'] = $config['heading'];
			$data['parent_id'] = $config['parent_id'];
			$data['short_description'] = $config['short_description'];
			$data['description'] = $config['description'];
			$data['icon'] = $config['icon'];
			$data['image'] = $config['image'];
			$data['banner_image'] = $config['banner_image'];
			$data['metatitle'] = $config['metatitle'];
			$data['metakeyword'] = $config['metakeyword'];
			$data['metadescription'] = $config['metadescription'];
			print_r($data);exit();
			$data['total_count'] = $this->Home_model->count_all_category();
			$data['clients'] = $this->Home_model->get_clients();
			$this->load->view("front/home/website", $data);
		} else{
			redirect('/');
		}
      
	//	$this->load->view('front/home/website');
	}
	public function why_wedigital_India()
	{	$data['client'] = $this->Home_model->get_clients();
      
		$this->load->view('front/home/why-weDigital-India',$data);
	}
	
	
	
		public function contactus()
	{
	    
      	$data['client'] = $this->Home_model->get_clients();
		$this->load->view('front/home/contact-us',$data);
	}
	
	public function single_blog()
	{
      
		$this->load->view('front/home/single-blog');
	}
	public function category(){
		$slug = $this->uri->segment(1);
		if($this->customer->isCategory($slug)){
			$config = $this->customer->isCategory($slug);
			
			$data['id'] = $config['id'];
			$data['name'] = $config['name'];
			$data['heading'] = $config['heading'];
			$data['parent_id'] = $config['parent_id'];
			$data['short_description'] = $config['short_description'];
			$data['description'] = $config['description'];
			$data['icon'] = $config['icon'];
			$data['image'] = $config['image'];
			$data['banner_image'] = $config['banner_image'];
			$data['metatitle'] = $config['metatitle'];
			$data['metakeyword'] = $config['metakeyword'];
			$data['metadescription'] = $config['metadescription'];
			print_r($data);exit();
			$data['total_count'] = $this->Home_model->count_all_category();
			$data['clients'] = $this->Home_model->get_clients();
			$this->load->view("front/home/website", $data);
		} else{
			redirect('/');
		}
	}
	
	public function category_ajax(){
		$data['product_count'] = $this->Home_model->count_all_category();
		/*----- Pagination ----*/
		$config = array();
		$config['base_url'] = base_url('services');
		$config['total_rows'] = $data['product_count'];
		$config['per_page'] = 12;
		$config['uri_segment'] = 3;
		$config['use_page_numbers'] = TRUE;
		$config['full_tag_open'] = '<ul class="pagination justify-content-center">';
		$config['full_tag_close'] = '</ul>';
		$config['first_link'] = 'First Page';

		$config['first_tag_open'] = '<li class="page-item firstlink">';
		$config['first_tag_close'] = '</li>';

		$config['last_link'] = 'Last Page';
		$config['last_tag_open'] = '<li class="page-item lastlink">';
		$config['last_tag_close'] = '</li>';

		$config['next_link'] = 'Next Page';
		$config['next_tag_open'] = '<li class="page-link page-link-next">';
		$config['next_tag_close'] = '</li>';
		$config['prev_link'] = 'Prev Page';

		$config['prev_tag_open'] = '<li class="page-link page-link-prev">';
		$config['prev_tag_close'] = '</li>';

		$config['cur_tag_open'] = '<li class="page-item curlink active">';
		$config['cur_tag_close'] = '</li>';

		$config['num_tag_open'] = '<li class="page-item numlink">';
		$config['num_tag_close'] = '</li>';
		$config['num_links'] = 3;
		
		$this->pagination->initialize($config);
		$page = $this->uri->segment(3);
		$start = ($page - 1) * $config['per_page'];
		$limit = $config['per_page'];
		
		$data['results'] = $this->Home_model->get_category($limit, $start)->result_array();
		// use the settings to initialize the library
		$data['pagination_link']  = $this->pagination->create_links();
		$output = $this->load->view("front/home/website", $data, true);
	
		echo json_encode($output);
	}
	/*------- Category End -----*/
	
	public function detail(){
		 $slug = $this->uri->segment(2);
		if($this->customer->isCategory($slug)){
			$pageInfo = $this->customer->isCategory($slug);
			$data['results'] = $this->Home_model->get_web($pageInfo['id']);
	$data['client'] = $this->Home_model->get_clients();
	$data['result'] = $this->Home_model->get_faq($pageInfo['name']);
		$data['packname'] = $this->Home_model->get_packName($pageInfo['id']);
	//print_r($data['packname']);
		//$data['pack'] = $this->Home_model->get_pack($pageInfo['id']);
			$data['id'] = $pageInfo['id'];
			$data['name'] = $pageInfo['name'];
			$data['heading'] = $pageInfo['heading'];
			$data['parent_id'] = $pageInfo['parent_id'];
			$data['short_description'] = $pageInfo['short_description'];
			$data['description'] = $pageInfo['description'];
			
			$data['Requirement'] = $pageInfo['Requirement'];
			$data['Prototype'] = $pageInfo['Prototype'];
			$data['Deployment'] = $pageInfo['Deployment'];
			$data['Maintenance'] = $pageInfo['Maintenance'];
			  $data['slug']=       $slug;
			$data['icon'] = $pageInfo['icon'];
			$data['image'] = $pageInfo['image'];
				$data['catimage'] = $pageInfo['catimage'];
			$data['banner_image'] = $pageInfo['banner_image'];
			$data['metatitle'] = $pageInfo['metatitle'];
			$data['metakeyword'] = $pageInfo['metakeyword'];
			$data['metadescription'] = $pageInfo['metadescription'];
			//$data['clients'] = $this->Home_model->get_clients();
	//	echo '<pre>';print_r($data);exit();
			$this->load->view("front/home/detail", $data);
		}else{
			redirect('/');
		}
	}
	
	public function blog(){
		$data['result'] = $this->Home_model->get_blogs();
		$data['allBlog'] = $this->Home_model->recent_blogs();
		$data['client'] = $this->Home_model->get_clients();
		//print_r($data['allBlog']);exit();
		$this->load->view("front/home/blog", $data);
	}

	public function blogs(){
		$slug = $this->uri->segment(2);
		$id = $this->customer->isBlog($slug);
		if($id){
		    	$data['sin'] = $this->Home_model->get_blog($id);
			$data['result'] = $this->Home_model->get_blog($id)->row();
			$data['metatitle'] = $data['result']->meta_title;
			$data['metakeyword'] = $data['result']->meta_keyword;
			$data['metadescription'] = $data['result']->meta_description;
			$data['allBlog'] = $this->Home_model->recent_blogs();
			$data['client'] = $this->Home_model->get_clients();
			$this->load->view("front/home/single-blog", $data);
		} else{
			redirect('/');
		}
	}
	
	public function submit_request(){
		//print_r('hello');exit();
	
	
			$query = $this->Home_model->submit_support_form();
			if($query){
				$this->session->set_flashdata('s_msg','Your request has been submitted successfully. We will contact you as soon as possible.');
				$this->session->set_flashdata('is_success','1');
					
			

				$message = '<table cellpadding="0" cellspacing="15" border="0" bgcolor="#c88843" width="100%" style="margin: auto;max-width:440px;font-family:arial;text-align: center;">
					<tbody>
					<tr bgcolor="#ffffff">
					<td>
					<table cellpadding="15" cellspacing="0" border="0" width="100%">
					<tbody>
					<tr>
					<td valign="middle" align="center" colspan="2">
					<h2 style=" color: green;">Wedigital India</h2></td>

					</tr>
					</tbody>
					</table>
					</td>
					</tr>

					<tr bgcolor="#ffffff">
					<td>
					<table cellpadding="0" cellspacing="0" border="0">
					<tbody>
					<tr>
					<td style="text-align:center;padding: 10px 0 0;">
					<h2 style=" text-align: center;">Support Form</h2>
					</td>
					</tr>
					<tr>
					<td>
					<table cellpadding="15" cellspacing="0" border="0" width="100%">
						<tbody>
							<tr>
								<td>
									<h4 style=" text-align: left;">Name</h4>
									<p>' . $this->input->post('name'). '</p>
								</td>
							</tr>
							<tr>
								<td>
									<h4 style=" text-align: left;">Last Name (if any)</h4>
									<p>' . $this->input->post('l_name'). '</p>
								</td>
									</tr>
							<tr>
								<td>
									<h4 style=" text-align: left;">Email</h4>
									<p>' . $this->input->post('email'). '</p>
								</td>
							</tr>
							<tr>
								<td>
									<h4 style=" text-align: left;">Contact Number</h4>
									<p>' . $this->input->post('phone'). '</p>
								</td>
							</tr>
							<tr>
								<td>
									<h4 style=" text-align: left;">Company Name (if any)</h4>
									<p>' . $this->input->post('message'). '</p>
								</td>
									</tr>
							<tr>
									<td>
									<h4 style=" text-align: left;">Location</h4>
									<p>' . $this->input->post('location'). '</p>
								</td>
									</tr>
							<tr>
									<td>
									<h4 style=" text-align: left;">Service</h4>
									<p>' . $this->input->post('Service'). '</p>
								</td>
							</tr>
							
						</tbody>
					</table>
					</td>
					</tr>
					</tbody>
					</table>
					</td>
					</tr>

					<tr bgcolor="#ffffff"><td>
					<table cellpadding="0" cellspacing="15" border="0" width="100%"><tbody><tr><td></td>
					</tr><tr><td><p style="margin:0;padding:0px;font-family:arial;font-size:13px;color:#121212;line-height:20px; style=" text-align: center;"">Wedigital India</p>
					</td></tr>
					</tbody></table>
					</td></tr>
					<tr>
					<td><p style="margin:0;padding:0px;font-family:arial;font-size:9px;color:#ffffff;line-height:20px;">
					This is a system generated mail. Please Do not reply of this mail .</p>
					</td>
					</tr>
					</tbody>
					</table>' ;         
                   $to = "info@wedigitalindia.com";
$subject = "Inquiry mail";

$from = $this->input->post('email');
//$headers = "From:" . $from;
$headers  = "From: $from\r\n"; 
    $headers .= "Content-type: text/html\r\n";
mail($to,$subject,$message,$headers);
					redirect('thank_you');
			}
			else{
				$this->session->set_flashdata('s_msg','Some error occured.');
				$this->session->set_flashdata('is_success','0');
				redirect('home');
			}
		
	}
	
	public function thank_you(){
		$this->load->view("front/home/thank-you");
	}
	
	public function detailgrap(){
		$slug = $this->uri->segment(2);
		if($this->customer->isCategory($slug)){
			$pageInfo = $this->customer->isCategory($slug);
	$data['results'] = $this->Home_model->get_grap($pageInfo['id']);
	$data['client'] = $this->Home_model->get_clients();
	$data['result'] = $this->Home_model->get_faq($pageInfo['name']);
		$data['packname'] = $this->Home_model->get_packName($pageInfo['id']);
	//print_r($data['packname'] );
		//$data['pack'] = $this->Home_model->get_pack($pageInfo['id']);
			$data['id'] = $pageInfo['id'];
			$data['name'] = $pageInfo['name'];
			$data['heading'] = $pageInfo['heading'];
			$data['parent_id'] = $pageInfo['parent_id'];
			$data['short_description'] = $pageInfo['short_description'];
			$data['description'] = $pageInfo['description'];
			
			$data['Requirement'] = $pageInfo['Requirement'];
			$data['Prototype'] = $pageInfo['Prototype'];
			$data['Deployment'] = $pageInfo['Deployment'];
			$data['Maintenance'] = $pageInfo['Maintenance'];
			  $data['slug']=       $slug;
			$data['icon'] = $pageInfo['icon'];
			$data['image'] = $pageInfo['image'];
				$data['catimage'] = $pageInfo['catimage'];
			$data['banner_image'] = $pageInfo['banner_image'];
			$data['metatitle'] = $pageInfo['metatitle'];
			$data['metakeyword'] = $pageInfo['metakeyword'];
			$data['metadescription'] = $pageInfo['metadescription'];
			//$data['clients'] = $this->Home_model->get_clients();
	//	echo '<pre>';print_r($data);exit();
			$this->load->view("front/home/graphic", $data);
		}else{
			redirect('/');
		}
	}

}
?>