Core  3.2
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  * @package FDL
5 */
6 /**
7  * Display input to select date interval
8  *
9  * @author Anakeen
10  * @version $Id: dateinterval.php,v 1.1 2004/02/05 15:41:40 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
17 {
18 
19  $actualyear = strftime("%Y", time());
20  $fmonth = GetHttpVars("fmonth", strftime("%m", time())); // from year
21  $fyear = GetHttpVars("fyear", $actualyear);
22  $tmonth = GetHttpVars("tmonth"); // to year
23  $tyear = GetHttpVars("tyear", $actualyear);
24 
25  for ($i = 1; $i < 13; $i++) {
26  $monthname[$i]["monthname"] = strftime("%B", $i * 3600 * 24 * 28);
27  $monthname[$i]["monthvalue"] = $i;
28  if ($i == $fmonth) $monthname[$i]["fselectmonth"] = "selected";
29  else $monthname[$i]["fselectmonth"] = "";
30  if ($i == $tmonth) $monthname[$i]["tselectmonth"] = "selected";
31  else $monthname[$i]["tselectmonth"] = "";
32  }
33 
34  for ($i = 2002; $i <= $actualyear; $i++) {
35  $year[$i]["yearvalue"] = $i;
36  if ($i == $fyear) $year[$i]["fselectyear"] = "selected";
37  else $year[$i]["fselectyear"] = "";
38  if ($i == $fyear) $year[$i]["tselectyear"] = "selected";
39  else $year[$i]["tselectyear"] = "";
40  }
41  $action->lay->SetBlockData("SELECTMONTHFROM", $monthname);
42  $action->lay->SetBlockData("SELECTMONTHTO", $monthname);
43  $action->lay->SetBlockData("SELECTYEARFROM", $year);
44  $action->lay->SetBlockData("SELECTYEARTO", $year);
45  $action->lay->Set("today", strftime("%d %B %Y", time()));
46 
47  $fdate = mktime(0, 0, 0, $fmonth, 1, $fyear);
48 
49  if ($tmonth == 0) $tdate = time(); // today
50  else $tdate = mktime(0, 0, -1, $tmonth + 1, 1, $tyear); // last day of the month
51  $action->lay->Set("period", sprintf(_("period from %s to %s") , strftime("%d %B %Y", $fdate) , strftime("%d %B %Y", $tdate)));
52 
53  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)));
54 
55  return array(
56  "fromdate" => $fdate,
57  "todate" => $tdate
58  );
59 }
60 ?>
global $action
dateinterval(&$action)
← centre documentaire © anakeen