<?php

//Clase de Paises
class clase
{
  	var $nom_tabla = 'farticulos';
  	var  $codigo = '0';
	var  $nparte1 = '0';
	var  $tip_ven = '0';
	//var  $modulo = '0';
	var  $np_desc1 = '0';
	//var  $des_cor = '0';
	var  $ubicacion = '0';
	//var  $exi_min = '0';
	var  $cod_pro = '0';
	
	//var  $uc_num_doc = '0';
	var  $acc_fec = '0';
	var  $acc_hor = '0';
	var  $usuario = '0';
	var  $cod_cli = '0';
	var  $uv_fec_doc = '0';
	
	
	
	
	var  $npartes = '0';
	//var  $fac_rend = '0';
	var  $status = '0';
	var  $lastInsId = '0';
	
	var  $calle = '0';
	var  $estado = '0';
	var  $postal = '0';
	var  $colonia = '0';
	var  $delegacion = '0';
	var  $tel1 = '0';
	var  $tel2 = '0';
	var  $fax = '0';
	var  $curp = '0';
	var  $web = '0';
	var  $mail = '0';
	var  $rfc = '0';
	var  $contacto = '0';
	var  $proveedor = '0';
	var  $dias = '0';
	var  $numero = '0';
	var  $pais = '0';
	var  $t1 = '0';
	var  $t2 = '0';
	var  $t3 = '0';
	var  $t4 = '0';
	var  $t5 = '0';
	var  $t6 = '0';
	var  $t7 = '0';
	var  $t8 = '0';
	var  $t9 = '0';
	var  $t10 = '0';
	var  $seccion = '0';
	var  $anaquel = '0';
	var  $cubo = '0';
	var  $max = '0';
	var  $min = '0';
	

//Funcion de Revicion
	function revisar(){
		$codVar='';
		if($this->cod_var!='')
			$codVar="OR cod_var = '$this->cod_var'";
		$sql = "SELECT * FROM $this->nom_tabla WHERE nparte1 = '$this->nparte1' $codVar";
	   	$result = mysqli_query($GLOBALS['con'] ,$sql);
	   	$num_salidas=mysqli_num_rows($result); 
		if($num_salidas>=1){
			return "ok";
		}else{
			$error = 'Error N:' . mysqli_errno($GLOBALS['con']) . ": " . mysqli_error($GLOBALS['con']);
			return "$error()";  
		}
	}
//Funcion de Agregar
	function agregar(){
		$this->nparte1=$this->getIdToInsert();
		$sql = "insert into $this->nom_tabla (nparte1, np_desc1, ubicacion, acc_fec, acc_hor, usuario, codigo, calle, estado, postal, colonia, delegacion, tel1, tel2, fax, curp, web, mail, rfc, contacto, proveedor, dias, numero, pais, t1, t2, t3, t4, t5, t6, t7, t8, seccion, anaquel, cubo, max, min,t9, por_des, t10, marca) values ('$this->nparte1', '$this->np_desc1', 'V', '".date('Y-m-d')."', '".date('H:i:s')."','".$_SESSION['num_usu']."', '$this->codigo', '$this->calle', '$this->estado', '$this->postal', '$this->colonia', '$this->delegacion', '$this->tel1', '$this->tel2', '$this->fax', '$this->curp', '$this->web', '$this->mail', '$this->rfc', '$this->contacto', '$this->proveedor', '$this->dias', '$this->numero', '$this->pais', '$this->t1', '$this->t2', '$this->t3', '$this->t4', '$this->t5', '$this->t6', '$this->t7', '$this->t8', '$this->seccion', '$this->anaquel', '$this->cubo', '$this->max', '$this->min', '$this->t9', '$this->por_des', '$this->t10', '$this->marca')";	   
		$result = mysqli_query($GLOBALS['con'] ,$sql);
		if ($result){
			return "ok";
		}else{
			$error = 'Error N:' . mysqli_errno($GLOBALS['con']) . ": " . mysqli_error($GLOBALS['con']);
			return "$error()";  
		}
	}
	function getIdToInsert(){
		$dt_invent=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,'select nparte1 from farticulos order by CAST(nparte1 AS UNSIGNED) desc limit 1'));
		return ($dt_invent['nparte1']+1);
	}
}       
?>