Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: first day of Week, change to Monday

  1. #1
    erol is offline Junior Member
    Join Date
    Aug 2006
    Posts
    4

    Default first day of Week, change to Monday

    hello,
    I don't know if this is the rigt forum for this question , but i have not found a forum about the callendar funktion.
    Can someone tell me how i can change the "first day of week" to Monday ??
    thanx

  2. #2
    kboughanem is offline Sugar Community Member
    Join Date
    Mar 2006
    Posts
    83

  3. #3
    erol is offline Junior Member
    Join Date
    Aug 2006
    Posts
    4

    Default Re: first day of Week, change to Monday

    thanks a lot
    i will try to understand this.

  4. #4
    erol is offline Junior Member
    Join Date
    Aug 2006
    Posts
    4

    Default Re: first day of Week, change to Monday

    sorry but it doesn't work.
    there are only 2 parts where i have to change something, i have done this but it doesn't work.

  5. #5
    Superman's Avatar
    Superman is offline Sugar Community Member
    Join Date
    Oct 2005
    Location
    Kazakhstan
    Posts
    880

    Default Re: first day of Week, change to Monday

    That would work for Month view.
    Last edited by Superman; 2006-11-16 at 04:31 PM.
    Farkhad Rakhimzhanov
    E-mail: farkhad@gmail.com

    SuperTimesheet — timesheet tool for SugarCRM.

  6. #6
    simple is offline Sugar Community Member
    Join Date
    Jul 2005
    Posts
    259

    Default Re: first day of Week, change to Monday

    To change it in week and shared view, you have to edit modules/Calendar/Calendar.php

    original version 4.5.0f pro, line 186:

    Code:
            else if ( $this->view == 'week' || $this->view == 'shared')
            {
                $days_in_week = 7;
    
                for($i=0;$i<$days_in_week;$i++)
                {
                    $slice = new Slice('day',$this->date_time->get_day_by_index_this_week($i));
                    $this->slice_hash[$slice->start_time->get_mysql_date()] = $slice;
                    array_push($this->slices_arr,  $slice->start_time->get_mysql_date());
                }
            }
    Changed to:
    Code:
            else if ( $this->view == 'week' || $this->view == 'shared')
            {
                $days_in_week = 7;
    
                // changed by simple
                for($i=1;$i<$days_in_week;$i++)
                {
                    $slice = new Slice('day',$this->date_time->get_day_by_index_this_week($i));
                    $this->slice_hash[$slice->start_time->get_mysql_date()] = $slice;
                    array_push($this->slices_arr,  $slice->start_time->get_mysql_date());
                }
                // added by simple
                $slice = new Slice('day',$this->date_time->get_first_day_of_next_week());
                $this->slice_hash[$slice->start_time->get_mysql_date()] = $slice;
                array_push($this->slices_arr,  $slice->start_time->get_mysql_date());
            }
    Cheers Pascal
    Simplicity GmbH

  7. #7
    Superman's Avatar
    Superman is offline Sugar Community Member
    Join Date
    Oct 2005
    Location
    Kazakhstan
    Posts
    880

    Default Re: first day of Week, change to Monday

    Tried Simple's solution in SugarOS 4.0.0 and it doesnt work.

    For SugarOS 4.0.0 I did following steps:

    1. modules/Calendar/templates/templates_calendar.php:

    PHP Code:
    ...
    if (
    $view == 'week' || $view == 'shared') {
     
    //$first_day = $date_time->get_day_by_index_this_week(0);
     //$last_day = $date_time->get_day_by_index_this_week(6);
     
     // begin farkhad
     
    $first_day $date_time->get_day_by_index_this_week(1);
     
    $last_day $date_time->get_day_by_index_this_week(7);
     
    // end farkhad
    ... 
    2. modules/Calendar/Calendar.php:

    PHP Code:
    ...
    $first_day_of_month $this->date_time->get_day_by_index_this_month(0);
    $num_of_prev_days $first_day_of_month->day_of_week;
    // do 42 slices (6x7 grid)

    // begin farkhad
    if ($num_of_prev_days == 0$num_of_prev_days 7;
    // end farkhad

    //for($i=0;$i < 42;$i++)
    // begin farkhad
    for($i=1;$i 43;$i++)
    // end farkhad
    {
     
    $slice = new Slice('day',$this->date_time->get_day_by_index_this_month($i-$num_of_prev_days));
    ... 
    3. modules/Calendar/DateTime.php:

    PHP Code:
    ...
    function 
    get_first_day_of_next_week()
    {
     
    //$first_day = $this->get_day_by_index_this_week(0);
     // begin farkhad
     
    $first_day $this->get_day_by_index_this_week(1);
     
    // end farkhad
     
    ... 
    PHP Code:
    ...
    function 
    get_first_day_of_last_week()
    {
     
    //$first_day = $this->get_day_by_index_this_week(0);
     // begin farkhad
     
    $first_day $this->get_day_by_index_this_week(1);
     
    // end farkhad
    ... 
    PHP Code:
    ...
    function 
    get_day_by_index_this_week($day_index)
    {
     
    $arr = array();
     
     
    //if ( $day_index < 0 || $day_index > 6  )
     // begin farkhad
     
    if ( $day_index || $day_index 7  )
     
    // end farkhad
    ... 
    4. jscalendar/calendar-setup_3.js:

    PHP Code:
    //param_default("firstDay",       0); // 0 to "Sunday"
    // begin farkhad
    param_default("firstDay",       1); // 1 to "Monday"
    // end farkhad 
    Farkhad Rakhimzhanov
    E-mail: farkhad@gmail.com

    SuperTimesheet — timesheet tool for SugarCRM.

  8. #8
    malcolmh's Avatar
    malcolmh is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Aug 2004
    Posts
    1,712

    Default Re: first day of Week, change to Monday

    Hi,

    This almost works (tried it on 4.5) . On the week and shared view I get the message "day is outside of week range", the value being passed it still 0 for some reason. Everywhere else it looks good (tried solution from Superman)
    Last edited by malcolmh; 2006-11-17 at 04:03 PM.
    Cheers Malcolm

    Genius4U Limited - Ingenious simple IT solutions for you / Genial einfache IT Lösungen für Sie
    http://www.genius4u.com or http://www.genius4u.de

  9. #9
    longreach Guest

    Default Re: first day of Week, change to Monday

    Judging by his image - is our superhero conflicted?

  10. #10
    malcolmh's Avatar
    malcolmh is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Aug 2004
    Posts
    1,712

    Default Re: first day of Week, change to Monday

    Quote Originally Posted by malcolmh
    Hi,

    This almost works (tried it on 4.5) . On the week and shared view I get the message "day is outside of week range", the value being passed it still 0 for some reason. Everywhere else it looks good (tried solution from Superman)
    I also added the modifications from simplicity, now the week and shared view work as well, great work guys!
    Cheers Malcolm

    Genius4U Limited - Ingenious simple IT solutions for you / Genial einfache IT Lösungen für Sie
    http://www.genius4u.com or http://www.genius4u.de

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •