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



class User extends CI_Controller 

{

	

	public function __construct()

	{

		parent::__construct();
	
		$this->load->library('form_validation');
		$this->load->model('aqadmin_model');		
		$this->load->library("pagination");
		$this->clear_cache();	
		define( 'SERVER_KEY', 'AAAA1CNpN5U:APA91bEqX8wnND4s74HM05GBogdOvhy99_te7ZZvgCzETTchl9j0MoYoDl5CxNehv5NRwjWI7v3gp-AqcxMA6ykPiU9zkEvYeRZWEyQMeAwY7TvI4YgSa8eqdWhed7BQZ0pmmjv3_kWt' );
	}
	function index()
	{
		$datas['tab']='home';
		$this->load->view("layout/header",$datas);
		$this->load->view("index",$datas);
		//$this->load->view("test",$datas);
		
	}
	function about()
	{
		$datas['tab']='about';
		$this->load->view("layout/header",$datas);
		$this->load->view("about",$datas);
	}
    function contact()
	{
		$datas['tab']='contact';
		$this->load->view("layout/header",$datas);
		$this->load->view("contact",$datas);
	}
	function clients()
	{
		$datas['tab']='clients';
		$this->load->view("layout/header",$datas);
		$this->load->view("clients",$datas);
	}
	
		function indexTest()
  {
		$datas['tab']='index';
        $this->load->view("layout/headerTest",$datas);                           
		$this->load->view("indexTest",$datas);
	}
	
	
	function gallery()
	{
		$id=$this->uri->segment(3);
		$client_id=base64_decode($id);
		
		$datas['client_id']=$client_id;
		$datas['tab']='clients';
		$this->load->view("layout/header",$datas);
		$this->load->view("gallery",$datas);
	} 
	
	function booking()
    {
		$datas['tab']='booking';
        $this->load->view("layout/header",$datas);                           
		$this->load->view("booking",$datas);
	}
	
	
	
