Пример #1
0
 /**
  * @param string $json_argument_array
  * @return integer
  */
 public static function count_batches($json_argument_array)
 {
     $datetime_handler_end = new DatetimeHandler();
     $datetime_handler_end->sub_day(7);
     $datetime_handler_create = new DatetimeHandler();
     $datetime_handler_create->sub_day(30);
     return Batch_Wrapper::count_batches($datetime_handler_create->get_formatted_string("Y-m-d H:i:s"), $datetime_handler_end->get_formatted_string("Y-m-d H:i:s"));
 }
Пример #2
0
 private function work_week_view()
 {
     $today = date("j-m-Y");
     $today_datetime_handler = new DatetimeHandler($today);
     if (!$_GET['page']) {
         $date = date("W-Y");
     } else {
         $date = $_GET['page'];
     }
     $date_aray = explode("-", $date);
     $week_mktime = mktime(0, 0, 0, 1, 1, $date_aray[1]);
     $week_mktime = $week_mktime + 86400 * $date_aray[0] * 7;
     $act_day_of_week = (date("w", $week_mktime) + 6) % 7;
     $week_mktime = $week_mktime - $act_day_of_week * 86400;
     $datetime_handler = new DatetimeHandler($week_mktime);
     $datetime_handler->add_hour(5);
     $next_week_datetime_handler = clone $datetime_handler;
     $next_week_datetime_handler->add_day(7);
     $prev_week_datetime_handler = clone $datetime_handler;
     $prev_week_datetime_handler->sub_day(7);
     $week = date("W", $week_mktime);
     $year = date("Y", $week_mktime);
     $content_array = array();
     $color_count = 0;
     $day_date_array[1] = array();
     $day_date_array[2] = array();
     $day_date_array[3] = array();
     $day_date_array[4] = array();
     $day_date_array[5] = array();
     for ($i = 0; $i <= 18; $i++) {
         if ($color_count % 2) {
             $tr_class = " class='CalendarTrGrey'";
         } else {
             $tr_class = "";
         }
         $content_array[$i]['tr_class'] = $tr_class;
         if ($i == 0) {
             $content_array[$i]['head'] = true;
             $content_array[$i][0]['content'] = "";
             for ($j = 1; $j <= 5; $j++) {
                 $mktime = $datetime_handler->get_mktime();
                 $day = date("D jS M", $mktime);
                 if ($datetime_handler->get_formatted_string("Y-m-d") == $today_datetime_handler->get_formatted_string("Y-m-d")) {
                     $content_array[$i][$j]['content'] = "<span class='CalendarToday'>" . $day . "</span>";
                 } else {
                     $content_array[$i][$j]['content'] = $day;
                 }
                 $datetime_handler->add_day(1);
             }
         } else {
             $datetime_handler->sub_day(5);
             $content_array[$i]['head'] = false;
             $content_array[$i][0]['time'] = true;
             $content_array[$i][0]['content'] = $datetime_handler->get_formatted_string("H:i");
             for ($j = 1; $j <= 5; $j++) {
                 $content_array[$i][$j]['time'] = false;
                 $mktime = $datetime_handler->get_mktime();
                 $date_array = $this->mktime_has_date($mktime, $mktime + 3599);
                 if (is_array($date_array) and count($date_array >= 1)) {
                     $counter = 0;
                     foreach ($date_array as $key => $value) {
                         if (!in_array($value, $day_date_array[$j])) {
                             if ($content_array[$i][$j]['content']) {
                                 if ($this->calendar_array[$value]['link']) {
                                     $content_array[$i][$j]['content'] .= "<div class='CalendarWeekEntry'><a href='index.php?" . $this->calendar_array[$value]['link'] . "'>" . $this->calendar_array[$value]['name'] . "</a></div>";
                                 } else {
                                     $content_array[$i][$j]['content'] .= "<div class='CalendarWeekEntry'>" . $this->calendar_array[$value]['name'] . "</div>";
                                 }
                             } else {
                                 if ($this->calendar_array[$value]['link']) {
                                     $content_array[$i][$j]['content'] = "<div class='CalendarWeekEntry'><a href='index.php?" . $this->calendar_array[$value]['link'] . "'>" . $this->calendar_array[$value]['name'] . "</a></div>";
                                 } else {
                                     $content_array[$i][$j]['content'] = "<div class='CalendarWeekEntry'>" . $this->calendar_array[$value]['name'] . "</div>";
                                 }
                             }
                             array_push($day_date_array[$j], $value);
                         } else {
                             $content_array[$i][$j]['content'] = "";
                         }
                         $content_array[$i][$j][$counter]['value'] = $this->calendar_array[$value]['color'];
                         $counter++;
                     }
                 } else {
                     $content_array[$i][$j]['content'] = "";
                 }
                 $datetime_handler->add_day(1);
             }
             $datetime_handler->add_hour(1);
         }
         $color_count++;
     }
     $template = new HTMLTemplate("organiser/views/work_week.html");
     $paramquery_prev = $_GET;
     $paramquery_prev['page'] = date("W-Y", $prev_week_datetime_handler->get_mktime());
     $params_prev = http_build_query($paramquery_prev, '', '&#38;');
     $paramquery_next = $_GET;
     $paramquery_next['page'] = date("W-Y", $next_week_datetime_handler->get_mktime());
     $params_next = http_build_query($paramquery_next, '', '&#38;');
     $template->set_var("previous_params", $params_prev);
     $template->set_var("next_params", $params_next);
     $template->set_var("week", $week);
     $template->set_var("year", $year);
     $template->set_var("content_array", $content_array);
     return $template->get_string();
 }