<?php
class vrdocu0
{
	var $ruta;
	var $codigo='';
	var $tabla='';
	var $numero=0;
	var $tipo='';
	var $error='1';
	var $sql='';
	var $autofec;
	var $autonum;
	var $ptoe;
	var $vstock;
	var $bstock;
	
	function vrdocu0($r,$cod)
	{
		$this->ruta=$r;
		$this->codigo=$cod;
		require($r);
		$sql_docu0='select *from docu0 where docu_codigo="'.$cod.'"';
		//$this->sql=$sql_docu0;
		if(mysql_query($sql_docu0,$link_vcrx))
		{
			$res_docu0=mysql_query($sql_docu0,$link_vcrx);
            if(mysql_num_rows($res_docu0)!=0)
		   	{
				$this->tabla=strtolower(mysql_result($res_docu0,0,'docu_tabla'));
				$this->numero=mysql_result($res_docu0,0,'docu_numero');
				$this->autofec=mysql_result($res_docu0,0,'docu_autofec');
				$this->autonum=mysql_result($res_docu0,0,'docu_autonum');
				$this->vstock=mysql_result($res_docu0,0,'docu_vstock');
				$this->bstock=mysql_result($res_docu0,0,'docu_bstock');
			
				if(empty($this->numero)){$this->numero=0;}
							
				if(empty($this->autofec)){$this->autofec=0;}
							
				if(empty($this->autonum)){$this->autonum=0;}
							
				if(empty($this->vstock)){$this->vstock=0;}
							
				if(empty($this->bstock)){$this->bstock=0;}
							
				$this->tipo=mysql_result($res_docu0,0,'docu_tipo');
				$this->error='0';
              }
			
		}
		else
		{
			$this->error=mysql_query($sql_docu0,$link_vcrx);
		}
		
		
		
	}
	function vrdocu_gettabla()
	{
	}
	function vrdocu_getnum()
	{
		
		
		require($this->ruta);
		$sql_docu0='select docu_numero from docu0 where docu_codigo="'.$cod.'"';
		
		if(mysql_query($sql_docu0,$link_vcrx))
		{
			$res_docu0=mysql_query($sql_docu0,$link_vcrx);

			$this->numero=mysql_result($res_docu0,0,'docu_numero');
			
			if(empty($this->numero))
			{
				$this->numero=0;
			}

			$this->error='0';
			
		}
		else
		{
			$this->error=mysql_query($sql_docu0,$link_vcrx);
			$this->sql=$sql_docu0;
		}
	}

	function vrdocu_getnum2($ptoe)
	{
		$this->ptoe=$ptoe;
		
		require($this->ruta);
		$sql_docu0='select * from numdocu where docu like "' . $this->codigo . '" and ptoe like "' . $this->ptoe . '"';
		$this->sql=$sql_docu0;
		if(mysql_query($sql_docu0,$link_vcrx))
		{
			$res_docu0=mysql_query($sql_docu0,$link_vcrx);

			$this->numero=mysql_result($res_docu0,0,'numero');
			
			if(empty($this->numero))
			{
				$this->numero=0;
			}

			$this->error='0';
			
		}
		else
		{
			$this->error=mysql_query($sql_docu0,$link_vcrx);
			$this->sql=$sql_docu0;
		}
	}
	
	function vrdocu_setplus()
	{
		require($this->ruta);
		if(!empty($this->numero))
		{
			$sql_docu0='update docu0 set  docu_numero=docu_numero+1 where docu_codigo="'.$this->codigo.'"';
		}
		else
		{
			$sql_docu0='update docu0 set  docu_numero=1 where docu_codigo="'.$this->codigo.'"';
		}
		if(!mysql_query($sql_docu0,$link_vcrx))
		{
			$this->error=mysql_error($link_vcrx);
			$this->sql=$sql_docu0;
		}
		else
		{
			$this->error='0';
			
		
		}
		
		
	}
}
?>