<?php

 ob_start();
// session_start();
header("Expires: Mon, 20 Mar 1998 12:01:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

 require_once("Sigma.php");
 mb_http_output('UTF-8');
 $tpl =& new HTML_Template_Sigma('.','./template/cache');
 $tpl->loadTemplateFile('pitcheo.htm');
 $file = $_GET['file'];

  $colores = "";
  $tpl->setVariable('fecha', date("d/m/Y"));
if(file_exists($file) && is_readable($file))
{
  if (!$myxml=simplexml_load_file($file))
   echo 'Error al Cargar Archivo XML';
  else
  {
   $colores = "#FFCB97";
   foreach($myxml as $node)
  {
       if ($colores == "#FFCB97")
         {
           $tpl->setVariable('colores', 'bgcolor=""');
           $colores = "";
         }
       elseif($colores == "")
         {
           $tpl->setVariable('colores', 'bgcolor="#FFCB97"');
           $colores = "#FFCB97";
         }
       else
        {
           $tpl->setVariable('colores', 'bgcolor="#FFCB97"');
           $colores = "#FFCB97";
        }

        $tpl->setVariable('nu'  ,BlankSpace($node->Orden));

        $timegame = explode(":", $node->GameTime);
        $hora = $timegame[0].':'.$timegame[1];
        //$meridian = $timegame[2];
         if($timegame[2] == 'p.' || $timegame[2] == 'P.')
                 $meridian = 'PM';
               elseif($timegame[2] == 'a.' || $timegame[2] == 'A.')
                 $meridian = 'AM';
               else
                 $meridian = $timegame[2];


           $tpl->setVariable('time',$hora);
           $tpl->setVariable('spa',$meridian);
           $tpl->setVariable('liga',$node->League);

           $tpl->setVariable('vis_team',   $node->TeamNameVis);
           $tpl->setVariable('loc_team',   $node->TeamNameLoc);

           $tpl->setVariable('g_vis', utf8_decode($node->TeamWinLossVis));
           $tpl->setVariable('g_loc', utf8_decode($node->TeamWinLossLoc));
           $tpl->setVariable('pitch_vis', utf8_decode($node->PitNameVis));
           $tpl->setVariable('pitch_loc', utf8_decode($node->PitNameLoc));
           $tpl->setVariable('gp_vis',   utf8_decode($node->PitWinLossVis));
           $tpl->setVariable('gp_loc',   utf8_decode($node->PitWinLossLoc));
           $tpl->setVariable('efe_vis',  utf8_decode($node->EfectivityVis));
           $tpl->setVariable('efe_loc',  utf8_decode($node->EfectivityLoc));
           $tpl->setVariable('ks_vis',   utf8_decode($node->StrikeOutVis));
           $tpl->setVariable('ks_loc',   utf8_decode($node->StrikeOutLoc));
           $tpl->setVariable('in_vis',   utf8_decode($node->ThrownInningVis));
           $tpl->setVariable('in_loc',   utf8_decode($node->ThrownInningLoc));
           $tpl->setVariable('gp_vis3',  utf8_decode($node->PitWinLossOPVis));
           $tpl->setVariable('gp_loc3',  utf8_decode($node->PitWinLossOPLoc));
           $tpl->setVariable('efe_vis2', utf8_decode($node->EfectivityOPVis));
           $tpl->setVariable('efe_loc2', utf8_decode($node->EfectivityOPLoc));
           $tpl->setVariable('ks2_vis', utf8_decode($node->StrikeOutOPVis));
           $tpl->setVariable('ks2_loc', utf8_decode($node->StrikeOutOPLoc));
           $tpl->setVariable('in2_vis', utf8_decode($node->ThrownInningOPVis));
           $tpl->setVariable('in2_loc', utf8_decode($node->ThrownInningOPLoc));

        $tpl->parse('bloque');

   }//for.
  }//else
}

//formar oferta del dia.

//$file = $_GET['file2'];
  $file = "ofd1.xml";

  $colores = "";
  $tpl->setVariable('fecha', date("d/m/Y"));
if(file_exists($file) && is_readable($file))
{
  if (!$myxml=simplexml_load_file($file))
   echo 'Error al Cargar Archivo XML';
  else
  {

  foreach($myxml as $node)
  {
    $tpl->setVariable('dep', $node->Liga);
     if ($colores == "#FFFF00")
         {
           $tpl->setVariable('colores', 'bgcolor=""');
           $colores = "";
         }
       elseif($colores == "")                     // bgcolor="#99CC00"
         {
          // $tpl->setVariable('colores', 'bgcolor="#FFCCFF"');
           $colores = "#FFFF00";
         }

        $timegame = explode(":", $node->TimeGame);
        $hora = $timegame[0].':'.$timegame[1];
       // $meridian = $timegame[2];
        if($timegame[2] == 'p.' || $timegame[2] == 'P.')
                 $meridian = 'PM';
               elseif($timegame[2] == 'a.' || $timegame[2] == 'A.')
                 $meridian = 'AM';
               else
                 $meridian = $timegame[2];

         //  $tpl->setVariable('nu'  ,BlankSpace($node->Orden));

           $tpl->setVariable('hora',$hora.$meridian);
           $tpl->setVariable('img1','<img src="./logos/'.$node->Logo.'" width="79" height="80">');
           $tpl->setVariable('vId',$node->Team);

           $tpl->setVariable('eq_visitante', $node->Equipo);
          // $tpl->setVariable('lId', $node->Team);
           $tpl->setVariable('ml',utf8_decode($node->MLOffer));
           $tpl->setVariable('rl',utf8_decode($node->RLOffer));
           $tpl->setVariable('to',utf8_decode($node->TOffer));
           $tpl->setVariable('note',utf8_decode($node->Note));
        $tpl->parse('bloque2');

   }//for.
  }//else
}
else
  {
    $tpl->setVariable('error', 'TODAVIA NO SE HA ESTABLECIDO LA OFERTA DEL DIA.');
    $tpl->setVariable('dep', 'TODAVIA NO SE HA ESTABLECIDO LA OFERTA DEL DIA.');
  }

$tpl->show();

?>