<?php

session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("DMMYSQLG.php");

//Funcion de Agregar
//Almacen
$i=0;
foreach ($_POST['almacen'] as $alm) {
      $almacen[$i] = $alm;
$i++;
}


//Ultimo precio
$i=0;
foreach ($_POST['ultimo'] as $ult) {
     $ultimo[$i] = $ult;
$i++;
}

//Precio
$i=0;
foreach ($_POST['precio'] as $prec) {
     $precio[$i] = $prec;
$i++;
}

//Existencia
$i=0;
foreach ($_POST['existencia'] as $exi) {
     $existencia[$i] = $exi;
$i++;
}

//Total
$i=0;
foreach ($_POST['total1'] as $tot) {
     $total[$i] = $tot;
$i++;
}

//Existencia Fisica
$i=0;
foreach ($_POST['exis'] as $exf) {
  $exifis[$i] = $exf;
$i++;
}

//Total fisico
$i=0;
foreach ($_POST['total'] as $totf) {
    $totfis[$i] = $totf;
$i++;
}

//diferencia ARTICULOS
$i=0;
foreach ($_POST['dif'] as $dif) {
     $diffis[$i] = $dif;
$i++;
}

//Diferencia en precio
$i=0;
foreach ($_POST['totdif'] as $totdf) {
     $totdfis[$i] = $totdf;
$i++;
}


if($_GET['b']==''){
//Articulo
$i=0;
foreach ($_POST['articulo'] as $art) {
	$articulo[$i] = $art;
	$sql = mysqli_query($GLOBALS['con'] ,"UPDATE farticulos SET fecha_inv='".$_POST['fecha2']."',exist_fis='".$exifis[$i]."',tot_fis='".$totfis[$i]."', dif_fis='".$diffis[$i]."', totd_fis='".$totdfis[$i]."' where nparte1 ='".$articulo[$i]."'");
	echo mysqli_error($GLOBALS['con']);
$i++;
}
}
if($_GET['b']==1){
//Articulo
$i=0;
foreach ($_POST['articulo'] as $art) {
	$articulo[$i] = $art;
	$sql = mysqli_query($GLOBALS['con'] ,"UPDATE farticulos SET fecha_inv='0000-00-00',exist_fis='0',tot_fis='0', dif_fis='0', totd_fis='0' where nparte1 ='".$articulo[$i]."'");
	echo mysqli_error($GLOBALS['con']);
$i++;
}
}
		
echo  '<meta content="0; url=AL30300_PR.php" HTTP-EQUIV="REFRESH">';       
?>