Jump to content

1st day of calendar


popopa

Recommended Posts

Hello!i have recently bought licence of your product from your reseller whmcs.com.ua and think that you able to do something to fix my issue too because whmcs.com.ua sent me to this forum arguing that this issue is not in their competence

 

 

So, i am living in Europe and i need, as it should be, set the begining of calendar at monday instead of Sunday.

 

By the way, my resseler just gave me that link fullcalendar.io/docs/display/firstDay/ but unfortunatelly this had not been helped me

 

So, dear support, can you assist me with this issue? I am sure, that this issue will be usefull not just for me

Link to comment
Share on other sites

So, i am living in Europe and i need, as it should be, set the beginning of calendar at Monday instead of Sunday.

there are two calendars within WHMCS - a calendar widget on the Admin Summary page, and the full calendar (utilities -> calendar) - if you want them both to use Monday as the start of the week, then you'll have to change them both separately.

 

Full Calendar

 

for v5.3, open the following file from your whmcs installation: /includes/jscript/fullcalendar.min.js

 

in there, you will find the start of the week setting (it only occurs once, so you should find it by searching):

 

firstDay:0

change that to...

 

firstDay:1

the start of the week should now be changed from Sunday (day 0) to Monday (day 1).

 

note: looking at the v6 beta 2, it seems that this setting is no longer there by default - however, you can easily add it to the script... open the file at /assets/js/fullcalendar.min.js and find the following entry...

 

header:{left:"title",center:"",right:"today prev,next"},weekends:!0

change it to...

 

header:{left:"title",center:"",right:"today prev,next"},firstDay:1,weekends:!0

 

Calendar Widget

 

the quick way to do this would be to just replace the existing code within /modules/widgets/calendar.php - but it would probably be overwritten by a future WHMCS update.

 

therefore, it it probably easier to create a new file, call it calendar_monday.php and put it in the /modules/widgets folder.

 

http://docs.whmcs.com/Widgets

 

<?php

if (!defined("WHMCS"))
   die("This file cannot be accessed directly");

function widget_calendar_monday($vars) {
   global $whmcs,$_ADMINLANG;

   if ($whmcs->get_req_var('getcalendarevents')) {
       $day = $whmcs->get_req_var('day');
       if (!$day) $day = date("d");
       echo '<div class="title">';
       if ($day==date("d")) echo 'Today, '.date("jS F Y",mktime(0,0,0,date("m"),$day,date("Y")));
       elseif ($day==date("d")-1) echo 'Yesterday, '.date("jS F Y",mktime(0,0,0,date("m"),$day,date("Y")));
       elseif ($day==date("d")+1) echo 'Tomorrow, '.date("jS F Y",mktime(0,0,0,date("m"),$day,date("Y")));
       else echo date("l, jS F Y",mktime(0,0,0,date("m"),$day,date("Y")));
       echo '</div>';
       $numproducts = get_query_val("tblhosting","COUNT(id)","domainstatus IN ('Active','Suspended') AND nextduedate='".date("Y-m-").(int)$day."'");
       $numaddons = get_query_val("tblhostingaddons","COUNT(id)","status IN ('Active','Suspended') AND nextduedate='".date("Y-m-").(int)$day."'");
       $numdomains = get_query_val("tbldomains","COUNT(id)","status IN ('Active') AND nextduedate='".date("Y-m-").(int)$day."'");
       $numtodoitems = get_query_val("tbltodolist","COUNT(id)","duedate='".date("Y-m-d",mktime(0,0,0,date("m"),$day,date("Y")))."'");
       $numevents = get_query_val("tblcalendar","COUNT(id)","start>='".mktime(0,0,0,date("m"),$day,date("Y"))."' AND start<'".mktime(0,0,0,date("m"),$day+1,date("Y"))."'");
       if ($numproducts==0 && $numaddons==0 && $numdomains==0 && $numtodoitems==0 && $numevents==0) echo '<div>No Events Scheduled</div>';
       else echo '<div>'.$numproducts.' Products/Services Due to Renew</div><div>'.$numaddons.' Addons Due to Renew</div><div>'.$numdomains.' Domains Due to Renew</div><div>'.$numtodoitems.' To-Do Items Due</div><div>'.$numevents.' Events Scheduled</div>';
       echo '<div style="padding-top:10px;"><a href="calendar.php"><img src="images/icons/add.png" align="top" /> Add New Event</a></div>';
       exit;
   }

   $jscode = 'function loadCalEvents(day) {
   $.post("index.php", { getcalendarevents: 1, day: day },
   function(data){
       jQuery("#eventslist").html(data);
   });
}';

   $jquerycode = 'loadCalEvents();';

   $title = "Calendar (Monday)";

   $content = '<style>
div#calendarwidget div.calendar { float: left; width: 265px; padding: 0 0 0 20px; }
div#calendarwidget div.eventslist { background-color: #fff; padding: 15px 0 0 0; height: 145px; overflow: auto; }
div#calendarwidget div.eventslist div.title { padding: 0 0 12px 0; font-family: Sans-Serif; font-size: 18px; }
div#calendarwidget table.calendar    { width: 240px; border-left:1px solid #ccc; }
div#calendarwidget td.calendar-day  { height:25px; font-size:11px; position:relative; }
div#calendarwidget div.calendar-day { height:25px; }
div#calendarwidget td.calendar-day:hover  { background:#eceff5; }
div#calendarwidget td.calendar-day-np  { background:#eee; height:25px; color: #fff; }
div#calendarwidget div.calendar-day-np { height:25px; }
div#calendarwidget td.calendar-day-head { background:#eee; font-weight:bold; text-align:center; width:14%; padding:5px; border-bottom:1px solid #ccc; border-top:1px solid #ccc; border-right:1px solid #ccc; }
div#calendarwidget td.calendar-day-today { background:#2165CB; }
div#calendarwidget td.calendar-day-today a { color: #fff; }
div#calendarwidget td.calendar-day-events { background:#D9F273; }
div#calendarwidget a.day-number    { display: block; color: #000; font-size: 13px; padding:0; float:right; margin: 0; width:100%; text-align:center; }
div#calendarwidget td.calendar-day, td.calendar-day-np { width:14%; padding:0; border-bottom:1px solid #ccc; border-right:1px solid #ccc; }
</style>
';

$headings = array('M','T','W','T','F','S','S');

$calendar = '
<div id="calendarwidget">
   <div class="calendar">
       <table cellpadding="0" cellspacing="0" class="calendar">
           <tr class="calendar-row"><td class="calendar-day-head">'.implode('</td><td class="calendar-day-head">',$headings).'</td></tr>
';

$month = date("m");
$year = date("Y");
$running_day = date('N',mktime(0,0,0,$month,1,$year));
$days_in_month = date('t',mktime(0,0,0,$month,1,$year));
$days_in_this_week = 1;
$day_counter = 0;
$dates_array = array();

$calendar.= '<tr class="calendar-row">';

for($x = 1; $x < $running_day; $x++){
   $calendar.= '<td class="calendar-day-np"> </td>';
   $days_in_this_week++;
}

for($list_day = 1; $list_day <= $days_in_month; $list_day++){
   $events = false;
   $calendar.= '<td class="calendar-day'.(($list_day==date("d"))?' calendar-day-today'($events)?' calendar-day-events':'')).'"><a href="#" class="day-number" onclick="loadCalEvents(\''.$list_day.'\');return false">'.$list_day.'</a></td>';
   if($running_day == 7){
     $calendar.= '</tr>';
     if(($day_counter+1) != $days_in_month){
       $calendar.= '<tr class="calendar-row">';
     }
     $running_day = 0;
     $days_in_this_week = 0;
   }
   $days_in_this_week++; $running_day++; $day_counter++;
}

 if($days_in_this_week < :
   for($x = 1; $x <= (8 - $days_in_this_week); $x++):
     $calendar.= '<td class="calendar-day-np"> </td>';
   endfor;
 endif;

$calendar.= '</tr>
       </table>
   </div>
   <div class="eventslist" id="eventslist"></div>
</div>';

   return array('title'=>$title,'content'=>$content.$calendar,'jscode'=>$jscode,'jquerycode'=>$jquerycode);

}

add_hook("AdminHomeWidgets",1,"widget_calendar_monday");

?>

 

you will need to enable the widget for each Administratinve user who wants to use it - details of how to do that are found in the thread below...

 

http://docs.whmcs.com/Widgets#Granting.2FRestricting_Access_to_Widgets

 

the above widget will work with v5.3 and currently works with v6 beta 2.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated