<?php
	include('../clases/clase.conexion.php');
	include('../funciones/variables.php');
	include('../funciones/funciones.php');
	$var = VarServer("MYSQLI");
	$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
	$varTitu = "EFECTIVIDAD POR VENDEDOR";
	$varFIni = ($_GET["fini"]=="") ? "NULL" : "'".FechaMySql($_GET["fini"])."'";
	$varFFin = ($_GET["ffin"]=="") ? "NULL" : "'".FechaMySql($_GET["ffin"])."'";
	$varPCod = ($_GET["pcod"]=="") ? "NULL" : $_GET["pcod"];
			
	$sql = "call spQuery_Efectividad_Vendedor($varPCod, $varFIni, $varFFin);";

	$varCab = array(array("cab"=>"VENTA SOLES (S/.)", "det"=>array("PREVEN.","VENTA","RECHAZ", "PARCIAL", "%EFECT.")),
					array("cab"=>"PEDIDOS", "det"=>array("PREVEN.","VENTA","RECHAZ", "PARCIAL", "%EFECT.")),
					array("cab"=>"PUNTOS DE VENTA", "det"=>array("PREVEN.","VENTA","RECHAZ", "PARCIAL", "%EFECT."))
					);
	$varNiv = array(0 =>array("COD"=>"CVEN","DES"=>"VENDEDOR"),
					1 =>array("COD"=>"CTIP","DES"=>"TIPO"),
					2 =>array("COD"=>"CTOT","DES"=>"TOTAL"));
	$varFor = array(10=>array("tipodat"=>"porc", "formula"=>array("valor1"=>6,  "valor2"=>7,  "funcion"=>"porc")),
					15=>array("tipodat"=>"porc", "formula"=>array("valor1"=>11, "valor2"=>12, "funcion"=>"porc")),
					20=>array("tipodat"=>"porc", "formula"=>array("valor1"=>16, "valor2"=>17, "funcion"=>"porc"))
					);
	
		
	$html = '
		<!DOCTYPE html  PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
		<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
		<head>
		<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
		<title>'.$varTitu.'</title>
		<link rel="stylesheet" href="css/print_grid_combinado.css" type="text/css" />
		</HEAD>
		<body class="page">';
		
	$html.='<table style="width: 98%; padding: 0; margin-top:10px; margin-bottom:10px; border-collapse:collapse;" align="center">';
	$html.='<thead>';
	$html.='<tr>';
	$html.='<td>';
		$html.='<table style="width: 100%;">';
		$html.='<tr>';
		$html.='<td style="width: 9%; vertical-align: middle; text-align:left;"><b>Fecha</b></td>';
		$html.='<td style="width: 1%; vertical-align: middle; text-align:center;"><b>:</b></td>';
		$html.='<td style="width: 40%; vertical-align: middle; text-align:left;"><b>'.$_GET[fini].' - '.$_GET[ffin].'</b></td>';
		$html.='<td style="width: 50%; vertical-align: middle; text-align:right;"><b>'.$varSysEmpresa.'</b></td>';
		$html.='</tr>';
		$html.='<tr>';
		$html.='<td style="vertical-align: middle; text-align:left;"><b>Proveedor/Linea</b></td>';
		$html.='<td style="vertical-align: middle; text-align:center;"><b>:</b></td>';
		$html.='<td style="vertical-align: middle; text-align:left;"><b>';
		if ($_GET[pro]<>"") {
			$sqlp = "select id_proveedor, nombre from _sv_proveedor where id_proveedor=".$_GET[pcod];
			$obj->AbrirConexion();
			$rsp = $obj->Query($sqlp);
			$obj->CerrarConexion();
			$filap = $obj->FetchArray($rsp);
			$html.= $filap[0].' - '.$filap[1];
			}
		else {
			$html.= 'TODAS LAS LINEAS';
			}
		$html.='</b></td>';
		$html.='<td style="vertical-align: middle; text-align:right;"><b>'.$varTitu.'</b></td>';
		$html.='</tr>';
		$html.='<tr>';
		$html.='<td style="vertical-align: middle; text-align:left;"><b></b></td>';
		$html.='<td style="vertical-align: middle; text-align:center;"><b></b></td>';
		$html.='<td style="width: 50%; vertical-align: middle; text-align:left;"><b></b></td>';
		$html.='<td style="width: 50%; vertical-align: middle; text-align:right;">'.MostrarFechaActual().'</td>';
		$html.='</tr>';
		$html.='</table>';
	$html.='</td>';
	$html.='</tr>';
	$html.='</thead>';	
	$html.='<tr>';
	$html.='<td>';
	$html.= $obj->setGridCombinaPrint($varCab, $sql, $varNiv, $varFor);	
	$html.='</td>';
	$html.='</tr>';
			
$html.='</table>		
		</body>
		</html>';
	echo $html;
?>