Browse Source

retraite individuelle

dev-rcn
root 3 years ago
parent
commit
92dc2abf67
4 changed files with 359 additions and 120 deletions
  1. +25
    -1
      controllers/booking.py
  2. +85
    -31
      models/booking_event_registration.py
  3. +199
    -65
      static/js/booking.js
  4. +50
    -23
      views/booking_website_registration.xml

+ 25
- 1
controllers/booking.py View File

@ -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


+ 85
- 31
models/booking_event_registration.py View File

@ -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_price<event.booking_down_payment:
vals['price_unit']=product_price
else:
vals['price_unit']=event.booking_down_payment
vals['name']='Acompte '+event.booking_product_id.name+' du '+str(reg.start_day_individual_booking)+' au '+str(reg.end_day_individual_booking)+ '- '+str(reg.days_duration)+' jour(s)'
else:
vals['price_unit']=event.booking_down_payment
vals['name']='Acompte '+event.booking_product_id.name
vals['account_id']=int(account_credit.id)
@ -561,7 +583,13 @@ class EventRegistration(models.Model):
# #debit_line
vals_d={}
vals_d['move_id']=invoice.id
vals_d['debit']=event.booking_down_payment
if event.individual_booking_event:
if product_price<event.booking_down_payment:
vals_d['debit']=product_price
else:
vals_d['debit']=event.booking_down_payment
else:
vals_d['debit']=event.booking_down_payment
vals_d['credit']=0
vals_d['date']=datetime.now()
vals_d['partner_id']=int(reg.partner_id)
@ -569,7 +597,14 @@ class EventRegistration(models.Model):
vals_d['name']='Acompte '+event.booking_product_id.name
vals_d['account_id']=int(account_debit.id)
vals_d['quantity']=1
vals_d['price_unit']=event.booking_down_payment
if event.individual_booking_event:
if product_price<event.booking_down_payment:
vals_d['price_unit']=product_price
else:
vals_d['price_unit']=event.booking_down_payment
else:
vals_d['price_unit']=event.booking_down_payment
vals_d['exclude_from_invoice_tab']=True
@ -604,7 +639,14 @@ class EventRegistration(models.Model):
vals['move_id']=invoice.id
vals['product_id']=int(event.booking_product_id)
vals['quantity']=1
vals['price_unit']=product_price-event.booking_down_payment
if event.individual_booking_event:
if product_price<event.booking_down_payment:
vals['price_unit']=0
else:
vals['price_unit']=product_price-event.booking_down_payment
else:
vals['price_unit']=product_price-event.booking_down_payment
vals['name']='solde '+event.booking_product_id.name
vals['account_id']=int(account_credit.id)
@ -631,7 +673,13 @@ class EventRegistration(models.Model):
# #debit_line
vals_d={}
vals_d['move_id']=invoice.id
vals_d['debit']=product_price-event.booking_down_payment
if event.individual_booking_event:
if product_price<event.booking_down_payment:
vals['debit']=0
else:
vals['debit']=product_price-event.booking_down_payment
else:
vals_d['debit']=product_price-event.booking_down_payment
vals_d['credit']=0
vals_d['date']=datetime.now()
vals_d['partner_id']=int(reg.partner_id)
@ -639,7 +687,13 @@ class EventRegistration(models.Model):
vals_d['name']='solde '+event.booking_product_id.name
vals_d['account_id']=int(account_debit.id)
vals_d['quantity']=1
vals_d['price_unit']=product_price-event.booking_down_payment
if event.individual_booking_event:
if product_price<event.booking_down_payment:
vals['price_unit']=0
else:
vals['price_unit']=product_price-event.booking_down_payment
else:
vals_d['price_unit']=product_price-event.booking_down_payment
vals_d['exclude_from_invoice_tab']=True


+ 199
- 65
static/js/booking.js View File

