Merge pull request #817 from popod/save-customer-language

Save customer language to the database
This commit is contained in:
Alex Tselegidis 2020-09-23 13:16:25 +03:00 committed by GitHub
commit 7bbe85b88a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 79 additions and 1 deletions

View file

@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE;
| be upgraded / downgraded to. | be upgraded / downgraded to.
| |
*/ */
$config['migration_version'] = 19; $config['migration_version'] = 20;
/* /*

View file

@ -1041,6 +1041,8 @@ class Appointments extends CI_Controller {
$appointment['location'] = $service['location']; $appointment['location'] = $service['location'];
} }
// save customer language (the language which is used to render the booking page)
$customer['language'] = $this->config->item('language');
$customer_id = $this->customers_model->add($customer); $customer_id = $this->customers_model->add($customer);
$appointment['id_users_customer'] = $customer_id; $appointment['id_users_customer'] = $customer_id;

View file

@ -21,6 +21,8 @@ $lang['address'] = 'Address';
$lang['city'] = 'City'; $lang['city'] = 'City';
$lang['zip_code'] = 'Zip Code'; $lang['zip_code'] = 'Zip Code';
$lang['notes'] = 'Notes'; $lang['notes'] = 'Notes';
$lang['language'] = 'Language';
$lang['no_language'] = 'No language';
$lang['fields_are_required'] = 'Fields with * are required!'; $lang['fields_are_required'] = 'Fields with * are required!';
$lang['appointment_confirmation'] = 'Appointment Confirmation'; $lang['appointment_confirmation'] = 'Appointment Confirmation';
$lang['confirm'] = 'Confirm'; $lang['confirm'] = 'Confirm';

View file

@ -20,6 +20,8 @@ $lang['address'] = 'Adresse';
$lang['city'] = 'Ville'; $lang['city'] = 'Ville';
$lang['zip_code'] = 'Code postal'; $lang['zip_code'] = 'Code postal';
$lang['notes'] = 'Commentaires'; $lang['notes'] = 'Commentaires';
$lang['language'] = 'Langue';
$lang['no_language'] = 'Pas de langue';
$lang['fields_are_required'] = 'Les champs avec * sont obligatoires'; $lang['fields_are_required'] = 'Les champs avec * sont obligatoires';
$lang['appointment_confirmation'] = 'Confirmez votre rendez-vous'; $lang['appointment_confirmation'] = 'Confirmez votre rendez-vous';
$lang['confirm'] = 'Confirmation'; $lang['confirm'] = 'Confirmation';

View file

@ -20,6 +20,7 @@ $lang['address'] = 'Adresse';
$lang['city'] = 'Stadt'; $lang['city'] = 'Stadt';
$lang['zip_code'] = 'Postleitzahl'; $lang['zip_code'] = 'Postleitzahl';
$lang['notes'] = 'Bemerkungen'; $lang['notes'] = 'Bemerkungen';
$lang['language'] = 'Sprache';
$lang['fields_are_required'] = 'Die Felder mit einem * sind Pflichtfelder!'; $lang['fields_are_required'] = 'Die Felder mit einem * sind Pflichtfelder!';
$lang['appointment_confirmation'] = 'Bitte bestätigen Sie die Terminauswahl'; $lang['appointment_confirmation'] = 'Bitte bestätigen Sie die Terminauswahl';
$lang['confirm'] = 'Bestätigung'; $lang['confirm'] = 'Bestätigung';

View file

@ -0,0 +1,48 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Open Source Web Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) 2013 - 2020, Alex Tselegidis
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
* @link http://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
/**
* Class Migration_Add_language_to_users
*
* @property CI_DB_query_builder db
* @property CI_DB_forge dbforge
*/
class Migration_Add_language_to_users extends CI_Migration {
/**
* Upgrade method.
*/
public function up()
{
if ( ! $this->db->field_exists('language', 'users'))
{
$fields = [
'language' => [
'type' => 'VARCHAR',
'constraint' => '256',
'default' => '',
'after' => 'timezone'
]
];
$this->dbforge->add_column('users', $fields);
}
}
/**
* Downgrade method.
*/
public function down()
{
$this->dbforge->drop_column('users', 'language');
}
}

View file

@ -132,6 +132,11 @@
<input id="zip-code" class="form-control"> <input id="zip-code" class="form-control">
</div> </div>
<div class="form-group">
<label for="language"><?= lang('language') ?></label>
<select id="language" class="form-control"></select>
</div>
<div class="form-group"> <div class="form-group">
<label for="timezone"><?= lang('timezone') ?></label> <label for="timezone"><?= lang('timezone') ?></label>
<?= render_timezone_dropdown('id="timezone" class="form-control"') ?> <?= render_timezone_dropdown('id="timezone" class="form-control"') ?>

View file

@ -42,6 +42,13 @@ window.BackendCustomers = window.BackendCustomers || {};
exports.initialize = function (defaultEventHandlers) { exports.initialize = function (defaultEventHandlers) {
defaultEventHandlers = defaultEventHandlers || false; defaultEventHandlers = defaultEventHandlers || false;
// Fill available service categories listbox.
availableLanguages.forEach(function (language) {
$('#language').append(new Option(language, language));
});
$('#language').append(new Option('- ' + EALang.no_language + ' -', null)).val('null');
helper = new CustomersHelper(); helper = new CustomersHelper();
helper.resetForm(); helper.resetForm();
helper.filter(''); helper.filter('');

View file

@ -128,6 +128,12 @@
timezone: $('#timezone').val() timezone: $('#timezone').val()
}; };
if ($('#language').val() !== 'null') {
customer.language = $('#language').val();
} else {
customer.language = '';
}
if ($('#customer-id').val()) { if ($('#customer-id').val()) {
customer.id = $('#customer-id').val(); customer.id = $('#customer-id').val();
} }
@ -259,6 +265,8 @@
.val('') .val('')
.prop('disabled', true); .prop('disabled', true);
$('#language').val('null');
$('#customer-appointments').empty(); $('#customer-appointments').empty();
$('#edit-customer, #delete-customer').prop('disabled', true); $('#edit-customer, #delete-customer').prop('disabled', true);
$('#add-edit-delete-group').show(); $('#add-edit-delete-group').show();
@ -289,6 +297,9 @@
$('#notes').val(customer.notes); $('#notes').val(customer.notes);
$('#timezone').val(customer.timezone); $('#timezone').val(customer.timezone);
var language = (customer.language !== '') ? customer.language : 'null';
$('#language').val(language);
$('#customer-appointments').empty(); $('#customer-appointments').empty();
if (!customer.appointments.length) { if (!customer.appointments.length) {