예제 #1
0
 function promocionesByCategorias(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $data = json_decode($request->getBody(), true);
     $data = Promocion::select("promocion.*")->join("categoriaspromocion", "categoriaspromocion.idPromocion", "=", "promocion.id")->whereIn("categoriaspromocion.idCategoria", $data['categorias'])->distinct()->get();
     if (count($data) == 0) {
         $response = $response->withStatus(404);
     }
     $response->getBody()->write($data);
     return $response;
 }
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once $_SERVER['DOCUMENT_ROOT'] . '/models/Promocion.php';
$PROMOCION = new Promocion();
if (empty($_POST['consulta'])) {
    $resultado = $PROMOCION->consultarPromociones("SELECT * FROM promo", 0, null, "ORDER BY fecha ASC");
    if (is_array($resultado)) {
        $_nombresEmpresa = $PROMOCION->traerNombresDeEmpresa($resultado["idEmpresa"]);
        echo crearPaginaReportes($resultado, $_nombresEmpresa);
    } else {
        echo "vacio";
    }
} else {
    $sql = base64_decode($_POST['consulta']);
    if (!empty($_POST['limite'])) {
        $resultado = $PROMOCION->consultarPromociones("{$sql}", $_POST['limite'], null, null);
    } else {
        $resultado = $PROMOCION->consultarPromociones("{$sql}", 0, null, null);
    }
    if (is_array($resultado)) {
        $_nombresEmpresa = $PROMOCION->traerNombresDeEmpresa($resultado["idEmpresa"]);
        echo crearPaginaReportes($resultado, $_nombresEmpresa);
    } else {
        echo "vacio";
    }
}
/****funcion que crea los cuadros de las promociones a partir de la consulta***********/
function crearPaginaReportes($resultado, $_nombresEmpresa)
{
예제 #3
0
function listaPromocionesPorProveedor()
{
    include_once '../php/clases/Promocion.class.php';
    $listaPromocion = new Promocion(1);
    $idProveedor = $_POST["idProveedor"];
    $idEstatus = $_POST["idEstatus"];
    $respuesta = $listaPromocion->listaPromocionesPorProveedor($idProveedor, $idEstatus);
    if (sizeof($respuesta)) {
        $exito = 1;
        $code = "";
        $msg = "Datos encontrados";
        $datos = array("exito" => $exito, "code" => $code, "msg" => $msg, "datos" => $respuesta);
    } else {
        $exito = 0;
        $code = "";
        $msg = "Busqueda de promociones sin resultados";
        $datos = array("exito" => $exito, "code" => $code, "msg" => $msg);
    }
    echo json_encode($datos);
}
예제 #4
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Promocion $obj A Promocion object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         PromocionPeer::$instances[$key] = $obj;
     }
 }
예제 #5
0
 /**
  * Exclude object from result
  *
  * @param   Promocion $promocion Object to remove from the list of results
  *
  * @return PromocionQuery The current query, for fluid interface
  */
 public function prune($promocion = null)
 {
     if ($promocion) {
         $this->addUsingAlias(PromocionPeer::ID, $promocion->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
예제 #6
0
 /**
  * Filter the query by a related Promocion object
  *
  * @param   Promocion|PropelObjectCollection $promocion  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return   ProductoQuery The current query, for fluid interface
  * @throws   PropelException - if the provided filter is invalid.
  */
 public function filterByPromocion($promocion, $comparison = null)
 {
     if ($promocion instanceof Promocion) {
         return $this->addUsingAlias(ProductoPeer::ID, $promocion->getProductoId(), $comparison);
     } elseif ($promocion instanceof PropelObjectCollection) {
         return $this->usePromocionQuery()->filterByPrimaryKeys($promocion->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByPromocion() only accepts arguments of type Promocion or PropelCollection');
     }
 }
예제 #7
0
 /**
  * @param	Promocion $promocion The promocion object to add.
  */
 protected function doAddPromocion($promocion)
 {
     $this->collPromocions[] = $promocion;
     $promocion->setProducto($this);
 }