Primer commit del sistema avantika sin cambios
This commit is contained in:
26
crons/liberar-productos.php
Executable file
26
crons/liberar-productos.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
include_once('/home/novomoda/public_html/sistema/init.php');
|
||||
include_once('/home/novomoda/public_html/sistema/config.php');
|
||||
|
||||
session_start();
|
||||
|
||||
if(!isset($_SESSION['empresaId']))
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
$sucursal->setRfcId(1);
|
||||
$sucursales = $sucursal->GetSucursalesByRfc();
|
||||
|
||||
foreach($sucursales as $res){
|
||||
|
||||
$sucursalId = $res['sucursalId'];
|
||||
|
||||
$venta->setSucursalId($sucursalId);
|
||||
$venta->LiberarProductos();
|
||||
|
||||
}
|
||||
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
2
crons/liberar-productos.txt
Executable file
2
crons/liberar-productos.txt
Executable file
@@ -0,0 +1,2 @@
|
||||
|
||||
Fatal error: Call to a member function setRfcId() on a non-object in /home/novomoda/domains/novomoda.com.mx/public_html/sistema/crons/liberar-productos.php on line 11
|
||||
348
crons/rep-prods-prov-original.php
Executable file
348
crons/rep-prods-prov-original.php
Executable file
@@ -0,0 +1,348 @@
|
||||
<?php
|
||||
|
||||
include_once('../init.php');
|
||||
|
||||
include_once('../config.php');
|
||||
include_once(DOC_ROOT.'/libraries.php');
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
$start = microtime(true);
|
||||
|
||||
/**
|
||||
Ejecuta TODOS los proveedores, sucursales y desde el 01-06-2013
|
||||
*/
|
||||
|
||||
$mesI = '06';
|
||||
$anioI = 2013;
|
||||
$mesF = date('m');
|
||||
$anioF = date('Y');
|
||||
$codigoBarra = trim($_POST['codigoBarra']);
|
||||
|
||||
$nomMes = $util->GetMMMName(intval($mesI));
|
||||
$perIni = $nomMes.' '.$anioI;
|
||||
$nomMes = $util->GetMMMName(intval($mesF));
|
||||
$perFin = $nomMes.' '.$anioF;
|
||||
|
||||
if($codigoBarra != ''){
|
||||
$producto->setCodigoBarra($codigoBarra);
|
||||
$productoId = $producto->GetProductIdByCodigo();
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$infP = $producto->Info();
|
||||
$proveedorId = $infP['proveedorId'];
|
||||
}
|
||||
|
||||
$mI = intval($mesI);
|
||||
$mF = intval($mesF);
|
||||
|
||||
$yI = $anioI;
|
||||
$yF = $anioF;
|
||||
|
||||
$anios = $yF - $yI;
|
||||
|
||||
if($anios == 0){
|
||||
$meses = $mF - $mI;
|
||||
$meses += 1;
|
||||
}else{
|
||||
$meses = (12 - $mI) + 1 + $mF;
|
||||
}
|
||||
|
||||
$sql = 'SELECT proveedorId FROM proveedor WHERE proveedorId = 111';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
foreach($proveedores as $prov){
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
$proveedorId = $prov['proveedorId'];
|
||||
|
||||
$reportes->setIdSuc(0);
|
||||
$resSuc = $reportes->EnumSucursales();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $suc){
|
||||
|
||||
$sucursalId = $suc['sucursalId'];
|
||||
|
||||
$producto->setProveedorId($proveedorId);
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM producto
|
||||
WHERE baja = '0'
|
||||
AND proveedorId = '".$proveedorId."'
|
||||
ORDER BY descripcion
|
||||
LIMIT 10";
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$resProds = $util->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$proveedor->setProveedorId($proveedorId);
|
||||
$nomProv = $proveedor->GetNameById();
|
||||
|
||||
$strFechaI = strtotime('01-'.$mesI.'-'.$anioI);
|
||||
|
||||
$totPzas = 0;
|
||||
$totImporte = 0;
|
||||
$totVtas = 0;
|
||||
$totImporteVtas = 0;
|
||||
$totIniciales = array();
|
||||
$totEntradas = array();
|
||||
$totSalidas = array();
|
||||
$productos = array();
|
||||
$resCategorias = array();
|
||||
$resSubcats = array();
|
||||
foreach($resProds as $res){
|
||||
|
||||
$prodCatId = $res['prodCatId'];
|
||||
$prodSubcatId = $res['prodSubcatId'];
|
||||
|
||||
if($productoId > 0 && $res['productoId'] != $productoId)
|
||||
continue;
|
||||
|
||||
if(!in_array($prodCatId, $resCategorias)){
|
||||
$resCategorias[] = $prodCatId;
|
||||
}
|
||||
|
||||
if(count($resSubcats[$prodCatId]) == 0)
|
||||
$resSubcats[$prodCatId] = array();
|
||||
|
||||
$resSub = $resSubcats[$prodCatId];
|
||||
|
||||
if(!in_array($prodSubcatId, $resSub)){
|
||||
$resSubcats[$prodCatId][] = $prodSubcatId;
|
||||
}
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$infP = $producto->Info();
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$res['fecha'] = $producto->GetFechaUltCompra();
|
||||
|
||||
if($res['fecha'] == 0)
|
||||
continue;
|
||||
|
||||
$res['modelo'] = utf8_encode($res['modelo']);
|
||||
|
||||
//Obtenemos el Saldo Inicial
|
||||
$fechaII = '2013-06-01';
|
||||
|
||||
$strFF = date('Y-m-01',$strFechaI);
|
||||
$strFF = strtotime($strFF);
|
||||
$fechaFF = date('Y-m-d',strtotime('-1 day',$strFF));
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$producto->setFechaIni($fechaII);
|
||||
$producto->setFechaFin($fechaFF);
|
||||
|
||||
$producto->setSucursalId($sucursalId);
|
||||
$cantSalidaI = $producto->GetCantVendidoOld();
|
||||
$cantSalidaI += $producto->GetSalEnvTTOld();
|
||||
|
||||
$cantEntradaI = $producto->GetCantTotalCompBySucOld();
|
||||
$cantEntradaI += $producto->GetEntEnvTT();
|
||||
|
||||
$cantEntradaAI = $producto->GetEntAjusteEnvOld();
|
||||
$cantSalidaAI = $producto->GetSalAjusteEnv();
|
||||
|
||||
$cantInicial = $cantEntradaI - $cantSalidaI + $cantEntradaAI - $cantSalidaAI;
|
||||
|
||||
$totalVtas = 0;
|
||||
$mostrar = false;
|
||||
$totalPzas = 0;
|
||||
$iniciales = array();
|
||||
$entradas = array();
|
||||
$salidas = array();
|
||||
for($m=0; $m<$meses; $m++){
|
||||
|
||||
$fechaIni = date('Y-m-01',strtotime('+'.$m.' month',$strFechaI));
|
||||
$fechaFin = date('Y-m-31',strtotime('+'.$m.' month',$strFechaI));
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$producto->setFechaIni($fechaIni);
|
||||
$producto->setFechaFin($fechaFin);
|
||||
|
||||
$producto->setSucursalId($sucursalId);
|
||||
$cantSalida = $producto->GetCantVendidoOld();
|
||||
|
||||
$cantSalidaVtas = $cantSalida;
|
||||
|
||||
$totalVtas += $cantSalida;
|
||||
|
||||
$cantSalida += $producto->GetSalEnvTTOld();
|
||||
|
||||
$cantEntrada = $producto->GetCantTotalCompBySucOld();
|
||||
$cantEntrada += $producto->GetEntEnvTT();
|
||||
|
||||
$cantEntradaA = $producto->GetEntAjusteEnvOld();
|
||||
$cantSalidaA = $producto->GetSalAjusteEnv();
|
||||
|
||||
//$cantEntradaA += $producto->GetEntAjusteExcel();
|
||||
|
||||
$totalPzas = ($cantInicial + $cantEntrada - $cantSalida + $cantEntradaA - $cantSalidaA);
|
||||
|
||||
$totSubs[$prodSubcatId][$m]['inicial'] += $cantInicial;
|
||||
$totSubs[$prodSubcatId][$m]['entradas'] += $cantEntrada;
|
||||
$totSubs[$prodSubcatId][$m]['salidas'] += $cantSalida;
|
||||
$totSubs[$prodSubcatId][$m]['entradasA'] += $cantEntradaA;
|
||||
$totSubs[$prodSubcatId][$m]['salidasA'] += $cantSalidaA;
|
||||
|
||||
$totCats[$prodCatId][$m]['inicial'] += $cantInicial;
|
||||
$totCats[$prodCatId][$m]['entradas'] += $cantEntrada;
|
||||
$totCats[$prodCatId][$m]['salidas'] += $cantSalida;
|
||||
$totCats[$prodCatId][$m]['entradasA'] += $cantEntradaA;
|
||||
$totCats[$prodCatId][$m]['salidasA'] += $cantSalidaA;
|
||||
|
||||
if($cantEntrada > 0 || $cantEntradaA > 0 || $cantInicial > 0)
|
||||
$mostrar = true;
|
||||
|
||||
if($cantSalida > 0 || $cantSalidaA > 0 || $cantInicial > 0)
|
||||
$mostrar = true;
|
||||
|
||||
if($mostrar == true){
|
||||
$iniciales[$m] = $cantInicial;
|
||||
$entradas[$m] = $cantEntrada;
|
||||
$salidas[$m] = $cantSalida;
|
||||
$entradasA[$m] = $cantEntradaA;
|
||||
$salidasA[$m] = $cantSalidaA;
|
||||
|
||||
$salidasVtas[$m] = $cantSalidaVtas;
|
||||
|
||||
$totIniciales[$m] += $cantInicial;
|
||||
$totEntradas[$m] += $cantEntrada;
|
||||
$totSalidas[$m] += $cantSalida;
|
||||
$totEntradasA[$m] += $cantEntradaA;
|
||||
$totSalidasA[$m] += $cantSalidaA;
|
||||
}else{
|
||||
$iniciales[$m] = 0;
|
||||
$entradas[$m] = 0;
|
||||
$salidas[$m] = 0;
|
||||
$entradasA[$m] = 0;
|
||||
$salidasA[$m] = 0;
|
||||
|
||||
$salidasVtas[$m] = 0;
|
||||
}
|
||||
|
||||
$cantInicial = $cantInicial + $cantEntrada - $cantSalida + $cantEntradaA - $cantSalidaA;
|
||||
|
||||
}//for
|
||||
|
||||
$res['iniciales'] = $iniciales;
|
||||
$res['entradas'] = $entradas;
|
||||
$res['salidas'] = $salidas;
|
||||
$res['salidasVtas'] = $salidasVtas;
|
||||
$res['entradasA'] = $entradasA;
|
||||
$res['salidasA'] = $salidasA;
|
||||
$res['totalPzas'] = $totalPzas;
|
||||
$res['proveedor'] = $nomProv;
|
||||
|
||||
$res['importe'] = $res['costo'] * $totalPzas;
|
||||
|
||||
$res['totalVtas'] = $totalVtas;
|
||||
$res['precioVta'] = $infP['precioVentaIva'];
|
||||
$res['importeVtas'] = $totalVtas * $infP['precioVentaIva'];
|
||||
|
||||
$totSubs[$prodSubcatId]['totalPzas'] += $totalPzas;
|
||||
$totCats[$prodCatId]['totalPzas'] += $totalPzas;
|
||||
$totSubs[$prodSubcatId]['importe'] += $res['importe'];
|
||||
$totCats[$prodCatId]['importe'] += $res['importe'];
|
||||
|
||||
$totSubs[$prodSubcatId]['totalVtas'] += $totalVtas;
|
||||
$totCats[$prodCatId]['totalVtas'] += $totalVtas;
|
||||
$totSubs[$prodSubcatId]['importeVtas'] += $res['importeVtas'];
|
||||
$totCats[$prodCatId]['importeVtas'] += $res['importeVtas'];
|
||||
|
||||
$res['prodCatId'] = $infP['prodCatId'];
|
||||
$res['prodSubcatId'] = $infP['prodSubcatId'];
|
||||
|
||||
if($mostrar == true){
|
||||
$totPzas += $totalPzas;
|
||||
$totImporte += $res['importe'];
|
||||
|
||||
$totVtas += $totalVtas;
|
||||
$totImporteVtas += $res['importeVtas'];
|
||||
|
||||
$productos[$prodCatId][$prodSubcatId][] = $res;
|
||||
}
|
||||
|
||||
}//foreach
|
||||
|
||||
$categorias = array();
|
||||
foreach($resCategorias as $prodCatId){
|
||||
$card['prodCatId'] = $prodCatId;
|
||||
$prodCat->setProdCatId($prodCatId);
|
||||
$card['nombre'] = utf8_encode($prodCat->GetNameById());
|
||||
$categorias[] = $card;
|
||||
}
|
||||
|
||||
$subcategorias = array();
|
||||
foreach($resSubcats as $prodCatId => $subcats){
|
||||
$card = array();
|
||||
$subcats2 = array();
|
||||
foreach($subcats as $prodSubcatId){
|
||||
$card['prodSubcatId'] = $prodSubcatId;
|
||||
$prodSubcat->setProdSubcatId($prodSubcatId);
|
||||
$card['nombre'] = utf8_encode($prodSubcat->GetNameById());
|
||||
$subcats2[] = $card;
|
||||
}
|
||||
|
||||
$subcategorias[$prodCatId] = $subcats2;
|
||||
|
||||
}
|
||||
|
||||
$suc['productos'] = $productos;
|
||||
$suc['categorias'] = $categorias;
|
||||
$suc['subcategorias'] = $subcategorias;
|
||||
$suc['totSubs'] = $totSubs;
|
||||
$suc['totCats'] = $totCats;
|
||||
|
||||
$suc['totIniciales'] = $totIniciales;
|
||||
$suc['totEntradas'] = $totEntradas;
|
||||
$suc['totSalidas'] = $totSalidas;
|
||||
$suc['totEntradasA'] = $totEntradasA;
|
||||
$suc['totSalidasA'] = $totSalidasA;
|
||||
$suc['totPzas'] = $totPzas;
|
||||
$suc['totImporte'] = $totImporte;
|
||||
$suc['totVtas'] = $totVtas;
|
||||
$suc['totImporteVtas'] = $totImporteVtas;
|
||||
|
||||
$sucursales[] = $suc;
|
||||
|
||||
}//foreach
|
||||
|
||||
//****
|
||||
|
||||
$serialize = urlencode(serialize($sucursales));
|
||||
|
||||
$sql = "REPLACE INTO `reporteProvBest` (
|
||||
`proveedorId` ,
|
||||
`fecha` ,
|
||||
`reporte` ,
|
||||
`sucursal`
|
||||
)
|
||||
VALUES (
|
||||
'".$proveedorId."',
|
||||
'".date("Y-m-d H:i:s")."',
|
||||
'".$serialize."',
|
||||
'')"
|
||||
;
|
||||
//$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
//$util->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
}//foreach
|
||||
|
||||
echo 'Done';
|
||||
|
||||
$end = microtime(true);
|
||||
echo "Tiempo de Ejecucion: ";
|
||||
echo $time = number_format(($end - $start), 2);
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
332
crons/rep-prods-prov-single.php
Executable file
332
crons/rep-prods-prov-single.php
Executable file
@@ -0,0 +1,332 @@
|
||||
<?php
|
||||
|
||||
include_once('/home/novomoda/public_html/sistema/init.php');
|
||||
include_once('/home/novomoda/public_html/sistema/config.php');
|
||||
include_once(DOC_ROOT.'/libraries.php');
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
$start = microtime(true);
|
||||
|
||||
/**
|
||||
Ejecuta TODOS los proveedores, sucursales y desde el 01-06-2013
|
||||
*/
|
||||
|
||||
$mesI = '06';
|
||||
$anioI = 2013;
|
||||
$mesF = date('m');
|
||||
$anioF = date('Y');
|
||||
$codigoBarra = trim($_POST['codigoBarra']);
|
||||
|
||||
$nomMes = $util->GetMMMName(intval($mesI));
|
||||
$perIni = $nomMes.' '.$anioI;
|
||||
$nomMes = $util->GetMMMName(intval($mesF));
|
||||
$perFin = $nomMes.' '.$anioF;
|
||||
|
||||
$mI = intval($mesI);
|
||||
$mF = intval($mesF);
|
||||
|
||||
$yI = $anioI;
|
||||
$yF = $anioF;
|
||||
|
||||
$anios = $yF - $yI;
|
||||
|
||||
if($anios == 0){
|
||||
$meses = $mF - $mI;
|
||||
$meses += 1;
|
||||
}else{
|
||||
$meses = (12 - $mI) + 1 + $mF;
|
||||
}
|
||||
|
||||
$strFechaI = strtotime('01-'.$mesI.'-'.$anioI);
|
||||
|
||||
$sql = 'SELECT proveedorId FROM proveedor WHERE proveedorId = 111';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
foreach($proveedores as $prov){
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
echo $proveedorId = $prov['proveedorId'];
|
||||
echo '<br><br>';
|
||||
|
||||
$proveedor->setProveedorId($proveedorId);
|
||||
$nomProv = $proveedor->GetNameById();
|
||||
|
||||
$reportes->setIdSuc(0);
|
||||
$resSuc = $reportes->EnumSucursales();
|
||||
|
||||
$sql = "SELECT p.productoId, p.precioVentaIva, p.prodCatId, p.prodSubcatId, p.modelo, p.codigoBarra, p.costo,
|
||||
p.proveedorId,
|
||||
(
|
||||
SELECT ped.fechaOrdenCompIng
|
||||
FROM pedido AS ped, pedidoProducto AS pp
|
||||
WHERE ped.pedidoId = pp.pedidoId
|
||||
AND pp.productoId = p.productoId
|
||||
ORDER BY ped.fechaOrdenCompIng DESC
|
||||
LIMIT 1
|
||||
) AS fecha
|
||||
FROM producto p
|
||||
WHERE p.baja = '0'
|
||||
AND p.proveedorId = '".$proveedorId."'
|
||||
ORDER BY p.descripcion";
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$resProds = $util->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $suc){
|
||||
|
||||
$sucursalId = $suc['sucursalId'];
|
||||
|
||||
echo 'Suc = '.$sucursalId;
|
||||
echo '<br>';
|
||||
|
||||
$totPzas = 0;
|
||||
$totImporte = 0;
|
||||
$totVtas = 0;
|
||||
$totImporteVtas = 0;
|
||||
$totIniciales = array();
|
||||
$totEntradas = array();
|
||||
$totSalidas = array();
|
||||
$productos = array();
|
||||
$resCategorias = array();
|
||||
$resSubcats = array();
|
||||
foreach($resProds as $res){
|
||||
|
||||
$prodCatId = $res['prodCatId'];
|
||||
$prodSubcatId = $res['prodSubcatId'];
|
||||
|
||||
if($productoId > 0 && $res['productoId'] != $productoId)
|
||||
continue;
|
||||
|
||||
if(!in_array($prodCatId, $resCategorias))
|
||||
$resCategorias[] = $prodCatId;
|
||||
|
||||
if(count($resSubcats[$prodCatId]) == 0)
|
||||
$resSubcats[$prodCatId] = array();
|
||||
|
||||
$resSub = $resSubcats[$prodCatId];
|
||||
|
||||
if(!in_array($prodSubcatId, $resSub))
|
||||
$resSubcats[$prodCatId][] = $prodSubcatId;
|
||||
|
||||
if($res['fecha'] == 0)
|
||||
continue;
|
||||
|
||||
echo $res['productoId'];
|
||||
echo '<br>';
|
||||
|
||||
$res['modelo'] = utf8_encode($res['modelo']);
|
||||
|
||||
//Obtenemos el Saldo Inicial
|
||||
$fechaII = '2013-06-01';
|
||||
|
||||
$cantInicial = 0;
|
||||
$totalVtas = 0;
|
||||
$mostrar = false;
|
||||
$totalPzas = 0;
|
||||
$iniciales = array();
|
||||
$entradas = array();
|
||||
$salidas = array();
|
||||
for($m=0; $m<$meses; $m++){
|
||||
|
||||
$fechaIni = date('Y-m-01',strtotime('+'.$m.' month',$strFechaI));
|
||||
$fechaFin = date('Y-m-31',strtotime('+'.$m.' month',$strFechaI));
|
||||
|
||||
echo ' ';
|
||||
echo $fechaIni.' - '.$fechaFin;
|
||||
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$producto->setFechaIni($fechaIni);
|
||||
$producto->setFechaFin($fechaFin);
|
||||
|
||||
$producto->setSucursalId($sucursalId);
|
||||
$cantSalida = $producto->GetCantVendido();
|
||||
|
||||
echo ' :: '.$cantSalida;
|
||||
echo '<br>';
|
||||
|
||||
$cantSalidaVtas = $cantSalida;
|
||||
|
||||
$totalVtas += $cantSalida;
|
||||
|
||||
$cantSalida += $producto->GetSalEnvTT();
|
||||
|
||||
$cantEntrada = $producto->GetCantTotalCompBySuc();
|
||||
$cantEntrada += $producto->GetEntEnvTT();
|
||||
|
||||
$cantEntradaA = $producto->GetEntAjusteEnv();
|
||||
|
||||
$cantSalidaA = $producto->GetSalAjusteEnv();
|
||||
|
||||
//$cantEntradaA += $producto->GetEntAjusteExcel();
|
||||
|
||||
$totalPzas = ($cantInicial + $cantEntrada - $cantSalida + $cantEntradaA - $cantSalidaA);
|
||||
|
||||
$totSubs[$prodSubcatId][$m]['inicial'] += $cantInicial;
|
||||
$totSubs[$prodSubcatId][$m]['entradas'] += $cantEntrada;
|
||||
$totSubs[$prodSubcatId][$m]['salidas'] += $cantSalida;
|
||||
$totSubs[$prodSubcatId][$m]['entradasA'] += $cantEntradaA;
|
||||
$totSubs[$prodSubcatId][$m]['salidasA'] += $cantSalidaA;
|
||||
|
||||
$totCats[$prodCatId][$m]['inicial'] += $cantInicial;
|
||||
$totCats[$prodCatId][$m]['entradas'] += $cantEntrada;
|
||||
$totCats[$prodCatId][$m]['salidas'] += $cantSalida;
|
||||
$totCats[$prodCatId][$m]['entradasA'] += $cantEntradaA;
|
||||
$totCats[$prodCatId][$m]['salidasA'] += $cantSalidaA;
|
||||
|
||||
if($cantEntrada > 0 || $cantEntradaA > 0 || $cantInicial > 0)
|
||||
$mostrar = true;
|
||||
|
||||
if($cantSalida > 0 || $cantSalidaA > 0 || $cantInicial > 0)
|
||||
$mostrar = true;
|
||||
|
||||
if($mostrar == true){
|
||||
$iniciales[$m] = $cantInicial;
|
||||
$entradas[$m] = $cantEntrada;
|
||||
$salidas[$m] = $cantSalida;
|
||||
$entradasA[$m] = $cantEntradaA;
|
||||
$salidasA[$m] = $cantSalidaA;
|
||||
|
||||
$salidasVtas[$m] = $cantSalidaVtas;
|
||||
|
||||
$totIniciales[$m] += $cantInicial;
|
||||
$totEntradas[$m] += $cantEntrada;
|
||||
$totSalidas[$m] += $cantSalida;
|
||||
$totEntradasA[$m] += $cantEntradaA;
|
||||
$totSalidasA[$m] += $cantSalidaA;
|
||||
}else{
|
||||
$iniciales[$m] = 0;
|
||||
$entradas[$m] = 0;
|
||||
$salidas[$m] = 0;
|
||||
$entradasA[$m] = 0;
|
||||
$salidasA[$m] = 0;
|
||||
|
||||
$salidasVtas[$m] = 0;
|
||||
}
|
||||
|
||||
$cantInicial = $cantInicial + $cantEntrada - $cantSalida + $cantEntradaA - $cantSalidaA;
|
||||
|
||||
}//for
|
||||
|
||||
$res['iniciales'] = $iniciales;
|
||||
$res['entradas'] = $entradas;
|
||||
$res['salidas'] = $salidas;
|
||||
$res['salidasVtas'] = $salidasVtas;
|
||||
$res['entradasA'] = $entradasA;
|
||||
$res['salidasA'] = $salidasA;
|
||||
$res['totalPzas'] = $totalPzas;
|
||||
$res['proveedor'] = $nomProv;
|
||||
|
||||
$res['importe'] = $res['costo'] * $totalPzas;
|
||||
|
||||
$res['totalVtas'] = $totalVtas;
|
||||
$res['precioVta'] = $infP['precioVentaIva'];
|
||||
$res['importeVtas'] = $totalVtas * $infP['precioVentaIva'];
|
||||
|
||||
$totSubs[$prodSubcatId]['totalPzas'] += $totalPzas;
|
||||
$totCats[$prodCatId]['totalPzas'] += $totalPzas;
|
||||
$totSubs[$prodSubcatId]['importe'] += $res['importe'];
|
||||
$totCats[$prodCatId]['importe'] += $res['importe'];
|
||||
|
||||
$totSubs[$prodSubcatId]['totalVtas'] += $totalVtas;
|
||||
$totCats[$prodCatId]['totalVtas'] += $totalVtas;
|
||||
$totSubs[$prodSubcatId]['importeVtas'] += $res['importeVtas'];
|
||||
$totCats[$prodCatId]['importeVtas'] += $res['importeVtas'];
|
||||
|
||||
$res['prodCatId'] = $infP['prodCatId'];
|
||||
$res['prodSubcatId'] = $infP['prodSubcatId'];
|
||||
|
||||
if($mostrar == true){
|
||||
$totPzas += $totalPzas;
|
||||
$totImporte += $res['importe'];
|
||||
|
||||
$totVtas += $totalVtas;
|
||||
$totImporteVtas += $res['importeVtas'];
|
||||
|
||||
$productos[$prodCatId][$prodSubcatId][] = $res;
|
||||
}
|
||||
|
||||
}//foreach
|
||||
|
||||
$categorias = array();
|
||||
foreach($resCategorias as $prodCatId){
|
||||
$card['prodCatId'] = $prodCatId;
|
||||
$prodCat->setProdCatId($prodCatId);
|
||||
$card['nombre'] = utf8_encode($prodCat->GetNameById());
|
||||
$categorias[] = $card;
|
||||
}
|
||||
|
||||
$subcategorias = array();
|
||||
foreach($resSubcats as $prodCatId => $subcats){
|
||||
$card = array();
|
||||
$subcats2 = array();
|
||||
foreach($subcats as $prodSubcatId){
|
||||
$card['prodSubcatId'] = $prodSubcatId;
|
||||
$prodSubcat->setProdSubcatId($prodSubcatId);
|
||||
$card['nombre'] = utf8_encode($prodSubcat->GetNameById());
|
||||
$subcats2[] = $card;
|
||||
}
|
||||
|
||||
$subcategorias[$prodCatId] = $subcats2;
|
||||
|
||||
}
|
||||
|
||||
$suc['productos'] = $productos;
|
||||
$suc['categorias'] = $categorias;
|
||||
$suc['subcategorias'] = $subcategorias;
|
||||
$suc['totSubs'] = $totSubs;
|
||||
$suc['totCats'] = $totCats;
|
||||
|
||||
$suc['totIniciales'] = $totIniciales;
|
||||
$suc['totEntradas'] = $totEntradas;
|
||||
$suc['totSalidas'] = $totSalidas;
|
||||
$suc['totEntradasA'] = $totEntradasA;
|
||||
$suc['totSalidasA'] = $totSalidasA;
|
||||
$suc['totPzas'] = $totPzas;
|
||||
$suc['totImporte'] = $totImporte;
|
||||
$suc['totVtas'] = $totVtas;
|
||||
$suc['totImporteVtas'] = $totImporteVtas;
|
||||
|
||||
$sucursales[] = $suc;
|
||||
|
||||
}//foreach
|
||||
|
||||
//****
|
||||
|
||||
$serialize = urlencode(serialize($sucursales));
|
||||
|
||||
$sql = "REPLACE INTO `reporteProvBest` (
|
||||
`proveedorId` ,
|
||||
`fecha` ,
|
||||
`reporte` ,
|
||||
`sucursal`
|
||||
)
|
||||
VALUES (
|
||||
'".$proveedorId."',
|
||||
'".date("Y-m-d H:i:s")."',
|
||||
'".$serialize."',
|
||||
'')"
|
||||
;
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$util->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
}//foreach
|
||||
|
||||
echo 'Done';
|
||||
|
||||
$end = microtime(true);
|
||||
echo "Tiempo de Ejecucion: ";
|
||||
echo $time = number_format(($end - $start), 2);
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
345
crons/rep-prods-prov.php
Executable file
345
crons/rep-prods-prov.php
Executable file
@@ -0,0 +1,345 @@
|
||||
<?php
|
||||
|
||||
include_once('/home/novomoda/public_html/sistema/init.php');
|
||||
include_once('/home/novomoda/public_html/sistema/config.php');
|
||||
include_once(DOC_ROOT.'/libraries.php');
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
/**
|
||||
Actualizamos las Fechas
|
||||
*/
|
||||
|
||||
$sql = 'UPDATE reporteProvBest SET fechaTemp = fecha';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$util->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
echo 'fechaTemp Actualizada';
|
||||
echo '<br>';
|
||||
|
||||
$start = microtime(true);
|
||||
|
||||
/**
|
||||
Ejecuta TODOS los proveedores, sucursales y desde el 01-06-2013
|
||||
*/
|
||||
|
||||
$mesI = '06';
|
||||
$anioI = 2013;
|
||||
$mesF = date('m');
|
||||
$anioF = date('Y');
|
||||
$codigoBarra = trim($_POST['codigoBarra']);
|
||||
|
||||
$nomMes = $util->GetMMMName(intval($mesI));
|
||||
$perIni = $nomMes.' '.$anioI;
|
||||
$nomMes = $util->GetMMMName(intval($mesF));
|
||||
$perFin = $nomMes.' '.$anioF;
|
||||
|
||||
$mI = intval($mesI);
|
||||
$mF = intval($mesF);
|
||||
|
||||
$yI = $anioI;
|
||||
$yF = $anioF;
|
||||
|
||||
$anios = $yF - $yI;
|
||||
|
||||
if($anios == 0){
|
||||
$meses = $mF - $mI;
|
||||
$meses += 1;
|
||||
}else{
|
||||
$meses = (12 - $mI) + 1 + $mF;
|
||||
}
|
||||
|
||||
$strFechaI = strtotime('01-'.$mesI.'-'.$anioI);
|
||||
|
||||
$sql = 'SELECT proveedor.proveedorId, reporteProvBest.fecha FROM proveedor
|
||||
LEFT JOIN reporteProvBest ON proveedor.proveedorId = reporteProvBest.proveedorId
|
||||
ORDER BY reporteProvBest.fechaTemp ASC
|
||||
LIMIT 0,40';
|
||||
|
||||
$sql = 'SELECT proveedor.proveedorId, reporteProvBest.fecha FROM proveedor
|
||||
LEFT JOIN reporteProvBest ON proveedor.proveedorId = reporteProvBest.proveedorId
|
||||
WHERE proveedor.proveedorId = 560';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
foreach($proveedores as $prov){
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
$proveedorId = $prov['proveedorId'];
|
||||
|
||||
$proveedor->setProveedorId($proveedorId);
|
||||
$nomProv = $proveedor->GetNameById();
|
||||
|
||||
$reportes->setIdSuc(0);
|
||||
$resSuc = $reportes->EnumSucursales();
|
||||
|
||||
$sql = "SELECT p.productoId, p.precioVentaIva, p.prodCatId, p.prodSubcatId, p.modelo, p.codigoBarra, p.costo,
|
||||
p.proveedorId,
|
||||
(
|
||||
SELECT ped.fechaOrdenCompIng
|
||||
FROM pedido AS ped, pedidoProducto AS pp
|
||||
WHERE ped.pedidoId = pp.pedidoId
|
||||
AND pp.productoId = p.productoId
|
||||
ORDER BY ped.fechaOrdenCompIng DESC
|
||||
LIMIT 1
|
||||
) AS fecha
|
||||
FROM producto p
|
||||
WHERE p.baja = '0'
|
||||
AND p.proveedorId = '".$proveedorId."'
|
||||
ORDER BY p.descripcion";
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$resProds = $util->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $suc){
|
||||
|
||||
$sucursalId = $suc['sucursalId'];
|
||||
|
||||
$totPzas = 0;
|
||||
$totImporte = 0;
|
||||
$totVtas = 0;
|
||||
$totImporteVtas = 0;
|
||||
$totIniciales = array();
|
||||
$totEntradas = array();
|
||||
$totSalidas = array();
|
||||
$productos = array();
|
||||
$resCategorias = array();
|
||||
$resSubcats = array();
|
||||
foreach($resProds as $res){
|
||||
|
||||
$prodCatId = $res['prodCatId'];
|
||||
$prodSubcatId = $res['prodSubcatId'];
|
||||
|
||||
if($productoId > 0 && $res['productoId'] != $productoId)
|
||||
continue;
|
||||
|
||||
if(!in_array($prodCatId, $resCategorias))
|
||||
$resCategorias[] = $prodCatId;
|
||||
|
||||
if(count($resSubcats[$prodCatId]) == 0)
|
||||
$resSubcats[$prodCatId] = array();
|
||||
|
||||
$resSub = $resSubcats[$prodCatId];
|
||||
|
||||
if(!in_array($prodSubcatId, $resSub))
|
||||
$resSubcats[$prodCatId][] = $prodSubcatId;
|
||||
|
||||
if($res['fecha'] == 0)
|
||||
continue;
|
||||
|
||||
$res['modelo'] = utf8_encode($res['modelo']);
|
||||
|
||||
//Obtenemos el Saldo Inicial
|
||||
$fechaII = '2013-06-01';
|
||||
|
||||
$cantInicial = 0;
|
||||
$totalVtas = 0;
|
||||
$mostrar = false;
|
||||
$totalPzas = 0;
|
||||
$iniciales = array();
|
||||
$entradas = array();
|
||||
$salidas = array();
|
||||
for($m=0; $m<$meses; $m++){
|
||||
|
||||
$fechaIni = date('Y-m-01',strtotime('+'.$m.' month',$strFechaI));
|
||||
$fechaFin = date('Y-m-31',strtotime('+'.$m.' month',$strFechaI));
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$producto->setFechaIni($fechaIni);
|
||||
$producto->setFechaFin($fechaFin);
|
||||
|
||||
$producto->setSucursalId($sucursalId);
|
||||
$cantSalida = $producto->GetCantVendido();
|
||||
|
||||
$cantSalidaVtas = $cantSalida;
|
||||
|
||||
$totalVtas += $cantSalida;
|
||||
|
||||
$cantSalida += $producto->GetSalEnvTT();
|
||||
|
||||
$cantEntrada = $producto->GetCantTotalCompBySuc();
|
||||
$cantEntrada += $producto->GetEntEnvTT();
|
||||
|
||||
$cantEntradaA = $producto->GetEntAjusteEnv();
|
||||
$cantBloqueados = $producto->GetBloqueadosEnv();
|
||||
|
||||
$cantSalidaA = $producto->GetSalAjusteEnv();
|
||||
|
||||
//$cantEntradaA += $producto->GetEntAjusteExcel();
|
||||
|
||||
$totalPzas = ($cantInicial + $cantEntrada - $cantSalida + $cantEntradaA - $cantSalidaA - $cantBloqueados);
|
||||
|
||||
$totSubs[$prodSubcatId][$m]['inicial'] += $cantInicial;
|
||||
$totSubs[$prodSubcatId][$m]['entradas'] += $cantEntrada;
|
||||
$totSubs[$prodSubcatId][$m]['salidas'] += $cantSalida;
|
||||
$totSubs[$prodSubcatId][$m]['entradasA'] += $cantEntradaA;
|
||||
$totSubs[$prodSubcatId][$m]['salidasA'] += $cantSalidaA;
|
||||
$totSubs[$prodSubcatId][$m]['bloqueados'] += $cantBloqueados;
|
||||
|
||||
$totCats[$prodCatId][$m]['inicial'] += $cantInicial;
|
||||
$totCats[$prodCatId][$m]['entradas'] += $cantEntrada;
|
||||
$totCats[$prodCatId][$m]['salidas'] += $cantSalida;
|
||||
$totCats[$prodCatId][$m]['entradasA'] += $cantEntradaA;
|
||||
$totCats[$prodCatId][$m]['salidasA'] += $cantSalidaA;
|
||||
$totCats[$prodCatId][$m]['bloqueados'] += $cantBloqueados;
|
||||
|
||||
if($cantEntrada > 0 || $cantEntradaA > 0 || $cantInicial > 0)
|
||||
$mostrar = true;
|
||||
|
||||
if($cantSalida > 0 || $cantSalidaA > 0 || $cantInicial > 0)
|
||||
$mostrar = true;
|
||||
|
||||
if($mostrar == true){
|
||||
$iniciales[$m] = $cantInicial;
|
||||
$entradas[$m] = $cantEntrada;
|
||||
$salidas[$m] = $cantSalida;
|
||||
$entradasA[$m] = $cantEntradaA;
|
||||
$salidasA[$m] = $cantSalidaA;
|
||||
$bloqueados[$m] = $cantBloqueados;
|
||||
|
||||
$salidasVtas[$m] = $cantSalidaVtas;
|
||||
|
||||
$totIniciales[$m] += $cantInicial;
|
||||
$totEntradas[$m] += $cantEntrada;
|
||||
$totSalidas[$m] += $cantSalida;
|
||||
$totEntradasA[$m] += $cantEntradaA;
|
||||
$totSalidasA[$m] += $cantSalidaA;
|
||||
$totBloqueados[$m] += $cantBloqueados;
|
||||
}else{
|
||||
$iniciales[$m] = 0;
|
||||
$entradas[$m] = 0;
|
||||
$salidas[$m] = 0;
|
||||
$entradasA[$m] = 0;
|
||||
$salidasA[$m] = 0;
|
||||
$bloqueados[$m] = 0;
|
||||
|
||||
$salidasVtas[$m] = 0;
|
||||
}
|
||||
|
||||
$cantInicial = $cantInicial + $cantEntrada - $cantSalida + $cantEntradaA - $cantSalidaA - $cantBloqueados;
|
||||
|
||||
|
||||
}//for
|
||||
|
||||
$res['iniciales'] = $iniciales;
|
||||
$res['entradas'] = $entradas;
|
||||
$res['salidas'] = $salidas;
|
||||
$res['salidasVtas'] = $salidasVtas;
|
||||
$res['entradasA'] = $entradasA;
|
||||
$res['salidasA'] = $salidasA;
|
||||
$res['bloqueados'] = $bloqueados;
|
||||
$res['totalPzas'] = $totalPzas;
|
||||
$res['proveedor'] = $nomProv;
|
||||
|
||||
$res['importe'] = $res['costo'] * $totalPzas;
|
||||
|
||||
$res['totalVtas'] = $totalVtas;
|
||||
$res['precioVta'] = $infP['precioVentaIva'];
|
||||
$res['importeVtas'] = $totalVtas * $infP['precioVentaIva'];
|
||||
|
||||
$totSubs[$prodSubcatId]['totalPzas'] += $totalPzas;
|
||||
$totCats[$prodCatId]['totalPzas'] += $totalPzas;
|
||||
$totSubs[$prodSubcatId]['importe'] += $res['importe'];
|
||||
$totCats[$prodCatId]['importe'] += $res['importe'];
|
||||
|
||||
$totSubs[$prodSubcatId]['totalVtas'] += $totalVtas;
|
||||
$totCats[$prodCatId]['totalVtas'] += $totalVtas;
|
||||
$totSubs[$prodSubcatId]['importeVtas'] += $res['importeVtas'];
|
||||
$totCats[$prodCatId]['importeVtas'] += $res['importeVtas'];
|
||||
|
||||
$res['prodCatId'] = $infP['prodCatId'];
|
||||
$res['prodSubcatId'] = $infP['prodSubcatId'];
|
||||
|
||||
if($mostrar == true){
|
||||
$totPzas += $totalPzas;
|
||||
$totImporte += $res['importe'];
|
||||
|
||||
$totVtas += $totalVtas;
|
||||
$totImporteVtas += $res['importeVtas'];
|
||||
|
||||
$productos[$prodCatId][$prodSubcatId][] = $res;
|
||||
}
|
||||
|
||||
}//foreach
|
||||
|
||||
$categorias = array();
|
||||
foreach($resCategorias as $prodCatId){
|
||||
$card['prodCatId'] = $prodCatId;
|
||||
$prodCat->setProdCatId($prodCatId);
|
||||
$card['nombre'] = utf8_encode($prodCat->GetNameById());
|
||||
$categorias[] = $card;
|
||||
}
|
||||
|
||||
$subcategorias = array();
|
||||
foreach($resSubcats as $prodCatId => $subcats){
|
||||
$card = array();
|
||||
$subcats2 = array();
|
||||
foreach($subcats as $prodSubcatId){
|
||||
$card['prodSubcatId'] = $prodSubcatId;
|
||||
$prodSubcat->setProdSubcatId($prodSubcatId);
|
||||
$card['nombre'] = utf8_encode($prodSubcat->GetNameById());
|
||||
$subcats2[] = $card;
|
||||
}
|
||||
|
||||
$subcategorias[$prodCatId] = $subcats2;
|
||||
|
||||
}
|
||||
|
||||
$suc['productos'] = $productos;
|
||||
$suc['categorias'] = $categorias;
|
||||
$suc['subcategorias'] = $subcategorias;
|
||||
$suc['totSubs'] = $totSubs;
|
||||
$suc['totCats'] = $totCats;
|
||||
|
||||
$suc['totIniciales'] = $totIniciales;
|
||||
$suc['totEntradas'] = $totEntradas;
|
||||
$suc['totSalidas'] = $totSalidas;
|
||||
$suc['totEntradasA'] = $totEntradasA;
|
||||
$suc['totSalidasA'] = $totSalidasA;
|
||||
$suc['totBloqueados'] = $totBloqueados;
|
||||
$suc['totPzas'] = $totPzas;
|
||||
$suc['totImporte'] = $totImporte;
|
||||
$suc['totVtas'] = $totVtas;
|
||||
$suc['totImporteVtas'] = $totImporteVtas;
|
||||
|
||||
$sucursales[] = $suc;
|
||||
|
||||
}//foreach
|
||||
|
||||
//****
|
||||
|
||||
$serialize = urlencode(serialize($sucursales));
|
||||
|
||||
$sql = "REPLACE INTO `reporteProvBest` (
|
||||
`proveedorId` ,
|
||||
`fecha` ,
|
||||
`reporte` ,
|
||||
`sucursal`
|
||||
)
|
||||
VALUES (
|
||||
'".$proveedorId."',
|
||||
'".date("Y-m-d H:i:s")."',
|
||||
'".$serialize."',
|
||||
'')"
|
||||
;
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$util->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
}//foreach
|
||||
|
||||
echo 'Done';
|
||||
|
||||
$end = microtime(true);
|
||||
echo "Tiempo de Ejecucion: ";
|
||||
echo $time = number_format(($end - $start), 2);
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
330
crons/rep-prods-prov2.php
Executable file
330
crons/rep-prods-prov2.php
Executable file
@@ -0,0 +1,330 @@
|
||||
<?php
|
||||
|
||||
include_once('/home/novomoda/public_html/sistema/init.php');
|
||||
include_once('/home/novomoda/public_html/sistema/config.php');
|
||||
include_once(DOC_ROOT.'/libraries.php');
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
$start = microtime(true);
|
||||
|
||||
/**
|
||||
Ejecuta TODOS los proveedores, sucursales y desde el 01-06-2013
|
||||
*/
|
||||
|
||||
$mesI = '06';
|
||||
$anioI = 2013;
|
||||
$mesF = date('m');
|
||||
$anioF = date('Y');
|
||||
$codigoBarra = trim($_POST['codigoBarra']);
|
||||
|
||||
$nomMes = $util->GetMMMName(intval($mesI));
|
||||
$perIni = $nomMes.' '.$anioI;
|
||||
$nomMes = $util->GetMMMName(intval($mesF));
|
||||
$perFin = $nomMes.' '.$anioF;
|
||||
|
||||
$mI = intval($mesI);
|
||||
$mF = intval($mesF);
|
||||
|
||||
$yI = $anioI;
|
||||
$yF = $anioF;
|
||||
|
||||
$anios = $yF - $yI;
|
||||
|
||||
if($anios == 0){
|
||||
$meses = $mF - $mI;
|
||||
$meses += 1;
|
||||
}else{
|
||||
$meses = (12 - $mI) + 1 + $mF;
|
||||
}
|
||||
|
||||
$strFechaI = strtotime('01-'.$mesI.'-'.$anioI);
|
||||
|
||||
$sql = 'SELECT proveedor.proveedorId, reporteProvBest.fecha FROM proveedor
|
||||
LEFT JOIN reporteProvBest ON proveedor.proveedorId = reporteProvBest.proveedorId
|
||||
ORDER BY reporteProvBest.fechaTemp ASC
|
||||
LIMIT 40,40';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
foreach($proveedores as $prov){
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
$proveedorId = $prov['proveedorId'];
|
||||
|
||||
$proveedor->setProveedorId($proveedorId);
|
||||
$nomProv = $proveedor->GetNameById();
|
||||
|
||||
$reportes->setIdSuc(0);
|
||||
$resSuc = $reportes->EnumSucursales();
|
||||
|
||||
$sql = "SELECT p.productoId, p.precioVentaIva, p.prodCatId, p.prodSubcatId, p.modelo, p.codigoBarra, p.costo,
|
||||
p.proveedorId,
|
||||
(
|
||||
SELECT ped.fechaOrdenCompIng
|
||||
FROM pedido AS ped, pedidoProducto AS pp
|
||||
WHERE ped.pedidoId = pp.pedidoId
|
||||
AND pp.productoId = p.productoId
|
||||
ORDER BY ped.fechaOrdenCompIng DESC
|
||||
LIMIT 1
|
||||
) AS fecha
|
||||
FROM producto p
|
||||
WHERE p.baja = '0'
|
||||
AND p.proveedorId = '".$proveedorId."'
|
||||
ORDER BY p.descripcion";
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$resProds = $util->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $suc){
|
||||
|
||||
$sucursalId = $suc['sucursalId'];
|
||||
|
||||
$totPzas = 0;
|
||||
$totImporte = 0;
|
||||
$totVtas = 0;
|
||||
$totImporteVtas = 0;
|
||||
$totIniciales = array();
|
||||
$totEntradas = array();
|
||||
$totSalidas = array();
|
||||
$productos = array();
|
||||
$resCategorias = array();
|
||||
$resSubcats = array();
|
||||
foreach($resProds as $res){
|
||||
|
||||
$prodCatId = $res['prodCatId'];
|
||||
$prodSubcatId = $res['prodSubcatId'];
|
||||
|
||||
if($productoId > 0 && $res['productoId'] != $productoId)
|
||||
continue;
|
||||
|
||||
if(!in_array($prodCatId, $resCategorias))
|
||||
$resCategorias[] = $prodCatId;
|
||||
|
||||
if(count($resSubcats[$prodCatId]) == 0)
|
||||
$resSubcats[$prodCatId] = array();
|
||||
|
||||
$resSub = $resSubcats[$prodCatId];
|
||||
|
||||
if(!in_array($prodSubcatId, $resSub))
|
||||
$resSubcats[$prodCatId][] = $prodSubcatId;
|
||||
|
||||
if($res['fecha'] == 0)
|
||||
continue;
|
||||
|
||||
$res['modelo'] = utf8_encode($res['modelo']);
|
||||
|
||||
//Obtenemos el Saldo Inicial
|
||||
$fechaII = '2013-06-01';
|
||||
|
||||
$cantInicial = 0;
|
||||
$totalVtas = 0;
|
||||
$mostrar = false;
|
||||
$totalPzas = 0;
|
||||
$iniciales = array();
|
||||
$entradas = array();
|
||||
$salidas = array();
|
||||
for($m=0; $m<$meses; $m++){
|
||||
|
||||
$fechaIni = date('Y-m-01',strtotime('+'.$m.' month',$strFechaI));
|
||||
$fechaFin = date('Y-m-31',strtotime('+'.$m.' month',$strFechaI));
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$producto->setFechaIni($fechaIni);
|
||||
$producto->setFechaFin($fechaFin);
|
||||
|
||||
$producto->setSucursalId($sucursalId);
|
||||
$cantSalida = $producto->GetCantVendido();
|
||||
|
||||
$cantSalidaVtas = $cantSalida;
|
||||
|
||||
$totalVtas += $cantSalida;
|
||||
|
||||
$cantSalida += $producto->GetSalEnvTT();
|
||||
|
||||
$cantEntrada = $producto->GetCantTotalCompBySuc();
|
||||
$cantEntrada += $producto->GetEntEnvTT();
|
||||
|
||||
$cantEntradaA = $producto->GetEntAjusteEnv();
|
||||
$cantBloqueados = $producto->GetBloqueadosEnv();
|
||||
|
||||
$cantSalidaA = $producto->GetSalAjusteEnv();
|
||||
|
||||
//$cantEntradaA += $producto->GetEntAjusteExcel();
|
||||
|
||||
$totalPzas = ($cantInicial + $cantEntrada - $cantSalida + $cantEntradaA - $cantSalidaA - $cantBloqueados);
|
||||
|
||||
$totSubs[$prodSubcatId][$m]['inicial'] += $cantInicial;
|
||||
$totSubs[$prodSubcatId][$m]['entradas'] += $cantEntrada;
|
||||
$totSubs[$prodSubcatId][$m]['salidas'] += $cantSalida;
|
||||
$totSubs[$prodSubcatId][$m]['entradasA'] += $cantEntradaA;
|
||||
$totSubs[$prodSubcatId][$m]['salidasA'] += $cantSalidaA;
|
||||
$totSubs[$prodSubcatId][$m]['bloqueados'] += $cantBloqueados;
|
||||
|
||||
$totCats[$prodCatId][$m]['inicial'] += $cantInicial;
|
||||
$totCats[$prodCatId][$m]['entradas'] += $cantEntrada;
|
||||
$totCats[$prodCatId][$m]['salidas'] += $cantSalida;
|
||||
$totCats[$prodCatId][$m]['entradasA'] += $cantEntradaA;
|
||||
$totCats[$prodCatId][$m]['salidasA'] += $cantSalidaA;
|
||||
$totCats[$prodCatId][$m]['bloqueados'] += $cantBloqueados;
|
||||
|
||||
if($cantEntrada > 0 || $cantEntradaA > 0 || $cantInicial > 0)
|
||||
$mostrar = true;
|
||||
|
||||
if($cantSalida > 0 || $cantSalidaA > 0 || $cantInicial > 0)
|
||||
$mostrar = true;
|
||||
|
||||
if($mostrar == true){
|
||||
$iniciales[$m] = $cantInicial;
|
||||
$entradas[$m] = $cantEntrada;
|
||||
$salidas[$m] = $cantSalida;
|
||||
$entradasA[$m] = $cantEntradaA;
|
||||
$salidasA[$m] = $cantSalidaA;
|
||||
$bloqueados[$m] = $cantBloqueados;
|
||||
|
||||
$salidasVtas[$m] = $cantSalidaVtas;
|
||||
|
||||
$totIniciales[$m] += $cantInicial;
|
||||
$totEntradas[$m] += $cantEntrada;
|
||||
$totSalidas[$m] += $cantSalida;
|
||||
$totEntradasA[$m] += $cantEntradaA;
|
||||
$totSalidasA[$m] += $cantSalidaA;
|
||||
$totBloqueados[$m] += $cantBloqueados;
|
||||
}else{
|
||||
$iniciales[$m] = 0;
|
||||
$entradas[$m] = 0;
|
||||
$salidas[$m] = 0;
|
||||
$entradasA[$m] = 0;
|
||||
$salidasA[$m] = 0;
|
||||
$bloqueados[$m] = 0;
|
||||
|
||||
$salidasVtas[$m] = 0;
|
||||
}
|
||||
|
||||
$cantInicial = $cantInicial + $cantEntrada - $cantSalida + $cantEntradaA - $cantSalidaA - $cantBloqueados;
|
||||
|
||||
|
||||
}//for
|
||||
|
||||
$res['iniciales'] = $iniciales;
|
||||
$res['entradas'] = $entradas;
|
||||
$res['salidas'] = $salidas;
|
||||
$res['salidasVtas'] = $salidasVtas;
|
||||
$res['entradasA'] = $entradasA;
|
||||
$res['salidasA'] = $salidasA;
|
||||
$res['bloqueados'] = $bloqueados;
|
||||
$res['totalPzas'] = $totalPzas;
|
||||
$res['proveedor'] = $nomProv;
|
||||
|
||||
$res['importe'] = $res['costo'] * $totalPzas;
|
||||
|
||||
$res['totalVtas'] = $totalVtas;
|
||||
$res['precioVta'] = $infP['precioVentaIva'];
|
||||
$res['importeVtas'] = $totalVtas * $infP['precioVentaIva'];
|
||||
|
||||
$totSubs[$prodSubcatId]['totalPzas'] += $totalPzas;
|
||||
$totCats[$prodCatId]['totalPzas'] += $totalPzas;
|
||||
$totSubs[$prodSubcatId]['importe'] += $res['importe'];
|
||||
$totCats[$prodCatId]['importe'] += $res['importe'];
|
||||
|
||||
$totSubs[$prodSubcatId]['totalVtas'] += $totalVtas;
|
||||
$totCats[$prodCatId]['totalVtas'] += $totalVtas;
|
||||
$totSubs[$prodSubcatId]['importeVtas'] += $res['importeVtas'];
|
||||
$totCats[$prodCatId]['importeVtas'] += $res['importeVtas'];
|
||||
|
||||
$res['prodCatId'] = $infP['prodCatId'];
|
||||
$res['prodSubcatId'] = $infP['prodSubcatId'];
|
||||
|
||||
if($mostrar == true){
|
||||
$totPzas += $totalPzas;
|
||||
$totImporte += $res['importe'];
|
||||
|
||||
$totVtas += $totalVtas;
|
||||
$totImporteVtas += $res['importeVtas'];
|
||||
|
||||
$productos[$prodCatId][$prodSubcatId][] = $res;
|
||||
}
|
||||
|
||||
}//foreach
|
||||
|
||||
$categorias = array();
|
||||
foreach($resCategorias as $prodCatId){
|
||||
$card['prodCatId'] = $prodCatId;
|
||||
$prodCat->setProdCatId($prodCatId);
|
||||
$card['nombre'] = utf8_encode($prodCat->GetNameById());
|
||||
$categorias[] = $card;
|
||||
}
|
||||
|
||||
$subcategorias = array();
|
||||
foreach($resSubcats as $prodCatId => $subcats){
|
||||
$card = array();
|
||||
$subcats2 = array();
|
||||
foreach($subcats as $prodSubcatId){
|
||||
$card['prodSubcatId'] = $prodSubcatId;
|
||||
$prodSubcat->setProdSubcatId($prodSubcatId);
|
||||
$card['nombre'] = utf8_encode($prodSubcat->GetNameById());
|
||||
$subcats2[] = $card;
|
||||
}
|
||||
|
||||
$subcategorias[$prodCatId] = $subcats2;
|
||||
|
||||
}
|
||||
|
||||
$suc['productos'] = $productos;
|
||||
$suc['categorias'] = $categorias;
|
||||
$suc['subcategorias'] = $subcategorias;
|
||||
$suc['totSubs'] = $totSubs;
|
||||
$suc['totCats'] = $totCats;
|
||||
|
||||
$suc['totIniciales'] = $totIniciales;
|
||||
$suc['totEntradas'] = $totEntradas;
|
||||
$suc['totSalidas'] = $totSalidas;
|
||||
$suc['totEntradasA'] = $totEntradasA;
|
||||
$suc['totSalidasA'] = $totSalidasA;
|
||||
$suc['totBloqueados'] = $totBloqueados;
|
||||
$suc['totPzas'] = $totPzas;
|
||||
$suc['totImporte'] = $totImporte;
|
||||
$suc['totVtas'] = $totVtas;
|
||||
$suc['totImporteVtas'] = $totImporteVtas;
|
||||
|
||||
$sucursales[] = $suc;
|
||||
|
||||
}//foreach
|
||||
|
||||
//****
|
||||
|
||||
$serialize = urlencode(serialize($sucursales));
|
||||
|
||||
$sql = "REPLACE INTO `reporteProvBest` (
|
||||
`proveedorId` ,
|
||||
`fecha` ,
|
||||
`reporte` ,
|
||||
`sucursal`
|
||||
)
|
||||
VALUES (
|
||||
'".$proveedorId."',
|
||||
'".date("Y-m-d H:i:s")."',
|
||||
'".$serialize."',
|
||||
'')"
|
||||
;
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$util->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
}//foreach
|
||||
|
||||
echo 'Done';
|
||||
|
||||
$end = microtime(true);
|
||||
echo "Tiempo de Ejecucion: ";
|
||||
echo $time = number_format(($end - $start), 2);
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
330
crons/rep-prods-prov3.php
Executable file
330
crons/rep-prods-prov3.php
Executable file
@@ -0,0 +1,330 @@
|
||||
<?php
|
||||
|
||||
include_once('/home/novomoda/public_html/sistema/init.php');
|
||||
include_once('/home/novomoda/public_html/sistema/config.php');
|
||||
include_once(DOC_ROOT.'/libraries.php');
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
$start = microtime(true);
|
||||
|
||||
/**
|
||||
Ejecuta TODOS los proveedores, sucursales y desde el 01-06-2013
|
||||
*/
|
||||
|
||||
$mesI = '06';
|
||||
$anioI = 2013;
|
||||
$mesF = date('m');
|
||||
$anioF = date('Y');
|
||||
$codigoBarra = trim($_POST['codigoBarra']);
|
||||
|
||||
$nomMes = $util->GetMMMName(intval($mesI));
|
||||
$perIni = $nomMes.' '.$anioI;
|
||||
$nomMes = $util->GetMMMName(intval($mesF));
|
||||
$perFin = $nomMes.' '.$anioF;
|
||||
|
||||
$mI = intval($mesI);
|
||||
$mF = intval($mesF);
|
||||
|
||||
$yI = $anioI;
|
||||
$yF = $anioF;
|
||||
|
||||
$anios = $yF - $yI;
|
||||
|
||||
if($anios == 0){
|
||||
$meses = $mF - $mI;
|
||||
$meses += 1;
|
||||
}else{
|
||||
$meses = (12 - $mI) + 1 + $mF;
|
||||
}
|
||||
|
||||
$strFechaI = strtotime('01-'.$mesI.'-'.$anioI);
|
||||
|
||||
$sql = 'SELECT proveedor.proveedorId, reporteProvBest.fecha FROM proveedor
|
||||
LEFT JOIN reporteProvBest ON proveedor.proveedorId = reporteProvBest.proveedorId
|
||||
ORDER BY reporteProvBest.fechaTemp ASC
|
||||
LIMIT 80,40';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
foreach($proveedores as $prov){
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
$proveedorId = $prov['proveedorId'];
|
||||
|
||||
$proveedor->setProveedorId($proveedorId);
|
||||
$nomProv = $proveedor->GetNameById();
|
||||
|
||||
$reportes->setIdSuc(0);
|
||||
$resSuc = $reportes->EnumSucursales();
|
||||
|
||||
$sql = "SELECT p.productoId, p.precioVentaIva, p.prodCatId, p.prodSubcatId, p.modelo, p.codigoBarra, p.costo,
|
||||
p.proveedorId,
|
||||
(
|
||||
SELECT ped.fechaOrdenCompIng
|
||||
FROM pedido AS ped, pedidoProducto AS pp
|
||||
WHERE ped.pedidoId = pp.pedidoId
|
||||
AND pp.productoId = p.productoId
|
||||
ORDER BY ped.fechaOrdenCompIng DESC
|
||||
LIMIT 1
|
||||
) AS fecha
|
||||
FROM producto p
|
||||
WHERE p.baja = '0'
|
||||
AND p.proveedorId = '".$proveedorId."'
|
||||
ORDER BY p.descripcion";
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$resProds = $util->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $suc){
|
||||
|
||||
$sucursalId = $suc['sucursalId'];
|
||||
|
||||
$totPzas = 0;
|
||||
$totImporte = 0;
|
||||
$totVtas = 0;
|
||||
$totImporteVtas = 0;
|
||||
$totIniciales = array();
|
||||
$totEntradas = array();
|
||||
$totSalidas = array();
|
||||
$productos = array();
|
||||
$resCategorias = array();
|
||||
$resSubcats = array();
|
||||
foreach($resProds as $res){
|
||||
|
||||
$prodCatId = $res['prodCatId'];
|
||||
$prodSubcatId = $res['prodSubcatId'];
|
||||
|
||||
if($productoId > 0 && $res['productoId'] != $productoId)
|
||||
continue;
|
||||
|
||||
if(!in_array($prodCatId, $resCategorias))
|
||||
$resCategorias[] = $prodCatId;
|
||||
|
||||
if(count($resSubcats[$prodCatId]) == 0)
|
||||
$resSubcats[$prodCatId] = array();
|
||||
|
||||
$resSub = $resSubcats[$prodCatId];
|
||||
|
||||
if(!in_array($prodSubcatId, $resSub))
|
||||
$resSubcats[$prodCatId][] = $prodSubcatId;
|
||||
|
||||
if($res['fecha'] == 0)
|
||||
continue;
|
||||
|
||||
$res['modelo'] = utf8_encode($res['modelo']);
|
||||
|
||||
//Obtenemos el Saldo Inicial
|
||||
$fechaII = '2013-06-01';
|
||||
|
||||
$cantInicial = 0;
|
||||
$totalVtas = 0;
|
||||
$mostrar = false;
|
||||
$totalPzas = 0;
|
||||
$iniciales = array();
|
||||
$entradas = array();
|
||||
$salidas = array();
|
||||
for($m=0; $m<$meses; $m++){
|
||||
|
||||
$fechaIni = date('Y-m-01',strtotime('+'.$m.' month',$strFechaI));
|
||||
$fechaFin = date('Y-m-31',strtotime('+'.$m.' month',$strFechaI));
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$producto->setFechaIni($fechaIni);
|
||||
$producto->setFechaFin($fechaFin);
|
||||
|
||||
$producto->setSucursalId($sucursalId);
|
||||
$cantSalida = $producto->GetCantVendido();
|
||||
|
||||
$cantSalidaVtas = $cantSalida;
|
||||
|
||||
$totalVtas += $cantSalida;
|
||||
|
||||
$cantSalida += $producto->GetSalEnvTT();
|
||||
|
||||
$cantEntrada = $producto->GetCantTotalCompBySuc();
|
||||
$cantEntrada += $producto->GetEntEnvTT();
|
||||
|
||||
$cantEntradaA = $producto->GetEntAjusteEnv();
|
||||
$cantBloqueados = $producto->GetBloqueadosEnv();
|
||||
|
||||
$cantSalidaA = $producto->GetSalAjusteEnv();
|
||||
|
||||
//$cantEntradaA += $producto->GetEntAjusteExcel();
|
||||
|
||||
$totalPzas = ($cantInicial + $cantEntrada - $cantSalida + $cantEntradaA - $cantSalidaA - $cantBloqueados);
|
||||
|
||||
$totSubs[$prodSubcatId][$m]['inicial'] += $cantInicial;
|
||||
$totSubs[$prodSubcatId][$m]['entradas'] += $cantEntrada;
|
||||
$totSubs[$prodSubcatId][$m]['salidas'] += $cantSalida;
|
||||
$totSubs[$prodSubcatId][$m]['entradasA'] += $cantEntradaA;
|
||||
$totSubs[$prodSubcatId][$m]['salidasA'] += $cantSalidaA;
|
||||
$totSubs[$prodSubcatId][$m]['bloqueados'] += $cantBloqueados;
|
||||
|
||||
$totCats[$prodCatId][$m]['inicial'] += $cantInicial;
|
||||
$totCats[$prodCatId][$m]['entradas'] += $cantEntrada;
|
||||
$totCats[$prodCatId][$m]['salidas'] += $cantSalida;
|
||||
$totCats[$prodCatId][$m]['entradasA'] += $cantEntradaA;
|
||||
$totCats[$prodCatId][$m]['salidasA'] += $cantSalidaA;
|
||||
$totCats[$prodCatId][$m]['bloqueados'] += $cantBloqueados;
|
||||
|
||||
if($cantEntrada > 0 || $cantEntradaA > 0 || $cantInicial > 0)
|
||||
$mostrar = true;
|
||||
|
||||
if($cantSalida > 0 || $cantSalidaA > 0 || $cantInicial > 0)
|
||||
$mostrar = true;
|
||||
|
||||
if($mostrar == true){
|
||||
$iniciales[$m] = $cantInicial;
|
||||
$entradas[$m] = $cantEntrada;
|
||||
$salidas[$m] = $cantSalida;
|
||||
$entradasA[$m] = $cantEntradaA;
|
||||
$salidasA[$m] = $cantSalidaA;
|
||||
$bloqueados[$m] = $cantBloqueados;
|
||||
|
||||
$salidasVtas[$m] = $cantSalidaVtas;
|
||||
|
||||
$totIniciales[$m] += $cantInicial;
|
||||
$totEntradas[$m] += $cantEntrada;
|
||||
$totSalidas[$m] += $cantSalida;
|
||||
$totEntradasA[$m] += $cantEntradaA;
|
||||
$totSalidasA[$m] += $cantSalidaA;
|
||||
$totBloqueados[$m] += $cantBloqueados;
|
||||
}else{
|
||||
$iniciales[$m] = 0;
|
||||
$entradas[$m] = 0;
|
||||
$salidas[$m] = 0;
|
||||
$entradasA[$m] = 0;
|
||||
$salidasA[$m] = 0;
|
||||
$bloqueados[$m] = 0;
|
||||
|
||||
$salidasVtas[$m] = 0;
|
||||
}
|
||||
|
||||
$cantInicial = $cantInicial + $cantEntrada - $cantSalida + $cantEntradaA - $cantSalidaA - $cantBloqueados;
|
||||
|
||||
|
||||
}//for
|
||||
|
||||
$res['iniciales'] = $iniciales;
|
||||
$res['entradas'] = $entradas;
|
||||
$res['salidas'] = $salidas;
|
||||
$res['salidasVtas'] = $salidasVtas;
|
||||
$res['entradasA'] = $entradasA;
|
||||
$res['salidasA'] = $salidasA;
|
||||
$res['bloqueados'] = $bloqueados;
|
||||
$res['totalPzas'] = $totalPzas;
|
||||
$res['proveedor'] = $nomProv;
|
||||
|
||||
$res['importe'] = $res['costo'] * $totalPzas;
|
||||
|
||||
$res['totalVtas'] = $totalVtas;
|
||||
$res['precioVta'] = $infP['precioVentaIva'];
|
||||
$res['importeVtas'] = $totalVtas * $infP['precioVentaIva'];
|
||||
|
||||
$totSubs[$prodSubcatId]['totalPzas'] += $totalPzas;
|
||||
$totCats[$prodCatId]['totalPzas'] += $totalPzas;
|
||||
$totSubs[$prodSubcatId]['importe'] += $res['importe'];
|
||||
$totCats[$prodCatId]['importe'] += $res['importe'];
|
||||
|
||||
$totSubs[$prodSubcatId]['totalVtas'] += $totalVtas;
|
||||
$totCats[$prodCatId]['totalVtas'] += $totalVtas;
|
||||
$totSubs[$prodSubcatId]['importeVtas'] += $res['importeVtas'];
|
||||
$totCats[$prodCatId]['importeVtas'] += $res['importeVtas'];
|
||||
|
||||
$res['prodCatId'] = $infP['prodCatId'];
|
||||
$res['prodSubcatId'] = $infP['prodSubcatId'];
|
||||
|
||||
if($mostrar == true){
|
||||
$totPzas += $totalPzas;
|
||||
$totImporte += $res['importe'];
|
||||
|
||||
$totVtas += $totalVtas;
|
||||
$totImporteVtas += $res['importeVtas'];
|
||||
|
||||
$productos[$prodCatId][$prodSubcatId][] = $res;
|
||||
}
|
||||
|
||||
}//foreach
|
||||
|
||||
$categorias = array();
|
||||
foreach($resCategorias as $prodCatId){
|
||||
$card['prodCatId'] = $prodCatId;
|
||||
$prodCat->setProdCatId($prodCatId);
|
||||
$card['nombre'] = utf8_encode($prodCat->GetNameById());
|
||||
$categorias[] = $card;
|
||||
}
|
||||
|
||||
$subcategorias = array();
|
||||
foreach($resSubcats as $prodCatId => $subcats){
|
||||
$card = array();
|
||||
$subcats2 = array();
|
||||
foreach($subcats as $prodSubcatId){
|
||||
$card['prodSubcatId'] = $prodSubcatId;
|
||||
$prodSubcat->setProdSubcatId($prodSubcatId);
|
||||
$card['nombre'] = utf8_encode($prodSubcat->GetNameById());
|
||||
$subcats2[] = $card;
|
||||
}
|
||||
|
||||
$subcategorias[$prodCatId] = $subcats2;
|
||||
|
||||
}
|
||||
|
||||
$suc['productos'] = $productos;
|
||||
$suc['categorias'] = $categorias;
|
||||
$suc['subcategorias'] = $subcategorias;
|
||||
$suc['totSubs'] = $totSubs;
|
||||
$suc['totCats'] = $totCats;
|
||||
|
||||
$suc['totIniciales'] = $totIniciales;
|
||||
$suc['totEntradas'] = $totEntradas;
|
||||
$suc['totSalidas'] = $totSalidas;
|
||||
$suc['totEntradasA'] = $totEntradasA;
|
||||
$suc['totSalidasA'] = $totSalidasA;
|
||||
$suc['totBloqueados'] = $totBloqueados;
|
||||
$suc['totPzas'] = $totPzas;
|
||||
$suc['totImporte'] = $totImporte;
|
||||
$suc['totVtas'] = $totVtas;
|
||||
$suc['totImporteVtas'] = $totImporteVtas;
|
||||
|
||||
$sucursales[] = $suc;
|
||||
|
||||
}//foreach
|
||||
|
||||
//****
|
||||
|
||||
$serialize = urlencode(serialize($sucursales));
|
||||
|
||||
$sql = "REPLACE INTO `reporteProvBest` (
|
||||
`proveedorId` ,
|
||||
`fecha` ,
|
||||
`reporte` ,
|
||||
`sucursal`
|
||||
)
|
||||
VALUES (
|
||||
'".$proveedorId."',
|
||||
'".date("Y-m-d H:i:s")."',
|
||||
'".$serialize."',
|
||||
'')"
|
||||
;
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$util->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
}//foreach
|
||||
|
||||
echo 'Done';
|
||||
|
||||
$end = microtime(true);
|
||||
echo "Tiempo de Ejecucion: ";
|
||||
echo $time = number_format(($end - $start), 2);
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
330
crons/rep-prods-prov4.php
Executable file
330
crons/rep-prods-prov4.php
Executable file
@@ -0,0 +1,330 @@
|
||||
<?php
|
||||
|
||||
include_once('/home/novomoda/public_html/sistema/init.php');
|
||||
include_once('/home/novomoda/public_html/sistema/config.php');
|
||||
include_once(DOC_ROOT.'/libraries.php');
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
$start = microtime(true);
|
||||
|
||||
/**
|
||||
Ejecuta TODOS los proveedores, sucursales y desde el 01-06-2013
|
||||
*/
|
||||
|
||||
$mesI = '06';
|
||||
$anioI = 2013;
|
||||
$mesF = date('m');
|
||||
$anioF = date('Y');
|
||||
$codigoBarra = trim($_POST['codigoBarra']);
|
||||
|
||||
$nomMes = $util->GetMMMName(intval($mesI));
|
||||
$perIni = $nomMes.' '.$anioI;
|
||||
$nomMes = $util->GetMMMName(intval($mesF));
|
||||
$perFin = $nomMes.' '.$anioF;
|
||||
|
||||
$mI = intval($mesI);
|
||||
$mF = intval($mesF);
|
||||
|
||||
$yI = $anioI;
|
||||
$yF = $anioF;
|
||||
|
||||
$anios = $yF - $yI;
|
||||
|
||||
if($anios == 0){
|
||||
$meses = $mF - $mI;
|
||||
$meses += 1;
|
||||
}else{
|
||||
$meses = (12 - $mI) + 1 + $mF;
|
||||
}
|
||||
|
||||
$strFechaI = strtotime('01-'.$mesI.'-'.$anioI);
|
||||
|
||||
$sql = 'SELECT proveedor.proveedorId, reporteProvBest.fecha FROM proveedor
|
||||
LEFT JOIN reporteProvBest ON proveedor.proveedorId = reporteProvBest.proveedorId
|
||||
ORDER BY reporteProvBest.fechaTemp ASC
|
||||
LIMIT 120,40';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
foreach($proveedores as $prov){
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
$proveedorId = $prov['proveedorId'];
|
||||
|
||||
$proveedor->setProveedorId($proveedorId);
|
||||
$nomProv = $proveedor->GetNameById();
|
||||
|
||||
$reportes->setIdSuc(0);
|
||||
$resSuc = $reportes->EnumSucursales();
|
||||
|
||||
$sql = "SELECT p.productoId, p.precioVentaIva, p.prodCatId, p.prodSubcatId, p.modelo, p.codigoBarra, p.costo,
|
||||
p.proveedorId,
|
||||
(
|
||||
SELECT ped.fechaOrdenCompIng
|
||||
FROM pedido AS ped, pedidoProducto AS pp
|
||||
WHERE ped.pedidoId = pp.pedidoId
|
||||
AND pp.productoId = p.productoId
|
||||
ORDER BY ped.fechaOrdenCompIng DESC
|
||||
LIMIT 1
|
||||
) AS fecha
|
||||
FROM producto p
|
||||
WHERE p.baja = '0'
|
||||
AND p.proveedorId = '".$proveedorId."'
|
||||
ORDER BY p.descripcion";
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$resProds = $util->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $suc){
|
||||
|
||||
$sucursalId = $suc['sucursalId'];
|
||||
|
||||
$totPzas = 0;
|
||||
$totImporte = 0;
|
||||
$totVtas = 0;
|
||||
$totImporteVtas = 0;
|
||||
$totIniciales = array();
|
||||
$totEntradas = array();
|
||||
$totSalidas = array();
|
||||
$productos = array();
|
||||
$resCategorias = array();
|
||||
$resSubcats = array();
|
||||
foreach($resProds as $res){
|
||||
|
||||
$prodCatId = $res['prodCatId'];
|
||||
$prodSubcatId = $res['prodSubcatId'];
|
||||
|
||||
if($productoId > 0 && $res['productoId'] != $productoId)
|
||||
continue;
|
||||
|
||||
if(!in_array($prodCatId, $resCategorias))
|
||||
$resCategorias[] = $prodCatId;
|
||||
|
||||
if(count($resSubcats[$prodCatId]) == 0)
|
||||
$resSubcats[$prodCatId] = array();
|
||||
|
||||
$resSub = $resSubcats[$prodCatId];
|
||||
|
||||
if(!in_array($prodSubcatId, $resSub))
|
||||
$resSubcats[$prodCatId][] = $prodSubcatId;
|
||||
|
||||
if($res['fecha'] == 0)
|
||||
continue;
|
||||
|
||||
$res['modelo'] = utf8_encode($res['modelo']);
|
||||
|
||||
//Obtenemos el Saldo Inicial
|
||||
$fechaII = '2013-06-01';
|
||||
|
||||
$cantInicial = 0;
|
||||
$totalVtas = 0;
|
||||
$mostrar = false;
|
||||
$totalPzas = 0;
|
||||
$iniciales = array();
|
||||
$entradas = array();
|
||||
$salidas = array();
|
||||
for($m=0; $m<$meses; $m++){
|
||||
|
||||
$fechaIni = date('Y-m-01',strtotime('+'.$m.' month',$strFechaI));
|
||||
$fechaFin = date('Y-m-31',strtotime('+'.$m.' month',$strFechaI));
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$producto->setFechaIni($fechaIni);
|
||||
$producto->setFechaFin($fechaFin);
|
||||
|
||||
$producto->setSucursalId($sucursalId);
|
||||
$cantSalida = $producto->GetCantVendido();
|
||||
|
||||
$cantSalidaVtas = $cantSalida;
|
||||
|
||||
$totalVtas += $cantSalida;
|
||||
|
||||
$cantSalida += $producto->GetSalEnvTT();
|
||||
|
||||
$cantEntrada = $producto->GetCantTotalCompBySuc();
|
||||
$cantEntrada += $producto->GetEntEnvTT();
|
||||
|
||||
$cantEntradaA = $producto->GetEntAjusteEnv();
|
||||
$cantBloqueados = $producto->GetBloqueadosEnv();
|
||||
|
||||
$cantSalidaA = $producto->GetSalAjusteEnv();
|
||||
|
||||
//$cantEntradaA += $producto->GetEntAjusteExcel();
|
||||
|
||||
$totalPzas = ($cantInicial + $cantEntrada - $cantSalida + $cantEntradaA - $cantSalidaA - $cantBloqueados);
|
||||
|
||||
$totSubs[$prodSubcatId][$m]['inicial'] += $cantInicial;
|
||||
$totSubs[$prodSubcatId][$m]['entradas'] += $cantEntrada;
|
||||
$totSubs[$prodSubcatId][$m]['salidas'] += $cantSalida;
|
||||
$totSubs[$prodSubcatId][$m]['entradasA'] += $cantEntradaA;
|
||||
$totSubs[$prodSubcatId][$m]['salidasA'] += $cantSalidaA;
|
||||
$totSubs[$prodSubcatId][$m]['bloqueados'] += $cantBloqueados;
|
||||
|
||||
$totCats[$prodCatId][$m]['inicial'] += $cantInicial;
|
||||
$totCats[$prodCatId][$m]['entradas'] += $cantEntrada;
|
||||
$totCats[$prodCatId][$m]['salidas'] += $cantSalida;
|
||||
$totCats[$prodCatId][$m]['entradasA'] += $cantEntradaA;
|
||||
$totCats[$prodCatId][$m]['salidasA'] += $cantSalidaA;
|
||||
$totCats[$prodCatId][$m]['bloqueados'] += $cantBloqueados;
|
||||
|
||||
if($cantEntrada > 0 || $cantEntradaA > 0 || $cantInicial > 0)
|
||||
$mostrar = true;
|
||||
|
||||
if($cantSalida > 0 || $cantSalidaA > 0 || $cantInicial > 0)
|
||||
$mostrar = true;
|
||||
|
||||
if($mostrar == true){
|
||||
$iniciales[$m] = $cantInicial;
|
||||
$entradas[$m] = $cantEntrada;
|
||||
$salidas[$m] = $cantSalida;
|
||||
$entradasA[$m] = $cantEntradaA;
|
||||
$salidasA[$m] = $cantSalidaA;
|
||||
$bloqueados[$m] = $cantBloqueados;
|
||||
|
||||
$salidasVtas[$m] = $cantSalidaVtas;
|
||||
|
||||
$totIniciales[$m] += $cantInicial;
|
||||
$totEntradas[$m] += $cantEntrada;
|
||||
$totSalidas[$m] += $cantSalida;
|
||||
$totEntradasA[$m] += $cantEntradaA;
|
||||
$totSalidasA[$m] += $cantSalidaA;
|
||||
$totBloqueados[$m] += $cantBloqueados;
|
||||
}else{
|
||||
$iniciales[$m] = 0;
|
||||
$entradas[$m] = 0;
|
||||
$salidas[$m] = 0;
|
||||
$entradasA[$m] = 0;
|
||||
$salidasA[$m] = 0;
|
||||
$bloqueados[$m] = 0;
|
||||
|
||||
$salidasVtas[$m] = 0;
|
||||
}
|
||||
|
||||
$cantInicial = $cantInicial + $cantEntrada - $cantSalida + $cantEntradaA - $cantSalidaA - $cantBloqueados;
|
||||
|
||||
|
||||
}//for
|
||||
|
||||
$res['iniciales'] = $iniciales;
|
||||
$res['entradas'] = $entradas;
|
||||
$res['salidas'] = $salidas;
|
||||
$res['salidasVtas'] = $salidasVtas;
|
||||
$res['entradasA'] = $entradasA;
|
||||
$res['salidasA'] = $salidasA;
|
||||
$res['bloqueados'] = $bloqueados;
|
||||
$res['totalPzas'] = $totalPzas;
|
||||
$res['proveedor'] = $nomProv;
|
||||
|
||||
$res['importe'] = $res['costo'] * $totalPzas;
|
||||
|
||||
$res['totalVtas'] = $totalVtas;
|
||||
$res['precioVta'] = $infP['precioVentaIva'];
|
||||
$res['importeVtas'] = $totalVtas * $infP['precioVentaIva'];
|
||||
|
||||
$totSubs[$prodSubcatId]['totalPzas'] += $totalPzas;
|
||||
$totCats[$prodCatId]['totalPzas'] += $totalPzas;
|
||||
$totSubs[$prodSubcatId]['importe'] += $res['importe'];
|
||||
$totCats[$prodCatId]['importe'] += $res['importe'];
|
||||
|
||||
$totSubs[$prodSubcatId]['totalVtas'] += $totalVtas;
|
||||
$totCats[$prodCatId]['totalVtas'] += $totalVtas;
|
||||
$totSubs[$prodSubcatId]['importeVtas'] += $res['importeVtas'];
|
||||
$totCats[$prodCatId]['importeVtas'] += $res['importeVtas'];
|
||||
|
||||
$res['prodCatId'] = $infP['prodCatId'];
|
||||
$res['prodSubcatId'] = $infP['prodSubcatId'];
|
||||
|
||||
if($mostrar == true){
|
||||
$totPzas += $totalPzas;
|
||||
$totImporte += $res['importe'];
|
||||
|
||||
$totVtas += $totalVtas;
|
||||
$totImporteVtas += $res['importeVtas'];
|
||||
|
||||
$productos[$prodCatId][$prodSubcatId][] = $res;
|
||||
}
|
||||
|
||||
}//foreach
|
||||
|
||||
$categorias = array();
|
||||
foreach($resCategorias as $prodCatId){
|
||||
$card['prodCatId'] = $prodCatId;
|
||||
$prodCat->setProdCatId($prodCatId);
|
||||
$card['nombre'] = utf8_encode($prodCat->GetNameById());
|
||||
$categorias[] = $card;
|
||||
}
|
||||
|
||||
$subcategorias = array();
|
||||
foreach($resSubcats as $prodCatId => $subcats){
|
||||
$card = array();
|
||||
$subcats2 = array();
|
||||
foreach($subcats as $prodSubcatId){
|
||||
$card['prodSubcatId'] = $prodSubcatId;
|
||||
$prodSubcat->setProdSubcatId($prodSubcatId);
|
||||
$card['nombre'] = utf8_encode($prodSubcat->GetNameById());
|
||||
$subcats2[] = $card;
|
||||
}
|
||||
|
||||
$subcategorias[$prodCatId] = $subcats2;
|
||||
|
||||
}
|
||||
|
||||
$suc['productos'] = $productos;
|
||||
$suc['categorias'] = $categorias;
|
||||
$suc['subcategorias'] = $subcategorias;
|
||||
$suc['totSubs'] = $totSubs;
|
||||
$suc['totCats'] = $totCats;
|
||||
|
||||
$suc['totIniciales'] = $totIniciales;
|
||||
$suc['totEntradas'] = $totEntradas;
|
||||
$suc['totSalidas'] = $totSalidas;
|
||||
$suc['totEntradasA'] = $totEntradasA;
|
||||
$suc['totSalidasA'] = $totSalidasA;
|
||||
$suc['totBloqueados'] = $totBloqueados;
|
||||
$suc['totPzas'] = $totPzas;
|
||||
$suc['totImporte'] = $totImporte;
|
||||
$suc['totVtas'] = $totVtas;
|
||||
$suc['totImporteVtas'] = $totImporteVtas;
|
||||
|
||||
$sucursales[] = $suc;
|
||||
|
||||
}//foreach
|
||||
|
||||
//****
|
||||
|
||||
$serialize = urlencode(serialize($sucursales));
|
||||
|
||||
$sql = "REPLACE INTO `reporteProvBest` (
|
||||
`proveedorId` ,
|
||||
`fecha` ,
|
||||
`reporte` ,
|
||||
`sucursal`
|
||||
)
|
||||
VALUES (
|
||||
'".$proveedorId."',
|
||||
'".date("Y-m-d H:i:s")."',
|
||||
'".$serialize."',
|
||||
'')"
|
||||
;
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$util->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
}//foreach
|
||||
|
||||
echo 'Done';
|
||||
|
||||
$end = microtime(true);
|
||||
echo "Tiempo de Ejecucion: ";
|
||||
echo $time = number_format(($end - $start), 2);
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
330
crons/rep-prods-prov5.php
Executable file
330
crons/rep-prods-prov5.php
Executable file
@@ -0,0 +1,330 @@
|
||||
<?php
|
||||
|
||||
include_once('/home/novomoda/public_html/sistema/init.php');
|
||||
include_once('/home/novomoda/public_html/sistema/config.php');
|
||||
include_once(DOC_ROOT.'/libraries.php');
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
$start = microtime(true);
|
||||
|
||||
/**
|
||||
Ejecuta TODOS los proveedores, sucursales y desde el 01-06-2013
|
||||
*/
|
||||
|
||||
$mesI = '06';
|
||||
$anioI = 2013;
|
||||
$mesF = date('m');
|
||||
$anioF = date('Y');
|
||||
$codigoBarra = trim($_POST['codigoBarra']);
|
||||
|
||||
$nomMes = $util->GetMMMName(intval($mesI));
|
||||
$perIni = $nomMes.' '.$anioI;
|
||||
$nomMes = $util->GetMMMName(intval($mesF));
|
||||
$perFin = $nomMes.' '.$anioF;
|
||||
|
||||
$mI = intval($mesI);
|
||||
$mF = intval($mesF);
|
||||
|
||||
$yI = $anioI;
|
||||
$yF = $anioF;
|
||||
|
||||
$anios = $yF - $yI;
|
||||
|
||||
if($anios == 0){
|
||||
$meses = $mF - $mI;
|
||||
$meses += 1;
|
||||
}else{
|
||||
$meses = (12 - $mI) + 1 + $mF;
|
||||
}
|
||||
|
||||
$strFechaI = strtotime('01-'.$mesI.'-'.$anioI);
|
||||
|
||||
$sql = 'SELECT proveedor.proveedorId, reporteProvBest.fecha FROM proveedor
|
||||
LEFT JOIN reporteProvBest ON proveedor.proveedorId = reporteProvBest.proveedorId
|
||||
ORDER BY reporteProvBest.fechaTemp ASC
|
||||
LIMIT 160,100';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
foreach($proveedores as $prov){
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
$proveedorId = $prov['proveedorId'];
|
||||
|
||||
$proveedor->setProveedorId($proveedorId);
|
||||
$nomProv = $proveedor->GetNameById();
|
||||
|
||||
$reportes->setIdSuc(0);
|
||||
$resSuc = $reportes->EnumSucursales();
|
||||
|
||||
$sql = "SELECT p.productoId, p.precioVentaIva, p.prodCatId, p.prodSubcatId, p.modelo, p.codigoBarra, p.costo,
|
||||
p.proveedorId,
|
||||
(
|
||||
SELECT ped.fechaOrdenCompIng
|
||||
FROM pedido AS ped, pedidoProducto AS pp
|
||||
WHERE ped.pedidoId = pp.pedidoId
|
||||
AND pp.productoId = p.productoId
|
||||
ORDER BY ped.fechaOrdenCompIng DESC
|
||||
LIMIT 1
|
||||
) AS fecha
|
||||
FROM producto p
|
||||
WHERE p.baja = '0'
|
||||
AND p.proveedorId = '".$proveedorId."'
|
||||
ORDER BY p.descripcion";
|
||||
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$resProds = $util->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $suc){
|
||||
|
||||
$sucursalId = $suc['sucursalId'];
|
||||
|
||||
$totPzas = 0;
|
||||
$totImporte = 0;
|
||||
$totVtas = 0;
|
||||
$totImporteVtas = 0;
|
||||
$totIniciales = array();
|
||||
$totEntradas = array();
|
||||
$totSalidas = array();
|
||||
$productos = array();
|
||||
$resCategorias = array();
|
||||
$resSubcats = array();
|
||||
foreach($resProds as $res){
|
||||
|
||||
$prodCatId = $res['prodCatId'];
|
||||
$prodSubcatId = $res['prodSubcatId'];
|
||||
|
||||
if($productoId > 0 && $res['productoId'] != $productoId)
|
||||
continue;
|
||||
|
||||
if(!in_array($prodCatId, $resCategorias))
|
||||
$resCategorias[] = $prodCatId;
|
||||
|
||||
if(count($resSubcats[$prodCatId]) == 0)
|
||||
$resSubcats[$prodCatId] = array();
|
||||
|
||||
$resSub = $resSubcats[$prodCatId];
|
||||
|
||||
if(!in_array($prodSubcatId, $resSub))
|
||||
$resSubcats[$prodCatId][] = $prodSubcatId;
|
||||
|
||||
if($res['fecha'] == 0)
|
||||
continue;
|
||||
|
||||
$res['modelo'] = utf8_encode($res['modelo']);
|
||||
|
||||
//Obtenemos el Saldo Inicial
|
||||
$fechaII = '2013-06-01';
|
||||
|
||||
$cantInicial = 0;
|
||||
$totalVtas = 0;
|
||||
$mostrar = false;
|
||||
$totalPzas = 0;
|
||||
$iniciales = array();
|
||||
$entradas = array();
|
||||
$salidas = array();
|
||||
for($m=0; $m<$meses; $m++){
|
||||
|
||||
$fechaIni = date('Y-m-01',strtotime('+'.$m.' month',$strFechaI));
|
||||
$fechaFin = date('Y-m-31',strtotime('+'.$m.' month',$strFechaI));
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$producto->setFechaIni($fechaIni);
|
||||
$producto->setFechaFin($fechaFin);
|
||||
|
||||
$producto->setSucursalId($sucursalId);
|
||||
$cantSalida = $producto->GetCantVendido();
|
||||
|
||||
$cantSalidaVtas = $cantSalida;
|
||||
|
||||
$totalVtas += $cantSalida;
|
||||
|
||||
$cantSalida += $producto->GetSalEnvTT();
|
||||
|
||||
$cantEntrada = $producto->GetCantTotalCompBySuc();
|
||||
$cantEntrada += $producto->GetEntEnvTT();
|
||||
|
||||
$cantEntradaA = $producto->GetEntAjusteEnv();
|
||||
$cantBloqueados = $producto->GetBloqueadosEnv();
|
||||
|
||||
$cantSalidaA = $producto->GetSalAjusteEnv();
|
||||
|
||||
//$cantEntradaA += $producto->GetEntAjusteExcel();
|
||||
|
||||
$totalPzas = ($cantInicial + $cantEntrada - $cantSalida + $cantEntradaA - $cantSalidaA - $cantBloqueados);
|
||||
|
||||
$totSubs[$prodSubcatId][$m]['inicial'] += $cantInicial;
|
||||
$totSubs[$prodSubcatId][$m]['entradas'] += $cantEntrada;
|
||||
$totSubs[$prodSubcatId][$m]['salidas'] += $cantSalida;
|
||||
$totSubs[$prodSubcatId][$m]['entradasA'] += $cantEntradaA;
|
||||
$totSubs[$prodSubcatId][$m]['salidasA'] += $cantSalidaA;
|
||||
$totSubs[$prodSubcatId][$m]['bloqueados'] += $cantBloqueados;
|
||||
|
||||
$totCats[$prodCatId][$m]['inicial'] += $cantInicial;
|
||||
$totCats[$prodCatId][$m]['entradas'] += $cantEntrada;
|
||||
$totCats[$prodCatId][$m]['salidas'] += $cantSalida;
|
||||
$totCats[$prodCatId][$m]['entradasA'] += $cantEntradaA;
|
||||
$totCats[$prodCatId][$m]['salidasA'] += $cantSalidaA;
|
||||
$totCats[$prodCatId][$m]['bloqueados'] += $cantBloqueados;
|
||||
|
||||
if($cantEntrada > 0 || $cantEntradaA > 0 || $cantInicial > 0)
|
||||
$mostrar = true;
|
||||
|
||||
if($cantSalida > 0 || $cantSalidaA > 0 || $cantInicial > 0)
|
||||
$mostrar = true;
|
||||
|
||||
if($mostrar == true){
|
||||
$iniciales[$m] = $cantInicial;
|
||||
$entradas[$m] = $cantEntrada;
|
||||
$salidas[$m] = $cantSalida;
|
||||
$entradasA[$m] = $cantEntradaA;
|
||||
$salidasA[$m] = $cantSalidaA;
|
||||
$bloqueados[$m] = $cantBloqueados;
|
||||
|
||||
$salidasVtas[$m] = $cantSalidaVtas;
|
||||
|
||||
$totIniciales[$m] += $cantInicial;
|
||||
$totEntradas[$m] += $cantEntrada;
|
||||
$totSalidas[$m] += $cantSalida;
|
||||
$totEntradasA[$m] += $cantEntradaA;
|
||||
$totSalidasA[$m] += $cantSalidaA;
|
||||
$totBloqueados[$m] += $cantBloqueados;
|
||||
}else{
|
||||
$iniciales[$m] = 0;
|
||||
$entradas[$m] = 0;
|
||||
$salidas[$m] = 0;
|
||||
$entradasA[$m] = 0;
|
||||
$salidasA[$m] = 0;
|
||||
$bloqueados[$m] = 0;
|
||||
|
||||
$salidasVtas[$m] = 0;
|
||||
}
|
||||
|
||||
$cantInicial = $cantInicial + $cantEntrada - $cantSalida + $cantEntradaA - $cantSalidaA - $cantBloqueados;
|
||||
|
||||
|
||||
}//for
|
||||
|
||||
$res['iniciales'] = $iniciales;
|
||||
$res['entradas'] = $entradas;
|
||||
$res['salidas'] = $salidas;
|
||||
$res['salidasVtas'] = $salidasVtas;
|
||||
$res['entradasA'] = $entradasA;
|
||||
$res['salidasA'] = $salidasA;
|
||||
$res['bloqueados'] = $bloqueados;
|
||||
$res['totalPzas'] = $totalPzas;
|
||||
$res['proveedor'] = $nomProv;
|
||||
|
||||
$res['importe'] = $res['costo'] * $totalPzas;
|
||||
|
||||
$res['totalVtas'] = $totalVtas;
|
||||
$res['precioVta'] = $infP['precioVentaIva'];
|
||||
$res['importeVtas'] = $totalVtas * $infP['precioVentaIva'];
|
||||
|
||||
$totSubs[$prodSubcatId]['totalPzas'] += $totalPzas;
|
||||
$totCats[$prodCatId]['totalPzas'] += $totalPzas;
|
||||
$totSubs[$prodSubcatId]['importe'] += $res['importe'];
|
||||
$totCats[$prodCatId]['importe'] += $res['importe'];
|
||||
|
||||
$totSubs[$prodSubcatId]['totalVtas'] += $totalVtas;
|
||||
$totCats[$prodCatId]['totalVtas'] += $totalVtas;
|
||||
$totSubs[$prodSubcatId]['importeVtas'] += $res['importeVtas'];
|
||||
$totCats[$prodCatId]['importeVtas'] += $res['importeVtas'];
|
||||
|
||||
$res['prodCatId'] = $infP['prodCatId'];
|
||||
$res['prodSubcatId'] = $infP['prodSubcatId'];
|
||||
|
||||
if($mostrar == true){
|
||||
$totPzas += $totalPzas;
|
||||
$totImporte += $res['importe'];
|
||||
|
||||
$totVtas += $totalVtas;
|
||||
$totImporteVtas += $res['importeVtas'];
|
||||
|
||||
$productos[$prodCatId][$prodSubcatId][] = $res;
|
||||
}
|
||||
|
||||
}//foreach
|
||||
|
||||
$categorias = array();
|
||||
foreach($resCategorias as $prodCatId){
|
||||
$card['prodCatId'] = $prodCatId;
|
||||
$prodCat->setProdCatId($prodCatId);
|
||||
$card['nombre'] = utf8_encode($prodCat->GetNameById());
|
||||
$categorias[] = $card;
|
||||
}
|
||||
|
||||
$subcategorias = array();
|
||||
foreach($resSubcats as $prodCatId => $subcats){
|
||||
$card = array();
|
||||
$subcats2 = array();
|
||||
foreach($subcats as $prodSubcatId){
|
||||
$card['prodSubcatId'] = $prodSubcatId;
|
||||
$prodSubcat->setProdSubcatId($prodSubcatId);
|
||||
$card['nombre'] = utf8_encode($prodSubcat->GetNameById());
|
||||
$subcats2[] = $card;
|
||||
}
|
||||
|
||||
$subcategorias[$prodCatId] = $subcats2;
|
||||
|
||||
}
|
||||
|
||||
$suc['productos'] = $productos;
|
||||
$suc['categorias'] = $categorias;
|
||||
$suc['subcategorias'] = $subcategorias;
|
||||
$suc['totSubs'] = $totSubs;
|
||||
$suc['totCats'] = $totCats;
|
||||
|
||||
$suc['totIniciales'] = $totIniciales;
|
||||
$suc['totEntradas'] = $totEntradas;
|
||||
$suc['totSalidas'] = $totSalidas;
|
||||
$suc['totEntradasA'] = $totEntradasA;
|
||||
$suc['totSalidasA'] = $totSalidasA;
|
||||
$suc['totBloqueados'] = $totBloqueados;
|
||||
$suc['totPzas'] = $totPzas;
|
||||
$suc['totImporte'] = $totImporte;
|
||||
$suc['totVtas'] = $totVtas;
|
||||
$suc['totImporteVtas'] = $totImporteVtas;
|
||||
|
||||
$sucursales[] = $suc;
|
||||
|
||||
}//foreach
|
||||
|
||||
//****
|
||||
|
||||
$serialize = urlencode(serialize($sucursales));
|
||||
|
||||
$sql = "REPLACE INTO `reporteProvBest` (
|
||||
`proveedorId` ,
|
||||
`fecha` ,
|
||||
`reporte` ,
|
||||
`sucursal`
|
||||
)
|
||||
VALUES (
|
||||
'".$proveedorId."',
|
||||
'".date("Y-m-d H:i:s")."',
|
||||
'".$serialize."',
|
||||
'')"
|
||||
;
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$util->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
}//foreach
|
||||
|
||||
echo 'Done';
|
||||
|
||||
$end = microtime(true);
|
||||
echo "Tiempo de Ejecucion: ";
|
||||
echo $time = number_format(($end - $start), 2);
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
123
crons/reporte-inventario.php
Executable file
123
crons/reporte-inventario.php
Executable file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
include_once('/home/novomoda/public_html/sistema/init.php');
|
||||
include_once('/home/novomoda/public_html/sistema/config.php');
|
||||
include_once(DOC_ROOT.'/libraries.php');
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
$start = microtime(true);
|
||||
|
||||
$reportes->setIdSuc(0);
|
||||
$resSuc = $reportes->EnumSucursales();
|
||||
|
||||
$sql = 'SELECT proveedorId FROM proveedor
|
||||
ORDER BY proveedorId ASC
|
||||
LIMIT 0,40';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
foreach($proveedores as $prov){
|
||||
|
||||
$proveedorId = $prov['proveedorId'];
|
||||
|
||||
$sqlFilter = ' AND p.proveedorId = '.$proveedorId;
|
||||
|
||||
$dispGral = 0;
|
||||
$totalGral = 0;
|
||||
$totalGralPV = 0;
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $res){
|
||||
|
||||
$sql = 'SELECT prov.nombre, p.productoId, p.costo, p.codigoBarra, p.modelo, p.precioVentaIva,
|
||||
p.prodCatId, p.prodSubcatId,
|
||||
SUM( i.cantidad ) AS disponible, (SUM( i.cantidad ) * p.costo) AS total,
|
||||
(SUM( i.cantidad ) * p.precioVentaIva) AS totalPV,
|
||||
prov.nombre AS proveedor
|
||||
FROM producto p, inventario i, proveedor prov
|
||||
WHERE p.productoId = i.productoId
|
||||
AND p.proveedorId = prov.proveedorId
|
||||
AND i.sucursalId = '.$res['sucursalId'].'
|
||||
'.$sqlFilter.'
|
||||
AND i.status = "Disponible"
|
||||
GROUP BY i.productoId
|
||||
ORDER BY p.codigoBarra ASC';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$resProductos = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
$totalSinDesc = 0;
|
||||
$productos = array();
|
||||
foreach($resProductos as $prod){
|
||||
|
||||
$prod['nombre'] = utf8_encode($prod['nombre']);
|
||||
$prod['modelo'] = utf8_encode($prod['modelo']);
|
||||
|
||||
$inventario->setSucursalId($res['sucursalId']);
|
||||
$inventario->setProductoId($prod['productoId']);
|
||||
$vtasSinDesc = $inventario->VentasDescontadas();
|
||||
|
||||
$totalSinDesc += $vtasSinDesc;
|
||||
$prod['disponible'] -= $vtasSinDesc;
|
||||
|
||||
$productos[] = $prod;
|
||||
}
|
||||
$res['productos'] = $productos;
|
||||
|
||||
//Obtenemos los Totales
|
||||
|
||||
$sql = 'SELECT SUM(i.cantidad) AS disponible, SUM(i.cantidad * p.costo) AS total,
|
||||
SUM(i.cantidad * p.precioVentaIva) AS totalPV
|
||||
FROM producto p, inventario i, proveedor prov
|
||||
WHERE p.productoId = i.productoId
|
||||
AND p.proveedorId = prov.proveedorId
|
||||
AND i.sucursalId = '.$res['sucursalId'].'
|
||||
'.$sqlFilter.'
|
||||
AND i.status = "Disponible"';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$row = $util->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
$row['disponible'] -= $totalSinDesc;
|
||||
|
||||
$res['disponible'] = $row['disponible'];
|
||||
$res['total'] = $row['total'];
|
||||
$res['totalPV'] = $row['totalPV'];
|
||||
|
||||
$dispGral += $row['disponible'];
|
||||
$totalGral += $row['total'];
|
||||
$totalGralPV += $row['totalPV'];
|
||||
|
||||
$sucursales[] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
$serialize = urlencode(serialize($sucursales));
|
||||
|
||||
$sql = "REPLACE INTO `reporteInvBest` (
|
||||
`proveedorId` ,
|
||||
`fecha` ,
|
||||
`reporte` ,
|
||||
`sucursal`
|
||||
)
|
||||
VALUES (
|
||||
'".$proveedorId."',
|
||||
'".date("Y-m-d H:i:s")."',
|
||||
'".$serialize."',
|
||||
'')"
|
||||
;
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$util->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
}//foreach
|
||||
|
||||
echo 'Done';
|
||||
|
||||
$end = microtime(true);
|
||||
echo "Tiempo de Ejecucion: ";
|
||||
echo $time = number_format(($end - $start), 2);
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
1
crons/reporte-inventario.txt
Executable file
1
crons/reporte-inventario.txt
Executable file
@@ -0,0 +1 @@
|
||||
DoneTiempo de Ejecucion: 78.55
|
||||
123
crons/reporte-inventario2.php
Executable file
123
crons/reporte-inventario2.php
Executable file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
include_once('/home/novomoda/public_html/sistema/init.php');
|
||||
include_once('/home/novomoda/public_html/sistema/config.php');
|
||||
include_once(DOC_ROOT.'/libraries.php');
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
$start = microtime(true);
|
||||
|
||||
$reportes->setIdSuc(0);
|
||||
$resSuc = $reportes->EnumSucursales();
|
||||
|
||||
$sql = 'SELECT proveedorId FROM proveedor
|
||||
ORDER BY proveedorId ASC
|
||||
LIMIT 40,40';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
foreach($proveedores as $prov){
|
||||
|
||||
$proveedorId = $prov['proveedorId'];
|
||||
|
||||
$sqlFilter = ' AND p.proveedorId = '.$proveedorId;
|
||||
|
||||
$dispGral = 0;
|
||||
$totalGral = 0;
|
||||
$totalGralPV = 0;
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $res){
|
||||
|
||||
$sql = 'SELECT prov.nombre, p.productoId, p.costo, p.codigoBarra, p.modelo, p.precioVentaIva,
|
||||
p.prodCatId, p.prodSubcatId,
|
||||
SUM( i.cantidad ) AS disponible, (SUM( i.cantidad ) * p.costo) AS total,
|
||||
(SUM( i.cantidad ) * p.precioVentaIva) AS totalPV,
|
||||
prov.nombre AS proveedor
|
||||
FROM producto p, inventario i, proveedor prov
|
||||
WHERE p.productoId = i.productoId
|
||||
AND p.proveedorId = prov.proveedorId
|
||||
AND i.sucursalId = '.$res['sucursalId'].'
|
||||
'.$sqlFilter.'
|
||||
AND i.status = "Disponible"
|
||||
GROUP BY i.productoId
|
||||
ORDER BY p.codigoBarra ASC';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$resProductos = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
$totalSinDesc = 0;
|
||||
$productos = array();
|
||||
foreach($resProductos as $prod){
|
||||
|
||||
$prod['nombre'] = utf8_encode($prod['nombre']);
|
||||
$prod['modelo'] = utf8_encode($prod['modelo']);
|
||||
|
||||
$inventario->setSucursalId($res['sucursalId']);
|
||||
$inventario->setProductoId($prod['productoId']);
|
||||
$vtasSinDesc = $inventario->VentasDescontadas();
|
||||
|
||||
$totalSinDesc += $vtasSinDesc;
|
||||
$prod['disponible'] -= $vtasSinDesc;
|
||||
|
||||
$productos[] = $prod;
|
||||
}
|
||||
$res['productos'] = $productos;
|
||||
|
||||
//Obtenemos los Totales
|
||||
|
||||
$sql = 'SELECT SUM(i.cantidad) AS disponible, SUM(i.cantidad * p.costo) AS total,
|
||||
SUM(i.cantidad * p.precioVentaIva) AS totalPV
|
||||
FROM producto p, inventario i, proveedor prov
|
||||
WHERE p.productoId = i.productoId
|
||||
AND p.proveedorId = prov.proveedorId
|
||||
AND i.sucursalId = '.$res['sucursalId'].'
|
||||
'.$sqlFilter.'
|
||||
AND i.status = "Disponible"';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$row = $util->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
$row['disponible'] -= $totalSinDesc;
|
||||
|
||||
$res['disponible'] = $row['disponible'];
|
||||
$res['total'] = $row['total'];
|
||||
$res['totalPV'] = $row['totalPV'];
|
||||
|
||||
$dispGral += $row['disponible'];
|
||||
$totalGral += $row['total'];
|
||||
$totalGralPV += $row['totalPV'];
|
||||
|
||||
$sucursales[] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
$serialize = urlencode(serialize($sucursales));
|
||||
|
||||
$sql = "REPLACE INTO `reporteInvBest` (
|
||||
`proveedorId` ,
|
||||
`fecha` ,
|
||||
`reporte` ,
|
||||
`sucursal`
|
||||
)
|
||||
VALUES (
|
||||
'".$proveedorId."',
|
||||
'".date("Y-m-d H:i:s")."',
|
||||
'".$serialize."',
|
||||
'')"
|
||||
;
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$util->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
}//foreach
|
||||
|
||||
echo 'Done';
|
||||
|
||||
$end = microtime(true);
|
||||
echo "Tiempo de Ejecucion: ";
|
||||
echo $time = number_format(($end - $start), 2);
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
1
crons/reporte-inventario2.txt
Executable file
1
crons/reporte-inventario2.txt
Executable file
@@ -0,0 +1 @@
|
||||
DoneTiempo de Ejecucion: 375.05
|
||||
123
crons/reporte-inventario3.php
Executable file
123
crons/reporte-inventario3.php
Executable file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
include_once('/home/novomoda/public_html/sistema/init.php');
|
||||
include_once('/home/novomoda/public_html/sistema/config.php');
|
||||
include_once(DOC_ROOT.'/libraries.php');
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
$start = microtime(true);
|
||||
|
||||
$reportes->setIdSuc(0);
|
||||
$resSuc = $reportes->EnumSucursales();
|
||||
|
||||
$sql = 'SELECT proveedorId FROM proveedor
|
||||
ORDER BY proveedorId ASC
|
||||
LIMIT 80,40';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
foreach($proveedores as $prov){
|
||||
|
||||
$proveedorId = $prov['proveedorId'];
|
||||
|
||||
$sqlFilter = ' AND p.proveedorId = '.$proveedorId;
|
||||
|
||||
$dispGral = 0;
|
||||
$totalGral = 0;
|
||||
$totalGralPV = 0;
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $res){
|
||||
|
||||
$sql = 'SELECT prov.nombre, p.productoId, p.costo, p.codigoBarra, p.modelo, p.precioVentaIva,
|
||||
p.prodCatId, p.prodSubcatId,
|
||||
SUM( i.cantidad ) AS disponible, (SUM( i.cantidad ) * p.costo) AS total,
|
||||
(SUM( i.cantidad ) * p.precioVentaIva) AS totalPV,
|
||||
prov.nombre AS proveedor
|
||||
FROM producto p, inventario i, proveedor prov
|
||||
WHERE p.productoId = i.productoId
|
||||
AND p.proveedorId = prov.proveedorId
|
||||
AND i.sucursalId = '.$res['sucursalId'].'
|
||||
'.$sqlFilter.'
|
||||
AND i.status = "Disponible"
|
||||
GROUP BY i.productoId
|
||||
ORDER BY p.codigoBarra ASC';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$resProductos = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
$totalSinDesc = 0;
|
||||
$productos = array();
|
||||
foreach($resProductos as $prod){
|
||||
|
||||
$prod['nombre'] = utf8_encode($prod['nombre']);
|
||||
$prod['modelo'] = utf8_encode($prod['modelo']);
|
||||
|
||||
$inventario->setSucursalId($res['sucursalId']);
|
||||
$inventario->setProductoId($prod['productoId']);
|
||||
$vtasSinDesc = $inventario->VentasDescontadas();
|
||||
|
||||
$totalSinDesc += $vtasSinDesc;
|
||||
$prod['disponible'] -= $vtasSinDesc;
|
||||
|
||||
$productos[] = $prod;
|
||||
}
|
||||
$res['productos'] = $productos;
|
||||
|
||||
//Obtenemos los Totales
|
||||
|
||||
$sql = 'SELECT SUM(i.cantidad) AS disponible, SUM(i.cantidad * p.costo) AS total,
|
||||
SUM(i.cantidad * p.precioVentaIva) AS totalPV
|
||||
FROM producto p, inventario i, proveedor prov
|
||||
WHERE p.productoId = i.productoId
|
||||
AND p.proveedorId = prov.proveedorId
|
||||
AND i.sucursalId = '.$res['sucursalId'].'
|
||||
'.$sqlFilter.'
|
||||
AND i.status = "Disponible"';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$row = $util->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
$row['disponible'] -= $totalSinDesc;
|
||||
|
||||
$res['disponible'] = $row['disponible'];
|
||||
$res['total'] = $row['total'];
|
||||
$res['totalPV'] = $row['totalPV'];
|
||||
|
||||
$dispGral += $row['disponible'];
|
||||
$totalGral += $row['total'];
|
||||
$totalGralPV += $row['totalPV'];
|
||||
|
||||
$sucursales[] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
$serialize = urlencode(serialize($sucursales));
|
||||
|
||||
$sql = "REPLACE INTO `reporteInvBest` (
|
||||
`proveedorId` ,
|
||||
`fecha` ,
|
||||
`reporte` ,
|
||||
`sucursal`
|
||||
)
|
||||
VALUES (
|
||||
'".$proveedorId."',
|
||||
'".date("Y-m-d H:i:s")."',
|
||||
'".$serialize."',
|
||||
'')"
|
||||
;
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$util->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
}//foreach
|
||||
|
||||
echo 'Done';
|
||||
|
||||
$end = microtime(true);
|
||||
echo "Tiempo de Ejecucion: ";
|
||||
echo $time = number_format(($end - $start), 2);
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
1
crons/reporte-inventario3.txt
Executable file
1
crons/reporte-inventario3.txt
Executable file
@@ -0,0 +1 @@
|
||||
DoneTiempo de Ejecucion: 590.89
|
||||
123
crons/reporte-inventario4.php
Executable file
123
crons/reporte-inventario4.php
Executable file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
include_once('/home/novomoda/public_html/sistema/init.php');
|
||||
include_once('/home/novomoda/public_html/sistema/config.php');
|
||||
include_once(DOC_ROOT.'/libraries.php');
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
$start = microtime(true);
|
||||
|
||||
$reportes->setIdSuc(0);
|
||||
$resSuc = $reportes->EnumSucursales();
|
||||
|
||||
$sql = 'SELECT proveedorId FROM proveedor
|
||||
ORDER BY proveedorId ASC
|
||||
LIMIT 120,40';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
foreach($proveedores as $prov){
|
||||
|
||||
$proveedorId = $prov['proveedorId'];
|
||||
|
||||
$sqlFilter = ' AND p.proveedorId = '.$proveedorId;
|
||||
|
||||
$dispGral = 0;
|
||||
$totalGral = 0;
|
||||
$totalGralPV = 0;
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $res){
|
||||
|
||||
$sql = 'SELECT prov.nombre, p.productoId, p.costo, p.codigoBarra, p.modelo, p.precioVentaIva,
|
||||
p.prodCatId, p.prodSubcatId,
|
||||
SUM( i.cantidad ) AS disponible, (SUM( i.cantidad ) * p.costo) AS total,
|
||||
(SUM( i.cantidad ) * p.precioVentaIva) AS totalPV,
|
||||
prov.nombre AS proveedor
|
||||
FROM producto p, inventario i, proveedor prov
|
||||
WHERE p.productoId = i.productoId
|
||||
AND p.proveedorId = prov.proveedorId
|
||||
AND i.sucursalId = '.$res['sucursalId'].'
|
||||
'.$sqlFilter.'
|
||||
AND i.status = "Disponible"
|
||||
GROUP BY i.productoId
|
||||
ORDER BY p.codigoBarra ASC';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$resProductos = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
$totalSinDesc = 0;
|
||||
$productos = array();
|
||||
foreach($resProductos as $prod){
|
||||
|
||||
$prod['nombre'] = utf8_encode($prod['nombre']);
|
||||
$prod['modelo'] = utf8_encode($prod['modelo']);
|
||||
|
||||
$inventario->setSucursalId($res['sucursalId']);
|
||||
$inventario->setProductoId($prod['productoId']);
|
||||
$vtasSinDesc = $inventario->VentasDescontadas();
|
||||
|
||||
$totalSinDesc += $vtasSinDesc;
|
||||
$prod['disponible'] -= $vtasSinDesc;
|
||||
|
||||
$productos[] = $prod;
|
||||
}
|
||||
$res['productos'] = $productos;
|
||||
|
||||
//Obtenemos los Totales
|
||||
|
||||
$sql = 'SELECT SUM(i.cantidad) AS disponible, SUM(i.cantidad * p.costo) AS total,
|
||||
SUM(i.cantidad * p.precioVentaIva) AS totalPV
|
||||
FROM producto p, inventario i, proveedor prov
|
||||
WHERE p.productoId = i.productoId
|
||||
AND p.proveedorId = prov.proveedorId
|
||||
AND i.sucursalId = '.$res['sucursalId'].'
|
||||
'.$sqlFilter.'
|
||||
AND i.status = "Disponible"';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$row = $util->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
$row['disponible'] -= $totalSinDesc;
|
||||
|
||||
$res['disponible'] = $row['disponible'];
|
||||
$res['total'] = $row['total'];
|
||||
$res['totalPV'] = $row['totalPV'];
|
||||
|
||||
$dispGral += $row['disponible'];
|
||||
$totalGral += $row['total'];
|
||||
$totalGralPV += $row['totalPV'];
|
||||
|
||||
$sucursales[] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
$serialize = urlencode(serialize($sucursales));
|
||||
|
||||
$sql = "REPLACE INTO `reporteInvBest` (
|
||||
`proveedorId` ,
|
||||
`fecha` ,
|
||||
`reporte` ,
|
||||
`sucursal`
|
||||
)
|
||||
VALUES (
|
||||
'".$proveedorId."',
|
||||
'".date("Y-m-d H:i:s")."',
|
||||
'".$serialize."',
|
||||
'')"
|
||||
;
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$util->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
}//foreach
|
||||
|
||||
echo 'Done';
|
||||
|
||||
$end = microtime(true);
|
||||
echo "Tiempo de Ejecucion: ";
|
||||
echo $time = number_format(($end - $start), 2);
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
12
crons/reporte-inventario4.txt
Executable file
12
crons/reporte-inventario4.txt
Executable file
@@ -0,0 +1,12 @@
|
||||
|
||||
Notice: REPLACE INTO `reporteInvBest` (
|
||||
`proveedorId` ,
|
||||
`fecha` ,
|
||||
`reporte` ,
|
||||
`sucursal`
|
||||
)
|
||||
VALUES (
|
||||
'560',
|
||||
'2014-07-22 22:30:46',
|
||||
'a%3A28%3A%7Bi%3A0%3Ba%3A6%3A%7Bs%3A10%3A%22sucursalId%22%3Bs%3A2%3A%2232%22%3Bs%3A6%3A%22nombre%22%3Bs%3A19%3A%2200%2520Bodega%2520Lerma%22%3Bs%3A9%3A%22productos%22%3Ba%3A70%3A%7Bi%3A0%3Ba%3A12%3A%7Bs%3A6%3A%22nombre%22%3Bs%3A38%3A%22SURTIDORA+DE+PRENDAS+MAS%2C+S.A.+DE+C.V.%22%3Bs%3A10%3A%22productoId%22%3Bs%3A4%3A%226093%22%3Bs%3A5%3A%22costo%22%3Bs%3A5%3A%2217.24%22%3Bs%3A11%3A%22codigoBarra%22%3Bs%3A16%3A%227506159311644-01%22%3Bs%3A6%3A%22modelo%22%3Bs%3A46%3A%22BUFANDA+NI%C3%91A+%28SURT.+PRENDAS%29+SB030+ANIMALITO.%22%3Bs%3A14%3A%22precioVentaIva%22%3Bs%3A5%3A%2239.99%22%3Bs%3A9%3A%22prodCatId%22%3Bs%3A1%3A%224%22%3Bs%3A12%3A%22prodSubcatId%22%3Bs%3A3%3A%22258%22%3Bs%3A10%3A%22disponible%22%3Bi%3A32%3Bs%3A5%3A%22total%22%3Bs%3A6%3A%22551.68%22%3Bs%3A7%3A%22totalPV%22%3Bs%3A7%3A%221279.68%22%3Bs%3A9%3A%22proveedor%22%3Bs%3A38%3A%22SURTIDORA+DE in /home/novomoda/domains/novomoda.com.mx/public_html/sistema/classes/db.class.php on line 103
|
||||
1
|
||||
123
crons/reporte-inventario5.php
Executable file
123
crons/reporte-inventario5.php
Executable file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
include_once('/home/novomoda/public_html/sistema/init.php');
|
||||
include_once('/home/novomoda/public_html/sistema/config.php');
|
||||
include_once(DOC_ROOT.'/libraries.php');
|
||||
|
||||
if(!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
$_SESSION['empresaId'] = 15;
|
||||
|
||||
$start = microtime(true);
|
||||
|
||||
$reportes->setIdSuc(0);
|
||||
$resSuc = $reportes->EnumSucursales();
|
||||
|
||||
$sql = 'SELECT proveedorId FROM proveedor
|
||||
ORDER BY proveedorId ASC
|
||||
LIMIT 160,100';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
foreach($proveedores as $prov){
|
||||
|
||||
$proveedorId = $prov['proveedorId'];
|
||||
|
||||
$sqlFilter = ' AND p.proveedorId = '.$proveedorId;
|
||||
|
||||
$dispGral = 0;
|
||||
$totalGral = 0;
|
||||
$totalGralPV = 0;
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $res){
|
||||
|
||||
$sql = 'SELECT prov.nombre, p.productoId, p.costo, p.codigoBarra, p.modelo, p.precioVentaIva,
|
||||
p.prodCatId, p.prodSubcatId,
|
||||
SUM( i.cantidad ) AS disponible, (SUM( i.cantidad ) * p.costo) AS total,
|
||||
(SUM( i.cantidad ) * p.precioVentaIva) AS totalPV,
|
||||
prov.nombre AS proveedor
|
||||
FROM producto p, inventario i, proveedor prov
|
||||
WHERE p.productoId = i.productoId
|
||||
AND p.proveedorId = prov.proveedorId
|
||||
AND i.sucursalId = '.$res['sucursalId'].'
|
||||
'.$sqlFilter.'
|
||||
AND i.status = "Disponible"
|
||||
GROUP BY i.productoId
|
||||
ORDER BY p.codigoBarra ASC';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$resProductos = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
$totalSinDesc = 0;
|
||||
$productos = array();
|
||||
foreach($resProductos as $prod){
|
||||
|
||||
$prod['nombre'] = utf8_encode($prod['nombre']);
|
||||
$prod['modelo'] = utf8_encode($prod['modelo']);
|
||||
|
||||
$inventario->setSucursalId($res['sucursalId']);
|
||||
$inventario->setProductoId($prod['productoId']);
|
||||
$vtasSinDesc = $inventario->VentasDescontadas();
|
||||
|
||||
$totalSinDesc += $vtasSinDesc;
|
||||
$prod['disponible'] -= $vtasSinDesc;
|
||||
|
||||
$productos[] = $prod;
|
||||
}
|
||||
$res['productos'] = $productos;
|
||||
|
||||
//Obtenemos los Totales
|
||||
|
||||
$sql = 'SELECT SUM(i.cantidad) AS disponible, SUM(i.cantidad * p.costo) AS total,
|
||||
SUM(i.cantidad * p.precioVentaIva) AS totalPV
|
||||
FROM producto p, inventario i, proveedor prov
|
||||
WHERE p.productoId = i.productoId
|
||||
AND p.proveedorId = prov.proveedorId
|
||||
AND i.sucursalId = '.$res['sucursalId'].'
|
||||
'.$sqlFilter.'
|
||||
AND i.status = "Disponible"';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$row = $util->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
$row['disponible'] -= $totalSinDesc;
|
||||
|
||||
$res['disponible'] = $row['disponible'];
|
||||
$res['total'] = $row['total'];
|
||||
$res['totalPV'] = $row['totalPV'];
|
||||
|
||||
$dispGral += $row['disponible'];
|
||||
$totalGral += $row['total'];
|
||||
$totalGralPV += $row['totalPV'];
|
||||
|
||||
$sucursales[] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
$serialize = urlencode(serialize($sucursales));
|
||||
|
||||
$sql = "REPLACE INTO `reporteInvBest` (
|
||||
`proveedorId` ,
|
||||
`fecha` ,
|
||||
`reporte` ,
|
||||
`sucursal`
|
||||
)
|
||||
VALUES (
|
||||
'".$proveedorId."',
|
||||
'".date("Y-m-d H:i:s")."',
|
||||
'".$serialize."',
|
||||
'')"
|
||||
;
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$util->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
}//foreach
|
||||
|
||||
echo 'Done';
|
||||
|
||||
$end = microtime(true);
|
||||
echo "Tiempo de Ejecucion: ";
|
||||
echo $time = number_format(($end - $start), 2);
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
0
crons/reporte-inventario5.txt
Executable file
0
crons/reporte-inventario5.txt
Executable file
@@ -0,0 +1,342 @@
|
||||
<?php /* Smarty version Smarty3-b7, created on 2014-03-25 13:18:03
|
||||
compiled from "/home/avantikads/domains/avantikads.com/public_html/novomoda/templates/lists/reportes-prod-prov-item.tpl" */ ?>
|
||||
<?php /*%%SmartyHeaderCode:6260259835331d66b957321-86299010%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
|
||||
$_smarty_tpl->decodeProperties(array (
|
||||
'file_dependency' =>
|
||||
array (
|
||||
'277ea483755c3f5c606c1b1bf0a1e298e5fc409a' =>
|
||||
array (
|
||||
0 => '/home/avantikads/domains/avantikads.com/public_html/novomoda/templates/lists/reportes-prod-prov-item.tpl',
|
||||
1 => 1391008846,
|
||||
),
|
||||
),
|
||||
'nocache_hash' => '6260259835331d66b957321-86299010',
|
||||
'function' =>
|
||||
array (
|
||||
),
|
||||
'has_nocache_code' => false,
|
||||
)); /*/%%SmartyHeaderCode%%*/?>
|
||||
<?php if (!is_callable('smarty_modifier_date_format')) include '/home/avantikads/domains/avantikads.com/public_html/novomoda/libs/plugins/modifier.date_format.php';
|
||||
?><table width="<?php echo $_smarty_tpl->getVariable('width')->value;?>
|
||||
" cellpadding="0" cellspacing="0" id="tblProdProv" border="0" bgcolor="#FFFFFF" class="sortable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="60"></th>
|
||||
<th width="60"></th>
|
||||
<th width="100"></th>
|
||||
<th width="100"></th>
|
||||
<th width="200"></th>
|
||||
<th width="60"></th>
|
||||
<?php $_smarty_tpl->tpl_vars['mes'] = new Smarty_Variable;
|
||||
$_smarty_tpl->tpl_vars['kP'] = new Smarty_Variable;
|
||||
$_from = $_smarty_tpl->getVariable('periodo')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
|
||||
if (count($_from) > 0){
|
||||
foreach ($_from as $_smarty_tpl->tpl_vars['mes']->key => $_smarty_tpl->tpl_vars['mes']->value){
|
||||
$_smarty_tpl->tpl_vars['kP']->value = $_smarty_tpl->tpl_vars['mes']->key;
|
||||
?>
|
||||
<th width="300" colspan="5"><b><?php echo $_smarty_tpl->getVariable('mes')->value;?>
|
||||
</b></th>
|
||||
<?php }} ?>
|
||||
<th width="100"></th>
|
||||
<th width="80"></th>
|
||||
<th width="80"></th>
|
||||
<th width="100"></th>
|
||||
|
||||
<th width="80"></th>
|
||||
<th width="80"></th>
|
||||
<th width="100"></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Depto.</th>
|
||||
<th>Línea</th>
|
||||
<th>Clave</th>
|
||||
<th><b>Código</b></th>
|
||||
<th><b>Producto</b></th>
|
||||
<th><b>No. Prov.</b></th>
|
||||
<?php $_smarty_tpl->tpl_vars['mes'] = new Smarty_Variable;
|
||||
$_smarty_tpl->tpl_vars['kP'] = new Smarty_Variable;
|
||||
$_from = $_smarty_tpl->getVariable('periodo')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
|
||||
if (count($_from) > 0){
|
||||
foreach ($_from as $_smarty_tpl->tpl_vars['mes']->key => $_smarty_tpl->tpl_vars['mes']->value){
|
||||
$_smarty_tpl->tpl_vars['kP']->value = $_smarty_tpl->tpl_vars['mes']->key;
|
||||
?>
|
||||
<th><b>Inicial</b></th>
|
||||
<th><b>Entrada</b></th>
|
||||
<th><b>Salida</b></th>
|
||||
<th><b>Ajuste Entrada</b></th>
|
||||
<th><b>Ajuste Salida</b></th>
|
||||
<?php }} ?>
|
||||
<th><b>Ultima Compra</b></th>
|
||||
<th><b>Total Piezas</b></th>
|
||||
<th><b>Costo</b></th>
|
||||
<th><b>Importe Total de Inv.</b></th>
|
||||
<th><b>Total Ventas</b></th>
|
||||
<th><b>Precio Venta</b></th>
|
||||
<th><b>Importe Total Ventas</b></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php $_smarty_tpl->tpl_vars['item'] = new Smarty_Variable;
|
||||
$_smarty_tpl->tpl_vars['key'] = new Smarty_Variable;
|
||||
$_from = $_smarty_tpl->getVariable('suc')->value['categorias']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
|
||||
if (count($_from) > 0){
|
||||
foreach ($_from as $_smarty_tpl->tpl_vars['item']->key => $_smarty_tpl->tpl_vars['item']->value){
|
||||
$_smarty_tpl->tpl_vars['key']->value = $_smarty_tpl->tpl_vars['item']->key;
|
||||
?>
|
||||
<tr>
|
||||
<td align="center"><?php echo $_smarty_tpl->getVariable('item')->value['prodCatId'];?>
|
||||
</td>
|
||||
<td align="center"><?php echo $_smarty_tpl->getVariable('item')->value['prodSubcatId'];?>
|
||||
</td>
|
||||
<td align="left" colspan="2"><?php echo $_smarty_tpl->getVariable('item')->value['nombre'];?>
|
||||
</td>
|
||||
<td align="left"></td>
|
||||
<td align="center"></td>
|
||||
<?php $_smarty_tpl->tpl_vars['p'] = new Smarty_Variable;
|
||||
$_smarty_tpl->tpl_vars['kP'] = new Smarty_Variable;
|
||||
$_from = $_smarty_tpl->getVariable('periodo')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
|
||||
if (count($_from) > 0){
|
||||
foreach ($_from as $_smarty_tpl->tpl_vars['p']->key => $_smarty_tpl->tpl_vars['p']->value){
|
||||
$_smarty_tpl->tpl_vars['kP']->value = $_smarty_tpl->tpl_vars['p']->key;
|
||||
?>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<?php }} ?>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="right"></td>
|
||||
</tr>
|
||||
<?php ob_start();?><?php echo $_smarty_tpl->getVariable('item')->value['prodCatId'];?>
|
||||
<?php $_tmp1=ob_get_clean();?><?php $_smarty_tpl->tpl_vars['iS'] = new Smarty_Variable;
|
||||
$_smarty_tpl->tpl_vars['kS'] = new Smarty_Variable;
|
||||
$_from = $_smarty_tpl->getVariable('suc')->value['subcategorias'][$_tmp1]; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
|
||||
if (count($_from) > 0){
|
||||
foreach ($_from as $_smarty_tpl->tpl_vars['iS']->key => $_smarty_tpl->tpl_vars['iS']->value){
|
||||
$_smarty_tpl->tpl_vars['kS']->value = $_smarty_tpl->tpl_vars['iS']->key;
|
||||
?>
|
||||
<tr>
|
||||
<td align="center"><?php echo $_smarty_tpl->getVariable('item')->value['prodCatId'];?>
|
||||
</td>
|
||||
<td align="center"><?php echo $_smarty_tpl->getVariable('iS')->value['prodSubcatId'];?>
|
||||
</td>
|
||||
<td align="left" colspan="2"><?php echo $_smarty_tpl->getVariable('iS')->value['nombre'];?>
|
||||
</td>
|
||||
<td align="left"></td>
|
||||
<td align="center"></td>
|
||||
<?php $_smarty_tpl->tpl_vars['p'] = new Smarty_Variable;
|
||||
$_smarty_tpl->tpl_vars['kP'] = new Smarty_Variable;
|
||||
$_from = $_smarty_tpl->getVariable('periodo')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
|
||||
if (count($_from) > 0){
|
||||
foreach ($_from as $_smarty_tpl->tpl_vars['p']->key => $_smarty_tpl->tpl_vars['p']->value){
|
||||
$_smarty_tpl->tpl_vars['kP']->value = $_smarty_tpl->tpl_vars['p']->key;
|
||||
?>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<?php }} ?>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="right"></td>
|
||||
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
</tr>
|
||||
|
||||
<?php ob_start();?><?php echo $_smarty_tpl->getVariable('item')->value['prodCatId'];?>
|
||||
<?php $_tmp2=ob_get_clean();?><?php ob_start();?><?php echo $_smarty_tpl->getVariable('iS')->value['prodSubcatId'];?>
|
||||
<?php $_tmp3=ob_get_clean();?><?php $_smarty_tpl->tpl_vars['iP'] = new Smarty_Variable;
|
||||
$_smarty_tpl->tpl_vars['kP'] = new Smarty_Variable;
|
||||
$_from = $_smarty_tpl->getVariable('suc')->value['productos'][$_tmp2][$_tmp3]; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
|
||||
if (count($_from) > 0){
|
||||
foreach ($_from as $_smarty_tpl->tpl_vars['iP']->key => $_smarty_tpl->tpl_vars['iP']->value){
|
||||
$_smarty_tpl->tpl_vars['kP']->value = $_smarty_tpl->tpl_vars['iP']->key;
|
||||
?>
|
||||
<tr>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center"><?php echo $_smarty_tpl->getVariable('iP')->value['codigoBarra'];?>
|
||||
</td>
|
||||
<td align="left"><?php echo $_smarty_tpl->getVariable('iP')->value['modelo'];?>
|
||||
</td>
|
||||
<td align="center"><?php echo $_smarty_tpl->getVariable('iP')->value['proveedorId'];?>
|
||||
</td>
|
||||
<?php $_smarty_tpl->tpl_vars['p'] = new Smarty_Variable;
|
||||
$_smarty_tpl->tpl_vars['kP'] = new Smarty_Variable;
|
||||
$_from = $_smarty_tpl->getVariable('periodo')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
|
||||
if (count($_from) > 0){
|
||||
foreach ($_from as $_smarty_tpl->tpl_vars['p']->key => $_smarty_tpl->tpl_vars['p']->value){
|
||||
$_smarty_tpl->tpl_vars['kP']->value = $_smarty_tpl->tpl_vars['p']->key;
|
||||
?>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('iP')->value['iniciales'][$_smarty_tpl->getVariable('kP')->value],0,'.','');?>
|
||||
</td>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('iP')->value['entradas'][$_smarty_tpl->getVariable('kP')->value],0,'.','');?>
|
||||
</td>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('iP')->value['salidas'][$_smarty_tpl->getVariable('kP')->value],0,'.','');?>
|
||||
</td>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('iP')->value['entradasA'][$_smarty_tpl->getVariable('kP')->value],0,'.','');?>
|
||||
</td>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('iP')->value['salidasA'][$_smarty_tpl->getVariable('kP')->value],0,'.','');?>
|
||||
</td>
|
||||
<?php }} ?>
|
||||
<td align="center"><?php echo smarty_modifier_date_format($_smarty_tpl->getVariable('iP')->value['fecha'],"%d-%m-%Y");?>
|
||||
</td>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('iP')->value['totalPzas'],0,'.','');?>
|
||||
</td>
|
||||
<td align="center">$<?php echo number_format($_smarty_tpl->getVariable('iP')->value['costo'],2,'.','');?>
|
||||
</td>
|
||||
<td align="right">$<?php echo number_format($_smarty_tpl->getVariable('iP')->value['importe'],2,'.','');?>
|
||||
</td>
|
||||
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('iP')->value['totalVtas'],0,'.','');?>
|
||||
</td>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('iP')->value['precioVta'],2,'.','');?>
|
||||
</td>
|
||||
<td align="right"><?php echo number_format($_smarty_tpl->getVariable('iP')->value['importeVtas'],2,'.','');?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php }} else { ?>
|
||||
<tr><td colspan="<?php echo $_smarty_tpl->getVariable('colspan')->value;?>
|
||||
" align="center">Ningún producto encontrado.</td></tr>
|
||||
<?php } ?>
|
||||
|
||||
<tr>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center"><b>TOTAL LINEA</b></td>
|
||||
<td align="center"></td>
|
||||
<?php $_smarty_tpl->tpl_vars['p'] = new Smarty_Variable;
|
||||
$_smarty_tpl->tpl_vars['kP'] = new Smarty_Variable;
|
||||
$_from = $_smarty_tpl->getVariable('periodo')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
|
||||
if (count($_from) > 0){
|
||||
foreach ($_from as $_smarty_tpl->tpl_vars['p']->key => $_smarty_tpl->tpl_vars['p']->value){
|
||||
$_smarty_tpl->tpl_vars['kP']->value = $_smarty_tpl->tpl_vars['p']->key;
|
||||
?>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totSubs'][$_smarty_tpl->getVariable('iS')->value['prodSubcatId']][$_smarty_tpl->getVariable('kP')->value]['inicial'],0,'.','');?>
|
||||
</td>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totSubs'][$_smarty_tpl->getVariable('iS')->value['prodSubcatId']][$_smarty_tpl->getVariable('kP')->value]['entradas'],0,'.','');?>
|
||||
</td>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totSubs'][$_smarty_tpl->getVariable('iS')->value['prodSubcatId']][$_smarty_tpl->getVariable('kP')->value]['salidas'],0,'.','');?>
|
||||
</td>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totSubs'][$_smarty_tpl->getVariable('iS')->value['prodSubcatId']][$_smarty_tpl->getVariable('kP')->value]['entradasA'],0,'.','');?>
|
||||
</td>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totSubs'][$_smarty_tpl->getVariable('iS')->value['prodSubcatId']][$_smarty_tpl->getVariable('kP')->value]['salidasA'],0,'.','');?>
|
||||
</td>
|
||||
<?php }} ?>
|
||||
<td align="center"></td>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totSubs'][$_smarty_tpl->getVariable('iS')->value['prodSubcatId']]['totalPzas'],0,'.','');?>
|
||||
</td>
|
||||
<td align="center"></td>
|
||||
<td align="right">$<?php echo number_format($_smarty_tpl->getVariable('suc')->value['totSubs'][$_smarty_tpl->getVariable('iS')->value['prodSubcatId']]['importe'],2,'.',',');?>
|
||||
</td>
|
||||
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totSubs'][$_smarty_tpl->getVariable('iS')->value['prodSubcatId']]['totalVtas'],0,'.','');?>
|
||||
</td>
|
||||
<td align="center"></td>
|
||||
<td align="right">$<?php echo number_format($_smarty_tpl->getVariable('suc')->value['totSubs'][$_smarty_tpl->getVariable('iS')->value['prodSubcatId']]['importeVtas'],2,'.',',');?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php }} ?>
|
||||
|
||||
<tr>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center"></td>
|
||||
<td align="center"><b>TOTAL DEPTO.</b></td>
|
||||
<td align="center"></td>
|
||||
<?php $_smarty_tpl->tpl_vars['p'] = new Smarty_Variable;
|
||||
$_smarty_tpl->tpl_vars['kP'] = new Smarty_Variable;
|
||||
$_from = $_smarty_tpl->getVariable('periodo')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
|
||||
if (count($_from) > 0){
|
||||
foreach ($_from as $_smarty_tpl->tpl_vars['p']->key => $_smarty_tpl->tpl_vars['p']->value){
|
||||
$_smarty_tpl->tpl_vars['kP']->value = $_smarty_tpl->tpl_vars['p']->key;
|
||||
?>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totCats'][$_smarty_tpl->getVariable('item')->value['prodCatId']][$_smarty_tpl->getVariable('kP')->value]['inicial'],0,'.','');?>
|
||||
</td>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totCats'][$_smarty_tpl->getVariable('item')->value['prodCatId']][$_smarty_tpl->getVariable('kP')->value]['entradas'],0,'.','');?>
|
||||
</td>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totCats'][$_smarty_tpl->getVariable('item')->value['prodCatId']][$_smarty_tpl->getVariable('kP')->value]['salidas'],0,'.','');?>
|
||||
</td>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totCats'][$_smarty_tpl->getVariable('item')->value['prodCatId']][$_smarty_tpl->getVariable('kP')->value]['entradasA'],0,'.','');?>
|
||||
</td>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totCats'][$_smarty_tpl->getVariable('item')->value['prodCatId']][$_smarty_tpl->getVariable('kP')->value]['salidasA'],0,'.','');?>
|
||||
</td>
|
||||
<?php }} ?>
|
||||
<td align="center"></td>
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totCats'][$_smarty_tpl->getVariable('item')->value['prodCatId']]['totalPzas'],0,'.','');?>
|
||||
</td>
|
||||
<td align="center"></td>
|
||||
<td align="right">$<?php echo number_format($_smarty_tpl->getVariable('suc')->value['totCats'][$_smarty_tpl->getVariable('item')->value['prodCatId']]['importe'],2,'.',',');?>
|
||||
</td>
|
||||
|
||||
<td align="center"><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totCats'][$_smarty_tpl->getVariable('item')->value['prodCatId']]['totalVtas'],0,'.','');?>
|
||||
</td>
|
||||
<td align="center"></td>
|
||||
<td align="right">$<?php echo number_format($_smarty_tpl->getVariable('suc')->value['totCats'][$_smarty_tpl->getVariable('item')->value['prodCatId']]['importeVtas'],2,'.',',');?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php }} ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php if (count($_smarty_tpl->getVariable('suc')->value['productos'])>0){?>
|
||||
<table width="<?php echo $_smarty_tpl->getVariable('width')->value;?>
|
||||
" cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF">
|
||||
<tr>
|
||||
<th width="60"></th>
|
||||
<th width="60"></th>
|
||||
<th width="100"></th>
|
||||
<th width="100"></th>
|
||||
<th width="200"><b>TOTALES</b></th>
|
||||
<th width="60"></th>
|
||||
<?php $_smarty_tpl->tpl_vars['mes'] = new Smarty_Variable;
|
||||
$_smarty_tpl->tpl_vars['kP'] = new Smarty_Variable;
|
||||
$_from = $_smarty_tpl->getVariable('periodo')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
|
||||
if (count($_from) > 0){
|
||||
foreach ($_from as $_smarty_tpl->tpl_vars['mes']->key => $_smarty_tpl->tpl_vars['mes']->value){
|
||||
$_smarty_tpl->tpl_vars['kP']->value = $_smarty_tpl->tpl_vars['mes']->key;
|
||||
?>
|
||||
<td width="60" align="center"><b><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totIniciales'][$_smarty_tpl->getVariable('kP')->value],0,'.',',');?>
|
||||
</b></td>
|
||||
<td width="60" align="center"><b><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totEntradas'][$_smarty_tpl->getVariable('kP')->value],0,'.',',');?>
|
||||
</b></td>
|
||||
<td width="60" align="center"><b><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totSalidas'][$_smarty_tpl->getVariable('kP')->value],0,'.',',');?>
|
||||
</b></td>
|
||||
<td width="60" align="center"><b><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totEntradasA'][$_smarty_tpl->getVariable('kP')->value],0,'.',',');?>
|
||||
</b></td>
|
||||
<td width="60" align="center"><b><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totSalidasA'][$_smarty_tpl->getVariable('kP')->value],0,'.',',');?>
|
||||
</b></td>
|
||||
<?php }} ?>
|
||||
<th width="100"></th>
|
||||
<th width="80"><b><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totPzas'],0,'.',',');?>
|
||||
</b></th>
|
||||
<th width="80"></th>
|
||||
<th width="100"><b>$<?php echo number_format($_smarty_tpl->getVariable('suc')->value['totImporte'],2,'.',',');?>
|
||||
</b></th>
|
||||
|
||||
<th width="80"><b><?php echo number_format($_smarty_tpl->getVariable('suc')->value['totVtas'],0,'.',',');?>
|
||||
</b></th>
|
||||
<th width="80"></th>
|
||||
<th width="100"><b>$<?php echo number_format($_smarty_tpl->getVariable('suc')->value['totImporteVtas'],2,'.',',');?>
|
||||
</b></th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php }?>
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php /* Smarty version Smarty3-b7, created on 2014-03-24 22:11:17
|
||||
compiled from "/home/avantikads/domains/avantikads.com/public_html/novomoda/templates/lists/reportes-prod-prov.tpl" */ ?>
|
||||
<?php /*%%SmartyHeaderCode:545610205533101e5b04b86-50828823%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
|
||||
$_smarty_tpl->decodeProperties(array (
|
||||
'file_dependency' =>
|
||||
array (
|
||||
'7ab370ea65e428f437fe6dde723470a638458a14' =>
|
||||
array (
|
||||
0 => '/home/avantikads/domains/avantikads.com/public_html/novomoda/templates/lists/reportes-prod-prov.tpl',
|
||||
1 => 1379467830,
|
||||
),
|
||||
),
|
||||
'nocache_hash' => '545610205533101e5b04b86-50828823',
|
||||
'function' =>
|
||||
array (
|
||||
),
|
||||
'has_nocache_code' => false,
|
||||
)); /*/%%SmartyHeaderCode%%*/?>
|
||||
|
||||
<div align="center"><b><?php echo $_smarty_tpl->getVariable('titulo')->value;?>
|
||||
</b></div>
|
||||
<br />
|
||||
|
||||
<table width="<?php echo $_smarty_tpl->getVariable('width')->value+410;?>
|
||||
" cellpadding="0" cellspacing="0" border="1">
|
||||
<?php $_smarty_tpl->tpl_vars['suc'] = new Smarty_Variable;
|
||||
$_smarty_tpl->tpl_vars['kS'] = new Smarty_Variable;
|
||||
$_from = $_smarty_tpl->getVariable('sucursales')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
|
||||
if (count($_from) > 0){
|
||||
foreach ($_from as $_smarty_tpl->tpl_vars['suc']->key => $_smarty_tpl->tpl_vars['suc']->value){
|
||||
$_smarty_tpl->tpl_vars['kS']->value = $_smarty_tpl->tpl_vars['suc']->key;
|
||||
?>
|
||||
<?php if (count($_smarty_tpl->getVariable('suc')->value['productos'])>0){?>
|
||||
<tr>
|
||||
<td align="left" height="25" style="background-color:#CCCCCC; border:1px solid #000000">
|
||||
<b><?php echo urldecode($_smarty_tpl->getVariable('suc')->value['nombre']);?>
|
||||
</b>
|
||||
</td>
|
||||
<td width="80" align="center" style="background-color:#CCCCCC; border:1px solid #000000">
|
||||
<a href="javascript:void(0)" onclick="ShowProdProv(<?php echo $_smarty_tpl->getVariable('suc')->value['sucursalId'];?>
|
||||
)">
|
||||
<div id="showHide_<?php echo $_smarty_tpl->getVariable('suc')->value['sucursalId'];?>
|
||||
">[+]</div>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="display:none" id="sucPP_<?php echo $_smarty_tpl->getVariable('suc')->value['sucursalId'];?>
|
||||
">
|
||||
<?php $_template = new Smarty_Internal_Template("{$_smarty_tpl->getVariable('DOC_ROOT')->value}/templates/lists/reportes-prod-prov-item.tpl", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
|
||||
echo $_template->getRenderedTemplate();?><?php $_template->updateParentVariables(0);?><?php unset($_template);?>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
<?php }} ?>
|
||||
</table>
|
||||
Reference in New Issue
Block a user