<?php

class funciones_BDResdis {
   private $db;
   // constructor
   function __construct () {
       require_once 'database_odbc_resdis.php';
	   $this->db = new database_odbc_Resdis('ResdisEnlace', 'resdis', '00reset');   
   }

   public function historicoPedido ($user, &$objeto){
     $consulta = "select num_cabped,fec_cabped,ser_cabped,dho_cabped,hho_cabped,sta_cabped,ob1_cabped  from fscabped  where cli_cabped ='$user' and emp_cabped in('80','81');";   
     $estatus =  $this->db->loadObjectList($consulta, $objeto);
      
     return $estatus;   
   }
   public function detallePedido ($empresa,$user,$pedido, &$objeto){   
		$consulta = "select num_linped,nli_linped,art_linped,des_articu as DESCART,bul_linped,sta_linped,obs_linped,bru_linped,pre_linped,obs_linped from fslinped,fscabped,fsarticu where emp_linped = emp_cabped and num_linped = num_cabped and art_linped = cod_articu and emp_linped = emp_articu and cli_linped ='$user' and num_cabped = $pedido and emp_cabped ='$empresa';";
		$estatus =  $this->db->loadObjectList($consulta, $objeto);      
		return $estatus;   
   }

   public function detalleSemanaPedido ($user, &$objeto){
		$semana = date("Y-m-d",strtotime('-7 day')); 

		$consulta = "select num_linped,date(fec_cabped) fecpedido, hour(hor_linped),nli_linped,art_linped,des_articu,bul_linped,sta_linped,obs_linped,bru_linped,
		pre_linped,obs_linped from fslinped,fscabped,fsarticu 
		where emp_linped = emp_cabped and num_linped = num_cabped and art_linped = cod_articu and emp_linped = emp_articu and cli_linped ='$user' 
		and date(fec_cabped) >= '$semana' and emp_cabped in ('80','81') order by fec_linped desc, num_linped,nli_linped;";
		$estatus =  $this->db->loadObjectList($consulta, $objeto);
		return  $estatus;   
   }

   public function pedidosDelDia      ($user,$fecha, &$objeto,$dia,$mes,$ano){
 $semana = date("d/m/Y",strtotime($fecha)); 
 //$semana = date($fecha); 
     
$consulta = "select emp_cabped, num_cabped NUMPEDIDO,fec_cabped FECPEDIDO  from fscabped  where fscabped.cli_cabped ='$user' AND DAY(fscabped.fec_cabped) = $dia and MONTH(fscabped.fec_cabped) = $mes and YEAR(fscabped.fec_cabped) = $ano and emp_cabped in ('80','81')order by fec_cabped desc;";

     $estatus =  $this->db->loadObjectList($consulta, $objeto);
     return  $estatus;   


   }




   public function fechaDosDiaPedido ($user, &$objeto){
 $semana = date("Y-m-d",strtotime('-2 day')); 
     
	$consulta = "select DATE(fscabped.fec_cabped)  FECPEDIDO FROM fscabped   WHERE emp_cabped in ('80','81') and fscabped.cli_cabped ='$user' AND DATE(fscabped.fec_cabped) >= '$semana' GROUP BY fec_cabped order by fec_cabped DESC;";
	     $estatus =  $this->db->loadObjectList($consulta, $objeto);
	     return  $estatus;   


   }




   public function detalleDosDiaPedido ($user, &$objeto){
 $semana = date("Y-m-d",strtotime('-2 day')); 
     
$consulta = "select fslinped.num_linped ,DATE(fscabped.fec_linped ) FECPEDIDO,
HOUR(hor_linped) HORA , fslinped.nli_linped,fslinped.art_linped,des_articu,fslinped.bul_linped,fslinped.sta_linped,fslinped.obs_linped,fslinped.bru_linped,fslinped.pre_linped,fslinped.obs_linped  FROM fslinped,fscabped,fsarticu where fslinped.emp_linped=fscabped.emp_cabped and fslinped.num_linped = fscabped.num_cabped and fslinped.art_linped = fsarticu.cod_articu and fscabped.cli_cabped ='$user'
AND DATE(fscabped.fec_cabped) >= '$semana' AND emp_cabped in ('80',81') order by fec_cabped desc, fslinped.num_linped,fslinped.nli_linped;";
     $estatus =  $this->db->loadObjectList($consulta, $objeto);
     return  $estatus;   


   }



}
?>
