<?php

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: *');

require '../../modelo/card_publicitario.php';
require '../../modelo/environment.php';
$response = array();

if (!isset($_POST['id_card_publicitario'])) {
    $response['response'] = 'error';
    $response['data'] = 'POST Error';
    echo json_encode($response);
    return;
}

$id_card_publicitario = $_POST['id_card_publicitario'];

$cardPublicitario = CardPublicitario::mdlGetCardPublicitario($id_card_publicitario);

if (!$cardPublicitario) {
    $response['response'] = 'error';
    $response['data'] = 'No se encontro card';
    echo json_encode($response);
    return;
}

$url_servidor = Environment::getUrlServidor();

$cardPublicitario['url_imagen'] = $url_servidor . $cardPublicitario['url_imagen'];

$response['response'] = 'success';
$response['data'] = $cardPublicitario;
echo json_encode($response);
