当前位置: 首页>>代码示例>>PHP>>正文


PHP Toolbox::getDaysOfWeekArray方法代码示例

本文整理汇总了PHP中Toolbox::getDaysOfWeekArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Toolbox::getDaysOfWeekArray方法的具体用法?PHP Toolbox::getDaysOfWeekArray怎么用?PHP Toolbox::getDaysOfWeekArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Toolbox的用法示例。


在下文中一共展示了Toolbox::getDaysOfWeekArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: showPlanning

 /**
  * Show the planning
  *
  * Function name change since version 0.84 show() => showPlanning
  *
  * @param $who             ID of the user (0 = undefined)
  * @param $who_group       ID of the group of users (0 = undefined)
  * @param $when            Date of the planning to display
  * @param $type            type of planning to display (day, week, month)
  * @param $limititemtype   itemtype limit display to this itemtype (default '')
  *
  * @return Nothing (display function)
  **/
 static function showPlanning($who, $who_group, $when, $type, $limititemtype = '')
 {
     global $CFG_GLPI, $DB;
     if (!Session::haveRight("show_planning", "1") && !Session::haveRight("show_all_planning", "1")) {
         return false;
     }
     // Define some constants
     $date = explode("-", $when);
     $time = mktime(0, 0, 0, $date[1], $date[2], $date[0]);
     $daysinweek = Toolbox::getDaysOfWeekArray();
     // Check bisextile years
     list($current_year, $current_month, $current_day) = explode("-", $when);
     if ($current_year % 4 == 0) {
         $feb = 29;
     } else {
         $feb = 28;
     }
     $nb_days = array(31, $feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
     // Begin of the month
     $begin_month_day = strftime("%w", mktime(0, 0, 0, $current_month, 1, $current_year));
     if ($begin_month_day == 0) {
         $begin_month_day = 7;
     }
     $end_month_day = strftime("%w", mktime(0, 0, 0, $current_month, $nb_days[$current_month - 1], $current_year));
     // Day of the week
     $dayofweek = date("w", $time);
     // Cas du dimanche
     if ($dayofweek == 0) {
         $dayofweek = 7;
     }
     // Get begin and duration
     $begin = 0;
     $end = 0;
     switch ($type) {
         case "month":
             $begin = strtotime($current_year . "-" . $current_month . "-01 00:00:00");
             $end = $begin + DAY_TIMESTAMP * $nb_days[$current_month - 1];
             break;
         case "week":
             $tbegin = $begin = $time + mktime(0, 0, 0, 0, 1, 0) - mktime(0, 0, 0, 0, $dayofweek, 0);
             $end = $begin + WEEK_TIMESTAMP;
             break;
         case "day":
             $add = "";
             $begin = $time;
             $end = $begin + DAY_TIMESTAMP;
             break;
     }
     $begin = date("Y-m-d H:i:s", $begin);
     $end = date("Y-m-d H:i:s", $end);
     // Print Headers
     echo "<div class='center'><table class='tab_cadre_fixe'>";
     // Print Headers
     echo "<tr class='tab_bg_1'>";
     switch ($type) {
         case "month":
             for ($i = 1; $i <= 7; $i++) {
                 echo "<th width='12%'>" . $daysinweek[$i % 7] . "</th>";
             }
             break;
         case "week":
             for ($i = 1; $i <= 7; $i++, $tbegin += DAY_TIMESTAMP) {
                 echo "<th width='12%'>" . $daysinweek[$i % 7] . " " . date('d', $tbegin) . "</th>";
             }
             break;
         case "day":
             echo "<th width='12%'>" . $daysinweek[$dayofweek % 7] . "</th>";
             break;
     }
     echo "</tr>\n";
     $params = array('who' => $who, 'who_group' => $who_group, 'begin' => $begin, 'end' => $end);
     $interv = array();
     if (empty($limititemtype)) {
         foreach ($CFG_GLPI['planning_types'] as $itemtype) {
             $interv = array_merge($interv, $itemtype::populatePlanning($params));
         }
     } else {
         $interv = $limititemtype::populatePlanning($params);
     }
     // Display Items
     $tmp = explode(":", $CFG_GLPI["planning_begin"]);
     $hour_begin = $tmp[0];
     $tmp = explode(":", $CFG_GLPI["planning_end"]);
     $hour_end = $tmp[0];
     if ($tmp[1] > 0) {
         $hour_end++;
     }
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:planning.class.php

示例2: showForCalendar

 /**
  * Show segments of a calendar
  *
  * @param $calendar Calendar object
  **/
 static function showForCalendar(Calendar $calendar)
 {
     global $DB, $CFG_GLPI;
     $ID = $calendar->getField('id');
     if (!$calendar->can($ID, READ)) {
         return false;
     }
     $canedit = $calendar->can($ID, UPDATE);
     $rand = mt_rand();
     $query = "SELECT *\n                FROM `glpi_calendarsegments`\n                WHERE `calendars_id` = '{$ID}'\n                ORDER BY `day`, `begin`, `end`";
     $result = $DB->query($query);
     $numrows = $DB->numrows($result);
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='calendarsegment_form{$rand}' id='calendarsegment_form{$rand}' method='post'\n                action='";
         echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='7'>" . __('Add a schedule') . "</tr>";
         echo "<tr class='tab_bg_2'><td class='center'>" . __('Day') . "</td><td>";
         echo "<input type='hidden' name='calendars_id' value='{$ID}'>";
         Dropdown::showFromArray('day', Toolbox::getDaysOfWeekArray());
         echo "</td><td class='center'>" . __('Start') . '</td><td>';
         Dropdown::showHours("begin", array('value' => date('H') . ":00"));
         echo "</td><td class='center'>" . __('End') . '</td><td>';
         Dropdown::showHours("end", array('value' => date('H') + 1 . ":00"));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $numrows) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr>";
     if ($canedit && $numrows) {
         echo "<th width='10'>";
         Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
         echo "</th>";
     }
     echo "<th>" . __('Day') . "</th>";
     echo "<th>" . __('Start') . "</th>";
     echo "<th>" . __('End') . "</th>";
     echo "</tr>";
     $daysofweek = Toolbox::getDaysOfWeekArray();
     if ($numrows) {
         while ($data = $DB->fetch_assoc($result)) {
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
                 echo "</td>";
             }
             echo "<td>";
             echo $daysofweek[$data['day']];
             echo "</td>";
             echo "<td>" . $data["begin"] . "</td>";
             echo "<td>" . $data["end"] . "</td>";
         }
         echo "</tr>";
     }
     echo "</table>";
     if ($canedit && $numrows) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
开发者ID:kipman,项目名称:glpi,代码行数:79,代码来源:calendarsegment.class.php

示例3: showTimeSlot

 /**
  * @todo This must be moved in Timeslot class since a Task class is linked to a Timeslot and not
  * directly to a TimeslotEntry. The Timeslot class must be the entry point of any other class.
  * -- Kevin 'kiniou' Roy
  */
 function showTimeSlot($timeslots_id)
 {
     echo "<div id='chart'></div>";
     echo "<div id='startperiod'></div>";
     echo "<div id='stopperiod'></div>";
     $daysofweek = Toolbox::getDaysOfWeekArray();
     $daysofweek[7] = $daysofweek[0];
     unset($daysofweek[0]);
     $dates = array($daysofweek[1] => array(), $daysofweek[2] => array(), $daysofweek[3] => array(), $daysofweek[4] => array(), $daysofweek[5] => array(), $daysofweek[6] => array(), $daysofweek[7] => array());
     for ($day = 1; $day <= 7; $day++) {
         $dbentries = getAllDatasFromTable('glpi_plugin_fusioninventory_timeslotentries', "`plugin_fusioninventory_timeslots_id`='" . $timeslots_id . "'\n                            AND `day`='" . $day . "'", '', '`begin` ASC');
         foreach ($dbentries as $entries) {
             $dates[$daysofweek[$day]][] = array('start' => $entries['begin'], 'end' => $entries['end']);
         }
     }
     echo '<script>timeslot(\'' . json_encode($dates) . '\')</script>';
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:22,代码来源:timeslotentry.class.php


注:本文中的Toolbox::getDaysOfWeekArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。