當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DateUtil::getDatetime_NextWeek方法代碼示例

本文整理匯總了PHP中DateUtil::getDatetime_NextWeek方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateUtil::getDatetime_NextWeek方法的具體用法?PHP DateUtil::getDatetime_NextWeek怎麽用?PHP DateUtil::getDatetime_NextWeek使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DateUtil的用法示例。


在下文中一共展示了DateUtil::getDatetime_NextWeek方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: reserva


//.........這裏部分代碼省略.........
                $finish_date = strtotime($finish_date);
                if ($finish_date < strtotime('today')) {
                    LogUtil::registerError($this->__('Finish date is minnor than actual date'));
                    System::redirect(ModUtil::url('IWbookings', 'user', 'assigna', array('sid' => $sid)));
                    return true;
                }
            }
        }


        // get nsessions from finish_date
        if ($book_end == 'date') {
            $nsessions = 0;
            $tmp_date = strtotime(date('Y-m-d', $eb));
            while ($tmp_date <= $finish_date) {
                $nsessions++;
                $tmp_date = strtotime(date('Y-m-d', $tmp_date) . ' + 1 week');
            }
        }

        $admin = true;
        if (!SecurityUtil::checkPermission('IWbookings::', '::', ACCESS_ADMIN)) {
            $admin = false;
            // Check if num sessions exceeds num weeks limit from actual date
            $maxWeeks = ModUtil::getVar('IWbookings', 'weeks');
            if ($maxWeeks != 0) {
                $factor = $nsessions - 1;
                $last = strtotime(date('Y-m-d', $eb) . ' + ' . $factor . ' weeks');
                $limit = strtotime('today + ' . $maxWeeks . ' weeks');
                $alert = false;

                while ($last > $limit) {
                    $last = strtotime(date('Y-m-d', $last) . ' -1 week');
                    $nsessions--;
                    $alert = true;
                }
                if ($alert)
                    $msg = $this->__('Bookings can only be made for the following ') . $maxWeeks . $this->__(' week(s). Haven\'t made all the requested bookings.');
            }
        }

        $bookingDates = array();
        // Generate all booking dates
        for ($i = 0; $i < $nsessions; ++$i) {
            foreach ($horaris as $h) {
                // Calculate next week
                $next = DateUtil::getDatetime_NextWeek($i, "%Y-%m-%d", $d[2], $d[1], $d[0], 12, 0, 0);
                // Per evitar canvis d'hora produits per l'horari d'estiu
                $bookingDates[] = array('s' => $next . " " . $h[t_inici][0] . ":" . $h[t_inici][1] . ":00",
                    'e' => $next . " " . $h[t_final][0] . ":" . $h[t_final][1] . ":00");
            }
        }



        // Check if the requested bookings is possible
        $reserved = array();
        foreach ($bookingDates as $bd) {
            $bookings = ModUtil::apiFunc('IWbookings', 'user', 'reservat', array('sid' => $sid,
                        'start' => $bd[s],
                        'end' => $bd[e]));
            if (count($bookings) != 0)
                $reserved[] = $bookings;
        }

        if (!count($reserved)) {
            // If all bookings are possible do it
            foreach ($bookingDates as $bd) {
                $success = ModUtil::apiFunc('IWbookings', 'user', 'reserva', array('sid' => $sid,
                            'start' => $bd[s],
                            'end' => $bd[e],
                            'user' => $user,
                            'usrgroup' => $group,
                            'reason' => $reason,
                            'nsessions' => $nsessions,
                            'nbooking' => $success,
                            'admin' => $admin));
                if (!$success) {
                    LogUtil::registerError($this->__('An error has occurred when loading the table or the form'));
                    return System::redirect(ModUtil::url('IWbookings', 'user', 'assigna', array('sid' => $sid,
                                        'date' => $cdate)));
                }
            }
            // Book receipt
            LogUtil::registerStatus("<b>[ " . $this->__('Booking receipt') . " ]</b><br />" . $this->__('Booking day: ') . ": <b> " . $bookingDate . "</b><br/>" . $this->__('Time: ') . ": <b>" . $horari
                    . "</b><br />" . $this->__('Group: ') . ": <b>" . $group . "</b><br />" . $this->__('Reason for booking') . ": <b>" . $reason . "</b><br />"
                    . $this->__('Repeat next weeks') . ": <b>" . $nsessions . "<br /><br /><b>" . $msg);
        } else {
            // Launch error message with reserved frames
            $message = $this->__('Booking failed! The following times are reserved:') . '<ul>';
            foreach ($reserved as $r) {
                $message .= '<li><b>' . date('d-m-Y', strtotime($r['0']['start'])) . $this->__('</b> from ') . date('H:i', strtotime($r['0']['start'])) . $this->__(' to ') . date('H:i', strtotime($r['0']['end'])) . '</li>';
            }
            $message .= '</ul>';
            LogUtil::registerError($message);
        }

        return System::redirect(ModUtil::url('IWbookings', 'user', 'assigna', array('sid' => $sid,
                            'date' => $cdate)));
    }
開發者ID:projectesIF,項目名稱:Sirius,代碼行數:101,代碼來源:User.php

示例2: getJumpDates

    /**
     * Calculate dates for date navigation purposes
     * @author	Josep Ferr�ndiz Farr� (jferran6@xtec.cat)
     * @args The date (a MySQL timestamp or a string)
     * @return	array. Fields: nextweek, preweek, nextmonth, prevmonth
     */
    public function getJumpDates($args) {
        $TheDate = FormUtil::getPassedValue('date', isset($args['date']) ? $args['date'] : null, 'GET');

        $result = array();
        if (!SecurityUtil::checkPermission('IWbookings::', '::', ACCESS_READ)) {
            return false;
        }

        $fields = explode('-', $TheDate);

        $result['nextweek'] = DateUtil::getDatetime_NextWeek(1, '%d-%m-%y', $fields[0], $fields[1], $fields[2]);
        $result['prevweek'] = DateUtil::getDatetime_NextWeek(-1, '%d-%m-%y', $fields[0], $fields[1], $fields[2]);
        $result['nextmonth'] = DateUtil::getDatetime_NextMonth(1, '%d-%m-%y', $fields[0], $fields[1], $fields[2]);
        $result['prevmonth'] = DateUtil::getDatetime_NextMonth(-1, '%d-%m-%y', $fields[0], $fields[1], $fields[2]);

        return $result;
    }
開發者ID:projectesIF,項目名稱:Sirius,代碼行數:23,代碼來源:User.php


注:本文中的DateUtil::getDatetime_NextWeek方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。