<?php 
class AgregarcitaC extends CI_Controller
{
	
	function __construct()
	{
		parent::__construct();
		
		$this->load->model('agenda/cosmetologo/agregarcitaC_model');
		$this->load->library(array('session','form_validation'));
	}
	public function clientes(){
		if(isset($_GET['term'])){
			$result = $this->agregarcitaC_model->BuscarCliente($_GET['term']);
			if(count($result)>0){
				foreach ($result as $row) 
					$arr_result[] = array(
						'label' => $row->NombreCliente,
						'id'=> $row->IdClientes,
					);
					echo json_encode($arr_result);
				}
			}else {
				  echo "<script>alert('No se encontrarón los datos solicitados');</script>";
            // redirect('clientes/franquiciatario/clienteF','refresh');
			}
		}

public function servicios(){
		if(isset($_GET['term'])){
			$result = $this->agregarcitaC_model->BuscarServicio($_GET['term']);
				if(count($result)>0){
				foreach ($result as $row) 
					$arr_result[] = array(
					'label' => $row->NombreServicio,
					'id' => $row->IdServiciosFranquicias,
				);
					echo json_encode($arr_result);
				}
			}
	}
		public function serviciosG(){
		if(isset($_GET['term'])){
			$servicioG = $this->agregarcitaC_model->BuscarServicioG($_GET['term']);
				if(count($servicioG)>0){
				foreach ($servicioG as $row) 
					$arr_servicioG[] = array(
					'label' => $row->NombreServicio,
					'id' => $row->Codigo_Servicios,
				);
					echo json_encode($arr_servicioG);
				}
			}
		
}
//Promociones Institucionales
		public function promocionesIn(){
		if(isset($_GET['term'])){
			$result = $this->agregarcitaC_model->BuscarPromociones($_GET['term']);
				if(count($result)>0){
				foreach ($result as $row) 
					$arr_result[] = array(
					'label' => $row->NombrePromocion,
					'sesiones' => $row->FolioPromocion,
				);
					echo json_encode($arr_result);
				}
			}
	}
		//Promociones Franquicias
		public function promocionesF(){
		if(isset($_GET['term'])){
			$result = $this->agregarcitaC_model->BuscarPromocion($_GET['term']);
				if(count($result)>0){
				foreach ($result as $row) 
					$arr_result[] = array(
					'label' => $row->NombrePromocion,
					'sesiones' => $row->FolioPromocion,
				);
					echo json_encode($arr_result);
				}
			}
	}
}