	function emergency_index()
	{
		
		$booking_type=$this->input->post('booking_type');
		$appliance_type=$this->input->post('appliance_type');
		$television_type=$this->input->post('television_type');
		$cleaning_type=$this->input->post('cleaning_type'); 
		$service_type=$this->input->post('service_type');
		$name=$this->input->post('name');
		$contact= $this->input->post('contact');
		$phone_code= $this->input->post('phone_code');
		$watsapp_code = $this->input->post('watsapp_code');
		$watsapp= $this->input->post('watsapp');
		$appointment_date=date('Y/m/d', strtotime($this->input->post('appointment_date')));
		$appointment_time=$this->input->post('appointment_time');
		//$service_type=$this->input->post('service_type');
		/*$equipment_type="";
		// if($_POST['eq_type1'])
		// $category_interests="";
		if(!empty($_POST['eq_type']))
		{
			foreach ($_POST['eq_type'] as $value ) 
	    	{
			    // echo $value;
			    $equipment_type.=$value.",";
			}
			$equipment_type = chop($equipment_type,",");
		}*/
    	//$cardio=$this->input->post('cardio');
		$no_of_equipment=$this->input->post('no_of_equipment');
		//$strength=$this->input->post('strength');
		//$other=$this->input->post('other');
		$issue=$this->input->post('issue');
		$building=$this->input->post('building');
		$street=$this->input->post('street');
		$zone=$this->input->post('zone');
		$landmark=$this->input->post('landmark');
		$type_of_property=$this->input->post('type_of_property');	
		$companyName=$this->input->post('companyName');
		
		
		$booking_datetime=date('Y/m/d H:i:s');

		
		/*if($equipment_type=="")
		{
			echo "Select atlest one equipment";
		}
		else
		{*/
			$data=array(
				'booking_type'=>$booking_type,
				'appliance_type'=>$appliance_type,
				'television_type'=>$television_type,
				'cleaning_type'=>$cleaning_type,
				'service_type'=>$service_type,
				'name'=>$name,
				'contact'=> $contact,
				'phone_code'=> $phone_code,
				'watsapp_code'=> $watsapp_code,
				'watsapp'=>$watsapp,
				// 'equipment_type'=>$equipment_type,
				'appointment_date'=>$appointment_date,
				'appointment_time'=>$appointment_time,
				//'service_type'=>$service_type,
				'issue'=>$issue,
				//'cardio'=>$cardio,
				'no_of_equipment'=>$no_of_equipment,
				'building'=>$building,
				'street'=>$street,
				'zone'=>$zone,
				'landmark'=>$landmark,
				'type_of_property'=>$type_of_property,
				'companyName'=>$companyName,
				//'strength'=>$strength,
				//'other'=>$other,
				'booking_datetime'=>$booking_datetime);
			$this->aqadmin_model->insert('exp_bookings',$data);
			$datas['booking_type']=$booking_type;
			$datas['appliance_type']=$appliance_type;
			$datas['television_type']=$television_type;
			$datas['cleaning_type']=$cleaning_type;
			$datas['service_type']=$service_type;
			$datas['name']=$name;
			$datas['contact']= $contact ;
			$datas['phone_code']= $phone_code ;
			$datas['watsapp_code']= $watsapp_code ;
			$datas['watsapp']= $watsapp ;
			$datas['appointment_date']=$this->input->post('appointment_date');
			$datas['appointment_time']=$this->input->post('appointment_time');
			//$datas['service_type']=$service_type;
			$datas['issue']=$issue;
			// $datas['equipment_type']=$equipment_type;
			//$datas['cardio']=$cardio;
			$datas['no_of_equipment']= $no_of_equipment;
			$datas['building']= $building;
			$datas['street']= $street;
			$datas['zone']= $zone;
			$datas['landmark']= $landmark;
			$datas['type_of_property']= $type_of_property;
			$datas['companyName']= $companyName;
			//$datas['strength']=$strength;
			//$datas['other']=$other;
			$service = strval($service_type);
if( $service=="Fitness Equipment Maintenance"){ 
$subject=$service_type."/".$booking_type;

 } else if($service=="Home appliance services"){
$subject=$service_type."/".$appliance_type;	 
 } else if($service=="Television repair services"){
$subject=$service_type."/".$television_type;	 

} else if($service=="Industrial cleaning equipment services"){
$subject=$service_type."/".$cleaning_type;	
} else {
	
				$subject=$service_type;
}


			$message=$this->load->view('email/booking_email',$datas,TRUE); 
            /************************************mailing****************************************/
                     
            $this->load->library('email', array('mailtype'=>'html'));
            $this->email->set_mailtype("html");            
            $this->email->from('booking@expertsolutions.qa');
            $this->email->to("wo@expertsolutions.qa");
           // $this->email->cc("sajeetha92@gmail.com");
         //$this->email->cc($adminmail);
            
            $this->email->subject($subject);
                    
            $this->email->message($message);

            if($this->email->send())
            {
                echo "Success@";
            } 
            else 
            {
                echo "Mail not send@";
            }
            /************************************mailing****************************************/
            echo "Request received, our technical team will be in touch with you shortly. In addition to the information you’ve provided please click on this link <a href='wa.me/97450852253'>wa.me/97450852253</a> to share your location on WhatsApp";
		// }
		
		
	}
	function one_time_index()
	{
		
		$booking_type=$this->input->post('booking_type');
		$service_type=$this->input->post('service_type');
		
		$appliance_type=$this->input->post('appliance_type');
		$television_type=$this->input->post('television_type');
		$cleaning_type=$this->input->post('cleaning_type'); 
		$name=$this->input->post('name');
		$contact=$this->input->post('contact');
		$watsapp= $this->input->post('watsapp');
		$phone_code= $this->input->post('phone_code');
		$watsapp_code = $this->input->post('watsapp_code');
		$appointment_date=date('Y/m/d', strtotime($this->input->post('appointment_date')));
		$appointment_time=$this->input->post('appointment_time');
		$service_type=$this->input->post('service_type');
		/*$equipment_type="";
		
		if(!empty($_POST['eq_type']))
		{
			foreach ($_POST['eq_type'] as $value ) 
	    	{
			    // echo $value;
			    $equipment_type.=$value.",";
			}
			$equipment_type = chop($equipment_type,",");
		}*/
		$cardio=$this->input->post('cardio');
		$strength=$this->input->post('strength');
		$other=$this->input->post('other');
		$issue=$this->input->post('issue');
		$building=$this->input->post('building');
		$street=$this->input->post('street');
		$zone=$this->input->post('zone');
		$landmark=$this->input->post('landmark');
		$type_of_property=$this->input->post('type_of_property');	
		$companyName=$this->input->post('companyName');
		$booking_datetime=date('Y/m/d H:i:s');
		/*if($equipment_type=="")
		{
			echo "Select atlest one equipment";
		}
		else
		{*/
			$data=array('booking_type'=>$booking_type,
			    'appliance_type'=>$appliance_type,
				'television_type'=>$television_type,
				'cleaning_type'=>$cleaning_type,
				'name'=>$name,
				'contact'=>$contact,
				'watsapp'=>$watsapp,
				'phone_code'=> $phone_code,
				'watsapp_code'=> $watsapp_code,
				
				// 'equipment_type'=>$equipment_type,
				'appointment_date'=>$appointment_date,
				'appointment_time'=>$appointment_time,
				'service_type'=>$service_type,
				'issue'=>$issue,
				'cardio'=>$cardio,
				'strength'=>$strength,
				'other'=>$other,
				'building'=>$building,
				'street'=>$street,
				'zone'=>$zone,
				'landmark'=>$landmark,
				'type_of_property'=>$type_of_property,
				'companyName'=>$companyName,
				'booking_datetime'=>$booking_datetime);
			$this->aqadmin_model->insert('exp_bookings',$data);
			$datas['booking_type']=$booking_type;
			$datas['service_type']=$service_type;
			$datas['appliance_type']=$appliance_type;
			$datas['television_type']=$television_type;
			$datas['cleaning_type']=$cleaning_type;
			$datas['name']=$name;
			$datas['contact']= $contact ;
			$datas['watsapp']= $watsapp ;
			$datas['phone_code']= $phone_code ;
			$datas['watsapp_code']= $watsapp_code ;
			$datas['appointment_date']=$this->input->post('appointment_date');
			$datas['appointment_time']=$this->input->post('appointment_time');
			$datas['issue']=$issue;
			// $datas['equipment_type']=$equipment_type;
			$datas['cardio']=$cardio;
			$datas['strength']=$strength;
			$datas['other']=$other;
			$datas['building']= $building;
			$datas['street']= $street;
			$datas['zone']= $zone;
			$datas['landmark']= $landmark;
			$datas['type_of_property']= $type_of_property;
			$datas['companyName']= $companyName;
			$subject=$service_type."/".$booking_type;
			$message=$this->load->view('email/booking_email',$datas,TRUE); 
            /************************************mailing****************************************/
                     
            $this->load->library('email', array('mailtype'=>'html'));
            $this->email->set_mailtype("html");            
            $this->email->from('booking@expertsolutions.qa');
            $this->email->to("wo@expertsolutions.qa");
            //$this->email->cc("sajeetha92@gmail.com");

            
            $this->email->subject($subject);
                    
            $this->email->message($message);

            if($this->email->send())
            {
                echo "Success@";
            } 
            else 
            {
                echo "Mail not send@";
            }
            /************************************mailing****************************************/
            echo "Request received, our technical team will be in touch with you shortly. In addition to the information you’ve provided please click on this link <a href='wa.me/97450852253'>wa.me/97450852253</a> to share your location on WhatsApp";
		// }
		
	}
	function contract_index()
	{
		
		$name=$this->input->post('name');
		$contact=$this->input->post('contact');
		$watsapp= $this->input->post('watsapp');
		$phone_code= $this->input->post('phone_code');
		$watsapp_code = $this->input->post('watsapp_code');
		$booking_type=$this->input->post('booking_type');
		$service_type=$this->input->post('service_type');
		
		$appliance_type=$this->input->post('appliance_type');
		$television_type=$this->input->post('television_type');
		$cleaning_type=$this->input->post('cleaning_type'); 
		
		$frequency_of_visit=$this->input->post('frequency_of_visit');
		$site_visit=$this->input->post('site_visit');
		/*$equipment_type="";
		
		if(!empty($_POST['eq_type']))
		{
			foreach ($_POST['eq_type'] as $value ) 
	    	{
			    // echo $value;
			    $equipment_type.=$value.",";
			}
			$equipment_type = chop($equipment_type,",");
		}*/
		$cardio=$this->input->post('cardio');
		$strength=$this->input->post('strength');
		$other=$this->input->post('other');
		$issue=$this->input->post('issue');
		$building=$this->input->post('building');
		$street=$this->input->post('street');
		$zone=$this->input->post('zone');
		$landmark=$this->input->post('landmark');
		$type_of_property=$this->input->post('type_of_property');	
		$companyName=$this->input->post('companyName');
		$booking_datetime=date('Y/m/d H:i:s');
		/*if($equipment_type=="")
		{
			echo "Select atlest one equipment";
		}
		else
		{*/
			$data=array(
				'booking_type'=>$booking_type,
				'service_type'=>$service_type,
				'appliance_type'=>$appliance_type,
				'television_type'=>$television_type,
				'cleaning_type'=>$cleaning_type,
				'name'=>$name,
				'contact'=>$contact,
				'watsapp'=>$watsapp,
				'phone_code'=> $phone_code,
				'watsapp_code'=> $watsapp_code,
				// 'equipment_type'=>$equipment_type,
				'frequency_of_visit'=>$frequency_of_visit,
				'site_visit'=>$site_visit,
				'issue'=>$issue,
				'cardio'=>$cardio,
				'strength'=>$strength,
				'other'=>$other,
				'building'=>$building,
				'street'=>$street,
				'zone'=>$zone,
				'landmark'=>$landmark,
				'type_of_property'=>$type_of_property,
				'companyName'=>$companyName,
				'booking_datetime'=>$booking_datetime);
			$this->aqadmin_model->insert('exp_bookings',$data);
			$datas['booking_type']=$booking_type;
			$datas['service_type']=$service_type;
			$datas['appliance_type']=$appliance_type;
			$datas['television_type']=$television_type;
			$datas['cleaning_type']=$cleaning_type;
			$datas['name']=$name;
			$datas['contact']= $contact;
			$datas['watsapp']= $watsapp ;
			$datas['phone_code']= $phone_code ;
			$datas['watsapp_code']= $watsapp_code ;
			$datas['frequency_of_visit']=$frequency_of_visit;
			$datas['site_visit']=$site_visit;
			$datas['issue']=$issue;
			// $datas['equipment_type']=$equipment_type;
			$datas['cardio']=$cardio;
			$datas['strength']=$strength;
			$datas['other']=$other;
			$datas['building']= $building;
			$datas['street']= $street;
			$datas['zone']= $zone;
			$datas['landmark']= $landmark;
			$datas['type_of_property']= $type_of_property;
			$datas['companyName']= $companyName;
			$subject=$service_type."/".$booking_type;
			$message=$this->load->view('email/booking_email',$datas,TRUE); 
            /************************************mailing****************************************/
                     
            $this->load->library('email', array('mailtype'=>'html'));
            $this->email->set_mailtype("html");            
            $this->email->from('booking@expertsolutions.qa');
            $this->email->to("wo@expertsolutions.qa");
            
            //$this->email->cc("sajeetha92@gmail.com");

            
            $this->email->subject($subject);
                    
            $this->email->message($message);

            if($this->email->send())
            {
                echo "Success@";
            } 
            else 
            {
                echo "Mail not send@";
            }
            /************************************mailing****************************************/
            echo "Request received, our technical team will be in touch with you shortly. In addition to the information you’ve provided please click on this link <a href='wa.me/97450852253'>wa.me/97450852253</a> to share your location on WhatsApp";
        
	}
	 
