<?php
		header("Access-Control-Allow-Origin: *");
		header("Access-Control-Allow-Headers: access");
		header("Access-Control-Allow-Methods: GET");
		header("Access-Control-Allow-Credentials: true");
		header("Content-Type: application/json; charset=UTF-8");

		include_once '../Database.php';
		include_once 'cupones.php';

		$database = new DataBase();
		$db = $database->getConnection();
     
        
        $ads = isset($_GET['ads'])?$_GET['ads']:0;
		$concepto = new Cupon($db);
		try{
			$stmt = $concepto->select("select * from ".$concepto->table_name."   where tipo=2 and id_anuncio=".$ads);
		$num = $stmt->rowCount();

		if($num>0){
		    $lista=array();
			while($row =$stmt->fetch(PDO::FETCH_ASSOC)){
				array_push($lista,$row);
			}
			echo json_encode($lista);
		}
		else {
			echo json_encode(array("Mensaje"=>"No se han encontrado registros"));
		}
	}catch(Exeption $e){
		echo json_encode(array("Error"=>"Error ".$e));
	}
	
		
?>
