phpScheduleIt
June 18, 2013, 03:54:25 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: phpScheduleIt 2.4.2 has been released!
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: One Day Only View in Bookings - Day Titles Hyperlink to A Bookings One Day View  (Read 3156 times)
phpwhizkid
Newbie
*

Karma: 0
Posts: 8


« on: August 27, 2008, 02:21:33 PM »

If you ever wanted to be able to click on the days in the Bookings part of the scheduler to pull up that one day by clicking on the date, say Monday August 5, 2008 and having it show that one day only and allow you to make reservations from there, then I suggest using this modification.  Also, with one tweak you can use this to display as many days as you want, just make $this->viewone = '1';  (which is found in step Cool to be 2,3,4,5, 10, etc....

Please note that is quite long and requires a bit of programming knowledge.  So here goes:

1.  Copy schedule.php and rename the new one schedule_1day.php

2.  Copy schedule.template.php and rename the new one schedule.template_1day.php

3.  Copy Schedule.class.php and rename the new one Schedule.class_1day.php

*** Please keep the new copies in the same folder as their original ones.

4.  In schedule_1day.php change the following lines:

* Include scheduler-specific output functions
*/
include_once('lib/Schedule.class.php');


to

* Include scheduler-specific output functions
*/
include_once('lib/Schedule.class_1day.php');
« Last Edit: August 27, 2008, 03:24:36 PM by phpwhizkid » Logged
phpwhizkid
Newbie
*

Karma: 0
Posts: 8


« Reply #1 on: August 27, 2008, 02:28:30 PM »

5.  Go to config -> constants.php and add the following lines:

define('DAY_URL', 'http://www.yoursite/scheduler/schedule_1day.php');
define('DAY_URL_SCHEDULE', 'http://www.yoursite/scheduler/schedule.php');


*** Change these values to the direct path of your site and these pages

6.  Go to lang->en_US.lang.php and scroll down until you see:

/***
  DATE FORMATTING
  All of the date formatting must use the PHP strftime() syntax
  You can include any text/HTML formatting in the translation
***/

Add the following lines:

// Date for the scheduler_1day fix
$dates['oneday'] = '%m-%d-%Y';
Logged
phpwhizkid
Newbie
*

Karma: 0
Posts: 8


« Reply #2 on: August 27, 2008, 02:50:46 PM »

7.  Make the following changes to schedule.template_1day.php

Line 81, Change:   function start_day_table($displayDate, $hour_header, $isCurrentDate) {

to:  function start_day_table($displayDate, $hour_header, $isCurrentDate, $date,  $scheduleid) {


Line 88, Change:          <td rowspan="2" width="15%" class="<?php echo $isCurrentDate ? 'scheduleDateCurrent' : 'scheduleDate' ?>"><?php echo $displayDate ?></td>

to: <td rowspan="2" class="<?php echo $isCurrentDate ? 'scheduleDateCurrent' : 'scheduleDate' ?>"><?php echo "<a href=\"".DAY_URL."?date=$date&amp;scheduleid=$scheduleid\" target=\"_parent\"\">$displayDate</a>"; ?></td>


Lines 345-355 Change all instances of <?php $link->doLink($_SERVER['PHP_SELF'] .

to: <?php $link->doLink("".DAY_URL_SCHEDULE."" .
***Should be about 5 changes to this
« Last Edit: August 27, 2008, 04:34:01 PM by phpwhizkid » Logged
phpwhizkid
Newbie
*

Karma: 0
Posts: 8


« Reply #3 on: August 27, 2008, 03:05:46 PM »

8.  Go to schedule.class_1day.php and change the following:

Line 23, Change: include_once($basedir . '/templates/schedule.template.php');

to: include_once($basedir . '/templates/schedule.template_1day.php');

Line 64, after  $this->viewdays = $data['viewdays'];

insert this line:  $this->viewone = '1'; 
***this will make the calendar display only one day, or you can change it for as many days as you want

Line 117, Change: start_day_table($this->get_display_date(), $hour_header, $this->_date['now'] == $this->_date['current']);    // Start the table for this day

to: start_day_table($this->get_display_date(), $hour_header, $this->_date['now'] == $this->_date['current'], $this->get_one_day_date(), $this->$scheduleid);    // Start the table for this day
***Note, we added a new function get_one_day_date, we will add this on later lines

Line 280, after function get_display_date() skip a few lines and insert this additional function:
              /**
   *Used in the schedule_1day fix
   */
    function get_one_day_date() {
      return Time::formatOneDate($this->_date['current']);
                }


Line 331, Change: $dv['lastDayTs'] = mktime(0,0,0, $dv['month'], ($dv['day'] + $this->viewdays - 1), $dv['year']);

to: $dv['lastDayTs'] = mktime(0,0,0, $dv['month'], ($dv['day'] + $this->viewone), $dv['year']);
« Last Edit: August 27, 2008, 04:34:40 PM by phpwhizkid » Logged
phpwhizkid
Newbie
*

Karma: 0
Posts: 8


« Reply #4 on: August 27, 2008, 03:08:06 PM »

9.  Go to lib->Time.class.php and add the following function:

   /**
   * Formats the time for the scheduler_1day fix
   * Formats a timezone-adjusted timestamp for a reservation with this date and time
   * @param int $res_ts the reservation start_date or end_date timestamp
   * @param int $res_time the reservation starttime or endtime as minutes
   * @param string $format the PHP format string for the resulting date
   * @return the adjusted and formatted timestamp for the reservation
   */
   function formatOneDate($res_ts, $res_time, $format = '', $format_key = '') {
      global $conf;
      global $dates;

      $start_ts = $res_ts + (60 * $res_time);
      $res_ts = Time::getAdjustedTime($start_ts);

      if (empty($format_key)) {
         $format_key = 'oneday';
      }

      return translate_date($format_key, $res_ts);
   }
Logged
phpwhizkid
Newbie
*

Karma: 0
Posts: 8


« Reply #5 on: August 27, 2008, 03:11:44 PM »

10.  Go to schedule.tempate.php

Line 81, Change:   [color=green}function start_day_table($displayDate, $hour_header, $isCurrentDate) { [/color]

to:  function start_day_table($displayDate, $hour_header, $isCurrentDate, $date, $scheduleid) {

Line 88, Change:          <td rowspan="2" width="15%" class="<?php echo $isCurrentDate ? 'scheduleDateCurrent' : 'scheduleDate' ?>"><?php echo $displayDate ?></td>

to: <td rowspan="2" class="<?php echo $isCurrentDate ? 'scheduleDateCurrent' : 'scheduleDate' ?>"><?php echo "<a href=\"".DAY_URL."?date=$date&amp;scheduleid=$scheduleid\" target=\"_parent\"\">$displayDate</a>"; ?></td>
« Last Edit: August 27, 2008, 04:35:51 PM by phpwhizkid » Logged
phpwhizkid
Newbie
*

Karma: 0
Posts: 8


« Reply #6 on: August 27, 2008, 03:15:20 PM »

11.  Go to schedule.class.php

Line 117, Change: start_day_table($this->get_display_date(), $hour_header, $this->_date['now'] == $this->_date['current']);    // Start the table for this day

to: start_day_table($this->get_display_date(), $hour_header, $this->_date['now'] == $this->_date['current'], $this->get_one_day_date(), $this->scheduleid);    // Start the table for this day
***Note, we added a new function get_one_day_date, we will add this on later lines

Line 280, after function get_display_date() skip a few lines and insert this additional function:
              /**
   *Used in the schedule_1day fix
   */
    function get_one_day_date() {
      return Time::formatOneDate($this->_date['current']);
                }
« Last Edit: August 27, 2008, 04:35:06 PM by phpwhizkid » Logged
phpwhizkid
Newbie
*

Karma: 0
Posts: 8


« Reply #7 on: August 27, 2008, 03:23:14 PM »

12.  Enjoy your new feature and I hope Nick incorporates it into his next release.  Phpwhizkid out.

Also, I know there is some more elegant ways for this solution, and I don't like hard coding the urls, but this took me only a couple of hours to do and I haven't gone back to refine it.  So if you have better suggestions then just post them here.  I won't feel bad Smiley
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2006-2007, Simple Machines Valid XHTML 1.0! Valid CSS!