Skip to content

Commit

Permalink
Merged pull request alextselegidis#260 - Add 'Location' option to Ser…
Browse files Browse the repository at this point in the history
…vices [Not a required field]
  • Loading branch information
alextselegidis committed Jun 8, 2019
1 parent 52e1706 commit 44cd035
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
22 changes: 2 additions & 20 deletions src/application/controllers/Appointments.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,26 +482,8 @@ public function ajax_register_appointment()
$provider = $this->providers_model->get_row($appointment['id_users_provider']);
$service = $this->services_model->get_row($appointment['id_services']);

if (empty($appointment['location'])) {
$location = [];

if (!empty($provider['address'])) {
$location[] = $provider['address'];
}

if (!empty($provider['city'])) {
$location[] = $provider['city'];
}

if (!empty($provider['state'])) {
$location[] = $provider['state'];
}

if (!empty($provider['zip_code'])) {
$location[] = $provider['zip_code'];
}

$appointment['location'] = implode(', ', $location);
if (empty($appointment['location']) && !empty($service['location'])) {
$appointment['location'] = $service['location'];
}

$customer_id = $this->customers_model->add($customer);
Expand Down
5 changes: 5 additions & 0 deletions src/application/views/backend/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@
<input id="service-attendants-number" class="form-control required" type="number" min="1">
</div>

<div class="form-group">
<label for="service-location"><?= lang('location') ?></label>
<input id="service-location" class="form-control">
</div>

<div class="form-group">
<label for="service-description"><?= lang('description') ?></label>
<textarea id="service-description" rows="4" class="form-control"></textarea>
Expand Down
2 changes: 2 additions & 0 deletions src/assets/js/backend_services_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
price: $('#service-price').val(),
currency: $('#service-currency').val(),
description: $('#service-description').val(),
location: $('#service-location').val(),
availabilities_type: $('#service-availabilities-type').val(),
attendants_number: $('#service-attendants-number').val()
};
Expand Down Expand Up @@ -288,6 +289,7 @@
$('#service-price').val(service.price);
$('#service-currency').val(service.currency);
$('#service-description').val(service.description);
$('#service-location').val(service.location);
$('#service-availabilities-type').val(service.availabilities_type);
$('#service-attendants-number').val(service.attendants_number);

Expand Down
4 changes: 4 additions & 0 deletions src/assets/js/frontend_book.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,10 @@ window.FrontendBook = window.FrontendBook || {};
html += '[' + EALang.price + ' ' + service.price + ' ' + service.currency + ']';
}

if (service.location != '' && service.location != null) {
html += '[' + EALang.location + ' ' + service.location + ']';
}

html += '<br>';

return false;
Expand Down
6 changes: 6 additions & 0 deletions src/engine/Api/V1/Parsers/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function encode(array &$response)
'price' => (float)$response['price'],
'currency' => $response['currency'],
'description' => $response['description'],
'location' => $response['location'],
'availabilitiesType' => $response['availabilities_type'],
'attendantsNumber' => (int)$response['attendants_number'],
'categoryId' => $response['id_service_categories'] !== NULL ? (int)$response['id_service_categories'] : NULL
Expand Down Expand Up @@ -81,6 +82,11 @@ public function decode(array &$request, array $base = NULL)
$decodedRequest['description'] = $request['description'];
}

if ( ! empty($request['location']))
{
$decodedRequest['location'] = $request['location'];
}

if ( ! empty($request['availabilitiesType']))
{
$decodedRequest['availabilities_type'] = $request['availabilitiesType'];
Expand Down

0 comments on commit 44cd035

Please sign in to comment.