Primer commit del sistema avantika sin cambios
This commit is contained in:
200
modules/_facturacion-nueva.php
Executable file
200
modules/_facturacion-nueva.php
Executable file
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sucursalId = $_SESSION['idSuc'];
|
||||
|
||||
$_SESSION['tipoComp'] = '';
|
||||
$_SESSION['compFI'] = '';
|
||||
$_SESSION['compFF'] = '';
|
||||
$_SESSION['conceptos'] = array();
|
||||
$_SESSION['impuestos'] = array();
|
||||
$_SESSION["notasPorFacturar"] = array();
|
||||
|
||||
$totalDesglosado = array(
|
||||
'subtotal' => '0.00',
|
||||
'descuento' => '0.00',
|
||||
'afterDescuento' => '0.00',
|
||||
'iva' => '0.00',
|
||||
'afterIva' => '0.00',
|
||||
'ieps' => '0.00',
|
||||
'afterImpuestos' => '0.00',
|
||||
'retIva' => '0.00',
|
||||
'retIsr' => '0.00',
|
||||
'total' => '0.00'
|
||||
);
|
||||
|
||||
if(is_numeric($_GET['ventaId'])){
|
||||
|
||||
$ventaId = $_GET['ventaId'];
|
||||
|
||||
$venta->setVentaId($ventaId);
|
||||
$infV = $venta->Info();
|
||||
|
||||
$venta->LoadProductos();
|
||||
|
||||
if($infV['valDesc'] > 0){
|
||||
$datos['porcentajeDescuento'] = $infV['valDesc'];
|
||||
$post['porcentajeDescuento'] = $infV['valDesc'];
|
||||
}
|
||||
|
||||
$totalDesglosado = $venta->GetTotalDesglosado($datos);
|
||||
|
||||
$difCents = $infV['total'] - $totalDesglosado['total'];
|
||||
$difCents = number_format($difCents,2,'.','');
|
||||
|
||||
if($difCents == 0.01 || $difCents == -0.01){
|
||||
$totalDesglosado['iva'] += $difCents;
|
||||
$totalDesglosado['afterIva'] += $difCents;
|
||||
$totalDesglosado['afterImpuestos'] += $difCents;
|
||||
$totalDesglosado['total'] += $difCents;
|
||||
}
|
||||
|
||||
$totalDesglosado['iva'] = number_format($totalDesglosado['iva'],2,'.','');
|
||||
$totalDesglosado['afterIva'] = number_format($totalDesglosado['afterIva'],2,'.','');
|
||||
$totalDesglosado['afterDescuento'] = number_format($totalDesglosado['afterDescuento'],2,'.','');
|
||||
$totalDesglosado['afterImpuestos'] = number_format($totalDesglosado['afterImpuestos'],2,'.','');
|
||||
$totalDesglosado['total'] = number_format($totalDesglosado['total'],2,'.','');
|
||||
|
||||
if($totalDesglosado){
|
||||
foreach($totalDesglosado as $key => $total)
|
||||
{
|
||||
$totalDesglosado[$key] = number_format($totalDesglosado[$key], 2);
|
||||
}
|
||||
}
|
||||
|
||||
$concepts = $util->DecodeResult($_SESSION["conceptos"]);
|
||||
$smarty->assign('ventaId', $ventaId);
|
||||
$smarty->assign('conceptos', $concepts);
|
||||
$smarty->assign("totalDesglosado", $totalDesglosado);
|
||||
|
||||
}elseif(isset($_GET['mensual'])){
|
||||
|
||||
/*
|
||||
Factura Octubre = 2013-08-30 al 2013-09-28
|
||||
Factura Noviembre = 2013-09-29 al 2013-10-29
|
||||
Factura Diciembre = 2013-10-30 al 2013-11-28
|
||||
*/
|
||||
|
||||
$venta->setSucursalId($sucursalId);
|
||||
$vta = $venta->GetFirstTicket();
|
||||
|
||||
$fechaX = date('Y-m-01',strtotime($vta['fecha']));
|
||||
|
||||
while($fechaX < date('Y-m-01',strtotime('- 1 months'))){
|
||||
|
||||
$fechaI = date('Y-m-d', strtotime($fechaX.' - 2 days'));
|
||||
$venta->setFecha($fechaI);
|
||||
|
||||
if(!$venta->MesFacturado()){
|
||||
|
||||
//START
|
||||
|
||||
$fechaT = $fechaX;
|
||||
$fechaI = date('Y-m-d', strtotime($fechaT.' - 2 days'));
|
||||
$fecha2 = date('Y-m-d', strtotime($fechaT.' + 1 months'));
|
||||
$fechaF = date('Y-m-d', strtotime($fecha2.' - 3 days'));
|
||||
|
||||
$venta->setSucursalId($sucursalId);
|
||||
$total = $venta->TotalTicketsNoFact($fechaI, $fechaF);
|
||||
|
||||
if($total == 0)
|
||||
$fechaX = date('Y-m-d', strtotime($fechaX.' + 1 months'));
|
||||
else
|
||||
break;
|
||||
|
||||
//END
|
||||
|
||||
}else{
|
||||
$fechaX = date('Y-m-d', strtotime($fechaX.' + 1 months'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$fechaX = date('Y-m-d', strtotime($fechaX.' + 1 months'));
|
||||
|
||||
//$fechaT = date('Y-m-01');
|
||||
$fechaT = $fechaX;
|
||||
$fechaT = date('Y-m-d', strtotime($fechaT.' - 1 months'));
|
||||
|
||||
$fechaIni = date('Y-m-d', strtotime($fechaT.' - 2 days'));
|
||||
$fecha2 = date('Y-m-d', strtotime($fechaT.' + 1 months'));
|
||||
$fechaFin = date('Y-m-d', strtotime($fecha2.' - 3 days'));
|
||||
|
||||
//$fechaIni = '2013-09-10';
|
||||
//$fechaFin = '2013-10-30';
|
||||
|
||||
$venta->setSucursalId($sucursalId);
|
||||
$venta->TicketsNoFacturados($fechaIni, $fechaFin);
|
||||
|
||||
$_SESSION['tipoComp'] = 'Publico';
|
||||
$_SESSION['compFI'] = $fechaIni;
|
||||
$_SESSION['compFF'] = $fechaFin;
|
||||
|
||||
$facturacion->LoadConceptoPublico($_SESSION["notasPorFacturar"], $fechaIni, $fechaFin);
|
||||
$notasPorFacturar = implode("-", $_SESSION["notasPorFacturar"]);
|
||||
|
||||
$totalDesglosado = $facturacion->GetTotalDesglosado();
|
||||
if($totalDesglosado){
|
||||
foreach($totalDesglosado as $key => $total)
|
||||
{
|
||||
$totalDesglosado[$key] = number_format($totalDesglosado[$key], 2);
|
||||
}
|
||||
}
|
||||
|
||||
//Obtenemos la informacion del RFC
|
||||
|
||||
$rfc->setRfcId(1);
|
||||
$infR = $rfc->Info();
|
||||
|
||||
$post['rfc'] = $infR['rfc'];
|
||||
$post['razonSocial'] = $infR['razonSocial'];
|
||||
$post['calle'] = $infR['calle'];
|
||||
$post['noExt'] = $infR['noExt'];
|
||||
$post['noInt'] = $infR['noInt'];
|
||||
$post['colonia'] = $infR['colonia'];
|
||||
$post['municipio'] = $infR['ciudad'];
|
||||
$post['estado'] = $infR['estado'];
|
||||
$post['cp'] = $infR['cp'];
|
||||
$post['pais'] = 'MEXICO';
|
||||
$post['referencia'] = $infR['referencia'];
|
||||
$post['metodoPago'] = 'Efectivo';
|
||||
|
||||
|
||||
$smarty->assign('post', $_SESSION['conceptos']);
|
||||
$smarty->assign('ventaId', 'publico');
|
||||
$smarty->assign('conceptos', $_SESSION['conceptos']);
|
||||
$smarty->assign('notasPorFacturar', $notasPorFacturar);
|
||||
$smarty->assign('totalDesglosado', $totalDesglosado);
|
||||
|
||||
}//elseif
|
||||
|
||||
$ivas = $main->ListIvas();
|
||||
$retIsrs = $main->ListRetIsr();
|
||||
$retIvas = $main->ListRetIva();
|
||||
$tiposDeMoneda = $main->ListTipoDeMoneda();
|
||||
$comprobantes = $main->ListTiposDeComprobantesValidos();
|
||||
|
||||
$sucursal->setSucursalId($sucursalId);
|
||||
$infSuc = $sucursal->Info();
|
||||
$infSuc['nombre'] = urldecode($infSuc['nombre']);
|
||||
$infSuc['nombre'] = utf8_decode($infSuc['nombre']);
|
||||
|
||||
$excentoIva = $main->ListExcentoIva();
|
||||
|
||||
$smarty->assign("ivas", $ivas);
|
||||
$smarty->assign("retIsrs", $retIsrs);
|
||||
$smarty->assign("retIvas", $retIvas);
|
||||
$smarty->assign("excentoIva", $excentoIva);
|
||||
$smarty->assign("infSuc", $infSuc);
|
||||
$smarty->assign("post", $post);
|
||||
$smarty->assign('totalDesglosado', $totalDesglosado);
|
||||
$smarty->assign("tiposDeMoneda", $tiposDeMoneda);
|
||||
$smarty->assign("comprobantes", $comprobantes);
|
||||
|
||||
?>
|
||||
14
modules/analisis-venta.php
Executable file
14
modules/analisis-venta.php
Executable file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$fechaHoy = date('d-m-Y');
|
||||
|
||||
$resSuc = $reportes->EnumSucursales($Usr['type'],$Usr['usuarioId']);
|
||||
$resSuc2 = $util->DecodeUrlResult($resSuc);
|
||||
$sucursals = $util->DecodeResult($resSuc2);
|
||||
|
||||
$smarty->assign('fechaHoy',$fechaHoy);
|
||||
$smarty->assign('sucursals',$sucursals);
|
||||
|
||||
?>
|
||||
22
modules/atributos.php
Executable file
22
modules/atributos.php
Executable file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$atributo->SetPage($_GET["p"]);
|
||||
$atributos = $atributo->Enumerate();
|
||||
|
||||
$items = array();
|
||||
foreach($atributos['items'] as $res){
|
||||
$card = $res;
|
||||
|
||||
$atribVal->setAtributoId($res['atributoId']);
|
||||
$card['valores'] = $atribVal->EnumerateAll();
|
||||
|
||||
$items[] = $card;
|
||||
}
|
||||
$atributos['items'] = $items;
|
||||
|
||||
$smarty->assign('atributos', $atributos);
|
||||
|
||||
|
||||
?>
|
||||
12
modules/bonificacion-devolucion.php
Executable file
12
modules/bonificacion-devolucion.php
Executable file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$bonificacion->SetPage($_GET["p"]);
|
||||
$politicas = $politica->Enumerate();
|
||||
|
||||
|
||||
$smarty->assign('politicas', $politicas);
|
||||
|
||||
|
||||
?>
|
||||
13
modules/bonificaciones-agregar.php
Executable file
13
modules/bonificaciones-agregar.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$smarty->assign('msg', $msg);
|
||||
$smarty->assign('devoluciones', $devoluciones);
|
||||
|
||||
?>
|
||||
210
modules/bonificaciones-pendientes.php
Executable file
210
modules/bonificaciones-pendientes.php
Executable file
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$bonificacion->SetPage($_GET["p"]);
|
||||
|
||||
///// EVALUACION DE PEDIDOS
|
||||
|
||||
$evaluarPedidos = $evaluacion->Enumerate();
|
||||
$evaluacion->ActualizaPendientes();
|
||||
|
||||
$rfc->setRfcId("1");
|
||||
$rfcInfo = $rfc->Info();
|
||||
$items = array();
|
||||
$politicas = $politica->EnumerateAll();
|
||||
//print_r($evaluarPedidos);
|
||||
foreach($evaluarPedidos['items'] as $res)
|
||||
{
|
||||
$proveedor->setProveedorId($res['proveedorId']);
|
||||
$res['proveedor'] = $proveedor->GetNameById();
|
||||
$proveedorInfo = $proveedor->Info();
|
||||
$porcentajeBonifProveedor = $proveedorInfo['bonificacion'];
|
||||
|
||||
$evaluacion->setPedidoId($res['pedidoId']);
|
||||
$evaluacion->setPlazo($res['plazo']);
|
||||
$evaluacion->setFecha($res['fechaOrdenCompIng']);
|
||||
$evaluacion->setBonificacion($res['bonificacion']);
|
||||
|
||||
//echo $res['plazo']." ".$res['proveedor'];
|
||||
|
||||
/*$bonificacion->setPedidoId($res['pedidoId']);
|
||||
$bonificacion->setPlazo($res['plazo']);
|
||||
$bonificacion->setFecha($res['fechaEntrega']);
|
||||
$bonificacion->setBonificacion($res['bonificacion']);*/
|
||||
//echo $res['plazo']." ".$res['proveedor']."<br>";
|
||||
|
||||
if($evaluacion->evaluar() || $evaluacion->evaluar2())
|
||||
{
|
||||
$productosRes = $evaluacion->searchProductos();
|
||||
$productosR = array();
|
||||
|
||||
foreach($productosRes as $resP)
|
||||
{
|
||||
$auxiliar = 0;
|
||||
$bonificacion->setProdItemId($resP['prodItemId']);
|
||||
$bonificacion->setProveedorId($resP['proveedorId']);
|
||||
$bonificacion->setPedidoId($resP['pedidoId']);
|
||||
$bonificacion->setProductoId($resP['productoId']);
|
||||
|
||||
if($bonificacion->checkBonificacion() || ($bonificacion->checkBonificacion2() && $evaluacion->evaluar2()))
|
||||
{
|
||||
/*$atribVal->setAtribValId($resP['tallaId']);
|
||||
$talla = utf8_encode($atribVal->GetNameById());
|
||||
|
||||
$atribVal->setAtribValId($resP['colorId']);
|
||||
$color = utf8_encode($atribVal->GetNameById());*/
|
||||
|
||||
$evaluacion->setProductoId($resP['productoId']);
|
||||
|
||||
$resP['disponible'] = $evaluacion->GetDisponible();
|
||||
$resP['total'] = $evaluacion->GetTotalProductosPedido();
|
||||
$resP['vendido'] = $evaluacion->GetTotalVendidos();
|
||||
$resP['porcentajeVendido'] = $evaluacion->evaluarVentas();
|
||||
|
||||
$resP['costoTotal'] = $resP['total']*$resP['costo'];
|
||||
foreach($politicas as $key => $politica)
|
||||
{
|
||||
$porcentaje1 = $politicas[$key]['porcentajeEvaluacion'];
|
||||
if(isset($politicas[$key+1]['porcentajeEvaluacion']))
|
||||
$porcentaje2 = $politicas[$key+1]['porcentajeEvaluacion'];
|
||||
else
|
||||
$porcentaje2 = 0;
|
||||
//echo $resP['porcentajeVendido']." >= ".$porcentaje2." && ".$resP['porcentajeVendido']." < ".$porcentaje1."<br>";
|
||||
if($resP['porcentajeVendido'] >= $porcentaje2 && $resP['porcentajeVendido'] < $porcentaje1)
|
||||
{
|
||||
$auxiliar = 1;
|
||||
//echo $porcentaje1."-".$porcentaje2."<br>";
|
||||
//$resP['costoBonificacion'] = $resP['disponible']*(($resP['costo']*$porcentajeBonifProveedor)/100);
|
||||
$resP['costoBonificacion'] = $resP['disponible']*(($resP['costo']*$politicas[$key]['porcentajeBonificacion'])/100);
|
||||
$resP['porcentajeAplicado'] = $politicas[$key]['porcentajeBonificacion'];//$politica['porcentajeBonificacion'];
|
||||
if($politica['tipo'] == "Devolucion")
|
||||
{
|
||||
$resP['costoBonificacion'] = $resP['disponible']*$resP['costo'];
|
||||
//echo "#####".$resP['productoId']."<br>";
|
||||
//$resP['costoBonificacion'] = "";
|
||||
$resP['porcentajeAplicado'] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
$resP['nombre'] = $resP['modelo'];//.' '.$talla.' '.$color;
|
||||
//print_r($resP);
|
||||
if($auxiliar == 1)
|
||||
$productosR[] = $resP;
|
||||
}
|
||||
}
|
||||
//print_r($productosR);
|
||||
$res['productos'] = $productosR;
|
||||
$items[] = $res;
|
||||
}
|
||||
}
|
||||
|
||||
$evaluarPedidos['items'] = $items;
|
||||
//print_r($evaluarPedidos);
|
||||
//{foreach from=$evaluarPedidos.items item=item key=key}
|
||||
foreach($evaluarPedidos['items'] as $key => $evalua)
|
||||
{
|
||||
foreach($evalua['productos'] as $kk => $prod)
|
||||
{
|
||||
/*{if $it.porcentajeAplicado neq ""}
|
||||
<img src="{$WEB_ROOT}/images/icons/add.png" class="spanAdd" border="0"
|
||||
id="{$it.productoId}##{$it.prodItemId}##{$item.pedidoId}##{$item.proveedorId}##{$it.costo}##{$it.total}##{$it.disponible}##{$it.vendido}##{$it.porcentajeVendido}##{if $it.porcentajeAplicado > 0}{$it.porcentajeAplicado}{else}0{/if}##{if $it.costoBonificacion > 0}{$it.costoBonificacion}{/if}" title="Aplicar Bonificacion"/>
|
||||
{/if}
|
||||
{if $it.costoDevolucion neq ""}*/
|
||||
if($prod['porcentajeAplicado'] == "")
|
||||
{
|
||||
$tipo = "Devolucion";
|
||||
}else
|
||||
{
|
||||
$tipo = "Bonificacion";
|
||||
}
|
||||
//print_r($prod); exit(0);
|
||||
$productoId = $prod['productoId'];
|
||||
$prodItemId = $prod['prodItemId'];
|
||||
$pedidoId = $prod['pedidoId'];
|
||||
$proveedorId = $prod['proveedorId'];
|
||||
|
||||
$costo = $prod['costo'];
|
||||
$total = $prod['total'];
|
||||
$disponible = $prod['disponible'];
|
||||
$vendido = $prod['vendido'];
|
||||
$porcentajeVendido = $prod['porcentajeVendido'];
|
||||
$porcentajeAplicado = $prod['porcentajeAplicado'];
|
||||
$pagoTotal = $prod['costoBonificacion'];
|
||||
|
||||
$porcentajeBonifica = $prod['bonificacion'];
|
||||
$cantidad = $prod['costoBonificacion'];
|
||||
|
||||
$restante = $pagoTotal - $cantidad;
|
||||
|
||||
$bonificacion->setProdItemId($prodItemId);
|
||||
$bonificacion->setProveedorId($proveedorId);
|
||||
$bonificacion->setPedidoId($pedidoId);
|
||||
$bonificacion->setProductoId($productoId);
|
||||
$bonificacion->setPorcentajeBonifica($porcentajeBonifica);
|
||||
$bonificacion->setPagoTotal($pagoTotal);
|
||||
$bonificacion->setRestante($restante);
|
||||
$bonificacion->setPorcentajeAplicado($porcentajeAplicado);
|
||||
$bonificacion->setTotal($total);
|
||||
$bonificacion->setCosto($costo);
|
||||
$bonificacion->setDisponible($disponible);
|
||||
$bonificacion->setVendido($vendido);
|
||||
$bonificacion->setPorcentajeVendido($porcentajeVendido);
|
||||
//$bonificacion->setCantidad($cantidad);
|
||||
$bonificacion->setTipo($tipo);
|
||||
|
||||
$bonificacion->Save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///// FIN EVALUACION DE PEDIDOS
|
||||
|
||||
$bonificaciones = $bonificacion->Enumerate();
|
||||
|
||||
foreach($bonificaciones['items'] as $key => $productosBonificacion)
|
||||
{
|
||||
$proveedor->setProveedorId($productosBonificacion['proveedorId']);
|
||||
$bonificaciones['items'][$key]['nombreProveedor'] = $proveedor->GetNameById();
|
||||
|
||||
$bonificacion->setProductoId($productosBonificacion['productoId']);
|
||||
$bonificacion->setPedidoId($productosBonificacion['pedidoId']);
|
||||
$resP = $bonificacion->searchProductoById();
|
||||
|
||||
$producto->setProductoId($productosBonificacion['productoId']);
|
||||
$infoProd = $producto->Info();
|
||||
|
||||
/* $atribVal->setAtribValId($resP['tallaId']);
|
||||
$talla = utf8_encode($atribVal->GetNameById());
|
||||
|
||||
$atribVal->setAtribValId($resP['colorId']);
|
||||
$color = utf8_encode($atribVal->GetNameById());*/
|
||||
//echo $productosBonificacion['totalProductos']."***".$productosBonificacion['costoProducto']."<br>";
|
||||
$bonificaciones['items'][$key]['nombreProducto'] = $infoProd['modelo'];//$productosBonificacion['modelo'];//.' '.$talla.' '.$color;
|
||||
$bonificaciones['items'][$key]['codigoBarra'] = $infoProd['codigoBarra'];
|
||||
$bonificaciones['items'][$key]['costoTotal'] = $productosBonificacion['totalProductos']*$productosBonificacion['costoProducto'];
|
||||
$bonificaciones['items'][$key]['costoTotalVendido'] = $productosBonificacion['vendido']*$productosBonificacion['costoProducto'];
|
||||
@$bonificaciones['items'][$key]['porcentajeUtilidad'] = ($bonificaciones['items'][$key]['costoTotal']-$bonificaciones['items'][$key]['costoTotalVendido'])/$bonificaciones['items'][$key]['costoTotalVendido'];
|
||||
if($bonificaciones['items'][$key]['costoTotal'] > $bonificaciones['items'][$key]['costoTotalVendido'])
|
||||
$bonificaciones['items'][$key]['porcentajeUtilidad'] = "-".$bonificaciones['items'][$key]['porcentajeUtilidad'];
|
||||
}
|
||||
//print_r($bonificaciones);
|
||||
|
||||
$resPedidos = $evaluacion->GetPedidos();
|
||||
//print_r($resPedidos);
|
||||
foreach($resPedidos as $key => $resPedido)
|
||||
{
|
||||
$evaluacion->setPedidoId($resPedido['pedidoId']);
|
||||
$proveedor->setProveedorId($resPedido['proveedorId']);
|
||||
$resPedidos[$key]['compraFirme'] = $proveedor->GetCompraFirme();
|
||||
$totalBonificaciones = $evaluacion->getTotalBonificaciones();
|
||||
$totalDevoluciones = $evaluacion->getTotalDevoluciones();
|
||||
$resPedidos[$key]["totalBonificacion"] = $totalBonificaciones;
|
||||
$resPedidos[$key]["totalDevolucion"] = $totalDevoluciones;
|
||||
}
|
||||
|
||||
$smarty->assign('resPedidos', $resPedidos);
|
||||
$smarty->assign('bonificaciones', $bonificaciones);
|
||||
|
||||
|
||||
?>
|
||||
29
modules/bonificaciones.php
Executable file
29
modules/bonificaciones.php
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$bonificaciones = $bonificacion->EnumBonifDev();
|
||||
|
||||
$items = array();
|
||||
foreach($bonificaciones['items'] as $res){
|
||||
|
||||
$pedido->setPedidoId($res['pedidoId']);
|
||||
$infPed = $pedido->Info();
|
||||
|
||||
$usuario->setUsuarioId($res['usuarioId']);
|
||||
$res['usuario'] = $usuario->GetNameById();
|
||||
|
||||
$res['pedido'] = $infPed['noPedido'];
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$bonificaciones['items'] = $items;
|
||||
|
||||
$smarty->assign('bonificaciones', $bonificaciones);
|
||||
|
||||
?>
|
||||
10
modules/clientes.php
Executable file
10
modules/clientes.php
Executable file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$cliente->SetPage($_GET["p"]);
|
||||
$clientes = $cliente->Enumerate();
|
||||
|
||||
$smarty->assign("clientes", $clientes);
|
||||
|
||||
?>
|
||||
15
modules/colores.php
Executable file
15
modules/colores.php
Executable file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($Usr['type'] != 'admin' && $Usr['type'] != 'direccion'){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$color->SetPage($_GET["p"]);
|
||||
$colores = $color->Enumerate();
|
||||
|
||||
$smarty->assign('colores', $colores);
|
||||
|
||||
?>
|
||||
16
modules/comisiones.php
Executable file
16
modules/comisiones.php
Executable file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$atributo->SetPage($_GET["p"]);
|
||||
$comisiones = $comision->Enumerate();
|
||||
|
||||
foreach($comisiones['items'] as $key => $resComision)
|
||||
{
|
||||
$comisiones['items'][$key]['tipoUsuario'] = $util->GetNameUsrType($resComision['tipoUsuario']);
|
||||
}
|
||||
|
||||
$smarty->assign('comisiones', $comisiones);
|
||||
|
||||
|
||||
?>
|
||||
110
modules/conciliaciones.php
Executable file
110
modules/conciliaciones.php
Executable file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$pedido->setPage($_GET['p']);
|
||||
$pedidos = $pedido->EnumConciliaciones();
|
||||
|
||||
$items = array();
|
||||
foreach($pedidos['items'] as $res){
|
||||
|
||||
$pedidoId = $res['pedidoId'];
|
||||
|
||||
$pedido->setPedidoId($pedidoId);
|
||||
$productos = $pedido->GetProductos();
|
||||
|
||||
$costoCompra = 0;
|
||||
$precioVenta = 0;
|
||||
foreach($productos as $val){
|
||||
$totalProds = $val['totalLote'] * $val['cantLotes'];
|
||||
|
||||
$precioVenta += $val['precioVenta'] * $totalProds;
|
||||
}
|
||||
|
||||
$costoCompra = $res['total'];
|
||||
|
||||
$res['costoCompra'] = number_format($costoCompra,2,'.',',');
|
||||
$res['precioVenta'] = number_format($precioVenta,2,'.',',');
|
||||
|
||||
//Obtenemos el Porcentaje de Utilidad
|
||||
$utilidad = $precioVenta - $costoCompra;
|
||||
|
||||
if($costoCompra > 0){
|
||||
$porcUtilidad = ($utilidad * 100) / $costoCompra;
|
||||
$res['utilidad'] = number_format($porcUtilidad,2,'.',',');
|
||||
}else{
|
||||
$res['utilidad'] = 0;
|
||||
}
|
||||
|
||||
$proveedor->setProveedorId($res['proveedorId']);
|
||||
$res['proveedor'] = $proveedor->GetNameById();
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($res['fecha']));
|
||||
$hora = date('H:i:s',strtotime($res['fecha']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$res['fecha'] = $fecha.' '.$hora;
|
||||
|
||||
$fechaEntrega = date('d-m-Y',strtotime($res['fechaEntrega']));
|
||||
$res['fechaEntrega'] = $util->FormatDateDMMMY($fechaEntrega);
|
||||
|
||||
if($res['fechaEntregaF']){
|
||||
$fechaEntregaF = date('d-m-Y',strtotime($res['fechaEntregaF']));
|
||||
$res['fechaEntregaF'] = $util->FormatDateDMMMY($fechaEntregaF);
|
||||
}
|
||||
|
||||
//Obtenemos los Datos
|
||||
|
||||
$sql = 'SELECT sucursalId FROM envio AS env, envioPedido AS envPed
|
||||
WHERE env.envioId = envPed.envioId
|
||||
AND envPed.pedidoId = '.$pedidoId.'
|
||||
GROUP BY sucursalId';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$resSuc = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $suc){
|
||||
|
||||
$sucursalId = $suc['sucursalId'];
|
||||
|
||||
$sql = 'SELECT * FROM pedidoDistribucion
|
||||
WHERE sucursalId = '.$sucursalId.'
|
||||
AND pedidoId = '.$pedidoId;
|
||||
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$productos = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
$cantEnv = 0;
|
||||
$cantRec = 0;
|
||||
foreach($productos as $prod){
|
||||
|
||||
$sql = 'SELECT SUM(noPrendas) FROM envioRecibir
|
||||
WHERE pedidoId = '.$prod['pedidoId'].'
|
||||
AND productoId = '.$prod['productoId'];
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$cantRec += $util->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
$cantEnv += $prod['cantidad'];
|
||||
}
|
||||
|
||||
$card['enviadas'] = $cantEnv;
|
||||
$card['recibidas'] = $cantRec;
|
||||
|
||||
$sucursal->setSucursalId($sucursalId);
|
||||
$card['nombre'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$sucursales[] = $card;
|
||||
|
||||
}
|
||||
$res['sucursales'] = $sucursales;
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$pedidos['items'] = $items;
|
||||
|
||||
$proveedores = $proveedor->EnumerateAll();
|
||||
|
||||
$smarty->assign('msg', $msg);
|
||||
$smarty->assign('proveedores', $proveedores);
|
||||
$smarty->assign('pedidos', $pedidos);
|
||||
|
||||
?>
|
||||
12
modules/conjunto-tallas.php
Executable file
12
modules/conjunto-tallas.php
Executable file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$conTalla->SetPage($_GET["p"]);
|
||||
$conjuntos = $conTalla->Enumerate();
|
||||
|
||||
$_SESSION['conTallas'] = array();
|
||||
|
||||
$smarty->assign('conjuntos', $conjuntos);
|
||||
|
||||
?>
|
||||
15
modules/cuentas-bancarias.php
Executable file
15
modules/cuentas-bancarias.php
Executable file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($Usr['type'] != 'admin' && $Usr['type'] != 'direccion' && $Usr['type'] != 'almacen' && $Usr['type'] != 'centralizador'){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$cuentaBancaria->SetPage($_GET["p"]);
|
||||
$cuentasBancarias = $cuentaBancaria->Enumerate();
|
||||
|
||||
$smarty->assign('cuentasBancarias', $cuentasBancarias);
|
||||
|
||||
?>
|
||||
47
modules/cuentas-pagar-saldos.php
Executable file
47
modules/cuentas-pagar-saldos.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$proveedor->setPage($_GET['p']);
|
||||
$proveedores = $proveedor->EnumCtaPagarSaldos();
|
||||
|
||||
$items = array();
|
||||
foreach($proveedores['items'] as $res){
|
||||
|
||||
//Obtenemos los abonos realizados
|
||||
$cuentaPagar->setProveedorId($res['proveedorId']);
|
||||
$res['abonos'] = $cuentaPagar->GetTotalPagosProv();
|
||||
|
||||
$res['saldoActual'] = $res['saldoCtaPagar'] - $res['abonos'];
|
||||
|
||||
$cuentaPagar->setProveedorId($res['proveedorId']);
|
||||
$resPagos = $cuentaPagar->EnumPagosProv();
|
||||
|
||||
$pagos = array();
|
||||
foreach($resPagos as $val){
|
||||
|
||||
$metodoPago->setMetodoPagoId($val['metodoPagoId']);
|
||||
$val['metodoPago'] = $metodoPago->GetNameById();
|
||||
|
||||
$val['fecha'] = date('d-m-Y',strtotime($val['fecha']));
|
||||
|
||||
$pagos[] = $val;
|
||||
}
|
||||
$res['pagos'] = $pagos;
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$proveedores['items'] = $items;
|
||||
|
||||
$suppliers = $proveedor->EnumerateAll();
|
||||
|
||||
$smarty->assign('msg', $msg);
|
||||
$smarty->assign('proveedores', $proveedores);
|
||||
$smarty->assign('suppliers', $suppliers);
|
||||
|
||||
?>
|
||||
59
modules/cuentas-pagar.php
Executable file
59
modules/cuentas-pagar.php
Executable file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
/*
|
||||
$cuentaPagar->setPage($_GET['p']);
|
||||
$resCuenta = $cuentaPagar->Enumerate();
|
||||
|
||||
$items = array();
|
||||
foreach($resCuenta['items'] as $res){
|
||||
|
||||
if(preg_match('/FOLIO/i',$res['folioProv']))
|
||||
continue;
|
||||
|
||||
$proveedor->setProveedorId($res['proveedorId']);
|
||||
$res['proveedor'] = $proveedor->GetNameById();
|
||||
|
||||
//Obtenemos los abonos realizados
|
||||
$cuentaPagar->setPedidoId($res['pedidoId']);
|
||||
$res['abonos'] = $cuentaPagar->GetTotalPagos();
|
||||
|
||||
$totalDesc = $res['totalPub'] + $res['totalDes'] + $res['totalFlete'] + $res['totalEsp'];
|
||||
$res['totalDescuentos'] = number_format($totalDesc,2,'.','');
|
||||
|
||||
$res['saldo'] = $res['total'] - $res['abonos'] - $res['bonificaciones'] - $res['devoluciones'] - $res['totalDescuentos'];
|
||||
|
||||
$cuentaPagar->setPedidoId($res['pedidoId']);
|
||||
$resPagos = $cuentaPagar->EnumPagos();
|
||||
|
||||
$pagos = array();
|
||||
foreach($resPagos as $val){
|
||||
|
||||
$cuentaBancaria->setCuentaBancariaId($val['cuentaBancariaId']);
|
||||
$val['cuentaBancaria'] = $cuentaBancaria->GetNameById();
|
||||
|
||||
$metodoPago->setMetodoPagoId($val['metodoPagoId']);
|
||||
$val['metodoPago'] = $metodoPago->GetNameById();
|
||||
|
||||
$val['fecha'] = date('d-m-Y',strtotime($val['fecha']));
|
||||
|
||||
$pagos[] = $val;
|
||||
}
|
||||
$res['pagos'] = $pagos;
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$resCuenta['items'] = $items;
|
||||
*/
|
||||
$proveedores = $proveedor->EnumerateAll();
|
||||
|
||||
$smarty->assign('msg', $msg);
|
||||
$smarty->assign('proveedores', $proveedores);
|
||||
$smarty->assign('cuentasPagar', $resCuenta);
|
||||
|
||||
?>
|
||||
17
modules/datos-generales.php
Executable file
17
modules/datos-generales.php
Executable file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($Usr['type'] != 'admin' && $Usr['type'] != 'direccion' && $Usr['type'] != 'almacen' && $Usr['type'] != 'centralizador'){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rfc->setEmpresaId($_SESSION['empresaId']);
|
||||
$result = $rfc->GetRfcsByEmpresa();
|
||||
$result2 = $util->DecodeUrlResult($result);
|
||||
$empresasRfcs = $util->DecodeResult($result2);
|
||||
|
||||
$smarty->assign('empresaRfcs', $empresasRfcs);
|
||||
|
||||
?>
|
||||
274
modules/debug.php
Executable file
274
modules/debug.php
Executable file
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
exit;
|
||||
$sql = 'SHOW TABLES';
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$tables = $util->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$tablas = array();
|
||||
foreach($tables as $t){
|
||||
|
||||
$tabla = $t['Tables_in_avantikads_nm'];
|
||||
|
||||
$sql = 'DESCRIBE '.$tabla;
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$campos = $util->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
foreach($campos as $c){
|
||||
|
||||
if($c['Field'] == 'proveedorId'){
|
||||
if(!in_array($tabla, $tablas))
|
||||
$tablas[] = $tabla;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo 'Tablas con Proveedores';
|
||||
echo '<br><br>';
|
||||
|
||||
//Eliminar 597. Dejar 77
|
||||
//Eliminar 598. Dejar 70
|
||||
//Eliminar 536. Dejar 124
|
||||
|
||||
foreach($tablas as $tabla){
|
||||
|
||||
if($tabla == 'proveedor')
|
||||
continue;
|
||||
|
||||
$sql = 'SELECT COUNT(*) FROM '.$tabla.' WHERE proveedorId = 597';
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total597 = $util->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$sql = 'SELECT COUNT(*) FROM '.$tabla.' WHERE proveedorId = 598';
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total598 = $util->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$sql = 'SELECT COUNT(*) FROM '.$tabla.' WHERE proveedorId = 536';
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total536 = $util->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
echo $tabla.' = 597 = '.$total597.' :: 598 = '.$total598.' :: 536 = '.$total536;
|
||||
echo '<br>';
|
||||
/*
|
||||
$sql = 'UPDATE '.$tabla.' SET proveedorId = 77 WHERE proveedorId = 597';
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$util->DBSelect($_SESSION["empresaId"])->UpdateData();
|
||||
|
||||
$sql = 'UPDATE '.$tabla.' SET proveedorId = 70 WHERE proveedorId = 598';
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$util->DBSelect($_SESSION["empresaId"])->UpdateData();
|
||||
|
||||
$sql = 'UPDATE '.$tabla.' SET proveedorId = 124 WHERE proveedorId = 536';
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$util->DBSelect($_SESSION["empresaId"])->UpdateData();
|
||||
*/
|
||||
}
|
||||
|
||||
echo '<br><br>';
|
||||
echo 'Done';
|
||||
|
||||
exit;
|
||||
exit;
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM envio
|
||||
WHERE status = 'Pendiente'";
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $util->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
foreach($result as $res){
|
||||
|
||||
echo $res['envioId'];
|
||||
echo '<br>';
|
||||
|
||||
$envio->setEnvioId($res['envioId']);
|
||||
$info = $envio->Info();
|
||||
|
||||
$resOrdenes = $envio->GetPedidos();
|
||||
|
||||
$ordenes = array();
|
||||
foreach($resOrdenes as $res){
|
||||
|
||||
$pedidoId = $res['pedidoId'];
|
||||
|
||||
$pedido->setPedidoId($pedidoId);
|
||||
$infP = $pedido->Info();
|
||||
|
||||
$fechaIng = date('Y-m-d',strtotime($infP['fechaOrdenCompIng']));
|
||||
|
||||
if($fechaIng >= '2013-12-17')
|
||||
continue;
|
||||
|
||||
echo ' - '.$res['pedidoId'].' = '.$fechaIng;
|
||||
echo '<br>';
|
||||
|
||||
$pedido->setSucursalId($info['sucursalId']);
|
||||
$items = $pedido->GetItemsDistSuc();
|
||||
|
||||
$total = 0;
|
||||
$totPrendas = 0;
|
||||
$productos = array();
|
||||
foreach($items as $val){
|
||||
|
||||
/*
|
||||
if($val['envioId'] != $envioId && $envioId >= 4791) //Local 4776, Prod = 4791
|
||||
continue;
|
||||
*/
|
||||
|
||||
if($val['envioId'] == 0){
|
||||
echo ' > '.$val['productoId'];
|
||||
echo ' = '.$val['pedDistId'].' = '.$val['envioId'];
|
||||
echo '<br>';
|
||||
}
|
||||
|
||||
$producto->setProductoId($val['productoId']);
|
||||
$infP = $producto->Info();
|
||||
|
||||
$pedido->setProductoId($val['productoId']);
|
||||
$infPP = $pedido->GetInfoProd();
|
||||
|
||||
if($infPP['prendasComp'] == 0)
|
||||
$val['cantidad'] = $val['prendas'];
|
||||
|
||||
$prendas = $val['cantidad'];
|
||||
|
||||
$totPrendas += $prendas;
|
||||
|
||||
$total += $prendas * $infP['costo'];
|
||||
|
||||
//Informacion del Producto
|
||||
|
||||
if($val['cantidad']){
|
||||
$card['codigoBarra'] = $infP['codigoBarra'];
|
||||
$card['modelo'] = $infP['modelo'];
|
||||
$card['cantidad'] = $val['cantidad'];
|
||||
$card['cajas'] = $val['cajas'];
|
||||
|
||||
$productos[] = $card;
|
||||
}
|
||||
|
||||
}//foreach
|
||||
|
||||
$res['total'] = number_format($total,2);
|
||||
$res['prendas'] = $totPrendas;
|
||||
$res['productos'] = $productos;
|
||||
|
||||
$ordenes[] = $res;
|
||||
}
|
||||
|
||||
}//foreach
|
||||
|
||||
exit;
|
||||
exit;
|
||||
|
||||
$envioId = 4786;
|
||||
|
||||
$envio->setEnvioId($envioId);
|
||||
$info = $envio->Info();
|
||||
|
||||
echo $sucursalId = $info['sucursalId'];
|
||||
echo '<br>';
|
||||
|
||||
$resOrdenes = $envio->GetPedidos();
|
||||
|
||||
$productos = array();
|
||||
$idProds = array();
|
||||
foreach($resOrdenes as $res){
|
||||
|
||||
$pedidoId = $res['pedidoId'];
|
||||
|
||||
$pedido->setPedidoId($pedidoId);
|
||||
$infP = $pedido->Info();
|
||||
|
||||
echo $res['pedidoId'].' = '.$infP['noPedido'];
|
||||
echo '<br>';
|
||||
|
||||
//Obtenemos los Productos
|
||||
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
pedidoDistribucion
|
||||
WHERE
|
||||
pedidoId = '".$pedidoId."'
|
||||
AND
|
||||
sucursalId = '".$sucursalId."'
|
||||
AND
|
||||
status = 'Enviado'";
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$productos = $util->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
foreach($productos as $val){
|
||||
|
||||
$pedDistId = $val['pedDistId'];
|
||||
|
||||
if($val['cantidad'] == 0)
|
||||
continue;
|
||||
|
||||
$pedido->setProductoId($val['productoId']);
|
||||
$infPP = $pedido->GetInfoProd();
|
||||
|
||||
if($infPP['prendasComp'] == 0)
|
||||
$val['cantidad'] = $val['prendas'];
|
||||
|
||||
$val['cantPrendas'] = $val['cantidad'];
|
||||
|
||||
echo ' ';
|
||||
echo $pedDistId.' :: '.$val['productoId'].' = '.$val['cantPrendas'].' = '.$val['envioId'];
|
||||
echo '<br>';
|
||||
|
||||
$sql = 'UPDATE pedidoDistribucion SET envioId = '.$envioId.'
|
||||
WHERE pedDistId = '.$pedDistId;
|
||||
//$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
//$util->DBSelect($_SESSION["empresaId"])->UpdateData();
|
||||
//echo $sql.'<br>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exit;
|
||||
exit;
|
||||
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM `pedido`
|
||||
WHERE `status` = 'OrdenCompIng'
|
||||
AND pedidoId <= 4003
|
||||
ORDER BY pedidoId DESC";
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $util->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
foreach($result as $res){
|
||||
|
||||
$pedidoId = $res['pedidoId'];
|
||||
|
||||
echo $pedidoId;
|
||||
echo '<br>';
|
||||
|
||||
$sql = "UPDATE `_pedidoProducto` SET recibido = '1'
|
||||
WHERE pedidoId = ".$pedidoId;
|
||||
//echo $sql.'<br>';
|
||||
//$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
//$util->DBSelect($_SESSION["empresaId"])->UpdateData();
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM `pedidoProducto`
|
||||
WHERE pedidoId = ".$pedidoId;
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$productos = $util->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
foreach($productos as $p){
|
||||
|
||||
$productoId = $p['productoId'];
|
||||
|
||||
echo ' '.$productoId.' = '.$p['recibido'];
|
||||
echo '<br>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
52
modules/descuentos-nuevo.php
Executable file
52
modules/descuentos-nuevo.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$ventaId = intval($_GET['ventaId']);
|
||||
$sucursalId = $_SESSION['idSuc'];
|
||||
|
||||
$venta->setVentaId($ventaId);
|
||||
$info = $venta->Info();
|
||||
|
||||
$usuario->setUsuarioId($info['vendedorId']);
|
||||
$info['vendedor'] = $usuario->GetFullNameById();
|
||||
|
||||
$usuario->setUsuarioId($info['usuarioId']);
|
||||
$info['usuario'] = $usuario->GetFullNameById();
|
||||
|
||||
$sucursal->setSucursalId($info['sucursalId']);
|
||||
$info['sucursal'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$venta->setVentaId($ventaId);
|
||||
$resProds = $venta->GetSingleProds();
|
||||
|
||||
$_SESSION['prodDesc'] = array();
|
||||
|
||||
$productos = array();
|
||||
foreach($resProds as $res){
|
||||
|
||||
$venta->setVentaId($ventaId);
|
||||
$venta->setProdItemId($res['prodItemId']);
|
||||
$res['cantidad'] = $venta->GetCantProdsByItem();
|
||||
$res['precioUnitario'] = $venta->GetMaxPrecioByItem();
|
||||
$res['total'] = $venta->GetTotalByItem();
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$res['nombre'] = $producto->GetModeloById();
|
||||
|
||||
$res['tipoDesc'] = '';
|
||||
|
||||
$productos[] = $res;
|
||||
}
|
||||
|
||||
$_SESSION['prodDesc'] = $productos;
|
||||
|
||||
$smarty->assign('productos', $productos);
|
||||
$smarty->assign('info', $info);
|
||||
|
||||
?>
|
||||
42
modules/descuentos.php
Executable file
42
modules/descuentos.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sucursalId = $_SESSION['idSuc'];
|
||||
|
||||
$msg = $_SESSION['msgI'];
|
||||
$_SESSION['msgI'] = '';
|
||||
|
||||
$descuento->setPage(intval($_GET['p']));
|
||||
$descuento->setSucursalId($sucursalId);
|
||||
$ventas = $descuento->Enumerate();
|
||||
|
||||
$items = array();
|
||||
foreach($ventas['items'] as $res){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($res['fecha']));
|
||||
$hora = date('H:i:s',strtotime($res['fecha']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$res['fecha'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($res['usuarioId']);
|
||||
$res['usuario'] = $usuario->GetFullNameById();
|
||||
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['sucursal'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
if($res['status'] == 'DescAp')
|
||||
$res['total'] = $res['totalDesc'];
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$ventas['items'] = $items;
|
||||
|
||||
$smarty->assign('ventas', $ventas);
|
||||
|
||||
?>
|
||||
23
modules/devoluciones-cedis-agregar.php
Executable file
23
modules/devoluciones-cedis-agregar.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($Usr['type'] != 'admin' && $Usr['type'] != 'compras' && $Usr['type'] != 'direccion' && $Usr['type'] != 'almacen'){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$_SESSION['prodsDevC'] = array();
|
||||
unset($_SESSION['prodsDevC']);
|
||||
|
||||
$info['noDevolucion'] = $devolucion->GetNextNoDevCedis();
|
||||
$info['fecha'] = date('d-m-Y H:i:s');
|
||||
|
||||
$sucursal->setRfcId(1);
|
||||
$resSuc = $sucursal->GetSucursalesByRfc();
|
||||
$sucursales = $util->DecodeUrlResult($resSuc);
|
||||
|
||||
$smarty->assign('sucursales',$sucursales);
|
||||
$smarty->assign('info',$info);
|
||||
|
||||
?>
|
||||
43
modules/devoluciones-cedis-detalles.php
Executable file
43
modules/devoluciones-cedis-detalles.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($Usr['type'] != 'admin' && $Usr['type'] != 'compras' && $Usr['type'] != 'direccion' && $Usr['type'] != 'almacen'){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$devCedisId = intval($_GET['id']);
|
||||
|
||||
$devolucion->setDevCedisId($devCedisId);
|
||||
$info = $devolucion->InfoCedis();
|
||||
|
||||
$resProductos = $devolucion->GetProdsCedis();
|
||||
|
||||
$productos = array();
|
||||
foreach($resProductos as $res){
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$infP = $producto->Info();
|
||||
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['sucursal'] = urldecode($sucursal->GetNameById());
|
||||
|
||||
$prodCat->setProdCatId($infP['prodCatId']);
|
||||
$res['departamento'] = ($prodCat->GetNameById());
|
||||
|
||||
$prodSubcat->setProdSubcatId($infP['prodSubcatId']);
|
||||
$res['linea'] = ($prodSubcat->GetNameById());
|
||||
|
||||
$res['modelo'] = ($infP['modelo']);
|
||||
$res['codigoBarra'] = $infP['codigoBarra'];
|
||||
|
||||
$res['atributos'] = $producto->GetAtributosAll();
|
||||
|
||||
$productos[] = $res;
|
||||
}
|
||||
|
||||
$smarty->assign('info',$info);
|
||||
$smarty->assign('products',$productos);
|
||||
|
||||
?>
|
||||
28
modules/devoluciones-cedis.php
Executable file
28
modules/devoluciones-cedis.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($Usr['type'] != 'admin' && $Usr['type'] != 'compras' && $Usr['type'] != 'direccion' && $Usr['type'] != 'almacen'){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$msg = $_SESSION['msgDevC'];
|
||||
$_SESSION['msgDevC'] = '';
|
||||
|
||||
$devoluciones = $devolucion->EnumerateCedis();
|
||||
|
||||
$items = array();
|
||||
foreach($devoluciones['items'] as $res){
|
||||
|
||||
$usuario->setUsuarioId($res['usuarioId']);
|
||||
$res['usuario'] = $usuario->GetNameById();
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$devoluciones['items'] = $items;
|
||||
|
||||
$smarty->assign('msg', $msg);
|
||||
$smarty->assign('devoluciones', $devoluciones);
|
||||
|
||||
?>
|
||||
27
modules/devoluciones-nueva.php
Executable file
27
modules/devoluciones-nueva.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sucursalId = $_SESSION['idSuc'];
|
||||
|
||||
$usuario->setUsuarioId($_SESSION['loginKey']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
$info['folio'] = $devolucion->GetNextFolio();
|
||||
|
||||
$_SESSION['conceptosD'] = array();
|
||||
$_SESSION['infDev'] = array();
|
||||
|
||||
$msg = $_SESSION['msgI'];
|
||||
$_SESSION['msgI'] = '';
|
||||
|
||||
$smarty->assign('info', $info);
|
||||
$smarty->assign('msg', $msg);
|
||||
$smarty->assign('ventas', $ventas);
|
||||
|
||||
?>
|
||||
78
modules/devoluciones-ticket.php
Executable file
78
modules/devoluciones-ticket.php
Executable file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$mode = 'cobro';
|
||||
if(isset($_GET['devolucionId'])){
|
||||
$devolucionId = intval($_GET['devolucionId']);
|
||||
$mode = 'detalles';
|
||||
}else{
|
||||
$devolucionId = intval($_GET['id']);
|
||||
}
|
||||
|
||||
$rfc->setRfcId(1);
|
||||
$infE = $util->EncodeRow($rfc->Info());
|
||||
|
||||
$devolucion->setDevolucionId($devolucionId);
|
||||
$info = $devolucion->Info();
|
||||
|
||||
$info['hora'] = date('H:i:s',strtotime($info['fecha']));
|
||||
$info['fecha'] = date('d-m-Y',strtotime($info['fecha']));
|
||||
|
||||
$usuario->setUsuarioId($info['usuarioId']);
|
||||
$info['usuario'] = strtoupper($usuario->GetFullNameById());
|
||||
|
||||
//$_SESSION['idSuc'];
|
||||
|
||||
$sucursal->setSucursalId($info['sucursalId']);
|
||||
$infS = $sucursal->Info();
|
||||
$infS['nombre'] = strtoupper($infS['nombre']);
|
||||
$infS = $util->DecodeUrlRow($infS);
|
||||
$infS = $util->DecodeRow($infS);
|
||||
|
||||
//Obtenemos los Productos
|
||||
|
||||
$devolucion->setDevolucionId($devolucionId);
|
||||
$resProds = $devolucion->GetProductos();
|
||||
|
||||
$saldoFavor = 0;
|
||||
$productos = array();
|
||||
foreach($resProds as $res){
|
||||
|
||||
$producto->setProdItemId($res['prodItemId']);
|
||||
$infI = $producto->GetInfoItemById();
|
||||
|
||||
$producto->setProductoId($infI['productoId']);
|
||||
$infP = $producto->Info();
|
||||
|
||||
$atribVal->setAtribValId($infI['tallaId']);
|
||||
$talla = $atribVal->GetNameById();
|
||||
|
||||
$atribVal->setAtribValId($infI['colorId']);
|
||||
$color = $atribVal->GetNameById();
|
||||
|
||||
$res['nombre'] = $infP['modelo'].' '.$talla.' '.$color;
|
||||
$res['codigoBarra'] = $infI['codigoBarra'];
|
||||
|
||||
$saldoFavor += $res['total'];
|
||||
|
||||
$productos[] = $res;
|
||||
}
|
||||
|
||||
$info['total'] = $saldoFavor;
|
||||
|
||||
$smarty->assign('infE', $infE);
|
||||
$smarty->assign('infS', $infS);
|
||||
$smarty->assign('info', $info);
|
||||
$smarty->assign('mode', $mode);
|
||||
$smarty->assign('productos', $productos);
|
||||
$smarty->display(DOC_ROOT."/templates/devoluciones-ticket.tpl");
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
60
modules/devoluciones.php
Executable file
60
modules/devoluciones.php
Executable file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$_SESSION['conceptosD'] = array();
|
||||
$_SESSION['infDev'] = array();
|
||||
|
||||
$sucursalId = $_SESSION['idSuc'];
|
||||
|
||||
$msg = $_SESSION['msgI'];
|
||||
$_SESSION['msgI'] = '';
|
||||
|
||||
$devolucion->setSucursalId($sucursalId);
|
||||
$devolucion->setPage($_GET['p']);
|
||||
$devoluciones = $devolucion->Enumerate();
|
||||
|
||||
$items = array();
|
||||
foreach($devoluciones['items'] as $res){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($res['fecha']));
|
||||
$hora = date('H:i:s',strtotime($res['fecha']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$res['fecha'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($res['usuarioId']);
|
||||
$res['usuario'] = $usuario->GetNameById();
|
||||
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['sucursal'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$devoluciones['items'] = $items;
|
||||
|
||||
//Filtro
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId($Usr['sucursalId']);
|
||||
$resSuc2 = $util->DecodeUrlResult($resSuc);
|
||||
$sucursales = $util->DecodeResult($resSuc2);
|
||||
|
||||
$usuario->setSucursalid($sucursalId);
|
||||
$usuario->setTipo('cajero');
|
||||
$cajeros = $usuario->GetUsersBySucAndType();
|
||||
$usuario->setTipo('gerente');
|
||||
$gerentes = $usuario->GetUsersBySucAndType();
|
||||
$usuarios = array_merge($cajeros, $gerentes);
|
||||
|
||||
$fechaHoy = date('d-m-Y');
|
||||
|
||||
$smarty->assign('fechaHoy', $fechaHoy);
|
||||
$smarty->assign('usuarios', $usuarios);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
$smarty->assign('devoluciones', $devoluciones);
|
||||
|
||||
?>
|
||||
16
modules/envios-cedis-agregar.php
Executable file
16
modules/envios-cedis-agregar.php
Executable file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($Usr['type'] != 'almacen'){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$resSuc2 = $util->DecodeUrlResult($resSuc);
|
||||
$sucursales = $util->DecodeResult($resSuc2);
|
||||
|
||||
$smarty->assign('sucursales',$sucursales);
|
||||
|
||||
?>
|
||||
138
modules/envios-detalles.php
Executable file
138
modules/envios-detalles.php
Executable file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$envioId = intval($_GET['id']);
|
||||
|
||||
$envio->setEnvioId($envioId);
|
||||
$info = $envio->Info();
|
||||
|
||||
$sucursal->setSucursalId($info['sucursalId']);
|
||||
$nomSucursal = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
$info['sucursal'] = strtoupper($nomSucursal);
|
||||
|
||||
if($info['status'] == 'Pendiente'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fecha']));
|
||||
$hora = date('H:i:s',strtotime($info['fecha']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fecha'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($info['usuarioId']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
}elseif($info['status'] == 'Recibido'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaRecibido']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaRecibido']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fecha'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($info['userIdRecibido']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
}
|
||||
|
||||
$resOrdenes = $envio->GetPedidos();
|
||||
|
||||
$ordenes = array();
|
||||
foreach($resOrdenes as $res){
|
||||
|
||||
$pedido->setPedidoId($res['pedidoId']);
|
||||
$infP = $pedido->Info();
|
||||
|
||||
$res['noPedido'] = $infP['noPedido'];
|
||||
|
||||
$proveedor->setProveedorId($infP['proveedorId']);
|
||||
$res['proveedor'] = $proveedor->GetNameById();
|
||||
$res['noProv'] = $proveedor->GetNoProv();
|
||||
$res['proveedorId'] = $infP['proveedorId'];
|
||||
|
||||
|
||||
$pedido->setSucursalId($info['sucursalId']);
|
||||
$items = $pedido->GetItemsDistSuc();
|
||||
|
||||
$total = 0;
|
||||
$totPrendas = 0;
|
||||
$productos = array();
|
||||
foreach($items as $val){
|
||||
|
||||
if($val['envioId'] != $envioId && $envioId >= 4791) //Local 4776, Prod = 4791
|
||||
continue;
|
||||
|
||||
$producto->setProductoId($val['productoId']);
|
||||
$infP = $producto->Info();
|
||||
|
||||
$pedido->setProductoId($val['productoId']);
|
||||
$infPP = $pedido->GetInfoProd();
|
||||
|
||||
if($infPP['prendasComp'] == 0)
|
||||
$val['cantidad'] = $val['prendas'];
|
||||
|
||||
$prendas = $val['cantidad'];
|
||||
|
||||
$totPrendas += $prendas;
|
||||
|
||||
$total += $prendas * $infP['costo'];
|
||||
|
||||
//Informacion del Producto
|
||||
|
||||
if($val['cantidad']){
|
||||
$card['codigoBarra'] = $infP['codigoBarra'];
|
||||
$card['modelo'] = $infP['modelo'];
|
||||
$card['cantidad'] = $val['cantidad'];
|
||||
$card['cajas'] = $val['cajas'];
|
||||
|
||||
$productos[] = $card;
|
||||
}
|
||||
|
||||
}//foreach
|
||||
|
||||
$res['total'] = number_format($total,2);
|
||||
$res['prendas'] = $totPrendas;
|
||||
$res['productos'] = $productos;
|
||||
|
||||
$ordenes[] = $res;
|
||||
}
|
||||
|
||||
//Ordenes Recibidas
|
||||
|
||||
$envio->setEnvioId($envioId);
|
||||
$resProds = $envio->GetProdRecibidos();
|
||||
|
||||
$productos = array();
|
||||
foreach($resProds as $res){
|
||||
|
||||
$pedido->setPedidoId($res['pedidoId']);
|
||||
$infP = $pedido->Info();
|
||||
|
||||
$res['noPedido'] = $infP['noPedido'];
|
||||
|
||||
$productoId = $res['productoId'];
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$infP = $producto->Info();
|
||||
|
||||
$res['codigoBarra'] = $infP['codigoBarra'];
|
||||
$res['modelo'] = $infP['modelo'];
|
||||
$res['descripcion'] = $producto->GetAtributosAll();
|
||||
|
||||
$pedido->setPedidoId($res['pedidoId']);
|
||||
$pedido->setProductoId($productoId);
|
||||
$pedido->setSucursalId($info['sucursalId']);
|
||||
$infD = $pedido->InfoProdDist();
|
||||
|
||||
$pedido->setPedidoId($res['pedidoId']);
|
||||
$pedido->setSucursalId($info['sucursalId']);
|
||||
$res['cajas'] = $pedido->GetTotalCajasBySucAndPed();
|
||||
|
||||
//$res['cajas'] = $infD['cajas'];
|
||||
|
||||
$productos[] = $res;
|
||||
|
||||
}
|
||||
|
||||
$smarty->assign('info',$info);
|
||||
$smarty->assign('productos',$productos);
|
||||
$smarty->assign('ordenes',$ordenes);
|
||||
|
||||
?>
|
||||
49
modules/envios-recibir-reporte.php
Executable file
49
modules/envios-recibir-reporte.php
Executable file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$Usr = $user->Info();
|
||||
|
||||
$envio->SetPage($_GET["p"]);
|
||||
$envio->setSucursalId($Usr['sucursalId']);
|
||||
$productos = $envio->EnumRepProd();
|
||||
|
||||
$items = array();
|
||||
foreach($productos['items'] as $res){
|
||||
$card = $res;
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$infP = $producto->Info();
|
||||
|
||||
$card['codigoBarra'] = $infP['codigoBarra'];
|
||||
$card['modelo'] = $infP['modelo'];
|
||||
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$card['sucursal'] = urldecode($sucursal->GetNameById());
|
||||
|
||||
if($card['tipo'] == 'Faltante')
|
||||
$card['recibido'] = $card['total'] - $card['cantidad'];
|
||||
else
|
||||
$card['recibido'] = $card['total'] + $card['cantidad'];
|
||||
|
||||
$items[] = $card;
|
||||
}
|
||||
$productos['items'] = $items;
|
||||
|
||||
$sucursal->setSucursalId($Usr['sucursalId']);
|
||||
$info['sucursal'] = urldecode($sucursal->GetNameById());
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$resSuc2 = $util->DecodeUrlResult($resSuc);
|
||||
$sucursales = $util->DecodeResult($resSuc2);
|
||||
|
||||
$smarty->assign('info',$info);
|
||||
$smarty->assign('sucursales',$sucursales);
|
||||
$smarty->assign('productos',$productos);
|
||||
|
||||
?>
|
||||
81
modules/envios-recibir.php
Executable file
81
modules/envios-recibir.php
Executable file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$envioId = intval($_GET['id']);
|
||||
|
||||
$envio->setEnvioId($envioId);
|
||||
$info = $envio->Info();
|
||||
|
||||
$sucursalId = $info['sucursalId'];
|
||||
|
||||
$sucursal->setSucursalId($sucursalId);
|
||||
$nomSucursal = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
$info['sucursal'] = strtoupper($nomSucursal);
|
||||
|
||||
if($info['status'] == 'Pendiente'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fecha']));
|
||||
$hora = date('H:i:s',strtotime($info['fecha']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fecha'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($info['usuarioId']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
}
|
||||
|
||||
//Obtenemos los Productos
|
||||
|
||||
$resOrdenes = $envio->GetPedidos();
|
||||
|
||||
$productos = array();
|
||||
$idProds = array();
|
||||
foreach($resOrdenes as $res){
|
||||
|
||||
$pedidoId = $res['pedidoId'];
|
||||
|
||||
$pedido->setPedidoId($pedidoId);
|
||||
$infPed = $pedido->Info();
|
||||
|
||||
$envio->setPedidoId($pedidoId);
|
||||
$envio->setSucursalId($sucursalId);
|
||||
$resProducts = $envio->GetProductos();
|
||||
|
||||
foreach($resProducts as $val){
|
||||
$productoId = $val['productoId'];
|
||||
|
||||
if($val['cantidad'] == 0)
|
||||
continue;
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$infP = $producto->Info();
|
||||
|
||||
$pedido->setProductoId($val['productoId']);
|
||||
$infPP = $pedido->GetInfoProd();
|
||||
|
||||
$pedido->setPedidoId($pedidoId);
|
||||
$pedido->setSucursalId($sucursalId);
|
||||
$val['cajas'] = $pedido->GetTotalCajasBySucAndPed();
|
||||
|
||||
$val['noPedido'] = $infPed['noPedido'];
|
||||
$val['codigoBarra'] = $infP['codigoBarra'];
|
||||
$val['modelo'] = $infP['modelo'];
|
||||
$val['descripcion'] = $producto->GetAtributosAll();
|
||||
|
||||
if($infPP['prendasComp'] == 0)
|
||||
$val['cantidad'] = $val['prendas'];
|
||||
|
||||
$val['cantPrendas'] = $val['cantidad'];
|
||||
|
||||
$productos[] = $val;
|
||||
$idProds[] = $productoId;
|
||||
|
||||
}//foreach
|
||||
|
||||
}//foreach
|
||||
|
||||
$smarty->assign('info',$info);
|
||||
$smarty->assign('productos',$productos);
|
||||
|
||||
?>
|
||||
19
modules/envios-reporte.php
Executable file
19
modules/envios-reporte.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$resSuc2 = $util->DecodeUrlResult($resSuc);
|
||||
$sucursales = $util->DecodeResult($resSuc2);
|
||||
|
||||
$fecha = $util->Today();
|
||||
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
$smarty->assign('fecha', $fecha);
|
||||
|
||||
?>
|
||||
146
modules/envios-talones-pdf.php
Executable file
146
modules/envios-talones-pdf.php
Executable file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
//$empresa->AuthUser();
|
||||
|
||||
require_once(DOC_ROOT.'/tcpdf/config/lang/eng.php');
|
||||
require_once(DOC_ROOT.'/tcpdf/tcpdf.php');
|
||||
|
||||
$envioId = intval($_GET['id']);
|
||||
|
||||
$envio->setEnvioId($envioId);
|
||||
$info = $envio->Info();
|
||||
|
||||
$sucursal->setSucursalId($info['sucursalId']);
|
||||
$info['nomSuc'] = urldecode($sucursal->GetNameById());
|
||||
|
||||
$infS = $sucursal->Info();
|
||||
|
||||
$dir = '';
|
||||
if($infS['calle'])
|
||||
$dir .= $infS['calle'];
|
||||
if($infS['noExt'])
|
||||
$dir .= '. No. Ext. '.$infS['noExt'];
|
||||
if($infS['noInt'])
|
||||
$dir .= '. No. Int. '.$infS['noInt'];
|
||||
if($infS['colonia'])
|
||||
$dir .= '. Col. '.$infS['colonia'];
|
||||
if($infS['ciudad'])
|
||||
$dir .= ','.$infS['ciudad'];
|
||||
if($infS['municipio'])
|
||||
$dir .= ', '.$infS['municipio'];
|
||||
if($infS['estado'])
|
||||
$dir .= ', '.$infS['estado'];
|
||||
|
||||
$info['direccion'] = utf8_encode($dir);
|
||||
|
||||
$usuario->setSucursalId($info['sucursalId']);
|
||||
$usuario->setTipo('gerente');
|
||||
$usuarioId = $usuario->GetUserBySucAndType();
|
||||
|
||||
$usuario->setUsuarioId($usuarioId);
|
||||
$info['gteDest'] = $usuario->GetFullNameById();
|
||||
|
||||
$envio->setEnvioId($envioId);
|
||||
$info['noCajas'] = $envio->GetTotalCajas();
|
||||
|
||||
$total = $envio->GetValorTotal();
|
||||
$info['total'] = number_format($total,2);
|
||||
|
||||
// create new PDF document
|
||||
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
|
||||
|
||||
// set document information
|
||||
$pdf->SetCreator(PDF_CREATOR);
|
||||
$pdf->SetAuthor('');
|
||||
$pdf->SetTitle('');
|
||||
$pdf->SetSubject('');
|
||||
$pdf->SetKeywords('');
|
||||
|
||||
// set default header data
|
||||
$pdf->SetHeaderData('', '', 'Talones de Embarque', '');
|
||||
|
||||
// set header and footer fonts
|
||||
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
|
||||
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
|
||||
|
||||
// set default monospaced font
|
||||
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
|
||||
|
||||
//set margins
|
||||
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
|
||||
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
|
||||
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
|
||||
|
||||
//set auto page breaks
|
||||
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
|
||||
|
||||
//set image scale factor
|
||||
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
|
||||
|
||||
//set some language-dependent strings
|
||||
$pdf->setLanguageArray($l);
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
// add a page
|
||||
$pdf->AddPage();
|
||||
|
||||
$pdf->SetFont('helvetica', '', 9);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
for($k=1; $k<=$info['noCajas']; $k++){
|
||||
|
||||
$tbl .= '<table cellspacing="0" cellpadding="0" border="1">
|
||||
<tr>
|
||||
<td align="center" width="150" height="40">
|
||||
<div></div>
|
||||
<img src="'.DOC_ROOT.'/images/logo.jpg" width="120" height="40">
|
||||
</td>
|
||||
<td width="490"> <br> Novomoda</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="20"> <b>Remitente</b></td>
|
||||
<td>
|
||||
CEDIS <br>
|
||||
Gte. Abel Pérez <br>
|
||||
Dir. Av. Tulipanes, Col. Centro, Oaxaca, Oaxaca. <br>
|
||||
Tel. 01-982-123-456 <br>
|
||||
No. de Envio: '.$envioId.'
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="20"> <b>Destinatario</b></td>
|
||||
<td>
|
||||
Suc: '.$info['nomSuc'].'<br>
|
||||
Gte: '.utf8_encode($info['gteDest']).'<br>
|
||||
Dir. '.urldecode($info['direccion']).' <br>
|
||||
Tel. '.$infS['telefono'].'
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="20"> <b>Conteo de Cajas</b></td>
|
||||
<td> Caja '.$k.' de '.$info['noCajas'].'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="20"> <b>Contenido</b></td>
|
||||
<td> Ropa en General</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="20"> <b>Valor</b></td>
|
||||
<td> '.$info['total'].'</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br><br><br><br>';
|
||||
|
||||
}
|
||||
|
||||
$pdf->writeHTML($tbl, true, false, false, false, '');
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
//Close and output PDF document
|
||||
$pdf->Output('example_048.pdf', 'I');
|
||||
|
||||
|
||||
?>
|
||||
131
modules/envios-talones-tienda.php
Executable file
131
modules/envios-talones-tienda.php
Executable file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
//$empresa->AuthUser();
|
||||
|
||||
require_once(DOC_ROOT.'/tcpdf/config/lang/eng.php');
|
||||
require_once(DOC_ROOT.'/tcpdf/tcpdf.php');
|
||||
|
||||
$envioId = intval($_GET['id']);
|
||||
|
||||
$envio->setEnvioId($envioId);
|
||||
$info = $envio->Info();
|
||||
|
||||
$sucursal->setSucursalId($info['sucOrigen']);
|
||||
$infO = $sucursal->Info();
|
||||
$info['sucOrigen'] = urldecode($sucursal->GetNameById());
|
||||
$info['nomGteO'] = $sucursal->GetNomGerente();
|
||||
$info['telO'] = $infO['telefono'];
|
||||
|
||||
$dirO = $infO['calle'].', No. Ext. '.$infO['noExt'].', No. Int. '.$infO['noInt'].', '.$infO['colonia'];
|
||||
$dirO .= ', '.$infO['municipio'].', '.$infO['ciudad'].', '.$infO['estado'].', C.P. '.$infO['cp'];
|
||||
$info['dirO'] = utf8_encode($dirO);
|
||||
|
||||
$sucursal->setSucursalId($info['sucursalId']);
|
||||
$infD = $sucursal->Info();
|
||||
$info['nomSuc'] = urldecode($sucursal->GetNameById());
|
||||
$info['nomGteD'] = $sucursal->GetNomGerente();
|
||||
$info['telD'] = $infD['telefono'];
|
||||
|
||||
$dirD = $infD['calle'].', No. Ext. '.$infD['noExt'].', No. Int. '.$infD['noInt'].', '.$infD['colonia'];
|
||||
$dirD .= ', '.$infD['municipio'].', '.$infD['ciudad'].', '.$infD['estado'].', C.P. '.$infD['cp'];
|
||||
$info['dirD'] = utf8_encode($dirD);
|
||||
|
||||
$total = $envio->GetValorTotal();
|
||||
$info['total'] = number_format($total,2);
|
||||
|
||||
// create new PDF document
|
||||
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
|
||||
|
||||
// set document information
|
||||
$pdf->SetCreator(PDF_CREATOR);
|
||||
$pdf->SetAuthor('');
|
||||
$pdf->SetTitle('');
|
||||
$pdf->SetSubject('');
|
||||
$pdf->SetKeywords('');
|
||||
|
||||
// set default header data
|
||||
$pdf->SetHeaderData('', '', 'Talones de Embarque', '');
|
||||
|
||||
// set header and footer fonts
|
||||
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
|
||||
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
|
||||
|
||||
// set default monospaced font
|
||||
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
|
||||
|
||||
//set margins
|
||||
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
|
||||
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
|
||||
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
|
||||
|
||||
//set auto page breaks
|
||||
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
|
||||
|
||||
//set image scale factor
|
||||
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
|
||||
|
||||
//set some language-dependent strings
|
||||
$pdf->setLanguageArray($l);
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
// add a page
|
||||
$pdf->AddPage();
|
||||
|
||||
$pdf->SetFont('helvetica', '', 9);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
for($k=1; $k<=$info['noCajas']; $k++){
|
||||
|
||||
$tbl .= '<table cellspacing="0" cellpadding="0" border="1">
|
||||
<tr>
|
||||
<td align="center" width="150" height="28">
|
||||
<img src="'.WEB_ROOT.'/images/logo.jpg" width="100" height="50">
|
||||
</td>
|
||||
<td width="490"> Novomoda</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="20"> <b>Remitente</b></td>
|
||||
<td>
|
||||
'.$info['sucOrigen'].' <br>
|
||||
Gte. '.$info['nomGteO'].' <br>
|
||||
Dir. '.$info['dirO'].' <br>
|
||||
Tel. '.$info['telO'].' <br>
|
||||
No. de Envio: '.$envioId.'
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="20"> <b>Destinatario</b></td>
|
||||
<td>
|
||||
'.$info['nomSuc'].'<br>
|
||||
Gte. '.$info['nomGteD'].' <br>
|
||||
Dir. '.$info['dirD'].' <br>
|
||||
Tel. '.$info['telD'].'
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="20"> <b>Conteo de Cajas</b></td>
|
||||
<td> Caja '.$k.' de '.$info['noCajas'].'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="20"> <b>Contenido</b></td>
|
||||
<td> Ropa en General</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="20"> <b>Valor</b></td>
|
||||
<td> '.$info['total'].'</td>
|
||||
</tr>
|
||||
</table><br><br>';
|
||||
|
||||
}
|
||||
|
||||
$pdf->writeHTML($tbl, true, false, false, false, '');
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
//Close and output PDF document
|
||||
$pdf->Output('example_048.pdf', 'I');
|
||||
|
||||
|
||||
?>
|
||||
77
modules/envios-tienda-agregar.php
Executable file
77
modules/envios-tienda-agregar.php
Executable file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($Usr['type'] != 'almacen' && $Usr['type'] != 'compras' && $Usr['type'] != 'gerente' && $Usr['type'] != 'direccion'){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$envioId = intval($_GET['id']);
|
||||
|
||||
$_SESSION['envProds'] = array();
|
||||
unset($_SESSION['envProds']);
|
||||
|
||||
if($envioId){
|
||||
|
||||
$envio->setEnvioId($envioId);
|
||||
$infE = $envio->Info();
|
||||
|
||||
$info['sucursalId'] = $infE['sucOrigen'];
|
||||
$info['sucursalId2'] = $infE['sucursalId'];
|
||||
|
||||
$products = $envio->GetProdsTienda();
|
||||
|
||||
$productos = array();
|
||||
foreach($products as $res){
|
||||
|
||||
$prodItemId = $res['prodItemId'];
|
||||
|
||||
$card['cantidad'] = $res['cantidad'];
|
||||
|
||||
$producto->setProdItemId($prodItemId);
|
||||
$infI = $producto->GetInfoItemById();
|
||||
|
||||
$card['productoId'] = $infI['productoId'];
|
||||
|
||||
$producto->setProductoId($infI['productoId']);
|
||||
$infP = $producto->Info();
|
||||
|
||||
$nombre = $infP['modelo'].', ';
|
||||
$nombre .= $producto->GetAtributosAll();
|
||||
|
||||
$atribVal->setAtribValId($infI['tallaId']);
|
||||
$nombre .= ', '.$atribVal->GetNameById();
|
||||
|
||||
$atribVal->setAtribValId($infI['colorId']);
|
||||
$nombre .= ', '.$atribVal->GetNameById();
|
||||
|
||||
$card['nombre'] = $nombre;
|
||||
$card['prodItemId'] = $prodItemId;
|
||||
|
||||
$inventario->setSucursalId($info['sucursalId']);
|
||||
$inventario->setProdItemId($prodItemId);
|
||||
$card['disponible'] = $inventario->GetDisponible();
|
||||
|
||||
$productos[] = $card;
|
||||
|
||||
}//foreach
|
||||
|
||||
$_SESSION['envProds'] = $util->EncodeResult($productos);
|
||||
|
||||
}//if
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$resSuc2 = $util->DecodeUrlResult($resSuc);
|
||||
$sucursales = $util->DecodeResult($resSuc2);
|
||||
|
||||
$proveedores = $proveedor->EnumerateAll();
|
||||
$categorias = $prodCat->EnumerateAll();
|
||||
|
||||
$smarty->assign('info',$info);
|
||||
$smarty->assign('productos',$productos);
|
||||
$smarty->assign('sucursales',$sucursales);
|
||||
$smarty->assign('categorias', $categorias);
|
||||
$smarty->assign('proveedores', $proveedores);
|
||||
|
||||
?>
|
||||
72
modules/envios-tienda-cedis.php
Executable file
72
modules/envios-tienda-cedis.php
Executable file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$envio->setPage(intval($_GET['p']));
|
||||
if($Usr['type'] == 'gerente'){
|
||||
$envio->setSucursalId($_SESSION['idSuc']);
|
||||
$resEnvios = $envio->EnumBySucD();
|
||||
|
||||
$sucursal->setSucursalId($_SESSION['idSuc']);
|
||||
$nomSuc = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
}else{
|
||||
$resEnvios = $envio->EnumerateD();
|
||||
}
|
||||
|
||||
$envios = array();
|
||||
$proveedores = array();
|
||||
$provInfo = array();
|
||||
|
||||
foreach($resEnvios['items'] as $res){
|
||||
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['nombreSucursal'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$res['nombreProducto'] = utf8_decode(urldecode($producto->GetModeloById()));
|
||||
|
||||
$prov = array();
|
||||
if(!in_array($res['proveedorId'],$proveedores))
|
||||
{
|
||||
$proveedores[] = $res['proveedorId'];
|
||||
$prov['proveedorId'] = $res['proveedorId'];
|
||||
$proveedor->setProveedorId($res['proveedorId']);
|
||||
$prov['nombreProveedor'] = utf8_decode(urldecode($proveedor->GetNameById()));
|
||||
$provInfo[] = $prov;
|
||||
}
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($res['fecha']));
|
||||
//$hora = date('H:i:s',strtotime($res['fecha']));
|
||||
//$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$res['fecha'] = $fecha;//.' '.$hora;
|
||||
|
||||
$fechaRecibido = date('d-m-Y',strtotime($res['fechaRecibido']));
|
||||
if($fechaRecibido != "00-00-0000")
|
||||
$res['fechaRecibido'] = $fechaRecibido;
|
||||
else
|
||||
$res['fechaRecibido'] = "";
|
||||
|
||||
$res['total'] = number_format($res['total'],2);
|
||||
|
||||
$envios[] = $res;
|
||||
}
|
||||
$envios['items'] = $envios;
|
||||
|
||||
$msg = $_SESSION['msgEnv'];
|
||||
$_SESSION['msgEnv'] = '';
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$resSuc2 = $util->DecodeUrlResult($resSuc);
|
||||
$sucursales = $util->DecodeResult($resSuc2);
|
||||
|
||||
//print_r($provInfo);
|
||||
|
||||
$smarty->assign('provInfo',$provInfo);
|
||||
$smarty->assign('proveedores',$proveedores);
|
||||
$smarty->assign('msg', $msg);
|
||||
$smarty->assign('nomSuc', $nomSuc);
|
||||
$smarty->assign('envios',$envios);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
?>
|
||||
105
modules/envios-tienda-detalles.php
Executable file
105
modules/envios-tienda-detalles.php
Executable file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$envioId = intval($_GET['id']);
|
||||
|
||||
$envio->setEnvioId($envioId);
|
||||
$info = $envio->Info();
|
||||
|
||||
$sucursal->setSucursalId($info['sucOrigen']);
|
||||
$nomSucursal = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
$info['nomSucOrigen'] = strtoupper($nomSucursal);
|
||||
|
||||
$sucursal->setSucursalId($info['sucursalId']);
|
||||
$nomSucursal = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
$info['sucDestino'] = strtoupper($nomSucursal);
|
||||
|
||||
if($info['status'] != 'Pendiente'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fecha']));
|
||||
$hora = date('H:i:s',strtotime($info['fecha']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fechaEnvio'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($info['usuarioId']);
|
||||
$info['userEnvio'] = $usuario->GetNameById();
|
||||
|
||||
}
|
||||
|
||||
if($info['status'] == 'Pendiente'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fecha']));
|
||||
$hora = date('H:i:s',strtotime($info['fecha']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fecha'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($info['usuarioId']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
}elseif($info['status'] == 'Autorizado'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaAutorizacion']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaAutorizacion']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fecha'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($info['userIdAutorizacion']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
}elseif($info['status'] == 'AutSuc'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaAutSuc']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaAutSuc']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fecha'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($info['userIdAutSuc']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
}elseif($info['status'] == 'Recibido'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaRecibido']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaRecibido']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fecha'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($info['userIdRecibido']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
}elseif($info['status'] == 'Rechazado'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaRechazo']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaRechazo']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fecha'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($info['userIdRechazo']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
$motivo->setMotivoId($info['motivoId']);
|
||||
$info['motivo'] = $motivo->GetNameById();
|
||||
|
||||
}//elseif
|
||||
|
||||
|
||||
|
||||
$resProds = $envio->GetProdsTienda();
|
||||
|
||||
$productos = array();
|
||||
foreach($resProds as $res){
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$infP = $producto->Info();
|
||||
|
||||
$res['nombre'] = $infP['modelo'];
|
||||
$res['codigoBarra'] = $infP['codigoBarra'];
|
||||
|
||||
$productos[] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
$smarty->assign('info',$info);
|
||||
$smarty->assign('productos',$productos);
|
||||
|
||||
?>
|
||||
42
modules/envios-tienda-revivir.php
Executable file
42
modules/envios-tienda-revivir.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($Usr['type'] != 'almacen'){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$envioId = intval($_GET['id']);
|
||||
|
||||
foreach($idProds as $prodItemId){
|
||||
|
||||
$card['cantidad'] = $_POST['cantidad_'.$prodItemId];
|
||||
|
||||
$producto->setProdItemId($prodItemId);
|
||||
$info = $producto->GetInfoItemById();
|
||||
|
||||
$card['productoId'] = $info['productoId'];
|
||||
|
||||
$producto->setProductoId($info['productoId']);
|
||||
$infP = $producto->Info();
|
||||
|
||||
$nombre = $infP['modelo'].', ';
|
||||
$nombre .= $producto->GetAtributosAll();
|
||||
|
||||
$atribVal->setAtribValId($info['tallaId']);
|
||||
$nombre .= ', '.$atribVal->GetNameById();
|
||||
|
||||
$atribVal->setAtribValId($info['colorId']);
|
||||
$nombre .= ', '.$atribVal->GetNameById();
|
||||
|
||||
$card['nombre'] = utf8_encode($nombre);
|
||||
$card['prodItemId'] = $prodItemId;
|
||||
|
||||
$productos[] = $card;
|
||||
|
||||
}//foreach
|
||||
|
||||
$_SESSION['envProds'] = $productos;
|
||||
|
||||
?>
|
||||
60
modules/envios-tienda.php
Executable file
60
modules/envios-tienda.php
Executable file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$envio->setPage(intval($_GET['p']));
|
||||
if($Usr['type'] == 'gerente'){
|
||||
$envio->setSucursalId($_SESSION['idSuc']);
|
||||
$envios = $envio->EnumBySucT();
|
||||
|
||||
$sucursal->setSucursalId($_SESSION['idSuc']);
|
||||
$nomSuc = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
}else{
|
||||
$envios = $envio->EnumerateT();
|
||||
}
|
||||
|
||||
$items = array();
|
||||
foreach($envios['items'] as $res){
|
||||
|
||||
$sucursal->setSucursalId($res['sucOrigen']);
|
||||
$res['sucursalO'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['sucursal'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($res['fecha']));
|
||||
$hora = date('H:i:s',strtotime($res['fecha']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$res['fecha'] = $fecha.' '.$hora;
|
||||
|
||||
//Obtenemos los Productos del Envio
|
||||
|
||||
$envio->setEnvioId($res['envioId']);
|
||||
$resProds = $envio->GetProdsTienda();
|
||||
|
||||
$prendas = 0;
|
||||
foreach($resProds as $val)
|
||||
$prendas += $val['cantidad'];
|
||||
|
||||
$res['prendas'] = $prendas;
|
||||
|
||||
$res['total'] = number_format($res['total'],2);
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$envios['items'] = $items;
|
||||
|
||||
$msg = $_SESSION['msgEnv'];
|
||||
$_SESSION['msgEnv'] = '';
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$resSuc2 = $util->DecodeUrlResult($resSuc);
|
||||
$sucursales = $util->DecodeResult($resSuc2);
|
||||
|
||||
$smarty->assign('msg', $msg);
|
||||
$smarty->assign('nomSuc', $nomSuc);
|
||||
$smarty->assign('envios',$envios);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
?>
|
||||
14
modules/envios-transito.php
Executable file
14
modules/envios-transito.php
Executable file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$resSuc2 = $util->DecodeUrlResult($resSuc);
|
||||
$sucursales = $util->DecodeResult($resSuc2);
|
||||
|
||||
$proveedores = $proveedor->EnumerateAll();
|
||||
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
$smarty->assign('proveedores', $proveedores);
|
||||
|
||||
?>
|
||||
44
modules/envios-traspasos.php
Executable file
44
modules/envios-traspasos.php
Executable file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$envio->setPage(intval($_GET['p']));
|
||||
$envio->setTipo('CT');
|
||||
if($Usr['type'] == 'gerente'){
|
||||
$envio->setSucursalId($_SESSION['idSuc']);
|
||||
$resEnvios = $envio->EnumBySuc();
|
||||
|
||||
$sucursal->setSucursalId($_SESSION['idSuc']);
|
||||
$nomSuc = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
}else{
|
||||
$resEnvios = $envio->Enumerate();
|
||||
}
|
||||
|
||||
$envios = array();
|
||||
foreach($resEnvios['items'] as $res){
|
||||
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['sucursal'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($res['fecha']));
|
||||
$res['fecha'] = $util->FormatDateDMMMY($fecha);
|
||||
|
||||
$envio->setEnvioId($res['envioId']);
|
||||
$res['enviaron'] = $envio->GetTotalPrendas();
|
||||
$res['recibieron'] = $envio->GetTotalRec();
|
||||
|
||||
$res['diferencia'] = $res['enviaron'] - $res['recibieron'];
|
||||
|
||||
$envios[] = $res;
|
||||
}
|
||||
$resEnvios['items'] = $envios;
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$resSuc2 = $util->DecodeUrlResult($resSuc);
|
||||
$sucursales = $util->DecodeResult($resSuc2);
|
||||
|
||||
$smarty->assign('envios', $resEnvios);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
?>
|
||||
58
modules/envios.php
Executable file
58
modules/envios.php
Executable file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$envio->setPage(intval($_GET['p']));
|
||||
$envio->setTipo('CT');
|
||||
if($Usr['type'] == 'gerente'){
|
||||
$envio->setSucursalId($_SESSION['idSuc']);
|
||||
$resEnvios = $envio->EnumBySuc();
|
||||
|
||||
$sucursal->setSucursalId($_SESSION['idSuc']);
|
||||
$nomSuc = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
}else{
|
||||
$resEnvios = $envio->Enumerate();
|
||||
}
|
||||
|
||||
$envios = array();
|
||||
foreach($resEnvios['items'] as $res){
|
||||
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['sucursal'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$envio->setEnvioId($res['envioId']);
|
||||
$res['noCajas'] = $envio->GetTotalCajas();
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($res['fecha']));
|
||||
$hora = date('H:i:s',strtotime($res['fecha']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$res['fecha'] = $fecha.' '.$hora;
|
||||
|
||||
$total = $envio->GetValorTotal();
|
||||
$res['total'] = number_format($total,2);
|
||||
|
||||
$res['prendas'] = $envio->GetTotalPrendas();
|
||||
|
||||
$envios[] = $res;
|
||||
}
|
||||
$resEnvios['items'] = $envios;
|
||||
|
||||
$msg = $_SESSION['msgEnv'];
|
||||
$_SESSION['msgEnv'] = '';
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$resSuc2 = $util->DecodeUrlResult($resSuc);
|
||||
$sucursales = $util->DecodeResult($resSuc2);
|
||||
|
||||
$smarty->assign('msg', $msg);
|
||||
$smarty->assign('nomSuc', $nomSuc);
|
||||
$smarty->assign('envios', $resEnvios);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
?>
|
||||
106
modules/evaluar-pedidos.php
Executable file
106
modules/evaluar-pedidos.php
Executable file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$evaluacion->setPage($_GET['p']);
|
||||
$evaluarPedidos = $evaluacion->Enumerate();
|
||||
|
||||
$rfc->setRfcId("1");
|
||||
$rfcInfo = $rfc->Info();
|
||||
$items = array();
|
||||
$politicas = $politica->EnumerateAll();
|
||||
|
||||
foreach($evaluarPedidos['items'] as $res)
|
||||
{
|
||||
$proveedor->setProveedorId($res['proveedorId']);
|
||||
$res['proveedor'] = $proveedor->GetNameById();
|
||||
$proveedorInfo = $proveedor->Info();
|
||||
$porcentajeBonifProveedor = $proveedorInfo['bonificacion'];
|
||||
|
||||
$evaluacion->setPedidoId($res['pedidoId']);
|
||||
$evaluacion->setPlazo($res['plazo']);
|
||||
$evaluacion->setFecha($res['fechaEntrega']);
|
||||
$evaluacion->setBonificacion($res['bonificacion']);
|
||||
|
||||
//echo $res['plazo']." ".$res['proveedor'];
|
||||
|
||||
/*$bonificacion->setPedidoId($res['pedidoId']);
|
||||
$bonificacion->setPlazo($res['plazo']);
|
||||
$bonificacion->setFecha($res['fechaEntrega']);
|
||||
$bonificacion->setBonificacion($res['bonificacion']);*/
|
||||
//echo $res['plazo']." ".$res['proveedor']."<br>";
|
||||
|
||||
if($evaluacion->evaluar() || $evaluacion->evaluar2())
|
||||
{
|
||||
$productosRes = $evaluacion->searchProductos();
|
||||
$productosR = array();
|
||||
|
||||
foreach($productosRes as $resP)
|
||||
{
|
||||
// print_r($resP); exit(0);
|
||||
|
||||
$bonificacion->setProdItemId($resP['prodItemId']);
|
||||
$bonificacion->setProveedorId($resP['proveedorId']);
|
||||
$bonificacion->setPedidoId($resP['pedidoId']);
|
||||
$bonificacion->setProductoId($resP['productoId']);
|
||||
|
||||
if($bonificacion->checkBonificacion() || ($bonificacion->checkBonificacion2() && $evaluacion->evaluar2()))
|
||||
{
|
||||
$atribVal->setAtribValId($resP['tallaId']);
|
||||
$talla = utf8_encode($atribVal->GetNameById());
|
||||
|
||||
$atribVal->setAtribValId($resP['colorId']);
|
||||
$color = utf8_encode($atribVal->GetNameById());
|
||||
|
||||
$evaluacion->setProdItemId($resP['prodItemId']);
|
||||
|
||||
$resP['disponible'] = $evaluacion->GetDisponible();
|
||||
$resP['total'] = $evaluacion->GetTotalProductosPedido();
|
||||
$resP['vendido'] = $evaluacion->GetTotalVendidos();
|
||||
$resP['porcentajeVendido'] = $evaluacion->evaluarVentas();
|
||||
|
||||
$resP['costoTotal'] = $resP['total']*$resP['costo'];
|
||||
foreach($politicas as $key => $politica)
|
||||
{
|
||||
$porcentaje1 = $politicas[$key]['porcentajeEvaluacion'];
|
||||
if(isset($politicas[$key+1]['porcentajeEvaluacion']))
|
||||
$porcentaje2 = $politicas[$key+1]['porcentajeEvaluacion'];
|
||||
else
|
||||
$porcentaje2 = 0;
|
||||
|
||||
if($resP['porcentajeVendido'] <= $porcentaje1 && $resP['porcentajeVendido'] > $porcentaje2)
|
||||
{
|
||||
//$resP['costoBonificacion'] = $resP['disponible']*(($resP['costo']*$porcentajeBonifProveedor)/100);
|
||||
$resP['costoBonificacion'] = $resP['disponible']*(($resP['costo']*$politicas[$key]['porcentajeBonificacion'])/100);
|
||||
$resP['porcentajeAplicado'] = $politicas[$key]['porcentajeBonificacion'];//$politica['porcentajeBonificacion'];
|
||||
if($politica['tipo'] == "Devolucion")
|
||||
{
|
||||
$resP['costoDevolucion'] = $resP['disponible']*$resP['costo'];
|
||||
$resP['costoBonificacion'] = "";
|
||||
$resP['porcentajeAplicado'] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$resP['nombre'] = $resP['modelo'].' '.$talla.' '.$color;
|
||||
|
||||
$productosR[] = $resP;
|
||||
}
|
||||
}
|
||||
$res['productos'] = $productosR;
|
||||
$items[] = $res;
|
||||
}
|
||||
}
|
||||
$evaluarPedidos['items'] = $items;
|
||||
|
||||
$smarty->assign('rfcInfo',$rfcInfo);
|
||||
|
||||
$smarty->assign('msg', $msg);
|
||||
$smarty->assign('evaluarPedidos', $evaluarPedidos);
|
||||
|
||||
?>
|
||||
180
modules/facturacion-certificado.php
Executable file
180
modules/facturacion-certificado.php
Executable file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$rfcId = 1;
|
||||
$empresaId = $_SESSION['empresaId'];
|
||||
|
||||
$ruta_dir = DOC_ROOT.'/empresas/'.$empresaId.'/certificados/'.$rfcId;
|
||||
|
||||
if($_POST['accion'] == 'guardar_certificado'){
|
||||
|
||||
$continuar = true;
|
||||
|
||||
//Checamos si existe el directorio
|
||||
if(!is_dir($ruta_dir)){
|
||||
|
||||
//Sino existe creamos el directorio
|
||||
if(!mkdir($ruta_dir, 0755, true)){
|
||||
$errMsg = 'Hubo un error al actualizar el certificado. No se pudo crear el directorio.';
|
||||
$smarty->assign('errMsg', $errMsg);
|
||||
$continuar = false;
|
||||
}//else
|
||||
|
||||
}//if
|
||||
|
||||
if($continuar){
|
||||
|
||||
//Certificado .key
|
||||
$no_certificado = $_POST['certificado'];
|
||||
$pass = $_POST['pass_llave'];
|
||||
$generar_sello = true;
|
||||
|
||||
if(empty($pass)){
|
||||
$smarty->assign('errPass', 'Ingrese la contrasena de la llave privada.');
|
||||
$generar_sello = false;
|
||||
}//if
|
||||
|
||||
$tmp_archivo = $_FILES['file_certificado']['tmp_name'];
|
||||
$nombre_archivo = $_FILES['file_certificado']['name'];
|
||||
$file = pathinfo($nombre_archivo);
|
||||
$ext = $file['extension'];
|
||||
$ruta_destino = $ruta_dir.'/'.$nombre_archivo;
|
||||
|
||||
if(strlen($file['filename']) != 20){
|
||||
$smarty->assign('errCertificado', 'Nombre del certificado invalido. Debe tener 20 caracteres.');
|
||||
$generar_sello = false;
|
||||
@unlink($ruta_destino);
|
||||
}elseif($ext != 'cer'){
|
||||
$smarty->assign('errCertificado', 'Certificado invalido. Debe ser extension .cer');
|
||||
$generar_sello = false;
|
||||
@unlink($ruta_destino);
|
||||
}else{
|
||||
if(!move_uploaded_file($tmp_archivo, $ruta_destino)){
|
||||
$errMsg = 'Hubo un error al actualizar el certificado. No se pudo guardar el certificado.';
|
||||
$smarty->assign('errMsg', $errMsg);
|
||||
$generar_sello = false;
|
||||
}//if
|
||||
}//else
|
||||
|
||||
//Llave privada .cer
|
||||
$tmp_archivo2 = $_FILES['file_llave']['tmp_name'];
|
||||
$nombre_archivo2 = $_FILES['file_llave']['name'];
|
||||
$file2 = pathinfo($nombre_archivo2);
|
||||
$ext2 = $file2['extension'];
|
||||
$ruta_destino2 = $ruta_dir.'/'.$nombre_archivo2;
|
||||
|
||||
if($ext2 != 'key'){
|
||||
$smarty->assign('errLlave', 'Llave privada invalida. Debe ser extension .key');
|
||||
@unlink($ruta_destino);
|
||||
@unlink($ruta_destino2);
|
||||
$generar_sello = false;
|
||||
}else{
|
||||
if(!move_uploaded_file($tmp_archivo2, $ruta_destino2)){
|
||||
$errMsg = 'Hubo un error al actualizar el certificado. No se pudo guardar la llave privada.';
|
||||
$smarty->assign('errMsg', $errMsg);
|
||||
$generar_sello = false;
|
||||
}//if
|
||||
}//else
|
||||
|
||||
if($generar_sello){
|
||||
|
||||
$cadenaOriginal = 'abcdefghijklmnopqrstuvwxyz';
|
||||
$md5 = md5($cadenaOriginal);
|
||||
$certificado = $nombre_archivo2;
|
||||
$llave = $nombre_archivo;
|
||||
|
||||
//Borramos los archivos del certificado anterior
|
||||
|
||||
if(is_dir($ruta_dir)){
|
||||
if($gd = opendir($ruta_dir)){
|
||||
while($archivo = readdir($gd)){
|
||||
$info = pathinfo($ruta_dir.'/'.$archivo);
|
||||
$archivoActual = $info['basename'];
|
||||
if($archivoActual != $certificado && $archivoActual != $llave){
|
||||
@unlink($ruta_dir.'/'.$archivoActual);
|
||||
}//if
|
||||
}//while
|
||||
closedir($gd);
|
||||
}//if
|
||||
}//if
|
||||
|
||||
$comprobante->GenerarSelloGral($cadenaOriginal, $md5, $certificado, $llave, $pass, $rfcId);
|
||||
|
||||
//Checamos si se genero el archivo
|
||||
$status = '';
|
||||
$ruta_verified = $ruta_dir.'/verified.txt';
|
||||
|
||||
if(file_exists($ruta_verified))
|
||||
$status = file_get_contents($ruta_verified);
|
||||
|
||||
if(trim($status) == 'Verified OK'){
|
||||
|
||||
//guardamos el password
|
||||
$myFile = $ruta_dir."/password.txt";
|
||||
$fh = fopen($myFile, 'w');
|
||||
$stringData = $pass;
|
||||
fwrite($fh, $stringData);
|
||||
|
||||
$smarty->assign('cmpMsg', 'El certificado fue actualizado correctamente.');
|
||||
}else{
|
||||
$errMsg = 'Error al actualizar el certificado. Los datos no coinciden.';
|
||||
$smarty->assign('errMsg', $errMsg);
|
||||
|
||||
//Borramos los archivos
|
||||
if(is_dir($ruta_dir)){
|
||||
if($gd = opendir($ruta_dir)){
|
||||
while($archivo = readdir($gd)){
|
||||
@unlink($ruta_dir.'/'.$archivo);
|
||||
}//while
|
||||
closedir($gd);
|
||||
}//if
|
||||
}//if
|
||||
|
||||
}//else
|
||||
|
||||
}else{
|
||||
|
||||
@unlink($ruta_destino);
|
||||
@unlink($ruta_destino2);
|
||||
|
||||
}//else
|
||||
|
||||
}//if
|
||||
|
||||
}//if Guardar Certificado
|
||||
|
||||
$rfc->setEmpresaId($empresaId);
|
||||
$rfc->setRfcId($rfcId);
|
||||
$certNuevo = $rfc->GetCertificadoByRfc();
|
||||
|
||||
if($certNuevo == '')
|
||||
|
||||
$nom_certificado = 'No hay certificados.';
|
||||
|
||||
else{
|
||||
|
||||
$sqlQuery = 'UPDATE serie SET noCertificado = "'.$certNuevo.'" WHERE noCertificado = "'.$certAnterior.'"';
|
||||
$folios->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sqlQuery);
|
||||
$folios->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
|
||||
|
||||
$existe_certificado = true;
|
||||
$nom_certificado = $certNuevo;
|
||||
|
||||
}//else
|
||||
|
||||
|
||||
//Expiration Date
|
||||
if($existe_certificado){
|
||||
|
||||
$expire = exec('openssl x509 -noout -in '.$ruta_dir.'/'.$nom_certificado.'.cer.pem -dates');
|
||||
$exp = explode('=',$expire);
|
||||
$fecha_expiracion = $exp[1];
|
||||
$fecha_exp = date('d-m-Y g:i:s a',strtotime($fecha_expiracion));
|
||||
|
||||
}//if
|
||||
|
||||
$smarty->assign('fecha_expiracion', $fecha_exp);
|
||||
$smarty->assign('nom_certificado', $nom_certificado);
|
||||
|
||||
?>
|
||||
120
modules/facturacion-folios.php
Executable file
120
modules/facturacion-folios.php
Executable file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($_FILES['qr'])
|
||||
{
|
||||
$continuar = true;
|
||||
|
||||
$ruta_dir = DOC_ROOT.'/empresas/'.$_SESSION['empresaId'].'/qrs';
|
||||
$file = '/'.$_POST["serieId"];
|
||||
|
||||
//Checamos si existe el directorio
|
||||
if(!is_dir($ruta_dir)){
|
||||
|
||||
//Sino existe creamos el directorio
|
||||
if(!mkdir($ruta_dir, 0755, true)){
|
||||
$errMsg = 'No se pudo crear el directorio.';
|
||||
$smarty->assign('errMsg', $errMsg);
|
||||
$continuar = false;
|
||||
}//else
|
||||
|
||||
}//if
|
||||
|
||||
if($continuar)
|
||||
{
|
||||
$ext = substr($file, strrpos($file, '.') + 1);
|
||||
if (($ext != "png") || ($_FILES["qr"]["type"] != "image/png"))
|
||||
{
|
||||
$errMsg = 'El archivo debe de tener una extension .PNG.';
|
||||
$smarty->assign('errMsg', $errMsg);
|
||||
$continuar = false;
|
||||
}
|
||||
}
|
||||
|
||||
if($continuar)
|
||||
{
|
||||
if(!move_uploaded_file($_FILES['qr']['tmp_name'], $ruta_dir.$file))
|
||||
{
|
||||
$errMsg = 'No se pudo subir el archivo';
|
||||
$smarty->assign('errMsg', $errMsg);
|
||||
$continuar = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
chmod($ruta_dir.$file, 0777);
|
||||
$cmpMsg = 'Codigo de Barras Bidimensional Asignado';
|
||||
$smarty->assign('cmpMsg', $cmpMsg);
|
||||
$continuar = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($_FILES['cedula'])
|
||||
{
|
||||
$continuar = true;
|
||||
|
||||
$ruta_dir = DOC_ROOT.'/empresas/'.$_SESSION['empresaId'].'/qrs';
|
||||
$file = '/'.$_POST["serieId"].'_cedula_'.basename( $_FILES['cedula']['name']);
|
||||
|
||||
//Checamos si existe el directorio
|
||||
if(!is_dir($ruta_dir)){
|
||||
//Sino existe creamos el directorio
|
||||
if(!mkdir($ruta_dir, 0755, true)){
|
||||
$errMsg = 'No se pudo crear el directorio.';
|
||||
$smarty->assign('errMsg', $errMsg);
|
||||
$continuar = false;
|
||||
}//else
|
||||
|
||||
}//if
|
||||
|
||||
if($continuar)
|
||||
{
|
||||
$ext = strtolower(substr($file, strrpos($file, '.') + 1));
|
||||
if (($ext != "jpg") || ($_FILES["cedula"]["type"] != "image/jpeg"))
|
||||
{
|
||||
$errMsg = 'El archivo debe de tener una extension .JPG.';
|
||||
$smarty->assign('errMsg', $errMsg);
|
||||
$continuar = false;
|
||||
}
|
||||
}
|
||||
|
||||
$file = '/'.$_POST["serieId"].".".$ext;
|
||||
|
||||
if($continuar)
|
||||
{
|
||||
if(!move_uploaded_file($_FILES['cedula']['tmp_name'], $ruta_dir.$file))
|
||||
{
|
||||
$errMsg = 'Lo sentimos, pero no se pudo subir el archivo.';
|
||||
$smarty->assign('errMsg', $errMsg);
|
||||
$continuar = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cmpMsg = 'El logo fue agregado correctamente.';
|
||||
$smarty->assign('cmpMsg', $cmpMsg);
|
||||
|
||||
//convertir en jepg
|
||||
$continuar = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rfcId = 1;
|
||||
$folios->setIdRfc($rfcId);
|
||||
$resFolios = $folios->GetFoliosByRfc();
|
||||
|
||||
$listFolios = array();
|
||||
foreach($resFolios as $res){
|
||||
|
||||
if($res['sucursalId']){
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['sucursal'] = urldecode($sucursal->GetNameById());
|
||||
}
|
||||
|
||||
$listFolios[] = $res;
|
||||
}
|
||||
|
||||
$smarty->assign('folios', $listFolios);
|
||||
|
||||
?>
|
||||
126
modules/facturacion-mensual.php
Executable file
126
modules/facturacion-mensual.php
Executable file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(isset($_GET['ver-pdf'])){
|
||||
|
||||
$comprobanteId = intval($_GET['ver-pdf']);
|
||||
|
||||
$infoComp = $comprobante->GetInfoComprobante($comprobanteId);
|
||||
$rfcId = $rfc->getRfcActive();
|
||||
$empresaId = $_SESSION['empresaId'];
|
||||
|
||||
$archivo = $empresaId.'_'.$infoComp['serie'].'_'.$infoComp['folio'].'.pdf';
|
||||
$enlace = WEB_ROOT.'/empresas/'.$empresaId.'/certificados/'.$rfcId.'/facturas/pdf/'.$archivo;
|
||||
|
||||
header('Location: '.$enlace);
|
||||
exit;
|
||||
|
||||
}elseif(isset($_GET['descargar-pdf'])){
|
||||
|
||||
$comprobanteId = intval($_GET['descargar-pdf']);
|
||||
|
||||
$infoComp = $comprobante->GetInfoComprobante($comprobanteId);
|
||||
$rfcId = $rfc->getRfcActive();
|
||||
$empresaId = $_SESSION['empresaId'];
|
||||
|
||||
$archivo = $empresaId.'_'.$infoComp['serie'].'_'.$infoComp['folio'].'.pdf';
|
||||
$enlace = WEB_ROOT.'/empresas/'.$empresaId.'/certificados/'.$rfcId.'/facturas/pdf/'.$archivo;
|
||||
|
||||
header ("Content-Disposition: attachment; filename=".$archivo."\n\n");
|
||||
header ("Content-Type: text/pdf");
|
||||
readfile($enlace);
|
||||
exit;
|
||||
|
||||
}elseif(isset($_GET['descargar-xml'])){
|
||||
|
||||
$comprobanteId = intval($_GET['descargar-xml']);
|
||||
|
||||
$infoComp = $comprobante->GetInfoComprobante($comprobanteId);
|
||||
$rfcId = $rfc->getRfcActive();
|
||||
$empresaId = $_SESSION['empresaId'];
|
||||
|
||||
if($_SESSION["version"] == "v3" || $_SESSION["version"] == "construc")
|
||||
{
|
||||
$archivo = "SIGN_".$empresaId.'_'.$infoComp['serie'].'_'.$infoComp['folio'].'.xml';
|
||||
}
|
||||
else
|
||||
{
|
||||
$archivo = $empresaId.'_'.$infoComp['serie'].'_'.$infoComp['folio'].'.xml';
|
||||
}
|
||||
|
||||
$enlace = WEB_ROOT.'/empresas/'.$empresaId.'/certificados/'.$rfcId.'/facturas/xml/'.$archivo;
|
||||
|
||||
header ("Content-Disposition: attachment; filename=".$archivo."\n\n");
|
||||
header ("Content-Type: application/octet-stream");
|
||||
//header ("Content-Length: ".filesize($enlace));
|
||||
readfile($enlace);
|
||||
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
$sucursalId = $_SESSION['idSuc'];
|
||||
$version = $_SESSION['version'];
|
||||
|
||||
$comprobante->setSucursalId($sucursalId);
|
||||
$comprobantes = $comprobante->GetCompMensBySuc();
|
||||
|
||||
$items = array();
|
||||
foreach($comprobantes['items'] as $res){
|
||||
|
||||
$rfc->setRfcId(1);
|
||||
$infC = $rfc->Info();
|
||||
$res['nombre'] = $infC['razonSocial'];
|
||||
$res['rfc'] = $infC['rfc'];
|
||||
|
||||
$res['total'] = number_format($res['total'],2);
|
||||
|
||||
$timbreFiscal = unserialize($res['timbreFiscal']);
|
||||
$res["uuid"] = $timbreFiscal["UUID"];
|
||||
|
||||
$res['fecha'] = date('d-m-Y H:i:s',strtotime($res['fecha']));
|
||||
|
||||
$venta->setComprobanteId($res['comprobanteId']);
|
||||
$resFolios = $venta->GetFoliosByCompId();
|
||||
|
||||
$folios = array();
|
||||
foreach($resFolios as $val)
|
||||
$folios[] = $val['folio'];
|
||||
|
||||
$res['tickets'] = implode(',',$folios);
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$comprobantes['items'] = $items;
|
||||
|
||||
//Obtenemos los Meses
|
||||
|
||||
for($k=1; $k<=12; $k++){
|
||||
$card['id'] = $k;
|
||||
$card['nombre'] = ucfirst($util->ConvertirMes($k));
|
||||
|
||||
$meses[$k] = $card;
|
||||
}//for
|
||||
|
||||
$tiposComprobantes = $main->ListTiposDeComprobantes();
|
||||
|
||||
if($Usr['type'] == 'facturacion'){
|
||||
$resSucursales = $sucursal->EnumerateAll();
|
||||
$sucursales = array();
|
||||
foreach($resSucursales as $res){
|
||||
|
||||
$res['nombre'] = utf8_decode(urldecode($res['nombre']));
|
||||
//$res['nombre'] = substr($res['nombre'],0,10);
|
||||
|
||||
$sucursales[] = $res;
|
||||
}
|
||||
$smarty->assign('sucursales',$sucursales);
|
||||
}
|
||||
|
||||
$smarty->assign('meses',$meses);
|
||||
$smarty->assign('version', $version);
|
||||
$smarty->assign('comprobantes', $comprobantes);
|
||||
$smarty->assign('tiposComprobantes',$tiposComprobantes);
|
||||
|
||||
?>
|
||||
254
modules/facturacion-nueva.php
Executable file
254
modules/facturacion-nueva.php
Executable file
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sucursalId = $_SESSION['idSuc'];
|
||||
|
||||
$_SESSION['tipoComp'] = '';
|
||||
$_SESSION['compFI'] = '';
|
||||
$_SESSION['compFF'] = '';
|
||||
$_SESSION['conceptos'] = array();
|
||||
$_SESSION['impuestos'] = array();
|
||||
$_SESSION["notasPorFacturar"] = array();
|
||||
|
||||
$totalDesglosado = array(
|
||||
'subtotal' => '0.00',
|
||||
'descuento' => '0.00',
|
||||
'afterDescuento' => '0.00',
|
||||
'iva' => '0.00',
|
||||
'afterIva' => '0.00',
|
||||
'ieps' => '0.00',
|
||||
'afterImpuestos' => '0.00',
|
||||
'retIva' => '0.00',
|
||||
'retIsr' => '0.00',
|
||||
'total' => '0.00'
|
||||
);
|
||||
|
||||
if(is_numeric($_GET['ventaId'])){
|
||||
|
||||
$ventaId = $_GET['ventaId'];
|
||||
|
||||
$venta->setVentaId($ventaId);
|
||||
$infV = $venta->Info();
|
||||
|
||||
$venta->LoadProductos();
|
||||
|
||||
if($infV['valDesc'] > 0){
|
||||
$datos['porcentajeDescuento'] = $infV['valDesc'];
|
||||
$post['porcentajeDescuento'] = $infV['valDesc'];
|
||||
}
|
||||
|
||||
$totalDesglosado = $venta->GetTotalDesglosado($datos);
|
||||
|
||||
$difCents = $infV['total'] - $totalDesglosado['total'];
|
||||
$difCents = number_format($difCents,2,'.','');
|
||||
|
||||
if($difCents == 0.01 || $difCents == -0.01){
|
||||
$totalDesglosado['iva'] += $difCents;
|
||||
$totalDesglosado['afterIva'] += $difCents;
|
||||
$totalDesglosado['afterImpuestos'] += $difCents;
|
||||
$totalDesglosado['total'] += $difCents;
|
||||
}
|
||||
|
||||
$totalDesglosado['iva'] = number_format($totalDesglosado['iva'],2,'.','');
|
||||
$totalDesglosado['afterIva'] = number_format($totalDesglosado['afterIva'],2,'.','');
|
||||
$totalDesglosado['afterDescuento'] = number_format($totalDesglosado['afterDescuento'],2,'.','');
|
||||
$totalDesglosado['afterImpuestos'] = number_format($totalDesglosado['afterImpuestos'],2,'.','');
|
||||
$totalDesglosado['total'] = number_format($totalDesglosado['total'],2,'.','');
|
||||
|
||||
if($totalDesglosado){
|
||||
foreach($totalDesglosado as $key => $total)
|
||||
{
|
||||
$totalDesglosado[$key] = number_format($totalDesglosado[$key], 2);
|
||||
}
|
||||
}
|
||||
|
||||
$concepts = $util->DecodeResult($_SESSION["conceptos"]);
|
||||
$smarty->assign('ventaId', $ventaId);
|
||||
$smarty->assign('conceptos', $concepts);
|
||||
$smarty->assign("totalDesglosado", $totalDesglosado);
|
||||
|
||||
}elseif(isset($_GET['faltantes'])){
|
||||
|
||||
$fechaI = $_GET['faltantes'];
|
||||
$fechaF = $_GET['faltantes'];
|
||||
|
||||
$fechaIni = $fechaI;
|
||||
$fechaFin = $fechaF;
|
||||
|
||||
$venta->setSucursalId($sucursalId);
|
||||
$total = $venta->TotalTicketsNoFact($fechaI, $fechaF);
|
||||
|
||||
$venta->setSucursalId($sucursalId);
|
||||
$venta->TicketsNoFacturados($fechaIni, $fechaFin);
|
||||
|
||||
$_SESSION['tipoComp'] = 'Publico';
|
||||
$_SESSION['compFI'] = $fechaIni;
|
||||
$_SESSION['compFF'] = $fechaFin;
|
||||
|
||||
$facturacion->LoadConceptoPublico($_SESSION["notasPorFacturar"], $fechaIni, $fechaFin);
|
||||
$notasPorFacturar = implode("-", $_SESSION["notasPorFacturar"]);
|
||||
|
||||
$totalDesglosado = $facturacion->GetTotalDesglosado();
|
||||
if($totalDesglosado){
|
||||
foreach($totalDesglosado as $key => $total)
|
||||
{
|
||||
$totalDesglosado[$key] = number_format($totalDesglosado[$key], 2);
|
||||
}
|
||||
}
|
||||
|
||||
//Obtenemos la informacion del RFC
|
||||
|
||||
$rfc->setRfcId(1);
|
||||
$infR = $rfc->Info();
|
||||
|
||||
$post['rfc'] = $infR['rfc'];
|
||||
$post['razonSocial'] = $infR['razonSocial'];
|
||||
$post['calle'] = $infR['calle'];
|
||||
$post['noExt'] = $infR['noExt'];
|
||||
$post['noInt'] = $infR['noInt'];
|
||||
$post['colonia'] = $infR['colonia'];
|
||||
$post['municipio'] = $infR['ciudad'];
|
||||
$post['estado'] = $infR['estado'];
|
||||
$post['cp'] = $infR['cp'];
|
||||
$post['pais'] = 'MEXICO';
|
||||
$post['referencia'] = $infR['referencia'];
|
||||
$post['metodoPago'] = 'Efectivo';
|
||||
|
||||
|
||||
$smarty->assign('post', $_SESSION['conceptos']);
|
||||
$smarty->assign('ventaId', 'publico');
|
||||
$smarty->assign('conceptos', $_SESSION['conceptos']);
|
||||
$smarty->assign('notasPorFacturar', $notasPorFacturar);
|
||||
$smarty->assign('totalDesglosado', $totalDesglosado);
|
||||
|
||||
}elseif(isset($_GET['mensual'])){
|
||||
|
||||
/*
|
||||
Factura Octubre = 2013-08-30 al 2013-09-28
|
||||
Factura Noviembre = 2013-09-29 al 2013-10-29
|
||||
Factura Diciembre = 2013-10-30 al 2013-11-28
|
||||
*/
|
||||
|
||||
$venta->setSucursalId($sucursalId);
|
||||
$vta = $venta->GetFirstTicket();
|
||||
|
||||
$fechaX = date('Y-m-01',strtotime($vta['fecha']));
|
||||
|
||||
while($fechaX < date('Y-m-01',strtotime('- 1 months'))){
|
||||
|
||||
$fechaI = date('Y-m-d', strtotime($fechaX.' - 2 days'));
|
||||
$venta->setFecha($fechaI);
|
||||
|
||||
if(!$venta->MesFacturado()){
|
||||
|
||||
//START
|
||||
|
||||
$fechaT = $fechaX;
|
||||
$fechaI = date('Y-m-d', strtotime($fechaT.' - 2 days'));
|
||||
$fecha2 = date('Y-m-d', strtotime($fechaT.' + 1 months'));
|
||||
$fechaF = date('Y-m-d', strtotime($fecha2.' - 3 days'));
|
||||
|
||||
$venta->setSucursalId($sucursalId);
|
||||
$total = $venta->TotalTicketsNoFact($fechaI, $fechaF);
|
||||
|
||||
if($total == 0)
|
||||
$fechaX = date('Y-m-d', strtotime($fechaX.' + 1 months'));
|
||||
else
|
||||
break;
|
||||
|
||||
//END
|
||||
|
||||
}else{
|
||||
$fechaX = date('Y-m-d', strtotime($fechaX.' + 1 months'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$fechaX = date('Y-m-d', strtotime($fechaX.' + 1 months'));
|
||||
|
||||
//$fechaT = date('Y-m-01');
|
||||
$fechaT = $fechaX;
|
||||
$fechaT = date('Y-m-d', strtotime($fechaT.' - 1 months'));
|
||||
|
||||
$fechaIni = date('Y-m-d', strtotime($fechaT.' - 2 days'));
|
||||
$fecha2 = date('Y-m-d', strtotime($fechaT.' + 1 months'));
|
||||
$fechaFin = date('Y-m-d', strtotime($fecha2.' - 3 days'));
|
||||
|
||||
//$fechaIni = '2013-09-10';
|
||||
//$fechaFin = '2013-10-30';
|
||||
|
||||
$venta->setSucursalId($sucursalId);
|
||||
$venta->TicketsNoFacturados($fechaIni, $fechaFin);
|
||||
|
||||
$_SESSION['tipoComp'] = 'Publico';
|
||||
$_SESSION['compFI'] = $fechaIni;
|
||||
$_SESSION['compFF'] = $fechaFin;
|
||||
|
||||
$facturacion->LoadConceptoPublico($_SESSION["notasPorFacturar"], $fechaIni, $fechaFin);
|
||||
$notasPorFacturar = implode("-", $_SESSION["notasPorFacturar"]);
|
||||
|
||||
$totalDesglosado = $facturacion->GetTotalDesglosado();
|
||||
if($totalDesglosado){
|
||||
foreach($totalDesglosado as $key => $total)
|
||||
{
|
||||
$totalDesglosado[$key] = @number_format($totalDesglosado[$key], 2);
|
||||
}
|
||||
}
|
||||
|
||||
//Obtenemos la informacion del RFC
|
||||
|
||||
$rfc->setRfcId(1);
|
||||
$infR = $rfc->Info();
|
||||
|
||||
$post['rfc'] = $infR['rfc'];
|
||||
$post['razonSocial'] = $infR['razonSocial'];
|
||||
$post['calle'] = $infR['calle'];
|
||||
$post['noExt'] = $infR['noExt'];
|
||||
$post['noInt'] = $infR['noInt'];
|
||||
$post['colonia'] = $infR['colonia'];
|
||||
$post['municipio'] = $infR['ciudad'];
|
||||
$post['estado'] = $infR['estado'];
|
||||
$post['cp'] = $infR['cp'];
|
||||
$post['pais'] = 'MEXICO';
|
||||
$post['referencia'] = $infR['referencia'];
|
||||
$post['metodoPago'] = 'Efectivo';
|
||||
|
||||
|
||||
$smarty->assign('post', $_SESSION['conceptos']);
|
||||
$smarty->assign('ventaId', 'publico');
|
||||
$smarty->assign('conceptos', $_SESSION['conceptos']);
|
||||
$smarty->assign('notasPorFacturar', $notasPorFacturar);
|
||||
$smarty->assign('totalDesglosado', $totalDesglosado);
|
||||
|
||||
}//elseif
|
||||
|
||||
$ivas = $main->ListIvas();
|
||||
$retIsrs = $main->ListRetIsr();
|
||||
$retIvas = $main->ListRetIva();
|
||||
$tiposDeMoneda = $main->ListTipoDeMoneda();
|
||||
$comprobantes = $main->ListTiposDeComprobantesValidos($sucursalId);
|
||||
|
||||
$sucursal->setSucursalId($sucursalId);
|
||||
$infSuc = $sucursal->Info();
|
||||
$infSuc['nombre'] = urldecode($infSuc['nombre']);
|
||||
$infSuc['nombre'] = utf8_decode($infSuc['nombre']);
|
||||
|
||||
$excentoIva = $main->ListExcentoIva();
|
||||
|
||||
$smarty->assign("ivas", $ivas);
|
||||
$smarty->assign("retIsrs", $retIsrs);
|
||||
$smarty->assign("retIvas", $retIvas);
|
||||
$smarty->assign("excentoIva", $excentoIva);
|
||||
$smarty->assign("infSuc", $infSuc);
|
||||
$smarty->assign("post", $post);
|
||||
$smarty->assign('totalDesglosado', $totalDesglosado);
|
||||
$smarty->assign("tiposDeMoneda", $tiposDeMoneda);
|
||||
$smarty->assign("comprobantes", $comprobantes);
|
||||
|
||||
?>
|
||||
233
modules/facturacion-pdf.php
Executable file
233
modules/facturacion-pdf.php
Executable file
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
include_once(DOC_ROOT."/classes/override_generator_pdf.class.php");
|
||||
|
||||
if($_GET['ver']){
|
||||
$modo = 'ver';
|
||||
$comprobanteId = intval($_GET['ver']);
|
||||
}elseif($_GET['descargar']){
|
||||
$modo = 'descargar';
|
||||
$comprobanteId = intval($_GET['descargar']);
|
||||
}
|
||||
|
||||
$fact = $comprobante->GetInfoComprobante($comprobanteId);
|
||||
$rfcId = $rfc->getRfcActive();
|
||||
$empresaId = $_SESSION['empresaId'];
|
||||
|
||||
$empresa->setEmpresaId($empresaId);
|
||||
$emp = $empresa->Info();
|
||||
|
||||
$cancelado = ($fact['status'] == 0) ? 1 : 0;
|
||||
|
||||
$archivo = 'SIGN_'.$empresaId.'_'.$fact['serie'].'_'.$fact['folio'].'.xml';
|
||||
$enlace = DOC_ROOT.'/empresas/'.$empresaId.'/certificados/'.$rfcId.'/facturas/xml/'.$archivo;
|
||||
|
||||
$xml = simplexml_load_file($enlace);
|
||||
|
||||
$ns = $xml->getNamespaces(true);
|
||||
$xml->registerXPathNamespace('c',$ns['cfdi']);
|
||||
$xml->registerXPathNamespace('t',$ns['tfd']);
|
||||
|
||||
$data['sucursalId'] = $fact['sucursalId'];
|
||||
$data['tiposComprobanteId'] = $fact['tiposComprobanteId'];
|
||||
$data['observaciones'] = $fact['observaciones'];
|
||||
$data["comprobante"] = $comprobante->InfoComprobante($data["tiposComprobanteId"]);
|
||||
|
||||
//Comprobante
|
||||
|
||||
foreach($xml->xpath('//cfdi:Comprobante') as $comp){
|
||||
|
||||
$serie['serie'] = $comp['serie'];
|
||||
$serie['noCertificado'] = $comp['noCertificado'];
|
||||
|
||||
$data['folio'] = $comp['folio'];
|
||||
$fecha = explode('T',$comp['fecha']);
|
||||
$data['fecha'] = $fecha[0].' '.$fecha[1];
|
||||
$data['tipoDeComprobante'] = $comp['tipoDeComprobante'];
|
||||
|
||||
$data['formaDePago'] = $comp['formaDePago'];
|
||||
$data['metodoDePago'] = $comp['metodoDePago'];
|
||||
$data['LugarExpedicion'] = $comp['LugarExpedicion'];
|
||||
$data['tiposDeMoneda'] = $comp['Moneda'];
|
||||
$data['tipoDeCambio'] = $comp['TipoCambio'];
|
||||
|
||||
$totales['subtotal'] = $comp['subTotal'];
|
||||
$totales['descuento'] = $comp['descuento'];
|
||||
$totales['total'] = $comp['total'];
|
||||
|
||||
}//foreach
|
||||
|
||||
//Retenciones
|
||||
|
||||
foreach($xml->xpath('//cfdi:Comprobante//cfdi:Impuestos//cfdi:Retenciones//cfdi:Retencion') as $ret){
|
||||
if($ret['impuesto'] == 'IVA')
|
||||
$totales['retIva'] = floatval($ret['importe']);
|
||||
elseif($ret['impuesto'] == 'ISR')
|
||||
$totales['retIsr'] = floatval($ret['importe']);
|
||||
}
|
||||
|
||||
//Traslados
|
||||
|
||||
foreach($xml->xpath('//cfdi:Comprobante//cfdi:Impuestos//cfdi:Traslados//cfdi:Traslado') as $tras){
|
||||
if($tras['impuesto'] == 'IVA'){
|
||||
$totales['iva'] = floatval($tras['importe']);
|
||||
$totales['tasaIva'] = $tras['tasa'];
|
||||
}elseif($tras['impuesto'] == 'IEPS'){
|
||||
$totales['ieps'] = floatval($tras['importe']);
|
||||
$totales['porcentajeIEPS'] = $tras['tasa'];
|
||||
}
|
||||
}
|
||||
|
||||
//Emisor
|
||||
|
||||
$card = array();
|
||||
foreach($xml->xpath('//cfdi:Comprobante//cfdi:Emisor') as $emisor){
|
||||
$card['rfc'] = $emisor['rfc'];
|
||||
$card['razonSocial'] = $emisor['nombre'];
|
||||
}//foreach
|
||||
|
||||
//Emisor > Domicilio Fiscal
|
||||
|
||||
foreach($xml->xpath('//cfdi:Comprobante//cfdi:Emisor//cfdi:DomicilioFiscal') as $domFiscal){
|
||||
$card['calle'] = $domFiscal['calle'];
|
||||
$card['noExt'] = $domFiscal['noExterior'];
|
||||
$card['noInt'] = $domFiscal['noInterior'];
|
||||
$card['colonia'] = $domFiscal['colonia'];
|
||||
$card['municipio'] = $domFiscal['municipio'];
|
||||
$card['estado'] = $domFiscal['estado'];
|
||||
$card['pais'] = $domFiscal['pais'];
|
||||
$card['cp'] = $domFiscal['codigoPostal'];
|
||||
}//foreach
|
||||
|
||||
//Emisor > Regimen Fiscal
|
||||
|
||||
foreach($xml->xpath('//cfdi:Comprobante//cfdi:Emisor//cfdi:RegimenFiscal') as $regimen){
|
||||
$card['regimenFiscal'] = $regimen['Regimen'];
|
||||
}//foreach
|
||||
|
||||
$data['nodoEmisor']['rfc'] = $card;
|
||||
|
||||
//Emisor > Expedido En
|
||||
|
||||
$card = array();
|
||||
foreach($xml->xpath('//cfdi:Comprobante//cfdi:Emisor//cfdi:ExpedidoEn') as $exp){
|
||||
$card['identificador'] = $data['LugarExpedicion'];
|
||||
$card['calle'] = $exp['calle'];
|
||||
$card['noExt'] = $exp['noExterior'];
|
||||
$card['noInt'] = $exp['noInterior'];
|
||||
$card['colonia'] = $exp['colonia'];
|
||||
$card['municipio'] = $exp['municipio'];
|
||||
$card['estado'] = $exp['estado'];
|
||||
$card['pais'] = $exp['pais'];
|
||||
$card['cp'] = $exp['codigoPostal'];
|
||||
}//foreach
|
||||
|
||||
$data['nodoEmisor']['sucursal'] = $card;
|
||||
$data['nodoEmisor']['sucursal']['nombre'] = $card['identificador'];
|
||||
$data['nodoEmisor']['sucursal']['sucursalActiva'] = 'no';
|
||||
|
||||
//Receptor
|
||||
|
||||
$card = array();
|
||||
foreach($xml->xpath('//cfdi:Comprobante//cfdi:Receptor') as $receptor){
|
||||
$card['rfc'] = $receptor['rfc'];
|
||||
$card['nombre'] = $receptor['nombre'];
|
||||
}//foreach
|
||||
|
||||
//Receptor > Domicilio
|
||||
|
||||
foreach($xml->xpath('//cfdi:Comprobante//cfdi:Receptor//cfdi:Domicilio') as $dom){
|
||||
$card['calle'] = $dom['calle'];
|
||||
$card['noExt'] = $dom['noExterior'];
|
||||
$card['noInt'] = $dom['noInterior'];
|
||||
$card['colonia'] = $dom['colonia'];
|
||||
$card['municipio'] = $dom['municipio'];
|
||||
$card['estado'] = $dom['estado'];
|
||||
$card['pais'] = $dom['pais'];
|
||||
$card['cp'] = $dom['codigoPostal'];
|
||||
}//foreach
|
||||
|
||||
$data['nodoReceptor'] = $card;
|
||||
$nodoReceptor = $card;
|
||||
|
||||
//Conceptos
|
||||
$conceptos = array();
|
||||
foreach($xml->xpath('//cfdi:Comprobante//cfdi:Conceptos//cfdi:Concepto') as $con){
|
||||
$conceptos[] = $con;
|
||||
}
|
||||
|
||||
//TimbreFiscalDigital
|
||||
|
||||
foreach($xml->xpath('//t:TimbreFiscalDigital') as $tfd){
|
||||
$data['UUID'] = $tfd['UUID'];
|
||||
$data['FechaTimbrado'] = $tfd['FechaTimbrado'];
|
||||
$data['sello'] = $tfd['selloCFD'];
|
||||
$data['selloSAT'] = $tfd['selloSAT'];
|
||||
}//foreach
|
||||
|
||||
$sql = 'SELECT serieId FROM serie
|
||||
WHERE serie = "'.$serie['serie'].'"
|
||||
AND sucursalId = '.$fact['sucursalId'];
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$serie['serieId'] = $util->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
$infEmp['empresaId'] = $empresaId;
|
||||
|
||||
//Cadena Original
|
||||
|
||||
switch($emp['version'])
|
||||
{
|
||||
case 'auto':
|
||||
case 'v3':
|
||||
case 'construc':
|
||||
include_once(DOC_ROOT.'/classes/cadena_original_v3.class.php');break;
|
||||
case '2':
|
||||
include_once(DOC_ROOT.'/classes/cadena_original_v2.class.php');break;
|
||||
}
|
||||
|
||||
$cadena = new Cadena;
|
||||
$cadenaOriginal = $cadena->BuildCadenaOriginal($data, $serie, $totales, $nodoEmisor, $nodoReceptor, $conceptos);
|
||||
$data['cadenaOriginal'] = $cadenaOriginal;
|
||||
|
||||
//Timbre
|
||||
|
||||
$user = USER_PAC;
|
||||
$pw = PW_PAC;
|
||||
$pac = new Pac;
|
||||
|
||||
$nufa = $infEmp["empresaId"]."_".$serie["serie"]."_".$data["folio"];
|
||||
$rfcActivo = $rfc->getRfcActive();
|
||||
$root = DOC_ROOT."/empresas/".$_SESSION["empresaId"]."/certificados/".$rfcActivo."/facturas/xml/";
|
||||
$root_dos = DOC_ROOT."/empresas/".$_SESSION["empresaId"]."/certificados/".$rfcActivo."/facturas/xml/timbres/";
|
||||
|
||||
$nufa_dos = "SIGN_".$_SESSION["empresaId"]."_".$serie["serie"]."_".$data["folio"];
|
||||
$timbradoFile = $root.$nufa_dos.".xml";
|
||||
$timbreXml = $pac->ParseTimbre($timbradoFile);
|
||||
$cadenaOriginalTimbre = $pac->GenerateCadenaOriginalTimbre($timbreXml);
|
||||
$data['timbreFiscal'] = $cadenaOriginalTimbre;
|
||||
|
||||
$override = new Override;
|
||||
$override->GeneratePDF($data, $serie, $totales, $nodoEmisor, $nodoReceptor, $conceptos, $infEmp, $cancelado);
|
||||
|
||||
if($modo == 'ver'){
|
||||
|
||||
header('Location: '.WEB_ROOT.'/temp/factura_'.$data['sucursalId'].'.pdf?noCache='.rand());
|
||||
|
||||
}elseif($modo == 'descargar'){
|
||||
|
||||
$archivo = 'factura_'.$data['sucursalId'].'.pdf';
|
||||
$nomPdf = $_SESSION['empresaId'].'_'.$serie['serie'].'_'.$data['folio'].'.pdf';
|
||||
|
||||
$enlace = WEB_ROOT.'/temp/'.$archivo;
|
||||
|
||||
header ("Content-Disposition: attachment; filename=".$nomPdf."\n\n");
|
||||
header ("Content-Type: text/pdf");
|
||||
readfile($enlace);
|
||||
|
||||
}//elseif
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
118
modules/facturacion.php
Executable file
118
modules/facturacion.php
Executable file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(isset($_GET['ver-pdf'])){
|
||||
|
||||
$comprobanteId = intval($_GET['ver-pdf']);
|
||||
|
||||
$infoComp = $comprobante->GetInfoComprobante($comprobanteId);
|
||||
$rfcId = $rfc->getRfcActive();
|
||||
$empresaId = $_SESSION['empresaId'];
|
||||
$archivo = $empresaId.'_'.$infoComp['serie'].'_'.$infoComp['folio'].'.pdf';
|
||||
$enlace = WEB_ROOT.'/empresas/'.$empresaId.'/certificados/'.$rfcId.'/facturas/pdf/'.$archivo;
|
||||
|
||||
header('Location: '.$enlace);
|
||||
exit;
|
||||
|
||||
}elseif(isset($_GET['descargar-pdf'])){
|
||||
|
||||
$comprobanteId = intval($_GET['descargar-pdf']);
|
||||
|
||||
$infoComp = $comprobante->GetInfoComprobante($comprobanteId);
|
||||
$rfcId = $rfc->getRfcActive();
|
||||
$empresaId = $_SESSION['empresaId'];
|
||||
|
||||
$archivo = $empresaId.'_'.$infoComp['serie'].'_'.$infoComp['folio'].'.pdf';
|
||||
$enlace = WEB_ROOT.'/empresas/'.$empresaId.'/certificados/'.$rfcId.'/facturas/pdf/'.$archivo;
|
||||
|
||||
header ("Content-Disposition: attachment; filename=".$archivo."\n\n");
|
||||
header ("Content-Type: text/pdf");
|
||||
readfile($enlace);
|
||||
exit;
|
||||
|
||||
}elseif(isset($_GET['descargar-xml'])){
|
||||
|
||||
$comprobanteId = intval($_GET['descargar-xml']);
|
||||
|
||||
$infoComp = $comprobante->GetInfoComprobante($comprobanteId);
|
||||
$rfcId = $rfc->getRfcActive();
|
||||
$empresaId = $_SESSION['empresaId'];
|
||||
//print_r($infoComp);
|
||||
$archivo = "SIGN_".$empresaId.'_'.$infoComp['serie'].'_'.$infoComp['folio'].'.xml';
|
||||
|
||||
$enlace = WEB_ROOT.'/empresas/'.$empresaId.'/certificados/'.$rfcId.'/facturas/xml/'.$archivo;
|
||||
|
||||
header ("Content-Disposition: attachment; filename=".$archivo."\n\n");
|
||||
header ("Content-Type: application/octet-stream");
|
||||
//header ("Content-Length: ".filesize($enlace));
|
||||
readfile($enlace);
|
||||
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
$sucursalId = $_SESSION['idSuc'];
|
||||
$version = $_SESSION['version'];
|
||||
|
||||
$comprobante->setSucursalId($sucursalId);
|
||||
$comprobantes = $comprobante->GetComprobantesBySuc();
|
||||
|
||||
$items = array();
|
||||
foreach($comprobantes['items'] as $res){
|
||||
|
||||
$cliente->setClienteId($res['userId']);
|
||||
$infC = $cliente->Info();
|
||||
$res['nombre'] = $infC['nombre'];
|
||||
$res['rfc'] = $infC['rfc'];
|
||||
|
||||
$res['total'] = number_format($res['total'],2);
|
||||
|
||||
$timbreFiscal = unserialize($res['timbreFiscal']);
|
||||
$res["uuid"] = $timbreFiscal["UUID"];
|
||||
|
||||
$res['fecha'] = date('d-m-Y H:i:s',strtotime($res['fecha']));
|
||||
|
||||
$venta->setComprobanteId($res['comprobanteId']);
|
||||
$resFolios = $venta->GetFoliosByCompId();
|
||||
|
||||
$folios = array();
|
||||
foreach($resFolios as $val)
|
||||
$folios[] = $val['folio'];
|
||||
|
||||
$res['tickets'] = implode(',',$folios);
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$comprobantes['items'] = $items;
|
||||
|
||||
//Obtenemos los Meses
|
||||
|
||||
for($k=1; $k<=12; $k++){
|
||||
$card['id'] = $k;
|
||||
$card['nombre'] = ucfirst($util->ConvertirMes($k));
|
||||
|
||||
$meses[$k] = $card;
|
||||
}//for
|
||||
|
||||
$tiposComprobantes = $main->ListTiposDeComprobantes();
|
||||
|
||||
if($Usr['type'] == 'facturacion'){
|
||||
$resSucursales = $sucursal->EnumerateAll();
|
||||
$sucursales = array();
|
||||
foreach($resSucursales as $res){
|
||||
|
||||
$res['nombre'] = utf8_decode(urldecode($res['nombre']));
|
||||
//$res['nombre'] = substr($res['nombre'],0,10);
|
||||
|
||||
$sucursales[] = $res;
|
||||
}
|
||||
$smarty->assign('sucursales',$sucursales);
|
||||
}
|
||||
|
||||
$smarty->assign('meses',$meses);
|
||||
$smarty->assign('version', $version);
|
||||
$smarty->assign('comprobantes', $comprobantes);
|
||||
$smarty->assign('tiposComprobantes',$tiposComprobantes);
|
||||
|
||||
?>
|
||||
20
modules/facturas-datos.php
Executable file
20
modules/facturas-datos.php
Executable file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
if($_SESSION['tipoUsr'] != 'Cliente'){
|
||||
header('Location: '.WEB_ROOT.'/facturas');
|
||||
exit;
|
||||
}
|
||||
|
||||
$clienteId = $_SESSION['loginKey'];
|
||||
|
||||
if($clienteId){
|
||||
$cliente->setClienteId($clienteId);
|
||||
$info = $cliente->Info();
|
||||
}else{
|
||||
$info['clienteId'] = $clienteId;
|
||||
$info['rfc'] = $_SESSION['rfcClte'];
|
||||
}
|
||||
|
||||
$smarty->assign('info',$info);
|
||||
|
||||
?>
|
||||
36
modules/facturas-listado.php
Executable file
36
modules/facturas-listado.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
if($_SESSION['tipoUsr'] != 'Cliente'){
|
||||
header('Location: '.WEB_ROOT.'/facturas');
|
||||
exit;
|
||||
}
|
||||
|
||||
$_SESSION['tipoComp'] = '';
|
||||
$_SESSION['conceptos'] = array();
|
||||
$_SESSION['impuestos'] = array();
|
||||
|
||||
$clienteId = $_SESSION['loginKey'];
|
||||
|
||||
if($clienteId){
|
||||
|
||||
$cliente->setClienteId($clienteId);
|
||||
$infC = $cliente->Info();
|
||||
|
||||
$comprobantes = $cliente->EnumFacturasByClte();
|
||||
|
||||
$items = array();
|
||||
foreach($comprobantes['items'] as $res){
|
||||
$res['rfc'] = $infC['rfc'];
|
||||
$res['nombre'] = $infC['nombre'];
|
||||
|
||||
$venta->setComprobanteId($res['comprobanteId']);
|
||||
$res['ventaId'] = $venta->GetTicketByComprobanteId();
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$comprobantes['items'] = $items;
|
||||
|
||||
}//if
|
||||
|
||||
$smarty->assign('comprobantes',$comprobantes);
|
||||
?>
|
||||
114
modules/facturas-nueva.php
Executable file
114
modules/facturas-nueva.php
Executable file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
if($_SESSION['tipoUsr'] != 'Cliente'){
|
||||
header('Location: '.WEB_ROOT.'/facturas');
|
||||
exit;
|
||||
}
|
||||
|
||||
$_SESSION['tipoComp'] = '';
|
||||
$_SESSION['compFI'] = '';
|
||||
$_SESSION['compFF'] = '';
|
||||
$_SESSION['conceptos'] = array();
|
||||
$_SESSION['impuestos'] = array();
|
||||
$_SESSION["notasPorFacturar"] = array();
|
||||
|
||||
$totalDesglosado = array(
|
||||
'subtotal' => '0.00',
|
||||
'descuento' => '0.00',
|
||||
'afterDescuento' => '0.00',
|
||||
'iva' => '0.00',
|
||||
'afterIva' => '0.00',
|
||||
'ieps' => '0.00',
|
||||
'afterImpuestos' => '0.00',
|
||||
'retIva' => '0.00',
|
||||
'retIsr' => '0.00',
|
||||
'total' => '0.00'
|
||||
);
|
||||
|
||||
$clienteId = $_SESSION['loginKey'];
|
||||
|
||||
$cliente->setClienteId($clienteId);
|
||||
$post = $cliente->Info();
|
||||
|
||||
$post['razonSocial'] = $post['nombre'];
|
||||
$post['metodoPago'] = 'Efectivo';
|
||||
|
||||
if(is_numeric($_GET['ventaId'])){
|
||||
|
||||
$ventaId = $_GET['ventaId'];
|
||||
|
||||
if($_SESSION['idVta'] != $ventaId){
|
||||
header('Location: '.WEB_ROOT.'/facturas-listado');
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$venta->setVentaId($ventaId);
|
||||
$infV = $venta->Info();
|
||||
|
||||
$sucursalId = $infV['sucursalId'];
|
||||
$_SESSION['idSuc'] = $sucursalId;
|
||||
|
||||
$venta->LoadProductos();
|
||||
|
||||
if($infV['valDesc'] > 0){
|
||||
$datos['porcentajeDescuento'] = $infV['valDesc'];
|
||||
$post['porcentajeDescuento'] = $infV['valDesc'];
|
||||
}
|
||||
|
||||
$totalDesglosado = $venta->GetTotalDesglosado($datos);
|
||||
|
||||
$difCents = $infV['total'] - $totalDesglosado['total'];
|
||||
$difCents = number_format($difCents,2,'.','');
|
||||
|
||||
if($difCents == 0.01 || $difCents == -0.01){
|
||||
$totalDesglosado['iva'] += $difCents;
|
||||
$totalDesglosado['afterIva'] += $difCents;
|
||||
$totalDesglosado['afterImpuestos'] += $difCents;
|
||||
$totalDesglosado['total'] += $difCents;
|
||||
}
|
||||
|
||||
$totalDesglosado['iva'] = number_format($totalDesglosado['iva'],2,'.','');
|
||||
$totalDesglosado['afterIva'] = number_format($totalDesglosado['afterIva'],2,'.','');
|
||||
$totalDesglosado['afterDescuento'] = number_format($totalDesglosado['afterDescuento'],2,'.','');
|
||||
$totalDesglosado['afterImpuestos'] = number_format($totalDesglosado['afterImpuestos'],2,'.','');
|
||||
$totalDesglosado['total'] = number_format($totalDesglosado['total'],2,'.','');
|
||||
|
||||
if($totalDesglosado){
|
||||
foreach($totalDesglosado as $key => $total)
|
||||
{
|
||||
$totalDesglosado[$key] = number_format($totalDesglosado[$key], 2);
|
||||
}
|
||||
}
|
||||
|
||||
$concepts = $util->DecodeResult($_SESSION["conceptos"]);
|
||||
$smarty->assign('ventaId', $ventaId);
|
||||
$smarty->assign('conceptos', $concepts);
|
||||
$smarty->assign("totalDesglosado", $totalDesglosado);
|
||||
|
||||
}//elseif
|
||||
|
||||
$ivas = $main->ListIvas();
|
||||
$retIsrs = $main->ListRetIsr();
|
||||
$retIvas = $main->ListRetIva();
|
||||
$tiposDeMoneda = $main->ListTipoDeMoneda();
|
||||
$comprobantes = $main->ListTiposDeComprobantesValidos();
|
||||
|
||||
$sucursal->setSucursalId($sucursalId);
|
||||
$infSuc = $sucursal->Info();
|
||||
$infSuc['nombre'] = urldecode($infSuc['nombre']);
|
||||
$infSuc['nombre'] = utf8_decode($infSuc['nombre']);
|
||||
|
||||
$excentoIva = $main->ListExcentoIva();
|
||||
|
||||
$smarty->assign("ivas", $ivas);
|
||||
$smarty->assign("retIsrs", $retIsrs);
|
||||
$smarty->assign("retIvas", $retIvas);
|
||||
$smarty->assign("excentoIva", $excentoIva);
|
||||
$smarty->assign("infSuc", $infSuc);
|
||||
$smarty->assign("post", $post);
|
||||
$smarty->assign('totalDesglosado', $totalDesglosado);
|
||||
$smarty->assign("tiposDeMoneda", $tiposDeMoneda);
|
||||
$smarty->assign("comprobantes", $comprobantes);
|
||||
|
||||
?>
|
||||
4
modules/facturas.php
Executable file
4
modules/facturas.php
Executable file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
|
||||
?>
|
||||
5
modules/homepage.php
Executable file
5
modules/homepage.php
Executable file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
?>
|
||||
34
modules/inventario-ajustar-list.php
Executable file
34
modules/inventario-ajustar-list.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$inventario->setPage($_GET['p']);
|
||||
|
||||
$resReportes = $inventario->EnumAjustes();
|
||||
|
||||
$items = array();
|
||||
foreach($resReportes['items'] as $res){
|
||||
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['sucursal'] = urldecode($sucursal->GetNameById());
|
||||
|
||||
$usuario->setUsuarioId($res['usuarioId']);
|
||||
$res['usuario'] = urldecode($usuario->GetNameById());
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$infP = $producto->Info();
|
||||
|
||||
$res['codigoBarra'] = $infP['codigoBarra'];
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$resReportes['items'] = $items;
|
||||
|
||||
$smarty->assign('resReportes',$resReportes);
|
||||
|
||||
?>
|
||||
18
modules/inventario-ajustar.php
Executable file
18
modules/inventario-ajustar.php
Executable file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$sucursal->setRfcId(1);
|
||||
$resSucursales = $sucursal->GetSucursalesByRfc();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSucursales as $res){
|
||||
|
||||
$res['nombre'] = utf8_decode(urldecode($res['nombre']));
|
||||
|
||||
$sucursales[] = $res;
|
||||
}
|
||||
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
?>
|
||||
136
modules/inventario-bloqueados-detalles.php
Executable file
136
modules/inventario-bloqueados-detalles.php
Executable file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$productoId = intval($_GET['id']);
|
||||
$sucursalId = $_SESSION['idSuc'];
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$info = $producto->Info();
|
||||
$info = $util->DecodeRow($info);
|
||||
|
||||
$proveedor->setProveedorId($info['proveedorId']);
|
||||
$info['proveedor'] = $proveedor->GetNameById();
|
||||
|
||||
$prodCat->setProdCatId($info['prodCatId']);
|
||||
$info['departamento'] = $prodCat->GetNameById();
|
||||
|
||||
if($info['prodSubcatId']){
|
||||
$prodSubcat->setProdSubcatId($info['prodSubcatId']);
|
||||
$info['linea'] = $prodSubcat->GetNameById();
|
||||
}
|
||||
|
||||
$temporada->setTemporadaId($info['temporadaId']);
|
||||
$info['temporada'] = $temporada->GetNameById();
|
||||
|
||||
$porcUtilidad = ($info['utilidad'] * 100) / $info['costo'];
|
||||
$info['porcUtilidad'] = number_format($porcUtilidad,2,'.',',');
|
||||
|
||||
//Obtenemos las Tallas
|
||||
|
||||
$atribVal->setAtributoId(1);
|
||||
$resTallas = $atribVal->EnumerateAll();
|
||||
|
||||
$tallas = array();
|
||||
foreach($resTallas as $res){
|
||||
|
||||
$producto->setTallaId($res['atribValId']);
|
||||
if($producto->ExistTalla())
|
||||
$tallas[] = $res;
|
||||
}
|
||||
|
||||
$atribVal->setAtributoId(2);
|
||||
$resColores = $atribVal->EnumerateAll();
|
||||
|
||||
//Obtenemos los Colores
|
||||
|
||||
$colores = array();
|
||||
foreach($resColores as $res){
|
||||
|
||||
$producto->setColorId($res['atribValId']);
|
||||
if($producto->ExistColor())
|
||||
$colores[] = $res;
|
||||
|
||||
}
|
||||
|
||||
//Obtenemos los Atributos
|
||||
|
||||
$prodSubcat->setProdSubcatId($info['prodSubcatId']);
|
||||
$resAtributos = $prodSubcat->EnumAtributos();
|
||||
|
||||
$atributos = array();
|
||||
foreach($resAtributos as $res){
|
||||
|
||||
$atributo->setAtributoId($res['atributoId']);
|
||||
$res['nombre'] = $atributo->GetNameById();
|
||||
|
||||
$atribVal->setAtributoId($res['atributoId']);
|
||||
$resValores = $atribVal->EnumerateAll();
|
||||
|
||||
$valores = array();
|
||||
foreach($resValores as $val){
|
||||
|
||||
$producto->setAtribValId($val['atribValId']);
|
||||
if($producto->ExistAtributo())
|
||||
$valores[] = $val;
|
||||
|
||||
}
|
||||
|
||||
$res['valores'] = $valores;
|
||||
|
||||
$atributos[] = $res;
|
||||
}
|
||||
|
||||
//Obtenemos los Codigos de Barra
|
||||
|
||||
$resCodigos = $producto->GetCodigosBarra();
|
||||
$codigos = array();
|
||||
foreach($resCodigos as $res){
|
||||
|
||||
$card = $res;
|
||||
|
||||
$atribVal->setAtribValId($res['tallaId']);
|
||||
$nomTalla = $atribVal->GetNameById();
|
||||
|
||||
$atribVal->setAtribValId($res['colorId']);
|
||||
$card['nombre'] = $nomTalla.' '.$atribVal->GetNameById();
|
||||
$card['codigo'] = $res['codigoBarra'];
|
||||
|
||||
$inventario->setSucursalId($sucursalId);
|
||||
$inventario->setProdItemId($res['prodItemId']);
|
||||
$card['cantidad'] = $inventario->GetBloqueados();
|
||||
|
||||
if($card['cantidad'])
|
||||
$codigos[] = $card;
|
||||
|
||||
}
|
||||
|
||||
//Obtenemos los materiales del Producto
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$resMats = $producto->GetMaterials();
|
||||
|
||||
$prodMats = array();
|
||||
foreach($resMats as $res){
|
||||
|
||||
$material->setMaterialId($res['materialId']);
|
||||
$res['material'] = $material->GetNameById();
|
||||
|
||||
$prodMats[] = $res;
|
||||
|
||||
}
|
||||
|
||||
$smarty->assign('tipo', 'Bloqueados');
|
||||
$smarty->assign('info', $info);
|
||||
$smarty->assign('tallas', $tallas);
|
||||
$smarty->assign('colores', $colores);
|
||||
$smarty->assign('codigos', $codigos);
|
||||
$smarty->assign('prodMats', $prodMats);
|
||||
$smarty->assign('atributos', $atributos);
|
||||
|
||||
?>
|
||||
102
modules/inventario-bloqueados.php
Executable file
102
modules/inventario-bloqueados.php
Executable file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sucursalId = $_SESSION['idSuc'];
|
||||
|
||||
$inventario->SetPage($_GET["p"]);
|
||||
// $result = $inventario->EnumerateAll();
|
||||
|
||||
if($sucursalId)
|
||||
{
|
||||
$add = " AND inventario.sucursalId = '".$sucursalId."'";
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
SUM(inventario.cantidad) AS cantidad, inventario.productoId, proveedorId, producto.codigoBarra, producto.modelo, producto.precioVenta, inventario.sucursalId
|
||||
FROM
|
||||
inventario
|
||||
JOIN producto ON producto.productoId = inventario.productoId
|
||||
WHERE
|
||||
1
|
||||
".$add."
|
||||
AND
|
||||
status = 'Bloqueado'
|
||||
GROUP BY productoId ORDER BY inventario.sucursalId";
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $util->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$items = array();
|
||||
foreach($result as $key => $res){
|
||||
|
||||
$granTotal += $res["cantidad"];
|
||||
$proveedor->setProveedorId($res['proveedorId']);
|
||||
$res['proveedor'] = $proveedor->GetNameById();
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$resTallas = $producto->GetTallas();
|
||||
|
||||
$tallas = array();
|
||||
foreach($resTallas as $val){
|
||||
$atribVal->setAtribValId($val['tallaId']);
|
||||
$tallas[] = $atribVal->GetNameById();
|
||||
}
|
||||
|
||||
$res['talla'] = implode(', ',$tallas);
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$resColores = $producto->GetColores();
|
||||
|
||||
$colores = array();
|
||||
foreach($resColores as $val){
|
||||
$atribVal->setAtribValId($val['colorId']);
|
||||
$colores[] = $atribVal->GetNameById();
|
||||
}
|
||||
|
||||
$res['color'] = implode(', ',$colores);
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$resAtributos = $producto->GetAtributos();
|
||||
|
||||
$atributos = array();
|
||||
foreach($resAtributos as $val){
|
||||
$atribVal->setAtribValId($val['atribValId']);
|
||||
$atributos[] = $atribVal->GetNameById();
|
||||
}
|
||||
|
||||
$res['atributos'] = implode(', ',$atributos);
|
||||
$sucursal->setSucursalId($res["sucursalId"]);
|
||||
$res["sucursal"] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
//Obtenemos los Codigos de Barra
|
||||
/*
|
||||
$inventario->setProductoId($res['productoId']);
|
||||
$inventario->setSucursalId($sucursalId);
|
||||
$res['cantidad'] = $inventario->GetTotalItemsBloqBySuc();
|
||||
*/
|
||||
if($res['cantidad'])
|
||||
$items[] = $res;
|
||||
}
|
||||
$productos['items'] = $items;
|
||||
|
||||
|
||||
$msg = $_SESSION['msgI'];
|
||||
$_SESSION['msgI'] = '';
|
||||
|
||||
$proveedores = $proveedor->EnumerateAll();
|
||||
$categorias = $prodCat->EnumerateAll();
|
||||
|
||||
$smarty->assign('msg', $msg);
|
||||
$smarty->assign('tipo', 'Bloqueados');
|
||||
$smarty->assign('nomSuc', $nomSuc);
|
||||
$smarty->assign('granTotal', $granTotal);
|
||||
$smarty->assign('productos', $productos);
|
||||
$smarty->assign('proveedores', $proveedores);
|
||||
$smarty->assign('categorias', $categorias);
|
||||
|
||||
?>
|
||||
134
modules/inventario-detalles.php
Executable file
134
modules/inventario-detalles.php
Executable file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$productoId = intval($_GET['id']);
|
||||
$sucursalId = $_SESSION['idSuc'];
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$info = $producto->Info();
|
||||
//$info = $util->DecodeRow($info);
|
||||
|
||||
$proveedor->setProveedorId($info['proveedorId']);
|
||||
$info['proveedor'] = $proveedor->GetNameById();
|
||||
|
||||
$prodCat->setProdCatId($info['prodCatId']);
|
||||
$info['departamento'] = $prodCat->GetNameById();
|
||||
|
||||
if($info['prodSubcatId']){
|
||||
$prodSubcat->setProdSubcatId($info['prodSubcatId']);
|
||||
$info['linea'] = $prodSubcat->GetNameById();
|
||||
}
|
||||
|
||||
$temporada->setTemporadaId($info['temporadaId']);
|
||||
$info['temporada'] = $temporada->GetNameById();
|
||||
|
||||
$porcUtilidad = ($info['utilidad'] * 100) / $info['costo'];
|
||||
$info['porcUtilidad'] = number_format($porcUtilidad,2,'.',',');
|
||||
|
||||
//Obtenemos las Tallas
|
||||
|
||||
$atribVal->setAtributoId(1);
|
||||
$resTallas = $atribVal->EnumerateAll();
|
||||
|
||||
$tallas = array();
|
||||
foreach($resTallas as $res){
|
||||
|
||||
$producto->setTallaId($res['atribValId']);
|
||||
if($producto->ExistTalla())
|
||||
$tallas[] = $res;
|
||||
}
|
||||
|
||||
$atribVal->setAtributoId(2);
|
||||
$resColores = $atribVal->EnumerateAll();
|
||||
|
||||
//Obtenemos los Colores
|
||||
|
||||
$colores = array();
|
||||
foreach($resColores as $res){
|
||||
|
||||
$producto->setColorId($res['atribValId']);
|
||||
if($producto->ExistColor())
|
||||
$colores[] = $res;
|
||||
|
||||
}
|
||||
|
||||
//Obtenemos los Atributos
|
||||
|
||||
$prodSubcat->setProdSubcatId($info['prodSubcatId']);
|
||||
$resAtributos = $prodSubcat->EnumAtributos();
|
||||
|
||||
$atributos = array();
|
||||
foreach($resAtributos as $res){
|
||||
|
||||
$atributo->setAtributoId($res['atributoId']);
|
||||
$res['nombre'] = $atributo->GetNameById();
|
||||
|
||||
$atribVal->setAtributoId($res['atributoId']);
|
||||
$resValores = $atribVal->EnumerateAll();
|
||||
|
||||
$valores = array();
|
||||
foreach($resValores as $val){
|
||||
|
||||
$producto->setAtribValId($val['atribValId']);
|
||||
if($producto->ExistAtributo())
|
||||
$valores[] = $val;
|
||||
|
||||
}
|
||||
|
||||
$res['valores'] = $valores;
|
||||
|
||||
$atributos[] = $res;
|
||||
}
|
||||
|
||||
//Obtenemos los Codigos de Barra
|
||||
|
||||
$resCodigos = $producto->GetCodigosBarra();
|
||||
$codigos = array();
|
||||
foreach($resCodigos as $res){
|
||||
|
||||
$card = $res;
|
||||
|
||||
$atribVal->setAtribValId($res['tallaId']);
|
||||
$nomTalla = $atribVal->GetNameById();
|
||||
|
||||
$atribVal->setAtribValId($res['colorId']);
|
||||
$card['nombre'] = $nomTalla.' '.$atribVal->GetNameById();
|
||||
$card['codigo'] = $res['codigoBarra'];
|
||||
|
||||
$inventario->setSucursalId($sucursalId);
|
||||
$inventario->setProdItemId($res['prodItemId']);
|
||||
$card['cantidad'] = $inventario->GetDisponible();
|
||||
|
||||
$codigos[] = $card;
|
||||
|
||||
}
|
||||
|
||||
//Obtenemos los materiales del Producto
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$resMats = $producto->GetMaterials();
|
||||
|
||||
$prodMats = array();
|
||||
foreach($resMats as $res){
|
||||
|
||||
$material->setMaterialId($res['materialId']);
|
||||
$res['material'] = $material->GetNameById();
|
||||
|
||||
$prodMats[] = $res;
|
||||
|
||||
}
|
||||
|
||||
$smarty->assign('info', $info);
|
||||
$smarty->assign('tallas', $tallas);
|
||||
$smarty->assign('colores', $colores);
|
||||
$smarty->assign('codigos', $codigos);
|
||||
$smarty->assign('prodMats', $prodMats);
|
||||
$smarty->assign('atributos', $atributos);
|
||||
|
||||
?>
|
||||
63
modules/inventario-fisico-agregar.php
Executable file
63
modules/inventario-fisico-agregar.php
Executable file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$invFisicoId = intval($_GET['id']);
|
||||
|
||||
$inventario->setInvFisicoId($invFisicoId);
|
||||
$info = $inventario->InfoInvFisico();
|
||||
|
||||
if(!$info){
|
||||
header('Location: '.WEB_ROOT.'/inventario-fisico');
|
||||
exit;
|
||||
}
|
||||
|
||||
if($info['usuarioId'] != $Usr['usuarioId'] && $Usr['type'] == 'supervisor'){
|
||||
header('Location: '.WEB_ROOT.'/inventario-fisico');
|
||||
exit;
|
||||
}
|
||||
|
||||
//Obtenemos los Productos
|
||||
$inventario->setInvFisicoId($invFisicoId);
|
||||
$resProds = $inventario->GetInvFisicoProds();
|
||||
|
||||
$productos = array();
|
||||
foreach($resProds as $res){
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$infP = $producto->Info();
|
||||
|
||||
$proveedor->setProveedorId($infP['proveedorId']);
|
||||
$res['proveedor'] = $proveedor->GetNameById();
|
||||
|
||||
$res['codigoBarra'] = $infP['codigoBarra'];
|
||||
$res['modelo'] = $infP['modelo'];
|
||||
|
||||
$productos[] = $res;
|
||||
}
|
||||
|
||||
//Obtenemos las Sucursales
|
||||
$sucursal->setRfcId(1);
|
||||
$resSucursales = $sucursal->GetSucursalesByRfc();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSucursales as $res){
|
||||
$res['nombre'] = utf8_decode(urldecode($res['nombre']));
|
||||
|
||||
$usuario->setUsuarioId($Usr['usuarioId']);
|
||||
$usuario->setSucursalId($res['sucursalId']);
|
||||
$res['checked'] = $usuario->IsSucChecked();
|
||||
|
||||
$sucursales[] = $res;
|
||||
}
|
||||
|
||||
$smarty->assign('info', $info);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
$smarty->assign('productos', $productos);
|
||||
|
||||
?>
|
||||
60
modules/inventario-fisico-detalles.php
Executable file
60
modules/inventario-fisico-detalles.php
Executable file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$invFisicoId = intval($_GET['id']);
|
||||
|
||||
$inventario->setInvFisicoId($invFisicoId);
|
||||
$info = $inventario->InfoInvFisico();
|
||||
|
||||
if(!$info){
|
||||
header('Location: '.WEB_ROOT.'/inventario-fisico');
|
||||
exit;
|
||||
}
|
||||
|
||||
if($Usr['type'] != 'admin'){
|
||||
if($info['usuarioId'] != $Usr['usuarioId'] && $Usr['type'] == 'supervisor'){
|
||||
header('Location: '.WEB_ROOT.'/inventario-fisico');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
//Obtenemos los Productos
|
||||
$inventario->setInvFisicoId($invFisicoId);
|
||||
$resProds = $inventario->GetInvFisicoProds();
|
||||
|
||||
$productos = array();
|
||||
foreach($resProds as $res){
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$infP = $producto->Info();
|
||||
|
||||
$proveedor->setProveedorId($infP['proveedorId']);
|
||||
$res['proveedor'] = $proveedor->GetNameById();
|
||||
|
||||
if($info['status'] == "Pendiente"){
|
||||
$inventario->setProductoId($res['productoId']);
|
||||
$inventario->setSucursalId($info['sucursalId']);
|
||||
$res['disponible'] = $inventario->GetDispByProd();
|
||||
}
|
||||
|
||||
$res['diferencia'] = $res['cantidad'] - $res['disponible'];
|
||||
|
||||
$res['codigoBarra'] = $infP['codigoBarra'];
|
||||
$res['modelo'] = $infP['modelo'];
|
||||
|
||||
$productos[] = $res;
|
||||
}
|
||||
|
||||
$sucursal->setSucursalId($info['sucursalId']);
|
||||
$info['sucursal'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$smarty->assign('info', $info);
|
||||
$smarty->assign('productos', $productos);
|
||||
|
||||
?>
|
||||
42
modules/inventario-fisico.php
Executable file
42
modules/inventario-fisico.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$fechaHoy = date('d-m-Y');
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$resSuc2 = $util->DecodeUrlResult($resSuc);
|
||||
$sucursals = $util->DecodeResult($resSuc2);
|
||||
|
||||
$inventario->setPage($_GET['p']);
|
||||
|
||||
if($Usr['type'] == 'supervisor'){
|
||||
$inventario->setUsuarioId($Usr['usuarioId']);
|
||||
$resReportes = $inventario->EnumRepInvFisByUser();
|
||||
}else{
|
||||
$resReportes = $inventario->EnumRepInvFis();
|
||||
}
|
||||
|
||||
$items = array();
|
||||
foreach($resReportes['items'] as $res){
|
||||
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['sucursal'] = urldecode($sucursal->GetNameById());
|
||||
|
||||
$usuario->setUsuarioId($res['usuarioId']);
|
||||
$res['usuario'] = urldecode($usuario->GetNameById());
|
||||
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$resReportes['items'] = $items;
|
||||
|
||||
$smarty->assign('sucursals',$sucursals);
|
||||
$smarty->assign('resReportes',$resReportes);
|
||||
|
||||
?>
|
||||
5
modules/inventario-liberar.php
Executable file
5
modules/inventario-liberar.php
Executable file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
?>
|
||||
24
modules/inventario-wizard-list.php
Executable file
24
modules/inventario-wizard-list.php
Executable file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$sucursalId = $_SESSION['idSuc'];
|
||||
|
||||
$ajustes = $inventario->EnumWizard();
|
||||
|
||||
$items = array();
|
||||
foreach($ajustes['items'] as $res){
|
||||
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['sucursal'] = urldecode($sucursal->GetNameById());
|
||||
|
||||
$usuario->setUsuarioId($res['usuarioId']);
|
||||
$res['usuario'] = $usuario->GetNameById();
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$ajustes['items'] = $items;
|
||||
|
||||
$smarty->assign('ajustes',$ajustes);
|
||||
|
||||
?>
|
||||
24
modules/inventario-wizard-list2.php
Executable file
24
modules/inventario-wizard-list2.php
Executable file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$sucursalId = $_SESSION['idSuc'];
|
||||
|
||||
$ajustes = $inventario->EnumWizard2();
|
||||
|
||||
$items = array();
|
||||
foreach($ajustes['items'] as $res){
|
||||
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['sucursal'] = urldecode($sucursal->GetNameById());
|
||||
|
||||
$usuario->setUsuarioId($res['usuarioId']);
|
||||
$res['usuario'] = $usuario->GetNameById();
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$ajustes['items'] = $items;
|
||||
|
||||
$smarty->assign('ajustes',$ajustes);
|
||||
|
||||
?>
|
||||
184
modules/inventario-wizard.php
Executable file
184
modules/inventario-wizard.php
Executable file
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$sucursalId = $_SESSION['idSuc'];
|
||||
|
||||
$step = intval($_GET['step']);
|
||||
|
||||
if($step == 0)
|
||||
$step++;
|
||||
|
||||
if($_POST['type'] == 'uploadFile'){
|
||||
|
||||
$sucursalId = $_POST['sucursalId'];
|
||||
$_SESSION['wizSucId'] = $sucursalId;
|
||||
|
||||
if($_SESSION['xlsFile'] != ''){
|
||||
header('Location: '.WEB_ROOT.'/inventario-wizard/step/2');
|
||||
exit;
|
||||
}
|
||||
|
||||
$tempFile = $_FILES['excelFile']['tmp_name'];
|
||||
|
||||
if($tempFile == ''){
|
||||
|
||||
$errMsg = 'Por favor, seleccione un archivo.';
|
||||
|
||||
}else{
|
||||
|
||||
$fileParts = pathinfo($_FILES['excelFile']['name']);
|
||||
|
||||
if($fileParts['extension'] != 'csv'){
|
||||
|
||||
$errMsg = 'Tipo de archivo invalido. Debe ser .csv';
|
||||
|
||||
}else{
|
||||
|
||||
$targetFolder = DOC_ROOT.'/temp';
|
||||
$timestamp = time();
|
||||
$_SESSION['identificador'] = $timestamp;
|
||||
|
||||
$targetPath = $targetFolder;
|
||||
|
||||
$nomFile = 'excel_'.$timestamp.'.'.$fileParts['extension'];
|
||||
|
||||
$targetFile = rtrim($targetPath,'/').'/'.$nomFile;
|
||||
|
||||
if(move_uploaded_file($_FILES['excelFile']['tmp_name'], $targetFile)){
|
||||
|
||||
$_SESSION['xlsFile'] = $nomFile;
|
||||
|
||||
header('Location: '.WEB_ROOT.'/inventario-wizard/step/2');
|
||||
exit;
|
||||
|
||||
}else{
|
||||
|
||||
$errMsg = 'Ocurrio un error al subir el archivo.';
|
||||
|
||||
}//else
|
||||
|
||||
}//else
|
||||
|
||||
}//else
|
||||
|
||||
}//if
|
||||
|
||||
if($step == 1){
|
||||
|
||||
if($_SESSION['wizSucId'])
|
||||
$sucursalId = $_SESSION['wizSucId'];
|
||||
|
||||
$sucursal->setSucursalId($sucursalId);
|
||||
$nomSuc = $sucursal->GetNameById($sucursalId);
|
||||
$nomSuc = utf8_decode(urldecode($nomSuc));
|
||||
|
||||
$xlsFile = $_SESSION['xlsFile'];
|
||||
|
||||
$sucursal->setRfcId(1);
|
||||
$resSucursales = $sucursal->GetSucursalesByRfc();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSucursales as $res){
|
||||
|
||||
$res['nombre'] = utf8_decode(urldecode($res['nombre']));
|
||||
|
||||
$sucursales[] = $res;
|
||||
}
|
||||
|
||||
}elseif($step == 2){
|
||||
|
||||
$sucursalId = $_SESSION['wizSucId'];
|
||||
|
||||
$sucursal->setSucursalId($sucursalId);
|
||||
$nomSuc = $sucursal->GetNameById($sucursalId);
|
||||
$nomSuc = utf8_decode(urldecode($nomSuc));
|
||||
|
||||
$csvFile = DOC_ROOT.'/temp/'.$_SESSION['xlsFile'];
|
||||
|
||||
$file = @fopen($csvFile, 'r');
|
||||
|
||||
if($_SESSION['xlsFile'] == ''){
|
||||
$errMsg = 'No se ha cargado ningún archivo. Por favor, verifique.';
|
||||
}elseif(!$file){
|
||||
$errMsg = 'Ocurrio un error al abrir el archivo';
|
||||
}else{
|
||||
|
||||
$size = filesize($csvFile);
|
||||
|
||||
if(!$size){
|
||||
$errMsg = 'El archivo esta vacio, verifique';
|
||||
}else{
|
||||
|
||||
$db = $util->DBSelect(15);
|
||||
|
||||
$cantProdExisten = 0;
|
||||
$cantProdFaltan = 0;
|
||||
$prodExisten = array();
|
||||
$prodFaltan = array();
|
||||
|
||||
while (( $field = fgetcsv($file,2048,",")) !== false ) { // Mientras hay líneas que leer...
|
||||
|
||||
if($lines >= 1){
|
||||
|
||||
$codigoBarra = trim($field[0]);
|
||||
$stock = trim($field[1]);
|
||||
|
||||
$card['codigoBarra'] = $codigoBarra;
|
||||
$card['stock'] = $stock;
|
||||
|
||||
if($codigoBarra){
|
||||
|
||||
$sql = 'SELECT productoId FROM producto WHERE codigoBarra = "'.$codigoBarra.'"';
|
||||
$db->setQuery($sql);
|
||||
$productoId = $db->GetSingle();
|
||||
|
||||
if($productoId){
|
||||
|
||||
$prodExisten[] = $card;
|
||||
$cantProdExisten += $stock;
|
||||
|
||||
}else{
|
||||
|
||||
$prodFaltan[] = $card;
|
||||
$cantProdFaltan += $stock;
|
||||
|
||||
}//if
|
||||
|
||||
$regs++;
|
||||
|
||||
}//if
|
||||
|
||||
}//if
|
||||
|
||||
$lines++;
|
||||
|
||||
}//while
|
||||
|
||||
if(count($prodFaltan)){
|
||||
$errMsg = 'Debido a que hay productos que no se encuentran en el sistema,
|
||||
<br>primero debe dar da alta esos productos para poder continuar con el proceso.';
|
||||
@unlink($csvFile);
|
||||
$_SESSION['xlsFile'] = '';
|
||||
$_SESSION['wizSucId'] = '';
|
||||
$_SESSION['identificador'] = '';
|
||||
}
|
||||
|
||||
}//else
|
||||
|
||||
}//else
|
||||
|
||||
}//if
|
||||
|
||||
$smarty->assign('errMsg', $errMsg);
|
||||
$smarty->assign('step', $step);
|
||||
$smarty->assign('xlsFile', $xlsFile);
|
||||
$smarty->assign('sucursalId', $sucursalId);
|
||||
$smarty->assign('nomSuc', $nomSuc);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
$smarty->assign('cantProdExisten', $cantProdExisten);
|
||||
$smarty->assign('cantProdFaltan', $cantProdFaltan);
|
||||
$smarty->assign('prodExisten', $prodExisten);
|
||||
$smarty->assign('prodFaltan', $prodFaltan);
|
||||
|
||||
?>
|
||||
184
modules/inventario-wizard2.php
Executable file
184
modules/inventario-wizard2.php
Executable file
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$sucursalId = $_SESSION['idSuc'];
|
||||
|
||||
$step = intval($_GET['step']);
|
||||
|
||||
if($step == 0)
|
||||
$step++;
|
||||
|
||||
if($_POST['type'] == 'uploadFile'){
|
||||
|
||||
$sucursalId = $_POST['sucursalId'];
|
||||
$_SESSION['wizSucId'] = $sucursalId;
|
||||
|
||||
if($_SESSION['xlsFile'] != ''){
|
||||
header('Location: '.WEB_ROOT.'/inventario-wizard2/step/2');
|
||||
exit;
|
||||
}
|
||||
|
||||
$tempFile = $_FILES['excelFile']['tmp_name'];
|
||||
|
||||
if($tempFile == ''){
|
||||
|
||||
$errMsg = 'Por favor, seleccione un archivo.';
|
||||
|
||||
}else{
|
||||
|
||||
$fileParts = pathinfo($_FILES['excelFile']['name']);
|
||||
|
||||
if($fileParts['extension'] != 'csv'){
|
||||
|
||||
$errMsg = 'Tipo de archivo invalido. Debe ser .csv';
|
||||
|
||||
}else{
|
||||
|
||||
$targetFolder = DOC_ROOT.'/temp';
|
||||
$timestamp = time();
|
||||
$_SESSION['identificador'] = $timestamp;
|
||||
|
||||
$targetPath = $targetFolder;
|
||||
|
||||
$nomFile = 'excel_'.$timestamp.'.'.$fileParts['extension'];
|
||||
|
||||
$targetFile = rtrim($targetPath,'/').'/'.$nomFile;
|
||||
|
||||
if(move_uploaded_file($_FILES['excelFile']['tmp_name'], $targetFile)){
|
||||
|
||||
$_SESSION['xlsFile'] = $nomFile;
|
||||
|
||||
header('Location: '.WEB_ROOT.'/inventario-wizard2/step/2');
|
||||
exit;
|
||||
|
||||
}else{
|
||||
|
||||
$errMsg = 'Ocurrio un error al subir el archivo.';
|
||||
|
||||
}//else
|
||||
|
||||
}//else
|
||||
|
||||
}//else
|
||||
|
||||
}//if
|
||||
|
||||
if($step == 1){
|
||||
|
||||
if($_SESSION['wizSucId'])
|
||||
$sucursalId = $_SESSION['wizSucId'];
|
||||
|
||||
$sucursal->setSucursalId($sucursalId);
|
||||
$nomSuc = $sucursal->GetNameById($sucursalId);
|
||||
$nomSuc = utf8_decode(urldecode($nomSuc));
|
||||
|
||||
$xlsFile = $_SESSION['xlsFile'];
|
||||
|
||||
$sucursal->setRfcId(1);
|
||||
$resSucursales = $sucursal->GetSucursalesByRfc();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSucursales as $res){
|
||||
|
||||
$res['nombre'] = utf8_decode(urldecode($res['nombre']));
|
||||
|
||||
$sucursales[] = $res;
|
||||
}
|
||||
|
||||
}elseif($step == 2){
|
||||
|
||||
$sucursalId = $_SESSION['wizSucId'];
|
||||
|
||||
$sucursal->setSucursalId($sucursalId);
|
||||
$nomSuc = $sucursal->GetNameById($sucursalId);
|
||||
$nomSuc = utf8_decode(urldecode($nomSuc));
|
||||
|
||||
$csvFile = DOC_ROOT.'/temp/'.$_SESSION['xlsFile'];
|
||||
|
||||
$file = @fopen($csvFile, 'r');
|
||||
|
||||
if($_SESSION['xlsFile'] == ''){
|
||||
$errMsg = 'No se ha cargado ningún archivo. Por favor, verifique.';
|
||||
}elseif(!$file){
|
||||
$errMsg = 'Ocurrio un error al abrir el archivo';
|
||||
}else{
|
||||
|
||||
$size = filesize($csvFile);
|
||||
|
||||
if(!$size){
|
||||
$errMsg = 'El archivo esta vacio, verifique';
|
||||
}else{
|
||||
|
||||
$db = $util->DBSelect(15);
|
||||
|
||||
$cantProdExisten = 0;
|
||||
$cantProdFaltan = 0;
|
||||
$prodExisten = array();
|
||||
$prodFaltan = array();
|
||||
|
||||
while (( $field = fgetcsv($file,2048,",")) !== false ) { // Mientras hay líneas que leer...
|
||||
|
||||
if($lines >= 1){
|
||||
|
||||
$codigoBarra = trim($field[0]);
|
||||
$stock = trim($field[1]);
|
||||
|
||||
$card['codigoBarra'] = $codigoBarra;
|
||||
$card['stock'] = $stock;
|
||||
|
||||
if($codigoBarra){
|
||||
|
||||
$sql = 'SELECT productoId FROM producto WHERE codigoBarra = "'.$codigoBarra.'"';
|
||||
$db->setQuery($sql);
|
||||
$productoId = $db->GetSingle();
|
||||
|
||||
if($productoId){
|
||||
|
||||
$prodExisten[] = $card;
|
||||
$cantProdExisten += $stock;
|
||||
|
||||
}else{
|
||||
|
||||
$prodFaltan[] = $card;
|
||||
$cantProdFaltan += $stock;
|
||||
|
||||
}//if
|
||||
|
||||
$regs++;
|
||||
|
||||
}//if
|
||||
|
||||
}//if
|
||||
|
||||
$lines++;
|
||||
|
||||
}//while
|
||||
|
||||
if(count($prodFaltan)){
|
||||
$errMsg = 'Debido a que hay productos que no se encuentran en el sistema,
|
||||
<br>primero debe dar da alta esos productos para poder continuar con el proceso.';
|
||||
@unlink($csvFile);
|
||||
$_SESSION['xlsFile'] = '';
|
||||
$_SESSION['wizSucId'] = '';
|
||||
$_SESSION['identificador'] = '';
|
||||
}
|
||||
|
||||
}//else
|
||||
|
||||
}//else
|
||||
|
||||
}//if
|
||||
|
||||
$smarty->assign('errMsg', $errMsg);
|
||||
$smarty->assign('step', $step);
|
||||
$smarty->assign('xlsFile', $xlsFile);
|
||||
$smarty->assign('sucursalId', $sucursalId);
|
||||
$smarty->assign('nomSuc', $nomSuc);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
$smarty->assign('cantProdExisten', $cantProdExisten);
|
||||
$smarty->assign('cantProdFaltan', $cantProdFaltan);
|
||||
$smarty->assign('prodExisten', $prodExisten);
|
||||
$smarty->assign('prodFaltan', $prodFaltan);
|
||||
|
||||
?>
|
||||
36
modules/inventario-wizprods.php
Executable file
36
modules/inventario-wizprods.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$invWizardId = intval($_GET['id']);
|
||||
|
||||
$inventario->setInvWizardId($invWizardId);
|
||||
$info = $inventario->InfoWizard();
|
||||
|
||||
$resProductos = $inventario->EnumWizardProds();
|
||||
|
||||
$productos = array();
|
||||
foreach($resProductos as $res){
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$infP = $producto->Info();
|
||||
|
||||
$res['codigoBarra'] = $infP['codigoBarra'];
|
||||
$res['producto'] = $infP['modelo'];
|
||||
|
||||
$proveedor->setProveedorId($infP['proveedorId']);
|
||||
$res['proveedor'] = $proveedor->GetNameById();
|
||||
|
||||
$productos[] = $res;
|
||||
}
|
||||
|
||||
$sucursal->setSucursalId($info['sucursalId']);
|
||||
$info['sucursal'] = urldecode($sucursal->GetNameById());
|
||||
|
||||
$info['fecha'] = date('d-m-Y H:i:s', strtotime($info['fecha']));
|
||||
|
||||
$smarty->assign('info',$info);
|
||||
$smarty->assign('invWizardId',$invWizardId);
|
||||
$smarty->assign('productos',$productos);
|
||||
|
||||
?>
|
||||
36
modules/inventario-wizprods2.php
Executable file
36
modules/inventario-wizprods2.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$invWizardId = intval($_GET['id']);
|
||||
|
||||
$inventario->setInvWizardId($invWizardId);
|
||||
$info = $inventario->InfoWizard2();
|
||||
|
||||
$resProductos = $inventario->EnumWizardProds2();
|
||||
|
||||
$productos = array();
|
||||
foreach($resProductos as $res){
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$infP = $producto->Info();
|
||||
|
||||
$res['codigoBarra'] = $infP['codigoBarra'];
|
||||
$res['producto'] = $infP['modelo'];
|
||||
|
||||
$proveedor->setProveedorId($infP['proveedorId']);
|
||||
$res['proveedor'] = $proveedor->GetNameById();
|
||||
|
||||
$productos[] = $res;
|
||||
}
|
||||
|
||||
$sucursal->setSucursalId($info['sucursalId']);
|
||||
$info['sucursal'] = urldecode($sucursal->GetNameById());
|
||||
|
||||
$info['fecha'] = date('d-m-Y H:i:s', strtotime($info['fecha']));
|
||||
|
||||
$smarty->assign('info',$info);
|
||||
$smarty->assign('invWizardId',$invWizardId);
|
||||
$smarty->assign('productos',$productos);
|
||||
|
||||
?>
|
||||
178
modules/inventario.php
Executable file
178
modules/inventario.php
Executable file
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sucursalId = $_SESSION['idSuc'];
|
||||
|
||||
//Checamos si hay solicitud de Reporte
|
||||
$inventario->setSucursalId($sucursalId);
|
||||
$infR = $inventario->InfoInvParcial();
|
||||
|
||||
if($_POST['type'] == 'sendReport'){
|
||||
|
||||
$repInvParcialId = $_POST['repInvParcialId'];
|
||||
|
||||
//Guardamos la identificacion
|
||||
|
||||
$ruta = DOC_ROOT.'/reportes';
|
||||
|
||||
// obtenemos los datos del archivo
|
||||
$tamano = $_FILES["fileReport"]['size'];
|
||||
$tipo = $_FILES["fileReport"]['type'];
|
||||
$archivo = $_FILES["fileReport"]['name'];
|
||||
|
||||
$nom = explode('.',$archivo);
|
||||
|
||||
$prefijo = substr(md5(uniqid(rand())),0,3);
|
||||
$time = time();
|
||||
|
||||
if($tipo != 'text/plain'){
|
||||
|
||||
$msgReport = 'typeFail';
|
||||
|
||||
}elseif($archivo != ""){
|
||||
|
||||
$fileName = $repInvParcialId.'_'.$time.'.'.$nom[1];
|
||||
|
||||
$destino = $ruta.'/'.$fileName;
|
||||
if (move_uploaded_file($_FILES['fileReport']['tmp_name'],$destino)) {
|
||||
|
||||
//Actualizamos el status
|
||||
|
||||
$inventario->setRepInvParcialId($repInvParcialId);
|
||||
$inventario->UpdateStatusRepParcial('Generado');
|
||||
$inventario->UpdateFileRepParcial($fileName);
|
||||
|
||||
//Comparamos los Datos con el Inventario Real y guardamos los datos.
|
||||
|
||||
$fp = fopen(DOC_ROOT.'/reportes/'.$fileName,'r') or die('No se pudo abrir el archivo');
|
||||
|
||||
while(!feof($fp)){
|
||||
|
||||
$linea = fgets($fp);
|
||||
$inv = preg_split('/\s+/', $linea);
|
||||
|
||||
if($inv[0] != ''){
|
||||
|
||||
$cantidad = $inv[1];
|
||||
|
||||
$producto->setCodigoBarra($inv[0]);
|
||||
$productoId = $producto->GetProductIdByCodigo();
|
||||
|
||||
if($productoId){
|
||||
|
||||
$inventario->setProductoId($productoId);
|
||||
$inventario->setSucursalId($sucursalId);
|
||||
$cantReal = $inventario->GetTotalItemsBySuc();
|
||||
|
||||
$inventario->setRepInvParcialId($repInvParcialId);
|
||||
$inventario->setProductoId($productoId);
|
||||
$inventario->setCantidad($cantidad);
|
||||
$inventario->setCantReal($cantReal);
|
||||
$inventario->SaveRepProd();
|
||||
}
|
||||
|
||||
}//if
|
||||
|
||||
}//while
|
||||
|
||||
$msgReport = 'success';
|
||||
|
||||
}//if
|
||||
|
||||
}//if
|
||||
|
||||
}else{
|
||||
|
||||
$inventario->SetPage($_GET["p"]);
|
||||
$inventario->setSucursalId($sucursalId);
|
||||
|
||||
if($infR['repInvParcialId'])
|
||||
$productos = $inventario->EnumDisponibleByRand();
|
||||
else
|
||||
$productos = $inventario->EnumDisponible();
|
||||
|
||||
$items = array();
|
||||
foreach($productos['items'] as $res){
|
||||
|
||||
$proveedor->setProveedorId($res['proveedorId']);
|
||||
$res['proveedor'] = $proveedor->GetNameById();
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$resTallas = $producto->GetTallas();
|
||||
|
||||
$tallas = array();
|
||||
foreach($resTallas as $val){
|
||||
$atribVal->setAtribValId($val['tallaId']);
|
||||
$tallas[] = $atribVal->GetNameById();
|
||||
}
|
||||
|
||||
$res['talla'] = implode(', ',$tallas);
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$resColores = $producto->GetColores();
|
||||
|
||||
$colores = array();
|
||||
foreach($resColores as $val){
|
||||
$atribVal->setAtribValId($val['colorId']);
|
||||
$colores[] = $atribVal->GetNameById();
|
||||
}
|
||||
|
||||
$res['color'] = implode(', ',$colores);
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$resAtributos = $producto->GetAtributos();
|
||||
|
||||
$atributos = array();
|
||||
foreach($resAtributos as $val){
|
||||
$atribVal->setAtribValId($val['atribValId']);
|
||||
$atributos[] = $atribVal->GetNameById();
|
||||
}
|
||||
|
||||
$res['atributos'] = implode(', ',$atributos);
|
||||
|
||||
//Obtenemos los Codigos de Barra
|
||||
$inventario->setProductoId($res['productoId']);
|
||||
$inventario->setSucursalId($sucursalId);
|
||||
$res['cantidad'] = $inventario->GetTotalItemsBySuc();
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$productos['items'] = $items;
|
||||
|
||||
|
||||
$msg = $_SESSION['msgI'];
|
||||
$_SESSION['msgI'] = '';
|
||||
|
||||
$sucursal->setSucursalId($sucursalId);
|
||||
$nomSuc = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$proveedores = $proveedor->EnumerateAll();
|
||||
$categorias = $prodCat->EnumerateAll();
|
||||
|
||||
}//else
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$resSuc2 = $util->DecodeUrlResult($resSuc);
|
||||
$sucursales = $util->DecodeResult($resSuc2);
|
||||
|
||||
$smarty->assign('msg', $msg);
|
||||
$smarty->assign('nomSuc', $nomSuc);
|
||||
$smarty->assign('envios', $resEnvios);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
$smarty->assign('infR', $infR);
|
||||
$smarty->assign('msg', $msg);
|
||||
$smarty->assign('msgReport', $msgReport);
|
||||
$smarty->assign('nomSuc', $nomSuc);
|
||||
$smarty->assign('productos', $productos);
|
||||
$smarty->assign('proveedores', $proveedores);
|
||||
$smarty->assign('categorias', $categorias);
|
||||
|
||||
|
||||
?>
|
||||
8
modules/login.php
Executable file
8
modules/login.php
Executable file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
$empresa->Util()->DB()->setQuery("SELECT * FROM empresa");
|
||||
$result = $empresa->Util()->DB->GetResult();
|
||||
|
||||
$smarty->assign("empresas", $result);
|
||||
|
||||
?>
|
||||
8
modules/login.php~
Executable file
8
modules/login.php~
Executable file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
echo 'ee';
|
||||
$empresa->Util()->DB()->setQuery("SELECT * FROM empresa");
|
||||
$result = $empresa->Util()->DB->GetResult();
|
||||
|
||||
$smarty->assign("empresas", $result);
|
||||
|
||||
?>
|
||||
15
modules/materiales.php
Executable file
15
modules/materiales.php
Executable file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($Usr['type'] != 'admin' && $Usr['type'] != 'direccion' && $Usr['type'] != 'compras' && $Usr['type'] != 'almacen' && $Usr['type'] != 'centralizador'){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$material->SetPage($_GET["p"]);
|
||||
$materiales = $material->Enumerate();
|
||||
|
||||
$smarty->assign('materiales', $materiales);
|
||||
|
||||
?>
|
||||
15
modules/metodos-pago.php
Executable file
15
modules/metodos-pago.php
Executable file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($Usr['type'] != 'admin' && $Usr['type'] != 'direccion' && $Usr['type'] != 'almacen' && $Usr['type'] != 'centralizador'){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$metodoPago->SetPage($_GET["p"]);
|
||||
$metodosPago = $metodoPago->Enumerate();
|
||||
|
||||
$smarty->assign('metodosPago', $metodosPago);
|
||||
|
||||
?>
|
||||
25
modules/monederos.php
Executable file
25
modules/monederos.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
|
||||
$monedero->setPage($_GET["p"]);
|
||||
$monederos = $monedero->Enumerate();
|
||||
|
||||
$items = array();
|
||||
foreach($monederos['items'] as $res){
|
||||
|
||||
$monedero->setMonederoId($res['monederoId']);
|
||||
$res['historial'] = $monedero->EnumHistorial();
|
||||
|
||||
$items[] = $res;
|
||||
|
||||
}
|
||||
$monederos['items'] = $items;
|
||||
|
||||
$smarty->assign('monederos', $monederos);
|
||||
|
||||
|
||||
?>
|
||||
11
modules/motivos.php
Executable file
11
modules/motivos.php
Executable file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$motivo->SetPage($_GET["p"]);
|
||||
$motivos = $motivo->Enumerate();
|
||||
|
||||
$smarty->assign('motivos', $motivos);
|
||||
|
||||
|
||||
?>
|
||||
403
modules/pedidos-acuse.php
Executable file
403
modules/pedidos-acuse.php
Executable file
@@ -0,0 +1,403 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
include_once(DOC_ROOT.'/pdf/dompdf_config.inc.php');
|
||||
|
||||
$pedidoId = $_GET['pedidoId'];
|
||||
|
||||
$pedido->setPedidoId($pedidoId);
|
||||
$info = $pedido->Info();
|
||||
|
||||
$rfc->setRfcId(1);
|
||||
$infE = $util->EncodeRow($rfc->Info());
|
||||
|
||||
$direccion = $infE['calle'];
|
||||
|
||||
if($infE['noExt'] != '')
|
||||
$direccion .= ' No. Ext. '.$infE['noExt'];
|
||||
if($infE['noInt'] != '')
|
||||
$direccion .= ', No. Int. '.$infE['noInt'];
|
||||
if($infE['colonia'] != '')
|
||||
$direccion .= ', Col. '.$infE['colonia'];
|
||||
// if($infE['localidad'] != '')
|
||||
// $direccion .= ', '.$infE['localidad'];
|
||||
// if($infE['ciudad'] != '')
|
||||
// $direccion .= ', '.$infE['ciudad'];
|
||||
if($infE['municipio'] != '')
|
||||
$direccion .= ', '.$infE['municipio'];
|
||||
if($infE['estado'] != '')
|
||||
$direccion .= ', '.$infE['estado'];
|
||||
if($infE['codigoPostal'] != '')
|
||||
$direccion .= 'C.P. '.$infE['codigoPostal'];
|
||||
|
||||
$infE['direccion'] = $direccion;
|
||||
|
||||
$proveedor->setProveedorId($info['proveedorId']);
|
||||
$infPv = $util->EncodeRow($proveedor->Info());
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fecha']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fecha'] = $fecha;
|
||||
|
||||
$fechaEntrega = date('d-m-Y',strtotime($info['fechaEntrega']));
|
||||
$info['fechaEntrega'] = $util->FormatDateDMMMY($fechaEntrega);
|
||||
|
||||
/*
|
||||
if($info['metodoCompra'] == 'conIva')
|
||||
$info['metodoCompra'] = 'IVA Incluido';
|
||||
else
|
||||
$info['metodoCompra'] = 'IVA No Incluido';
|
||||
*/
|
||||
//Productos
|
||||
|
||||
$resProducts = $pedido->GetProductos();
|
||||
|
||||
$sugerencias = 0;
|
||||
$subtotalP = 0;
|
||||
$products = array();
|
||||
foreach($resProducts as $card){
|
||||
|
||||
$prodCatId = $card['prodCatId'];
|
||||
$prodSubcatId = $card['prodSubcatId'];
|
||||
$productoId = $card['productoId'];
|
||||
|
||||
$card['productoId'] = $productoId;
|
||||
$card['prodCatId'] = $prodCatId;
|
||||
$card['prodSubcatId'] = $prodSubcatId;
|
||||
|
||||
$prodCat->setProdCatId($prodCatId);
|
||||
$card['departamento'] = $prodCat->GetNameById();
|
||||
|
||||
$prodSubcat->setProdSubcatId($prodSubcatId);
|
||||
$card['linea'] = $prodSubcat->GetNameById();
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$infP = $producto->Info();
|
||||
$card['modelo'] = $infP['modelo'];
|
||||
$card['imagen'] = $infP['imagen'];
|
||||
$card['codigoBarra'] = $infP['codigoBarra'];
|
||||
|
||||
$card['atributos'] = $producto->GetAtributosAll();
|
||||
|
||||
if($card['prendasComp'] == 1)
|
||||
$card['cantidad'] = $card['totalLote'] * $card['cantLotes'];
|
||||
else
|
||||
$card['cantidad'] = $card['prendasRec'];
|
||||
|
||||
$totalP = $card['costo'] * $card['cantidad'];
|
||||
$card['total'] = number_format($totalP,2,'.','');
|
||||
|
||||
$subtotalP += $totalP;
|
||||
|
||||
$card['subtotales'] = $subtotales;
|
||||
|
||||
$products[] = $card;
|
||||
|
||||
}//foreach
|
||||
|
||||
if($info['fechaFolio'] == "0000-00-00")
|
||||
{
|
||||
$fechaP = "---";
|
||||
}
|
||||
else
|
||||
{
|
||||
$fechaP = date('d-m-Y',strtotime($info['fechaFolio']));
|
||||
}
|
||||
|
||||
if($info['fechaOrdenCompIng'] == "0000-00-00")
|
||||
{
|
||||
$fechaP1 = "---";
|
||||
}
|
||||
else
|
||||
{
|
||||
$fechaP1 = date('d-m-Y',strtotime($info['fechaOrdenCompIng']));
|
||||
}
|
||||
|
||||
if($info['fechaOrdenCompIng'] == "0000-00-00")
|
||||
{
|
||||
$horaP1 = "---";
|
||||
}
|
||||
else
|
||||
{
|
||||
$horaP1 = date('H:i:s',strtotime($info['fechaOrdenCompIng']));
|
||||
}
|
||||
|
||||
if($fechaP1 == "---")
|
||||
{
|
||||
$fechaV = "---";
|
||||
}
|
||||
else
|
||||
{
|
||||
$fechaV = date('d-m-Y',strtotime($fechaP1.' + 90 days'));
|
||||
}
|
||||
|
||||
$porcDesc = $info['porcPub'] + $info['porcFlete'] + $info['porcDes'] + $info['porcEsp'];
|
||||
|
||||
$foliosP = array();
|
||||
if($info['folioProv'])
|
||||
$foliosP[] = $info['folioProv'];
|
||||
if($info['folioProv2'])
|
||||
$foliosP[] = $info['folioProv2'];
|
||||
if($info['folioProv3'])
|
||||
$foliosP[] = $info['folioProv3'];
|
||||
if($info['folioProv4'])
|
||||
$foliosP[] = $info['folioProv4'];
|
||||
if($info['folioProv5'])
|
||||
$foliosP[] = $info['folioProv5'];
|
||||
|
||||
$foliosProv = implode('<br>',$foliosP);
|
||||
|
||||
//HTML - PDF
|
||||
|
||||
$html .= '
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
body{
|
||||
font-family:Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size:10px;
|
||||
}
|
||||
.titulo {
|
||||
color: #FFFFFF;
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-weight: bold;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="550" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td width="430">
|
||||
<p><b>CEDIS <br>
|
||||
COMERCIALIZADORA NOVOMODA, S.A. DE C.V.</b><br />
|
||||
'.$infE['direccion'].'
|
||||
</td>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<table width="550" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td>
|
||||
<table width="550" border="1" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td width="" align="center"><b>ORDEN COMPRA</b></td>
|
||||
<td width="15%" align="center"><b>FECHA EXP.</b></td>
|
||||
<td width="15%" align="center"><b>CONDICIONES</b></td>
|
||||
<td width="15%" align="center"><b>FECHA VECTO.</b></td>
|
||||
<td width="15%" align="center"><b>FACT/REM.</b></td>
|
||||
<td width="15%" align="center"><b>FECHA REG.</b></td>
|
||||
<td width="15%" align="center"><b>HORA REG.</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="15" align="center">'.$info['noPedido'].'</td>
|
||||
<td align="center">'.$fechaP.'</td>
|
||||
<td align="center">90 Dias</td>
|
||||
<td align="center">'.$fechaV.'</td>
|
||||
<td align="center">'.$foliosProv.'</td>
|
||||
<td align="center">'.$fechaP.'</td>
|
||||
<td align="center">'.$horaP1.'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><b>NO. PROV.</b></td>
|
||||
<td align="center"><b>T. MONEDA.</b></td>
|
||||
<td align="center"><b>CONC. INV.</b></td>
|
||||
<td align="center"><b>CONC. CXP.</b></td>
|
||||
<td align="center"><b></b></td>
|
||||
<td align="center"><b></b></td>
|
||||
<td align="center"><b></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="15" align="center">'.$info['proveedorId'].'</td>
|
||||
<td align="center">MONEDA NACIONAL</td>
|
||||
<td align="center">ENT X COMPR</td>
|
||||
<td align="center">COMPRAS</td>
|
||||
<td align="center"> --- </td>
|
||||
<td align="center"> --- </td>
|
||||
<td align="center"> --- </td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
//DATOS DEL PROVEEDOR
|
||||
|
||||
$html .= '
|
||||
<table width="550" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td colspan="4" align="center" bgcolor="#809829"><span class="titulo">DATOS DEL PROVEEDOR</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="23%"><b>Razón Social</b></td>
|
||||
<td width="26%">'.$infPv['nombre'].'</td>
|
||||
<td width="27%"><b>Calle</b></td>
|
||||
<td width="">'.$infPv['calle'].'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>RFC</b></td>
|
||||
<td>'.$infPv['rfc'].'</td>
|
||||
<td><b>Colonia</b></td>
|
||||
<td>'.$infPv['colonia'].'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Teléfonos</b></td>
|
||||
<td>'.$infPv['phone'].'</td>
|
||||
<td><b>Delegación o Municipio</b></td>
|
||||
<td>'.$infPv['municipio'].'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>C.P.</b></td>
|
||||
<td>'.$infS['codigoPostal'].'</td>
|
||||
<td><b>Estado</b></td>
|
||||
<td>'.$infS['estado'].'</td>
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
//PRODUCTOS
|
||||
|
||||
$html .= '
|
||||
<br>
|
||||
<table width="550" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td colspan="5" align="center" bgcolor="#809829"><span class="titulo">PRODUCTOS</span></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>';
|
||||
|
||||
$html .= '
|
||||
<table width="550" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td width="13%" align="center" bgcolor="#CCCCCC">CODIGO BARRA</td>
|
||||
<td width="" align="center" bgcolor="#CCCCCC">DESCRIPCION</td>
|
||||
<td width="10%" align="center" bgcolor="#CCCCCC">T.U.</td>
|
||||
<td width="10%" align="center" bgcolor="#CCCCCC">CANTIDAD</td>
|
||||
<td width="10%" align="center" bgcolor="#CCCCCC">PRECIO</td>
|
||||
<td width="10%" align="center" bgcolor="#CCCCCC">DESCUENTOS</td>
|
||||
<td width="10%" align="center" bgcolor="#CCCCCC">IMP. BRUTO</td>
|
||||
<td width="10%" align="center" bgcolor="#CCCCCC">IMP. NETO</td>
|
||||
</tr>';
|
||||
|
||||
$cantTotal = 0;
|
||||
$totalGlobal = 0;
|
||||
$descGlobal = 0;
|
||||
foreach($products as $res){
|
||||
|
||||
$impBruto = $res['total'];
|
||||
|
||||
$totalDesc = $impBruto * ($porcDesc/100);
|
||||
$descGlobal += $totalDesc;
|
||||
|
||||
$impNeto = $impBruto - $totalDesc;
|
||||
|
||||
$html .= '
|
||||
<tr>
|
||||
<td align="center">'.$res['codigoBarra'].'</td>
|
||||
<td align="left">'.$res['modelo'].'</td>
|
||||
<td align="center">Pza.</td>
|
||||
<td align="center">'.number_format($res['cantidad'],0).'</td>
|
||||
<td align="center">$'.number_format($res['costo'],2).'</td>
|
||||
<td align="center">'.$porcDesc.'%</td>
|
||||
<td align="center">$'.number_format($impBruto,2).'</td>
|
||||
<td align="right">$'.number_format($impNeto,2).'</td>
|
||||
</tr>';
|
||||
|
||||
$cantTotal += $res['cantidad'];
|
||||
$impBrutoG += $impBruto;
|
||||
$impNetoG += $impNeto;
|
||||
|
||||
}//foreach
|
||||
|
||||
$html .= '
|
||||
<tr>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center">TOTALES</td>
|
||||
<td align="center">'.number_format($cantTotal,0).'</td>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center">$'.number_format($impBrutoG,2).'</td>
|
||||
<td align="right">$'.number_format($impNetoG,2).'</td>
|
||||
</tr>
|
||||
';
|
||||
|
||||
$html .= '</table>';
|
||||
|
||||
//TOTALES
|
||||
|
||||
if($info['subtotal2'] > 0){
|
||||
$info['subtotal'] = $info['subtotal2'];
|
||||
$info['iva'] = $info['iva2'];
|
||||
$info['total'] = $info['total2'];
|
||||
}
|
||||
|
||||
$ivaPorc = 16;
|
||||
|
||||
if($porcDesc > 0){
|
||||
$info['subtotal'] = $impNetoG;
|
||||
$info['iva'] = $impNetoG * ($ivaPorc/100);
|
||||
$info['total'] = $info['subtotal'] + $info['iva'];
|
||||
}
|
||||
|
||||
if($info['metodoCompra'] == 'sinIva')
|
||||
$info['total'] = $impNetoG;
|
||||
|
||||
$info['subtotal'] = number_format($info['subtotal'],2);
|
||||
$info['iva'] = number_format($info['iva'],2);
|
||||
$info['total'] = number_format($info['total'],2);
|
||||
|
||||
$html .= '
|
||||
<br>
|
||||
<table width="550" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td colspan="5" align="center" bgcolor="#809829"><span class="titulo">TOTALES</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="20%"></td>
|
||||
<td width=""></td>
|
||||
<td width="16%"> </td>
|
||||
<td width="16%" valign="top">';
|
||||
|
||||
if($porcDesc > 0)
|
||||
$html .= '<b>DESCUENTO</b> <br>';
|
||||
|
||||
if($info['metodoCompra'] == 'conIva')
|
||||
$html .= '<b>SUBTOTAL</b> <br>
|
||||
<b>IVA '.$ivaPorc.'%</b> <br>';
|
||||
|
||||
$html .= '<b>TOTAL</b>';
|
||||
|
||||
|
||||
$html .= '
|
||||
</td>
|
||||
<td width="16%" align="right" valign="top">';
|
||||
|
||||
if($porcDesc > 0)
|
||||
$html .= '$'.number_format($descGlobal,2).'<br>';
|
||||
|
||||
if($info['metodoCompra'] == 'conIva')
|
||||
$html .= '$'.$info['subtotal'].'<br>
|
||||
$'.$info['iva'].'<br>';
|
||||
|
||||
$html .= '$'.$info['total'].'
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
';
|
||||
|
||||
$dompdf = new DOMPDF();
|
||||
$dompdf->set_paper('letter');
|
||||
$dompdf->load_html($html);
|
||||
$dompdf->render();
|
||||
|
||||
$dompdf->stream('acuse_recibo.pdf', array('Attachment'=>0));
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
26
modules/pedidos-agregar.php
Executable file
26
modules/pedidos-agregar.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$_SESSION['prodsPed'] = array();
|
||||
unset($_SESSION['prodsPed']);
|
||||
|
||||
$proveedores = $proveedor->EnumerateAll();
|
||||
$categorias = $prodCat->EnumerateAll();
|
||||
|
||||
$info['noPedido'] = $pedido->GetNextNoPedido();
|
||||
$info['fechaPedido'] = date('d-m-Y H:i:s');
|
||||
|
||||
$productoId = 0;
|
||||
|
||||
$smarty->assign('info', $info);
|
||||
$smarty->assign('productoId', $productoId);
|
||||
$smarty->assign('categorias', $categorias);
|
||||
$smarty->assign('proveedores', $proveedores);
|
||||
|
||||
?>
|
||||
528
modules/pedidos-detalles.php
Executable file
528
modules/pedidos-detalles.php
Executable file
@@ -0,0 +1,528 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$pedidoId = intval($_GET['id']);
|
||||
|
||||
$pedido->setPedidoId($pedidoId);
|
||||
$info = $pedido->Info();
|
||||
|
||||
$info['distComp'] = $pedido->DistCompleta();
|
||||
|
||||
$proveedor->setProveedorId($info['proveedorId']);
|
||||
$infPv = $proveedor->Info();
|
||||
|
||||
$info['proveedor'] = $infPv['nombre'];
|
||||
$info['proveedor2'] = str_replace(''', '', $infPv['nombre']);
|
||||
$info['noProv'] = $infPv['noProv'];
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fecha']));
|
||||
$hora = date('H:i:s',strtotime($info['fecha']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fecha'] = $fecha.' '.$hora;
|
||||
|
||||
$fechaEntrega = date('d-m-Y',strtotime($info['fechaEntrega']));
|
||||
$info['fechaEntrega'] = $util->FormatDateDMMMY($fechaEntrega);
|
||||
|
||||
if($info['fechaEntregaF']){
|
||||
$fechaEntregaF = date('d-m-Y',strtotime($info['fechaEntregaF']));
|
||||
$info['fechaEntregaF'] = $util->FormatDateDMMMY($fechaEntregaF);
|
||||
}
|
||||
|
||||
if($info['status'] == 'Aprobado'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaAprobacion']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaAprobacion']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fechaAprobacion'] = $fecha.' '.$hora;
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$sucursales = $util->DecodeUrlResult($resSuc);
|
||||
$sucursales = $util->DecodeResult($sucursales);
|
||||
|
||||
$usuario->setUsuarioId($info['userIdAprobacion']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
}elseif($info['status'] == 'Rechazado'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaRechazo']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaRechazo']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fechaRechazo'] = $fecha.' '.$hora;
|
||||
|
||||
$motivo->setMotivoId($info['motivoId']);
|
||||
$info['motivo'] = $motivo->GetNameById();
|
||||
|
||||
$usuario->setUsuarioId($info['userIdRechazo']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
}elseif($info['status'] == 'Distribucion'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaDistribucion']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaDistribucion']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fechaDistribucion'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($info['userIdDistribucion']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
$resProducts = $pedido->GetProdsDistribucion();
|
||||
|
||||
$dist = array();
|
||||
foreach($resProducts as $res){
|
||||
$productoId = $res['productoId'];
|
||||
$sucursalId = $res['sucursalId'];
|
||||
|
||||
$pedido->setProductoId($productoId);
|
||||
$infPP = $pedido->GetInfoProd();
|
||||
|
||||
$dist[$productoId][$sucursalId]['cantidad'] = $res['cantidad'];
|
||||
$dist[$productoId][$sucursalId]['pedDistId'] = $res['pedDistId'];
|
||||
}
|
||||
|
||||
$resSuc = $pedido->GetSucursales();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $res){
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['nombre'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$infS = $sucursal->Info();
|
||||
$res['noSuc'] = $infS['noSuc'];
|
||||
|
||||
$sucursales[] = $res;
|
||||
}
|
||||
|
||||
$smarty->assign('dist', $dist);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
}elseif($info['status'] == 'Autorizado'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaAutorizacion']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaAutorizacion']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fechaAutorizacion'] = $fecha.' '.$hora;
|
||||
|
||||
$resProducts = $pedido->GetProdsDistribucion();
|
||||
|
||||
$dist = array();
|
||||
foreach($resProducts as $res){
|
||||
$productoId = $res['productoId'];
|
||||
$sucursalId = $res['sucursalId'];
|
||||
|
||||
$pedido->setProductoId($productoId);
|
||||
$infPP = $pedido->GetInfoProd();
|
||||
|
||||
$dist[$productoId][$sucursalId]['cantidad'] = $res['cantidad'];
|
||||
$dist[$productoId][$sucursalId]['pedDistId'] = $res['pedDistId'];
|
||||
}
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$sucursales = $util->DecodeUrlResult($resSuc);
|
||||
$sucursales = $util->DecodeResult($sucursales);
|
||||
|
||||
$smarty->assign('dist', $dist);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
}elseif($info['status'] == 'Sugerencia'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaSugerencia']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaSugerencia']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fechaSugerencia'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($info['userIdSugerencia']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
$resProducts = $pedido->GetProdsDistribucion();
|
||||
|
||||
$dist = array();
|
||||
foreach($resProducts as $res){
|
||||
|
||||
$productoId = $res['productoId'];
|
||||
$sucursalId = $res['sucursalId'];
|
||||
|
||||
$pedido->setProductoId($productoId);
|
||||
$infPP = $pedido->GetInfoProd();
|
||||
|
||||
if($infPP['status'] == 'Sugerencia3'){
|
||||
|
||||
$pedido->setSucursalId($sucursalId);
|
||||
$pedido->setUsuario('Distribucion');
|
||||
$infPS = $pedido->GetInfoProdSug();
|
||||
$cantSug = $infPS['cantidad'];
|
||||
|
||||
}elseif($infPP['status'] == 'Sugerencia2'){
|
||||
|
||||
$pedido->setSucursalId($sucursalId);
|
||||
$pedido->setUsuario('Directivo');
|
||||
$infPS = $pedido->GetInfoProdSug();
|
||||
|
||||
$res['cantidad'] = $infPS['cantidad'];
|
||||
|
||||
$pedido->setUsuario('Distribucion');
|
||||
$infPS = $pedido->GetInfoProdSug();
|
||||
$cantSug = $infPS['cantidad'];
|
||||
|
||||
}elseif($infPP['status'] == 'Sugerencia' || $infPP['status'] == 'Aprobado2'){
|
||||
|
||||
$pedido->setSucursalId($sucursalId);
|
||||
$pedido->setUsuario('Directivo');
|
||||
$infPS = $pedido->GetInfoProdSug();
|
||||
$cantSug = $infPS['cantidad'];
|
||||
|
||||
}else{
|
||||
$cantSug = $res['cantidad'];
|
||||
}
|
||||
|
||||
$dist[$productoId][$sucursalId]['cantidad'] = $res['cantidad'];
|
||||
$dist[$productoId][$sucursalId]['sugerencia'] = $cantSug;
|
||||
$dist[$productoId][$sucursalId]['pedDistId'] = $res['pedDistId'];
|
||||
}
|
||||
|
||||
$resSuc = $pedido->GetSucursales();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $res){
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['nombre'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$infS = $sucursal->Info();
|
||||
$res['noSuc'] = $infS['noSuc'];
|
||||
|
||||
$sucursales[] = $res;
|
||||
}
|
||||
|
||||
|
||||
$smarty->assign('dist', $dist);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
}elseif($info['status'] == 'OrdenCompEnv'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaOrdenCompEnv']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaOrdenCompEnv']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fechaOrdenCompEnv'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($info['userIdOrdenCompEnv']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
$resProducts = $pedido->GetProdsDistribucion();
|
||||
|
||||
$dist = array();
|
||||
foreach($resProducts as $res){
|
||||
$productoId = $res['productoId'];
|
||||
$sucursalId = $res['sucursalId'];
|
||||
|
||||
$pedido->setProductoId($productoId);
|
||||
$infPP = $pedido->GetInfoProd();
|
||||
|
||||
if($infPP['status'] == 'Sugerencia'){
|
||||
$pedido->setSucursalId($sucursalId);
|
||||
$infPS = $pedido->GetInfoProdSug();
|
||||
$res['cantidad'] = $infPS['cantidad'];
|
||||
}
|
||||
|
||||
$dist[$productoId][$sucursalId]['cantidad'] = $res['cantidad'];
|
||||
$dist[$productoId][$sucursalId]['pedDistId'] = $res['pedDistId'];
|
||||
}
|
||||
|
||||
$resSuc = $pedido->GetSucursales();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $res){
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['nombre'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$infS = $sucursal->Info();
|
||||
$res['noSuc'] = $infS['noSuc'];
|
||||
|
||||
$sucursales[] = $res;
|
||||
}
|
||||
|
||||
$smarty->assign('dist', $dist);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
}elseif($info['status'] == 'OrdenCompEnvCan'){
|
||||
|
||||
$usuario->setUsuarioId($info['userIdOrdenCompEnv']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
}elseif($info['status'] == 'OrdenCompIng'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaOrdenCompIng']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaOrdenCompIng']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fechaOrdenCompIng'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($info['userIdOrdenCompIng']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
$resProducts = $pedido->GetProdsDistribucion();
|
||||
|
||||
$dist = array();
|
||||
foreach($resProducts as $res){
|
||||
$productoId = $res['productoId'];
|
||||
$sucursalId = $res['sucursalId'];
|
||||
|
||||
$pedido->setProductoId($productoId);
|
||||
$infPP = $pedido->GetInfoProd();
|
||||
|
||||
if($infPP['status'] == 'Sugerencia'){
|
||||
$pedido->setSucursalId($sucursalId);
|
||||
$infPS = $pedido->GetInfoProdSug();
|
||||
$res['cantidad'] = $infPS['cantidad'];
|
||||
}
|
||||
|
||||
$dist[$productoId][$sucursalId]['cantidad'] = $res['cantidad'];
|
||||
$dist[$productoId][$sucursalId]['prendas'] = $res['prendas'];
|
||||
$dist[$productoId][$sucursalId]['pedDistId'] = $res['pedDistId'];
|
||||
$dist[$productoId][$sucursalId]['noCajas'] = $res['cajas'];
|
||||
}
|
||||
|
||||
$resSuc = $pedido->GetSucursales();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $res){
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['nombre'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$infS = $sucursal->Info();
|
||||
$res['noSuc'] = $infS['noSuc'];
|
||||
|
||||
$sucursales[] = $res;
|
||||
}
|
||||
|
||||
|
||||
$smarty->assign('dist', $dist);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
}elseif($info['status'] == 'EnvSuc'){
|
||||
|
||||
$resProducts = $pedido->GetProdsDistribucion();
|
||||
|
||||
$dist = array();
|
||||
foreach($resProducts as $res){
|
||||
$productoId = $res['productoId'];
|
||||
$sucursalId = $res['sucursalId'];
|
||||
|
||||
$pedido->setProductoId($productoId);
|
||||
$infPP = $pedido->GetInfoProd();
|
||||
|
||||
if($infPP['status'] == 'Sugerencia'){
|
||||
$pedido->setSucursalId($sucursalId);
|
||||
$infPS = $pedido->GetInfoProdSug();
|
||||
$res['cantidad'] = $infPS['cantidad'];
|
||||
}
|
||||
|
||||
$dist[$productoId][$sucursalId]['cantidad'] = $res['cantidad'];
|
||||
$dist[$productoId][$sucursalId]['pedDistId'] = $res['pedDistId'];
|
||||
}
|
||||
|
||||
$resSuc = $pedido->GetSucursales();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $res){
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['nombre'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$infS = $sucursal->Info();
|
||||
$res['noSuc'] = $infS['noSuc'];
|
||||
|
||||
$sucursales[] = $res;
|
||||
}
|
||||
|
||||
$smarty->assign('dist', $dist);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
}else{
|
||||
|
||||
$usuario->setUsuarioId($info['usuarioId']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
}//elseif
|
||||
|
||||
if($info['metodoCompra'] == "sinIva")
|
||||
$info['metodoCompra'] = 'IVA No Incluido';
|
||||
else
|
||||
$info['metodoCompra'] = 'IVA Incluido';
|
||||
|
||||
$resProducts = $pedido->GetProductos();
|
||||
|
||||
$products = array();
|
||||
$products2 = array();
|
||||
|
||||
$sugerencias = 0;
|
||||
$subtotalP = 0;
|
||||
$totalPzas = 0;
|
||||
foreach($resProducts as $card){
|
||||
|
||||
$prodCatId = $card['prodCatId'];
|
||||
$prodSubcatId = $card['prodSubcatId'];
|
||||
$productoId = $card['productoId'];
|
||||
|
||||
$card['productoId'] = $productoId;
|
||||
$card['prodCatId'] = $prodCatId;
|
||||
$card['prodSubcatId'] = $prodSubcatId;
|
||||
|
||||
$prodCat->setProdCatId($prodCatId);
|
||||
$card['departamento'] = $prodCat->GetNameById();
|
||||
|
||||
$prodSubcat->setProdSubcatId($prodSubcatId);
|
||||
$card['linea'] = $prodSubcat->GetNameById();
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$infP = $producto->Info();
|
||||
$card['modelo'] = strtoupper($infP['modelo']);
|
||||
$card['imagen'] = $infP['imagen'];
|
||||
$card['codigoBarra'] = $infP['codigoBarra'];
|
||||
|
||||
$card['atributos'] = $producto->GetAtributosAll();
|
||||
|
||||
$card['cantidad'] = $card['totalLote'] * $card['cantLotes'];
|
||||
$totalP = $card['costo'] * $card['cantidad'];
|
||||
$card['total'] = number_format($totalP,2);
|
||||
|
||||
$totalPzas += $card['cantidad'];
|
||||
$subtotalP += $totalP;
|
||||
|
||||
if($info['status'] == 'OrdenCompIng' || $info['status'] == 'EnvSuc'){
|
||||
$card['cantidad'] = ($card['prendasComp'] == 1) ? $card['cantPrendas'] : $card['prendasRec'];
|
||||
$totalP = $card['costo'] * $card['cantidad'];
|
||||
$card['total'] = number_format($totalP,2);
|
||||
}
|
||||
|
||||
//PROPORCIONES
|
||||
|
||||
//Colores
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$resColores = $producto->GetColores();
|
||||
|
||||
$colores = array();
|
||||
foreach($resColores as $res){
|
||||
|
||||
$colorId = $res['colorId'];
|
||||
|
||||
$pedido->setColorId($colorId);
|
||||
$pedido->setProductoId($productoId);
|
||||
$cantidad = $pedido->GetProporcionByColor();
|
||||
|
||||
$proporcionC[$colorId] = $cantidad;
|
||||
|
||||
$res['cantidad'] = $cantidad;
|
||||
|
||||
$atribVal->setAtribValId($res['colorId']);
|
||||
$res['nombre'] = $atribVal->GetNameById();
|
||||
|
||||
$colores[$colorId] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
//Tallas
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$resTallas = $producto->GetTallas();
|
||||
|
||||
$tallas = array();
|
||||
foreach($resTallas as $res){
|
||||
|
||||
$tallaId = $res['tallaId'];
|
||||
|
||||
$pedido->setTallaId($tallaId);
|
||||
$pedido->setProductoId($productoId);
|
||||
$cantidad = $pedido->GetProporcionByTalla();
|
||||
|
||||
$proporcionT[$tallaId] = $cantidad;
|
||||
|
||||
$res['cantidad'] = $cantidad;
|
||||
|
||||
$atribVal->setAtribValId($tallaId);
|
||||
$res['nombre'] = $atribVal->GetNameById();
|
||||
|
||||
$tallas[$tallaId] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
//Obtenemos Totales
|
||||
|
||||
$totales = array();
|
||||
$subtotales = array();
|
||||
foreach($tallas as $idT => $t){
|
||||
|
||||
$cantT = $t['cantidad'];
|
||||
|
||||
$total = 0;
|
||||
foreach($colores as $idC => $c){
|
||||
|
||||
$cantC = $c['cantidad'];
|
||||
|
||||
$subtotal = $cantC * $cantT;
|
||||
$total += $subtotal;
|
||||
|
||||
$subtotales[$idT][$idC] = $subtotal;
|
||||
}
|
||||
|
||||
$totales[$idT] = $total;
|
||||
|
||||
}//foreach
|
||||
|
||||
$card['tallas'] = $tallas;
|
||||
$card['colores'] = $colores;
|
||||
$card['totales'] = $totales;
|
||||
$card['subtotales'] = $subtotales;
|
||||
$card['proporcionT'] = $proporcionT;
|
||||
$card['proporcionC'] = $proporcionC;
|
||||
|
||||
$card['costo'] = number_format($card['costo'],2);
|
||||
$card['precioVenta'] = number_format($card['precioVenta'],2);
|
||||
|
||||
//FIN PROPORCIONES
|
||||
|
||||
if($card['status'] == 'Sugerencia')
|
||||
$sugerencias++;
|
||||
|
||||
$products[] = $card;
|
||||
|
||||
}//foreach
|
||||
|
||||
if($info['subtotal2'] > 0){
|
||||
$info['subtotal'] = $info['subtotal2'];
|
||||
$info['iva'] = $info['iva2'];
|
||||
$info['total'] = $info['total2'];
|
||||
}
|
||||
|
||||
$info['subtotal'] = number_format($info['subtotal'],2);
|
||||
$info['iva'] = number_format($info['iva'],2);
|
||||
$info['total'] = number_format($info['total'],2);
|
||||
|
||||
$info['totalPzas'] = $totalPzas;
|
||||
|
||||
$info['view'] = 1;
|
||||
$info['sugerencias'] = $sugerencias;
|
||||
|
||||
//Obtenemos las Dist. de Cajas por Sucursal
|
||||
$pedido->setPedidoId($pedidoId);
|
||||
$resSucCajas = $pedido->EnumSucCajas();
|
||||
|
||||
$sucCajas = array();
|
||||
foreach($resSucCajas as $res){
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$infS = $sucursal->Info();
|
||||
$res['noSuc'] = $infS['noSuc'];
|
||||
$sucCajas[] = $res;
|
||||
}
|
||||
|
||||
$smarty->assign('info', $info);
|
||||
$smarty->assign('sucCajas', $sucCajas);
|
||||
$smarty->assign('pedidoId', $pedidoId);
|
||||
$smarty->assign('products', $products);
|
||||
|
||||
?>
|
||||
355
modules/pedidos-distribucion.php
Executable file
355
modules/pedidos-distribucion.php
Executable file
@@ -0,0 +1,355 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$pedidoId = intval($_GET['id']);
|
||||
|
||||
$pedido->setPedidoId($pedidoId);
|
||||
$info = $pedido->Info();
|
||||
|
||||
$proveedor->setProveedorId($info['proveedorId']);
|
||||
$infPv = $proveedor->Info();
|
||||
|
||||
$info['proveedor'] = $infPv['nombre'];
|
||||
$info['noProv'] = $infPv['noProv'];
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fecha']));
|
||||
$hora = date('H:i:s',strtotime($info['fecha']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fecha'] = $fecha.' '.$hora;
|
||||
|
||||
$fechaEntrega = date('d-m-Y',strtotime($info['fechaEntrega']));
|
||||
$info['fechaEntrega'] = $util->FormatDateDMMMY($fechaEntrega);
|
||||
|
||||
if($info['fechaEntregaF']){
|
||||
$fechaEntregaF = date('d-m-Y',strtotime($info['fechaEntregaF']));
|
||||
$info['fechaEntregaF'] = $util->FormatDateDMMMY($fechaEntregaF);
|
||||
}
|
||||
|
||||
if($info['status'] == 'Autorizado'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaAutorizacion']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaAutorizacion']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fechaAutorizacion'] = $fecha.' '.$hora;
|
||||
|
||||
$resProducts = $pedido->GetProdsDistribucion();
|
||||
|
||||
$dist = array();
|
||||
foreach($resProducts as $res){
|
||||
$productoId = $res['productoId'];
|
||||
$sucursalId = $res['sucursalId'];
|
||||
|
||||
$pedido->setProductoId($productoId);
|
||||
$infPP = $pedido->GetInfoProd();
|
||||
|
||||
$dist[$productoId][$sucursalId]['cantidad'] = $res['cantidad'];
|
||||
$dist[$productoId][$sucursalId]['pedDistId'] = $res['pedDistId'];
|
||||
}
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$sucursales = $util->DecodeUrlResult($resSuc);
|
||||
$sucursales = $util->DecodeResult($sucursales);
|
||||
|
||||
$smarty->assign('dist', $dist);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
}elseif($info['status'] == 'Sugerencia'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaSugerencia']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaSugerencia']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fechaSugerencia'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($info['userIdSugerencia']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
$resProducts = $pedido->GetProdsDistribucion();
|
||||
|
||||
$dist = array();
|
||||
foreach($resProducts as $res){
|
||||
|
||||
$productoId = $res['productoId'];
|
||||
$sucursalId = $res['sucursalId'];
|
||||
|
||||
$pedido->setProductoId($productoId);
|
||||
$infPP = $pedido->GetInfoProd();
|
||||
|
||||
if($infPP['status'] == 'Sugerencia3'){
|
||||
|
||||
$pedido->setSucursalId($sucursalId);
|
||||
$pedido->setUsuario('Distribucion');
|
||||
$infPS = $pedido->GetInfoProdSug();
|
||||
$cantSug = $infPS['cantidad'];
|
||||
|
||||
}elseif($infPP['status'] == 'Sugerencia2'){
|
||||
|
||||
$pedido->setSucursalId($sucursalId);
|
||||
$pedido->setUsuario('Directivo');
|
||||
$infPS = $pedido->GetInfoProdSug();
|
||||
|
||||
$res['cantidad'] = $infPS['cantidad'];
|
||||
|
||||
$pedido->setUsuario('Distribucion');
|
||||
$infPS = $pedido->GetInfoProdSug();
|
||||
$cantSug = $infPS['cantidad'];
|
||||
|
||||
}elseif($infPP['status'] == 'Sugerencia' || $infPP['status'] == 'Aprobado2'){
|
||||
|
||||
$pedido->setSucursalId($sucursalId);
|
||||
$pedido->setUsuario('Directivo');
|
||||
$infPS = $pedido->GetInfoProdSug();
|
||||
$cantSug = $infPS['cantidad'];
|
||||
|
||||
}else{
|
||||
$cantSug = $res['cantidad'];
|
||||
}
|
||||
|
||||
$dist[$productoId][$sucursalId]['cantidad'] = $res['cantidad'];
|
||||
$dist[$productoId][$sucursalId]['sugerencia'] = $cantSug;
|
||||
$dist[$productoId][$sucursalId]['pedDistId'] = $res['pedDistId'];
|
||||
}
|
||||
|
||||
$resSuc = $pedido->GetSucursales();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $res){
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['nombre'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$infS = $sucursal->Info();
|
||||
$res['noSuc'] = $infS['noSuc'];
|
||||
|
||||
$sucursales[] = $res;
|
||||
}
|
||||
|
||||
|
||||
$smarty->assign('dist', $dist);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
}elseif($info['status'] == 'OrdenCompEnv'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaOrdenCompEnv']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaOrdenCompEnv']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fechaOrdenCompEnv'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($info['userIdOrdenCompEnv']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
$resProducts = $pedido->GetProdsDistribucion();
|
||||
|
||||
$dist = array();
|
||||
foreach($resProducts as $res){
|
||||
$productoId = $res['productoId'];
|
||||
$sucursalId = $res['sucursalId'];
|
||||
|
||||
$pedido->setProductoId($productoId);
|
||||
$infPP = $pedido->GetInfoProd();
|
||||
|
||||
if($infPP['status'] == 'Sugerencia'){
|
||||
$pedido->setSucursalId($sucursalId);
|
||||
$infPS = $pedido->GetInfoProdSug();
|
||||
$res['cantidad'] = $infPS['cantidad'];
|
||||
}
|
||||
|
||||
$dist[$productoId][$sucursalId]['cantidad'] = $res['cantidad'];
|
||||
$dist[$productoId][$sucursalId]['pedDistId'] = $res['pedDistId'];
|
||||
}
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$sucursales = $util->DecodeUrlResult($resSuc);
|
||||
$sucursales = $util->DecodeResult($sucursales);
|
||||
|
||||
$smarty->assign('dist', $dist);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
}elseif($info['status'] == 'OrdenCompEnvCan'){
|
||||
|
||||
$usuario->setUsuarioId($info['userIdOrdenCompEnv']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
}elseif($info['status'] == 'OrdenCompIng'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaOrdenCompIng']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaOrdenCompIng']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fechaOrdenCompIng'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($info['userIdOrdenCompIng']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
$resProducts = $pedido->GetProdsDistribucion();
|
||||
|
||||
$dist = array();
|
||||
foreach($resProducts as $res){
|
||||
$productoId = $res['productoId'];
|
||||
$sucursalId = $res['sucursalId'];
|
||||
|
||||
$pedido->setProductoId($productoId);
|
||||
$infPP = $pedido->GetInfoProd();
|
||||
|
||||
if($infPP['status'] == 'Sugerencia'){
|
||||
$pedido->setSucursalId($sucursalId);
|
||||
$infPS = $pedido->GetInfoProdSug();
|
||||
$res['cantidad'] = $infPS['cantidad'];
|
||||
}
|
||||
|
||||
$dist[$productoId][$sucursalId]['cantidad'] = $res['cantidad'];
|
||||
$dist[$productoId][$sucursalId]['prendas'] = $res['prendas'];
|
||||
$dist[$productoId][$sucursalId]['pedDistId'] = $res['pedDistId'];
|
||||
$dist[$productoId][$sucursalId]['noCajas'] = $res['cajas'];
|
||||
}
|
||||
|
||||
$resSuc = $pedido->GetSucursales();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $res){
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['nombre'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$infS = $sucursal->Info();
|
||||
$res['noSuc'] = $infS['noSuc'];
|
||||
|
||||
$sucursales[] = $res;
|
||||
}
|
||||
|
||||
|
||||
$smarty->assign('dist', $dist);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
}elseif($info['status'] == 'EnvSuc'){
|
||||
|
||||
$resProducts = $pedido->GetProdsDistribucion();
|
||||
|
||||
$dist = array();
|
||||
foreach($resProducts as $res){
|
||||
$productoId = $res['productoId'];
|
||||
$sucursalId = $res['sucursalId'];
|
||||
|
||||
$pedido->setProductoId($productoId);
|
||||
$infPP = $pedido->GetInfoProd();
|
||||
|
||||
if($infPP['status'] == 'Sugerencia'){
|
||||
$pedido->setSucursalId($sucursalId);
|
||||
$infPS = $pedido->GetInfoProdSug();
|
||||
$res['cantidad'] = $infPS['cantidad'];
|
||||
}
|
||||
|
||||
$dist[$productoId][$sucursalId]['cantidad'] = $res['cantidad'];
|
||||
$dist[$productoId][$sucursalId]['pedDistId'] = $res['pedDistId'];
|
||||
}
|
||||
|
||||
$resSuc = $pedido->GetSucursales();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $res){
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['nombre'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$infS = $sucursal->Info();
|
||||
$res['noSuc'] = $infS['noSuc'];
|
||||
|
||||
$sucursales[] = $res;
|
||||
}
|
||||
|
||||
$smarty->assign('dist', $dist);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
}else{
|
||||
|
||||
$usuario->setUsuarioId($info['usuarioId']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
}//elseif
|
||||
|
||||
if($info['metodoCompra'] == "sinIva")
|
||||
$info['metodoCompra'] = 'IVA No Incluido';
|
||||
else
|
||||
$info['metodoCompra'] = 'IVA Incluido';
|
||||
|
||||
$resProducts = $pedido->GetProductos();
|
||||
|
||||
$products = array();
|
||||
$products2 = array();
|
||||
|
||||
$sugerencias = 0;
|
||||
$subtotalP = 0;
|
||||
$totalPzas = 0;
|
||||
foreach($resProducts as $card){
|
||||
|
||||
$prodCatId = $card['prodCatId'];
|
||||
$prodSubcatId = $card['prodSubcatId'];
|
||||
$productoId = $card['productoId'];
|
||||
|
||||
$card['productoId'] = $productoId;
|
||||
$card['prodCatId'] = $prodCatId;
|
||||
$card['prodSubcatId'] = $prodSubcatId;
|
||||
|
||||
$prodCat->setProdCatId($prodCatId);
|
||||
$card['departamento'] = $prodCat->GetNameById();
|
||||
|
||||
$prodSubcat->setProdSubcatId($prodSubcatId);
|
||||
$card['linea'] = $prodSubcat->GetNameById();
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$infP = $producto->Info();
|
||||
$card['modelo'] = strtoupper($infP['modelo']);
|
||||
$card['imagen'] = $infP['imagen'];
|
||||
$card['codigoBarra'] = $infP['codigoBarra'];
|
||||
|
||||
$card['atributos'] = $producto->GetAtributosAll();
|
||||
|
||||
$card['cantidad'] = $card['totalLote'] * $card['cantLotes'];
|
||||
$totalP = $card['costo'] * $card['cantidad'];
|
||||
$card['total'] = number_format($totalP,2);
|
||||
|
||||
$totalPzas += $card['cantidad'];
|
||||
$subtotalP += $totalP;
|
||||
|
||||
if($info['status'] == 'OrdenCompIng' || $info['status'] == 'EnvSuc'){
|
||||
$card['cantidad'] = ($card['prendasComp'] == 1) ? $card['cantPrendas'] : $card['prendasRec'];
|
||||
$totalP = $card['costo'] * $card['cantidad'];
|
||||
$card['total'] = number_format($totalP,2);
|
||||
}
|
||||
|
||||
$card['costo'] = number_format($card['costo'],2);
|
||||
$card['precioVenta'] = number_format($card['precioVenta'],2);
|
||||
|
||||
if($card['status'] == 'Sugerencia')
|
||||
$sugerencias++;
|
||||
|
||||
$pedido->setPedidoId($pedidoId);
|
||||
$pedido->setProductoId($productoId);
|
||||
$totalDist = $pedido->GetTotalDistByProd();
|
||||
$card['prendasFaltantes'] = $card['cantPrendas'] - $totalDist;
|
||||
|
||||
$products[] = $card;
|
||||
|
||||
}//foreach
|
||||
|
||||
if($info['subtotal2'] > 0){
|
||||
$info['subtotal'] = $info['subtotal2'];
|
||||
$info['iva'] = $info['iva2'];
|
||||
$info['total'] = $info['total2'];
|
||||
}
|
||||
|
||||
$info['subtotal'] = number_format($info['subtotal'],2);
|
||||
$info['iva'] = number_format($info['iva'],2);
|
||||
$info['total'] = number_format($info['total'],2);
|
||||
|
||||
$info['totalPzas'] = $totalPzas;
|
||||
|
||||
$info['view'] = 1;
|
||||
$info['sugerencias'] = $sugerencias;
|
||||
|
||||
$smarty->assign('info', $info);
|
||||
$smarty->assign('pedidoId', $pedidoId);
|
||||
$smarty->assign('products', $products);
|
||||
|
||||
?>
|
||||
160
modules/pedidos-editar.php
Executable file
160
modules/pedidos-editar.php
Executable file
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$pedidoId = intval($_GET['id']);
|
||||
|
||||
$_SESSION['prodsEdit'] = array();
|
||||
unset($_SESSION['prodsEdit']);
|
||||
|
||||
$_SESSION['prodsDel'] = array();
|
||||
unset($_SESSION['prodsDel']);
|
||||
|
||||
$pedido->setPedidoId($pedidoId);
|
||||
$info = $pedido->Info();
|
||||
|
||||
$proveedor->setProveedorId($info['proveedorId']);
|
||||
$infPv = $proveedor->Info();
|
||||
|
||||
$info['proveedor'] = $infPv['nombre'];
|
||||
$info['noProv'] = $infPv['noProv'];
|
||||
|
||||
$info['fechaEntrega'] = date('d-m-Y',strtotime($info['fechaEntrega']));
|
||||
$info['fechaEntregaF'] = date('d-m-Y',strtotime($info['fechaEntregaF']));
|
||||
$info['fecha'] = date('d-m-Y H:i:s',strtotime($info['fecha']));
|
||||
|
||||
if($info['status'] != 'OrdenCompIng'){
|
||||
|
||||
$resProducts = $pedido->GetProductos();
|
||||
|
||||
$products = array();
|
||||
$products2 = array();
|
||||
foreach($resProducts as $card){
|
||||
|
||||
$prodCatId = $card['prodCatId'];
|
||||
$prodSubcatId = $card['prodSubcatId'];
|
||||
$productoId = $card['productoId'];
|
||||
|
||||
$prodCat->setProdCatId($prodCatId);
|
||||
$card['departamento'] = $prodCat->GetNameById();
|
||||
|
||||
$prodSubcat->setProdSubcatId($prodSubcatId);
|
||||
$card['linea'] = $prodSubcat->GetNameById();
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$infP = $producto->Info();
|
||||
$card['modelo'] = $infP['modelo'];
|
||||
$card['codigoBarra'] = $infP['codigoBarra'];
|
||||
$card['atributos'] = $producto->GetAtributosAll();
|
||||
|
||||
//PROPORCIONES
|
||||
|
||||
//Colores
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$resColores = $producto->GetColores();
|
||||
|
||||
$colores = array();
|
||||
foreach($resColores as $res){
|
||||
|
||||
$colorId = $res['colorId'];
|
||||
|
||||
$pedido->setColorId($colorId);
|
||||
$pedido->setProductoId($productoId);
|
||||
$cantidad = $pedido->GetProporcionByColor();
|
||||
|
||||
$proporcionC[$colorId] = $cantidad;
|
||||
|
||||
$res['cantidad'] = $cantidad;
|
||||
|
||||
$atribVal->setAtribValId($res['colorId']);
|
||||
$res['nombre'] = $atribVal->GetNameById();
|
||||
|
||||
$colores[$colorId] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
//Tallas
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$resTallas = $producto->GetTallas();
|
||||
|
||||
$tallas = array();
|
||||
foreach($resTallas as $res){
|
||||
|
||||
$tallaId = $res['tallaId'];
|
||||
|
||||
$pedido->setTallaId($tallaId);
|
||||
$pedido->setProductoId($productoId);
|
||||
$cantidad = $pedido->GetProporcionByTalla();
|
||||
|
||||
$proporcionT[$tallaId] = $cantidad;
|
||||
|
||||
$res['cantidad'] = $cantidad;
|
||||
|
||||
$atribVal->setAtribValId($tallaId);
|
||||
$res['nombre'] = $atribVal->GetNameById();
|
||||
|
||||
$tallas[$tallaId] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
//Obtenemos Totales
|
||||
|
||||
$totales = array();
|
||||
$subtotales = array();
|
||||
foreach($tallas as $idT => $t){
|
||||
|
||||
$cantT = $t['cantidad'];
|
||||
|
||||
$total = 0;
|
||||
foreach($colores as $idC => $c){
|
||||
|
||||
$cantC = $c['cantidad'];
|
||||
|
||||
$subtotal = $cantC * $cantT;
|
||||
$total += $subtotal;
|
||||
|
||||
$subtotales[$idT][$idC] = $subtotal;
|
||||
}
|
||||
|
||||
$totales[$idT] = $total;
|
||||
|
||||
}//foreach
|
||||
|
||||
$card['tallas'] = $tallas;
|
||||
$card['colores'] = $colores;
|
||||
$card['totales'] = $totales;
|
||||
$card['subtotales'] = $subtotales;
|
||||
$card['proporcionT'] = $proporcionT;
|
||||
$card['proporcionC'] = $proporcionC;
|
||||
|
||||
//FIN PROPORCIONES
|
||||
|
||||
$card['departamento'] = utf8_encode($card['departamento']);
|
||||
$card['linea'] = utf8_encode($card['linea']);
|
||||
$card['tallas'] = $util->EncodeResult($tallas);
|
||||
$card['colores'] = $util->EncodeResult($colores);
|
||||
|
||||
$products[] = $card;
|
||||
|
||||
}//foreach
|
||||
|
||||
$_SESSION['prodsEdit'] = $products;
|
||||
|
||||
$proveedores = $proveedor->EnumerateAll();
|
||||
$categorias = $prodCat->EnumerateAll();
|
||||
|
||||
}//if
|
||||
|
||||
$smarty->assign('info', $info);
|
||||
$smarty->assign('products', $products);
|
||||
$smarty->assign('categorias', $categorias);
|
||||
$smarty->assign('proveedores', $proveedores);
|
||||
|
||||
?>
|
||||
93
modules/pedidos-enviar-pendientes.php
Executable file
93
modules/pedidos-enviar-pendientes.php
Executable file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
require_once('../config.php');
|
||||
include_once(DOC_ROOT.'/libraries.php');
|
||||
|
||||
/*
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
|
||||
$pedidos = $pedido->Enumerate();
|
||||
|
||||
$items = array();
|
||||
foreach($pedidos['items'] as $res){
|
||||
|
||||
$pedido->setPedidoId($res['pedidoId']);
|
||||
$productos = $pedido->GetProductos();
|
||||
|
||||
$costoCompra = 0;
|
||||
$precioVenta = 0;
|
||||
foreach($productos as $val){
|
||||
$totalProds = $val['totalLote'] * $val['cantLotes'];
|
||||
|
||||
//$costoCompra += $val['costo'] * $totalProds;
|
||||
$precioVenta += $val['precioVenta'] * $totalProds;
|
||||
}
|
||||
|
||||
$costoCompra = $res['total'];
|
||||
|
||||
$res['costoCompra'] = number_format($costoCompra,2,'.',',');
|
||||
$res['precioVenta'] = number_format($precioVenta,2,'.',',');
|
||||
|
||||
//Obtenemos el Porcentaje de Utilidad
|
||||
$utilidad = $precioVenta - $costoCompra;
|
||||
|
||||
if($costoCompra > 0){
|
||||
$porcUtilidad = ($utilidad * 100) / $costoCompra;
|
||||
$res['utilidad'] = number_format($porcUtilidad,2,'.',',');
|
||||
}else{
|
||||
$res['utilidad'] = 0;
|
||||
}
|
||||
|
||||
$proveedor->setProveedorId($res['proveedorId']);
|
||||
$res['proveedor'] = $proveedor->GetNameById();
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($res['fecha']));
|
||||
$hora = date('H:i:s',strtotime($res['fecha']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$res['fecha'] = $fecha.' '.$hora;
|
||||
|
||||
$fechaEntrega = date('d-m-Y',strtotime($res['fechaEntrega']));
|
||||
$res['fechaEntrega'] = $util->FormatDateDMMMY($fechaEntrega);
|
||||
|
||||
if($res['fechaEntregaF']){
|
||||
$fechaEntregaF = date('d-m-Y',strtotime($res['fechaEntregaF']));
|
||||
$res['fechaEntregaF'] = $util->FormatDateDMMMY($fechaEntregaF);
|
||||
}
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
|
||||
$html = '<html>';
|
||||
$html .= '<body>
|
||||
Hola
|
||||
</body>';
|
||||
$html = '</html>';
|
||||
|
||||
$email = 'diego@avantika.com.mx';
|
||||
|
||||
try {
|
||||
$_mail->AddAddress($email, 'Directivo');
|
||||
$_mail->SetFrom('contacto@novomoda.com', 'Novomoda');
|
||||
$_mail->Subject = 'Listao de Ordenes de Compra Pendientes de Aprobacion';
|
||||
$_mail->MsgHTML($html);
|
||||
$_mail->Send();
|
||||
|
||||
$emailSent = 1;
|
||||
|
||||
} catch (phpmailerException $e) {
|
||||
$emailSent = 2;
|
||||
} catch (Exception $e) {
|
||||
$emailSent = 2;
|
||||
}
|
||||
|
||||
echo 'Done';
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
607
modules/pedidos-enviar-prov.php
Executable file
607
modules/pedidos-enviar-prov.php
Executable file
@@ -0,0 +1,607 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
include_once(DOC_ROOT.'/pdf/dompdf_config.inc.php');
|
||||
|
||||
if(isset($_GET['cancelarId'])){
|
||||
$pedidoId = intval($_GET['cancelarId']);
|
||||
$mode = 'cancelar';
|
||||
}elseif(isset($_GET['show-pdf'])){
|
||||
$pedidoId = intval($_GET['show-pdf']);
|
||||
$mode = 'show';
|
||||
}elseif(isset($_GET['id'])){
|
||||
$pedidoId = intval($_GET['id']);
|
||||
$mode = 'send';
|
||||
}else{
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
if(WEB_ROOT == 'http://novomoda.ddns.net/html')
|
||||
$enProduccion = false;
|
||||
else
|
||||
$enProduccion = true;
|
||||
|
||||
$pedido->setPedidoId($pedidoId);
|
||||
$info = $pedido->Info();
|
||||
|
||||
$rfc->setRfcId(1);
|
||||
$infE = $util->EncodeRow($rfc->Info());
|
||||
|
||||
$direccion = $infE['calle'];
|
||||
|
||||
if($infE['noExt'] != '')
|
||||
$direccion .= ' No. Ext. '.$infE['noExt'];
|
||||
if($infE['noInt'] != '')
|
||||
$direccion .= ', No. Int. '.$infE['noInt'];
|
||||
if($infE['colonia'] != '')
|
||||
$direccion .= ', Col. '.$infE['colonia'];
|
||||
if($infE['localidad'] != '')
|
||||
$direccion .= ', '.$infE['localidad'];
|
||||
if($infE['ciudad'] != '')
|
||||
$direccion .= ', '.$infE['ciudad'];
|
||||
if($infE['municipio'] != '')
|
||||
$direccion .= ', '.$infE['municipio'];
|
||||
if($infE['estado'] != '')
|
||||
$direccion .= ', '.$infE['estado'];
|
||||
if($infE['codigoPostal'] != '')
|
||||
$direccion .= 'C.P. '.$infE['codigoPostal'];
|
||||
|
||||
$infE['direccion'] = $direccion;
|
||||
|
||||
$proveedor->setProveedorId($info['proveedorId']);
|
||||
$infPv = $util->EncodeRow($proveedor->Info());
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fecha']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fecha'] = $fecha;
|
||||
|
||||
$fechaEntrega = date('d-m-Y',strtotime($info['fechaEntrega']));
|
||||
$info['fechaEntrega'] = $util->FormatDateDMMMY($fechaEntrega);
|
||||
|
||||
if($info['fechaEntregaF']){
|
||||
$fechaEntregaF = date('d-m-Y',strtotime($info['fechaEntregaF']));
|
||||
$info['fechaEntrega'] .= ' al '.$util->FormatDateDMMMY($fechaEntregaF);
|
||||
}
|
||||
|
||||
if($info['metodoCompra'] == 'conIva')
|
||||
$info['metodoCompra'] = 'IVA Incluido';
|
||||
else
|
||||
$info['metodoCompra'] = 'IVA No Incluido';
|
||||
|
||||
//Distribuciones
|
||||
|
||||
$resProducts = $pedido->GetProdsDistribucion();
|
||||
|
||||
$dist = array();
|
||||
$sucIds = array();
|
||||
foreach($resProducts as $res){
|
||||
$productoId = $res['productoId'];
|
||||
$sucursalId = $res['sucursalId'];
|
||||
|
||||
$pedido->setProductoId($productoId);
|
||||
$infPP['status'] = $pedido->GetInfoStatusProd();
|
||||
|
||||
if($infPP['status'] == 'Sugerencia'){
|
||||
$pedido->setSucursalId($sucursalId);
|
||||
$infPS['cantidad'] = $pedido->GetInfoCantProdSug();
|
||||
$res['cantidad'] = $infPS['cantidad'];
|
||||
}
|
||||
|
||||
if($res['cantidad'] == 0)
|
||||
continue;
|
||||
|
||||
$dist[$productoId][$sucursalId]['cantidad'] = $res['cantidad'];
|
||||
$dist[$productoId][$sucursalId]['pedDistId'] = $res['pedDistId'];
|
||||
|
||||
if(!in_array($sucursalId, $sucIds))
|
||||
$sucIds[] = $sucursalId;
|
||||
}
|
||||
|
||||
//Sucursales
|
||||
|
||||
$sucursals = array();
|
||||
$tiendas = array();
|
||||
foreach($sucIds as $sucursalId){
|
||||
|
||||
$res['sucursalId'] = $sucursalId;
|
||||
|
||||
$sucursal->setSucursalId($sucursalId);
|
||||
$infS = $sucursal->Info();
|
||||
|
||||
$res['noSuc'] = $infS['noSuc'];
|
||||
|
||||
$tiendas[] = $res;
|
||||
}
|
||||
|
||||
if(count($tiendas) > 0){
|
||||
$tiendas = $util->orderMultiDimensionalArray($tiendas, 'noSuc');
|
||||
$sucursals[] = $tiendas;
|
||||
}
|
||||
|
||||
//Productos
|
||||
|
||||
$resProducts = $pedido->GetProductos();
|
||||
|
||||
$sugerencias = 0;
|
||||
$subtotalP = 0;
|
||||
$products = array();
|
||||
foreach($resProducts as $card){
|
||||
|
||||
$prodCatId = $card['prodCatId'];
|
||||
$prodSubcatId = $card['prodSubcatId'];
|
||||
$productoId = $card['productoId'];
|
||||
|
||||
$card['productoId'] = $productoId;
|
||||
$card['prodCatId'] = $prodCatId;
|
||||
$card['prodSubcatId'] = $prodSubcatId;
|
||||
|
||||
$prodCat->setProdCatId($prodCatId);
|
||||
$card['departamento'] = $prodCat->GetNameById();
|
||||
|
||||
$prodSubcat->setProdSubcatId($prodSubcatId);
|
||||
$card['linea'] = $prodSubcat->GetNameById();
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$infP = $producto->Info();
|
||||
$card['modelo'] = $infP['modelo'].' '.$infP['descripcion'];
|
||||
$card['imagen'] = $infP['imagen'];
|
||||
$card['codigoBarra'] = $infP['codigoBarra'];
|
||||
$card['precioVentaIva'] = $infP['precioVentaIva'];
|
||||
|
||||
$card['atributos'] = $producto->GetAtributosAll();
|
||||
|
||||
$card['cantidad'] = $card['totalLote'] * $card['cantLotes'];
|
||||
$totalP = $card['costo'] * $card['cantidad'];
|
||||
$card['total'] = number_format($totalP,2);
|
||||
|
||||
$subtotalP += $totalP;
|
||||
|
||||
//PROPORCIONES
|
||||
|
||||
//Colores
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$resColores = $producto->GetColores();
|
||||
|
||||
$colores = array();
|
||||
foreach($resColores as $res){
|
||||
|
||||
$colorId = $res['colorId'];
|
||||
|
||||
$pedido->setColorId($colorId);
|
||||
$pedido->setProductoId($productoId);
|
||||
$cantidad = $pedido->GetProporcionByColor();
|
||||
|
||||
$proporcionC[$colorId] = $cantidad;
|
||||
|
||||
$res['cantidad'] = $cantidad;
|
||||
|
||||
$atribVal->setAtribValId($res['colorId']);
|
||||
$res['nombre'] = $atribVal->GetNameById();
|
||||
|
||||
$colores[$colorId] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
//Tallas
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$resTallas = $producto->GetTallas();
|
||||
|
||||
$tallas = array();
|
||||
foreach($resTallas as $res){
|
||||
|
||||
$tallaId = $res['tallaId'];
|
||||
|
||||
$pedido->setTallaId($tallaId);
|
||||
$pedido->setProductoId($productoId);
|
||||
$cantidad = $pedido->GetProporcionByTalla();
|
||||
|
||||
$proporcionT[$tallaId] = $cantidad;
|
||||
|
||||
$res['cantidad'] = $cantidad;
|
||||
|
||||
$atribVal->setAtribValId($tallaId);
|
||||
$res['nombre'] = $atribVal->GetNameById();
|
||||
|
||||
$tallas[$tallaId] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
//Obtenemos Totales
|
||||
|
||||
$totales = array();
|
||||
$subtotales = array();
|
||||
foreach($tallas as $idT => $t){
|
||||
|
||||
$cantT = $t['cantidad'];
|
||||
|
||||
$total = 0;
|
||||
foreach($colores as $idC => $c){
|
||||
|
||||
$cantC = $c['cantidad'];
|
||||
|
||||
$subtotal = $cantC * $cantT;
|
||||
$total += $subtotal;
|
||||
|
||||
$subtotales[$idT][$idC] = $subtotal;
|
||||
}
|
||||
|
||||
$totales[$idT] = $total;
|
||||
|
||||
}//foreach
|
||||
|
||||
$card['tallas'] = $tallas;
|
||||
$card['colores'] = $colores;
|
||||
$card['totales'] = $totales;
|
||||
$card['subtotales'] = $subtotales;
|
||||
$card['proporcionT'] = $proporcionT;
|
||||
$card['proporcionC'] = $proporcionC;
|
||||
|
||||
//FIN PROPORCIONES
|
||||
|
||||
if($card['status'] == 'Sugerencia')
|
||||
$sugerencias++;
|
||||
|
||||
$products[] = $card;
|
||||
|
||||
}//foreach
|
||||
|
||||
$info['subtotal'] = number_format($info['subtotal'],2);
|
||||
$info['iva'] = number_format($info['iva'],2);
|
||||
$info['total'] = number_format($info['total'],2);
|
||||
|
||||
//HTML - PDF
|
||||
|
||||
$html .= '
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
body{
|
||||
font-family:Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size:10px;
|
||||
}
|
||||
.titulo {
|
||||
color: #FFFFFF;
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-weight: bold;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="550" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td width="430">
|
||||
<p><b>'.strtoupper($infE['razonSocial']).'</b><br />
|
||||
'.$infE['direccion'].'
|
||||
</td>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<table width="550" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td>
|
||||
<table width="550" border="1" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td width="" align="center"><b>No. PEDIDO</b></td>
|
||||
<td width="25%" align="center"><b>METODO COMPRA</b></td>
|
||||
<td width="25%" align="center"><b>FECHA DE SOLICITUD</b></td>
|
||||
<td width="26%" align="center"><b>FECHA DE ENTREGA</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="15" align="center">'.$info['noPedido'].'</td>
|
||||
<td align="center">'.$info['metodoCompra'].'</td>
|
||||
<td align="center">'.$info['fecha'].'</td>
|
||||
<td align="center">'.$info['fechaEntrega'].'</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
//DATOS DEL PROVEEDOR
|
||||
|
||||
$html .= '
|
||||
<table width="550" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td colspan="4" align="center" bgcolor="#809829"><span class="titulo">DATOS DEL PROVEEDOR</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="23%"><b>Razón Social</b></td>
|
||||
<td width="26%">'.$infPv['nombre'].'</td>
|
||||
<td width="27%"><b>Calle</b></td>
|
||||
<td width="">'.$infPv['calle'].'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>RFC</b></td>
|
||||
<td>'.$infPv['rfc'].'</td>
|
||||
<td><b>Colonia</b></td>
|
||||
<td>'.$infPv['colonia'].'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Teléfonos</b></td>
|
||||
<td>'.$infPv['phone'].'</td>
|
||||
<td><b>Delegación o Municipio</b></td>
|
||||
<td>'.$infPv['municipio'].'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>C.P.</b></td>
|
||||
<td>'.$infS['codigoPostal'].'</td>
|
||||
<td><b>Estado</b></td>
|
||||
<td>'.$infS['estado'].'</td>
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
//PRODUCTOS
|
||||
|
||||
$html .= '
|
||||
<br>
|
||||
<table width="550" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td colspan="5" align="center" bgcolor="#809829"><span class="titulo">PRODUCTOS</span></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>';
|
||||
|
||||
foreach($products as $res){
|
||||
|
||||
//Tallas
|
||||
|
||||
$hTallas = '<br>
|
||||
<table width="" cellpadding="0" cellspacing="0" border="1" align="center">
|
||||
<tr>
|
||||
<td colspan="'.count($res['tallas']).'" align="center"><b>Proporción Tallas</b></td>
|
||||
</tr>
|
||||
<tr>';
|
||||
foreach($res['tallas'] as $val)
|
||||
$hTallas .= '<td align="center" width="30">'.$val['nombre'].'<br>'.$val['cantidad'].'</td>';
|
||||
|
||||
$hTallas .= '
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
//Colores
|
||||
|
||||
$hColores = '<br>
|
||||
<table width="" cellpadding="0" cellspacing="0" border="1" align="center">
|
||||
<tr>
|
||||
<td colspan="'.count($res['colores']).'" align="center"><b>Proporción Colores</b></td>
|
||||
</tr>
|
||||
<tr>';
|
||||
foreach($res['colores'] as $val)
|
||||
$hColores .= '<td align="center" width="30">'.$val['nombre'].'<br>'.$val['cantidad'].'</td>';
|
||||
|
||||
$hColores .= '
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
//Producto
|
||||
|
||||
$html .= '
|
||||
<table width="550" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td width="13%" align="center" bgcolor="#CCCCCC">CODIGO BARRA</td>
|
||||
<td width="" align="center" bgcolor="#CCCCCC">MODELO</td>
|
||||
<td width="14%" align="center" bgcolor="#CCCCCC">COSTO UNITARIO</td>
|
||||
<td width="14%" align="center" bgcolor="#CCCCCC">PRECIO VENTA</td>
|
||||
<td width="14%" align="center" bgcolor="#CCCCCC">CANTIDAD</td>
|
||||
<td width="14%" align="center" bgcolor="#CCCCCC">TOTAL</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">'.$res['codigoBarra'].'</td>
|
||||
<td align="center">'.$res['modelo'].'</td>
|
||||
<td align="center">$'.$res['costo'].'</td>
|
||||
<td align="center">$'.$res['precioVentaIva'].'</td>
|
||||
<td align="center">'.$res['cantidad'].'</td>
|
||||
<td align="right">$'.$res['total'].'</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<table width="550" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td>'.$hTallas.'</td>
|
||||
<td>'.$hColores.'</td>
|
||||
</tr>
|
||||
</table>
|
||||
';
|
||||
|
||||
//Distribucion
|
||||
|
||||
$html .= '<br>
|
||||
<div align="center"><b>DISTRIBUCION</b></div>
|
||||
<br>
|
||||
<table width="" cellpadding="0" cellspacing="0" border="1" align="center">
|
||||
';
|
||||
|
||||
$html .= '<tr>';
|
||||
$bloque = 0;
|
||||
foreach($sucursals as $sucursales){
|
||||
//$html .= '<tr>';
|
||||
|
||||
foreach($sucursales as $val){
|
||||
|
||||
$productoId = $res['productoId'];
|
||||
$sucursalId = $val['sucursalId'];
|
||||
|
||||
$sucursal->setSucursalId($sucursalId);
|
||||
$infS = $sucursal->Info();
|
||||
$noSuc = $infS['noSuc'];
|
||||
|
||||
$distP = $dist[$productoId][$sucursalId];
|
||||
|
||||
if($distP['cantidad'] > 0){
|
||||
$html .= '<td align="center" width="40">Suc. '.$noSuc.'<br>'.$distP['cantidad'].'</td>';
|
||||
$bloque++;
|
||||
}
|
||||
|
||||
if($bloque == 11){
|
||||
$html .= '</tr><tr>';
|
||||
$bloque = 0;
|
||||
}
|
||||
|
||||
}//foreach
|
||||
|
||||
}//foreach $sucursals
|
||||
|
||||
if($bloque == 0)
|
||||
$falta = 0;
|
||||
else
|
||||
$falta = 11 - $bloque;
|
||||
|
||||
for($k=1; $k<=$falta; $k++)
|
||||
$html .= '<td align="center" width="40"></td>';
|
||||
|
||||
$html .= '</tr>';
|
||||
|
||||
$html .= '</table>';
|
||||
|
||||
}//foreach
|
||||
|
||||
//PRODUCTOS
|
||||
|
||||
$html .= '
|
||||
<br>
|
||||
<table width="550" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td colspan="5" align="center" bgcolor="#809829"><span class="titulo">PIEZAS POR CAJA</span></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>';
|
||||
|
||||
$html .= '
|
||||
<table width="550" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td width="15%" align="center" bgcolor="#CCCCCC">CODIGO BARRA</td>
|
||||
<td width="" align="center" bgcolor="#CCCCCC">MODELO</td>
|
||||
<td width="20%" align="center" bgcolor="#CCCCCC">CANTIDAD</td>
|
||||
</tr>
|
||||
';
|
||||
|
||||
foreach($products as $res){
|
||||
|
||||
$html .= '
|
||||
<tr>
|
||||
<td align="center">'.$res['codigoBarra'].'</td>
|
||||
<td align="left">'.$res['modelo'].'</td>
|
||||
<td align="center">'.$res['piezasCaja'].'</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
$html .= '</table>';
|
||||
|
||||
//TOTALES
|
||||
|
||||
$html .= '
|
||||
<br>
|
||||
<table width="550" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td colspan="5" align="center" bgcolor="#809829"><span class="titulo">TOTALES</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="20%"></td>
|
||||
<td width=""></td>
|
||||
<td width="16%"> </td>
|
||||
<td width="16%" valign="top">
|
||||
<b>SUBTOTAL</b> <br>
|
||||
<b>IVA '.$ivaPorc.'%</b> <br>
|
||||
<b>TOTAL</b>
|
||||
</td>
|
||||
<td width="16%" align="right" valign="top">
|
||||
$'.$info['subtotal'].'<br>
|
||||
$'.$info['iva'].'<br>
|
||||
$'.$info['total'].'
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
';
|
||||
|
||||
$dompdf = new DOMPDF();
|
||||
$dompdf->set_paper('letter');
|
||||
$dompdf->load_html($html);
|
||||
$dompdf->render();
|
||||
|
||||
if($mode == 'show'){
|
||||
$dompdf->stream('orden_compra.pdf');
|
||||
exit;
|
||||
}
|
||||
|
||||
//Guardamos el archivo temporalmente
|
||||
$pdfoutput = $dompdf->output();
|
||||
$filename = DOC_ROOT.'/temp/orden_compra.pdf';
|
||||
$fp = fopen($filename, "a");
|
||||
fwrite($fp, $pdfoutput);
|
||||
fclose($fp);
|
||||
|
||||
$_mail = new PHPMailer(true);
|
||||
|
||||
//Configurando el servidor SMTP
|
||||
|
||||
$_mail->IsSMTP();
|
||||
$_mail->SMTPAuth = true;
|
||||
$_mail->Host = SMTP_HOST;
|
||||
$_mail->Username = SMTP_USER;
|
||||
$_mail->Password = SMTP_PASS;
|
||||
$_mail->Port = SMTP_PORT;
|
||||
|
||||
//Enviamos el mensaje
|
||||
|
||||
$email = $infPv['emailVtas'];
|
||||
$proveedor = $infPv['nombre'];
|
||||
|
||||
if($mode == 'cancelar'){
|
||||
$subject = 'Cancelacion Orden de Compra No. '.$info['noPedido'];
|
||||
$message = 'Por medio de la presente le informamos que la Orden de Compra No. '.$info['noPedido'];
|
||||
$message .= 'ha sido cancelada.';
|
||||
$message .= '<br><br>Lamentamos los inconvenientes que esto pudiera ocasionar.';
|
||||
}else{
|
||||
$subject = 'Envio Orden de Compra No. '.$info['noPedido'];
|
||||
$message = 'Por medio de la presente le hacemos llegar la Orden de Compra No. '.$info['noPedido'];
|
||||
}
|
||||
|
||||
$message .= '<br><br>Por su atención';
|
||||
$message .='<br><br>Gracias';
|
||||
|
||||
$html = '<html>
|
||||
<body>
|
||||
'.$message.'
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
try {
|
||||
$_mail->AddAddress($email, $proveedor);
|
||||
|
||||
if($enProduccion){
|
||||
$_mail->AddBCC('silvano.cruz@novomoda.com.mx');
|
||||
$_mail->AddBCC('sonia.velazquez@novomoda.com.mx');
|
||||
}
|
||||
|
||||
$_mail->AddBCC('sistemas@novomoda.com.mx');
|
||||
$_mail->SetFrom('contacto@novomoda.com.mx', 'Novomoda');
|
||||
$_mail->Subject = $subject;
|
||||
$_mail->MsgHTML($html);
|
||||
$_mail->AddAttachment(DOC_ROOT.'/temp/orden_compra.pdf'); // attachment
|
||||
$_mail->Send();
|
||||
|
||||
$emailSent = 1;
|
||||
|
||||
} catch (phpmailerException $e) {
|
||||
$emailSent = 2;
|
||||
} catch (Exception $e) {
|
||||
$emailSent = 2;
|
||||
}
|
||||
|
||||
|
||||
@unlink(DOC_ROOT.'/temp/orden_compra.pdf');
|
||||
|
||||
header('Location: '.WEB_ROOT.'/pedidos');
|
||||
exit;
|
||||
|
||||
?>
|
||||
187
modules/pedidos-revivir.php
Executable file
187
modules/pedidos-revivir.php
Executable file
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($Usr['type'] != 'compras'){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$pedidoId = intval($_GET['id']);
|
||||
|
||||
$_SESSION['prodsPed'] = array();
|
||||
unset($_SESSION['prodsPed']);
|
||||
|
||||
$pedido->setPedidoId($pedidoId);
|
||||
$info = $pedido->Info();
|
||||
|
||||
$info['noPedido'] = $pedido->GetNextNoPedido();
|
||||
$info['fecha'] = date('d-m-Y H:i:s');
|
||||
|
||||
$proveedor->setProveedorId($info['proveedorId']);
|
||||
$info['proveedor'] = $proveedor->GetNameById();
|
||||
|
||||
$info['fechaEntrega'] = date('d-m-Y',strtotime($info['fechaEntrega']));
|
||||
|
||||
if($info['fechaEntregaF'])
|
||||
$info['fechaEntregaF'] = date('d-m-Y',strtotime($info['fechaEntregaF']));
|
||||
|
||||
$info['fecha'] = date('d-m-Y H:i:s',strtotime($info['fecha']));
|
||||
|
||||
$resProducts = $pedido->GetProductos();
|
||||
|
||||
$products = array();
|
||||
$products2 = array();
|
||||
foreach($resProducts as $card){
|
||||
|
||||
$prodCatId = $card['prodCatId'];
|
||||
$prodSubcatId = $card['prodSubcatId'];
|
||||
$productoId = $card['productoId'];
|
||||
|
||||
$card['productoId'] = $productoId;
|
||||
$card['prodCatId'] = $prodCatId;
|
||||
$card['prodSubcatId'] = $prodSubcatId;
|
||||
|
||||
$prodCat->setProdCatId($prodCatId);
|
||||
$card['departamento'] = $prodCat->GetNameById();
|
||||
|
||||
$prodSubcat->setProdSubcatId($prodSubcatId);
|
||||
$card['linea'] = $prodSubcat->GetNameById();
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$infP = $producto->Info();
|
||||
$card['modelo'] = $infP['modelo'];
|
||||
$card['codigoBarra'] = $infP['codigoBarra'];
|
||||
|
||||
$card['atributos'] = $producto->GetAtributosAll();
|
||||
|
||||
//PROPORCIONES
|
||||
|
||||
//Colores
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$resColores = $producto->GetColores();
|
||||
|
||||
$atribVal->setAtributoId(2);
|
||||
$resColores = $atribVal->EnumerateAll();
|
||||
|
||||
$colores = array();
|
||||
foreach($resColores as $res){
|
||||
|
||||
$colorId = $res['atribValId'];
|
||||
|
||||
$pedido->setColorId($colorId);
|
||||
$pedido->setProductoId($productoId);
|
||||
$cantidad = $pedido->GetProporcionByColor();
|
||||
|
||||
$proporcionC[$colorId] = $cantidad;
|
||||
|
||||
$res['cantidad'] = $cantidad;
|
||||
|
||||
$colores[$colorId] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
//Tallas
|
||||
|
||||
$atribVal->setAtributoId(1);
|
||||
$resTallas = $atribVal->EnumerateAll();
|
||||
|
||||
$tallas = array();
|
||||
foreach($resTallas as $res){
|
||||
|
||||
$tallaId = $res['atribValId'];
|
||||
|
||||
$pedido->setTallaId($tallaId);
|
||||
$pedido->setProductoId($productoId);
|
||||
$cantidad = $pedido->GetProporcionByTalla();
|
||||
|
||||
$proporcionT[$tallaId] = $cantidad;
|
||||
|
||||
$res['cantidad'] = $cantidad;
|
||||
|
||||
$tallas[$tallaId] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
//Obtenemos Totales
|
||||
|
||||
$totales = array();
|
||||
$subtotales = array();
|
||||
foreach($tallas as $idT => $t){
|
||||
|
||||
$cantT = $t['cantidad'];
|
||||
|
||||
$total = 0;
|
||||
foreach($colores as $idC => $c){
|
||||
|
||||
$cantC = $c['cantidad'];
|
||||
|
||||
$subtotal = $cantC * $cantT;
|
||||
$total += $subtotal;
|
||||
|
||||
$subtotales[$idT][$idC] = $subtotal;
|
||||
}
|
||||
|
||||
$totales[$idT] = $total;
|
||||
|
||||
}//foreach
|
||||
|
||||
$card['tallas'] = $tallas;
|
||||
$card['colores'] = $colores;
|
||||
$card['totales'] = $totales;
|
||||
$card['subtotales'] = $subtotales;
|
||||
$card['proporcionT'] = $proporcionT;
|
||||
$card['proporcionC'] = $proporcionC;
|
||||
|
||||
//FIN PROPORCIONES
|
||||
|
||||
$card2 = $card;
|
||||
|
||||
$card2['departamento'] = utf8_encode($card['departamento']);
|
||||
$card2['linea'] = utf8_encode($card['linea']);
|
||||
$card2['atributos'] = utf8_encode($card['atributos']);
|
||||
$card2['tallas'] = $util->EncodeResult($tallas);
|
||||
$card2['colores'] = $util->EncodeResult($colores);
|
||||
|
||||
$products[] = $card;
|
||||
$products2[] = $card2;
|
||||
|
||||
}//foreach
|
||||
|
||||
$_SESSION['prodsPed'] = $products2;
|
||||
|
||||
$proveedores = $proveedor->EnumerateAll();
|
||||
$categorias = $prodCat->EnumerateAll();
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$sucursales = $util->DecodeUrlResult($resSuc);
|
||||
$sucursales = $util->DecodeResult($sucursales);
|
||||
|
||||
$distVal = array();
|
||||
foreach($products2 as $res){
|
||||
|
||||
$productoId = $res['productoId'];
|
||||
|
||||
foreach($sucursales as $suc){
|
||||
|
||||
$sucursalId = $suc['sucursalId'];
|
||||
|
||||
$pedido->setPedidoId($pedidoId);
|
||||
$pedido->setProductoId($productoId);
|
||||
$pedido->setSucursalId($sucursalId);
|
||||
|
||||
$distVal[$productoId][$sucursalId] = $pedido->GetCantDist();
|
||||
|
||||
}//foreach
|
||||
|
||||
}//foreach
|
||||
|
||||
$smarty->assign('info', $info);
|
||||
$smarty->assign('distVal', $distVal);
|
||||
$smarty->assign('products', $products);
|
||||
$smarty->assign('categorias', $categorias);
|
||||
$smarty->assign('proveedores', $proveedores);
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
?>
|
||||
84
modules/pedidos.php
Executable file
84
modules/pedidos.php
Executable file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$_SESSION['prodsPed'] = array();
|
||||
unset($_SESSION['prodsPed']);
|
||||
|
||||
$pedido->setPage($_GET['p']);
|
||||
|
||||
$pedidos = $pedido->Enumerate2();
|
||||
|
||||
$items = array();
|
||||
foreach($pedidos['items'] as $res){
|
||||
$pedido->setPedidoId($res['pedidoId']);
|
||||
$productos = $pedido->GetProductos();
|
||||
|
||||
$costoCompra = 0;
|
||||
$precioVenta = 0;
|
||||
foreach($productos as $val){
|
||||
|
||||
$totalProds = ($val['prendasComp'] == 1) ? $val['cantPrendas'] : $val['prendasRec'];
|
||||
$precioVenta += $val['precioVenta'] * $totalProds;
|
||||
}
|
||||
|
||||
if($res['total2'] > 0)
|
||||
$costoCompra = $res['total2'];
|
||||
else
|
||||
$costoCompra = $res['total'];
|
||||
|
||||
$res['costoCompra'] = number_format($costoCompra,2,'.',',');
|
||||
$res['precioVenta'] = number_format($precioVenta,2,'.',',');
|
||||
|
||||
//Obtenemos el Porcentaje de Utilidad
|
||||
if($costoCompra > 0){
|
||||
if($precioVenta == 0)
|
||||
$porcUtilidad = 0;
|
||||
else
|
||||
$porcUtilidad = (($costoCompra / $precioVenta) - 1) * -1 * 100;
|
||||
|
||||
$res['utilidad'] = number_format($porcUtilidad,2,'.',',');
|
||||
}else{
|
||||
$res['utilidad'] = 0;
|
||||
}
|
||||
|
||||
$proveedor->setProveedorId($res['proveedorId']);
|
||||
$res['proveedor'] = $proveedor->GetNameById();
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($res['fecha']));
|
||||
$hora = date('H:i:s',strtotime($res['fecha']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$res['fecha'] = $fecha.' '.$hora;
|
||||
|
||||
$fechaEntrega = date('d-m-Y',strtotime($res['fechaEntrega']));
|
||||
$res['fechaEntrega'] = $util->FormatDateDMMMY($fechaEntrega);
|
||||
|
||||
if($res['fechaEntregaF']){
|
||||
$fechaEntregaF = date('d-m-Y',strtotime($res['fechaEntregaF']));
|
||||
$res['fechaEntregaF'] = $util->FormatDateDMMMY($fechaEntregaF);
|
||||
}
|
||||
|
||||
if($res['status'] == 'Autorizado' || $res['status'] == 'OrdenCompEnv')
|
||||
$res['distComp'] = $pedido->DistCompleta();
|
||||
else
|
||||
$res['distComp'] = 1;
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$pedidos['items'] = $items;
|
||||
|
||||
$msg = $_SESSION['msgPed'];
|
||||
$_SESSION['msgPed'] = '';
|
||||
|
||||
$proveedores = $proveedor->EnumerateAll();
|
||||
|
||||
$smarty->assign('msg', $msg);
|
||||
$smarty->assign('proveedores', $proveedores);
|
||||
$smarty->assign('pedidos', $pedidos);
|
||||
|
||||
?>
|
||||
188
modules/productos-agregar.php
Executable file
188
modules/productos-agregar.php
Executable file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($_POST['type'] == 'saveProducto'){
|
||||
|
||||
$codigoBarra = $_POST['codigoBarra'];
|
||||
$precioVentaIva = $_POST['precioVentaIva'];
|
||||
$costo = $_POST['costo'];
|
||||
|
||||
//Calculamos el Precio de Venta
|
||||
$precioVenta = 0;
|
||||
if($precioVentaIva != ''){
|
||||
$precioVenta = $precioVentaIva / 1.16;
|
||||
$precioVenta = number_format($precioVenta,2,'.','');
|
||||
}
|
||||
|
||||
//Calculamos la Utilidad
|
||||
$utilidad = $precioVenta - $costo;
|
||||
$porcUtilidad = ($utilidad * 100) / $costo;
|
||||
|
||||
$producto->setProveedorId($_POST['proveedorId']);
|
||||
$producto->setProdCatId($_POST['prodCatId']);
|
||||
$producto->setProdSubcatId($_POST['prodSubcatId']);
|
||||
$producto->setConTallaId($_POST['conTallaId']);
|
||||
$producto->setModelo($_POST['modelo']);
|
||||
$producto->setCodigoBarra($codigoBarra);
|
||||
$producto->setConTallaId($_POST['conTallaId']);
|
||||
$producto->setDescripcion($_POST['descripcion']);
|
||||
$producto->setTemporadaId($_POST['temporadaId']);
|
||||
$producto->setCosto($costo);
|
||||
$producto->setPrecioVentaIva($precioVentaIva);
|
||||
$producto->setPrecioVenta($precioVenta);
|
||||
$producto->setUtilidad($utilidad);
|
||||
|
||||
$productoId = $producto->Save();
|
||||
|
||||
//Guardamos los Materiales
|
||||
|
||||
if(count($_POST['materialId']) == 0)
|
||||
$_POST['materialId'] = array();
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
foreach($_POST['materialId'] as $k => $materialId){
|
||||
$producto->setMaterialId($materialId);
|
||||
$producto->setPorcentaje($_POST['porcentaje'][$k]);
|
||||
|
||||
$producto->SaveMaterial();
|
||||
}
|
||||
|
||||
//Guardamos los Atributos
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
|
||||
if(count($_POST['atrib']) == 0)
|
||||
$_POST['atrib'] = array();
|
||||
|
||||
foreach($_POST['atrib'] as $atributoId => $id){
|
||||
|
||||
$producto->setAtributoId($atributoId);
|
||||
$producto->setAtribValId($id);
|
||||
$producto->SaveAtributo();
|
||||
}
|
||||
|
||||
//Guardamos los Codigos de Barra
|
||||
|
||||
$codigo = $_POST['codigo'];
|
||||
if(count($codigo) == 0)
|
||||
$codigo = array();
|
||||
|
||||
if(count($_POST['tallas']) == 0)
|
||||
$_POST['tallas'] = array(1);
|
||||
|
||||
if(count($_POST['colores']) == 0)
|
||||
$_POST['colores'] = array(2);
|
||||
|
||||
$codigos = array();
|
||||
/*
|
||||
foreach($_POST['tallas'] as $tallaId){
|
||||
|
||||
$atribVal->setAtribValId($tallaId);
|
||||
$nomTalla = $atribVal->GetNameById();
|
||||
|
||||
foreach($_POST['colores'] as $colorId){
|
||||
|
||||
$codigoBarra = trim($codigo[$tallaId][$colorId]);
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$producto->setTallaId($tallaId);
|
||||
$producto->setColorId($colorId);
|
||||
$producto->setCodigoBarra($codigoBarra);
|
||||
|
||||
$producto->SaveItem();
|
||||
|
||||
}//foreach
|
||||
|
||||
}//foreach
|
||||
*/
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$producto->setTallaId(1);
|
||||
$producto->setColorId(2);
|
||||
$producto->setCodigoBarra($codigoBarra);
|
||||
|
||||
$producto->SaveItem();
|
||||
|
||||
//Guardamos el archivo
|
||||
|
||||
$ruta = DOC_ROOT.'/images/productos';
|
||||
|
||||
// obtenemos los datos del archivo
|
||||
$tamano = $_FILES["imagen"]['size'];
|
||||
$tipo = $_FILES["imagen"]['type'];
|
||||
$archivo = $_FILES["imagen"]['name'];
|
||||
|
||||
$nom = explode('.',$archivo);
|
||||
|
||||
$prefijo = substr(md5(uniqid(rand())),0,3);
|
||||
$time = time();
|
||||
|
||||
if($archivo != "") {
|
||||
|
||||
//Comparamos si el archivo es un pdf
|
||||
//if ($tipo == 'application/pdf'){
|
||||
|
||||
$fileName = $productoId.'_'.$time.'.'.$nom[1];
|
||||
|
||||
$destino = $ruta.'/'.$fileName;
|
||||
if (move_uploaded_file($_FILES['imagen']['tmp_name'],$destino)) {
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$producto->setImagen($fileName);
|
||||
$producto->UpdateImagen();
|
||||
|
||||
}
|
||||
/*
|
||||
else{
|
||||
$mensaje = '<span class="txtRed">Error al subir el archivo.</span>';
|
||||
}//else
|
||||
*/
|
||||
/*
|
||||
}else{
|
||||
$mensaje = '<span class="txtRed">Archivo no válido. Debe ser pdf.</span>';
|
||||
}//else
|
||||
*/
|
||||
}//if
|
||||
|
||||
$_SESSION['msgP'] = 'Saved';
|
||||
|
||||
header('Location: '.WEB_ROOT.'/productos');
|
||||
exit;
|
||||
|
||||
}//if
|
||||
|
||||
$categorias = $prodCat->EnumerateAll();
|
||||
$proveedores = $proveedor->EnumerateAll();
|
||||
$temporadas = $temporada->EnumerateAll();
|
||||
$materiales = $material->EnumerateAll();
|
||||
|
||||
$atribVal->setAtributoId(2);
|
||||
$colores = $atribVal->EnumerateAll();
|
||||
|
||||
$conTallas = $conTalla->EnumerateAll();
|
||||
|
||||
//Obtenemos los materiales del Producto
|
||||
|
||||
$prodMats = array();
|
||||
|
||||
$card['materialId'] = 0;
|
||||
$card['porcentaje'] = 0;
|
||||
|
||||
$prodMats[] = $card;
|
||||
|
||||
$_SESSION['prodMats'] = $prodMats;
|
||||
|
||||
$info['precioVenta'] = '0.00';
|
||||
|
||||
$smarty->assign('info', $info);
|
||||
$smarty->assign('colores', $colores);
|
||||
$smarty->assign('prodMats', $prodMats);
|
||||
$smarty->assign('conTallas', $conTallas);
|
||||
$smarty->assign('atributos', $atributos);
|
||||
$smarty->assign('categorias', $categorias);
|
||||
$smarty->assign('temporadas', $temporadas);
|
||||
$smarty->assign('proveedores', $proveedores);
|
||||
$smarty->assign('materiales', $materiales);
|
||||
|
||||
?>
|
||||
38
modules/productos-categorias.php
Executable file
38
modules/productos-categorias.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$prodCat->SetPage($_GET["p"]);
|
||||
$categorias = $prodCat->Enumerate();
|
||||
|
||||
$items = array();
|
||||
foreach($categorias['items'] as $res){
|
||||
$card = $res;
|
||||
|
||||
$prodSubcat->setProdCatId($res['prodCatId']);
|
||||
$resSubcats = $prodSubcat->EnumerateAll();
|
||||
|
||||
$subcategorias = array();
|
||||
foreach($resSubcats as $val){
|
||||
|
||||
$prodSubcat->setProdSubcatId($val['prodSubcatId']);
|
||||
$resAtributos = $prodSubcat->GetAtributos();
|
||||
|
||||
$atributos = array();
|
||||
foreach($resAtributos as $atr){
|
||||
$atributo->setAtributoId($atr['atributoId']);
|
||||
$atributos[] = $atributo->GetNameById();
|
||||
}
|
||||
$val['atributos'] = implode(', ',$atributos);
|
||||
|
||||
$subcategorias[] = $val;
|
||||
}
|
||||
$card['subcategorias'] = $subcategorias;
|
||||
|
||||
$items[] = $card;
|
||||
}
|
||||
$categorias['items'] = $items;
|
||||
|
||||
$smarty->assign('categorias', $categorias);
|
||||
|
||||
?>
|
||||
129
modules/productos-detalles.php
Executable file
129
modules/productos-detalles.php
Executable file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$productoId = $_GET['id'];
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$info = $producto->Info();
|
||||
|
||||
$proveedor->setProveedorId($info['proveedorId']);
|
||||
$infPv = $proveedor->Info();
|
||||
|
||||
$info['proveedor'] = $infPv['nombre'];
|
||||
$info['noProv'] = $infPv['noProv'];
|
||||
|
||||
$prodCat->setProdCatId($info['prodCatId']);
|
||||
$info['departamento'] = $prodCat->GetNameById();
|
||||
|
||||
if($info['prodSubcatId']){
|
||||
$prodSubcat->setProdSubcatId($info['prodSubcatId']);
|
||||
$info['linea'] = $prodSubcat->GetNameById();
|
||||
}
|
||||
|
||||
$temporada->setTemporadaId($info['temporadaId']);
|
||||
$info['temporada'] = $temporada->GetNameById();
|
||||
|
||||
if($info['costo'] > 0)
|
||||
$porcUtilidad = ($info['utilidad'] * 100) / $info['costo'];
|
||||
else
|
||||
$porcUtilidad = 0;
|
||||
|
||||
$info['porcUtilidad'] = number_format($porcUtilidad,2,'.',',');
|
||||
|
||||
//Obtenemos las Tallas
|
||||
|
||||
$atribVal->setAtributoId(1);
|
||||
$resTallas = $atribVal->EnumerateAll();
|
||||
|
||||
$tallas = array();
|
||||
foreach($resTallas as $res){
|
||||
|
||||
$producto->setTallaId($res['atribValId']);
|
||||
if($producto->ExistTalla())
|
||||
$tallas[] = $res;
|
||||
}
|
||||
|
||||
$atribVal->setAtributoId(2);
|
||||
$resColores = $atribVal->EnumerateAll();
|
||||
|
||||
//Obtenemos los Colores
|
||||
|
||||
$colores = array();
|
||||
foreach($resColores as $res){
|
||||
|
||||
$producto->setColorId($res['atribValId']);
|
||||
if($producto->ExistColor())
|
||||
$colores[] = $res;
|
||||
|
||||
}
|
||||
|
||||
//Obtenemos los Atributos
|
||||
|
||||
$prodSubcat->setProdSubcatId($info['prodSubcatId']);
|
||||
$resAtributos = $prodSubcat->EnumAtributos();
|
||||
|
||||
$atributos = array();
|
||||
foreach($resAtributos as $res){
|
||||
|
||||
$atributo->setAtributoId($res['atributoId']);
|
||||
$res['nombre'] = $atributo->GetNameById();
|
||||
|
||||
$atribVal->setAtributoId($res['atributoId']);
|
||||
$resValores = $atribVal->EnumerateAll();
|
||||
|
||||
$valores = array();
|
||||
foreach($resValores as $val){
|
||||
|
||||
$producto->setAtribValId($val['atribValId']);
|
||||
if($producto->ExistAtributo())
|
||||
$valores[] = $val;
|
||||
|
||||
}
|
||||
|
||||
$res['valores'] = $valores;
|
||||
|
||||
$atributos[] = $res;
|
||||
}
|
||||
|
||||
//Obtenemos los Codigos de Barra
|
||||
|
||||
$resCodigos = $producto->GetCodigosBarra();
|
||||
foreach($resCodigos as $res){
|
||||
|
||||
$card = $res;
|
||||
|
||||
$atribVal->setAtribValId($res['tallaId']);
|
||||
$nomTalla = $atribVal->GetNameById();
|
||||
|
||||
$atribVal->setAtribValId($res['colorId']);
|
||||
$card['nombre'] = $nomTalla.' '.$atribVal->GetNameById();
|
||||
$card['codigo'] = $res['codigoBarra'];
|
||||
|
||||
$codigos[] = $card;
|
||||
|
||||
}
|
||||
|
||||
//Obtenemos los materiales del Producto
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$resMats = $producto->GetMaterials();
|
||||
|
||||
$prodMats = array();
|
||||
foreach($resMats as $res){
|
||||
|
||||
$material->setMaterialId($res['materialId']);
|
||||
$res['material'] = $material->GetNameById();
|
||||
|
||||
$prodMats[] = $res;
|
||||
|
||||
}
|
||||
|
||||
$smarty->assign('info', $info);
|
||||
$smarty->assign('tallas', $tallas);
|
||||
$smarty->assign('colores', $colores);
|
||||
$smarty->assign('codigos', $codigos);
|
||||
$smarty->assign('prodMats', $prodMats);
|
||||
$smarty->assign('atributos', $atributos);
|
||||
|
||||
?>
|
||||
40
modules/productos-duplicados.php
Executable file
40
modules/productos-duplicados.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$producto->SetPage($_GET["p"]);
|
||||
$productos = $producto->EnumDuplicados();
|
||||
|
||||
$items = array();
|
||||
foreach($productos['items'] as $res){
|
||||
|
||||
$proveedor->setProveedorId($res['proveedorId']);
|
||||
$infPv = $proveedor->Info();
|
||||
|
||||
$res['proveedor'] = $infPv['nombre'];
|
||||
$res['noProv'] = $infPv['noProv'];
|
||||
|
||||
$prodCat->setProdCatId($res['prodCatId']);
|
||||
$res['departamento'] = $prodCat->GetNameById();
|
||||
|
||||
if($res['prodSubcatId']){
|
||||
$prodSubcat->setProdSubcatId($res['prodSubcatId']);
|
||||
$res['linea'] = $prodSubcat->GetNameById();
|
||||
}
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$productos['items'] = $items;
|
||||
|
||||
$categorias = $prodCat->EnumerateAll();
|
||||
$proveedores = $proveedor->EnumerateAll();
|
||||
|
||||
$msg = $_SESSION['msgP'];
|
||||
$_SESSION['msgP'] = '';
|
||||
|
||||
$smarty->assign('msg', $msg);
|
||||
$smarty->assign('categorias', $categorias);
|
||||
$smarty->assign('proveedores', $proveedores);
|
||||
$smarty->assign('productos', $productos);
|
||||
|
||||
?>
|
||||
249
modules/productos-editar.php
Executable file
249
modules/productos-editar.php
Executable file
@@ -0,0 +1,249 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($_POST['type'] == 'saveEditProducto'){
|
||||
|
||||
$productoId = $_POST['productoId'];
|
||||
$codigoBarra = $_POST['codigoBarra'];
|
||||
$precioVentaIva = $_POST['precioVentaIva'];
|
||||
$costo = $_POST['costo'];
|
||||
|
||||
//Calculamos el Precio de Venta
|
||||
$precioVenta = 0;
|
||||
if($precioVentaIva != ''){
|
||||
$precioVenta = $precioVentaIva / 1.16;
|
||||
$precioVenta = number_format($precioVenta,2,'.','');
|
||||
}
|
||||
|
||||
//Calculamos la Utilidad
|
||||
$utilidad = $precioVenta - $costo;
|
||||
$porcUtilidad = ($utilidad * 100) / $costo;
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$producto->setProveedorId($_POST['proveedorId']);
|
||||
$producto->setProdCatId($_POST['prodCatId']);
|
||||
$producto->setProdSubcatId($_POST['prodSubcatId']);
|
||||
$producto->setConTallaId($_POST['conTallaId']);
|
||||
$producto->setModelo($_POST['modelo']);
|
||||
$producto->setCodigoBarra($codigoBarra);
|
||||
$producto->setDescripcion($_POST['descripcion']);
|
||||
$producto->setTemporadaId($_POST['temporadaId']);
|
||||
$producto->setCosto($costo);
|
||||
$producto->setPrecioVentaIva($precioVentaIva);
|
||||
$producto->setPrecioVenta($precioVenta);
|
||||
$producto->setUtilidad($utilidad);
|
||||
|
||||
$infP = $producto->Info();
|
||||
|
||||
$producto->Update();
|
||||
|
||||
//Actualizamos los ProdItems
|
||||
$producto->UpdateProdItems();
|
||||
|
||||
//Actualizamos los Precios en Inventario
|
||||
$producto->UpdatePriceInv();
|
||||
|
||||
//Guardamos los Materiales
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$producto->DeleteMateriales();
|
||||
|
||||
if(count($_POST['materialId']) == 0)
|
||||
$_POST['materialId'] = array();
|
||||
|
||||
foreach($_POST['materialId'] as $k => $materialId){
|
||||
$producto->setMaterialId($materialId);
|
||||
$producto->setPorcentaje($_POST['porcentaje'][$k]);
|
||||
|
||||
$producto->SaveMaterial();
|
||||
}
|
||||
|
||||
//Eliminamos el archivo
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
if($_POST['delImage']){
|
||||
$infP = $producto->Info();
|
||||
@unlink(DOC_ROOT.'/images/productos/'.$infP['imagen']);
|
||||
|
||||
$producto->setImagen('');
|
||||
$producto->UpdateImagen();
|
||||
}
|
||||
|
||||
//Guardamos el archivo
|
||||
|
||||
$ruta = DOC_ROOT.'/images/productos';
|
||||
|
||||
// obtenemos los datos del archivo
|
||||
$tamano = $_FILES["imagen"]['size'];
|
||||
$tipo = $_FILES["imagen"]['type'];
|
||||
$archivo = $_FILES["imagen"]['name'];
|
||||
|
||||
$nom = explode('.',$archivo);
|
||||
|
||||
$prefijo = substr(md5(uniqid(rand())),0,3);
|
||||
$time = time();
|
||||
|
||||
if($archivo != "") {
|
||||
|
||||
$fileName = $productoId.'_'.$time.'.'.$nom[1];
|
||||
|
||||
$destino = $ruta.'/'.$fileName;
|
||||
if (move_uploaded_file($_FILES['imagen']['tmp_name'],$destino)) {
|
||||
|
||||
//Eliminamos el archivo anterior
|
||||
|
||||
$infP = $producto->Info();
|
||||
@unlink(DOC_ROOT.'/images/productos/'.$infP['imagen']);
|
||||
|
||||
$producto->setImagen('');
|
||||
$producto->UpdateImagen();
|
||||
|
||||
//Actualizamos con el nuevo archivo
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$producto->setImagen($fileName);
|
||||
$producto->UpdateImagen();
|
||||
|
||||
}
|
||||
|
||||
}//if
|
||||
|
||||
$_SESSION['msgP'] = 'Updated';
|
||||
|
||||
header('Location: '.WEB_ROOT.'/productos');
|
||||
exit;
|
||||
|
||||
}//if
|
||||
|
||||
$productoId = $_GET['id'];
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$info = $producto->Info();
|
||||
//$info = $util->DecodeRow($info);
|
||||
|
||||
$proveedor->setProveedorId($info['proveedorId']);
|
||||
$info['proveedor'] = $proveedor->GetNameById();
|
||||
|
||||
$porcUtilidad = ($info['utilidad'] * 100) / $info['costo'];
|
||||
$info['porcUtilidad'] = number_format($porcUtilidad,2,'.',',');
|
||||
|
||||
$categorias = $prodCat->EnumerateAll();
|
||||
$proveedores = $proveedor->EnumerateAll();
|
||||
$temporadas = $temporada->EnumerateAll();
|
||||
$materiales = $material->EnumerateAll();
|
||||
|
||||
//Obtenemos las Tallas
|
||||
|
||||
$conValor->setConTallaId($info['conTallaId']);
|
||||
$resTallas = $conValor->EnumerateAll();
|
||||
|
||||
$tallas = array();
|
||||
foreach($resTallas as $res){
|
||||
|
||||
$atribVal->setAtribValId($res['tallaId']);
|
||||
$res['nombre'] = $atribVal->GetNameById();
|
||||
|
||||
$producto->setTallaId($res['tallaId']);
|
||||
if($producto->ExistTalla())
|
||||
$res['checked'] = 1;
|
||||
else
|
||||
$res['checked'] = 0;
|
||||
|
||||
$tallas[] = $res;
|
||||
}
|
||||
|
||||
$atribVal->setAtributoId(2);
|
||||
$resColores = $atribVal->EnumerateAll();
|
||||
|
||||
$conTallas = $conTalla->EnumerateAll();
|
||||
|
||||
//Obtenemos los Colores
|
||||
|
||||
$colores = array();
|
||||
foreach($resColores as $res){
|
||||
|
||||
$producto->setColorId($res['atribValId']);
|
||||
if($producto->ExistColor())
|
||||
$res['exist'] = 1;
|
||||
else
|
||||
$res['exist'] = 0;
|
||||
|
||||
$colores[] = $res;
|
||||
}
|
||||
|
||||
//Obtenemos los Atributos
|
||||
|
||||
$prodSubcat->setProdSubcatId($info['prodSubcatId']);
|
||||
$resAtributos = $prodSubcat->EnumAtributos();
|
||||
|
||||
$atributos = array();
|
||||
foreach($resAtributos as $res){
|
||||
|
||||
$atributo->setAtributoId($res['atributoId']);
|
||||
$res['nombre'] = $atributo->GetNameById();
|
||||
|
||||
$atribVal->setAtributoId($res['atributoId']);
|
||||
$resValores = $atribVal->EnumerateAll();
|
||||
|
||||
$valores = array();
|
||||
foreach($resValores as $val){
|
||||
|
||||
$producto->setAtribValId($val['atribValId']);
|
||||
if($producto->ExistAtributo())
|
||||
$val['exist'] = 1;
|
||||
else
|
||||
$val['exist'] = 0;
|
||||
|
||||
$valores[] = $val;
|
||||
}
|
||||
|
||||
$res['valores'] = $valores;
|
||||
|
||||
$atributos[] = $res;
|
||||
}
|
||||
|
||||
//Obtenemos los Codigos de Barra
|
||||
|
||||
$resCodigos = $producto->GetCodigosBarra();
|
||||
foreach($resCodigos as $res){
|
||||
|
||||
$card = $res;
|
||||
|
||||
$atribVal->setAtribValId($res['tallaId']);
|
||||
$nomTalla = $atribVal->GetNameById();
|
||||
|
||||
$atribVal->setAtribValId($res['colorId']);
|
||||
$card['nombre'] = $nomTalla.' '.$atribVal->GetNameById();
|
||||
$card['codigo'] = $res['codigoBarra'];
|
||||
|
||||
$codigos[] = $card;
|
||||
|
||||
}
|
||||
|
||||
//Obtenemos las subcategorias
|
||||
|
||||
$prodSubcat->setProdCatId($info['prodCatId']);
|
||||
$subcategorias = $prodSubcat->EnumerateAll();
|
||||
|
||||
//Obtenemos los materiales del Producto
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$prodMats = $producto->GetMaterials();
|
||||
|
||||
$_SESSION['prodMats'] = $prodMats;
|
||||
|
||||
$smarty->assign('info', $info);
|
||||
$smarty->assign('tallas', $tallas);
|
||||
$smarty->assign('conTallas', $conTallas);
|
||||
$smarty->assign('colores', $colores);
|
||||
$smarty->assign('codigos', $codigos);
|
||||
$smarty->assign('prodMats', $prodMats);
|
||||
$smarty->assign('atributos', $atributos);
|
||||
$smarty->assign('categorias', $categorias);
|
||||
$smarty->assign('subcategorias', $subcategorias);
|
||||
$smarty->assign('temporadas', $temporadas);
|
||||
$smarty->assign('proveedores', $proveedores);
|
||||
$smarty->assign('materiales', $materiales);
|
||||
|
||||
?>
|
||||
40
modules/productos.php
Executable file
40
modules/productos.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$producto->SetPage($_GET["p"]);
|
||||
$productos = $producto->Enumerate();
|
||||
|
||||
$items = array();
|
||||
foreach($productos['items'] as $res){
|
||||
|
||||
$proveedor->setProveedorId($res['proveedorId']);
|
||||
$infPv = $proveedor->Info();
|
||||
|
||||
$res['proveedor'] = $infPv['nombre'];
|
||||
$res['noProv'] = $infPv['noProv'];
|
||||
|
||||
$prodCat->setProdCatId($res['prodCatId']);
|
||||
$res['departamento'] = $prodCat->GetNameById();
|
||||
|
||||
if($res['prodSubcatId']){
|
||||
$prodSubcat->setProdSubcatId($res['prodSubcatId']);
|
||||
$res['linea'] = $prodSubcat->GetNameById();
|
||||
}
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$productos['items'] = $items;
|
||||
|
||||
$categorias = $prodCat->EnumerateAll();
|
||||
$proveedores = $proveedor->EnumerateAll();
|
||||
|
||||
$msg = $_SESSION['msgP'];
|
||||
$_SESSION['msgP'] = '';
|
||||
|
||||
$smarty->assign('msg', $msg);
|
||||
$smarty->assign('categorias', $categorias);
|
||||
$smarty->assign('proveedores', $proveedores);
|
||||
$smarty->assign('productos', $productos);
|
||||
|
||||
?>
|
||||
10
modules/promociones.php
Executable file
10
modules/promociones.php
Executable file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$promocion->setPage($_GET["p"]);
|
||||
$promociones = $promocion->Enumerate();
|
||||
|
||||
$smarty->assign('promociones', $promociones);
|
||||
|
||||
?>
|
||||
15
modules/proveedores.php
Executable file
15
modules/proveedores.php
Executable file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($Usr['type'] == 'compras'){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$proveedor->SetPage($_GET["p"]);
|
||||
$proveedores = $proveedor->Enumerate();
|
||||
|
||||
$smarty->assign("proveedores", $proveedores);
|
||||
|
||||
?>
|
||||
6
modules/redirect.php
Executable file
6
modules/redirect.php
Executable file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
print_r($_GET);
|
||||
exit;
|
||||
|
||||
?>
|
||||
22
modules/reportes-compras.php
Executable file
22
modules/reportes-compras.php
Executable file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
$empresa->AuthUser();
|
||||
if($Usr['type'] != 'admin')
|
||||
{
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$reportes->SetPage($_GET["p"]);
|
||||
|
||||
$dateNow=$reportes->dateNow();
|
||||
$smarty->assign("dateNow",$dateNow);
|
||||
if($Usr['type']=="admin")
|
||||
{
|
||||
$smarty->assign("tipo","admin");
|
||||
$resSuc=$reportes->enumsucursales();
|
||||
$resSuc=$util->DecodeUrlResult($resSuc);
|
||||
$smarty->assign("resSuc",$resSuc);
|
||||
}
|
||||
}
|
||||
?>
|
||||
16
modules/reportes-cuentaspagar.php
Executable file
16
modules/reportes-cuentaspagar.php
Executable file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
$empresa->AuthUser();
|
||||
if($Usr['type'] != 'admin')
|
||||
{
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$reportes->SetPage($_GET["p"]);
|
||||
}
|
||||
$dateNow=$reportes->dateNow();
|
||||
$smarty->assign("dateNow",$dateNow);
|
||||
$resProveedor=$reportes->proveedores();
|
||||
$smarty->assign("resProveedor",$resProveedor);
|
||||
?>
|
||||
15
modules/reportes-devcedis.php
Executable file
15
modules/reportes-devcedis.php
Executable file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$fechaHoy = date('d-m-Y');
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$resSuc2 = $util->DecodeUrlResult($resSuc);
|
||||
$sucursals = $util->DecodeResult($resSuc2);
|
||||
|
||||
$smarty->assign('fechaHoy',$fechaHoy);
|
||||
$smarty->assign('sucursals',$sucursals);
|
||||
$smarty->assign('devoluciones',$devoluciones);
|
||||
|
||||
?>
|
||||
16
modules/reportes-faltantes.php
Executable file
16
modules/reportes-faltantes.php
Executable file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($Usr['type'] != 'admin' && $Usr['type'] != 'centralizador' && $Usr['type'] != 'compras' && $Usr['type'] != 'direccion' && $Usr['type'] != 'supervisor'){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$departamentos = $prodCat->EnumerateAll();
|
||||
$proveedores2 = $reportes->proveedores();
|
||||
|
||||
$smarty->assign('tipo', $Usr['type']);
|
||||
$smarty->assign('proveedores2',$proveedores2);
|
||||
|
||||
?>
|
||||
23
modules/reportes-inventario.php
Executable file
23
modules/reportes-inventario.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($Usr['type'] != 'admin' && $Usr['type'] != 'centralizador' && $Usr['type'] != 'compras' && $Usr['type'] != 'direccion' && $Usr['type'] != 'supervisor'){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$reportes->setIdSuc($Usr['sucursalId']);
|
||||
$resSuc = $reportes->EnumSucursales($Usr['type'],$Usr['usuarioId']);
|
||||
$resSuc = $util->DecodeUrlResult($resSuc);
|
||||
|
||||
$departamentos = $prodCat->EnumerateAll();
|
||||
$proveedores = $reportes->proveedores();
|
||||
|
||||
$smarty->assign('tipo', $Usr['type']);
|
||||
$smarty->assign('resSuc',$resSuc);
|
||||
$smarty->assign('productos',$data);
|
||||
$smarty->assign('departamentos', $departamentos);
|
||||
$smarty->assign('proveedores',$proveedores);
|
||||
|
||||
?>
|
||||
85
modules/reportes-invparcial-detalles.php
Executable file
85
modules/reportes-invparcial-detalles.php
Executable file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($Usr['type'] != 'admin'){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$inventario->setRepInvParcialId($_GET['id']);
|
||||
$infR = $inventario->InfoInvParcialById();
|
||||
|
||||
$sucursalId = $infR['sucursalId'];
|
||||
|
||||
$sucursal->setSucursalId($sucursalId);
|
||||
$infR['sucursal'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$resProductos = $inventario->GetProdsByReport();
|
||||
|
||||
$totalIng = 0;
|
||||
$totalreal = 0;
|
||||
$items = array();
|
||||
foreach($resProductos as $res){
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$infP = $producto->Info();
|
||||
|
||||
$modelo = $infP['codigoBarra'].'<br>';
|
||||
$modelo .= $infP['modelo'];
|
||||
|
||||
$res['modelo'] = $modelo;
|
||||
|
||||
$proveedor->setProveedorId($infP['proveedorId']);
|
||||
$res['proveedor'] = $proveedor->GetNameById();
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$resTallas = $producto->GetTallas();
|
||||
|
||||
$tallas = array();
|
||||
foreach($resTallas as $val){
|
||||
$atribVal->setAtribValId($val['tallaId']);
|
||||
$tallas[] = $atribVal->GetNameById();
|
||||
}
|
||||
|
||||
$res['talla'] = implode(', ',$tallas);
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$resColores = $producto->GetColores();
|
||||
|
||||
$colores = array();
|
||||
foreach($resColores as $val){
|
||||
$atribVal->setAtribValId($val['colorId']);
|
||||
$colores[] = $atribVal->GetNameById();
|
||||
}
|
||||
|
||||
$res['color'] = implode(', ',$colores);
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$resAtributos = $producto->GetAtributos();
|
||||
|
||||
$atributos = array();
|
||||
foreach($resAtributos as $val){
|
||||
$atribVal->setAtribValId($val['atribValId']);
|
||||
$atributos[] = $atribVal->GetNameById();
|
||||
}
|
||||
|
||||
$res['atributos'] = implode(', ',$atributos);
|
||||
|
||||
$totalIng += $res['cantidad'];
|
||||
$totalReal += $res['cantReal'];
|
||||
|
||||
$items[] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
$productos['items'] = $items;
|
||||
|
||||
$totales['ingresada'] = $totalIng;
|
||||
$totales['real'] = $totalReal;
|
||||
|
||||
$smarty->assign('infR',$infR);
|
||||
$smarty->assign('totales',$totales);
|
||||
$smarty->assign('productos',$productos);
|
||||
|
||||
?>
|
||||
36
modules/reportes-invparcial.php
Executable file
36
modules/reportes-invparcial.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($Usr['type'] != 'admin'){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$inventario->setPage($_GET['p']);
|
||||
$reportesInv = $inventario->EnumReporteParcial();
|
||||
|
||||
if(count($reportesInv['items']))
|
||||
$reportesInv['items'] = $util->EncodeResult($reportesInv['items']);
|
||||
|
||||
$items = array();
|
||||
foreach($reportesInv['items'] as $res){
|
||||
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$res['sucursal'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$items[] = $res;
|
||||
}
|
||||
$reportesInv['items'] = $items;
|
||||
|
||||
$smarty->assign("reportesInv", $reportesInv);
|
||||
|
||||
/*
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$resSuc2 = $util->DecodeUrlResult($resSuc);
|
||||
$sucursales = $util->DecodeResult($resSuc2);
|
||||
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
*/
|
||||
|
||||
?>
|
||||
12
modules/reportes-tickets.php
Executable file
12
modules/reportes-tickets.php
Executable file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if($Usr['type'] != 'admin' && $Usr['type'] != 'centralizador' && $Usr['type'] != 'direccion' && $Usr['type'] != 'compras' && $Usr['type'] != 'supervisor'){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$smarty->assign('view',$_GET['view']);
|
||||
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user