<?php use_helper('UrlFunctions'); 

$i_IdColaborador = myUser::getUser()->getIdColaborador();
$i_IdPadre = myUser::getUser()->getIdParent();


$o_sucursalBL = new SucursalBL();
$o_SucursalBean = new SucursalBean();
$o_SucursalBean->setIdAdministrador($i_IdPadre);
$a_o_sucursales = $o_sucursalBL->busquedaSucursal($o_SucursalBean);

foreach ($a_o_sucursales as $iKey => $o_sucursales){ 
		$idsucursal = $o_sucursales->getIdSucursal();
		$descripcionSucursal = $o_sucursales->getDescripcion();
		//echo $idsucursal;
}



//$s_FechaOperacion = date("Y-m-d"); 
$o_CierrePedidoDP = new CierrePedidoDP(new CierrePedidoBean());
$s_FechaOperacion = $o_CierrePedidoDP->obtenerFechaCierrePeriodo($idsucursal,$i_IdColaborador);

$i_idpedidon = $o_CierrePedidoDP->existe_pedidos($s_FechaOperacion,$idsucursal,$i_IdColaborador,'-1');

?>
<script>
findControl = function(){  
  concatValueStr();
}
concatValueStr = function(){
  strFormSerialize = returnQueryStringForm();
  if(arguments[0]){
    strFormSerialize += '&'+arguments[0];
  }
  executeFind(strFormSerialize);
}
executeFind = function(str){ 
  url = "<?=buildUrl('pdo/grid', "block=".$block)?>";
  cargandoImagenSerch();
  new Ajax.Updater(
                    'resultGrtid', 
                    url,
                    {
                      method      : 'get',
                      parameters  : str,
                      evalScripts	: true,
                      onSuccess   : function(transport, json)
                      {
                        
                      },
                      onFailure  : function(transport)
                      {
                        alert("Error ("+transport.status+"): "+transport.statusText);
                      },
                      onComplete : function(transport)
                      {
                        
                      }
                    }
                  );
}
returnQueryStringForm = function ()
{
  cadenaFormulario = $('form1').serialize();
  return(cadenaFormulario);
}
cargandoImagenSerch = function()
{
	//disabledWin.setPathImage('/images/common/progress.gif');
	disabledWin.show(true,true,'resultGrtid');
}
</script>
<table width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-top: 5px; margin-bottom: 5px;">
  <tr>
    <td class="titleBody"><li>Pedidos</li></td>
    <td align="right">
     <?php if($i_idpedidon == 0){?><input type="button" class="button" value="Nuevo pedido" onclick="location.href='<?php echo buildUrl('pdo/addedit','block=001')?>'" title="Nuevo pedido"/><?php }?>
    </td>
  </tr>
</table>

<form action="" method="post" name="form1" id="form1">
  <table width="100%" cellspacing="0" cellpadding="0" border="0" class="marco" style="padding-left: 10px;">
    <tr>
      <td colspan="2"><img width="1" height="4" src="/images/common/spacer.gif"></td>
    </tr>
    
    <tr>
      <td width="25%" nowrap="nowrap">
        <table width="100%" cellspacing="1" cellpadding="0" border="0" class="SubCabecera">
          <tr>
            <td width="35%" nowrap="nowrap"><div class="field-label"><label for="s_Nombre" class="label">Fecha Desde :</label></div></td>
            <td nowrap="nowrap">
                <input class="text" type="text" ondblclick="this.value=''" name="txtFechaInicial" id="txtFechaInicial" size="7" readonly value=""/>
                <button type="button" onclick="return false" id="btnFechaInicial">...</button></td>
                <script type="text/javascript">
                    document.getElementById("txtFechaInicial").disabled = false;
                    Calendar.setup({
                      inputField : "txtFechaInicial",
                      ifFormat : "%Y-%m-%d",
                      daFormat : "%Y-%m-%d",
                      button   : "btnFechaInicial"
                    });
                </script>
            </td>
          </tr>
        </table>
      </td>
      <td width="25%" nowrap="nowrap">
        <table width="100%" cellspacing="1" cellpadding="0" border="0" class="SubCabecera">
          <tr>
            <td width="35%" nowrap="nowrap"><div class="field-label">
                <label for="s_codigoCliente" class="label">C&oacute;digo Cliente :</label></div>
            </td>
            <td nowrap="nowrap">
              <input type="text" class="text" name="s_codigoCliente" id="s_codigoCliente" size="8px"/>
            </td>
          </tr>
        </table>
      </td>
    </tr>
    
    <tr>
      <td width="25%" nowrap="nowrap">
        <table width="100%" cellspacing="1" cellpadding="0" border="0" class="SubCabecera">
          <tr>
            <td width="35%" nowrap="nowrap"><div class="field-label"><label for="s_Descripcion" class="label">Fecha Hasta</label></div></td>
            <td nowrap="nowrap">
                <input class="text" type="text" ondblclick="this.value=''" name="txtFechaFinal" id="txtFechaFinal" size="7" readonly value=""/>
                <button type="button" onclick="return false" id="btnFechaFinal">...</button></td>
                <script type="text/javascript">
                    document.getElementById("txtFechaFinal").disabled = false;
                    Calendar.setup({
                      inputField : "txtFechaFinal",
                      ifFormat : "%Y-%m-%d",
                      daFormat : "%Y-%m-%d",
                      button   : "btnFechaFinal"
                    });
                </script>
            </td>
          </tr>
        </table>
      </td>
      <td width="25%" nowrap="nowrap">
        <table width="100%" cellspacing="1" cellpadding="0" border="0" class="SubCabecera">
          <tr>
            <td width="35%" nowrap="nowrap">
            	<div class="field-label">
            		<label for="s_cliente" class="label">Cliente :</label>
            	</div>
            </td>
            <td nowrap="nowrap">
              <input type="text" class="text" name="s_cliente" id="s_cliente" size="25px"/>
            </td>
          </tr>
        </table>
      </td>
    </tr>
    
    <tr>
      <td align="center" colspan="100"><input type="button" onclick="findControl();" value="Buscar" id="btn_frmFindFeaturesTpl" class="button"></td>
    </tr>
    <tr>
      <td colspan="2"><img width="1" height="4" src="/images/common/spacer.gif"></td>
    </tr>
  </table>
</form>
<div id="resultGrtid"></div>
<script>
findControl();
</script>