# The two can be equal in leap years when february has 29 days, the equal sign is added here //In the first case the whole interval is within a week, in the second case the interval falls in two weeks. if ($the_first_day_of_week <= $the_last_day_of_week) { if ($the_first_day_of_week <= 6 && 6 <= $the_last_day_of_week) $no_remaining_days--; if ($the_first_day_of_week <= 7 && 7 <= $the_last_day_of_week) $no_remaining_days--; } else { if ($the_first_day_of_week <= 6) { //In the case when the interval falls in two weeks, there will be a Sunday for sure $no_remaining_days--; } } //The no. of business days is: (number of weeks between the two dates) * (5 working days) + the remainder //---->february in none leap years gave a remainder of 0 but still calculated weekends between first and last day, this is one way to fix it $workingDays = $no_full_weeks * 5; if ($no_remaining_days > 0 ) { $workingDays += $no_remaining_days; } return @ceil($workingDays); } //The function returns the no. of total days between two dates function getDays($startDate, $endDate) { //The total number of days between the two dates. We compute the no. of seconds and divide it to 60*60*24 $days = abs(strtotime($endDate) - strtotime($startDate)) / 86400; return @ceil($days); } function sql($s) { @mysql_connect('74.208.229.38','reader','p10OSBKmO'); if ($s == "www.rumbacaracas.com" || $s == "www.rumbavenezuela.com") { @mysql_select_db('caracas'); } if ($s == "www.rumbabogota.com") { @mysql_select_db('bogota'); } if ($s == "www.rumbapanama.com") { @mysql_select_db('panama'); } } $username_sql = ""; $city_sql = ""; $a = $_REQUEST[a]; $d = $_REQUEST[d]; $m = $_REQUEST[m]; $a2 = $_REQUEST[a2]; $d2 = $_REQUEST[d2]; $m2 = $_REQUEST[m2]; $usuario = $_REQUEST[usuario]; $domain = $_REQUEST[domain]; $ciudad = $_REQUEST[ciudad]; $down = $_REQUEST[down]; $categoria = $_REQUEST[categoria]; if ($down) { if ($categoria != "") $city_sql = " and categoria LIKE '%$categoria%' "; if ($usuario != "") $username_sql = " and author='$usuario' "; if ($categoria != "") $categoria_sql = " and c.category_id='$categoria' "; $f = ''; if ($domain == "www.rumbavenezuela.com") $f .= ''; $f .= ''; sql($domain); // $sql = 'SELECT * FROM `music_news` WHERE ((`ano`*10000)+(`mes`*100)+`dia`) >= '.$a.$m.$d.' AND ((`ano`*10000)+(`mes`*100)+`dia`) <= '.$a2.$m2.$d2.' '.$username_sql.' '.$city_sql.' ORDER BY `ano` ASC, `mes` ASC, `dia` ASC;'; // $sql = '(SELECT titulo,usuario,fecha,`music_news` as plantilla FROM `music_news` WHERE (fecha >= ' . $a . '-' .$m . '-' .$d.' AND fecha <= ' . $a2 . '-' .$m2 . '-' .$d2.') '.$username_sql.' '.$city_sql.' ORDER BY fecha ASC) UNION (SELECT titulo,usuario,fecha,`rumba_news` as plantilla FROM `rumba_news` WHERE (fecha >= ' . $a . '-' .$m . '-' .$d.' AND fecha <= ' . $a2 . '-' .$m2 . '-' .$d2.') '.$username_sql.' '.$city_sql.' ORDER BY fecha ASC) UNION (SELECT titulo,usuario,fecha,`entrevista` as plantilla FROM `entrevista` WHERE (fecha >= ' . $a . '-' .$m . '-' .$d.' AND fecha <= ' . $a2 . '-' .$m2 . '-' .$d2.') '.$username_sql.' '.$city_sql.' ORDER BY fecha ASC) UNION (SELECT titulo,usuario,fecha,`especial` as plantilla FROM `especial` WHERE (fecha >= ' . $a . '-' .$m . '-' .$d.' AND fecha <= ' . $a2 . '-' .$m2 . '-' .$d2.') '.$username_sql.' '.$city_sql.' ORDER BY fecha ASC) ORDER BY fecha ASC;'; $sql = 'SELECT e.title,e.start_publication,e.author,c.category_id,ca.title as categoria FROM zinnia_entry e, zinnia_entry_categories c, zinnia_category ca WHERE c.entry_id=e.id AND c.category_id=ca.id AND (start_publication >= \'' . $a . '-' .$m . '-' .$d.'\' AND start_publication <= \'' . $a2 . '-' .$m2 . '-' .$d2.'\') '.$username_sql.' '.$city_sql.' '.$categoria_sql.' ORDER BY creation_date ASC;'; $texto = $sql; $sql = @mysql_query($sql); // echo @mysql_error(); while ($row = @mysql_fetch_array($sql)) { //DHP $dhp = 0; $row['aa'] = str_pad($row['aa'],2,0,STR_PAD_LEFT); $row['ma'] = str_pad($row['ma'],2,0,STR_PAD_LEFT); $row['da'] = str_pad($row['da'],2,0,STR_PAD_LEFT); $dhp = getWorkingDays( ($row['ano']."-".$row['mes']."-".$row['dia']), ($row['aa']."-".$row['ma']."-".$row['da']) ); $dtp = getDays( ($row['ano']."-".$row['mes']."-".$row['dia']), ($row['aa']."-".$row['ma']."-".$row['da']) ); $f .= ''; if ($domain == "www.rumbavenezuela.com") $f .= ''; $f .= ''; } $f .= '
REPORTE DESDE EL '.$d.' DE '.strtoupper($meses[$m]).' DE '.$a.' HASTA EL '.$d2.' DE '.strtoupper($meses[$m2]).' DE '.$a2.'
CiudadEvento Reporteros Fecha Categoria
'.$row['title'].''.$row['title'].' '.$row['author'].' '.$row['start_publication'].' '.$row['categoria'].'
'; header( "Content-Type: application/octet-stream"); header( "Content-Disposition: attachment; filename=$d-$m-".$a."_-_$d2-$m2-$a2.xls"); echo($f); exit; } ?>

 
   
Generar Reporte del al  

= '.$a.$m.$d.' AND ((`ano`*10000)+(`mes`*100)+`dia`) <= '.$a2.$m2.$d2.' ORDER BY categoria ASC;'; $rs = @mysql_query($sql); $count = @mysql_num_rows($rs) ?> = \'' . $a . '-' .$m . '-' .$d.'\' AND start_publication <= \'' . $a2 . '-' .$m2 . '-' .$d2.'\') '.$username_sql.' '.$city_sql.' '.$categoria_sql.' ORDER BY creation_date ASC;'; //echo $sql; $sql = @mysql_query($sql); //echo @mysql_error(); while ($row = @mysql_fetch_array($sql)) { //DHP $teve++; $row['ano'] = str_pad($row['ano'],2,0,STR_PAD_LEFT); $row['mes'] = str_pad($row['mes'],2,0,STR_PAD_LEFT); $row['dia'] = str_pad($row['dia'],2,0,STR_PAD_LEFT); $dhp = getWorkingDays( ($row['ano']."-".$row['mes']."-".$row['dia']), ($row['aa']."-".$row['ma']."-".$row['da']) ); $dtp = getDays( ($row['ano']."-".$row['mes']."-".$row['dia']), ($row['aa']."-".$row['ma']."-".$row['da']) ); ?>
REPORTE DESDE EL Descargar Reporte"; ?>
Ciudad Evento   ( ) Usuario Fecha Plantilla
Total Eventos Cargados: