/**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0);
     $this->assign('bookingId', $this->_id);
     $config = CRM_Core_Config::singleton();
     /**
      * [dateformatDatetime] => %B %E%f, %Y %l:%M %P
      * [dateformatFull] => %B %E%f, %Y
      * [dateformatPartial] => %B %Y
      * [dateformatYear] => %Y
      * [dateformatTime] => %l:%M %P
      */
     $this->crmDateFormat = $config->dateformatDatetime;
     //retrieve crmDateFormat
     $this->assign('dateFormat', $this->crmDateFormat);
     $days = CRM_Booking_Utils_DateTime::getDays();
     $months = CRM_Utils_Date::getFullMonthNames();
     $years = CRM_Booking_Utils_DateTime::getYears();
     $this->assign('days', $days);
     $this->assign('months', $months);
     $this->assign('years', $years);
     $config = CRM_Core_Config::singleton();
     $currencySymbols = "";
     if (!empty($config->currencySymbols)) {
         $currencySymbols = $config->currencySymbols;
     } else {
         $currencySymbols = $config->defaultCurrencySymbol;
     }
     $resourceTypes = CRM_Booking_BAO_Resource::getResourceTypes();
     $resources = array();
     foreach ($resourceTypes as $key => $type) {
         $result = CRM_Booking_BAO_Resource::getResourcesByType($key);
         $rTypekey = trim(strtolower($key . '_' . $type['label']));
         $resources[$rTypekey]['label'] = $type['label'];
         $resources[$rTypekey]['child'] = $result;
     }
     $this->assign('resources', $resources);
     $this->assign('currencySymbols', $currencySymbols);
     $config = CRM_Booking_BAO_BookingConfig::getConfig();
     $this->assign('colour', CRM_Utils_Array::value('slot_new_colour', $config));
     list($xStart, $xSize, $xStep) = CRM_Booking_Utils_DateTime::getCalendarTime();
     $this->assign('xStart', $xStart);
     $this->assign('xSize', $xSize);
     $this->assign('xStep', $xStep);
     $this->assign('timeOptions', CRM_Booking_Utils_DateTime::getTimeRange());
     if ($this->_id && $this->_action == CRM_Core_Action::UPDATE) {
         $title = CRM_Core_DAO::getFieldValue('CRM_Booking_BAO_Booking', $this->_id, 'title', 'id');
         CRM_Utils_System::setTitle(ts('Edit Booking') . " - {$title}");
     } else {
         CRM_Utils_System::setTitle(ts('New Booking'));
     }
     self::registerScripts();
 }
<?php

