{% set language = app.request.locale %}
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyApPskY-64e2AFF_RDSK2XHyyGQAlN0qN0&language={{ language }}&libraries=places&callback=initAutoComplete"
async defer></script>
<script>
Dropzone.autoDiscover = false;
let BulledValue = '';
let ResponseData = [];
let ListData = [];
let token = '';
let autocomplete;
let autocomplete_2;
let company = `{{ company is defined and not null and company != '' ? company.numberOfEmployers : '' }}`;
const INPUT_HIDDEN = (i, name, value) => {
return `<input type="hidden" name="offer[`+ name +`][selected][`+ i +`]" value="`+ value +`" class="input-list-point_`+ name +` input_bulleted_list_`+name+`_`+ i +`">`;
};
function initAutoComplete() {
$(document).on('click', '.city', function () {
let city = $(this)[0];
autocomplete = new google.maps.places.Autocomplete(
city,
{
types: ['(cities)'],
fields: ['name', 'address_components', 'geometry']
});
autocomplete.addListener('place_changed', onPlaceChanged);
});
$(document).on('click', '.place', function () {
token = $(this).data('token');
let city = $(this)[0];
autocomplete = new google.maps.places.Autocomplete(
city,
{
types: ['(regions)'],
fields: ['name','address_components', 'geometry']
});
autocomplete.addListener('place_changed', onRegionChanged);
});
$(document).on('click', '.city_2', function () {
let city2 = $(this)[0];
autocomplete_2 = new google.maps.places.Autocomplete(
city2,
{
types: ['(cities)'],
fields: ['name', 'address_components', 'geometry']
});
autocomplete_2.addListener('place_changed', onPlaceChanged_2);
});
}
function getClearNameCity(name){
let clearName = '';
let length = name.length;
for(let i = 0; i<length; i++){
if(name.charAt(i) == ','){break;}
clearName += name.charAt(i);
}
return clearName;
}
function onRegionChanged(){
var place = autocomplete.getPlace();
let isLocality = 0;
if (place) {
for (const component of place.address_components) {
const componentType = component.types[0];
switch (componentType) {
case "locality":
isLocality = 1;
$('#company_lat_'+token).val(place.geometry.location.lat);
$('#company_lnt_'+token).val(place.geometry.location.lng);
$('#company_place').val(getClearNameCity(component.long_name));
$(".place_"+token).val(getClearNameCity(component.long_name));
$(".city_"+token).val(getClearNameCity(component.long_name));
$(".pl_name").val(component.long_name);
break;
case "administrative_area_level_1":
if(isLocality != 1){
$('#company_lat_'+token).val(place.geometry.location.lat);
$('#company_lnt_'+token).val(place.geometry.location.lng);
$('#company_place').val(getClearNameCity(component.long_name));
$("#work-data-city").val(getClearNameCity(component.long_name));
$(".place_"+token).val(getClearNameCity(component.long_name));
$(".city_"+token).val(getClearNameCity(component.long_name));
$(".pl_name").val(getClearNameCity(component.long_name));
}
break;
case "country":
$('#company_lat_'+token).val(place.geometry.location.lat);
$('#company_lnt_'+token).val(place.geometry.location.lng);
$(".country").val(component.long_name);
$(".pl_name").val(getClearNameCity(component.long_name));
break;
}
}
} else {
$(".place").val('');
$(".city").val('');
$(".country").val('');
$("#company_lat").val('');
$("#company_lnt").val('');
$("#company_place").val('');
}
}
function onPlaceChanged() {
var place = autocomplete.getPlace();
console.log(place);
if (place) {
for (const component of place.address_components) {
const componentType = component.types[0];
switch (componentType) {
case "locality":
$('#company_lat').val(place.geometry.location.lat);
$('#company_lnt').val(place.geometry.location.lng);
$('#company_place').val(component.long_name);
$(".city").val(component.long_name);
$(".pl_name").val(getClearNameCity(component.long_name));
break;
case "country":
$(".country").val(component.long_name);
break;
}
}
} else {
$(".city").val('');
$(".country").val('');
$("#company_lat").val('');
$("#company_lnt").val('');
$("#company_place").val('');
}
}
function onPlaceChanged_2() {
var place = autocomplete_2.getPlace();
if (place) {
for (const component of place.address_components) {
const componentType = component.types[0];
switch (componentType) {
case "locality":
$(".city_2").val(component.long_name);
$("#company_extra_lat").val(place.geometry.location.lat);
$("#company_extra_lnt").val(place.geometry.location.lng);
$("#company_extra_place").val(component.long_name);
$(".pl_name_2").val(getClearNameCity(component.long_name));
break;
case "country":
$(".country_2").val(component.long_name);
break;
}
}
} else {
$(".city_2").val('');
$(".country_2").val('');
$("#company_extra_lat").val('');
$("#company_extra_lnt").val('');
$("#company_extra_place").val('');
}
}
function checkIsExtraInvoiceData()
{
if($('.invoice-data-toggle').length >= 1){
if($('.invoice-data-toggle').prop('checked')){
$('.invoice_extra_input_required').prop('required', true);
}else{
$('.invoice_extra_input_required').prop('required', false);
}
}
}
$(document).ready(function(){
$('.ui-multiselect span:last-child').html(`{{ 'USER_ZONE.OFFER.SALARY.PERIOD.SELECT'|trans }}`);
$('.custom-select select.limit-education option:first-child').html(`{{ 'USER_ZONE.OFFER.SALARY.PERIOD.SELECT'|trans }}`);
checkIsExtraInvoiceData();
});
$(document).on('change', '.invoice-data-toggle', function (){
checkIsExtraInvoiceData();
});
$(document).on('click change', 'input[name="multiselect_lang-select"]', function(){
let active = $(this).prop('checked');
let divId = $(this).val();
if(active == false){
$('#lang-'+divId).hide();
}
});
$(document).on('click change', '.ui-multiselect-checkboxes input[type="checkbox"]', function(){
let active = $(this).prop('checked');
let divId = $(this).val();
if(active == false){
$('#education-'+divId).hide();
}
});
$('.input-checkbox-form-place-cv').on('click', function (){
$('.input-checkbox-form-place-cv').prop('checked', false);
$(this).prop("checked", true);
if($(this).prop("id") == 'check-agre-checkbox-2'){
$('.box-input-surce').show();
}else{
$('.box-input-surce').hide();
}
});
$('.label-input-checkbox-form-place-cv').on('click', function (){
$('.input-checkbox-form-place-cv').prop('checked', false);
let idName = '#'+ $(this).attr('for');
$(idName).prop("checked", true);
if(idName == '#check-agre-checkbox-2'){
$('.box-input-surce').show();
}else{
$('.box-input-surce').hide();
}
});
$(document).on('click', '.size-input', function () {
let val = $(this).val();
});
$(document).on('click', '#check31', () => {
if ($('.button_invoice').val()) {
$('.button_invoice').removeClass('button_invoice');
$('.invoice_input').removeAttr('required');
} else {
$('#check31').addClass('button_invoice');
$('.invoice_input').attr('required', true);
}
});
$(".form-company-user").submit(function (e) {
$('.alert').css('display', 'none');
});
$(document).on('click', '.box_dropzone_logo', function(){
$("#dropzone1").click();
});
$("#dropzone1").dropzone({
maxFiles: 1,
createImageThumbnails: false,
previewsContainer: false,
acceptedFiles: 'image/png, image/jpg, image/svg, image/jpeg',
url: "{{ path('user-create-logo') }}",
success: function (file, response) {
if(response != ''){
$('.logo-box').removeClass(['border-dotted', 'border-secondary']);
$('.container-box-logo').addClass('d-none');
$('.box-company-logo-set').show();
$('.box-company-logo-is-add').hide();
$('img').remove('.img-drop-logo-2');
$('.box-to-set-logo').append(`
<img src="` + '/firm/' + response.name + '.' + response.extension + `" class="img-drop-logo-2" alt="" style="max-width:100;max-height:60px;"/>
<a href="#" class="remove-logo-button"><i class="fas fa-times"></i></a>
`);
$('input').remove('.company_logo');
$('.form-company-user').append('<input type="hidden" name="company[logo]" value="' + response.id + '" class="company_logo">');
$('.dz-message').hide();
}else{
Dropzone.forElement('#dropzone1').removeAllFiles(true);
}
}
});
$(document).on('click', '.remove-logo-button', function () {
Dropzone.forElement('#dropzone1').removeAllFiles(true);
$('.container-box-logo').removeClass('d-none');
$('.box-company-logo-set').hide();
$('.remove-logo-button').hide();
$('input').remove('.company_logo');
$('.box-to-set-logo').remove('.img-drop-logo-2');
$('.dz-message').show();
$('.logo-box').addClass('border-dotted');
$('.logo-box').addClass('border-secondary');
});
$(document).on('click', '.close-row', function(){
let select = $(this).data('select');
let education = $(this).data('education');
let sizeOption = 0;
let selected = 0;
$('#'+select+' option[value='+education+']').prop('selected', false);
$('#'+select+' option[value='+education+']').prop('checked', false);
$('#'+select+'').trigger('change').multiselect('refresh');
$('.ui-multiselect-checkboxes input[value="'+education+'"]').prop('selected', false);
$('.ui-multiselect-checkboxes input[value="'+education+'"]').prop('checked', false);
$('.ui-multiselect-checkboxes input[value="'+education+'"]').trigger('change');
$('.ui-multiselect span:last-child').html(`{{ 'USER_ZONE.OFFER.SALARY.PERIOD.SELECT'|trans }}`);
});
$(document).on('change', '#companyVatId', function (e) {
e.preventDefault();
let nip = $(this).val();
$.get('/gus/' + nip, function (data) {
if (data.error == null){
const name = data.reports[0].name;
const postCode = data.reports[0].zipCode;
const county = data.reports[0].district;
const city = data.reports[0].city;
const address = data.reports[0].street + ' ' + data.reports[0].propertyNumber + ' ' + data.reports[0].apartmentNumber;
{#const country = `{{ 'USER_ZONE.OFFER.WORK_DATA.DEFAULT_VALUE_COUNTRY'|trans() }}`;#}
const country = 'pl';
$('#companyName').val(name);
$('#companyAddress').val(address);
$('#companyCity').val(city);
$('#companyPostCode').val(postCode);
$('#companyCountry').val(country);
$('#company_place').val(city);
}
}
);
return false;
});
$(document).on('change', '#companyVatId2', function (e) {
e.preventDefault();
let nip = $(this).val();
$.get('/gus/' + nip, function (data) {
if (data.error == null){
const name = data.reports[0].name;
const postCode = data.reports[0].zipCode;
const county = data.reports[0].district;
const city = data.reports[0].city;
const address = data.reports[0].street + ' ' + data.reports[0].propertyNumber + ' ' + data.reports[0].apartmentNumber;
{#const country = `{{ 'USER_ZONE.OFFER.WORK_DATA.DEFAULT_VALUE_COUNTRY'|trans() }}`;#}
const country = 'pl';
$('#companyName2').val(name);
$('#companyAddress2').val(address);
$('#companyCity2').val(city);
$('#companyPostCode2').val(postCode);
$('#companyCountry2').val(country);
$('#company_extra_place').val(city);
}
}
);
return false;
});
</script>