A PHP Simple multi-date picker calendar.
The reason for yet another PHP Calendar is to provide a simple calendar with just enough features, but without an overhead of too many of them:
- Start the week on Sundays or Mondays (default: Sunday)
- Show other month dates (default: true)
- Can received an array of dates to circle (i.e. holidays, meetings, etc.) *
- Can received an array of dates to pre-select for processing *
- Provides a customizable legend
- Allows for i18n translations using \CorbeauPerdu\i18n\Locale
- Finally, because it uses Boostrap, it is responsive!
* Dates must be in 'YYYY-mm-dd' string format.
Requirements
- Boostrap
- jQuery: only if you use the javascript from the CalendarUsageExample.php
- \CorbeauPerdu\i18n\Locale
Other important requirements and informations
- All dates are returned and processed in 'YYYY-mm-dd' format!
- Expects to find a loadCalendar(month,year) Javascript function: use it to either reload the page passing along month and year to querystring, load the calendar using an Ajax call... As you wish!
- Expects to find a setSelectedDate(date) Javascript function: this is where you'll toggle date cell ON/OFF (by toggling class calendar_selected on the cell IDs) and where you process the clicked date!
Methods
- Object's constructor :
- \CorbeauPerdu\i18n\Locale $locale CorbeauPerdu's locale instance for translations
- bool $startWeekOnMonday Whether to start weeks on Mondays (default: start on sunday)
- bool $showOtherMonths Whether to display dates in other months at the start or end of the current month (default: true)
- bool $forceSixRows Whether to show a 6th row in the calendar, EVEN if that hole row belongs to the next month (default: false)
- string $anchor calendar href anchor to reposition page upon calendar reload (default: 'calendar')
- string $legendDateCircled Legend text for circled dates: pass along the text to load from the locale 'calendar' domain
- string $legendDateSelected Legend text for Selected dates: pass along the text to load from the locale 'calendar' domain
- $calendar->show()
- string $month for which month?
- string $year for which year?
- array $circledDates dates that are to be circled, in 'YYYY-mm-dd' string format
- array $selectedDates dates that are flagged as selected, in to be in 'YYYY-mm-dd' string format
Demos:
The calendar is loaded from getting month and year in the URL querystring:
The calendar is loaded from an Ajax call that passes along the desired month and year, hidding other month, week starts on Mondays and finally, in french: