{# {% include '@Application/inc/buddybee_new_header.html.twig' %} #}
{% include '@Application/inc/central_header.html.twig' %}
<style>
.email-input{
position: relative;
}
.otp_in{ }
/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* Firefox */
input[type=number] {
-moz-appearance: textfield;
}
</style>
{# honeybee otp verrify form section #}
<section class="verification-code-page section">
<div class="container d-flex justify-content-center align-items-center">
<div class="card text-center login-inputs">
<h2 class="section-title">We've sent you a code to your email address </h2>
<p style="margin: 0; text-align: center; color: #eb9f9f;">{{ message==''?'':message }}</p>
<p>Please check your email and enter the code from there.</p>
{# form #}
<form action="" id="relevantForm" method="post">
<div class="email-input d-flex justify-content-center " id="code-input">
{# otp digit 1 #}
<input type="number" id="otp_in_1" name="otp_in_1" placeholder="" maxlength="1" data-prev-id="_NONE_" data-next-id="2" class="code-box mx-1 otp_in otp_in_1" required>
{# otp digit 2 #}
<input type="number" id="otp_in_2" name="otp_in_2" placeholder="" maxlength="1" data-prev-id="1" data-next-id="3" class="code-box mx-1 otp_in otp_in_2" required>
{# otp digit 3 #}
<input type="number" id="otp_in_3" name="otp_in_3" placeholder="" maxlength="1" data-prev-id="2" data-next-id="4" class="code-box mx-1 otp_in otp_in_3" required>
{# otp digit 4 #}
<input type="number" id="otp_in_4" name="otp_in_4" placeholder="" maxlength="1" data-prev-id="3" data-next-id="_NONE_" class="code-box mx-1 otp_in otp_in_4" required>
<input type="hidden" id="otp" name="otp" placeholder="otp" maxlength="4" class="input_field" required>
<div class="eye-onoff d-none">
<i class="fas fa-times small_error_icon email"></i>
</div>
{# error message #}
<p class="small_error_text email"></p>
</div>
<h6 class='mt-5' style="margin: 10px 0 10px;color: #615A5A;font-size:12px;text-align: center;"><span id="otpExpireTextPrefix">The OTP will expire</span> <span style="" id="otpExpireText"
class="time convert_to_moment_time" data-moment-ts-format="_today_or_date_"
data-moment-ts="{{ otpExpireTs }}"></span> <a class="resend_otp_button" style="display: inline-block;" href="#"> Resend OTP</a>
</h6>
<button type="submit" class="honeybtn rel_form_submit mt-4">Confirm</button>
</form>
<p class="mt-3"><small>Not you? </small><a href="{{ url('central_landing') }}" >Login with another account?</a></p>
</div>
</div>
</section>
{% include '@HoneybeeWeb/footer/central_footer.html.twig' %}
{# {% include '@Application/footer/buddybee_new_footer.html.twig' %} #}
<script type="text/javascript" src="{{ absolute_url(path('dashboard')) }}js/onscan.min.js"></script>
{#<script type="text/javascript" src="{{ absolute_url(path('dashboard')) }}buddybee_assets/js/detect_autofill.js"></script>#}
<script>
var fbt='';
var cndDwnInterval='';
$(document).ready(function () {
function ConvertToMomentTimeOtpExpire(elem) {
elem=elem||$('#otpExpireText');
var moment_time = moment.unix($(elem).attr('data-moment-ts'));
// console.log($(elem).attr('data-moment-ts'));
$('#otpExpireTextPrefix').text('This OTP will Expire');
var format = $(elem).attr('data-moment-ts-format');
var toReplaceStr = '';
if ($(elem).attr('data-moment-ts') <= 0) {
clearInterval(cndDwnInterval);
toReplaceStr = ''
}
else {
if (format == '_today_or_date_') {
// toReplaceStr = moment_time.fromNow()
if (moment() > moment_time) {
// alert('here')
$('#otpExpireTextPrefix').text('The OTP has Expired');
toReplaceStr = ''
clearInterval(cndDwnInterval);
}
else {
toReplaceStr = moment_time.fromNow()
}
}
else {
toReplaceStr = moment_time.format(format)
}
}
$(elem).text(toReplaceStr)
}
function resendOtp(options){
options=options||{
{#userId:{{ session[UserConstants.USER_ID] is defined?session[UserConstants.USER_ID]:'0' }},#}
userId:{{ session[UserConstants.USER_ID] is defined?session[UserConstants.USER_ID]:(userId is defined?userId:'0') }},
userType:{{ session[UserConstants.USER_TYPE] is defined?session[UserConstants.USER_TYPE]:(userType is defined?userType:'0') }},
userCategory:'{{ userCategory is defined?userCategory:'_BUDDYBEE_USER_' }}',
otpActionId:'{{ otpActionId is defined?otpActionId:1 }}',
otpExpireSecond:180,
email:'{{ email is defined?email:'_NONE_' }}',
}
$.post('{{ url('send_otp_ajax') }}', options)
.done(function (data) {
// // console.log(data);
if (data.success == true) {
$('#otpExpireText').attr('data-moment-ts',data.otpExpireTs);
reset_otp()
clearInterval(cndDwnInterval);
cndDwnInterval = setInterval(ConvertToMomentTimeOtpExpire, 1000);
} else {
// $('#barcode_selector_cont').waitMe('hide');
}
})
.fail(function () {
// $('#barcode_selector_cont').waitMe('hide');
});
}
// cndDwnInterval = setInterval(ConvertToMomentTimeOtpExpire($('#otpExpireText')), 1000);
function paste_otp(curr_number){
$('.otp_in_1').val(Math.floor(curr_number/1000));curr_number=curr_number%1000;
$('.otp_in_2').val(Math.floor(curr_number/100));curr_number=curr_number%100;
$('.otp_in_3').val(Math.floor(curr_number/10));curr_number=curr_number%10;
$('.otp_in_4').val(Math.floor(curr_number/1));curr_number=curr_number%1;
update_otp_field()
}
function reset_otp(){
$('.otp_in_1').val('').focus();
$('.otp_in_2').val('');
$('.otp_in_3').val('');
$('.otp_in_4').val('');
}
function update_otp_field(){
$('#otp').val(
1000*($('.otp_in_1').val())+
100*($('.otp_in_2').val())+
10*($('.otp_in_3').val())+
1*($('.otp_in_4').val())
)
check_doc_and_submit(0); //check only not submit
}
// $('.otp_in').keydown(function(event){
//// alert('keydown')
// alert($(this).val())
//SS
//
//
//
// })
// $('.otp_in').keydown(function(event){
//// alert('blur')
//// alert($(this).val())
// if(1*$(this).val()>=1000) {
// alert($(this).val())
// paste_otp(1 * $(this).val())
//
// }
//
//
//
//
// })
$('.otp_in_1').keydown(function(event){
// $('#enter_otp_title').text(
// '_'+$(this).val()+'_'
// )
if($(this).val().length>=4)
paste_otp($(this).val())
})
// document.addEventListener('onautocomplete', function(e) {
// e.target.hasAttribute('autocompleted'); // true or false
//// alert(event.target.value)
// paste_otp(event.target.value)
//// e.preventDefault(); // prevent autocomplete
// // do you stuff...
// })
$('.otp_in').keyup(function(event){
var prev_data_id=$(this).data('prevId')
var next_data_id=$(this).data('nextId')
// alert(event.keyCode)
if ( event.which == 13 ) {
event.preventDefault();
}
else if ( event.which == 8 ) {
event.preventDefault();
$(this).val('');
if(prev_data_id!='_NONE_')
$('.otp_in_'+prev_data_id).focus();
// $('.otp_in_'+prev_data_id).val('').focus();
}
else if ( event.which == 39 ) {
event.preventDefault();
if (next_data_id != '_NONE_') {
$('.otp_in_' + next_data_id).focus();
}
}
else if ( event.which == 37 ) {
event.preventDefault();
if(prev_data_id!='_NONE_')
$('.otp_in_'+prev_data_id).focus();
}
else
{
if(event.key >=0 && event.key<=9 ) {
// alert(event.which)
// alert(event.key)
// alert(String.fromCharCode(event.which))
// $(this).val(String.fromCharCode(event.which));
$(this).val(event.key);
if (next_data_id != '_NONE_') {
$('.otp_in_' + next_data_id).focus();
}
}
// alert($(this).val())
// alert(isNaN($(this).val()))
if( isNaN($(this).val()))
$(this).val('');
}
update_otp_field()
})
function attach_onscan() {
// alert('pika')
onScan.attachTo(document, {
singleScanQty: 1,
minLength:4,
suffixKeyCodes: [13], // enter-key expected at the end of a scan
reactToPaste: true, // Compatibility to built-in scanners in paste-mode (as opposed to keyboard-mode)
onScan: function (sCode, iQty) { // Alternative to document.addEventListener('scan')
// // console.log('Scanned: ' + iQty + 'x ' + sCode);
//
// var foundIds = [];
//
//// // console.log('PIKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
// // console.log(sCode);
// lastScanCrossMatched = 1;
if (!isNaN(sCode)) {
paste_otp(sCode)
}
//// dynamic_product_selector.focus();
// // console.log(dynamic_product_selector.currentResults.items);
//// dynamic_product_selector.setValue(dynamic_product_selector.currentResults.items[0].id);
// if(dynamic_product_selector.currentResults.items.length>=1) {
//// alert(dynamic_product_selector.currentResults.items.length+','+dynamic_product_selector.currentResults.items[0].id)
// dynamic_product_selector.setValue(dynamic_product_selector.currentResults.items[0].id);
// //// console.log(this.currentResults.items.length);
//
// dynamic_product_selector.focus();
// }
},
// onKeyDetect: function(iKeyCode){ // output all potentially relevant key events - great for debugging!
// // console.log('Pressed: ' + iKeyCode);
// }
});
}
function detach_onscan() {
onScan.detachFrom(document);
}
// $('#deliveryInfoModal').on('hidden.bs.modal', function (e) {
// attach_onscan();
// })
// $('#deliveryInfoModal').on('shown.bs.modal', function (e) {
// detach_onscan();
// })
attach_onscan();
$('.otp_in_'+1).focus();
$('.resend_otp_button').click(function(e){
e.preventDefault();
{# console.log("resend clicked") #}
resendOtp();
})
$('.login-inputs input').focus(function () {
// if()
// $('.login-inputs input').removeClass('error_class');
$(this).removeClass('error_class');
})
$('.login-inputs input').change(function () {
// if()
// $('.login-inputs input').removeClass('error_class');
if($(this).hasClass('checkIfExists'))
{
check_field_validity($(this).attr('data-field-type'))
}
check_doc_and_submit(0); //check only not submit
})
function check_field_validity(fieldType)
{
fieldType = fieldType || 'email';
$('.small_error_text.' + fieldType).text('')
$('.small_error_text.' + fieldType).hide()
$('.small_error_icon.' + fieldType).removeClass('success').removeClass('error');
$('.small_error_icon.' + fieldType).removeClass('fa-check').removeClass('fa-times');
$('.small_error_icon.' + fieldType).addClass('fa-spinner');
$('.small_error_icon.' + fieldType).show()
// $.post( "example.php", function() {
// alert( "success" );
// })
// .done(function() {
// alert( "second success" );
// })
// .fail(function() {
// alert( "error" );
// })
// .always(function() {
// alert( "finished" );
// });
//{#// console.log({#}
//{# fieldType: fieldType,#}
//{#fieldValue: $('.input_field.' + fieldType).val(),#}
//{#signUpUserType: {{ signUpUserType }},#}
//{#}) #}
if(fieldType=='password')
{
// if($('#password2').val()=='')
// return;
if($('#password').val()!==$('#password2').val())
// if(0)
{
$('.small_error_text.' + fieldType).text('Passwords do not Match')
$('.small_error_text.' + fieldType).show()
$('.small_error_icon.' + fieldType).removeClass('fa-spinner').removeClass('success');
$('.small_error_icon.' + fieldType).addClass('fa-times').addClass('error');
$('.small_error_icon.' + fieldType).show()
}
else {
$('.small_error_text.' + fieldType).text('')
$('.small_error_text.' + fieldType).hide()
$('.small_error_icon.' + fieldType).removeClass('fa-spinner').removeClass('error');
$('.small_error_icon.' + fieldType).addClass('fa-check').addClass('success');
$('.small_error_icon.' + fieldType).show()
}
return;
}
$.post('{{ url('check_if_email_exists_already') }}', {
fieldType: fieldType,
fieldValue: $('.input_field.' + fieldType).val(),
signUpUserType: {{ userType }},
})
.done(function (data) {
//sales.clearItemTable()
fieldType=data.fieldType;
if (data.alreadyExists != true) {
$('.small_error_text.' + fieldType).text('Couldnot find your email')
$('.small_error_text.' + fieldType).show()
$('.small_error_icon.' + fieldType).removeClass('fa-spinner').removeClass('success');
$('.small_error_icon.' + fieldType).addClass('fa-times').addClass('error');
$('.small_error_icon.' + fieldType).show()
}
else {
$('.small_error_text.' + fieldType).text('')
$('.small_error_text.' + fieldType).hide()
$('.small_error_icon.' + fieldType).removeClass('fa-spinner').removeClass('error');
$('.small_error_icon.' + fieldType).addClass('fa-check').addClass('success');
$('.small_error_icon.' + fieldType).show()
}
}
);
}
function check_doc_and_submit(submitFlag) {
var checkFailed = 0;
submitFlag=submitFlag||0
///check if any checking needed here
$('.login-inputs input').each(function(ind,elem){
if($(this).prop('required')){
if($(this).val()=='' )
checkFailed=1;
// console.log("REQ");
} else {
// console.log("NREQ");
}
});
$('.small_error_text').each(function(ind,elem)
{
if($(elem).text()!='')
checkFailed=1;
})
$('.small_error_text').each(function(ind,elem)
{
if($(elem).text()!='')
checkFailed=1;
})
if(checkFailed==0)
$('.rel_form_submit').addClass('ready');
else
{
$('.rel_form_submit').removeClass('ready');
}
if (checkFailed == 0 && submitFlag==1) {
$('.rel_form_submit').removeClass('ready');
$('.rel_form_submit').hide();
$('#relevantForm').submit();
}
}
//For save action
$('input[type="submit"], button[type="submit"], .rel_form_submit').click(function (event) {
event.preventDefault();
check_doc_and_submit(1);
})
$('.convert_to_moment_time').each(function (ind, elem) {
ConvertToMomentTimeOtpExpire(elem);
});
cndDwnInterval = setInterval(ConvertToMomentTimeOtpExpire, 1000);
check_doc_and_submit(0)
})
</script>