Exemple #1
0
 public function saveVenta()
 {
     $this->load->model(array('Venta', 'DetalleVenta'));
     header("Content-type: application/json");
     $postdata = file_get_contents("php://input");
     $request = json_decode($postdata);
     $venta = new Venta();
     if (isset($request->folio)) {
         $venta->load($request->folio);
     }
     $venta->fecha = $request->fecha;
     $venta->cliente = $request->cliente->id;
     if ($venta->save()) {
         foreach ($request->deletedRows as $id) {
             $detalle = new DetalleVenta($id);
             $detalle->delete();
         }
         foreach ($request->rows as $row) {
             $detalle = new DetalleVenta();
             if (isset($row->id)) {
                 $detalle->load($row->id);
             }
             $detalle->venta = $venta->folio;
             $detalle->cantidad = $row->cantidad;
             $detalle->producto = $row->producto->codigo;
             $detalle->iepsUnidad = isset($row->iepsUnidad) && $row->iepsUnidad ? 1 : 0;
             $detalle->save();
         }
         $venta->loadObjectAttributes();
         $response = $this->setDocumentoVenta($venta);
         echo json_encode(array("success" => true, "ws" => $response));
     } else {
         echo json_encode(array("success" => true));
     }
 }
 function getList($p = 0, $rpp = 3, $condicion = "1=1", $parametro = array(), $orderby = "1")
 {
     $principio = $p * $rpp;
     $list = array();
     $sql = "select * from {$this->tabla} where {$condicion} order by {$orderby} limit {$principio},{$rpp}";
     $r = $this->bd->setConsulta($sql, $parametro);
     if ($r) {
         while ($fila = $this->bd->getFila()) {
             $detalleventa = new DetalleVenta();
             $detalleventa->set($fila);
             $list[] = $detalleventa;
         }
     } else {
         return null;
     }
     return $list;
 }
<?php

include_once '../conexion.php';
include_once '../formatter.php';
include_once '../table_handler.php';
include_once '../detalle_factura.php';
include_once '../detalle_venta.php';
include_once '../articulos/articulos.php';
include_once '../ventas/ventas.php';
include_once '../ventas/ventas_detalle.php';
Conexion::conectar();
$ventas = new Ventas();
$ventas_detalle = new VentasDetalle($_REQUEST['venta']);
$detalle = new DetalleVenta($_REQUEST['venta'], $ventas, $ventas_detalle);
$detalle->mostrar_detalle();
Exemple #4
0
 /**
  * @return DetalleVenta []
  */
 public function getDetalle()
 {
     $this->load->model('DetalleVenta');
     $detalle = new DetalleVenta();
     return array_values($detalle->get(array('venta' => $this->folio)));
 }