implementing crm with laravel calendar

Implementing CRM System With Laravel Part 12: Calendar Module

The calendar module shows a full page calendar usually used to display the tasks status with the start and end dates, we will cover this module in this part.

 

 

Series Topics:

 

The calendar module is pretty simple it just has one page that displays a calendar, in that case we use Jquery fulcalendar plugin to display the tasks or events.

create a new controller using the artisan command:

Open app/Http/Controllers/CalendarController.php and update it with this code:

The controller contains only two functions, the main function is the index() function which displays the calendar. We call another function getTaskStatusByDate() which retrieves tasks which have start and end dates.

We will consider three types of tasks:

  • Pending tasks: tasks that are not begin yet having start date greater than today.
  • Tasks in progress: tasks already working in the current time which have start and end dates between today.
  • Finished tasks: tasks which have end date passed.

If the user is super admin then we display all the tasks, else we display the tasks assigned to or created by the current user.

Then we looped over each collection saving them into a new array, why we do this because the Jquery fullcalendar expects an array of events similar to this one:

We sent this javacript code to the view:

This variables will be passed to the fullcalendar Jquery plugin.

 

Calendar View

resources/views/pages/calendar/index.blade.php

I have includes the fullcalendar stylesheet and javascript and also included the fullcalendar script that i will show in the next section

resources/views/pages/calendar/includes/event_modal.blade.php

 

Calendar Javascript

In the above code i have initialized the fullcalendar passing in the events variables that we described above. I used the fullcalendar clickEvent handler to listen for on click events then we showed a modal of the event details.

Also i added three listeners when i click any of the buttons which has class “bg-*” which toggles the display of the any event category like this one:

This code will toggle the pending events.

 

Sidebar

Update resources/views/layout/sidebar.blade.php

 

 

Continue to Part 13: Finishing

 

Share this: