diff --git a/controllers/booking.py b/controllers/booking.py index b989d13..6aab257 100755 --- a/controllers/booking.py +++ b/controllers/booking.py @@ -41,6 +41,9 @@ class booking(WebsiteEventController,AuthSignupHome): event=request.env['event.event'].sudo().search([('id','=',int(event_id))]) data['event']=event + request.session['individual_booking_event']=event.individual_booking_event + + data['status']=partner.member_status @@ -114,6 +117,20 @@ class booking(WebsiteEventController,AuthSignupHome): vals['gender']=post.get('gender') vals['mobile']=post.get('mobile') + #individual booking data + if request.session['individual_booking_event']: + s=post.get('start_day').split('/') + start_day=s[2]+'-'+s[1]+'-'+s[0] + + e=post.get('end_day').split('/') + end_day=e[2]+'-'+e[1]+'-'+e[0] + + + vals['start_day_individual_booking']=start_day + vals['end_day_individual_booking']=end_day + vals['days_duration']=post.get('days_duration') + vals['price_individual_booking']=post.get('price_individual_booking') + request.session['registrant'] = vals request.session['down_payment'] =False if post.get('down_payment')=="false":request.session['down_payment'] = False @@ -143,7 +160,7 @@ class booking(WebsiteEventController,AuthSignupHome): data['questions']=False if event.question_ids: data['questions']=event.question_ids - #return vals3 + return http.request.render('kalachakra.booking_registration_questionnaire_form',data) @http.route(['/booking/payment_choice'], type='http',auth='user', website=True, sitemap=False,csrf=False) @@ -171,6 +188,13 @@ class booking(WebsiteEventController,AuthSignupHome): vals['down_payment']=request.session['down_payment'] vals['state']='draft' + if request.session['individual_booking_event']: + vals['start_day_individual_booking']=request.session['registrant']['start_day_individual_booking'] + vals['end_day_individual_booking']=request.session['registrant']['end_day_individual_booking'] + vals['days_duration']=request.session['registrant']['days_duration'] + vals['price_individual_booking']=request.session['registrant']['price_individual_booking'] + + res=request.env['event.registration'].sudo().create(vals) request.session['res_id']=res.id diff --git a/models/booking_event_registration.py b/models/booking_event_registration.py index ac7f868..e26ba72 100755 --- a/models/booking_event_registration.py +++ b/models/booking_event_registration.py @@ -100,8 +100,12 @@ class EventRegistration(models.Model): to_be_paid_amount=fields.Monetary('to be paid amount',compute='_compute_to_be_paid_amount',currency_field='currency_id') payment_adjustement=fields.Monetary('payment adjustement',currency_field='currency_id') individual_room=fields.Boolean('Individual room',compute='compute_individual_room') + + #individual booking fields start_day_individual_booking=fields.Date('Start day individual booking') end_day_individual_booking=fields.Date('End day individual booking') + days_duration=fields.Integer('duration in days') + price_individual_booking=fields.Monetary('price individual booking',currency_field='currency_id') def compute_individual_room(self): @@ -332,30 +336,33 @@ class EventRegistration(models.Model): else: status='not member' + if event.individual_booking_event: + product_price=reg.price_individual_booking + else: + + product_price=event.booking_price + if status=='not member':product_price=event.booking_price + if status=='member':product_price=event.booking_member_price + if status=='super member':product_price=event.booking_super_member_price - product_price=event.booking_price - if status=='not member':product_price=event.booking_price - if status=='member':product_price=event.booking_member_price - if status=='super member':product_price=event.booking_super_member_price - - #Prix à appliquer au produit si paiement de l'adhésion - membership_option=False - #membership_product=self.env['event.membership_product'].search([]) - membership_product=self.env['product.product'].sudo().search([('membership_product','=',True)],limit=1) - - if membership_product: - if selected_registrant_options: - for opt in selected_registrant_options: - #raise Warning("opt.booking_option_id="+str(opt.booking_option_id.id)+" membership_product.id="+str(membership_product.id)) - if opt.booking_option_id.id==membership_product.id: - membership_option=True - - if status!="super member": - product_price=event.booking_member_price + #Prix à appliquer au produit si paiement de l'adhésion + membership_option=False + #membership_product=self.env['event.membership_product'].search([]) + membership_product=self.env['product.product'].sudo().search([('membership_product','=',True)],limit=1) + + if membership_product: + if selected_registrant_options: + for opt in selected_registrant_options: + #raise Warning("opt.booking_option_id="+str(opt.booking_option_id.id)+" membership_product.id="+str(membership_product.id)) + if opt.booking_option_id.id==membership_product.id: + membership_option=True - if self.payment_adjustement!=0: - product_price=product_price+self.payment_adjustement - + if status!="super member": + product_price=event.booking_member_price + + if self.payment_adjustement!=0: + product_price=product_price+self.payment_adjustement + #calcul du montant total à régler if end_of_stay_invoice:product_price=0 @@ -407,7 +414,10 @@ class EventRegistration(models.Model): vals['product_id']=int(event.booking_product_id) vals['quantity']=1 vals['price_unit']=product_price - vals['name']=event.booking_product_id.name + if event.individual_booking_event: + vals['name']=event.booking_product_id.name+' du '+str(reg.start_day_individual_booking)+' au '+str(reg.end_day_individual_booking)+ ' - '+str(reg.days_duration)+' jours' + else: + vals['name']=event.booking_product_id.name vals['account_id']=int(account_credit.id) @@ -500,7 +510,7 @@ class EventRegistration(models.Model): else: reg.end_of_stay_invoice_id=invoice.id - user=self.env['res.users'].search([('email','ilike',reg.partner_id.email)]) + user=self.env['res.users'].search([('email','ilike',reg.partner_id.email)],limit=1) invoice.invoice_user_id=user.id invoice.user_id=user.id @@ -550,8 +560,20 @@ class EventRegistration(models.Model): vals['move_id']=invoice.id vals['product_id']=int(event.booking_product_id) vals['quantity']=1 - vals['price_unit']=event.booking_down_payment - vals['name']='Acompte '+event.booking_product_id.name + + if event.individual_booking_event: + if product_price100) + { + + return 'les dates saisies ne sont pas correctes' + + } + html_days_message='Soit '+diff.toString()+' 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() + + $("#days_duration").val(diff) + + + + return true + } + function parseDate(str) { + var d = str.split('/'); + var date1=d[0]+'-'+d[1]+'-'+d[2] + var m = date1.match(/^(\d{1,2})-(\d{1,2})-(\d{4})$/); + return (m) ? -1 : null; + } + + function compute_individual_booking_prices_without_option(days) + { + mod_days=days%7 + if (days<7) + { + + $("#booking_price").val(days*$("#individual_day_price").val()) + $("#booking_member_price").val(days*$("#individual_member_day_price").val()) + $("#booking_super_member_price").val(days*$("#individual_super_member_day_price").val()) + + + + } + 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()) + + } + if (days<22 && 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()) + + } + if (days>21) + { + 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()) + + } + + + } + function compute_total_price_from_status_without_options() + { + //recalcul du prix total selon le status + if ($("#status2").val()=='not member') + { + + $("#total_price").val($("#booking_price").val()) + $("#price_individual_booking").val($("#booking_price").val()) + } + if ($("#status2").val()=='member') + { + + $("#total_price").val($("#booking_member_price").val()) + $("#price_individual_booking").val($("#booking_member_price").val()) + } + if ($("#status2").val()=='super member') + { + + $("#total_price").val($("#booking_super_member_price").val()) + $("#price_individual_booking").val($("#booking_super_member_price").val()) + } + + } + + function compute_total_price_with_options() + { + $( ":checkbox" ).each(function( index ) { + var l=this.name.length + var i=this.name.substring(2,l-1) + + if (this.value==$("#membership_product").val()) + { + var option_price_str='#o_standard'+i + } + else + { + if ($("#status2").val()=='not member') + { + var option_price_str='#o_standard'+i + } + else + { + var option_price_str='#o_'+$("#status2").val()+i + } + + } + + + option_price=$(option_price_str).val() + if (!option_price) option_price=0 + console.log(option_price_str+'='+option_price) + total_price=$("#total_price").val() + + if(this.checked) { + + $("#total_price").val(parseInt(total_price)+parseInt(option_price)) + console.log($("#total_price").val()) + + } + + }); + + $("#booking_total_price").text($("#total_price").val()+' €'); + console.log( 'total price final='+$("#booking_total_price").text()) + console.log('end debug price') + + } $( "#medical_concern" ).change(function() { if (this.value=='have medical concern') @@ -129,8 +319,8 @@ odoo.define('booking.main', function (require) { }); $(":checkbox").change(function() { - console.log('start debug price') - console.log('status:'+$("#status").val()) + //console.log('start debug price') + //console.log('status:'+$("#status").val()) //si coche adhésion alors le statut devient membre if(this.value==$("#membership_product").val() && this.checked) { @@ -148,68 +338,12 @@ odoo.define('booking.main', function (require) { console.log('status2:'+$("#status2").val()) - - //recalcul du prix total selon le status - if ($("#status2").val()=='not member') - { - - $("#your_status").text('non adhérent') - - $("#price_of_the_stay").text($("#booking_price").val()+' €') - $("#total_price").val($("#booking_price").val()) - } - if ($("#status2").val()=='member') - { - $("#your_status").text('adhérent') - $("#price_of_the_stay").text($("#booking_member_price").val()+' €') - $("#total_price").val($("#booking_member_price").val()) - } - if ($("#status2").val()=='super member') - { - $("#your_status").text('Adhérent de soutien') - $("#price_of_the_stay").text($("#booking_super_member_price").val()+' €') - $("#total_price").val($("#booking_super_member_price").val()) - } + compute_total_price_from_status_without_options() + compute_total_price_with_options() - $( ":checkbox" ).each(function( index ) { - var l=this.name.length - var i=this.name.substring(2,l-1) - - if (this.value==$("#membership_product").val()) - { - var option_price_str='#o_standard'+i - } - else - { - if ($("#status2").val()=='not member') - { - var option_price_str='#o_standard'+i - } - else - { - var option_price_str='#o_'+$("#status2").val()+i - } - - } - - - option_price=$(option_price_str).val() - if (!option_price) option_price=0 - console.log(option_price_str+'='+option_price) - total_price=$("#total_price").val() - - if(this.checked) { - - $("#total_price").val(parseInt(total_price)+parseInt(option_price)) - console.log($("#total_price").val()) - - } - - }); + - $("#booking_total_price").text($("#total_price").val()+' €'); - console.log( 'total price final='+$("#booking_total_price").text()) - console.log('end debug price') + }); diff --git a/views/booking_website_registration.xml b/views/booking_website_registration.xml index 2f49746..f43ea4c 100755 --- a/views/booking_website_registration.xml +++ b/views/booking_website_registration.xml @@ -37,6 +37,7 @@
+
Registering to :


From to
@@ -77,28 +78,11 @@ de séjour en solitaire. - -
Total Price :
- - -
-
- -
- -
-
-
+ -

- + + +
Dates souhaitées :
+ name="start_day" id="start_day" value="" />
+ name="end_day" id="end_day" value="" />
+
+
Total Price :
+ + +
+
+ +
+ +
+
+
+ +

+
Please select your booking options :


@@ -151,6 +157,27 @@ de séjour en solitaire. + + + + + + + + + + + + + + + + + + + + +