|
|
@ -1,5 +1,7 @@ |
|
|
|
odoo.define('booking.main', function (require) { |
|
|
|
|
|
|
|
var core = require('web.core'); |
|
|
|
var QWeb = core.qweb; |
|
|
|
var _t = core._t; |
|
|
|
|
|
|
|
$(document).ready(function() { |
|
|
|
|
|
|
@ -65,26 +67,58 @@ odoo.define('booking.main', function (require) { |
|
|
|
|
|
|
|
function fct_days() |
|
|
|
{ |
|
|
|
var s = $("#start_day").val().split('/'); |
|
|
|
var e = $("#end_day").val().split('/'); |
|
|
|
var end_day=e[2]+'-'+e[1]+'-'+e[0] |
|
|
|
var start_day=s[2]+'-'+s[1]+'-'+s[0] |
|
|
|
// var s = $("#start_day").val().split('/');
|
|
|
|
// var e = $("#end_day").val().split('/');
|
|
|
|
// var end_day=e[2]+'-'+e[1]+'-'+e[0]
|
|
|
|
// var start_day=s[2]+'-'+s[1]+'-'+s[0]
|
|
|
|
|
|
|
|
var diff = Math.floor((Date.parse(end_day) - Date.parse(start_day)) / 86400000)+1; |
|
|
|
if (diff<0 || diff>100) |
|
|
|
var diff = Math.floor((Date.parse($("#end_day").val()) - Date.parse($("#start_day").val())) / 86400000)+1; |
|
|
|
console.log(diff) |
|
|
|
var start_date = Date.parse($("#start_day").val()) |
|
|
|
var end_date = Date.parse($("#end_day").val()) |
|
|
|
var start_date_p1month=start_date.addMonths(1) |
|
|
|
diff1=end_date-start_date_p1month |
|
|
|
|
|
|
|
if (diff<=0) |
|
|
|
{ |
|
|
|
$("#days").html(_t('Les dates saisies ne sont pas valides')) |
|
|
|
$("#booking_total_price").hide() |
|
|
|
$("#continue_button").hide() |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
else if (end_date>start_date_p1month) |
|
|
|
{ |
|
|
|
|
|
|
|
$("#days").html(_t('Pour les retraites de plus d\'un mois, veuillez contacter le centre à l\'adresse suivante :<br>info@centre-kalachakra.net')) |
|
|
|
$("#booking_total_price").hide() |
|
|
|
$("#continue_button").hide() |
|
|
|
|
|
|
|
} |
|
|
|
else if (diff1==0) |
|
|
|
{ |
|
|
|
|
|
|
|
return 'les dates saisies ne sont pas correctes' |
|
|
|
$("#days").html(_t('soit 1 mois')) |
|
|
|
$("#booking_total_price").show() |
|
|
|
$("#continue_button").show() |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
html_days_message='Soit '+diff.toString()+' jours' |
|
|
|
else |
|
|
|
{ |
|
|
|
html_days_message=_t('soit ')+diff.toString()+_t(' jours') |
|
|
|
console.log(html_days_message) |
|
|
|
$("#days").html(html_days_message) |
|
|
|
compute_individual_booking_prices_without_option(diff) |
|
|
|
compute_total_price_from_status_without_options() |
|
|
|
compute_total_price_with_options() |
|
|
|
$("#booking_total_price").show() |
|
|
|
$("#continue_button").show() |
|
|
|
|
|
|
|
$("#days_duration").val(diff) |
|
|
|
|
|
|
|
} |
|
|
|
compute_individual_booking_prices_without_option(diff,start_day,end_day) |
|
|
|
compute_total_price_from_status_without_options() |
|
|
|
compute_total_price_with_options() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -97,9 +131,17 @@ odoo.define('booking.main', function (require) { |
|
|
|
return (m) ? -1 : null; |
|
|
|
} |
|
|
|
|
|
|
|
function compute_individual_booking_prices_without_option(days) |
|
|
|
function compute_individual_booking_prices_without_option(days,start_day,end_day) |
|
|
|
{ |
|
|
|
mod_days=days%7 |
|
|
|
let coef_price=1+mod_days/7 |
|
|
|
|
|
|
|
|
|
|
|
var start_date = Date.parse($("#start_day").val()) |
|
|
|
var end_date = Date.parse($("#end_day").val()) |
|
|
|
var start_date_p1month=start_date.addMonths(1) |
|
|
|
diff1=end_date-start_date_p1month |
|
|
|
|
|
|
|
if (days<7) |
|
|
|
{ |
|
|
|
|
|
|
@ -112,30 +154,54 @@ odoo.define('booking.main', function (require) { |
|
|
|
} |
|
|
|
if (days<14 && days>6) |
|
|
|
{ |
|
|
|
mod_days=days%7 |
|
|
|
// console.log('booking_price'+mod_days*$("#individual_day_price").val())
|
|
|
|
$("#booking_price").val(parseInt($("#individual_week_price").val(),10)+mod_days*$("#individual_day_price").val()) |
|
|
|
$("#booking_member_price").val(parseInt($("#individual_member_week_price").val(),10)+mod_days*$("#individual_member_day_price").val()) |
|
|
|
$("#booking_super_member_price").val(parseInt($("#individual_super_member_week_price").val(),10)+mod_days*$("#individual_super_member_day_price").val()) |
|
|
|
|
|
|
|
|
|
|
|
price_not_member=Math.round(parseInt($("#individual_week_price").val(),10)*coef_price) |
|
|
|
price_member=Math.round(parseInt($("#individual_member_week_price").val(),10)*coef_price) |
|
|
|
price_super_member=Math.round(parseInt($("#individual_super_member_week_price").val(),10)*coef_price) |
|
|
|
|
|
|
|
$("#booking_price").val(price_not_member) |
|
|
|
$("#booking_member_price").val(price_member) |
|
|
|
$("#booking_super_member_price").val(price_super_member) |
|
|
|
|
|
|
|
} |
|
|
|
if (days<22 && days>13) |
|
|
|
if (days<21 && days>13) |
|
|
|
{ |
|
|
|
mod_days=days%14 |
|
|
|
// console.log('booking_price'+mod_days*$("#individual_day_price").val())
|
|
|
|
$("#booking_price").val(parseInt($("#individual_2weeks_price").val(),10)+mod_days*$("#individual_day_price").val()) |
|
|
|
$("#booking_member_price").val(parseInt($("#individual_member_2weeks_price").val(),10)+mod_days*$("#individual_member_day_price").val()) |
|
|
|
$("#booking_super_member_price").val(parseInt($("#individual_super_member_2weeks_price").val(),10)+mod_days*$("#individual_super_member_day_price").val()) |
|
|
|
price_not_member=Math.round(parseInt($("#individual_2weeks_price").val(),10)*coef_price) |
|
|
|
price_member=Math.round(parseInt($("#individual_member_2weeks_price").val(),10)*coef_price) |
|
|
|
price_super_member=Math.round(parseInt($("#individual_super_member_2weeks_price").val(),10)*coef_price) |
|
|
|
|
|
|
|
$("#booking_price").val(price_not_member) |
|
|
|
$("#booking_member_price").val(price_member) |
|
|
|
$("#booking_super_member_price").val(price_super_member) |
|
|
|
|
|
|
|
} |
|
|
|
if (days>21) |
|
|
|
|
|
|
|
if (days>20 && end_date<start_date_p1month) |
|
|
|
{ |
|
|
|
mod_days=days%21 |
|
|
|
// console.log('booking_price'+mod_days*$("#individual_day_price").val())
|
|
|
|
$("#booking_price").val(parseInt($("#individual_3weeks_price").val(),10)+mod_days*$("#individual_day_price").val()) |
|
|
|
$("#booking_member_price").val(parseInt($("#individual_member_3weeks_price").val(),10)+mod_days*$("#individual_member_day_price").val()) |
|
|
|
$("#booking_super_member_price").val(parseInt($("#individual_super_member_3weeks_price").val(),10)+mod_days*$("#individual_super_member_day_price").val()) |
|
|
|
|
|
|
|
price_not_member=Math.round(parseInt($("#individual_3weeks_price").val(),10)*coef_price) |
|
|
|
price_member=Math.round(parseInt($("#individual_member_3weeks_price").val(),10)*coef_price) |
|
|
|
price_super_member=Math.round(parseInt($("#individual_super_member_3weeks_price").val(),10)*coef_price) |
|
|
|
|
|
|
|
$("#booking_price").val(price_not_member) |
|
|
|
$("#booking_member_price").val(price_member) |
|
|
|
$("#booking_super_member_price").val(price_super_member) |
|
|
|
|
|
|
|
} |
|
|
|
if (diff1==0) |
|
|
|
{ |
|
|
|
$("#booking_price").val(parseInt($("#individual_month_price").val(),10)) |
|
|
|
$("#booking_member_price").val(parseInt($("#individual_member_month_price").val(),10)) |
|
|
|
$("#booking_super_member_price").val(parseInt($("#individual_super_member_month_price").val(),10)) |
|
|
|
|
|
|
|
} |
|
|
|
if (end_date>start_date_p1month) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|