@ -3,20 +3,210 @@ odoo.define('booking.main', function (require) {
$(document).ready(function() {
$('#datetimepickerstart_day').datetimepicker({format: 'DD/MM/YYYY'});
$('#datetimepickerend_day').datetimepicker({format: 'DD/MM/YYYY'});
$('#datetimepickerstart_day').datetimepicker({
format: 'DD/MM/YYYY',
enableOnReadonly: true
});
$('#datetimepickerend_day').datetimepicker({
format: 'DD/MM/YYYY',
enableOnReadonly: true
});
$('#medical_info').hide()
$('#booking_total_price').text(
$('#booking_price_product').val()+' €'
);
//$( "#continue_button2").unbind( "click" );
});
$( "#start_day").on("input", function(e) {
//alert(parseDate($("#start_day").val()))
if (parseDate($("#start_day").val())==-1 && parseDate($("#end_day").val())==-1)
{
console.log('end_day_change')
console.log('start_day='+$("#start_day").val())
console.log('end_day='+$("#end_day").val())
console.log(parseDate($("#start_day").val()))
console.log(parseDate($("#end_day").val()))
fct_days()
}
else
{
$("#days").html()
}
});
$( "#end_day").on("input", function(e) {
if (parseDate($("#end_day").val())==-1 && parseDate($("#start_day").val())==-1)
{
console.log('end_day_change')
console.log('start_day='+$("#start_day").val())
console.log('end_day='+$("#end_day").val())
console.log(parseDate($("#start_day").val()))
console.log(parseDate($("#end_day").val()))
fct_days()
}
else
{
$("#days").html()
}
});
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 diff = Math.floor((Date.parse(end_day) - Date.parse(start_day)) / 86400000)+1;
if (diff<0 || diff>100)
{
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')
});


+ 50
- 23
views/booking_website_registration.xml View File

@ -37,6 +37,7 @@
<t t-call="website.layout">
<div class="container-fluid">
<form id="form1" action="questionnaire" method="post" class="form js_website_submit_form">
<h6 style="display: inline">Registering to : </h6><h6 style="display: inline" t-esc="event.name"></h6>
<br></br>
<h6>From <span t-field="event.date_begin" t-options='{"format": "dd/mm/yyyy hh:mm"}'/> to <span t-field="event.date_end" t-options='{"format": "dd/MM/yyyy hh:mm"}'/> </h6>
@ -77,28 +78,11 @@ de séjour en solitaire.</b>
</tr>
</table>
</t>
<h6>Total Price : <span id="booking_total_price"></span></h6>
<form id="form1" action="questionnaire" method="post" class="form js_website_submit_form">
<div class="form-group s_website_form_field col- s_website_form_custom s_website_form_required " data-type="char" data-name="Field">
<div class="row s_col_no_resize s_col_no_bgcolor">
<label class="col-form-label col-sm-auto s_website_form_label" style="width: 400px">
<span class="s_website_form_label_content">Do you want to pay only the deposit </span><span style="display:inline" t-esc="'('+str(int(event.booking_down_payment))+' €) ?'"/>
</label>
<div class="col- col-sm- col-md-">
<select form="form1" id="down_payment" name="down_payment" class="form-control s_website_form_input">
<option name="yes" selected="true" value="true" label="Oui"></option>
<option name="no" value="false" label="Non"></option>
</select>
</div>
</div>
</div>
<br></br>
<t t-if="event.individual_booking_event">
</t>
<t t-if="event.individual_booking_event">
<h6>Dates souhaitées :</h6>
<div class="form-group">
<div class="input-group datetime"
@ -108,7 +92,7 @@ de séjour en solitaire.</b>
<input type="text" placeholder="Du"
class="form-control datetimepicker-input"
data-target="#datetimepickerstart_day"
name="start_day"/>
name="start_day" id="start_day" value="" />
</div>
<div class="input-group-append"
data-target="#datetimepickerstart_day"
@ -126,7 +110,7 @@ de séjour en solitaire.</b>
<input type="text" placeholder="Au"
class="form-control datetimepicker-input"
data-target="#datetimepickerend_day"
name="end_day"/>
name="end_day" id="end_day" value="" />
</div>
<div class="input-group-append"
data-target="#datetimepickerend_day"
@ -135,8 +119,30 @@ de séjour en solitaire.</b>
</div>
</div>
</div>
<h6><span color="red" id="days"/></h6>
</t>
<h6>Total Price : <span id="booking_total_price"></span></h6>
<div class="form-group s_website_form_field col- s_website_form_custom s_website_form_required " data-type="char" data-name="Field">
<div class="row s_col_no_resize s_col_no_bgcolor">
<label class="col-form-label col-sm-auto s_website_form_label" style="width: 400px">
<span class="s_website_form_label_content">Do you want to pay only the deposit </span><span style="display:inline" t-esc="'('+str(int(event.booking_down_payment))+' €) ?'"/>
</label>
<div class="col- col-sm- col-md-">
<select form="form1" id="down_payment" name="down_payment" class="form-control s_website_form_input">
<option name="yes" selected="true" value="true" label="Oui"></option>
<option name="no" value="false" label="Non"></option>
</select>
</div>
</div>
</div>
<br></br>
<h6>Please select your booking options :</h6>
<br></br>
@ -151,6 +157,27 @@ de séjour en solitaire.</b>
<input type="hidden" id="status" name="status" t-att-value="status"/>
<input type="hidden" id="status2" name="status2" t-att-value="partner.member_status"/>
<input type="hidden" id="membership_product" name="membership_product" t-att-value="int(membership_product.id)"/>
<input type="hidden" id="individual_day_price" name="individual_day_price" t-att-value="int(event.individual_day_price)"/>
<input type="hidden" id="individual_member_day_price" name="individual_member_day_price" t-att-value="int(event.individual_member_day_price)"/>
<input type="hidden" id="individual_super_member_day_price" name="individual_super_member_day_price" t-att-value="int(event.individual_super_member_day_price)"/>
<input type="hidden" id="individual_week_price" name="individual_week_price" t-att-value="int(event.individual_week_price)"/>
<input type="hidden" id="individual_member_week_price" name="individual_member_week_price" t-att-value="int(event.individual_member_week_price)"/>
<input type="hidden" id="individual_super_member_week_price" name="individual_super_member_week_price" t-att-value="int(event.individual_super_member_week_price)"/>
<input type="hidden" id="individual_2weeks_price" name="individual_2weeks_price" t-att-value="int(event.individual_2weeks_price)"/>
<input type="hidden" id="individual_member_2weeks_price" name="individual_member_2weeks_price" t-att-value="int(event.individual_member_2weeks_price)"/>
<input type="hidden" id="individual_super_member_2weeks_price" name="individual_super_member_2weeks_price" t-att-value="int(event.individual_super_member_2weeks_price)"/>
<input type="hidden" id="individual_3weeks_price" name="individual_3weeks_price" t-att-value="int(event.individual_3weeks_price)"/>
<input type="hidden" id="individual_member_3weeks_price" name="individual_member_3weeks_price" t-att-value="int(event.individual_member_3weeks_price)"/>
<input type="hidden" id="individual_super_member_3weeks_price" name="individual_super_member_3weeks_price" t-att-value="int(event.individual_super_member_3weeks_price)"/>
<input type="hidden" id="days_duration" name="days_duration"/>
<input type="hidden" id="price_individual_booking" name="price_individual_booking"/>
<t t-if="options">
<table class='table' width='50%'>
<thead>


Loading…
Cancel
Save