function get_related_dates($projectname, $basedate) { include "cdash/config.php"; require_once "cdash/pdo.php"; $dates = array(); $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}"); pdo_select_db("{$CDASH_DB_NAME}", $db); $dbQuery = pdo_query("SELECT nightlytime FROM project WHERE name='{$projectname}'"); if (pdo_num_rows($dbQuery) > 0) { $project = pdo_fetch_array($dbQuery); $nightlytime = $project['nightlytime']; //echo "query result nightlytime: " . $nightlytime . "<br/>"; } else { $nightlytime = "00:00:00"; //echo "default nightlytime: " . $nightlytime . "<br/>"; } if (!isset($basedate) || strlen($basedate) == 0) { $basedate = gmdate(FMT_DATE); } // Convert the nightly time into GMT $nightlytime = gmdate(FMT_TIME, strtotime($nightlytime)); $nightlyhour = time2hour($nightlytime); $nightlyminute = time2minute($nightlytime); $nightlysecond = time2second($nightlytime); $basemonth = date2month($basedate); $baseday = date2day($basedate); $baseyear = date2year($basedate); $dates['nightly+2'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday + 2, $baseyear); $dates['nightly+1'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday + 1, $baseyear); $dates['nightly-0'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday, $baseyear); $dates['nightly-1'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday - 1, $baseyear); $dates['nightly-2'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday - 2, $baseyear); // Snapshot of "now" // $currentgmtime = time(); $currentgmdate = gmdate(FMT_DATE, $currentgmtime); // Find the most recently past nightly time: // $todaymonth = date2month($currentgmdate); $todayday = date2day($currentgmdate); $todayyear = date2year($currentgmdate); $currentnightly = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $todaymonth, $todayday, $todayyear); while ($currentnightly > $currentgmtime) { $todayday = $todayday - 1; $currentnightly = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $todaymonth, $todayday, $todayyear); } $dates['now'] = $currentgmtime; $dates['most-recent-nightly'] = $currentnightly; $dates['today_utc'] = $currentgmdate; $dates['basedate'] = gmdate(FMT_DATE, $dates['nightly-0']); // CDash equivalent of DART1's "last rollup time" if ($dates['basedate'] === $dates['today_utc']) { // If it's today, it's now: $dates['last-rollup-time'] = $dates['now']; } else { // If it's not today, it's the nightly time on the basedate: $dates['last-rollup-time'] = $dates['nightly-0']; } return $dates; }
function get_related_dates($projectnightlytime, $basedate) { $dates = array(); $nightlytime = $projectnightlytime; if (!isset($basedate) || strlen($basedate) == 0) { $basedate = gmdate(FMT_DATE); } // Convert the nightly time into GMT $nightlytime = gmdate(FMT_TIME, strtotime($nightlytime)); $nightlyhour = time2hour($nightlytime); $nightlyminute = time2minute($nightlytime); $nightlysecond = time2second($nightlytime); $basemonth = date2month($basedate); $baseday = date2day($basedate); $baseyear = date2year($basedate); $dates['nightly+2'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday + 2, $baseyear); $dates['nightly+1'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday + 1, $baseyear); $dates['nightly-0'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday, $baseyear); $dates['nightly-1'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday - 1, $baseyear); $dates['nightly-2'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday - 2, $baseyear); // Snapshot of "now" // $currentgmtime = time(); $currentgmdate = gmdate(FMT_DATE, $currentgmtime); // Find the most recently past nightly time: // $todaymonth = date2month($currentgmdate); $todayday = date2day($currentgmdate); $todayyear = date2year($currentgmdate); $currentnightly = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $todaymonth, $todayday, $todayyear); while ($currentnightly > $currentgmtime) { $todayday = $todayday - 1; $currentnightly = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $todaymonth, $todayday, $todayyear); } $dates['now'] = $currentgmtime; $dates['most-recent-nightly'] = $currentnightly; $dates['today_utc'] = $currentgmdate; $dates['basedate'] = gmdate(FMT_DATE, $dates['nightly-0']); // CDash equivalent of DART1's "last rollup time" if ($dates['basedate'] === $dates['today_utc']) { // If it's today, it's now: $dates['last-rollup-time'] = $dates['now']; } else { // If it's not today, it's the nightly time on the basedate: $dates['last-rollup-time'] = $dates['nightly-0']; } return $dates; }
<?php //$_POST["date_jour"]=date("Y-m-d",time()-86400); $_POST["date_jour"] = date("d-mY", time() - 86400); $_POST["date_jour"] = "27-08-2014"; //on recherche la liste de véhicule auquel a droit l'utilisateur $sql = getsqllistvehicule(); $link_list_vehicule = query($sql); while ($tbl_list_vehicule = fetch($link_list_vehicule)) { $_POST["vehicule"] = $tbl_list_vehicule["phantom_device_id"]; $tabresult = exportexcel("mensuel", implodeargskey($_POST), array("Date", "Début", "Fin", "Ampl.", "Conduite", "Arrêt", "Distance", "Vit.max."), array("date", "debut", "fin", "datediff", "conduite", "arret", "km", "vitessemax")); $html = "Ci joint le rapport conducteur du mois " . date2month($_POST["date_jour"]) . " pour le véhicule " . $tbl_list_vehicule["nomvehicule"]; sendmailmister('', '', 'Rapport conducteur du mois ' . date2month($_POST["date_jour"]), $html, $_SESSION["email"], '', $tabresult); } //mise a jour de la date dans rapport /* $sql="update ".__racinebd__."rapport set date_envoi='".$_POST["date_debut"]."' where rapport_id=10"; query($sql); */
/** Get dates * today: the *starting* timestamp of the current dashboard * previousdate: the date in Y-m-d format of the previous dashboard * nextdate: the date in Y-m-d format of the next dashboard */ function get_dates($date, $nightlytime) { $nightlytime = strtotime($nightlytime); $nightlyhour = date("H", $nightlytime); $nightlyminute = date("i", $nightlytime); $nightlysecond = date("s", $nightlytime); if (!isset($date) || strlen($date) == 0) { $date = date(FMT_DATE); // the date is always the date of the server if (date(FMT_TIME) > date(FMT_TIME, $nightlytime)) { $date = date(FMT_DATE, time() + 3600 * 24); //next day } } else { // If the $nightlytime is in the morning it's actually the day after if (date(FMT_TIME, $nightlytime) < '12:00:00') { $date = date(FMT_DATE, strtotime($date) + 3600 * 24); // previous date } } $today = mktime($nightlyhour, $nightlyminute, $nightlysecond, date2month($date), date2day($date), date2year($date)) - 3600 * 24; // starting time // If the $nightlytime is in the morning it's actually the day after if (date(FMT_TIME, $nightlytime) < '12:00:00') { $date = date(FMT_DATE, strtotime($date) - 3600 * 24); // previous date } $todaydate = mktime(0, 0, 0, date2month($date), date2day($date), date2year($date)); $previousdate = date(FMT_DATE, $todaydate - 3600 * 24); $nextdate = date(FMT_DATE, $todaydate + 3600 * 24); return array($previousdate, $today, $nextdate, $date); }
<div class="resize rapport_flotte"> <h1 class="bcktitle ajust_title ">Rapport de flotte mensuel</h1> <form class="form_rapport_flotte" action="<?php echo urlp($_GET["arbre"]); ?> " method="post"> <input type="hidden" value="flotte03" name="template"> <input type="hidden" value="<?php echo $_POST["agence"]; ?> " name="agence"> <div> <!-- <p>Agence : <span>toutes les agences</span></p> --> <p>Mois : <span><?php echo date2month($_POST["date_jour"]); ?> </span></p> <p> <label>Date : </label> <input class="datepicker first_input" type="text" id="datepicker" name="date_jour" value="<?php echo $_POST["date_jour"]; ?> "> </p> </div> <div class="content_filt_submit"> <input class="submit_butt" type="submit" value="Valider"> </div> </form> <span class="info_rapportkm">
?> </b></font></td> </tr> <?php } // end buildfailing ?> <?php if ($testfailing) { ?> <tr> <td bgcolor="#DDDDDD" id="nob"><font size="2">Tests have been failing since <b> <?php if ($testfailingdays > 1) { $date = date2year($datefirsttestfailing) . date2month($datefirsttestfailing) . date2day($datefirsttestfailing); echo "<a href=\"index.php?project=" . urlencode($project_array["name"]) . "&date=" . $date . "\">" . $datefirsttestfailing . "</a> (" . $testfailingdays . " days)"; } else { if ($testfailingdays == 1) { echo $datefirsttestfailing . " (" . $testfailingdays . " day)"; } else { echo $datefirsttestfailing . " (today)"; } } ?> </b></font></td> </tr> <?php } // end buildfailing ?>
<?php $_POST["date_jour"] = date("d-mY", time() - 86400); //$_POST["date_jour"]="27-08-2014"; $_POST["agence"] = ""; $tabresult = exportexcel("flotte03", implodeargskey($_POST), array("Nom", "Activité", "Conduite", "Arrêt", "Distance", "Vit.max.", "Conso."), array("nomvehicule", "amplitude", "datediff", "arret", "km", "vitesse", "conso")); $html = "Ci joint le rapport de la flotte du mois " . date2month($_POST["date_jour"]); sendmailmister('', '', 'Rapport flotte mensuelle ' . date2month($_POST["date_jour"]), $html, $_SESSION["email"], '', $tabresult); //mise a jour de la date dans rapport /* $sql="update ".__racinebd__."rapport set date_envoi='".$_POST["date_jour"]."' where rapport_id=7"; query($sql); */
return; } $project = pdo_query("SELECT name FROM project WHERE id='{$projectid}'"); $project_array = pdo_fetch_array($project); $currentUTCtime = gmdate(FMT_DATETIME, $currenttime); // Find the last build corresponding to thie siteid and buildid $lastbuild = pdo_query("SELECT starttime FROM build\n WHERE siteid='{$siteid}' AND type='{$buildtype}' AND name='{$buildname}'\n AND projectid='{$projectid}' AND starttime<='{$currentUTCtime}' ORDER BY starttime DESC LIMIT 1"); if (pdo_num_rows($lastbuild) > 0) { $lastbuild_array = pdo_fetch_array($lastbuild); $datelastbuild = $lastbuild_array['starttime']; $lastsbuilddays = round(($currenttime - strtotime($datelastbuild)) / (3600 * 24)); } else { $lastsbuilddays = -1; } ?> <table width="100%" border="0"> <tr> <td bgcolor="#DDDDDD" id="nob"><font size="2"> <?php if ($lastsbuilddays == -1) { echo 'This build has never submitted.'; } elseif ($lastsbuilddays >= 0) { $date = date2year($datelastbuild) . date2month($datelastbuild) . date2day($datelastbuild); echo 'This build has not been submitting since <b><a href="index.php?project=' . urlencode($project_array['name']) . '&date=' . $date . '">' . date('M j, Y ', strtotime($datelastbuild)) . '</a> (' . $lastsbuilddays . ' days)</b>'; } ?> </font></td> </tr> </table> </html>