/** DE Base de DAtos */ function getCompra($idCompra = 1) { $compra = ControladorCompraVenta::obtenerCompraVentaID($idCompra); $cliente = $compra->getCliente(); $this->nombreCliente = $cliente->getNombre(); $this->clienteRFC = $cliente->getRFC(); $this->direccionCliente = $cliente->getCalle() . ' #' . $cliente->getNoEdificio() . ' En ' . $cliente->getCiudad()->getNombre(); $sucursal = $compra->getSucursal(); $this->direccionSucursal = $sucursal->getCalle() . ' #' . $sucursal->getNoEdificio(); $this->sucursalColonia = $sucursal->getColonia(); $this->ciudadSucursal = $sucursal->getCiudad()->getNombre(); $productos = $compra->getHerramientaComprada()->getIDHerramienta(); $cantidades = $compra->getHerramientaComprada()->getCantidad(); $total = 0; $arrayName = array(); foreach ($productos as $key => $value) { $herramienta = ControladorHerramienta::obtenerHerramientaID($value); $precio = $herramienta->getPrecio(); $subtotal = $herramienta->getPrecio() * $cantidades[$key]; $arrayName[] = array($cantidades[$key], $herramienta->getNombre(), $precio, $subtotal); $total = $total + $subtotal; } $this->productos = $arrayName; $this->subtotal = $total; $this->total = ($this->iva / 100 + 1) * $total; $this->noFactura = $idCompra; $this->setFecha($compra->getFecha()); }
$actual = ""; //Obtenemos las cantidades escogidas for ($j = 0; $j < strlen($cantidades); $j++) { if ($cantidades[$j] == '|') { $cantidadesArray[] = $actual; $actual = ""; } else { if ($cantidades[$j] == '*') { $actual = ""; } else { $actual = $actual . $cantidades[$j]; } } } //Obtenemos los IDS relacionados a cada seleccion del select foreach ($herramientaSelect as $key => $value) { $ID_Herramientas[] = $herramientasDB[$value]->getID(); } $herramientasCompradas->setIDHerramienta($ID_Herramientas); $herramientasCompradas->SetCantidad($cantidadesArray); $compra->setHerramientaComprada($herramientasCompradas); if (ControladorCompraVenta::insertarCompraVenta($compra)) { echo ControladorCompraVenta::obtenerUltimoIdentificador(); foreach ($ID_Herramientas as $key => $value) { ControladorHerramienta::disminuirHerramientas($value, $cantidadesArray[$key]); } } else { echo "KO"; } } //var_dump($compra);
session_start(); require_once __DIR__ . "/../Clases/ControladorBaseDatos.php"; require_once __DIR__ . "/../Clases/DesplegadorInterfaz.php"; require_once __DIR__ . "/../Clases/ControladorCompraVenta.php"; ControladorBaseDatos::validarSesionIniciada('VerVenta'); $plantilla = file_get_contents(__DIR__ . "/Plantillas/plantillaBusqueda.html"); $plantilla = str_replace('|header|', DesplegadorInterfaz::getHeader(), $plantilla); $plantilla = str_replace('|objeto|', 'Ventas', $plantilla); $plantilla = str_replace('|footer|', DesplegadorInterfaz::getFooter(), $plantilla); $inputNormal = '<input name="bID" type="text" id="bID" class="busqueda" placeholder="ID compra"> <input type="date" id="bFecha" class="busqueda" placeholder="Fecha yyyy-mm-dd"> <button onclick="href(\'?keyword_id=compra\');" class="lupa"><span class="fa fa-search"></span></button>'; $inputAvanzado = ''; $plantilla = str_replace('|busquedaBasica|', $inputNormal, $plantilla); $plantilla = str_replace('|busquedaAvanzada|', $inputAvanzado, $plantilla); $ventas = ControladorCompraVenta::frontendFunctions(); $conTab = $conTab . "<thead>"; $conTab = $conTab . "<th class='text-left'>ID</th>"; $conTab = $conTab . "<th class='text-left'>Reporte</th>"; $conTab = $conTab . "<th class='text-left'>Cliente</th>"; $conTab = $conTab . "<th class='text-left'>Sucursal</th>"; $conTab = $conTab . "<th class='text-left'>Fecha</th>"; $conTab = $conTab . "<th class='text-left'>Herramienta</th>"; $conTab = $conTab . "<th class='text-left'>Cantidad</th>"; $conTab = $conTab . "</thead>"; foreach ($ventas as $simple) { $herramientas = $simple->getHerramientaComprada()->getIDHerramienta(); $cantidades = $simple->getHerramientaComprada()->getCantidad(); $conTab = $conTab . "<tr>"; $conTab = $conTab . "<td rowspan=" . sizeof($herramientas) . ">"; $conTab = $conTab . $simple->getID();