Example #1
0
if (!$estado_sal_max) {
    $estado_sal_max = 3;
}
if (!$Buscar) {
    $Buscar = 1;
}
if ($tipo_archivo == 0) {
}
if ($dep_sel == 0) {
    $dep_sel = "%";
}
$accion_sal = "Marcar como Archivado Fisicamente";
$pagina_sig = "envio.php";
$buscar_exp = trim($buscar_exp);
$buscar_rad = trim($buscar_rad);
$fechf = fnc_date_calc($fechafi, 1);
$dependencia_busq1 = " and d.sgd_exp_estado={$tipo_archivo} and cast(d.depe_codi as varchar) like '{$dep_sel}'  and (upper(d.sgd_exp_numero) like '%{$buscar_exp}%' and upper(cast(d.RADI_NUME_RADI as varchar)) like '%{$buscar_rad}%')";
$dependencia_busq2 = " and d.sgd_exp_estado={$tipo_archivo} and cast(d.depe_codi as varchar) like '{$dep_sel}' and (upper(d.sgd_exp_numero) like '%{$buscar_exp}%' and upper(cast(d.RADI_NUME_RADI as varchar)) like '%{$buscar_rad}%') ";
//$dependencia_busq1.="and d.depe_codi!=900 and d.depe_codi!=905";
$dependencia_busq1 .= " and d.sgd_exp_fech <= '{$fechf}' and d.sgd_exp_fech >= '{$fechai}' ";
$dependencia_busq2 .= " and d.sgd_exp_fech <= '{$fechf}' and d.sgd_exp_fech >= '{$fechai}'";
//print_r($GLOBALS);
$fechah = date("dmy") . "_" . time("h_m_s");
$encabezado = session_name() . "=" . session_id() . "&buscar_exp={$buscar_exp}&buscar_rad={$buscar_rad}&krd={$krd}&tipo_archivo={$tipo_archivo}&nomcarpeta={$nomcarpeta}&fechai={$fechai}&fechafi={$fechafi}";
$tbbordes = "#CEDFC6";
$tbfondo = "#FFFFCC";
if (!$orno) {
    $orno = 1;
}
$imagen = "flechadesc.gif";
?>
Example #2
0
/**
	# this calculates the ranking points of all players who belong
	# to a specific LEAGUE-Group $fedagroup FEDA (MIXED or DAMEN)
	# a) retrieve all legs belonging to this listnumber form all events for the specified period
	# b) check on legacy table and include data
	# v2.6 incl current league in report
	*	v3 changed to fit into ls_statsadmin - produce minimal output ...
	*	v4 changed and removed the team - event strings ...
	*			includes all events of this statgroup not only active events
	* v5  extended by the API_RS model
	* v5 reM: works only on 501 legs !!
	**/
