<?
include("ApiGlobalFunctions.php");

$usuario=$_POST['uid'];
$password=$_POST['key'];
$url=$_POST['url'];
$tipo=$_POST['Tipo'];
$OCOS=$_POST['OCid_OSid'];
$cdate=DateApp($_POST['cDate']);
$Nguia=$_POST['cNdeGuia'];
$courier=$_POST['cCourier'];
$detalles=$_POST['cDetalles'];
$status=$_POST['cStatus'];
$bodega=$_POST['cBodega'];
$seccion=$_POST['cSeccion'];
$slot=$_POST['cSlot"'];
$detalles=$_POST['cDetalles'];
$vendor="2x".$_POST['cVendor'];

echo $usuario;

/*
$username=username($usuario,$url);

$include=includec($url);
include ($include);
$query=mysqli_query($link,"SELECT *FROM vtiger_crmentity WHERE crmid='$OCOS'");
$data=mysqli_fetch_array($query);  
$type=$data['setype'];
if($type=="SalesOrder"){
	$OS="6x".$OCOS;
	$OC=NULL;
}    
if($type=="PurchaseOrder"){
	$OC="5x".$OCOS;
	$OS=NULL;
}
$asignado="19x".$usuario;
$bodega="50x".$bodega;
$includenat=includenative($usuario,$password,$url);
chdir($includenat);   
include_once 'vtwsclib/Vtiger/WSClient.php';
$user = $username;
$key  = $password;
$url  = $url;
$client = new Vtiger_WSClient($url);
$login = $client->doLogin($user, $key);
if(!$login) {
	echo 'Fallo';
}else {    
    if($vendor>1) {
        $record=$client->doCreate('Caja',array('caja_tks_noguiaodespacho'=>$Nguia,'caja_tks_estado'=>$status,'caja_tks_tipo'=>$tipo,'assigned_user_id'=>$asignado,'caja_tks_ordendecompra'=>$OC,'caja_tks_ordendesalida'=>$OS,'cf_1898'=>$cdate,'cf_1900'=>$courier,'cf_1908'=>$bodega,'cf_1910'=>$seccion,'cf_1906'=>$detalles,'cf_1918'=>$vendor));
    }else{
        $record=$client->doCreate('Caja',array('caja_tks_noguiaodespacho'=>$Nguia,'caja_tks_estado'=>$status,'caja_tks_tipo'=>$tipo,'assigned_user_id'=>$asignado,'caja_tks_ordendecompra'=>$OC,'caja_tks_ordendesalida'=>$OS,'cf_1898'=>$cdate,'cf_1900'=>$courier,'cf_1908'=>$bodega,'cf_1910'=>$seccion,'cf_1906'=>$detalles));
    }	
    if ($record) {
        $recordid = $client->POSTRecordId($record['id']);        
        $docs[0]=array('Result'=>'1', 'id'=>$recordid);
        echo json_encode($docs);
        caja_productos($recordid,$url);
        caja_direccion_od($recordid,$url);
        if ($status=='Traslado') {
            caja_bodegas($recordid,$OS,$url);
        }
        
    }else{
        $recordid=$client->lastError();
        $docs[0]=array('Result'=>'0', 'id'=>$recordid);
        echo json_encode($docs);
    }
}


*/
?>
