Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
dateinterval.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * Display input to select date interval
9  *
10  * @author Anakeen 2000
11  * @version $Id: dateinterval.php,v 1.1 2004/02/05 15:41:40 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage
15  */
16 /**
17  */
19 {
20 
21  $actualyear = strftime("%Y", time());
22  $fmonth = GetHttpVars("fmonth", strftime("%m", time())); // from year
23  $fyear = GetHttpVars("fyear", $actualyear);
24  $tmonth = GetHttpVars("tmonth"); // to year
25  $tyear = GetHttpVars("tyear", $actualyear);
26 
27  for ($i = 1; $i < 13; $i++) {
28  $monthname[$i]["monthname"] = strftime("%B", $i * 3600 * 24 * 28);
29  $monthname[$i]["monthvalue"] = $i;
30  if ($i == $fmonth) $monthname[$i]["fselectmonth"] = "selected";
31  else $monthname[$i]["fselectmonth"] = "";
32  if ($i == $tmonth) $monthname[$i]["tselectmonth"] = "selected";
33  else $monthname[$i]["tselectmonth"] = "";
34  }
35 
36  for ($i = 2002; $i <= $actualyear; $i++) {
37  $year[$i]["yearvalue"] = $i;
38  if ($i == $fyear) $year[$i]["fselectyear"] = "selected";
39  else $year[$i]["fselectyear"] = "";
40  if ($i == $fyear) $year[$i]["tselectyear"] = "selected";
41  else $year[$i]["tselectyear"] = "";
42  }
43  $action->lay->SetBlockData("SELECTMONTHFROM", $monthname);
44  $action->lay->SetBlockData("SELECTMONTHTO", $monthname);
45  $action->lay->SetBlockData("SELECTYEARFROM", $year);
46  $action->lay->SetBlockData("SELECTYEARTO", $year);
47  $action->lay->Set("today", strftime("%d %B %Y", time()));
48 
49  $fdate = mktime(0, 0, 0, $fmonth, 1, $fyear);
50 
51  if ($tmonth == 0) $tdate = time(); // today
52  else $tdate = mktime(0, 0, -1, $tmonth + 1, 1, $tyear); // last day of the month
53  $action->lay->Set("period", sprintf(_("period from %s to %s") , strftime("%d %B %Y", $fdate) , strftime("%d %B %Y", $tdate)));
54 
55  if ($tdate < $fdate) $action->ExitError(sprintf(_("the end date (%s) is before the begin date (%s)") , strftime("%d %B %Y %T", $tdate) , strftime("%d %B %Y %T", $fdate)));
56 
57  return array(
58  "fromdate" => $fdate,
59  "todate" => $tdate
60  );
61 }
62 ?>
← centre documentaire © anakeen - published under CC License - Dynacase