Beispiel #1
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->form = new VentaCabeceraForm(array('Fecha' => date('d/m/Y')));
     if ($request->isMethod('POST')) {
         $this->form->bind($request->getParameter('venta_cabecera'));
         if ($this->form->isValid()) {
             $valores = $this->form->getValues();
             $Factura = new Factura();
             $Factura->setClienteId($valores['Cliente']);
             $Factura->setTipoPagoId($valores['TipoPago']);
             $Factura->setFecha($valores['Fecha']);
             $Factura->setSerie($valores['Serie']);
             $Factura->setDocumento($valores['Documento']);
             $Factura->save();
             $this->redirect('venta/detalle?id=' . $Factura->getId());
         }
     }
 }
$stockDisponible = $juego->getStock() - $cantidad;
if ($cantidad > $stock) {
    echo $cantidad . "  " . $stock;
    echo "No hay suficientes unidades";
} else {
    /*GENERAMOS LA FACTURA*/
    $gestorFactura = new ManageFactura($bd);
    $facturas = new Factura();
    $facturas->read();
    $sesion = new Session();
    $id = $sesion->get("id");
    $time = time();
    $fecha = date("Y-m-d H:i:s", $time);
    echo $fecha;
    $facturas->setId_cliente($id);
    $facturas->setFecha($fecha);
    $r = $gestorFactura->insert($facturas);
    echo "El id de la factura es " . $r;
    /*GENERAMOS EL DETALLE*/
    $id_juego = Request::post("id_juego");
    $precio = Request::post("precio");
    $gestorDetalle = new ManageDetalle($bd);
    $detalles = new Detalle();
    $detalles->read();
    //$detalles->setNum_factura("27");
    $detalles->setNum_factura($r);
    echo "el numero de la factura es " . $facturas->getNum_factura();
    $detalles->setId_juego($id_juego);
    $detalles->setCantidad($cantidad);
    echo "<br/> la cantidad es " . $cantidad;
    echo $precioTotal = $cantidad * $precio;