mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-10 10:02:33 +03:00
Various fixes in the Calendar controller
This commit is contained in:
parent
a61701e2ad
commit
e51f8ff377
1 changed files with 23 additions and 11 deletions
|
@ -50,7 +50,7 @@ class Calendar extends EA_Controller
|
|||
*
|
||||
* @param string $appointment_hash Appointment hash.
|
||||
*/
|
||||
public function reschedule(string $appointment_hash)
|
||||
public function reschedule(string $appointment_hash): void
|
||||
{
|
||||
$this->index($appointment_hash);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class Calendar extends EA_Controller
|
|||
*
|
||||
* @param string $appointment_hash Appointment hash.
|
||||
*/
|
||||
public function index(string $appointment_hash = '')
|
||||
public function index(string $appointment_hash = ''): void
|
||||
{
|
||||
session(['dest_url' => site_url('backend/index' . (!empty($appointment_hash) ? '/' . $appointment_hash : ''))]);
|
||||
|
||||
|
@ -176,7 +176,7 @@ class Calendar extends EA_Controller
|
|||
/**
|
||||
* Save appointment changes that are made from the backend calendar page.
|
||||
*/
|
||||
public function save_appointment()
|
||||
public function save_appointment(): void
|
||||
{
|
||||
try {
|
||||
$customer_data = request('customer_data');
|
||||
|
@ -209,6 +209,11 @@ class Calendar extends EA_Controller
|
|||
'timezone',
|
||||
'language',
|
||||
'notes',
|
||||
'custom_field_1',
|
||||
'custom_field_2',
|
||||
'custom_field_3',
|
||||
'custom_field_4',
|
||||
'custom_field_5',
|
||||
]);
|
||||
|
||||
$customer['id'] = $this->customers_model->save($customer);
|
||||
|
@ -246,7 +251,6 @@ class Calendar extends EA_Controller
|
|||
'notes',
|
||||
'color',
|
||||
'status',
|
||||
'notes',
|
||||
'is_unavailability',
|
||||
'id_users_provider',
|
||||
'id_users_customer',
|
||||
|
@ -318,7 +322,7 @@ class Calendar extends EA_Controller
|
|||
* Notification emails are send to both provider and customer and the delete action is executed to the Google
|
||||
* Calendar account of the provider, if the "google_sync" setting is enabled.
|
||||
*/
|
||||
public function delete_appointment()
|
||||
public function delete_appointment(): void
|
||||
{
|
||||
try {
|
||||
if (cannot('delete', 'appointments')) {
|
||||
|
@ -376,7 +380,7 @@ class Calendar extends EA_Controller
|
|||
/**
|
||||
* Insert of update unavailability to database.
|
||||
*/
|
||||
public function save_unavailability()
|
||||
public function save_unavailability(): void
|
||||
{
|
||||
try {
|
||||
// Check privileges
|
||||
|
@ -416,7 +420,7 @@ class Calendar extends EA_Controller
|
|||
/**
|
||||
* Delete an unavailability from database.
|
||||
*/
|
||||
public function delete_unavailability()
|
||||
public function delete_unavailability(): void
|
||||
{
|
||||
try {
|
||||
if (cannot('delete', PRIV_APPOINTMENTS)) {
|
||||
|
@ -448,7 +452,7 @@ class Calendar extends EA_Controller
|
|||
/**
|
||||
* Insert of update working plan exceptions to database.
|
||||
*/
|
||||
public function save_working_plan_exception()
|
||||
public function save_working_plan_exception(): void
|
||||
{
|
||||
try {
|
||||
if (cannot('edit', PRIV_USERS)) {
|
||||
|
@ -478,7 +482,7 @@ class Calendar extends EA_Controller
|
|||
/**
|
||||
* Delete a working plan exceptions time period to database.
|
||||
*/
|
||||
public function delete_working_plan_exception()
|
||||
public function delete_working_plan_exception(): void
|
||||
{
|
||||
try {
|
||||
$required_permissions = can('edit', PRIV_CUSTOMERS);
|
||||
|
@ -506,7 +510,7 @@ class Calendar extends EA_Controller
|
|||
*
|
||||
* This method will return all the calendar events within a specified period.
|
||||
*/
|
||||
public function get_calendar_appointments_for_table_view()
|
||||
public function get_calendar_appointments_for_table_view(): void
|
||||
{
|
||||
try {
|
||||
$required_permissions = can('view', PRIV_APPOINTMENTS);
|
||||
|
@ -582,6 +586,12 @@ class Calendar extends EA_Controller
|
|||
$response['unavailabilities'] = array_values($response['unavailabilities']);
|
||||
}
|
||||
|
||||
foreach ($response['unavailabilities'] as &$unavailability) {
|
||||
$unavailability['provider'] = $this->providers_model->find($unavailability['id_users_provider']);
|
||||
}
|
||||
|
||||
unset($unavailability);
|
||||
|
||||
// Add blocked periods to the response.
|
||||
$start_date = request('start_date');
|
||||
$end_date = request('end_date');
|
||||
|
@ -599,7 +609,7 @@ class Calendar extends EA_Controller
|
|||
* This method returns the database appointments and unavailability periods for the user selected date period and
|
||||
* record type (provider or service).
|
||||
*/
|
||||
public function get_calendar_appointments()
|
||||
public function get_calendar_appointments(): void
|
||||
{
|
||||
try {
|
||||
if (cannot('view', PRIV_APPOINTMENTS)) {
|
||||
|
@ -720,6 +730,8 @@ class Calendar extends EA_Controller
|
|||
}
|
||||
}
|
||||
|
||||
unset($unavailability);
|
||||
|
||||
$response['unavailabilities'] = array_values($response['unavailabilities']);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue