Primer commit del sistema avantika sin cambios
This commit is contained in:
94
ajax/pedidos-distribucion.php
Executable file
94
ajax/pedidos-distribucion.php
Executable file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
include_once('../init.php');
|
||||
include_once('../config.php');
|
||||
include_once(DOC_ROOT.'/libraries.php');
|
||||
|
||||
session_start();
|
||||
|
||||
$Usr = $user->Info();
|
||||
$smarty->assign('Usr', $Usr);
|
||||
|
||||
if(isset($_POST['action']))
|
||||
$_POST['type'] = $_POST['action'];
|
||||
|
||||
switch($_POST["type"]){
|
||||
|
||||
case 'actualizarDist':
|
||||
|
||||
$pedidoId = $_POST['pedidoId'];
|
||||
|
||||
$sucursales = $sucursal->GetSucursalesByEmpresaId();
|
||||
|
||||
$pedido->setPedidoId($pedidoId);
|
||||
$resProducts = $pedido->GetProductos();
|
||||
|
||||
$dist = array();
|
||||
foreach($resProducts as $res){
|
||||
|
||||
$productoId = $res['productoId'];
|
||||
$cantPrendas = $res['cantPrendas'];
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$nomProducto = utf8_encode($producto->GetModeloById());
|
||||
|
||||
$totPrendas = 0;
|
||||
foreach($sucursales as $suc){
|
||||
|
||||
$sucursalId = $suc['sucursalId'];
|
||||
$prendasSuc = $_POST['cant_'.$productoId.'_'.$sucursalId];
|
||||
|
||||
$card['productoId'] = $productoId;
|
||||
$card['sucursalId'] = $sucursalId;
|
||||
$card['cantidad'] = $prendasSuc;
|
||||
|
||||
$dist[] = $card;
|
||||
|
||||
$totPrendas += $prendasSuc;
|
||||
|
||||
}//foreach
|
||||
|
||||
$continue = true;
|
||||
if($totPrendas > $cantPrendas){
|
||||
$util->setError(20096,'error','',strtoupper($nomProducto));
|
||||
$continue = false;
|
||||
}elseif($totPrendas < $cantPrendas){
|
||||
$util->setError(20097,'error','',strtoupper($nomProducto));
|
||||
$continue = false;
|
||||
}
|
||||
|
||||
if(!$continue){
|
||||
$util->PrintErrors();
|
||||
echo 'fail[#]';
|
||||
$smarty->display(DOC_ROOT.'/templates/boxes/status.tpl');
|
||||
exit;
|
||||
}
|
||||
|
||||
}//foreach
|
||||
|
||||
//Guardamos las Distribuciones
|
||||
|
||||
foreach($dist as $res){
|
||||
|
||||
$pedido->setPedidoId($pedidoId);
|
||||
$pedido->setProductoId($res['productoId']);
|
||||
$pedido->setSucursalId($res['sucursalId']);
|
||||
$pedido->setCantidad($res['cantidad']);
|
||||
|
||||
$infP = $pedido->InfoProdDist();
|
||||
|
||||
if($infP)
|
||||
$pedido->UpdateDistribucion();
|
||||
else
|
||||
$pedido->SaveDistribucion();
|
||||
|
||||
}//foreach
|
||||
|
||||
echo 'ok[#]';
|
||||
$_SESSION['msgPed'] = 'UpdDistribucion';
|
||||
|
||||
break;
|
||||
|
||||
}//switch
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user