function generateStaticFEDAStatisticEntries($feda_stat_group, $indexdate, $writeToDB = 'no')
{
    global $user, $dbi;
    $fromdate = fnc_date_calc($indexdate, -365);
    /*
     * Rangliste berechnet aus allen Spielen von $fromdate bis $indexdate
     * we query after all players from all events belonging to this statgroup ...
     * this returns really ALL players who have ever played in this group (active + non-active events ..)
     * No sense to include the teams+events here, since there could be multiple ...
     * this returns multiple records for each player ....
     */
    $RS = DB_listEventStatGroupPlayers($dbi, $feda_stat_group);
    $aTH = array("Vorname", "Nachname", "Scorezahl", "Checkzahl", "Gesamtzahl", "Legs", "Spiele");
    debug("Calculating actual stat values for " . count($RS) . " Players");
    OpenTable();
    echo ArrayToTableHead($aTH);
    foreach ($RS as $p) {
        #
        # get legs per player - calc - and sum up, att. here we can have multiple player entries
        #	the recordset is sorted by PID ...
        #
        $sumScore = 0;
        $sumCheck = 0;
        $CountScore = 0;
        $CountCheck = 0;
        $scoreindex = 0;
        $checkindex = 0;
        #######################
        # LEGACY data from pre system times
        #######################
        $legqry = "select lxid,lxdate,lxrscore,lxrest,lxrcheck from tbllegx where lxpid={$p['0']} and lxevlist={$feda_stat_group} and lxdate<'{$indexdate}' and lxdate>'{$fromdate}' and lxrscore>0 order by lxdate asc";
        $Lrecord = sql_query($legqry, $dbi);
        while (list($lxid, $lxdate, $lxrscore, $lxrest, $lxrcheck) = sql_fetch_row($Lrecord, $dbi)) {
            $idx = "";
            $idx = retFEDAIndexZahlperLeg(501, $lxrscore, $lxrest, $lxrcheck, $iTEST);
            list($a, $b, $c) = split(":", $idx);
            # values of -1 indicate failure
            if ($a > -1) {
                $sumScore = $sumScore + $a;
                $CountScore = $CountScore + 1;
            }
            if ($b > -1) {
                $sumCheck = $sumCheck + $b;
                $CountCheck = $CountCheck + 1;
            }
        }
        #######################
        # structured data from League-System
        #######################
        $LEGS = DB_listLegsFromPeriod($dbi, 0, 0, $feda_stat_group, $fromdate, $indexdate, $p[0]);
        #debug(count($LEGS));
        # lid,lroundscore,lscore,lroundcheck,gid,mid,mround,mdate ##
        $gamecount = 0;
        $lastgid = 0;
        foreach ($LEGS as $L) {
            if ($lastgid != $L[4]) {
                $gamecount = $gamecount + 1;
            }
            $idx = "";
            $idx = retFEDAIndexZahlperLeg(501, $L[1], 501 - $L[2], $L[3]);
            list($a, $b, $c) = split(":", $idx);
            # values of -1 indicate failure
            if ($a > -1) {
                $sumScore = $sumScore + $a;
                $CountScore = $CountScore + 1;
            }
            if ($b > -1) {
                $sumCheck = $sumCheck + $b;
                $CountCheck = $CountCheck + 1;
            }
            $lastgid = $L[4];
        }
        /*
         * calculate index by division with countvalues
         */
        if ($CountScore > 0) {
            $scoreindex = $sumScore / $CountScore;
        }
        if ($CountCheck > 0) {
            $checkindex = $sumCheck / $CountCheck;
        }
        /*
         * Finally Output into TABLEROW or OUTVAR
         */
        /*
         * V3.1 change, since we have ALL players here we have a lot of cases where no actual statval is compiled in this case its zero and
         * we cont store anything ..
         */
        if ($gamecount > 0) {
            echo "<tr><td>{$p['1']}</td><td>{$p['2']}</td><td>" . number_format($scoreindex, 2, '.', '') . "</td><td>" . number_format($checkindex, 2, '.', '') . "</td><td>" . number_format($scoreindex + $checkindex, 2, '.', '') . "</td><td>{$CountScore}</td><td>{$gamecount}</td></tr>";
            if ($writeToDB == 'yes') {
                $qry = "insert into tblstat(statid,statdate,statcode,statval,statpid,statgames,statlegs) values(0,'{$indexdate}',{$feda_stat_group}," . number_format($scoreindex + $checkindex, 2, '.', '') . ",{$p['0']},{$gamecount},{$CountScore})";
                $res = sql_query($qry, $dbi);
            }
        } else {
            echo "<tr style=\"color:#ff0000;\"><td>{$p['1']}</td><td>{$p['2']}</td><td>NO DATA</td><td>NO DATA</td><td>NO DATA</td><td></td><td></td></tr>";
        }
    }
    #//  END FOR EACH PLAYER
    CloseTable();
}
Example #3
0
/**
*	purpose:	show a personal detail listing ALL legs for a period of 1 year 
* 						for the FEDA Stat  for the passed event
* 	params:	$eventid,$indexdate,$pid
*	returns:	PageView: js-graph + detail listing
*/
function _showPersonStatListeDetail($eventid, $indexdate = '', $pid = 0)
{
    global $dbi, $tdbg, $event, $fedadefaultdate;
    if ($pid == 0) {
        return;
    }
    if (strlen($indexdate) < 5) {
        $indexdate = $fedadefaultdate;
    }
    $evstatcode = $event['evstatcode_id'];
    $fromdate = fnc_date_calc($indexdate, -365);
    # // we use a very general person query here ...
    $playerqry = "select pid,pfname,plname from tplayer where pid={$pid}";
    $precord = sql_query($playerqry, $dbi);
    $aPLAYER = sql_fetch_array($precord, $dbi);
    $aTH = array("Datum", "Runde", "Scorerunde", "Rest", "Checkrunde", "Scorezahl", "Checkzahl");
    echo _MakeStatPageHeader($eventid, $evstatcode);
    echo "<h3>Auflistung aller Spiele / Legs " . $aPLAYER["pfname"] . " " . $aPLAYER["plname"] . " von {$fromdate} bis {$indexdate}</h3>";
    # GRAPH ###############
    echo "<script language=\"JavaScript\" src=\"code/legdatagraph.js\"></script>";
    echo "<div id=\"JG\" style=\"position:relative;height:300px;width:700px\"></div>";
    # we need here to pass date constraints - dont pass event-id !!
    echo "<script>window.onLoad=perfgraph({$pid},{$evstatcode},0,'{$fromdate}','{$indexdate}')</script>";
    # GRAPH ###############
    OpenTable();
    #
    # get legs per player - calc - and sum up
    #
    ####################
    # Legacy Data from pre league system -> tbllegx
    ####################
    $legqry = "select lxid,lxpcnum,lxdate,lxrscore,lxrest,lxrcheck from tbllegx where lxpid={$pid} and lxevlist={$evstatcode} and lxdate<'{$indexdate}' and lxdate>'{$fromdate}' and lxrscore>0 order by lxdate asc";
    $Lrecord = sql_query($legqry, $dbi);
    echo ArrayToTableHead($aTH);
    while (list($lxid, $lxpcnum, $lxdate, $lxrscore, $lxrest, $lxrcheck) = sql_fetch_row($Lrecord, $dbi)) {
        $idx = "";
        $idx = retFEDAIndexZahlperLeg($event['evsgldist'], $lxrscore, $lxrest, $lxrcheck);
        list($a, $b, $c) = split(":", $idx);
        echo "<tr><td>{$lxdate}</td><td>n/a</td><td>{$lxrscore}</td><td>{$lxrest}</td><td>{$lxrcheck}</td><td>{$a}</td><td>{$b}</td></tr>";
    }
    ####################
    # official League system Data
    ####################
    $legqry = "select lid,lroundscore,lscore,lroundcheck,gid,gmkey,mround,mdate from tbllegrounds,tblgame,tblmatch,tblevent E where lpid = {$pid} and lgid=gid and gmkey=mkey and mevid=E.id and E.evstatcode_id={$evstatcode} and mdate<'{$indexdate}' and mdate>'{$fromdate}' and lroundscore>0 order by mdate asc,lid asc";
    $Lrecord = sql_query($legqry, $dbi);
    echo ArrayToTableHead($aTH);
    while (list($lid, $lroundscore, $lscore, $lroundcheck, $gid, $gmkey, $mround, $mdate) = sql_fetch_row($Lrecord, $dbi)) {
        $idx = "";
        $idx = retFEDAIndexZahlperLeg($event['evsgldist'], $lroundscore, $event['evsgldist'] - $lscore, $lroundcheck);
        list($a, $b, $c) = split(":", $idx);
        echo "<tr><td>{$mdate}</td><td>{$mround}</td><td>{$lroundscore}</td><td>" . ($event['evsgldist'] - $lscore) . "</td><td>{$lroundcheck}</td><td>{$a}</td><td>{$b}</td></tr>";
    }
    CloseTable();
}
do {
    $conceptosArray[$row_conceptos2['idcat_gastos']] = $row_conceptos2['nombre'];
} while ($row_conceptos2 = mysql_fetch_assoc($conceptos2));
if ($totalRows_conceptos > 0) {
    mysql_data_seek($conceptos, 0);
    $row_conceptos = mysql_fetch_assoc($conceptos);
}
$idempleado = base64_decode($_SESSION['IDEMPLEADO']);
mysql_select_db($database_tyeconn, $tyeconn);
$query_empleado = sprintf("SELECT idunidadnegocio, numempleado, idempleado, notarjetacredito FROM empleado WHERE idempleado = %s", $idempleado);
$empleado = mysql_query($query_empleado, $tyeconn) or die(mysql_error());
$row_empleado = mysql_fetch_assoc($empleado);
$totalRows_empleado = mysql_num_rows($empleado);
$noTarjeta = buscaTarjetaAmex($idempleado);
$colname_cargostc = $noTarjeta;
$fechalimite = fnc_date_calc(date("Y-m-d"), $TYE_parametros['MaximoDiasComprobacionTC'] * -1);
mysql_select_db($database_tyeconn, $tyeconn);
$query_cargostc = sprintf("SELECT amex.idamex, amex.notransaccion,amex.tarjeta,\ndate_format(amex.fecha,'%%d/%%m/%%Y') as fecha,\namex.monto, amex.estatus, amex.moneda, amex.TC,\namex.concepto, gastosamex.idgastosamex, sum(gastosamex.estatus) as sumaestatus\nFROM amex left join gastosamex on (gastosamex.idamex=amex.idamex)\nWHERE amex.tarjeta = '%s' and amex.estatus=0 and amex.fecha>='%s'\ngroup by amex.idamex\nORDER BY amex.fecha ASC", $colname_cargostc, $fechalimite);
$cargostc = mysql_query($query_cargostc, $tyeconn) or die(mysql_error());
$row_cargostc = mysql_fetch_assoc($cargostc);
$totalRows_cargostc = mysql_num_rows($cargostc);
mysql_select_db($database_tyeconn, $tyeconn);
$query_totalamex = sprintf("SELECT sum(amex.monto) as totalamex FROM amex  left join gastosamex on (gastosamex.idamex=amex.idamex) WHERE amex.tarjeta = '%s' and amex.estatus=0 and amex.fecha>='%s' and (gastosamex.estatus IS NULL or gastosamex.estatus=0) GROUP BY tarjeta", $colname_cargostc, $fechalimite);
$totalamex = mysql_query($query_totalamex, $tyeconn) or die(mysql_error());
$row_totalamex = mysql_fetch_assoc($totalamex);
$totalRows_totalamex = mysql_num_rows($totalamex);
$totalAmexMonto = 0;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html lang="es-MX"><head>
<!-- base href="http:://www.masnegocio.com" -->
Example #5
0
    while (!$rs->EOF) {
        $exp = $rs->fields["SGD_EXP_NUMERO"];
        $rad = $rs->fields["RADI_NUME_RADI"];
        $fechfin = $rs->fields["SGD_EXP_FECHFIN"];
        $arch = $rs->fields["SGD_EXP_ARCHIVO"];
        $rete = $rs->fields["SGD_EXP_RETE"];
        if ($fechfin != "" and $arch == 2 and $rete == 1) {
            $srd = $rs->fields["SGD_SRD_CODIGO"];
            $sbrd = $rs->fields["SGD_SBRD_CODIGO"];
            $rss = $db->query($query2);
            if (!$rss->EOF) {
                $tiemc = $rss->fields["SGD_SBRD_TIEMAC"];
                $tiemg = $rss->fields["SGD_SBRD_TIEMAG"];
                $fechaIni = date('Y-m-d');
                $time = fnc_date_calc($fechfin, $tiemg);
                $time2 = fnc_date_calc($time, $tiemc);
                if ($time <= $fechaIni and $fechaIni <= $time2) {
                    include "{$ruta_raiz}/include/query/archivo/queryAlerta.php";
                    /*
                     * Modificacion acceso a documentos
                     * @author Liliana Gomez Velasquez
                     * @since octubre 7 2009
                     */
                    $resulVali = $verLinkArchivo->valPermisoRadi($rad);
                    $valImg = $resulVali['verImg'];
                    $pathImagen = $resulVali['pathImagen'];
                    $rsr = $db->query($query3);
                    $path = $rsr->fields['RADI_PATH'];
                    ?>
			<tr>
			<td class=leidos2 align="center"><b><a href='datos_expediente.php?<?php 
Example #6
0
function _showEVENTIndexReallyALLPlayers($indexdate, $evstatcode)
{
    #
    # this shows the ranking points of all players who belong
    # to a specific Statistics-Group $evstatcode
    # a) retrieve all legs belonging to this listnumber form all events for the specified period
    # b) check on legacy table and include data
    #
    global $dbi, $tdbg, $event;
    $fromdate = fnc_date_calc($indexdate, -365);
    echo "<h3>Fiktive Rangliste berechnet aus allen Spielen von {$fromdate} bis {$indexdate} der Statistik-Gruppe {$evstatcode}</h3>";
    echo '<form action=\'ls_debug.php?func=allranking&amp;vindexdate=' . $indexdate . '\' method=\'post\'>';
    echo '<p>Beliebigen Stichtag w&auml;hlen (YYYY-MM-DD). F&uuml;r diesen Tag wird ein FEDA Wert pro Spieler erstellt der die letzten 365 Tage ber&uuml;cksichtigt.<br>Im Gegensatz zur offiziell sichtbaren Liste werden hier wirklich ALLE Spieler angezeigt die jemals in dieser Ligagruppe t&auml;tig waren, unabh&auml;ngig davon ob sie jetzt bei einer aktiven Mannschaft t&auml;tig sind .... (kann etwas dauern ... das ist eine LIVE Berechnung mit tausenden legs ...)<br>Es werden auch nur die Spieler angezeigt f&uuml;r die mind. 1 Leg gefunden wurde...</p>';
    echo '<table><tr><td>' . _input(1, "vindexdate", $indexdate, 12, 12) . '</td>';
    echo '<td>' . Select_StatGroup('evstatcode', $evstatcode) . '</td>';
    echo '<td>' . _button("Rangliste bis Stichtag") . '</td>';
    echo "</tr></table></form>";
    if ($evstatcode > 0) {
        generateStaticFEDAStatisticEntries($evstatcode, $indexdate, 'no');
    }
}
    function forma_comprobacion()
    {
        ?>
<!-- Inicia forma para comprobación -->
<script language="JavaScript" src="../../lib/js/jquery/jquery-1.3.2.js" type="text/javascript"></script>
<script language="JavaScript" src="../../lib/js/jquery/jquery.date_input.js" type="text/javascript"></script>
<script language="JavaScript" src="../../lib/js/jquery/jquery.tablesorter.js" type="text/javascript"></script>
<script language="JavaScript" src="../../lib/js/jquery/jquery.autocomplete.js" type="text/javascript"></script>
<script language="JavaScript" src="../../lib/js/jquery/jquery.bgiframe.js" type="text/javascript"></script>
<script language="JavaScript" src="../../lib/js/jquery/jquery.fadeSliderToggle.js" type="text/javascript"></script>
<script language="JavaScript" src="../../lib/js/formatNumber.js" type="text/javascript"></script>	
    	
<script language="JavaScript" type="text/javascript">
//variables
var doc;
var validaFactura=1;

function verificaFactura(){
var frm=document.detallecomp;	
	if (frm.fact_chk.checked){
		validaFactura=1;
		$("#rfc_prov_busq_div").html("RFC<span class='style1'>*</span>: ");
		$("#name_prov_busq_div").html("Razón Social<span class='style1'>*</span>: ");
		$("#div_folio").html("Folio<span class='style1'>*</span>: ");
		frm.d_folio.disabled=false;
	}else{
		validaFactura=0;
		$("#rfc_prov_busq_div").html("RFC: ");
		$("#name_prov_busq_div").html("Razón Social: ");
		$("#div_folio").html("Folio: ");
		frm.d_folio.disabled=true;
	}
}


doc = $(document);
doc.ready(inicializarEventos);//cuando el documento esté listo
function inicializarEventos(){			
			//genera la lista de sugerencia: nombre proveedor
			$("#proveedor").autocomplete("services/catalogo_proveedores.php", {				
			minChars:2,
			matchSubset:1,
			matchContains:1,
			cacheLength:10,
			onItemSelect:seleccionaItem2,
			onFindValue:buscaRFC,
			formatItem:arreglaItem,
			autoFill:false,
			extraParams:{tip:1}
			});//fin autocomplete

			//genera la lista de sugerencia: rfc proveedor
			$("#rfc").autocomplete("services/catalogo_proveedores.php", {				
			minChars:2,
			matchSubset:1,
			matchContains:1,
			cacheLength:10,
			onItemSelect:seleccionaItem,
			onFindValue:buscaProveedor,
			formatItem:arreglaItem,
			autoFill:false,
			extraParams:{tip:2}
			});//fin autocomplete			

			//$("#idCount").val(parseInt(0));
			//ajusta tabla
			$("#comprobacion_table").tablesorter({ 
					//cabeceras deshabilitadas del ordenamiento
					headers: { 
						4: {sorter: false }, 
						7: {sorter: false },
						9: {sorter: false },
						11:{sorter: false }  
					} //headers
   		 	}); //tabla
            
            // Se usa para controlar el div de agregar proveedor
            $(".fadeNext").click(function(){   
                $(this).next().fadeSliderToggle()

                return false;
            });            
            
			borrarPartida();
			guardaComprobacion();
}//fin ready ó inicializarEventos

function buscaProveedor(li) {
	if(li==null){ 
	return null;
	}
	if(!!li.extra){
	var valorLista=li.extra[0];
	}else{ 
	var valorLista=li.selectValue;
			$("#load_div").html("Cargando espere...");
			$.ajax({
				//busca el nombre del proveedor en el catalogo en base al RFC
				url: 'services/catalogo_proveedores.php',
				type: "POST",
				data: "nombre="+valorLista+"&tip=1",
				dataType: "html",
				success: function(datos){
						$("#proveedor").val(datos);
						$("#load_div").html("");
						}
				});//fin ajax	
	}
}//fin buscaProveedor

function buscaRFC(li) {
	if(li==null){ 
	return null;
	}
	if(!!li.extra){
	var valorLista=li.extra[0];
	}else{ 
	var valorLista=li.selectValue;
			$("#load_div").html("Cargando espere...");
			$.ajax({
				//busca el rfc del proveedor en el catalogo en base al nombre
				url: 'services/catalogo_proveedores.php',
				type: "POST",
				data: "nombre="+valorLista+"&tip=2",
				dataType: "html",
				success: function(datos){
						$("#rfc").val(datos);
						$("#load_div").html("");
						}
				});//fin ajax	
	}
}//fin buscaRFC

function seleccionaItem(li) {
	buscaProveedor(li);
}//fin seleccionaItem

function seleccionaItem2(li) {
	buscaRFC(li);
}//fin seleccionaItem

function arreglaItem(row) {
//da el formato a la lista
	return row[0];
}//fin arreglaItem

//Agrega Nuevo Proveedor al catálogo
function nuevoProveedor(nombreProveedor,rfcProveedor,dirFiscal){
	if(rfcProveedor<12 || rfcProveedor>13){
		alert("El RFC que intenta ingresar es incorrecto. Favor de verificarlo e intente nuevamente.");
		return false;
	}else if(dirFiscal==""){
		alert("Debe ingresar la dirección fiscal del proveedor.");
		return false;
	}else{			
		$.ajax({
		url: 'services/catalogo_proveedores.php',
		type: "POST",
		data: "submit=&nameprov="+nombreProveedor+"&rfcprov="+rfcProveedor+"&dirf="+dirFiscal,
		success: function(datos){
				if (datos==""){				
					$("#proveedor").val("");
					$("#rfc").val("");
					$('#new_proveedor').val("");
					$('#new_p_rfc').val("");
					$('#new_p_addr').val("");					
					$("#proveedor").focus();
				}else{	
				alert(datos);
					$("#new_proveedor").focus();
				}
			}
		});//fin ajax
		return false;
	}//fin if rfc
}//fin nuevoProveedor
		
//Fecha
$(function() {
	//campo 
	$("#fecha").date_input();
	});
		
	//obtiene formato de fecha YYYY/mm/dd
	$.extend(DateInput.DEFAULT_OPTS, {
	stringToDate: function(string) {
	var matches;
	if (matches = string.match(/^(\d{4,4})-(\d{2,2})-(\d{2,2})$/)) {
	return new Date(matches[1], matches[2] - 1, matches[3]);
	} else {
	return null;
	};
	},
	dateToString: function(date) {
	var month = (date.getMonth() + 1).toString();
	var dom = date.getDate().toString();
	if (month.length == 1) month = "0" + month;
	if (dom.length == 1) dom = "0" + dom;
	return dom + "/" + month + "/" + date.getFullYear();
	}
	});
		
	//Opciones de Idioma del Calendario
	jQuery.extend(DateInput.DEFAULT_OPTS, {
	month_names: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"],
	short_month_names: ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"],
	short_day_names: ["Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sab"]
	});
//fin Fecha	

//validación campos numericos
function validaNum(valor){
	cTecla=(document.all)?valor.keyCode:valor.which;
	if(cTecla==8) return true;
	patron=/^([0-9.]{1,2})?$/;
	cTecla= String.fromCharCode(cTecla);
	return patron.test(cTecla);
}

//cambia el valor del input
function cambiaTexto(){
var frm=document.detallecomp;
	if(!isNaN(frm.monto.value)||frm.monto.value!=null){
		if(frm.select_impuesto.value!=0 || frm.select_impuesto.value!="No"){
		var imp=(frm.select_impuesto.value*0.01)*(frm.monto.value);			
		frm.impuesto.disabled=false;		
		frm.impuesto.value=Math.round(imp * Math.pow(10, 2)) / Math.pow(10, 2);//redondea a 2 decimales
		//total
		var tot=parseFloat(frm.impuesto.value)+parseFloat(frm.monto.value);
		frm.total.value=Math.round(tot * Math.pow(10, 2)) / Math.pow(10, 2);//redondea a 2 decimales
		
		}
	}else{
	frm.impuesto.value=0;
	frm.total.value=0;
	
	}
}

// Esta funcion se llama cuando se selecciona un concepto.
function activaCb(){
    var frm=document.detallecomp;
    // nada que hacer aqui.
}
		
//IVA
function valor($combo){
	var frm=document.detallecomp;
	if(frm.monto.value=="" || frm.monto.value==0){
	frm.monto.value=0;
	frm.impuesto.value=0;
	frm.total.value=0;
		if(frm.select_impuesto.value=="No"){
			frm.impuesto.value=0;
			frm.impuesto.disabled=true;
			frm.total.value=parseFloat(frm.monto.value);
		}else{
			frm.impuesto.disabled=false;
			}
	}else{
		if(frm.select_impuesto.value=="No"){
			frm.impuesto.value=0;
			frm.impuesto.disabled=true;
			frm.total.value=parseFloat(frm.monto.value);
		}else{
			//impuesto
			var imp=(frm.select_impuesto.options[frm.select_impuesto.selectedIndex].value*0.01)*(frm.monto.value);			
			frm.impuesto.disabled=false;		
			frm.impuesto.value=Math.round(imp * Math.pow(10, 2)) / Math.pow(10, 2);//redondea a 2 decimales
			//total
			var tot=parseFloat(frm.impuesto.value)+parseFloat(frm.monto.value);
			frm.total.value=Math.round(tot * Math.pow(10, 2)) / Math.pow(10, 2);//redondea a 2 decimales
		}
			
	}
}//fin valor

//Divisa
function tipoCambio(combo){
	var frm=document.detallecomp;
	switch (combo) {
		case "0":
		frm.tasa.value=parseFloat(1.00);//este valor cambiará cuando sea parametrizado
		break
		case "1":
		frm.tasa.value=parseFloat(12.87);//este valor cambiará cuando sea parametrizado
		break
		case "2":
		frm.tasa.value=parseFloat(18.11);//este valor cambiará cuando sea parametrizado
		break
	} 
}//Tipo cambio

function getTotal(){
var frm=document.detallecomp;
	if(frm.select_impuesto.options[frm.select_impuesto.selectedIndex].value==0 || frm.select_impuesto.options[frm.select_impuesto.selectedIndex].value=="No" || frm.impuesto.value==0){
		if(frm.monto.value=="" || frm.monto.value==0){
		frm.total.value=0;
		}else{
		frm.total.value=parseFloat(frm.monto.value);
		}
	}else{
		//impuesto
		var imp=(frm.select_impuesto.options[frm.select_impuesto.selectedIndex].value*0.01)*(frm.monto.value);			
		frm.impuesto.disabled=false;		
		frm.impuesto.value=Math.round(imp * Math.pow(10, 2)) / Math.pow(10, 2);//redondea a 2 decimales
		//total
		var tot=parseFloat(frm.impuesto.value)+parseFloat(frm.monto.value);
		frm.total.value=Math.round(tot * Math.pow(10, 2)) / Math.pow(10, 2);//redondea a 2 decimales
	
	}
}

function agregarPartida(){
	var frm=document.detallecomp;
		//Valida que los campos obligatorios esten llenos
	if(frm.select_concepto.value=="" || frm.moneda.value=="" || frm.select_impuesto.value=="" || frm.impuesto.value=="" || frm.fecha.value=="" || frm.monto.value=="" || frm.monto.value==0 || frm.total.value=="" || frm.total.value==0 || frm.referencia_corta.value=="" || frm.tasa.value==0 || frm.tasa.value==""  || frm.referencia_corta.value == ""){
		alert("Los campos con (*) son obligatorios. Favor de llenar los datos faltantes");
		return false;	
				
	/*}else if(frm.motive.value.length<5){
		alert("El motivo debe tener al menos 5 caracteres.");
		frm.motive.focus();
		return false;*/
		
	}else if(validaFactura==1){
		if(frm.proveedor.value.length==0 || frm.rfc.value.length==0){
		alert("Los campos con (*) son obligatorios. Favor de llenar los datos faltantes");
		frm.proveedor.focus();
		return false;
		
		}else if(frm.rfc.value.length<12 || frm.rfc.value.length>13){
		alert("El RFC que intenta ingresar es incorrecto. Favor de verificarlo e intente nuevamente.");
		frm.rfc.focus();
		return false;
		
		}else if(frm.d_folio.value==""){
			alert("Debe ingresar el folio de la factura.");		
			frm.d_folio.focus();
			return false;
			
		}else if(frm.d_folio.value!=0 || frm.d_folio.value!=""){
				 var folio_factura=$('#d_folio').attr('value');
				var rfc_proveedor=$('#rfc').attr('value'); 
				
			//busca que el folio este disponible para este proveedor
			$.ajax({
			url: 'services/catalogo_proveedores.php',
			type: "POST",
			data: "find=&folio="+folio_factura+"&rfcprov="+rfc_proveedor,
			success: function(datos){
					if (datos==""){	
						construyePartida();	
						return true;
					}else{
						alert(datos);
						frm.d_folio.focus();
						return false;		
					}//fin if datos
				}//datos
			});//fin ajax
				
		}else if(frm.proveedor.value.length>0 || frm.rfc.length>0){
		//busca al proveedor
		var nombreProveedor = $('#proveedor').attr('value');
		var rfcProveedor = $('#rfc').attr('value'); 
		var dirFiscal="";
		var id=$("#idCount").val(parseInt($("#idCount").val()) + 1);
			$.ajax({
			url: 'services/catalogo_proveedores.php',
			type: "POST",
			data: "busca=&nameprov="+nombreProveedor+"&rfcprov="+rfcProveedor,
			success: function(datos){
					if (datos==""){	
						if(confirm("El proveedor no se encuentra registrado. ¿Desea agregarlo?")){
							nuevoProveedor(nombreProveedor,rfcProveedor,dirFiscal);
							construyePartida();
							return true;
						}else{
							return false;
						}
					}else{	
						construyePartida();			
					}//fin if datos
				}//datos
			});//fin ajax				
		}//if 	
		
	}else{
			construyePartida();	
	}//fin if
}//agregar partida

function construyePartida(){
		var frm=document.detallecomp;
		//conteo de la partida
		frm.rowCount.value=parseInt(frm.rowCount.value)+parseInt(1);
		//Busca el ultimo ID de las partidas y le sumamos uno para el siguiente
		id=parseInt($("#comprobacion_table").find("tr:last").find("td").eq(0).html());
		if(isNaN(id)){
			id=1;
		}else{
			id+=parseInt(1);
		}
		//Creamos la nueva fila y sus respectivas columnas
		var moneda=frm.moneda.value;
		switch(moneda){
		case "0":
		   divisa="MXN"
		   break
		case "1":
		   divisa="USD"
		   break
		case "2":
		  divisa="EUR"
		   break
		} 		
		var row=frm.rowCount.value;
		
		if (frm.proveedor.value!=""){
		prov_name=frm.proveedor.value;
		}else{
		prov_name="Sin Proveedor";
		}
		
		if (frm.rfc.value!=""){
		prov_rfc=frm.rfc.value;
		}else{
		prov_rfc="";
		}
		
		if (frm.referencia_corta.value!=""){
		ref_cort=frm.referencia_corta.value;
		}else{
		ref_cort="Sin Comentario";
		}
		
		if (validaFactura==1){
		fact_doc="Factura:"+frm.d_folio.value;
		}else{
		fact_doc="Sin Factura";
		}			
		
		var nuevaFila='<tr>';
		nuevaFila+="<td>"+id+"<input type='hidden' name='row"+id+"' id=row'"+id+"' value='"+id+"' readonly='readonly' /></td>";
		nuevaFila+="<td><input type='hidden' name='fecha"+id+"' id='fecha"+id+"' value='"+frm.fecha.value+"' readonly='readonly' />"+frm.fecha.value+"</td>";
		nuevaFila+="<td><input type='hidden' name='concepto"+id+"' id='concepto"+id+"' value='"+frm.select_concepto.options[frm.select_concepto.selectedIndex].text+"' 	readonly='readonly' />"+frm.select_concepto.options[frm.select_concepto.selectedIndex].text+"</td>";
		nuevaFila+="<td><input type='hidden' name='referencia"+id+"' id='referencia"+id+"' value='"+ref_cort+"' readonly='readonly' />"+ref_cort+"</td>"; 
		nuevaFila+="<td><input type='hidden' name='cant_asistentes"+id+"' id='cant_asistentes"+id+"' value='"+frm.no_asistentes.value+"' readonly='readonly' />"+frm.no_asistentes.value+"</td>";
		nuevaFila+="<td><input type='hidden' name='proveedor"+id+"' id='proveedor"+id+"' value='"+prov_name+"' readonly='readonly' />"+prov_name+"</td>";
		nuevaFila+="<td><input type='hidden' name='rfc"+id+"' id='rfc"+id+"' value='"+prov_rfc+"' readonly='readonly' />"+prov_rfc+"</td>"; 
		nuevaFila+="<td><input type='hidden' name='flag_factura"+id+"' id='flag_factura"+id+"' value='"+frm.d_folio.value+"' readonly='readonly' />"+fact_doc+"</td>";
		nuevaFila+="<td id='m'><input type='hidden' name='mnt"+id+"' id='mnt"+id+"' value='"+frm.monto.value+"' readonly='readonly' />$"+frm.monto.value+"</td>"; 
		nuevaFila+="<td><input type='hidden' name='divisa"+id+"' id='divisa"+id+"' value='"+divisa+"' readonly='readonly' />"+divisa+"</td>"; 
		nuevaFila+="<td><input type='hidden' name='tasa"+id+"' id='tasa"+id+"' value='"+frm.tasa.value+"' readonly='readonly' />$"+frm.tasa.value+"</td>"; 
		nuevaFila+="<td><input type='hidden' name='pimpuesto"+id+"' id='pimpuesto"+id+"' value='"+frm.select_impuesto.value+"' readonly='readonly' />"+frm.select_impuesto.value+" "+"<input type='hidden' name='imp"+id+"' id='imp"+id+"' value='"+frm.impuesto.value+"' readonly='readonly' />$"+frm.impuesto.value+"</td>"; 
		nuevaFila+="<td><input type='hidden' name='tot"+id+"' id='tot"+id+"' value='"+frm.total.value+"' readonly='readonly' />$"+frm.total.value+"</td>";
		nuevaFila+="<td><div align='center'><img class='elimina' src='../../images/delete.gif' alt='Click aqu&iacute; para Eliminar' name='del' id='"+id+"' onmousedown='borrarPartida(this.id);'  /></div></td>";
		nuevaFila+= '</tr>';
		//gran total
		var sumMnt=parseFloat(frm.monto.value)+parseFloat(frm.t_subtotal.value);
		var sumIVA=parseFloat(frm.impuesto.value)+parseFloat(frm.t_iva.value);
		var sumTotal=parseFloat(frm.total.value)+parseFloat(frm.t_total.value);		
		frm.t_subtotal.value=Math.round(sumMnt * Math.pow(10, 2)) / Math.pow(10, 2);
		frm.t_iva.value=Math.round(sumIVA * Math.pow(10, 2)) / Math.pow(10, 2);
		frm.t_total.value=Math.round(sumTotal * Math.pow(10, 2)) / Math.pow(10, 2);
		$("#g_sbt").html("Subtotal: "+parseFloat(frm.t_subtotal.value));
		$("#g_iva").html("IVA: "+parseFloat(frm.t_iva.value));
		$("#g_tot").html("Total: "+parseFloat(frm.t_total.value));
		
		
		//restablece los campos
		$("#comprobacion_table").append(nuevaFila);
		$("#monto").val(0);
		$("#tasa").val(1);
		$("#impuesto").val(0);
		$("#total").val(0);
		$("#referencia_corta").val("");
		$("#d_folio").val("");
		$("#proveedor").val("");
		$("#rfc").val("");
		$('#select_concepto').find('option:first').attr('selected', 'selected').parent('select');	
		$('#moneda').find('option:first').attr('selected', 'selected').parent('select');
		$('#select_impuesto').find('option:first').attr('selected', 'selected').parent('select');
		frm.impuesto.disabled=false;
		frm.select_impuesto.disabled=false;
		
		guardaComprobacion();
}//construye partida

function borrarPartida(id){
var firstRow=parseInt($("#comprobacion_table").find("tr:first").find("td").eq(0).html());
var lastRow=parseInt($("#comprobacion_table").find("tr:last").find("td").eq(0).html());
var frm=document.detallecomp;
var row=frm.rowCount.value;
	$("img.elimina").click(function(){
			var mnt=parseFloat($("#mnt"+id).val());
			var iva=parseFloat($("#imp"+id).val());
			var total=parseFloat($("#tot"+id).val());			
			var subtractMnt=0;
			var subtractIVA=0;
			var subtractTotal=0;	
			//substraccion		
			subtractMnt=parseFloat(frm.t_subtotal.value)-mnt;
			subtractIVA=parseFloat(frm.t_iva.value)-iva;
			subtractTotal=parseFloat(frm.t_total.value)-total;
			//calculo final
			frm.t_subtotal.value=Math.round(subtractMnt * Math.pow(10, 2)) / Math.pow(10, 2);
			frm.t_iva.value=Math.round(subtractIVA * Math.pow(10, 2)) / Math.pow(10, 2);
			frm.t_total.value=Math.round(subtractTotal * Math.pow(10, 2)) / Math.pow(10, 2);			
			
			//impresion en pantalla
			$("#g_sbt").html("Subtotal: "+parseFloat(frm.t_subtotal.value));
			$("#g_iva").html("IVA: "+parseFloat(frm.t_iva.value));
			$("#g_tot").html("Total: "+parseFloat(frm.t_total.value));
			$(this).parent().parent().parent().fadeOut("normal", function () { 
			$(this).remove();
			
			guardaComprobacion();
		});
		return false;
	});
	
}//borrar partida


function guardaComprobacion(){
var frm=document.detallecomp;
	id= parseInt($("#comprobacion_table").find("tr:last").find("td").eq(0).html());
	if(isNaN(id)){
	$("#guardarComp").attr("disabled", "disabled"); 
	frm.t_subtotal.value=parseFloat(0.00);
	frm.t_iva.value=parseFloat(0.00);
	frm.t_total.value=parseFloat(0.00);
	$("#g_sbt").html("Subtotal: "+frm.t_subtotal.value);
	$("#g_iva").html("IVA: "+frm.t_iva.value);
	$("#g_tot").html("Total: "+frm.t_total.value);
	}else{
	$("#guardarComp").removeAttr("disabled"); 
	}

}

function closeMsg(){
			$("#msg_div").fadeOut(2500);
			$("#msg_div").html("");
			$("#msg_div").removeClass('trans');
			$("#msg_div").removeAttr('style');

}

function cambiaNombreBtn(obj){
	if(obj.value=='Agregar Nuevo Proveedor'){
		$("#msg_div").removeAttr('style');
		$('#add_rem_prv').attr("style","background:url(../../images/reject.png); background-position:left; background-repeat:no-repeat; background-color:#E1E4EC;");
		obj.value='Cerrar Panel de Nuevo Proveedor' ;
	}else{
		$("#msg_div").removeAttr('style');
		$('#add_rem_prv').attr("style","background:url(../../images/add.png); background-position:left; background-repeat:no-repeat; background-color:#E1E4EC;");
		obj.value='Agregar Nuevo Proveedor' ;
	}
}

function Get_idAmex(){
var frm=document.detallecomp;
var idamex=frm.cargos_select.options[frm.cargos_select.selectedIndex].value;
frm.idamex.value=idamex;
$("#cargo_info").html("Detalle del cargo: Obteniendo información, espere...");
$.ajax({
		url: './comprobacion_amex.php',
		type: "POST",
		data: "idamex="+idamex,
		success: function(datos){
				if (datos==""){	
					$("#cargo_info").html("Detalle del cargo: (Sin detalle)");	
				}else{
					$("#cargo_info").html("Detalle del cargo: "+datos);	
					}//fin if datos
			}//datos
		});//fin ajax

}

</script>
<link rel="stylesheet" type="text/css" href="../../css/jquery.autocomplete.css"/>
<link rel="stylesheet" type="text/css" href="../../css/date_input.css"/>
<link rel="stylesheet" type="text/css" href="../../css/table_style.css"/>
<style type="text/css">
.style1 {color: #FF0000}.Estilo1 {
	color: #FF0000
}
</style>
<style type="text/css">
.style1 {color: #FF0000}
.fader{opacity:0;display:none;}
.trans{
	background-color:#D7D7D7;
	color:#0000FF;
	position:absolute;
	vertical-align:middle;	
	width:690px;
	height:200px;	     
    padding:65px;
	font-size:15px;
	font-weight:bold;
	top:26%;
	left:18%;
	
    }
	.boton{	
	background:#666666;
	color:#FFFFFF;
	border-color:#CCCCCC;
	}
</style>
<div id="Layer1">
<form action="comprobacion_amex.php?save" method="post" name="detallecomp" id="detallecomp">
  <table width="785" border="0" cellspacing="1" style="border:1px #CCCCCC solid;margin:auto;margin-top:5px;text-align:left;">
  <tr></tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td colspan="9">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <?php 
        $noEmpleado = $_SESSION["idusuario"];
        $cnn = new conexion();
        $query_card = sprintf("SELECT notarjetacredito FROM empleado WHERE numempleado = '%s'", $noEmpleado);
        $rst = $cnn->consultar($query_card);
        $fila = mysql_fetch_assoc($rst);
        $noCreditCard = $fila['notarjetacredito'];
        ?>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td colspan="9">Tarjeta de Cr&eacute;dito:&nbsp;<?php 
        echo $noCreditCard;
        ?>
</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td colspan="9">Cargo<span class="style1">*</span>:
      <?php 
        function fnc_date_calc($this_date, $num_days)
        {
            $my_time = strtotime($this_date);
            //converts date string to UNIX timestamp
            $timestamp = $my_time + $num_days * 86400;
            //calculates # of days passed ($num_days) * # seconds in a day (86400)
            $return_date = date("Y-m-d", $timestamp);
            //puts the UNIX timestamp back into string format
            return $return_date;
            //exit function and return string
        }
        //end of function
        $cnn = new conexion();
        $fechalimite = fnc_date_calc(date("Y-m-d"), 90 * -1);
        //aqui va parametrizado el tiempo limite
        $fechalimiteForm = $fechalimite . " 00:00:01";
        //Damos formato timestamp
        $query_cargostc = sprintf("SELECT amex.idamex, amex.notransaccion,amex.tarjeta,\n\t\tdate_format(amex.fecha,'%%d/%%m/%%Y') as fecha,\n\t\tamex.monto, amex.estatus, amex.moneda, amex.TC,\n\t\tamex.concepto, gastosamex.idgastosamex, sum(gastosamex.estatus) as sumaestatus\n\t\tFROM amex left join gastosamex on (gastosamex.idamex=amex.idamex)\n\t\tWHERE amex.tarjeta = '%s' and amex.estatus=0 and amex.fecha<='%s'\n\t\tgroup by amex.idamex\n\t\tORDER BY amex.fecha ASC", $noCreditCard, $fechalimiteForm);
        $rst = $cnn->consultar($query_cargostc);
        $rst_total = mysql_num_rows($rst);
        if ($rst_total > 0) {
            echo "<select name='cargos_select' id='cargos_select' onchange='Get_idAmex();'>";
            echo "<option id='-1' value='-1'>Seleccione...</option>";
            while ($fila = mysql_fetch_assoc($rst)) {
                echo "<option id=" . $fila['idamex'] . " value=" . $fila['idamex'] . ">" . $fila['notransaccion'] . " (" . $fila['concepto'] . ")" . "</option>";
            }
            echo "</select>";
            $button = "enabled";
        } else {
            echo "<select name='cargos_select' id='cargos_select' disabled='disabled'>";
            echo "<option>No se encontraron cargos</option>";
            echo "</select>";
            $button = "disabled";
        }
        ?>
</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width="10">&nbsp;</td>
    <td width="78">&nbsp;</td>
    <td colspan="9"><div id="cargo_info" align="left">Detalle del cargo:</div></td>
    <td width="133">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="8">&nbsp;</td>
  </tr>
  </table>
  <br />
  <table width="785" border="0" align="center" cellspacing="1" style="border:1px #CCCCCC solid;margin:auto;margin-top:5px;text-align:left;"><tr><td colspan="2">
      <tr>
        <td colspan="13"><h3 align="center">Registro de Partidas</h3></td>
      </tr>
      <tr>
        <td width="2">&nbsp;</td>
        <td width="85"><div align="left">Concepto<span class="style1">*</span>: <br />
        </div></td>
        <td colspan="4"><div align="left">
            <select name="select_concepto" id="select_concepto" onchange="activaCb();"  style='width:250px;'>
              <option value="-1">Seleccione...</option>
              <?php 
        //Cat&aacute;logo de conceptos
        $idusuario = $_SESSION["idusuario"];
        function Get_clasificaciones2($usuario)
        {
            $cnn = new conexion();
            $query = sprintf("select cp_concepto,cp_retencion,dc_id, cp_iva as iva, cp_deducible as deducible from cat_conceptos DC  where cp_activo=true and dc_catalogo=3  and cp_empresa_id = " . $_SESSION["empresa"] . " order by cp_concepto");
            error_log($query);
            $rst = $cnn->consultar($query);
            while ($fila = mysql_fetch_assoc($rst)) {
                echo "<option id=" . $fila["cp_concepto"] . " value=" . $fila["dc_id"] . "." . $fila["iva"] . ">" . $fila["cp_concepto"] . "</option>";
            }
        }
        $cat = Get_clasificaciones2($idusuario);
        ?>
            </select>
            <input type="hidden" name="c_nam_cb" id="c_nam_cb" readonly="readonly" value="" />
        </div></td>
        <td width="4">&nbsp;</td>
        <td width="10">&nbsp;</td>
        <td><div align="left">Fecha Comprobante<span class="style1">*</span>: </div></td>
        <td colspan="3"><div align="left">
        <!---ricardo: checafecha con 5 días permitidos--->
          <input name="fecha" id="fecha" value="<?php 
        echo date('d/m/Y');
        ?>
" size="15" readonly="readonly" onfocus="return checafecha(document.detallecomp.fecha.value, 5);" />
        <img src="../../images/b_calendar.png" alt="Calendario" name="fechaIMG" width="16" height="16" id="fechaIMG" /></div></td>
        <td width="32">&nbsp;</td>
      </tr>
      <tr>
        <td width="2" height="26">&nbsp;</td>
        <td width="85"><div align="left">Monto<span class="style1">*</span>: $ </div></td>
        <td width="83"><div align="left">
            <input name="monto" id="monto" value="0" onkeyup="getTotal();" onkeypress="return validaNum(event)"  size="10" autocomplete="off"/>
        </div></td>
        <td width="60"><div align="left">IVA<span class="style1">*</span>: </div></td>
        <td colspan="2"><div align="left">
            <select name="select_impuesto" id="select_impuesto" onchange="valor(this.value);">
              <?php 
        $porcentajes = array("0", "16", "11", "No aplica");
        for ($i = 0; $i < count($porcentajes); $i++) {
            echo "<option id=" . $i . " value=" . $porcentajes[$i] . ">" . $porcentajes[$i] . "</option>";
        }
        ?>
            </select>
            %&nbsp;</div>
        </td>
        <td width="4">&nbsp;</td>
        <td width="10">&nbsp;</td>
        <td width="143"><div align="left">Divisa<span class="style1">*</span>: </div></td>
        <td width="77"><div align="left">
          <select name="moneda" id="moneda" onchange="tipoCambio(this.value);" >
            <?php 
        $tipoCambio = array("MXN", "USD");
        for ($i = 0; $i < count($tipoCambio); $i++) {
            echo "<option value=" . $i . ">" . $tipoCambio[$i] . "</option>";
        }
        ?>
          </select>
        </div></td>
        <td colspan="2">&nbsp;</td>
        <td width="32">&nbsp;</td>
      </tr>
      <tr>
        <td width="2">&nbsp;</td>
        <td width="85"><div align="left">Total<span class="style1">*</span>: $ </div></td>
        <td width="83"><div align="left">
            <input name="total"  id="total" value="0" size="10" onkeypress="return validaNum(event)" autocomplete="off" />
        </div></td>
        <td width="60"><div align="left">IVA<span class="style1">*</span>: $</div></td>
        <td colspan="2"><div align="left">
            <input name="impuesto" id="impuesto" value="0" size="8" onkeypress="return validaNum(event);" autocomplete="off" />
        </div></td>
        <td width="4">&nbsp;</td>
        <td width="10">&nbsp;</td>
        <td><div align="left">Tasa MXN: $ </div></td>
        <td><div align="left">
          <input name="tasa" id="tasa" value="1.00" size="8" onkeypress="return validaNum(event)" autocomplete="off" />
        </div></td>
        <td colspan="2">&nbsp;</td>
        <td width="32">&nbsp;</td> 
      </tr>
      <tr>
        <td width="2">&nbsp;</td>
        <td width="85"><div align="left">Comentario<span class="style1">*</span>: </div></td>
        <td colspan="10"><div align="left">
            <input name="referencia_corta" id="referencia_corta" size="84" />
        </div></td>
        <td width="32">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><div align="left">No.Asistentes</div></td>
        <td colspan="2"><div align="left">
            <input name="no_asistentes" id="no_asistentes" value="1" size="10" onkeypress="return validaNum(event)" />
        </div></td>
        <td width="57">&nbsp;</td>
        <td width="61">&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td colspan="2">&nbsp;</td>
        <td width="1">&nbsp;</td>
        <td width="128">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <?php 
        //Centro costos
        $Usu = new Usuario();
        $Usu->Load_Usuario_By_No_Empleado($_SESSION['empleado']);
        $idcentrocosto = $Usu->Get_dato('idcentrocosto');
        //echo $idcentrocosto;
        ?>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td colspan="3">&nbsp;
        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td colspan="2">&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td colspan="13"><h3 align="center">Datos de proveedor</h3></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td colspan="4">&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td colspan="2">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><div align="left">Documento:</div></td>
        <td colspan="2"><input type="checkbox" name="fact_chk" id="fact_chk" checked="checked" onclick="verificaFactura();" />
          Cuenta con Factura </td>
        <td>&nbsp;</td>
        <td colspan="3"><div align="left" id="div_folio">Folio Factura<span class="style1">*</span>:</div></td>
        <td colspan="2"><div align="left">
          <input name="d_folio" id="d_folio" size="8" onkeypress="return validaNum(event)" />
        </div></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><div id="rfc_prov_busq_div" align="left">RFC<span class="style1">*</span>: 
        </div></td>
        <td colspan="3"><div align="left">
      <input name="rfc" type="text" id="rfc" value="" size="30" maxlength="13"  onkeyup="this.value = this.value.toUpperCase();" />
    </div></td>
        <td colspan="3"><div id="name_prov_busq_div" align="left">
          <div align="left">Raz&oacute;n Social<span class="style1">*</span>: </div>
        </div></td>
        <td colspan="2"><div align="left">
          <input name="proveedor" type="text" id="proveedor" value="" size="30" />
        </div></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td width="2">&nbsp;</td>
        <td colspan="11"><div align="center" class="style1" id="load_div" ></div></td>
        <td width="32">&nbsp;</td>
      </tr>
   </td>
    </tr>
  </table>
<br />
<center><input type="button" class="fadeNext" style="background:url(../../images/add.png); background-position:left; background-repeat:no-repeat; background-color:#E1E4EC;"  name="add_rem_prv" id="add_rem_prv" onclick="cambiaNombreBtn(this);" value="Agregar Nuevo Proveedor">
<div class="fader" align="right">

<table width="785" border="0" align="center" cellspacing="1" style="border:1px #CCCCCC solid;margin:auto;margin-top:5px;text-align:left;">
  <tr>
    <td colspan="8"><div align="center">
          <h3>Agregar nuevo proveedor</h3>
  </div>  </tr>
  <tr>
    <td width="38">&nbsp;</td>
    <td width="132"><div align="right"><em><strong>Raz&oacute;n Social: </strong></em></div></td>
    <td colspan="5"><div align="left">
      <input name="new_proveedor" type="text" id="new_proveedor" value="" size="50" />
    </div></td>
    <td width="77">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div align="right"><em><strong>RFC: </strong></em></div></td>
    <td width="194"><div align="left">
      <input name="new_p_rfc" type="text" id="new_p_rfc" value="" size="30" maxlength="13"/>
    </div></td>
    <td width="7">&nbsp;</td>
    <td width="7">&nbsp;</td>
    <td width="37">&nbsp;</td>
    <td width="266">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div align="right"><em><strong>Domicilio Fiscal:</strong></em></div></td>
    <td colspan="5"><input name="new_p_addr" id="new_p_addr" value="" size="80" /></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="6">
      <div align="center">
        <input type="button" name="agregar" value="    Agregar" onclick="nuevoProveedor(new_proveedor.value,new_p_rfc.value,new_p_addr.value);" style="background:url(../../images/add.png); background-position:left; background-repeat:no-repeat; background-color:#E1E4EC;" />
        </div></td><td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="6">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</div>
</center>
<br />
<div id="msg_div" align="center" >
  </div><br />
<div align="center">
	    <input name="registrar_comp" type="button" id="registrar_comp" value="    Registrar partida"  onclick="agregarPartida();" style="background:url(../../images/ok.png); background-position:left; background-repeat:no-repeat; background-color:#E1E4EC;"/>
        <input type="hidden" name="prm_valido" id="prm_valido" readonly="readonly" value="" />
  </div>

	
	
	<?php 
    }