 <!--Proforma-->
<?php
$num_ordenf2= $rowc['id_pedido'];
$queryf2="SELECT `id_check`, `num_orden`, `f_orden`, `f_proforma`, `f_anticipo`, `f_verif_ant`, `f_pago_ant`, `f_produccion`, f_embarque, `f_producion_cant`, `f_producion_color`, `f_producion_empaque`, `f_laps`, `f_aprob_lap`, `f_aprob_lap_tipo`, `f_ini_prod`, `f_fin_prod`, `f_revision`, `f_revision_tipo`, `f_envio_informe`, `f_shipping_sample`, `f_aprob_sample`, `f_aprob_sample_tipo`, `f_cargue_zarpe`, `f_cargue`, `f_zarpe`, `f_llegada`, `f_revision_doc`, `f_revision_doc_bl`, `f_revision_doc_emp`, `f_revision_doc_fact`, `f_envio_doc`, `f_balance`, `f_balance_pago`, `f_balance_fab` , `f_balance_fab_pago`, `f_liberar`, `f_liberar_tipo`, `f_factura`, `f_pago` FROM `checklist` where num_orden='$num_ordenf2'";
    $resultadof2=$conexion->query($queryf2);
    $rowf2=$resultadof2->fetch_assoc();

$resul_validador=0;
$total_dias2=0;


if ($rowc['fecha_pedido']=="") {

//echo "<td></td>";
  }