	function otherservice_index()
	{
		//$booking_type=$this->input->post('booking_type');
		$appliance_type=$this->input->post('appliance_type');
		//$television_type=$this->input->post('television_type');
		//$cleaning_type=$this->input->post('cleaning_type'); 
		//$cctv_type=$this->input->post('cctv_type');
		$service_type=$this->input->post('service_type');
		$name=$this->input->post('name');
		$contact= $this->input->post('contact');
		$watsapp= $this->input->post('watsapp');
		$appointment_date=date('Y/m/d', strtotime($this->input->post('appointment_date')));
		$appointment_time=$this->input->post('appointment_time');
		
    	
		$no_of_equipment=$this->input->post('no_of_equipment');
		$issue=$this->input->post('issue');
		$building=$this->input->post('building');
		$street=$this->input->post('street');
		$zone=$this->input->post('zone');
		$landmark=$this->input->post('landmark');
		$type_of_property=$this->input->post('type_of_property');	
		$companyName=$this->input->post('companyName');
	
			$data=array(
				//'booking_type'=>$booking_type,
				'appliance_type'=>$appliance_type,
				//'television_type'=>$television_type,
				//'cleaning_type'=>$cleaning_type,
				//'cctv_type'=>$cctv_type,
				'service_type'=>$service_type,
				'name'=>$name,
				'contact'=> $contact,
				'watsapp'=>$watsapp,
				'appointment_date'=>$appointment_date,
				'appointment_time'=>$appointment_time,
				'issue'=>$issue,
				'no_of_equipment'=>$no_of_equipment,
				'building'=>$building,
				'street'=>$street,
				'zone'=>$zone,
				'landmark'=>$landmark,
				'type_of_property'=>$type_of_property,
				'companyName'=>$companyName);
				
			$this->aqadmin_model->insert('exp_bookings',$data);
			//$datas['booking_type']=$booking_type;
			$datas['appliance_type']=$appliance_type;
			//$datas['television_type']=$television_type;
			//$datas['cleaning_type']=$cleaning_type;
			//$datas['cctv_type']=$cctv_type;
			$datas['service_type']=$service_type;
			$datas['name']=$name;
			$datas['contact']= $contact ;
			$datas['watsapp']= $watsapp ;
			$datas['appointment_date']=$this->input->post('appointment_date');
			$datas['appointment_time']=$this->input->post('appointment_time');
			$datas['issue']=$issue;		
			$datas['no_of_equipment']= $no_of_equipment;
			$datas['building']= $building;
			$datas['street']= $street;
			$datas['zone']= $zone;
			$datas['landmark']= $landmark;
			$datas['type_of_property']= $type_of_property;
			$datas['companyName']= $companyName;
			
			$subject=$appliance_type;
			$message=$this->load->view('email/booking_email',$datas,TRUE); 
            /************************************mailing****************************************/
                     
            $this->load->library('email', array('mailtype'=>'html'));
            $this->email->set_mailtype("html");            
            $this->email->from('booking@expertsolutions.qa');
            $this->email->to("wo@expertsolutions.qa");
            //$this->email->cc("sajeetha92@gmail.com");
       
            
            $this->email->subject($subject);
                    
            $this->email->message($message);

            if($this->email->send())
            {
                echo "Success@";
            } 
            else 
            {
                echo "Mail not send@";
            }
            /************************************mailing****************************************/
            echo "Request received, our technical team will be in touch with you shortly. In addition to the information you’ve provided please click on this link <a href='wa.me/97450852253'>wa.me/97450852253</a> to share your location on WhatsApp";
		// }
		
		
	}
	function contact_us()
	{
		$name=$this->input->post('name');
		$email=$this->input->post('email');
		$phone=$this->input->post('phone');
		$contact_code=$this->input->post('contact_code');
		$subject=$this->input->post('subject');
		$message=$this->input->post('message');
		
		/*	$data=array(
				
				'name'=>$name,
				'email'=>$email,
				'phone'=>$phone,
				'contact_code'=>$contact_code,
				'subject'=>$subject,
				'message'=>$message);
				
			$this->aqadmin_model->insert('exp_contact',$data);	*/
			$datas['name']=$name;
			$datas['email']=$email;
			$datas['phone']=$phone;
			$datas['contact_code']=$contact_code;
			$datas['subject']=$subject;
			$datas['message']=$message;
			//$subject="General inquiry";
			
			
			if(empty($subject)){
			$subject="General inquiry"; }
		    $contact_email=$this->load->view('email/contact_email',$datas,TRUE); 
            /************************************mailing****************************************/
                     
            $this->load->library('email', array('mailtype'=>'html'));
            $this->email->set_mailtype("html");            
            $this->email->from($email);
            $this->email->to("info@expertsolutions.qa");
            //$this->email->cc("sajeetha92@gmail.com");
            
            $this->email->subject($subject);
                    
            $this->email->message($contact_email);
            

            if($this->email->send())
            {
                echo "Success";
            } 
            else 
            {
                echo "Mail not send";
            }
            /************************************mailing****************************************/
            /*echo "Success";*/
        
	}

	function clear_cache()
    {
        $this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, no-transform, max-age=0, post-check=0, pre-check=0");
        $this->output->set_header("Pragma: no-cache");
    }
}
