mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-29 18:52:22 +01:00
revert real usage of templateUrl
This commit is contained in:
parent
9b6e5408f9
commit
31d1071f87
@ -58,8 +58,8 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
prefix: settings.invoice_prefix,
|
prefix: settings.invoice_prefix,
|
||||||
nextId: 40,
|
nextId: 40,
|
||||||
date: moment().format('DDMMYYYY'),
|
date: moment().format('DDMMYYYY'),
|
||||||
template: require('../../../../templates/editPrefix.html')
|
templateUrl: 'editPrefix.html'
|
||||||
}
|
};
|
||||||
|
|
||||||
// Invoices parameters
|
// Invoices parameters
|
||||||
$scope.invoice = {
|
$scope.invoice = {
|
||||||
@ -67,22 +67,22 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
reference: {
|
reference: {
|
||||||
model: '',
|
model: '',
|
||||||
help: null,
|
help: null,
|
||||||
template: require('../../../../templates/editReference.html')
|
templateUrl: 'editReference.html'
|
||||||
},
|
},
|
||||||
code: {
|
code: {
|
||||||
model: '',
|
model: '',
|
||||||
active: true,
|
active: true,
|
||||||
template: require('../../../../templates/editCode.html')
|
templateUrl: 'editCode.html'
|
||||||
},
|
},
|
||||||
number: {
|
number: {
|
||||||
model: '',
|
model: '',
|
||||||
help: null,
|
help: null,
|
||||||
template: require('../../../../templates/editNumber.html')
|
templateUrl: 'editNumber.html'
|
||||||
},
|
},
|
||||||
VAT: {
|
VAT: {
|
||||||
rate: 19.6,
|
rate: 19.6,
|
||||||
active: false,
|
active: false,
|
||||||
template: require('../../../../templates/editVAT.html')
|
templateUrl: 'editVAT.html'
|
||||||
},
|
},
|
||||||
text: {
|
text: {
|
||||||
content: ''
|
content: ''
|
||||||
@ -96,87 +96,87 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
$scope.settings = {
|
$scope.settings = {
|
||||||
journalCode: {
|
journalCode: {
|
||||||
name: 'accounting_journal_code',
|
name: 'accounting_journal_code',
|
||||||
value: settings['accounting_journal_code']
|
value: settings.accounting_journal_code
|
||||||
},
|
},
|
||||||
cardClientCode: {
|
cardClientCode: {
|
||||||
name: 'accounting_card_client_code',
|
name: 'accounting_card_client_code',
|
||||||
value: settings['accounting_card_client_code']
|
value: settings.accounting_card_client_code
|
||||||
},
|
},
|
||||||
cardClientLabel: {
|
cardClientLabel: {
|
||||||
name: 'accounting_card_client_label',
|
name: 'accounting_card_client_label',
|
||||||
value: settings['accounting_card_client_label']
|
value: settings.accounting_card_client_label
|
||||||
},
|
},
|
||||||
walletClientCode: {
|
walletClientCode: {
|
||||||
name: 'accounting_wallet_client_code',
|
name: 'accounting_wallet_client_code',
|
||||||
value: settings['accounting_wallet_client_code']
|
value: settings.accounting_wallet_client_code
|
||||||
},
|
},
|
||||||
walletClientLabel: {
|
walletClientLabel: {
|
||||||
name: 'accounting_wallet_client_label',
|
name: 'accounting_wallet_client_label',
|
||||||
value: settings['accounting_wallet_client_label']
|
value: settings.accounting_wallet_client_label
|
||||||
},
|
},
|
||||||
otherClientCode: {
|
otherClientCode: {
|
||||||
name: 'accounting_other_client_code',
|
name: 'accounting_other_client_code',
|
||||||
value: settings['accounting_other_client_code']
|
value: settings.accounting_other_client_code
|
||||||
},
|
},
|
||||||
otherClientLabel: {
|
otherClientLabel: {
|
||||||
name: 'accounting_other_client_label',
|
name: 'accounting_other_client_label',
|
||||||
value: settings['accounting_other_client_label']
|
value: settings.accounting_other_client_label
|
||||||
},
|
},
|
||||||
walletCode: {
|
walletCode: {
|
||||||
name: 'accounting_wallet_code',
|
name: 'accounting_wallet_code',
|
||||||
value: settings['accounting_wallet_code']
|
value: settings.accounting_wallet_code
|
||||||
},
|
},
|
||||||
walletLabel: {
|
walletLabel: {
|
||||||
name: 'accounting_wallet_label',
|
name: 'accounting_wallet_label',
|
||||||
value: settings['accounting_wallet_label']
|
value: settings.accounting_wallet_label
|
||||||
},
|
},
|
||||||
vatCode: {
|
vatCode: {
|
||||||
name: 'accounting_VAT_code',
|
name: 'accounting_VAT_code',
|
||||||
value: settings['accounting_VAT_code']
|
value: settings.accounting_VAT_code
|
||||||
},
|
},
|
||||||
vatLabel: {
|
vatLabel: {
|
||||||
name: 'accounting_VAT_label',
|
name: 'accounting_VAT_label',
|
||||||
value: settings['accounting_VAT_label']
|
value: settings.accounting_VAT_label
|
||||||
},
|
},
|
||||||
subscriptionCode: {
|
subscriptionCode: {
|
||||||
name: 'accounting_subscription_code',
|
name: 'accounting_subscription_code',
|
||||||
value: settings['accounting_subscription_code']
|
value: settings.accounting_subscription_code
|
||||||
},
|
},
|
||||||
subscriptionLabel: {
|
subscriptionLabel: {
|
||||||
name: 'accounting_subscription_label',
|
name: 'accounting_subscription_label',
|
||||||
value: settings['accounting_subscription_label']
|
value: settings.accounting_subscription_label
|
||||||
},
|
},
|
||||||
machineCode: {
|
machineCode: {
|
||||||
name: 'accounting_Machine_code',
|
name: 'accounting_Machine_code',
|
||||||
value: settings['accounting_Machine_code']
|
value: settings.accounting_Machine_code
|
||||||
},
|
},
|
||||||
machineLabel: {
|
machineLabel: {
|
||||||
name: 'accounting_Machine_label',
|
name: 'accounting_Machine_label',
|
||||||
value: settings['accounting_Machine_label']
|
value: settings.accounting_Machine_label
|
||||||
},
|
},
|
||||||
trainingCode: {
|
trainingCode: {
|
||||||
name: 'accounting_Training_code',
|
name: 'accounting_Training_code',
|
||||||
value: settings['accounting_Training_code']
|
value: settings.accounting_Training_code
|
||||||
},
|
},
|
||||||
trainingLabel: {
|
trainingLabel: {
|
||||||
name: 'accounting_Training_label',
|
name: 'accounting_Training_label',
|
||||||
value: settings['accounting_Training_label']
|
value: settings.accounting_Training_label
|
||||||
},
|
},
|
||||||
eventCode: {
|
eventCode: {
|
||||||
name: 'accounting_Event_code',
|
name: 'accounting_Event_code',
|
||||||
value: settings['accounting_Event_code']
|
value: settings.accounting_Event_code
|
||||||
},
|
},
|
||||||
eventLabel: {
|
eventLabel: {
|
||||||
name: 'accounting_Event_label',
|
name: 'accounting_Event_label',
|
||||||
value: settings['accounting_Event_label']
|
value: settings.accounting_Event_label
|
||||||
},
|
},
|
||||||
spaceCode: {
|
spaceCode: {
|
||||||
name: 'accounting_Space_code',
|
name: 'accounting_Space_code',
|
||||||
value: settings['accounting_Space_code']
|
value: settings.accounting_Space_code
|
||||||
},
|
},
|
||||||
spaceLabel: {
|
spaceLabel: {
|
||||||
name: 'accounting_Space_label',
|
name: 'accounting_Space_label',
|
||||||
value: settings['accounting_Space_label']
|
value: settings.accounting_Space_label
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -224,8 +224,8 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
controller: 'AvoirModalController',
|
controller: 'AvoirModalController',
|
||||||
resolve: {
|
resolve: {
|
||||||
invoice () { return invoice; },
|
invoice () { return invoice; },
|
||||||
closedPeriods() { return AccountingPeriod.query().$promise; },
|
closedPeriods () { return AccountingPeriod.query().$promise; },
|
||||||
lastClosingEnd() { return AccountingPeriod.lastClosingEnd().$promise; }
|
lastClosingEnd () { return AccountingPeriod.lastClosingEnd().$promise; }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -311,10 +311,10 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
growl.success(_t('app.admin.invoices.invoice_reference_successfully_saved'));
|
growl.success(_t('app.admin.invoices.invoice_reference_successfully_saved'));
|
||||||
}
|
}
|
||||||
, function (error) {
|
, function (error) {
|
||||||
if (error.status === 304) return;
|
if (error.status === 304) return;
|
||||||
|
|
||||||
growl.error(_t('app.admin.invoices.an_error_occurred_while_saving_invoice_reference'));
|
growl.error(_t('app.admin.invoices.an_error_occurred_while_saving_invoice_reference'));
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -352,10 +352,10 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
, function (error) {
|
, function (error) {
|
||||||
if (error.status === 304) return;
|
if (error.status === 304) return;
|
||||||
|
|
||||||
growl.error(_t('app.admin.invoices.an_error_occurred_while_saving_the_invoicing_code'));
|
growl.error(_t('app.admin.invoices.an_error_occurred_while_saving_the_invoicing_code'));
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
return Setting.update({ name: 'invoice_code-active' }, { value: result.active ? 'true' : 'false' }, function (data) {
|
return Setting.update({ name: 'invoice_code-active' }, { value: result.active ? 'true' : 'false' }, function (data) {
|
||||||
@ -367,10 +367,10 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
, function (error) {
|
, function (error) {
|
||||||
if (error.status === 304) return;
|
if (error.status === 304) return;
|
||||||
|
|
||||||
growl.error(_t('app.admin.invoices.an_error_occurred_while_activating_the_invoicing_code'));
|
growl.error(_t('app.admin.invoices.an_error_occurred_while_activating_the_invoicing_code'));
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -401,10 +401,10 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
return growl.success(_t('app.admin.invoices.order_number_successfully_saved'));
|
return growl.success(_t('app.admin.invoices.order_number_successfully_saved'));
|
||||||
}
|
}
|
||||||
, function (error) {
|
, function (error) {
|
||||||
if (error.status === 304) return;
|
if (error.status === 304) return;
|
||||||
|
|
||||||
growl.error(_t('app.admin.invoices.an_error_occurred_while_saving_the_order_number'));
|
growl.error(_t('app.admin.invoices.an_error_occurred_while_saving_the_order_number'));
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -440,15 +440,14 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
$scope.ok = function () { $uibModalInstance.close({ rate: $scope.rate, active: $scope.isSelected }); };
|
$scope.ok = function () { $uibModalInstance.close({ rate: $scope.rate, active: $scope.isSelected }); };
|
||||||
$scope.cancel = function () { $uibModalInstance.dismiss('cancel'); };
|
$scope.cancel = function () { $uibModalInstance.dismiss('cancel'); };
|
||||||
|
|
||||||
|
const initialize = function () {
|
||||||
const initialize = function() {
|
|
||||||
rateHistory.setting.history.forEach(function (rate) {
|
rateHistory.setting.history.forEach(function (rate) {
|
||||||
$scope.history.push({ date: rate.created_at, rate: rate.value, user: rate.user })
|
$scope.history.push({ date: rate.created_at, rate: rate.value, user: rate.user });
|
||||||
});
|
});
|
||||||
activeHistory.setting.history.forEach(function (v) {
|
activeHistory.setting.history.forEach(function (v) {
|
||||||
$scope.history.push({ date: v.created_at, enabled: v.value === 'true', user: v.user })
|
$scope.history.push({ date: v.created_at, enabled: v.value === 'true', user: v.user });
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
}]
|
}]
|
||||||
@ -462,10 +461,10 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
, function (error) {
|
, function (error) {
|
||||||
if (error.status === 304) return;
|
if (error.status === 304) return;
|
||||||
|
|
||||||
growl.error(_t('app.admin.invoices.an_error_occurred_while_saving_the_VAT_rate'));
|
growl.error(_t('app.admin.invoices.an_error_occurred_while_saving_the_VAT_rate'));
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
return Setting.update({ name: 'invoice_VAT-active' }, { value: result.active ? 'true' : 'false' }, function (data) {
|
return Setting.update({ name: 'invoice_VAT-active' }, { value: result.active ? 'true' : 'false' }, function (data) {
|
||||||
@ -477,10 +476,10 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
, function (error) {
|
, function (error) {
|
||||||
if (error.status === 304) return;
|
if (error.status === 304) return;
|
||||||
|
|
||||||
growl.error(_t('app.admin.invoices.an_error_occurred_while_activating_the_VAT'));
|
growl.error(_t('app.admin.invoices.an_error_occurred_while_activating_the_VAT'));
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -494,7 +493,7 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
templateUrl: $scope.file.templateUrl,
|
templateUrl: $scope.file.templateUrl,
|
||||||
size: 'lg',
|
size: 'lg',
|
||||||
resolve: {
|
resolve: {
|
||||||
model () { return $scope.file.prefix;}
|
model () { return $scope.file.prefix; }
|
||||||
},
|
},
|
||||||
controller: ['$scope', '$uibModalInstance', 'model', function ($scope, $uibModalInstance, model) {
|
controller: ['$scope', '$uibModalInstance', 'model', function ($scope, $uibModalInstance, model) {
|
||||||
$scope.model = model;
|
$scope.model = model;
|
||||||
@ -505,15 +504,15 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
|
|
||||||
return modalInstance.result.then(function (model) {
|
return modalInstance.result.then(function (model) {
|
||||||
Setting.update({ name: 'invoice_prefix' }, { value: model }, function (data) {
|
Setting.update({ name: 'invoice_prefix' }, { value: model }, function (data) {
|
||||||
$scope.file.prefix = model;
|
$scope.file.prefix = model;
|
||||||
return growl.success(_t('app.admin.invoices.prefix_successfully_saved'));
|
return growl.success(_t('app.admin.invoices.prefix_successfully_saved'));
|
||||||
}
|
}
|
||||||
, function (error) {
|
, function (error) {
|
||||||
if (error.status === 304) return;
|
if (error.status === 304) return;
|
||||||
|
|
||||||
growl.error(_t('app.admin.invoices.an_error_occurred_while_saving_the_prefix'));
|
growl.error(_t('app.admin.invoices.an_error_occurred_while_saving_the_prefix'));
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -527,10 +526,10 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
return growl.success(_t('app.admin.invoices.text_successfully_saved'));
|
return growl.success(_t('app.admin.invoices.text_successfully_saved'));
|
||||||
}
|
}
|
||||||
, function (error) {
|
, function (error) {
|
||||||
if (error.status === 304) return;
|
if (error.status === 304) return;
|
||||||
|
|
||||||
growl.error(_t('app.admin.invoices.an_error_occurred_while_saving_the_text'));
|
growl.error(_t('app.admin.invoices.an_error_occurred_while_saving_the_text'));
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -544,10 +543,10 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
return growl.success(_t('app.admin.invoices.address_and_legal_information_successfully_saved'));
|
return growl.success(_t('app.admin.invoices.address_and_legal_information_successfully_saved'));
|
||||||
}
|
}
|
||||||
, function (error) {
|
, function (error) {
|
||||||
if (error.status === 304) return;
|
if (error.status === 304) return;
|
||||||
|
|
||||||
growl.error(_t('app.admin.invoices.an_error_occurred_while_saving_the_address_and_the_legal_information'));
|
growl.error(_t('app.admin.invoices.an_error_occurred_while_saving_the_address_and_the_legal_information'));
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -557,7 +556,7 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
*/
|
*/
|
||||||
$scope.handleFilterChange = function () {
|
$scope.handleFilterChange = function () {
|
||||||
if (searchTimeout) clearTimeout(searchTimeout);
|
if (searchTimeout) clearTimeout(searchTimeout);
|
||||||
searchTimeout = setTimeout(function() {
|
searchTimeout = setTimeout(function () {
|
||||||
resetSearchInvoice();
|
resetSearchInvoice();
|
||||||
invoiceSearch();
|
invoiceSearch();
|
||||||
}, 300);
|
}, 300);
|
||||||
@ -576,7 +575,7 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
* Open a modal allowing the user to close an accounting period and to
|
* Open a modal allowing the user to close an accounting period and to
|
||||||
* view all periods already closed.
|
* view all periods already closed.
|
||||||
*/
|
*/
|
||||||
$scope.closeAnAccountingPeriod = function() {
|
$scope.closeAnAccountingPeriod = function () {
|
||||||
// open modal
|
// open modal
|
||||||
$uibModal.open({
|
$uibModal.open({
|
||||||
template: require('../../../../templates/admin/invoices/closePeriodModal.html'),
|
template: require('../../../../templates/admin/invoices/closePeriodModal.html'),
|
||||||
@ -585,38 +584,38 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
keyboard: false,
|
keyboard: false,
|
||||||
size: 'lg',
|
size: 'lg',
|
||||||
resolve: {
|
resolve: {
|
||||||
periods() { return AccountingPeriod.query().$promise; },
|
periods () { return AccountingPeriod.query().$promise; },
|
||||||
lastClosingEnd() { return AccountingPeriod.lastClosingEnd().$promise; }
|
lastClosingEnd () { return AccountingPeriod.lastClosingEnd().$promise; }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
$scope.toggleExportModal = function() {
|
$scope.toggleExportModal = function () {
|
||||||
$uibModal.open({
|
$uibModal.open({
|
||||||
template: require('../../../../templates/admin/invoices/accountingExportModal.html'),
|
template: require('../../../../templates/admin/invoices/accountingExportModal.html'),
|
||||||
controller: 'AccountingExportModalController',
|
controller: 'AccountingExportModalController',
|
||||||
size: 'xl'
|
size: 'xl'
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if the given date is within a closed accounting period
|
* Test if the given date is within a closed accounting period
|
||||||
* @param date {Date} date to test
|
* @param date {Date} date to test
|
||||||
* @returns {boolean} true if closed, false otherwise
|
* @returns {boolean} true if closed, false otherwise
|
||||||
*/
|
*/
|
||||||
$scope.isDateClosed = function(date) {
|
$scope.isDateClosed = function (date) {
|
||||||
for (const period of closedPeriods) {
|
for (const period of closedPeriods) {
|
||||||
if (moment(date).isBetween(moment.utc(period.start_at).startOf('day'), moment.utc(period.end_at).endOf('day'), null, '[]')) {
|
if (moment(date).isBetween(moment.utc(period.start_at).startOf('day'), moment.utc(period.end_at).endOf('day'), null, '[]')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback to bulk save all settings in the page to the database with their values
|
* Callback to bulk save all settings in the page to the database with their values
|
||||||
*/
|
*/
|
||||||
$scope.save = function() {
|
$scope.save = function () {
|
||||||
Setting.bulkUpdate(
|
Setting.bulkUpdate(
|
||||||
{ settings: Object.values($scope.settings) },
|
{ settings: Object.values($scope.settings) },
|
||||||
function () { growl.success(_t('app.admin.invoices.codes_customization_success')); },
|
function () { growl.success(_t('app.admin.invoices.codes_customization_success')); },
|
||||||
@ -625,29 +624,29 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the name of the operator that creates the invoice
|
* Return the name of the operator that creates the invoice
|
||||||
*/
|
*/
|
||||||
$scope.operatorName = function(invoice) {
|
$scope.operatorName = function (invoice) {
|
||||||
if (!invoice.operator) return '';
|
if (!invoice.operator) return '';
|
||||||
|
|
||||||
return `${invoice.operator.first_name} ${invoice.operator.last_name}`;
|
return `${invoice.operator.first_name} ${invoice.operator.last_name}`;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a modal dialog which ask for the stripe keys
|
* Open a modal dialog which ask for the stripe keys
|
||||||
* @param onlinePaymentModule {{name: String, value: String}} setting that defines the next status of the online payment module
|
* @param onlinePaymentModule {{name: String, value: String}} setting that defines the next status of the online payment module
|
||||||
* @return {boolean} false if the keys were not provided
|
* @return {boolean} false if the keys were not provided
|
||||||
*/
|
*/
|
||||||
$scope.requireStripeKeys = function(onlinePaymentModule) {
|
$scope.requireStripeKeys = function (onlinePaymentModule) {
|
||||||
// if the online payment is about to be disabled, accept the change without any further question
|
// if the online payment is about to be disabled, accept the change without any further question
|
||||||
if (onlinePaymentModule.value === false) return true;
|
if (onlinePaymentModule.value === false) return true;
|
||||||
|
|
||||||
// otherwise, open a modal to ask for the stripe keys
|
// otherwise, open a modal to ask for the stripe keys
|
||||||
const modalInstance = $uibModal.open({
|
const modalInstance = $uibModal.open({
|
||||||
template: require('../../../../templates/stripeKeys.html'),
|
templateUrl: 'stripeKeys.html',
|
||||||
controller: 'StripeKeysModalController',
|
controller: 'StripeKeysModalController',
|
||||||
resolve: {
|
resolve: {
|
||||||
stripeKeys: ['Setting', function (Setting) { return Setting.query({ names: "['stripe_public_key', 'stripe_secret_key']" }).$promise; }]
|
stripeKeys: ['Setting', function (Setting) { return Setting.query({ names: "['stripe_public_key', 'stripe_secret_key']" }).$promise; }]
|
||||||
@ -658,19 +657,19 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
if (success) {
|
if (success) {
|
||||||
Setting.get({ name: 'stripe_public_key' }, function (res) {
|
Setting.get({ name: 'stripe_public_key' }, function (res) {
|
||||||
$scope.allSettings.stripe_public_key = res.setting.value;
|
$scope.allSettings.stripe_public_key = res.setting.value;
|
||||||
})
|
});
|
||||||
Setting.isPresent({ name: 'stripe_secret_key' }, function (res) {
|
Setting.isPresent({ name: 'stripe_secret_key' }, function (res) {
|
||||||
$scope.stripeSecretKey = (res.isPresent ? STRIPE_SK_HIDDEN : '');
|
$scope.stripeSecretKey = (res.isPresent ? STRIPE_SK_HIDDEN : '');
|
||||||
})
|
});
|
||||||
Payment.onlinePaymentStatus(function (res) {
|
Payment.onlinePaymentStatus(function (res) {
|
||||||
$scope.onlinePaymentStatus = res.status;
|
$scope.onlinePaymentStatus = res.status;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
// return the promise
|
// return the promise
|
||||||
return modalInstance.result;
|
return modalInstance.result;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the feature-tour for the admin/invoices page.
|
* Setup the feature-tour for the admin/invoices page.
|
||||||
@ -814,7 +813,7 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
if (settings.feature_tour_display !== 'manual' && $scope.currentUser.profile.tours.indexOf('invoices') < 0) {
|
if (settings.feature_tour_display !== 'manual' && $scope.currentUser.profile.tours.indexOf('invoices') < 0) {
|
||||||
uitour.start();
|
uitour.start();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/* PRIVATE SCOPE */
|
/* PRIVATE SCOPE */
|
||||||
|
|
||||||
@ -827,18 +826,18 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
|||||||
}
|
}
|
||||||
|
|
||||||
// retrieve settings from the DB through the API
|
// retrieve settings from the DB through the API
|
||||||
$scope.invoice.legals.content = settings['invoice_legals'];
|
$scope.invoice.legals.content = settings.invoice_legals;
|
||||||
$scope.invoice.text.content = settings['invoice_text'];
|
$scope.invoice.text.content = settings.invoice_text;
|
||||||
$scope.invoice.VAT.rate = parseFloat(settings['invoice_VAT-rate']);
|
$scope.invoice.VAT.rate = parseFloat(settings['invoice_VAT-rate']);
|
||||||
$scope.invoice.VAT.active = (settings['invoice_VAT-active'] === 'true');
|
$scope.invoice.VAT.active = (settings['invoice_VAT-active'] === 'true');
|
||||||
$scope.invoice.number.model = settings['invoice_order-nb'];
|
$scope.invoice.number.model = settings['invoice_order-nb'];
|
||||||
$scope.invoice.code.model = settings['invoice_code-value'];
|
$scope.invoice.code.model = settings['invoice_code-value'];
|
||||||
$scope.invoice.code.active = (settings['invoice_code-active'] === 'true');
|
$scope.invoice.code.active = (settings['invoice_code-active'] === 'true');
|
||||||
$scope.invoice.reference.model = settings['invoice_reference'];
|
$scope.invoice.reference.model = settings.invoice_reference;
|
||||||
$scope.invoice.logo = {
|
$scope.invoice.logo = {
|
||||||
filetype: 'image/png',
|
filetype: 'image/png',
|
||||||
filename: 'logo.png',
|
filename: 'logo.png',
|
||||||
base64: settings['invoice_logo']
|
base64: settings.invoice_logo
|
||||||
};
|
};
|
||||||
|
|
||||||
// Watch the logo, when a change occurs, save it
|
// Watch the logo, when a change occurs, save it
|
||||||
@ -990,7 +989,7 @@ Application.Controllers.controller('AvoirModalController', ['$scope', '$uibModal
|
|||||||
$scope.ok = function () {
|
$scope.ok = function () {
|
||||||
// check that at least 1 element of the invoice is refunded
|
// check that at least 1 element of the invoice is refunded
|
||||||
$scope.avoir.invoice_items_ids = [];
|
$scope.avoir.invoice_items_ids = [];
|
||||||
for (let itemId in $scope.partial) {
|
for (const itemId in $scope.partial) {
|
||||||
if (Object.prototype.hasOwnProperty.call($scope.partial, itemId)) {
|
if (Object.prototype.hasOwnProperty.call($scope.partial, itemId)) {
|
||||||
const refundItem = $scope.partial[itemId];
|
const refundItem = $scope.partial[itemId];
|
||||||
if (refundItem) {
|
if (refundItem) {
|
||||||
@ -1024,14 +1023,14 @@ Application.Controllers.controller('AvoirModalController', ['$scope', '$uibModal
|
|||||||
* @param date {Date} date to test
|
* @param date {Date} date to test
|
||||||
* @returns {boolean} true if closed, false otherwise
|
* @returns {boolean} true if closed, false otherwise
|
||||||
*/
|
*/
|
||||||
$scope.isDateClosed = function(date) {
|
$scope.isDateClosed = function (date) {
|
||||||
for (const period of closedPeriods) {
|
for (const period of closedPeriods) {
|
||||||
if (moment(date).isBetween(moment.utc(period.start_at).startOf('day'), moment.utc(period.end_at).endOf('day'), null, '[]')) {
|
if (moment(date).isBetween(moment.utc(period.start_at).startOf('day'), moment.utc(period.end_at).endOf('day'), null, '[]')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
/* PRIVATE SCOPE */
|
/* PRIVATE SCOPE */
|
||||||
|
|
||||||
@ -1058,11 +1057,10 @@ Application.Controllers.controller('AvoirModalController', ['$scope', '$uibModal
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller used in the modal window allowing an admin to close an accounting period
|
* Controller used in the modal window allowing an admin to close an accounting period
|
||||||
*/
|
*/
|
||||||
Application.Controllers.controller('ClosePeriodModalController', ['$scope', '$uibModalInstance', '$window', '$sce', 'Invoice', 'AccountingPeriod', 'periods', 'lastClosingEnd','dialogs', 'growl', '_t',
|
Application.Controllers.controller('ClosePeriodModalController', ['$scope', '$uibModalInstance', '$window', '$sce', 'Invoice', 'AccountingPeriod', 'periods', 'lastClosingEnd', 'dialogs', 'growl', '_t',
|
||||||
function ($scope, $uibModalInstance, $window, $sce, Invoice, AccountingPeriod, periods, lastClosingEnd, dialogs, growl, _t) {
|
function ($scope, $uibModalInstance, $window, $sce, Invoice, AccountingPeriod, periods, lastClosingEnd, dialogs, growl, _t) {
|
||||||
const YESTERDAY = moment.utc({ h: 0, m: 0, s: 0, ms: 0 }).subtract(1, 'day').toDate();
|
const YESTERDAY = moment.utc({ h: 0, m: 0, s: 0, ms: 0 }).subtract(1, 'day').toDate();
|
||||||
const LAST_CLOSING = moment.utc(lastClosingEnd.last_end_date).toDate();
|
const LAST_CLOSING = moment.utc(lastClosingEnd.last_end_date).toDate();
|
||||||
@ -1124,11 +1122,11 @@ Application.Controllers.controller('ClosePeriodModalController', ['$scope', '$ui
|
|||||||
_t(
|
_t(
|
||||||
'app.admin.invoices.confirm_close_START_END',
|
'app.admin.invoices.confirm_close_START_END',
|
||||||
{ START: moment.utc($scope.period.start_at).format('LL'), END: moment.utc($scope.period.end_at).format('LL') }
|
{ START: moment.utc($scope.period.start_at).format('LL'), END: moment.utc($scope.period.end_at).format('LL') }
|
||||||
)
|
) +
|
||||||
+ '<br/><br/><strong>'
|
'<br/><br/><strong>' +
|
||||||
+ _t('app.admin.invoices.period_must_match_fiscal_year')
|
_t('app.admin.invoices.period_must_match_fiscal_year') +
|
||||||
+ '</strong><br/><br/>'
|
'</strong><br/><br/>' +
|
||||||
+ _t('app.admin.invoices.this_may_take_a_while')
|
_t('app.admin.invoices.this_may_take_a_while')
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -1151,7 +1149,7 @@ Application.Controllers.controller('ClosePeriodModalController', ['$scope', '$ui
|
|||||||
));
|
));
|
||||||
$uibModalInstance.close(resp);
|
$uibModalInstance.close(resp);
|
||||||
},
|
},
|
||||||
function(error) {
|
function (error) {
|
||||||
$scope.pendingCreation = false;
|
$scope.pendingCreation = false;
|
||||||
growl.error(_t('app.admin.invoices.failed_to_close_period'));
|
growl.error(_t('app.admin.invoices.failed_to_close_period'));
|
||||||
$scope.errors = error.data;
|
$scope.errors = error.data;
|
||||||
@ -1159,7 +1157,6 @@ Application.Controllers.controller('ClosePeriodModalController', ['$scope', '$ui
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1170,147 +1167,145 @@ Application.Controllers.controller('ClosePeriodModalController', ['$scope', '$ui
|
|||||||
/**
|
/**
|
||||||
* Trigger the API call to download the JSON archive of the closed accounting period
|
* Trigger the API call to download the JSON archive of the closed accounting period
|
||||||
*/
|
*/
|
||||||
$scope.downloadArchive = function(period) {
|
$scope.downloadArchive = function (period) {
|
||||||
$window.location.href = `/api/accounting_periods/${period.id}/archive`;
|
$window.location.href = `/api/accounting_periods/${period.id}/archive`;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Application.Controllers.controller('AccountingExportModalController', ['$scope', '$uibModalInstance', 'Invoice', 'Export', 'CSRF', 'growl', '_t',
|
Application.Controllers.controller('AccountingExportModalController', ['$scope', '$uibModalInstance', 'Invoice', 'Export', 'CSRF', 'growl', '_t',
|
||||||
function ($scope, $uibModalInstance, Invoice, Export, CSRF, growl, _t) {
|
function ($scope, $uibModalInstance, Invoice, Export, CSRF, growl, _t) {
|
||||||
// Retrieve Anti-CSRF tokens from cookies
|
// Retrieve Anti-CSRF tokens from cookies
|
||||||
CSRF.setMetaTags();
|
CSRF.setMetaTags();
|
||||||
|
|
||||||
const SETTINGS = {
|
const SETTINGS = {
|
||||||
acd: {
|
acd: {
|
||||||
format: 'csv',
|
format: 'csv',
|
||||||
encoding: 'ISO-8859-1',
|
encoding: 'ISO-8859-1',
|
||||||
separator: ';',
|
separator: ';',
|
||||||
dateFormat: '%d/%m/%Y',
|
dateFormat: '%d/%m/%Y',
|
||||||
labelMaxLength: 50,
|
labelMaxLength: 50,
|
||||||
decimalSeparator: ',',
|
decimalSeparator: ',',
|
||||||
exportInvoicesAtZero: false,
|
exportInvoicesAtZero: false,
|
||||||
columns: ['journal_code', 'date', 'account_code', 'account_label', 'piece', 'line_label', 'debit_origin', 'credit_origin', 'debit_euro', 'credit_euro', 'lettering']
|
columns: ['journal_code', 'date', 'account_code', 'account_label', 'piece', 'line_label', 'debit_origin', 'credit_origin', 'debit_euro', 'credit_euro', 'lettering']
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* PUBLIC SCOPE */
|
/* PUBLIC SCOPE */
|
||||||
|
|
||||||
// API URL where the form will be posted
|
// API URL where the form will be posted
|
||||||
$scope.actionUrl = '/api/accounting/export';
|
$scope.actionUrl = '/api/accounting/export';
|
||||||
|
|
||||||
// Form action on the above URL
|
// Form action on the above URL
|
||||||
$scope.method = 'post';
|
$scope.method = 'post';
|
||||||
|
|
||||||
// Anti-CSRF token to inject into the download form
|
// Anti-CSRF token to inject into the download form
|
||||||
$scope.csrfToken = angular.element('meta[name="csrf-token"]')[0].content;
|
$scope.csrfToken = angular.element('meta[name="csrf-token"]')[0].content;
|
||||||
|
|
||||||
// API request body to generate the export
|
// API request body to generate the export
|
||||||
$scope.query = null;
|
$scope.query = null;
|
||||||
|
|
||||||
// binding to radio button "export to"
|
// binding to radio button "export to"
|
||||||
$scope.exportTarget = {
|
$scope.exportTarget = {
|
||||||
software: null,
|
software: null,
|
||||||
startDate: null,
|
startDate: null,
|
||||||
endDate: null,
|
endDate: null,
|
||||||
settings: null
|
settings: null
|
||||||
};
|
};
|
||||||
|
|
||||||
// AngularUI-Bootstrap datepicker parameters to define export dates range
|
// AngularUI-Bootstrap datepicker parameters to define export dates range
|
||||||
$scope.datePicker = {
|
$scope.datePicker = {
|
||||||
format: Fablab.uibDateFormat,
|
format: Fablab.uibDateFormat,
|
||||||
opened: { // default: datePickers are not shown
|
opened: { // default: datePickers are not shown
|
||||||
start: false,
|
start: false,
|
||||||
end: false
|
end: false
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
startingDay: Fablab.weekStartingDay
|
startingDay: Fablab.weekStartingDay
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Date of the first invoice
|
// Date of the first invoice
|
||||||
$scope.firstInvoice = null;
|
$scope.firstInvoice = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate the export
|
* Validate the export
|
||||||
*/
|
*/
|
||||||
$scope.ok = function () {
|
$scope.ok = function () {
|
||||||
const statusQry = mkQuery();
|
const statusQry = mkQuery();
|
||||||
$scope.query = statusQry;
|
$scope.query = statusQry;
|
||||||
|
|
||||||
Export.status(statusQry).then(function (res) {
|
Export.status(statusQry).then(function (res) {
|
||||||
if (!res.data.exists) {
|
if (!res.data.exists) {
|
||||||
growl.success(_t('app.admin.invoices.export_is_running'));
|
growl.success(_t('app.admin.invoices.export_is_running'));
|
||||||
}
|
}
|
||||||
$uibModalInstance.close(res);
|
$uibModalInstance.close(res);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback to open/close one of the datepickers
|
* Callback to open/close one of the datepickers
|
||||||
* @param event {Object} see https://docs.angularjs.org/guide/expression#-event-
|
* @param event {Object} see https://docs.angularjs.org/guide/expression#-event-
|
||||||
* @param picker {string} start | end
|
* @param picker {string} start | end
|
||||||
*/
|
*/
|
||||||
$scope.toggleDatePicker = function(event, picker) {
|
$scope.toggleDatePicker = function (event, picker) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$scope.datePicker.opened[picker] = !$scope.datePicker.opened[picker];
|
$scope.datePicker.opened[picker] = !$scope.datePicker.opened[picker];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will fill the export settings, according to the selected software
|
* Will fill the export settings, according to the selected software
|
||||||
* @param software {String} must be one of SETTINGS.*
|
* @param software {String} must be one of SETTINGS.*
|
||||||
*/
|
*/
|
||||||
$scope.fillSettings = function(software) {
|
$scope.fillSettings = function (software) {
|
||||||
$scope.exportTarget.settings = SETTINGS[software];
|
$scope.exportTarget.settings = SETTINGS[software];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Just dismiss the modal window
|
* Just dismiss the modal window
|
||||||
*/
|
*/
|
||||||
$scope.cancel = function () { $uibModalInstance.dismiss('cancel'); };
|
$scope.cancel = function () { $uibModalInstance.dismiss('cancel'); };
|
||||||
|
|
||||||
/* PRIVATE SCOPE */
|
/* PRIVATE SCOPE */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kind of constructor: these actions will be realized first when the controller is loaded
|
* Kind of constructor: these actions will be realized first when the controller is loaded
|
||||||
*/
|
*/
|
||||||
const initialize = function () {
|
const initialize = function () {
|
||||||
// if the invoice was payed with stripe, allow to refund through stripe
|
// if the invoice was payed with stripe, allow to refund through stripe
|
||||||
Invoice.first(function (data) {
|
Invoice.first(function (data) {
|
||||||
$scope.firstInvoice = data.date;
|
$scope.firstInvoice = data.date;
|
||||||
$scope.exportTarget.startDate = data.date;
|
$scope.exportTarget.startDate = data.date;
|
||||||
$scope.exportTarget.endDate = moment().toISOString();
|
$scope.exportTarget.endDate = moment().toISOString();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare the query for the export API
|
* Prepare the query for the export API
|
||||||
* @returns {{extension: *, query: *, category: string, type: *, key: *}}
|
* @returns {{extension: *, query: *, category: string, type: *, key: *}}
|
||||||
*/
|
*/
|
||||||
const mkQuery = function() {
|
const mkQuery = function () {
|
||||||
return {
|
return {
|
||||||
category: 'accounting',
|
category: 'accounting',
|
||||||
type: $scope.exportTarget.software,
|
type: $scope.exportTarget.software,
|
||||||
extension: $scope.exportTarget.settings.format,
|
extension: $scope.exportTarget.settings.format,
|
||||||
key: $scope.exportTarget.settings.separator,
|
key: $scope.exportTarget.settings.separator,
|
||||||
query: JSON.stringify({
|
query: JSON.stringify({
|
||||||
columns: $scope.exportTarget.settings.columns,
|
columns: $scope.exportTarget.settings.columns,
|
||||||
encoding: $scope.exportTarget.settings.encoding,
|
encoding: $scope.exportTarget.settings.encoding,
|
||||||
date_format: $scope.exportTarget.settings.dateFormat,
|
date_format: $scope.exportTarget.settings.dateFormat,
|
||||||
start_date: $scope.exportTarget.startDate,
|
start_date: $scope.exportTarget.startDate,
|
||||||
end_date: $scope.exportTarget.endDate,
|
end_date: $scope.exportTarget.endDate,
|
||||||
label_max_length: $scope.exportTarget.settings.labelMaxLength,
|
label_max_length: $scope.exportTarget.settings.labelMaxLength,
|
||||||
decimal_separator: $scope.exportTarget.settings.decimalSeparator,
|
decimal_separator: $scope.exportTarget.settings.decimalSeparator,
|
||||||
export_invoices_at_zero: $scope.exportTarget.settings.exportInvoicesAtZero
|
export_invoices_at_zero: $scope.exportTarget.settings.exportInvoicesAtZero
|
||||||
})
|
})
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
// !!! MUST BE CALLED AT THE END of the controller
|
|
||||||
return initialize();
|
|
||||||
}]);
|
|
||||||
|
|
||||||
|
|
||||||
|
// !!! MUST BE CALLED AT THE END of the controller
|
||||||
|
return initialize();
|
||||||
|
}]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller used in the modal window allowing an admin to close an accounting period
|
* Controller used in the modal window allowing an admin to close an accounting period
|
||||||
@ -1343,15 +1338,14 @@ Application.Controllers.controller('StripeKeysModalController', ['$scope', '$uib
|
|||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: 'https://api.stripe.com/v1/charges',
|
url: 'https://api.stripe.com/v1/charges',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${$scope.secretKey}`,
|
Authorization: `Bearer ${$scope.secretKey}`
|
||||||
}
|
}
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
$scope.secretKeyStatus = true;
|
$scope.secretKeyStatus = true;
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err.status === 401) $scope.secretKeyStatus = false;
|
if (err.status === 401) $scope.secretKeyStatus = false;
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trigger the test of the secret key and set the result in $scope.secretKeyStatus
|
* Trigger the test of the secret key and set the result in $scope.secretKeyStatus
|
||||||
@ -1370,14 +1364,14 @@ Application.Controllers.controller('StripeKeysModalController', ['$scope', '$uib
|
|||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
},
|
},
|
||||||
data: $httpParamSerializerJQLike({
|
data: $httpParamSerializerJQLike({
|
||||||
'pii[id_number]': 'test',
|
'pii[id_number]': 'test'
|
||||||
})
|
})
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
$scope.publicKeyStatus = true;
|
$scope.publicKeyStatus = true;
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err.status === 401) $scope.publicKeyStatus = false;
|
if (err.status === 401) $scope.publicKeyStatus = false;
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate the keys
|
* Validate the keys
|
||||||
@ -1385,7 +1379,8 @@ Application.Controllers.controller('StripeKeysModalController', ['$scope', '$uib
|
|||||||
$scope.ok = function () {
|
$scope.ok = function () {
|
||||||
if ($scope.secretKeyStatus && $scope.publicKeyStatus) {
|
if ($scope.secretKeyStatus && $scope.publicKeyStatus) {
|
||||||
Setting.bulkUpdate(
|
Setting.bulkUpdate(
|
||||||
{ settings: [
|
{
|
||||||
|
settings: [
|
||||||
{
|
{
|
||||||
name: 'stripe_public_key',
|
name: 'stripe_public_key',
|
||||||
value: $scope.publicKey
|
value: $scope.publicKey
|
||||||
@ -1394,7 +1389,8 @@ Application.Controllers.controller('StripeKeysModalController', ['$scope', '$uib
|
|||||||
name: 'stripe_secret_key',
|
name: 'stripe_secret_key',
|
||||||
value: $scope.secretKey
|
value: $scope.secretKey
|
||||||
}
|
}
|
||||||
] },
|
]
|
||||||
|
},
|
||||||
function () {
|
function () {
|
||||||
growl.success(_t('app.admin.invoices.payment.stripe_keys_saved'));
|
growl.success(_t('app.admin.invoices.payment.stripe_keys_saved'));
|
||||||
$uibModalInstance.close(true);
|
$uibModalInstance.close(true);
|
||||||
@ -1405,7 +1401,7 @@ Application.Controllers.controller('StripeKeysModalController', ['$scope', '$uib
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
growl.error(_t('app.admin.invoices.payment.error_check_keys'))
|
growl.error(_t('app.admin.invoices.payment.error_check_keys'));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
|
|||||||
$scope.calendarStyle = function (calendar) {
|
$scope.calendarStyle = function (calendar) {
|
||||||
return {
|
return {
|
||||||
'border-color': calendar.color,
|
'border-color': calendar.color,
|
||||||
'color': calendar.text_color
|
color: calendar.text_color
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
|
|||||||
|
|
||||||
$scope.openFilterAside = () =>
|
$scope.openFilterAside = () =>
|
||||||
$aside.open({
|
$aside.open({
|
||||||
template: require('../../../templates/filterAside.html'),
|
templateUrl: 'filterAside.html',
|
||||||
placement: 'right',
|
placement: 'right',
|
||||||
size: 'md',
|
size: 'md',
|
||||||
backdrop: false,
|
backdrop: false,
|
||||||
@ -148,8 +148,8 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
|
|||||||
$uibModalInstance.dismiss();
|
$uibModalInstance.dismiss();
|
||||||
return e.stopPropagation();
|
return e.stopPropagation();
|
||||||
};
|
};
|
||||||
}
|
}]
|
||||||
] });
|
});
|
||||||
|
|
||||||
/* PRIVATE SCOPE */
|
/* PRIVATE SCOPE */
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
|
|||||||
viewRender (view, element) {
|
viewRender (view, element) {
|
||||||
return viewRenderCb(view, element);
|
return viewRenderCb(view, element);
|
||||||
},
|
},
|
||||||
eventRender (event, element, view) {
|
eventRender (event, element) {
|
||||||
return eventRenderCb(event, element);
|
return eventRenderCb(event, element);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -194,7 +194,7 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
|
|||||||
/**
|
/**
|
||||||
* Callback triggered when an event object is clicked in the fullCalendar view
|
* Callback triggered when an event object is clicked in the fullCalendar view
|
||||||
*/
|
*/
|
||||||
const calendarEventClickCb = function (event, jsEvent, view) {
|
const calendarEventClickCb = function (event) {
|
||||||
// current calendar object
|
// current calendar object
|
||||||
const { calendar } = uiCalendarConfig.calendars;
|
const { calendar } = uiCalendarConfig.calendars;
|
||||||
if (event.available_type === 'machines') {
|
if (event.available_type === 'machines') {
|
||||||
@ -240,7 +240,7 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
|
|||||||
* This function is called when calendar view is rendered or changed
|
* This function is called when calendar view is rendered or changed
|
||||||
* @see https://fullcalendar.io/docs/v3/viewRender#v2
|
* @see https://fullcalendar.io/docs/v3/viewRender#v2
|
||||||
*/
|
*/
|
||||||
const viewRenderCb = function (view, element) {
|
const viewRenderCb = function (view) {
|
||||||
toggleSlotEventOverlap(view);
|
toggleSlotEventOverlap(view);
|
||||||
if (view.type === 'agendaDay') {
|
if (view.type === 'agendaDay') {
|
||||||
// get availabilties by 1 day for show machine slots
|
// get availabilties by 1 day for show machine slots
|
||||||
@ -255,7 +255,7 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
|
|||||||
const eventRenderCb = function (event, element) {
|
const eventRenderCb = function (event, element) {
|
||||||
if (event.tags && event.tags.length > 0) {
|
if (event.tags && event.tags.length > 0) {
|
||||||
let html = '';
|
let html = '';
|
||||||
for (let tag of Array.from(event.tags)) {
|
for (const tag of Array.from(event.tags)) {
|
||||||
html += `<span class='label label-success text-white'>${tag.name}</span> `;
|
html += `<span class='label label-success text-white'>${tag.name}</span> `;
|
||||||
}
|
}
|
||||||
element.find('.fc-title').append(`<br/>${html}`);
|
element.find('.fc-title').append(`<br/>${html}`);
|
||||||
@ -269,7 +269,7 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
|
|||||||
return { t, m, s, evt: $scope.filter.evt, dispo: $scope.filter.dispo };
|
return { t, m, s, evt: $scope.filter.evt, dispo: $scope.filter.dispo };
|
||||||
};
|
};
|
||||||
|
|
||||||
var availabilitySourceUrl = () => `/api/availabilities/public?${$.param(getFilter())}`;
|
const availabilitySourceUrl = () => `/api/availabilities/public?${$.param(getFilter())}`;
|
||||||
|
|
||||||
// !!! MUST BE CALLED AT THE END of the controller
|
// !!! MUST BE CALLED AT THE END of the controller
|
||||||
return initialize();
|
return initialize();
|
||||||
|
@ -29,22 +29,22 @@ Application.Directives.directive('selectMultipleSetting', ['Setting', 'growl', '
|
|||||||
/**
|
/**
|
||||||
* Remove the items in the selection from the options and update setting.value
|
* Remove the items in the selection from the options and update setting.value
|
||||||
*/
|
*/
|
||||||
$scope.removeItem = function() {
|
$scope.removeItem = function () {
|
||||||
const options = $scope.options.filter(function (opt) {
|
const options = $scope.options.filter(function (opt) {
|
||||||
return $scope.selection.indexOf(opt) < 0;
|
return $scope.selection.indexOf(opt) < 0;
|
||||||
})
|
});
|
||||||
$scope.options = options;
|
$scope.options = options;
|
||||||
$scope.setting.value = options.join(' ');
|
$scope.setting.value = options.join(' ');
|
||||||
growl.success(_t('app.admin.settings.COUNT_items_removed', { COUNT: $scope.selection.length }));
|
growl.success(_t('app.admin.settings.COUNT_items_removed', { COUNT: $scope.selection.length }));
|
||||||
$scope.selection = [];
|
$scope.selection = [];
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a modal dialog asking for the value of a new item to add
|
* Open a modal dialog asking for the value of a new item to add
|
||||||
*/
|
*/
|
||||||
$scope.addItem = function() {
|
$scope.addItem = function () {
|
||||||
$uibModal.open({
|
$uibModal.open({
|
||||||
template: require('../../../../templates/newSelectOption.html'),
|
templateUrl: 'newSelectOption.html',
|
||||||
resolve: {
|
resolve: {
|
||||||
titleNew: function () { return $scope.titleNew; },
|
titleNew: function () { return $scope.titleNew; },
|
||||||
descriptionNew: function () { return $scope.descriptionNew; }
|
descriptionNew: function () { return $scope.descriptionNew; }
|
||||||
@ -60,7 +60,7 @@ Application.Directives.directive('selectMultipleSetting', ['Setting', 'growl', '
|
|||||||
$uibModalInstance.dismiss('cancel');
|
$uibModalInstance.dismiss('cancel');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}).result['finally'](null).then(function(val) {
|
}).result.finally(null).then(function (val) {
|
||||||
const options = Array.from($scope.options);
|
const options = Array.from($scope.options);
|
||||||
if (typeof $scope.beforeAdd === 'function') { val = $scope.beforeAdd(val); }
|
if (typeof $scope.beforeAdd === 'function') { val = $scope.beforeAdd(val); }
|
||||||
options.push(val);
|
options.push(val);
|
||||||
@ -68,14 +68,14 @@ Application.Directives.directive('selectMultipleSetting', ['Setting', 'growl', '
|
|||||||
$scope.setting.value = options.join(' ');
|
$scope.setting.value = options.join(' ');
|
||||||
growl.success(_t('app.admin.settings.item_added'));
|
growl.success(_t('app.admin.settings.item_added'));
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback to save the setting value to the database
|
* Callback to save the setting value to the database
|
||||||
* @param setting {{value:*, name:string}} note that the value will be stringified
|
* @param setting {{value:*, name:string}} note that the value will be stringified
|
||||||
*/
|
*/
|
||||||
$scope.save = function (setting) {
|
$scope.save = function (setting) {
|
||||||
let { value } = setting;
|
const { value } = setting;
|
||||||
|
|
||||||
Setting.update(
|
Setting.update(
|
||||||
{ name: setting.name },
|
{ name: setting.name },
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
// TODO remove unused?
|
// TODO remove unused?
|
||||||
(function (angular) {
|
(function (angular) {
|
||||||
var deviseModal = angular.module('DeviseModal', [
|
const deviseModal = angular.module('DeviseModal', [
|
||||||
'Devise',
|
'Devise',
|
||||||
'ui.bootstrap'
|
'ui.bootstrap'
|
||||||
]);
|
]);
|
||||||
deviseModal.run([
|
deviseModal.run([
|
||||||
'$uibModal',
|
'$uibModal',
|
||||||
'$http',
|
'$http',
|
||||||
@ -12,25 +12,25 @@
|
|||||||
'$rootScope',
|
'$rootScope',
|
||||||
function ($uibModal, $http, Auth, $rootScope) {
|
function ($uibModal, $http, Auth, $rootScope) {
|
||||||
var promise = null;
|
var promise = null;
|
||||||
function reset() {
|
function reset () {
|
||||||
promise = null;
|
promise = null;
|
||||||
}
|
}
|
||||||
function partial(fn, arg) {
|
function partial (fn, arg) {
|
||||||
return function () {
|
return function () {
|
||||||
return fn.call(this, arg);
|
return fn.call(this, arg);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
$rootScope.$on('devise:unauthorized', function (event, response, deferred) {
|
$rootScope.$on('devise:unauthorized', function (event, response, deferred) {
|
||||||
function retryRequestAfterLogin() {
|
function retryRequestAfterLogin () {
|
||||||
return promise.then(function () {
|
return promise.then(function () {
|
||||||
return $http(response.config);
|
return $http(response.config);
|
||||||
}).then(deferred.resolve, partial(deferred.reject, response));
|
}).then(deferred.resolve, partial(deferred.reject, response));
|
||||||
}
|
}
|
||||||
if (!promise) {
|
if (!promise) {
|
||||||
promise = $uibModal.open({
|
promise = $uibModal.open({
|
||||||
template: require('../../../templates/deviseModal.html'),
|
templateUrl: 'deviseModal.html',
|
||||||
controller: function ($scope, $uibModalInstance) {
|
controller: function ($scope, $uibModalInstance) {
|
||||||
var user = $scope.user = {};
|
const user = $scope.user = {};
|
||||||
$scope.login = function () {
|
$scope.login = function () {
|
||||||
$uibModalInstance.close(user);
|
$uibModalInstance.close(user);
|
||||||
};
|
};
|
||||||
@ -38,7 +38,7 @@
|
|||||||
$uibModalInstance.dismiss('cancel');
|
$uibModalInstance.dismiss('cancel');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}).result['finally'](reset).then(Auth.login);
|
}).result.finally(reset).then(Auth.login);
|
||||||
}
|
}
|
||||||
retryRequestAfterLogin();
|
retryRequestAfterLogin();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user