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

class Ajax extends CI_Controller {

	/**
	 * 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 http://codeigniter.com/user_guide/general/urls.html
	 */
	 public function __construct(){
  		parent::__construct();
		$this->load->model(array('admin/admin_model'));
		 //if($this->admin_model->is_login === false){  redirect('admin/login', 'refresh'); exit; }
     }
	
	public function loadCaptchaImg()
	{
			$this->session->unset_userdata('S4A_CAPTCHA');
			$captcha = create_captcha(captcha_config());
 			$this->session->set_userdata('S4A_CAPTCHA', $captcha['word']);
			echo $captcha['image'];exit;
	}
	public function loadCaptchaImgLogin()
	{
			$this->session->unset_userdata('S4A_CAPTCHA_login');
			$captcha = create_captcha(captcha_config());
 			$this->session->set_userdata('S4A_CAPTCHA_login', $captcha['word']);
			echo $captcha['image'];exit;
	}
	
	function uploadEditorFile(){
  			 $resFile = $this->admin_model->uploadFile('file');
			 if($resFile['result']=='Success'){
					//echo base_url('uploads/files').'/'.$resFile['fileData']['file_name'];	 
					echo mail_url().'uploads/files/'.$resFile['fileData']['file_name'];	 
			 }else{
				echo 'ERROR';	 
			 }
			 
	}
  function videoupload(){
	 
   			 $resFile = $this->admin_model->videoUplode($_FILES['qqfile']);
			 echo json_encode( $resFile);exit;
	 
			 
	}
	  function deleteVideo(){
		 
			 echo json_encode($_POST);exit;
	}
	  
// 	   function ajaxGetSubCategory(){
// 		 extract($_POST);
// 		 $gymCategory = $this->input->post('gymCategory',TRUE);
// 		 $gymSubCategory = $this->input->post('gymSubCategory',TRUE);
// 		  $categoryFor = $this->input->post('categoryFor',TRUE);
// 		 $statesList = $this->admin_gym_model->getSubParentCategoryList($gymCategory,$categoryFor);
// 		 $ARR_DEPT = array(0=>'Select Sub Category');
// 		if(!empty($statesList)){
// 			foreach($statesList as $subDeptRow){
// 				$ARR_DEPT[$subDeptRow->categoryId] = $subDeptRow->categoryTitle;
// 			}
// 		}else{
// 			 $ARR_DEPT = array('No records found');
// 		}
// 		$js = 'class="form-control" id="gymSubCategory"  '; 
// 		echo form_dropdown('gymSubCategory',$ARR_DEPT,set_value('gymSubCategory',isset($gymSubCategory)?$gymSubCategory:''), $js); 
// 	 }
	function isExistsData() {
		$arrResponse = array('email' => 'not_exists','username' => 'not_exists');
		if($this->input->post('userEmail',TRUE)){
 				$userRow = $this->common_model->isExistUserEmail($this->input->post('userEmail',TRUE),$this->input->post('user_id',TRUE));
				if($userRow){
					$arrResponse['email'] = 'exist';
				}
 		}
		if($this->input->post('username',TRUE)){
			$userRow = $this->common_model->isExistUsername($this->input->post('username',TRUE),$this->input->post('user_id',TRUE));
			if($userRow){
				$arrResponse['username'] = 'exist';
			}
		}
		echo json_encode($arrResponse);
		exit;
	}
	function file_upload($soourceCode = ''){
	 	$data['soourceCode'] = $soourceCode;
		$this->load->library('UploadHandler',$data);
	}
	
	function videouploadBulk(){
//	    echo $this->input->post("myname")."HHH";exit;
   			 //$resFile = $this->admin_model->videoUplodeBulk($_FILES['qqfile'], $catId);
   			 $resFile= $this->admin_model->uploadSTDBGD(1);
			 echo json_encode( $resFile);exit;
	 
			 
	}
	function imageuploadBulk(){
	 
   			 //$resFile = $this->admin_model->imageUplodeBulk($_FILES['qqfile'], $catId);
   			 $resFile= $this->admin_model->uploadSTDBGD(2);
			 echo json_encode( $resFile);exit;
	 
			 
	}
	function imageuploadBulk6(){
	 
   			 $resFile = $this->admin_model->imageUplodeBulk6($_FILES['qqfile'], $galleryCategory);
   			 //$resFile= $this->admin_model->uploadSTDBGD(2);
			 echo json_encode( $resFile);exit;
	 
			 
	}
		function bwp(){
	 
   			 $resFile = $this->admin_model->bulkWallPaperUpload($_FILES['qqfile'], $galleryCategory);
			 echo json_encode( $resFile);exit;
	 
			 
	}
	
	
// 	function getquestionorder_max($val)
// 	{
// 	    $res= $this->admin_model->getquestionorder_Max($val);
// 	    echo $res;exit;
// 	}

}

/* End of file welcome.php 

   

*/
/* Location: ./application/controllers/welcome.php */