require_once '../../civicrm.config.php';
require_once 'CRM/Core/Config.php';
require_once 'CRM/Core/I18n.php';
require_once 'CRM/Utils/Date.php';
// assign the weekday and month names
$DN = CRM_Utils_Date::getFullWeekdayNames();
$SDN = CRM_Utils_Date::getAbbrWeekdayNames();
$MN = CRM_Utils_Date::getFullMonthNames();
$SMN = CRM_Utils_Date::getAbbrMonthNames();
// assign the strings hash
$TT['INFO'] = ts('About the calendar');
$TT['ABOUT'] = "DHTML Date/Time Selector\n(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" . ts('For latest version visit: %1', array(1 => 'http://www.dynarch.com/projects/calendar/')) . "\n" . ts('Distributed under GNU LGPL. See %1 for details.', array(1 => 'http://gnu.org/licenses/lgpl.html')) . "\n\n" . ts('Date selection:') . "\n" . ts('- use the \\xab, \\xbb buttons to select year,') . "\n" . ts('- use the \\u2039, \\u203a buttons to select month,') . "\n" . ts('- hold mouse button on any of the above buttons for faster selection.');
$TT['ABOUT_TIME'] = "\n\n" . ts('Time selection:') . "\n" . ts('- click on any of the time parts to increase it') . "\n" . ts('- or Shift-click to decrease it') . "\n" . ts('- or click and drag for faster selection.');
$holdForMenu = ts('hold for menu');
$TT['PREV_YEAR'] = ts('Prev. year') . " ({$holdForMenu})";
$TT['PREV_MONTH'] = ts('Prev. month') . " ({$holdForMenu})";
$TT['GO_TODAY'] = ts('Go Today');
$TT['NEXT_MONTH'] = ts('Next month') . " ({$holdForMenu})";
$TT['NEXT_YEAR'] = ts('Next year') . " ({$holdForMenu})";
$TT['SEL_DATE'] = ts('Select date');
$TT['DRAG_TO_MOVE'] = ts('Drag to move');
$TT['PART_TODAY'] = ' (' . ts('today') . ')';
$TT['DAY_FIRST'] = ts('Display %s first');
$TT['WEEKEND'] = '0,6';
$TT['CLOSE'] = ts('Close');
$TT['TODAY'] = ts('Today');
$TT['TIME_PART'] = ts('(Shift-)Click or drag to change value');
$TT['DEF_DATE_FORMAT'] = '%Y-%m-%d';
$TT['TT_DATE_FORMAT'] = '%a, %b %e';
Example #3
0
 /**
  * converts the any given date to default date format.
  *
  * @param array  $params     has given date-format
  * @param int    $dateType   type of date  
  * @param string $dateParam  index of params
  * @static
  */
 function convertToDefaultDate(&$params, $dateType, $dateParam)
 {
     if ($dateType == 1) {
         return;
     }
     if ($dateType == 2) {
         if ($params[$dateParam]) {
             $value = $params[$dateParam];
         }
         $year = (int) substr($value, 6, 2);
         $year = $year < 100 ? "19" . "{$year}" : $year;
         $month = (int) substr($value, 0, 2);
         $day = (int) substr($value, 3, 2);
         $month = $month < 10 ? "0" . "{$month}" : $month;
         $day = $day < 10 ? "0" . "{$day}" : $day;
         if ($params[$dateParam]) {
             $params[$dateParam] = "{$year}{$month}{$day}";
         }
     }
     if ($dateType == 4) {
         if ($params[$dateParam]) {
             $value = $params[$dateParam];
         }
         $year = (int) substr($value, 6, 4);
         $month = (int) substr($value, 0, 2);
         $day = (int) substr($value, 3, 2);
         $month = $month < 10 ? "0" . "{$month}" : $month;
         $day = $day < 10 ? "0" . "{$day}" : $day;
         if ($params[$dateParam]) {
             $params[$dateParam] = "{$year}{$month}{$day}";
         }
     }
     if ($dateType == 8) {
         if ($params[$dateParam]) {
             $value = $params[$dateParam];
         }
         $dateArray = explode(' ', $value);
         $monthInt = 0;
         $fullMonths = CRM_Utils_Date::getFullMonthNames();
         foreach ($fullMonths as $key => $val) {
             if ($dateArray[0] == $val) {
                 $monthInt = $key;
                 break;
             }
         }
         if (!$monthInt) {
             $abbrMonths = CRM_Utils_Date::getAbbrMonthNames();
             foreach ($abbrMonths as $key => $val) {
                 if ($dateArray[0] == $val) {
                     $monthInt = $key;
                     break;
                 }
             }
         }
         $year = $dateArray[2];
         $year = $year < 100 ? "19" . "{$year}" : $year;
         $day = (int) $dateArray[1];
         $month = $monthInt < 10 ? "0" . "{$monthInt}" : $monthInt;
         $day = $day < 10 ? "0" . "{$day}" : $day;
         if ($params[$dateParam]) {
             $params[$dateParam] = "{$year}{$month}{$day}";
         }
     }
     if ($dateType == 16) {
         if ($params[$dateParam]) {
             $value = $params[$dateParam];
         }
         $dateArray = explode('-', $value);
         $monthInt = 0;
         $fullMonths = CRM_Utils_Date::getFullMonthNames();
         foreach ($fullMonths as $key => $val) {
             if ($dateArray[1] == $val) {
                 $monthInt = $key;
                 break;
             }
         }
         if (!$monthInt) {
             $abbrMonths = CRM_Utils_Date::getAbbrMonthNames();
             foreach ($abbrMonths as $key => $val) {
                 if ($dateArray[1] == $val) {
                     $monthInt = $key;
                     break;
                 }
             }
         }
         $year = $dateArray[2];
         $year = $year < 100 ? "19" . "{$year}" : $year;
         $day = (int) $dateArray[0];
         $month = $monthInt < 10 ? "0" . "{$monthInt}" : $monthInt;
         $day = $day < 10 ? "0" . "{$day}" : $day;
         if ($params[$dateParam]) {
             $params[$dateParam] = "{$year}{$month}{$day}";
         }
     }
 }
Example #4
0
 /**
  * Class constructor
  * 
  * @access   public
  * @param    string  Element's name
  * @param    mixed   Label(s) for an element
  * @param    array   Options to control the element's display
  * @param    mixed   Either a typical HTML attribute string or an associative array
  */
 function HTML_QuickForm_date($elementName = null, $elementLabel = null, $options = array(), $attributes = null)
 {
     $this->_locale = array('weekdays_short' => CRM_Utils_Date::getAbbrWeekdayNames(), 'weekdays_long' => CRM_Utils_Date::getFullWeekdayNames(), 'months_short' => CRM_Utils_Date::getAbbrMonthNames(), 'months_long' => CRM_Utils_Date::getFullMonthNames());
     $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes);
     $this->_persistantFreeze = true;
     $this->_appendName = true;
     $this->_type = 'date';
     // set the options, do not bother setting bogus ones
     if (is_array($options)) {
         foreach ($options as $name => $value) {
             if (isset($this->_options[$name])) {
                 if (is_array($value)) {
                     $this->_options[$name] = @array_merge($this->_options[$name], $value);
                 } else {
                     $this->_options[$name] = $value;
                 }
             }
         }
     }
 }