Split check_report_dates() into shared function check_dates().
[readifood.git] / lib / report.php
index 999bbc5..aa9e6e5 100644 (file)
     end_form();
   }
 
-  function check_report_dates($from, $to) {
-    list($y, $m, $d) = explode('-', $from);
-    if (! checkdate($m, $d, $y)) {
-      echo "<p>Invalid report start date!</p>\n";
-      return false;
-    }
-    $start = mktime(0, 0, 0, $m, $d, $y);
-
-    list($y, $m, $d) = explode('-', $to);
-    if (! checkdate($m, $d, $y)) {
-      echo "<p>Invalid report end date!</p>\n";
-      return false;
-    }
-    $end = mktime(0, 0, 0, $m, $d, $y);
-
-    if ($end < $start) {
-      echo "<p>Report end date is earlier than start date!</p>\n";
-      return false;
-    }
-
-    return true;
-  }
-
   function show_order_report($from, &$order_state_ids) {
     echo "<h3>Orders by week</h3>\n";
 
   }
 
   function show_reports($from, $to) {
-    if (! check_report_dates($from, $to)) return;
+    if (! check_dates('report', $from, $to)) return;
 
     echo "<p>Showing reports for the period <strong>$from</strong> to <strong>$to</strong>.</p>\n";