Commit 0dbdbd87 by Yvon

ajout nouveau champ configurable au process d'inscription : profession (champ…

ajout nouveau champ configurable au process d'inscription : profession (champ également rendu modifiable post circuit d'inscription depuis l'espace membre)
parent fed8bf23
Pipeline #3219 failed with stage
in 1 minute 24 seconds
......@@ -160,4 +160,5 @@ LOSSES_PICKING_TYPE_ID = 10
AUTOCONSO_LOC_ID = 27
AUTOCONSO_PICKING_TYPE_ID = 7
SUBSCRIPTION_ASK_FOR_SEX = True
\ No newline at end of file
SUBSCRIPTION_ASK_FOR_SEX = True
SUBSCRIPTION_ASK_FOR_JOB = True
\ No newline at end of file
......@@ -403,6 +403,8 @@ class CagetteMember(models.Model):
}
if ('sex' in post_data):
received_data['sex'] = post_data['sex']
if ('function' in post_data):
received_data['function'] = post_data['function']
if 'street2' in post_data:
received_data['street2'] = post_data['street2']
if 'phone' in post_data:
......@@ -450,11 +452,15 @@ class CagetteMember(models.Model):
partner_id = None
name_sep = getattr(settings, 'SUBSCRIPTION_NAME_SEP', ' ')
ask_4_sex = getattr(settings, 'SUBSCRIPTION_ASK_FOR_SEX', False)
ask_4_job = getattr(settings, 'SUBSCRIPTION_ASK_FOR_JOB', False)
concat_order = getattr(settings, 'CONCAT_NAME_ORDER', 'FL')
sex = 'o'
function = ''
if ask_4_sex is True:
sex = post_data['sex']
if ask_4_job is True:
function = post_data['function']
# With input type="date", transmitted value is YYYY-mm-dd
# But, it could be dd/mm/YYYY if not supported by browser
......@@ -484,7 +490,8 @@ class CagetteMember(models.Model):
'zip': post_data['zip'],
'city': post_data['city'],
'phone': format_phone_number(post_data['mobile']), # Because list view default show Phone and people mainly gives mobile
'barcode_rule_id': settings.COOP_BARCODE_RULE_ID
'barcode_rule_id': settings.COOP_BARCODE_RULE_ID,
'function': function
}
if ('_id' in post_data):
f['email'] = post_data['_id']
......@@ -556,7 +563,8 @@ class CagetteMember(models.Model):
'phone': format_phone_number(post_data['mobile']), # Because list view default show Phone and people mainly gives mobile
'barcode_rule_id': settings.ASSOCIATE_BARCODE_RULE_ID,
'parent_id' : post_data['parent_id'],
'is_associated_people': True
'is_associated_people': True,
'function': function
}
associated_member_id = api.create('res.partner', associated_member)
am = CagetteMember(associated_member_id)
......
......@@ -17,6 +17,7 @@ var latest_odoo_coop_bb = null,
subs_cap = $('#subs_cap'),
m_barcode = $('#m_barcode'),
sex = $('#sex'),
job = $('#job'),
self_records = [],
selected_associate=null,
associated_old_choice= null,
......@@ -158,7 +159,7 @@ function swipe_to_shift_choice() {
retrieve_and_draw_shift_tempates();
schoice_view.show();
}
function _really_save_new_coop(email, fname, lname, cap, pm, cn, bc, msex) {
function _really_save_new_coop(email, fname, lname, cap, pm, cn, bc, msex, mjob) {
var coop = current_coop || {};
......@@ -214,6 +215,7 @@ function _really_save_new_coop(email, fname, lname, cap, pm, cn, bc, msex) {
if (m_barcode.length > 0) coop.m_barcode = bc;
if (sex.length > 0) coop.sex = msex;
if (job.length > 0) coop.function = mjob;
coop.validation_state = "to_fill";
dbc.put(coop, function callback(err, result) {
if (!err) {
......@@ -244,6 +246,7 @@ function store_new_coop(event) {
var errors = [],
bc = '', // barcode may not be present
msex = '', // sex may not be present
mjob = '', //job may not be present
active_asso_area = $('#associate_area .choice_active'); // need to ckeck if associated data are available
// 1- Un coop avec le meme mail ne doit pas exister dans odoo (dans base intermediaire, le cas est géré par l'erreur à l'enregistrement)
let email = $('input[name="email"]').val()
......@@ -260,6 +263,9 @@ function store_new_coop(event) {
if (sex.length > 0) {
msex = $('input[name="sex"]:checked').val();
}
if (job.length > 0) {
mjob = $('input[name="job"]').val();
}
if (payment_meaning.val() == 'ch') {
if (ch_qty.val() <1) {
......@@ -319,7 +325,7 @@ function store_new_coop(event) {
if (errors.length == 0) {
_really_save_new_coop(
email, fname, lname,
subs_cap.val(), payment_meaning.val(), ch_qty.val(), bc, msex
subs_cap.val(), payment_meaning.val(), ch_qty.val(), bc, msex, mjob
);
} else {
......@@ -331,7 +337,7 @@ function store_new_coop(event) {
if (errors.length == 0) {
_really_save_new_coop(
email, fname, lname,
subs_cap.val(), payment_meaning.val(), ch_qty.val(), bc, msex
subs_cap.val(), payment_meaning.val(), ch_qty.val(), bc, msex, mjob
);
} else {
......@@ -405,6 +411,9 @@ function modify_current_coop() {
reset_sex_radios();
$('#' + current_coop.sex + '_sex').prop('checked', true);
}
if (job.length > 0) {
ncoop_view.find('input[name="job"]').val(current_coop.function);
}
ncoop_view.show();
}
......
......@@ -163,6 +163,7 @@ function submit_full_coop_form() {
var form_data = new FormData(form.get(0)),
m_barcode = form.find('[name="m_barcode"]'),
sex = $('#sex'),
job = $('#job'),
has_empty_values = false;
for (var pair of form_data.entries()) {
......@@ -205,6 +206,12 @@ function submit_full_coop_form() {
if (sex.length > 0) {
form_data.set('sex', $('input[name="sex"]:checked').val());
}
if (job.length > 0) {
form_data.set(
'function',
vform.find('input[name="job"]').val()
);
}
post_form(
'/members/coop_validated_data', form_data,
function(err) {
......@@ -246,7 +253,8 @@ function save_current_coop(callback) {
let form = coop_validation_form,
_id = form.find('[name="email"]').val(),
m_barcode = form.find('[name="m_barcode"]'),
sex = form.find('[name="sex"]');
sex = form.find('[name="sex"]'),
job = form.find('[name="job"]');
if (current_coop != null && _id.length > 0) {
//Birthdate verification
......@@ -300,6 +308,9 @@ function save_current_coop(callback) {
current_coop.sex = $('input[name="sex"]:checked').val();
if (typeof current_coop.sex == "undefined") sex_error = true;
}
if (job.length > 0) {
current_coop.function = $('input[name="job"]').val();
}
if (street2_input.length > 0) {
current_coop.street2 = street2_input.val();
}
......
......@@ -28,7 +28,8 @@ function display_current_coop_form() {
chgt_shift_btn = $('#change_shift_template');
var ftop_shift = $('#choosen_shift [name="ftop"]'),
m_barcode = form.find('[name="m_barcode"]'),
sex = $('#sex');
sex = $('#sex'),
job = $('#job');
let street2_input = form.find('[name="street2"]'),
phone_input = form.find('[name="phone"]');
......@@ -52,6 +53,9 @@ function display_current_coop_form() {
if (sex.length > 0 && typeof current_coop.sex != "undefined") {
$('input[name="sex"][value="' + current_coop.sex + '"]').prop('checked', true);
}
if (job.length > 0) {
form.find('[name="job"]').val(current_coop.function);
}
// form.find('[name="barcode_base"]').val(current_coop.barcode_base);
form.find('[name="email"]').val(current_coop._id);
if (current_coop.shift_template &&
......
......@@ -112,6 +112,7 @@ def inscriptions(request, type=1):
'input_barcode': getattr(settings, 'SUBSCRIPTION_INPUT_BARCODE', False),
'email_domain': getattr(settings, 'EMAIL_DOMAIN', 'lacagette-coop.fr'),
'ask_for_sex': getattr(settings, 'SUBSCRIPTION_ASK_FOR_SEX', False),
'ask_for_job': getattr(settings, 'SUBSCRIPTION_ASK_FOR_JOB', False),
'open_on_sunday': getattr(settings, 'OPEN_ON_SUNDAY', False),
'POUCHDB_VERSION': getattr(settings, 'POUCHDB_VERSION', ''),
'max_chq_nb': getattr(settings, 'MAX_CHQ_NB', 12),
......@@ -154,6 +155,7 @@ def prepa_odoo(request):
'input_phone_pattern': getattr(settings, 'INPUT_PHONE_PATTERN', default_input_phone_pattern),
'input_barcode': getattr(settings, 'SUBSCRIPTION_INPUT_BARCODE', False),
'ask_for_sex': getattr(settings, 'SUBSCRIPTION_ASK_FOR_SEX', False),
'ask_for_job': getattr(settings, 'SUBSCRIPTION_ASK_FOR_JOB', False),
'ask_for_street2': getattr(settings, 'SUBSCRIPTION_ADD_STREET2', False),
'ask_for_second_phone': getattr(settings, 'SUBSCRIPTION_ADD_SECOND_PHONE', False),
'show_ftop_button': getattr(settings, 'SHOW_FTOP_BUTTON', True),
......@@ -191,6 +193,7 @@ def validation_inscription(request, email):
'payment_meanings': settings.SUBSCRIPTION_PAYMENT_MEANINGS,
'input_phone_pattern': getattr(settings, 'INPUT_PHONE_PATTERN', default_input_phone_pattern),
'ask_for_sex': getattr(settings, 'SUBSCRIPTION_ASK_FOR_SEX', False),
'ask_for_job': getattr(settings, 'SUBSCRIPTION_ASK_FOR_JOB', False),
'ask_for_street2': getattr(settings, 'SUBSCRIPTION_ADD_STREET2', False),
'ask_for_second_phone': getattr(settings, 'SUBSCRIPTION_ADD_SECOND_PHONE', False),
'show_ftop_button': getattr(settings, 'SHOW_FTOP_BUTTON', True),
......
......@@ -81,6 +81,12 @@
gap: 10px;
}
.member_job_area {
display: flex;
flex-direction: column;
gap: 10px;
}
.edit-btn{
cursor: pointer;
}
......@@ -97,6 +103,9 @@
#edit_phone_form #mobile_form {
margin: 5px 0;
}
#edit_job_form {
display: none ;
}
@media screen and (max-width: 992px) {
......
......@@ -49,6 +49,19 @@ function init_my_info() {
$(".member_phone_line").hide();
}
$(".member_job").empty();
if (partner_data.function !== "" && partner_data.function !== "False" && partner_data.function !== false && partner_data.function !== null) {
$(".member_job")
.append(partner_data.function)
.show();
} else {
$(".member_job").hide();
}
if ($(".member_job").text() === "") {
$(".member_job_line").hide();
}
$('#edit_address').off('click')
.on('click', () => {
$("#street_form").val(partner_data.street.replace(/&#39;/g, "'"));
......@@ -96,6 +109,25 @@ function init_my_info() {
data['mobile']= $("#mobile_form").val();
saveInfo(data, 'phone');
});
$('#edit_job').off('click')
.on('click', () => {
if (partner_data.function === "False") partner_data.function = "";
$("#job_form").val(partner_data.function);
$('#edit_job_value').hide();
$('#edit_job_form').show();
});
$('#cancel_edit_job').off('click')
.on('click', () => {
$('#edit_job_form').hide();
$('#edit_job_value').show();
});
$('#save_edit_job').off('click')
.on('click', () => {
console.log('ici');
data =[];
data['function']= $("#job_form").val();
saveInfo(data, 'function');
});
}
......@@ -127,6 +159,10 @@ function saveInfo(data, field) {
$('#edit_phone_form').hide();
$('#edit_phone_value').show();
}
if (field == 'function') {
$('#edit_job_form').hide();
$('#edit_job_value').show();
}
},
error: function(error) {
console.log(error);
......
......@@ -69,6 +69,8 @@ def index(request, exception=None):
'WELCOME_SUBTITLE_ENTRANCE_MSG': getattr(settings, 'WELCOME_SUBTITLE_ENTRANCE_MSG', '')}
if hasattr(settings, 'SUBSCRIPTION_ASK_FOR_SEX'):
context['ask_for_sex'] = settings.SUBSCRIPTION_ASK_FOR_SEX
if hasattr(settings, 'SUBSCRIPTION_ASK_FOR_JOB'):
context['ask_for_job'] = settings.SUBSCRIPTION_ASK_FOR_JOB
if hasattr(settings, 'SUBSCRIPTION_ADD_STREET2'):
context['ask_for_street2'] = settings.SUBSCRIPTION_ADD_STREET2
if hasattr(settings, 'SUBSCRIPTION_ADD_SECOND_PHONE'):
......
......@@ -120,7 +120,7 @@ class CagetteShift(models.Model):
'shift_type', 'date_alert_stop', 'date_delay_stop', 'extension_ids',
'cooperative_state', 'final_standard_point', 'create_date',
'final_ftop_point', 'shift_type', 'leave_ids', 'makeups_to_do', 'barcode_base',
'street', 'street2', 'zip', 'city', 'mobile', 'phone', 'email',
'street', 'street2', 'zip', 'city', 'mobile', 'phone', 'function', 'email',
'is_associated_people', 'parent_id', 'extra_shift_done']
partnerData = self.o_api.search_read('res.partner', cond, fields, 1)
if partnerData:
......
......@@ -61,6 +61,11 @@
<input type="text" placeholder="email" name="email" value="" pattern="(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*)@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])" required autocomplete="off" />
(*)
</p>
{% if ask_for_job %}
<p>
{% include "members/job_input.html" %}
</p>
{% endif %}
<p>
<input type="number" step="10" min="10" placeholder="Montant souscription" name="subs_cap" id="subs_cap" required/>
<select name="payment_meaning" id="payment_meaning" autocomplete="off" required >
......
<div id="job">
<input type="text" placeholder="Profession" name="job" autocomplete="off" />
</div>
......@@ -33,6 +33,11 @@
<a id="change_shift_template" class="btn--primary">Changer</a>
</span>
</p>
{% if ask_for_job %}
<p>
{% include "members/job_input.html" %}
</p>
{% endif %}
<p>
<input type="number" step="1" min="1" placeholder="Nombre de parts" name="shares_nb" id="shares_nb" class="b_yellow" required disabled/>
<label for="shares_nb">Parts sociales</label>
......
......@@ -151,6 +151,7 @@
"city" : "{{partnerData.city|safe}}",
"mobile" : "{{partnerData.mobile}}",
"phone" : "{{partnerData.phone}}",
"function" : "{{partnerData.function}}",
"email" : "{{partnerData.email}}",
"is_associated_people" : "{{partnerData.is_associated_people}}",
"parent_id" : "{{partnerData.parent_id}}",
......
......@@ -88,6 +88,20 @@
<span id="save_edit_phone"><i class="fas fa-check tile_icon edit-btn"></i></span>
</div>
</div>
<div class="my_info_line member_job_line">
<div class="my_info_line_left">
Profession
</div>
<div class="my_info_line_right member_job_area" id="edit_job_value">
<span class="member_job member_info"></span>
<span id="edit_job"><i class="fas fa-edit tile_icon edit-btn" ></i></span>
</div>
<div class="my_info_line_right member_job_area1" id="edit_job_form">
<input type="text" name="job" id="job_form" placeholder="Profession"> <br>
<span id="cancel_edit_job"><i class="fas fa-times tile_icon edit-btn"></i></span>
<span id="save_edit_job"><i class="fas fa-check tile_icon edit-btn"></i></span>
</div>
</div>
</div>
</div>
<div class="tile full_width_tile" id="attached_info_area">
......
......@@ -21,7 +21,8 @@
city : '{{data.city}}',
email: '{{data.email}}',
mobile : '{{data.mobile}}',
phone : '{{data.phone}}'
phone : '{{data.phone}}',
function: '{{data.job}}'
},
name_sep = '{{data.name_sep}}'
</script>
......@@ -70,6 +71,9 @@
<select name="yyyy"></select>
<input type="hidden" name="birthdate" value="{{data.birthdate}}" />
</p>
<p>
{% include "members/job_input.html" %}
</p>
</div>
</div>
<div id="address">
......
......@@ -65,6 +65,8 @@ def index(request):
'WELCOME_SUBTITLE_ENTRANCE_MSG': getattr(settings, 'WELCOME_SUBTITLE_ENTRANCE_MSG', '')}
if hasattr(settings, 'SUBSCRIPTION_ASK_FOR_SEX'):
context['ask_for_sex'] = settings.SUBSCRIPTION_ASK_FOR_SEX
if hasattr(settings, 'SUBSCRIPTION_ASK_FOR_JOB'):
context['ask_for_job'] = settings.SUBSCRIPTION_ASK_FOR_JOB
if hasattr(settings, 'SUBSCRIPTION_ADD_STREET2'):
context['ask_for_street2'] = settings.SUBSCRIPTION_ADD_STREET2
if hasattr(settings, 'SUBSCRIPTION_ADD_SECOND_PHONE'):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment