<?php
ini_set("session.cookie_lifetime",60*60*10);
ini_set("session.gc_maxlifetime", 60*60*10);
	session_start();
	include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");	
	$StrCmd=V($_GET['C']);
	$P1=V($_GET['P1']);
	$P2=V($_GET['P2']);
	$P3=V($_GET['P3']);
	$P4=V($_GET['P4']);
	$P5=V($_GET['P5']);
	$P6=V($_GET['P6']);
	$P7=V($_GET['P7']);
	if($StrCmd=="K"){
		$AL=$P1;
		$PR=$P2;
		$PI=$P3;
		$KA=$P4;
		$XXX=$KA * $PI;
		$EXI=XERIFICAR($PR,$PI);
		if($EXI==0){
			ejt("UPDATE stocks SET stock=stock - $XXX WHERE id_producto=$PR AND id_almacen=$AL");
			ejt("DELETE FROM stocks_presentaciones WHERE sp_id_producto=$PR AND sp_id_almacen=$AL AND sp_presentacion=$PI");
			$s="DELETE FROM t_productos WHERE pro_id=$PR AND pro_pie=$PI";
			//echo $s;
			ejt($s);
			$IDK=GenId("id_ajuste","ajustex");
			$GII=GenGI();
			$FEC=date("Y-m-d");
			$s="INSERT INTO ajustex VALUES ($IDK,'$FEC',$AL,$PR,'Q',$KA,$PI,$GII,'CONTROL STOCK',0)";
			ejt($s);
			T_P_ACT($PR);
			echo "OK";
		}else{
			echo "ER";
		}
	}
	
?>