else {

$startDateString = $rowc['fecha_pedido']; 

if ($rowf2['f_proforma']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_proforma']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  



  if ($rowf2['f_proforma']=="" && $total_dias2>=1) {
  
  //echo "<td class=rojo ></td>";

    $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=0 && $rowf2['f_proforma']=="") {
     //echo "<td ></td>";
    // $resul_validador=$resul_validador-$total_dias2;
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}



}



//echo "Validador: ".$resul_validador;
$total_dias2=0;
?>
                                        
                                          <!-- fecha Pago 1er Anticipo -->
<?php
if ($rowf2['f_proforma']=="") {

//echo "<td></td>";
  }
else {

$startDateString = $rowf2['f_proforma']; 

if ($rowf2['f_anticipo']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_anticipo']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  


  if ($rowf2['f_anticipo']=="" && $total_dias2>=1 ) {
  
  //echo "<td class=rojo ></td>";
    $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=0 && $rowf2['f_anticipo']=="") {
     //echo "<td ></td>";
    
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}

}



//$total_dias2=0;echo "ESTEValidador: ".$resul_validador;
?>
                     
                                         
                                           <!-- Verificaión de Pago 1er Anticipo-->
<?php
if ($rowf2['f_anticipo']=="") {

//echo "<td></td>";
  }
else {

$startDateString = $rowf2['f_anticipo']; 

if ($rowf2['f_verif_ant']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_verif_ant']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  


  if ($rowf2['f_verif_ant']=="" && $total_dias2>=1 ) {
  
  //echo "<td class=rojo ></td>";
    $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=0 && $rowf2['f_verif_ant']=="") {
     //echo "<td ></td>";
    
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}

}

//echo "Validador: ".$resul_validador;

$total_dias2=0;
?>


 <!-- Verificaión de Pago Anticipo fabrica-->
<?php
if ($rowf2['f_verif_ant']=="") {

//echo "<td></td>";
  }
else {

$startDateString = $rowf2['f_verif_ant']; 

if ($rowf2['f_pago_ant']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_pago_ant']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  


  if ($rowf2['f_pago_ant']=="" && $total_dias2>=0 ) {
  
  //echo "<td class=rojo ></td>";
    $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=0 && $rowf2['f_pago_ant']=="") {
     //echo "<td ></td>";
    
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}

}

//echo "Validador: ".$resul_validador;

$total_dias2=0;
?>



                                            
                                            <!-- Generar orden de producción-->
                                            <?php
if ($rowf2['f_pago_ant']=="") {

//echo "<td></td>";
  }
else {

$startDateString = $rowf2['f_pago_ant']; 

if ($rowf2['f_produccion']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_produccion']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  


  if ($rowf2['f_produccion']=="" && $total_dias2>=1 ) {
  
  //echo "<td class=rojo ></td>";
    $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=0 && $rowf2['f_produccion']=="") {
     //echo "<td ></td>";
    
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}

}



//$total_dias2=0;echo "Validador: ".$resul_validador;
?>



                                            <!--Fecha de envío Lab dips/stike off-->
                                                                                         <?php
if ($rowf2['f_produccion']=="") {

//echo "<td></td>";
  }
else {

$startDateString = $rowf2['f_produccion']; 

if ($rowf2['f_laps']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_laps']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  


  if ($rowf2['f_laps']=="" && $total_dias2>=1 ) {
  
  //echo "<td class=rojo ></td>";
    $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=0 && $rowf2['f_laps']=="") {
     //echo "<td ></td>";
    
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}

}



//$total_dias2=0;echo "Validador: ".$resul_validador;
?>


                                           <!--Fecha de aprobación Lab dips/stike off-->
                                              <?php
if ($rowf2['f_laps']=="") {

//echo "<td></td>";
  }
else {

$startDateString = $rowf2['f_laps']; 

if ($rowf2['f_aprob_lap']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_aprob_lap']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  


  if ($rowf2['f_aprob_lap']=="" && $total_dias2>=1 ) {
  
  //echo "<td class=rojo ></td>";
    $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=0 && $rowf2['f_aprob_lap']=="") {
     //echo "<td ></td>";
    
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}

}




//echo "Validador: ".$resul_validador;

$total_dias2=0;
?>

                                            <!-- Fecha de inicio de Producción-->
                                                                                   <?php
if ($rowf2['f_ini_prod']=="" && $rowf2['f_aprob_lap']=="") {

//echo "<td style='border-left:1px solid;'></td>";
  }
else {

if ($rowf2['f_ini_prod']=="") {
 //echo "<td style='border-left:1px solid;' class=rojo ></td>";
   $resul_validador=$resul_validador+1;
}else
{
 //echo "<td style='border-left:1px solid;' class=verde ></td>";

}



}




//echo "Validador: ".$resul_validador;

$total_dias2=0;
?>
 <!-- Generar embarque-->
                                            <?php
if ($rowf2['f_ini_prod']=="") {

//echo "<td></td>";
  }
else {

$startDateString = $rowf2['f_ini_prod']; 

if ($rowf2['f_embarque']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_embarque']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  


  if ($rowf2['f_embarque']=="" && $total_dias2>=0 ) {
  
  //echo "<td class=rojo ></td>";
    $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=0 && $rowf2['f_embarque']=="") {
     //echo "<td ></td>";
    
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}

}




//echo "Validador: ".$resul_validador;

$total_dias2=0;
?>

                                            <!-- Fecha de fin de Producción-->
   <?php
if ($rowf2['f_fin_prod']=="" && $rowf2['f_ini_prod']=="") {

//echo "<td></td>";
  }
else {

if ($rowf2['f_fin_prod']=="") {
 //echo "<td class=rojo ></td>";
  $resul_validador=$resul_validador+1;
}else
{
 //echo "<td class=verde ></td>";

}



}




//echo "Validador: ".$resul_validador;

$total_dias2=0;
?>
                 <!--Revisión mercancia-->
                                                               <?php
if ($rowf2['f_fin_prod']=="") {

//echo "<td ></td>";
  }
else {

$startDateString = $rowf2['f_fin_prod']; 

if ($rowf2['f_revision']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_revision']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  


  if ($rowf2['f_revision']=="" && $total_dias2>=1 ) {
  
  //echo "<td class=rojo ></td>";
    $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=0 && $rowf2['f_revision']=="") {
     //echo "<td ></td>";
    
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}

}




//echo "Validador: ".$resul_validador;

$total_dias2=0;
?>

         <!--Envío informe-->
                                                               <?php
if ($rowf2['f_revision']=="") {

//echo "<td></td>";
  }
else {

$startDateString = $rowf2['f_revision']; 

if ($rowf2['f_envio_informe']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_envio_informe']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  


  if ($rowf2['f_envio_informe']=="" && $total_dias2>=1 ) {
  
  //echo "<td class=rojo ></td>";
    $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=0 && $rowf2['f_envio_informe']=="") {
     //echo "<td ></td>";
    
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}

}






//$total_dias2=0;echo "Validador: ".$resul_validador;
?>


                                            <!--Envío de shipping sample-->
                                                                                                                              <?php
if ($rowf2['f_envio_informe']=="") {

//echo "<td></td>";
  }
else {

$startDateString = $rowf2['f_envio_informe']; 

if ($rowf2['f_shipping_sample']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_shipping_sample']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  


  if ($rowf2['f_shipping_sample']=="" && $total_dias2>=1 ) {
  
  //echo "<td class=rojo ></td>";
    $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=0 && $rowf2['f_shipping_sample']=="") {
     //echo "<td ></td>";
    
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}

}

//$total_dias2=0;echo "Validador: ".$resul_validador;
?>





                                           <!-- Aprobación de shipping sample -->
   <?php
/*if ($rowf2['f_shipping_sample']=="") {

//echo "<td></td>";
  }
else {

$startDateString = $rowf2['f_shipping_sample']; 

if ($rowf2['f_aprob_sample']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_aprob_sample']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  


  if ($rowf2['f_aprob_sample']=="" && $total_dias2>=1 ) {
  
  //echo "<td class=rojo ></td>";
  $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=0 && $rowf2['f_aprob_sample']=="") {
     //echo "<td ></td>";
    
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}

}*/

$total_dias2=0;
?>
                                            <!--Fecha de cargue y zarpe-->
                                                       <?php
/*if ($rowf2['f_aprob_sample']=="" && $rowf2['f_cargue_zarpe']=="") {

echo "<td style='border-left:1px solid;' ></td>";
  }
else {

if ($rowf2['f_cargue_zarpe']=="") {
 echo "<td style='border-left:1px solid;' class=rojo ></td>";
}else
{
 echo "<td style='border-left:1px solid;' class=verde ></td>";

}



}*/

$total_dias2=0;
?>

                    <!-- fecha de cargue-->
                         <?php
if ($rowf2['f_cargue']=="" && $rowf2['f_shipping_sample']=="") {

//echo "<td style='border-left:1px solid;'></td>";
  }
else {

if ($rowf2['f_cargue']=="") {
// echo "<td style='border-left:1px solid;' class=rojo ></td>";
  $resul_validador=$resul_validador+1;
}else
{
 //echo "<td style='border-left:1px solid;' class=verde ></td>";

}



}



//echo "Validador: ".$resul_validador;

$total_dias2=0;
?>


                                           <!-- fecha de zarpe-->
                         <?php
if ($rowf2['f_zarpe']=="" && $rowf2['f_cargue']=="") {

//echo "<td></td>";
  }
else {

if ($rowf2['f_zarpe']=="") {
 //echo "<td class=rojo ></td>";
  $resul_validador=$resul_validador+1;
}else
{
 //echo "<td class=verde ></td>";

}



}



//echo "Validador: ".$resul_validador;

$total_dias2=0;
?>

                                            
                                           
                                            <!--fecha de llegada-->
                                                                                <?php
if ($rowf2['f_zarpe']=="") {

//echo "<td></td>";
  }
else {

$startDateString = $rowf2['f_zarpe']; 

if ($rowf2['f_llegada']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_llegada']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  


  if ($rowf2['f_llegada']=="" && $total_dias2>=1 ) {
  
  //echo "<td class=rojo ></td>";
    $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=0 && $rowf2['f_llegada']=="") {
     //echo "<td ></td>";
    
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}

}


//echo "Validador: ".$resul_validador;

$total_dias2=0;
?>
                                           <!--Revision de doc  -->
                                                                                <?php
if ($rowf2['f_zarpe']=="") {

//echo "<td></td>";
  }
else {

$startDateString = $rowf2['f_zarpe']; 

if ($rowf2['f_revision_doc']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_revision_doc']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  


  if ($rowf2['f_revision_doc']=="" && $total_dias2>=1 ) {
  
  //echo "<td class=rojo ></td>";
    $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=0 && $rowf2['f_revision_doc']=="") {
     //echo "<td ></td>";
    
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}

}

$total_dias2=0;
?>
                                            <!-- Fecha envio doc-->
                                                                                                              <?php
if ($rowf2['f_zarpe']=="") {

//echo "<td></td>";
  }
else {

$startDateString = $rowf2['f_zarpe']; 

if ($rowf2['f_envio_doc']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_envio_doc']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  


  if ($rowf2['f_envio_doc']=="" && $total_dias2>=1 ) {
  
  //echo "<td class=rojo ></td>";
    $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=0 && $rowf2['f_envio_doc']=="") {
     //echo "<td ></td>";
    
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}

}



//echo "Validador: ".$resul_validador;

$total_dias2=0;
?>

                 <!-- Fecha pago balance-->
                                                                                                              <?php
if ($rowf2['f_zarpe']=="") {

//echo "<td></td>";
  }
else {

$startDateString = $rowf2['f_zarpe']; 

if ($rowf2['f_balance']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_balance']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  


  if ($rowf2['f_balance']=="" && $total_dias2>=1 ) {
  
  //echo "<td class=rojo ></td>";
    $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=20 && $rowf2['f_balance']=="") {
     //echo "<td ></td>";
    
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}

}

$total_dias2=0;
?>

<!-- Fecha pago balance-->
                                                                                                              <?php
if ($rowf2['f_balance']=="") {

//echo "<td></td>";
  }
else {

$startDateString = $rowf2['f_balance']; 

if ($rowf2['f_balance_fab']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_balance_fab']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  


  if ($rowf2['f_balance_fab']=="" && $total_dias2>=1 ) {
  
  //echo "<td class=rojo ></td>";
    $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=20 && $rowf2['f_balance_fab']=="") {
     //echo "<td ></td>";
    
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}

}

$total_dias2=0;
?>


       <!-- Fecha liberar-->
                                                                                                              <?php
if ($rowf2['f_balance']=="") {

//echo "<td></td>";
  }
else {

$startDateString = $rowf2['f_balance']; 

if ($rowf2['f_liberar']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_liberar']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  


  if ($rowf2['f_liberar']=="" && $total_dias2>=1 ) {
  
  //echo "<td class=rojo ></td>";
    $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=0 && $rowf2['f_liberar']=="") {
     //echo "<td ></td>";
    
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}

}

$total_dias2=0;
?>

 


  <!-- Fecha factura-->
                                                                                                              <?php
if ($rowf2['f_balance']=="") {

//echo "<td></td>";
  }
else {

$startDateString = $rowf2['f_balance']; 

if ($rowf2['f_factura']=="") { $endDateString = date("Y-m-d"); } 
else { $endDateString = $rowf2['f_factura']; }

$format = 'Y-m-d';

$startDateTime = DateTime::createFromFormat($format, $startDateString);
$endDateTime = DateTime::createFromFormat($format, $endDateString);
$dateInterval = new DateInterval('P1D');

$days = new DatePeriod($startDateTime, $dateInterval, $endDateTime);

$total_dias2=0;
foreach ($days as $day) {
 $weekDay = $day->format('N');
  $dia = $day->format('Y-m-d');
if ($weekDay !== 'XX' && $weekDay !== 'XX' ) { $total_dias2=$total_dias2+1; }
}
  


  if ($rowf2['f_factura']=="" && $total_dias2>=1 ) {
  
  //echo "<td class=rojo ></td>";
    $resul_validador=$resul_validador+1;

}
else
{
   if ($total_dias2<=0 && $rowf2['f_factura']=="") {
     //echo "<td ></td>";
    
    }
    else
    {
        //echo "<td class=verde ></td>";
    }
}

}

$total_dias2=0;
?>


                                           <!-- fecha de pago comision-->
                         <?php
if ($rowf2['f_factura']=="" && $rowf2['f_pago']=="") {

//echo "<td></td>";
  }
else {

if ($rowf2['f_pago']=="") {
 //echo "<td class=rojo ></td>";
  $resul_validador=$resul_validador+1;
}else
{
 //echo "<td class=verde ></td>";

}



}



$total_dias2=0;
?>