{% extends 'content.cad2cut.html.twig' %}
{% block body_classes %}{% spaceless %}
is-ctl-product is-act-detail is-calculation custom-bg
{% endspaceless %}{% endblock %}
{% block container_inner %}
{{ include('includes/modal-confirm-offer.html.twig') }}
<script>
const MSG_UPLOAD_ERROR = '{{ "One or more files cannot be read."|trans }}';
const MSG_MAX_UPLOAD_FILES = '{{ "You cannot send more than %maxUploadFiles% files at the same time."|trans({'%maxUploadFiles%':maxUploadFiles}) }}'
const MSG_MAX_UPLOAD_FILES_NOT_LOGIN = '{{ "For further calculation please register in our webshop or log in to your existing account."|trans }}'
const REMOVE_FILE = '{{ 'Remove File'|trans }}'
const MSG_DELETE_NOTE = '{{ 'Are you sure to delete this note?'|trans }}'
const MSG_DELETE_OPTION = '{{ 'Are you sure to delete this option?'|trans }}'
</script>
{% if toEdit %}
<style>
header,footer{
display:none;
}
</style>
{% endif %}
{% set header_id = "" %}
{% set wicam_header_id = "" %}
{% set date_surcharge = "" %}
{% if WH is not empty %}
{% set header_id = WH.wicamHeaderId %}
{% set wicam_header_id = WH.wicamHeaderId %}
{% set guid = WH.guid %}
{% set date_surcharge = WH.dateSurcharge | date('Y-m-d') %}
{% endif %}
<div class="grid-x grid-margin-x">
<input type="hidden" id="guid" name="guid" value="{{ guid }}">
<input type="hidden" id="header_id" name="header_id" value="{{ header_id }}">
<input type="hidden" id="wicam_header_id" name="wicam_header_id" value="{{ wicam_header_id }}">
<input type="hidden" id="urlheader" value="{{ path('wi_cam_set_header') }}">
<input type="hidden" id="date_surcharge" value="{{ date_surcharge }}">
<input type="hidden" id="url_calculate" value="{{ path('wi_cam_calculate') }}">
<input type="hidden" id="url_multiple_surcharges" value="{{ path('multiple_surcharges') }}">
<input type="hidden" id="url_add_item" value="{{ path('calculation_addItem') }}">
<input type="hidden" id="messageMissingFields" value="{{ "Please enter/select the missing values!"|trans }}">
<input type="hidden" id="maxUploadFiles" value="{{ maxUploadFiles }}">
<input type="hidden" id="isLoggedIn" value="{{ isLoggedIn }}">
<span id="editModal"></span>
<div class="cell medium-9" id="detail-content">
<div class="grid-x grid-margin-x">
<div class="cell small-12 medium-6">
<form action="{{ path('wi_cam_upload') }}" id="WiCamFiles" style="height: 100%">
<h3><b>{{ "CAD Datei hochladen"|trans }}</b></h3>
<div class="dz-message needsclick">
{{ "Drop %maxUploadFiles% files here or click to upload."|trans({'%maxUploadFiles%':maxUploadFiles}) }}
<br>
<div id="messageLimitFiles" class="hide" style="color: red">
{{ "For further calculation please register in our webshop or log in to your existing account."|trans }}
</div><button type="button" class="button margin-top-1">{{ "CAD Datei hochladen"|trans }}</button>
</div>
</form>
</div>
<div class="cell small-12 medium-6">
<form class="custom-form" action="{{ path('wi_cam_send') }}" data-generate="{{ path('wi_cam_generate') }}" id="WiCamSend">
<h3 class="text-left"><b>{{ "Choose Shape"|trans }}</b></h3>
<div class="owl-carousel owl-carousel-custom-form owl-theme">
{% for sh in shapes %}
<div class="item" data-id="{{ sh.id }}">
<img src="{{ sh.smallImage }}" style="height: 90px;width: auto;" title="{{ sh.description|trans }}" alt="{{ sh.description|trans }}">
</div>
{% endfor %}
</div>
<button type="button" id="btChooseShape" name="btChooseShape" class="button">{{ "Choose Shape"|trans }}</button>
</form>
</div>
</div>
<form action="{{ path('wi_cam_send') }}" data-generate="{{ path('wi_cam_generate') }}" id="WiCamSend" style="margin-top:10px;">
<button type="button" id="btSend" class="button secondary disabled">{{ "Send Files" | trans }}</button>
<!--<button type="button" id="btChooseShape" name="btChooseShape" class="button secondary">{{ "Choose Shape"|trans }}</button>-->
</form>
<ul id="files" style="display:none;">
<!-- <input type="hidden" id="a20efaea-3369-4fb9-a3ba-ff3be7179cf1" data-name="Ronde_Lochblech_002.dxf" value="6109b05cc84cb.dxf"> -->
</ul>
{% set general_setting_box_show = general_setting_box ? '' : 'hide' %}
<div class="listing-header callout {{ general_setting_box_show }}">
<div class="header-options">
{% if toEdit %}
{% if is_granted('ROLE_ADMIN') %}
<input type="hidden" id="action-load-customers" value="{{ path('wi_cam_load_customer') }}">
<div class="grid-x align-spaced align-middle grid-margin-x">
<div class="cell small-12 medium-12">
<label>{{ "Representative" | trans }}:</label>
<select id="representative" name="representative">
{% if representatives is not empty %}
<option></option>
{% for representative in representatives %}
{% set selected = ' ' %}
{% if WH is not empty %}
{% if WH.representativeId|default(0) == representative.id %}
{% set selected = 'selected' %}
{% endif %}
{% endif %}
<option value="{{ representative.id }}" {{ selected }} >{{ representative.firstName }} {{ representative.lastName }}</option>
{% endfor %}
{% endif %}
</select>
</div>
</div>
{% endif %}
{% endif %}
{% if isRepresentativeOrAdmin %}
<div class="grid-x align-spaced align-middle grid-margin-x">
<div class="cell small-12 medium-12">
<label>{{ "Customer" | trans }}:</label>
<select id="customer" name="customer">
{% if customers is not empty %}
<option></option>
{% for customer in customers %}
{% set selected = ' ' %}
{% if WH is not empty %}
{% if WH.customerId|default(0) == customer.id %}
{% set selected = 'selected' %}
{% endif %}
{% endif %}
<option value="{{ customer.id }}" {{ selected }} >{{ customer.name }} {{ customer.lastName }}</option>
{% endfor %}
{% endif %}
</select>
</div>
</div>
{% endif %}
<div class="grid-x align-spaced align-middle grid-margin-x">
<div class="cell small-4 medium-2" data-url="{{ path('wi_cam_postcodes') }}">
<label>{{ "PLZ (Pflichtfeld)" | trans }}</label>
<input readonly="readonly" type="text" name="plz" id="plz" value="{{ WH is not empty ? WH.plz : "" }}">
<input type="hidden" name="plz_value" id="plz_value" value="">
</div>
<div class="cell small-8 medium-10">
<label> </label>
<input type="text" readonly name="plz_ex" id="plz_ex" value="{{ plz is not empty ? (plz.ort ~ ' - ' ~ plz.bundesland) : (WH is not empty ? WH.city ~ ' - ' ~ WH.country ~ ' - ' ~ WH.street : '')}}">
</div>
</div>
<hr>
<div class="grid-x align-spaced align-middle grid-margin-x">
<div class="cell small-12 medium-4">
<label>{{"Material Grades" | trans}}</label>
<select id="materialgrade_filter" class="materialgrade_filter">
<option value="0">{{"Choose one" | trans}}</option>
{% for mg in materialgrades %}
{% set selected = ' ' %}
{% if materialgrades|length == 1 %}
{% set selected = ' selected ' %}
{% endif %}
<option value="{{ mg.id }}" {{ selected }} >{{ mg.description }}</option>
{% endfor %}
</select>
</div>
<div class="cell small-12 medium-4">
<label>{{"Dicke"|trans}}</label>
<select id="thickness_filter" class="thickness_filter">
<option value="0">{{"Choose one" | trans}}</option>
{% for th in thickness %}
<option value="{{ th.id }}">{{ th.value }} mm</option>
{% endfor %}
</select>
</div>
<div class=" cell small-12 medium-4">
<label>{{"Stück"|trans}}</label>
<div class="input-group expanded amount" style="margin-bottom:1rem;">
<button class="button minus" type="button" disabled>-</button>
<input name="amount_filter"
id="amount_filter"
type="number" value="0"
oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
maxlength="6"
max="9999"
pattern="number"
class="amount amount_value_filter" style="padding:0px;"/>
<button class="button plus" type="button">+</button>
</div>
</div>
</div>
<div class="grid-x align-spaced align-middle grid-margin-x">
<div class="cell small-12 medium-8">
<label>{{"Surcharges" | trans}}</label>
{% for mg in surcharges_items %}
<label class="container_surcharge" >
<input type="checkbox" class="surcharges_chk_filter" name="surcharges_chk_filter" value="{{ mg.id }}">
<span class="">{{ mg.descriptions[app.request.locale] }}</span>
</label>
{% endfor %}
</div>
<div class="cell small-12 medium-2">
<label> </label>
<span>
<button type="button" id="btApplyFilter" class="button secondary expand top tooltip-detail" data-tooltip aria-haspopup="true"
data-disable-hover="false" data-allow-html="true"
tabindex="2"
title="{{ "Die folgenden Einstellungen auf alle Bauteile des aktuellen Angebots anwenden" | trans }}">{{ "Apply for all" | trans }}</button>
</span>
</div>
<div class="cell small-12 medium-2">
<label> </label>
<span>
<button type="button" id="btDeleteInvalid" data-open="ShowInvalidData" class="button expand top tooltip-detail" data-tooltip aria-haspopup="true"
data-disable-hover="false" data-allow-html="true"
tabindex="2"
title="{{ "Sie haben ungültige Dateien, wollen Sie diese löschen?" | trans }}" style="display:none;">
<i class="fas fa-exclamation-triangle" style="
position: absolute;
top: 3px;
right: 3px;
font-size: 1.1em;
color:#cc4b37;
"></i>
<span class="invalid_amount"></span>
<span class="single_invalid_text" style="display: none;">{{ "ungültige Datei"|trans }}</span>
<span class="multiple_invalid_text">{{ "ungültige Dateien"|trans }}</span>
</button>
</span>
</div>
<span id="calculate"></span>
</div>
</div>
</div>
<div id="fileResponse" data-total="{{ path('wi_cam_total') }}">
{% if WH is not empty %}
{{ files|raw }}
{% endif %}
</div>
<DIV id="preview-template" style="display: none;">
<DIV class="dz-preview dz-file-preview">
<DIV class="dz-image"><IMG data-dz-thumbnail=""></DIV>
<DIV class="dz-details">
<DIV class="dz-size"><SPAN data-dz-size=""></SPAN></DIV>
<DIV class="dz-filename"><SPAN data-dz-name=""></SPAN></DIV>
</DIV>
<DIV class="dz-progress"><SPAN class="dz-upload"
data-dz-uploadprogress=""></SPAN></DIV>
<div class="dz-error-message" style="top:95px"><span data-dz-errormessage="">{{ "Error"|trans }}</span></div>
<div class="dz-success-mark">
</div>
<div class="dz-error-mark">
</div>
</DIV>
</DIV>
</div>
<div class="cell medium-3" data-sticky-container>
<div class="sticky" data-sticky data-margin-top="2" data-sticky-on="medium"
data-check-every="0"
data-anchor="detail-content">
<div id="buyboxLoading" class="modal-loading"><div class="loader"></div></div>
<input type="text" id="price_general_surcharge" class="hide" value="{{ WH is not empty ? WH.priceSurchargeId|default(0) }}">
<div class="show-for-medium" id="buybox-large">
{{ include('includes/buybox-wicam.html.twig') }}
</div>
<div>
{{ include('includes/wicam-calendar.html.twig',{'notes':notes}) }}
</div>
</div>
</div>
</div>
<div class="hide-for-medium">
{{ include('includes/buybox-wicam-mobile.html.twig') }}
</div>
<div class="reveal" id="LoadingModal" data-reveal data-close-on-click="false" data-close-on-esc="false">
<h3>{{ "Sending Files" | trans }} <img src="{{ asset('build/unionstahl/images/loading.gif','unionstahl') }}" width="50" class="loading-modal-img"/></h3>
<hr>
<p>{{ "We process your files... it won't take much longer." | trans }}</p>
<div id="list_files">
</div>
<button type="button" class="button custom-close-reveal-modal hide" disabled id="closeLoadingModal">Close</button>
</div>
<div class="reveal" id="LoadingDetail" data-reveal data-close-on-click="false" data-close-on-esc="false">
<h3>{{ "Loading Details" | trans }} <img src="{{ asset('build/unionstahl/images/loading.gif','unionstahl') }}" width="50" /></h3>
<hr>
<p>{{ "We process your data... it won't take much longer." | trans }}</p>
</div>
<div class="reveal" id="ShowInvalidData" data-reveal data-close-on-click="false" data-close-on-esc="false">
<h3>{{ "Ungültige Dateien" | trans }} </h3>
<hr>
<span class="single-invalid">{{ "Sie haben 1 ungültige Datei, wollen Sie diese löschen?"|trans }}</span>
<span class="multiple-invalids_str" style="display: none;">{{ "Sie haben #fileNumber ungültige Dateien, wollen Sie diese löschen?"|trans }}</span>
<span class="multiple-invalids"></span>
<div class="article-listing-header callout hide-for-small-only" style=" border: 0px;/* padding: 1rem; */margin-bottom: 0.5rem;">
<div class="grid-x align-justify align-middle grid-margin-x">
<div class="cell small-1 font-bold">
{{"Pos"|trans}}
</div>
<div class="cell small-5 font-bold">
{{"Dateiname"|trans}}
</div>
<div class="cell small-6 font-bold">
{{"Hinweis"|trans}}
</div>
</div>
</div>
<div id="invalid_list_files"></div>
<button class="close-button" data-close aria-label="Close modal" type="button">
<span aria-hidden="true">×</span>
</button>
<hr>
<button type="button" class="button" id="btDeleteAllInvalidFiles">
{{ "Ungültige Dateien aus Bestellung entfernen"|trans }}
</button>
</div>
<div class="reveal" id="DeleteConfirmation" data-reveal data-close-on-click="false" data-close-on-esc="false">
<h3>{{ "Bestätigung erforderlich" | trans }}</h3>
<input type="hidden" id="row_identification">
<hr>
<span id="delete_str" style="display: none">{{ "Möchten Sie die Position (#POS-Number - #NAME_OF_THE_FILE) wirklich aus Ihrer Bestellung entfernen?"|trans }}</span>
<p id="delete_str_show">{{ "Are you sure to delete this position?" | trans }}</p>
<hr>
<button type="button" id="btDeleteRow" class="button secondary">{{ "Ja, Position entfernen"|trans }}</button>
<button type="button" class="button primary white-borders" style="vertical-align: top;" data-close>{{ "Nein, Position beibehalten"|trans }}</button>
</div>
<div class="large reveal" id="ShapeModal" data-reveal>
<input type="hidden" id="url_properties" value="{{ path('shape_properties') }}">
<input type="hidden" id="url_results" value="{{ path('calculation_results') }}">
<input type="hidden" name="shapeId" id="shapeId" value="">
<input type="hidden" name="WiCamIdentify" id="WCamIdentify" value="">
<div class="grid-container" id="ShapeList">
<h3>{{ "Choose a shape"|trans }}</h3>
<ul class="tabs" data-tabs id="deeplinked-tabs">
<li class="tabs-title is-active"><a href="#panel1d" aria-selected="true">{{ "Form"|trans }}</a></li>
{# <li class="tabs-title"><a href="#panel2d">{{ "Most Frequently"|trans }}</a></li>#}
</ul>
<div class="tabs-content" data-tabs-content="deeplinked-tabs">
<div class="tabs-panel is-active" id="panel1d">
<div class="grid-x shapeContainer">
{% for sh in shapes %}
<div class="cell small-6 medium-2 large-2">
<div class="card shape" data-id="{{ sh.id }}">
<div class="card-section">
<img src="{{ sh.image }}" style="height: 100px;">
<h5>{{ sh.description|trans }}</h5>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
<div class="tabs-panel" id="panel2d">
<div class="grid-x shapeContainer">
{% for sh in shapesFrequently %}
<div class="cell small-6 medium-2 large-2">
<div class="card shape" data-id="{{ sh.id }}">
<div class="card-section">
<img src="{{ sh.image }}" style="height: 100px;">
<h5>{{ sh.description }}</h5>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
<div class="grid-container" id="CalculationInfo">
<div class="info">Loading...</div>
<button class="button primary white-borders" id="btBack">{{ "Back"|trans }}</button>
<button class="button secondary" id="btAddToOverview" disabled>{{ "Add"|trans }}</button>
</div>
<button class="close-button" data-close aria-label="Close modal" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="large reveal" id="calculationModal" data-reveal>
<h3>{{"Calculation Form"|trans}} - <span class="title"></span></h3>
</div>
{% endblock %}
{% block javascripts_extend %}
<style>
@media (max-width: 767px) {
.sticky {
padding-top: 0 !important;
position: initial !important;
}
}
#btAddToOverview {
float: right;
}
.dropzone{
max-height: 365px;
overflow: auto;
}
.dropzone .dz-preview{
margin: 11px;
}
.dropzone .dz-message{
margin: 0;
}
.required{
border: 1px solid #cc4b37;
}
.lb_circle{
display: inline-block;
}
#list_files .row{
width: 90%;
}
#list_files{
max-height: 270px;
overflow: auto;
}
.label.alert{
background: #FF8716;
}
.select2-container--default .select2-selection--single{
padding-top: 5px;
padding-bottom: 5px;
height: 38px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow{
height: 36px;
}
</style>
<link rel="stylesheet" href="{{ asset('assets/jquery/mobiscroll.custom/css/mobiscroll.jquery.min.css?v=1.3') }}">
<script src="{{ asset('assets/jquery/mobiscroll.custom/js/mobiscroll.jquery.min.js') }}"></script>
<script>
var labels = [];
try{
mobiscroll.setOptions({
locale: mobiscroll.localeEn, // Specify language like: locale: mobiscroll.localePl or omit setting to use default
theme: 'ios', // Specify theme like: theme: 'ios' or omit setting to use default
themeVariant: 'light' // More info about themeVariant: https://docs.mobiscroll.com/5-3-0/calendar#opt-themeVariant
});
}catch (e) {
}
$(function () {
//createCalendar();
$('#fileResponse').sortable({
connectWith: "#fileResponse",
handle: ".position",
stop: function() {
setPositionsRows();
}
});
});
function DestroyCalendar(){
$('.headerCalendar').html('');
$('#mobiscroll').mobiscroll('destroy');
$('#calendar-legend').html('');
}
var recreated = false;
var currentVal = "";
var PriceSurchargeGlobal = 0;
function createCalendar(){
try{
if (typeof $('#mobiscroll').mobiscroll('getVal') === 'string') {
currentVal = $('#mobiscroll').mobiscroll('getVal');
}
$('#mobiscroll').mobiscroll('destroy');
}catch(ex){
}
// console.log('currentVal',currentVal);
recreated = true;
var now = new Date(),
currYear = now.getFullYear(),
currMonth = now.getMonth(),
currDay = now.getDate(),
min = new Date(currYear, currMonth, currDay),
max = new Date(currYear, currMonth + 6, currDay);
// Mobiscroll Calendar initialization
$('#mobiscroll').mobiscroll().datepicker({
locale: 'de',
monthNames: ['{{"January"|trans}}', '{{"February"|trans}}', '{{"March"|trans}}', '{{"April"|trans}}', '{{"May"|trans}}', '{{"June"|trans}}', '{{"July"|trans}}', '{{"August"|trans}}', '{{"September"|trans}}', '{{"October"|trans}}', '{{"November"|trans}}', '{{"December"|trans}}'],
monthNamesShort: ['{{"Jan"|trans}}', '{{"Feb"|trans}}', '{{"Mar"|trans}}', '{{"Apr"|trans}}', '{{"May"|trans}}', '{{"Jun"|trans}}', '{{"Jul"|trans}}', '{{"Aug"|trans}}', '{{"Sep"|trans}}', '{{"Oct"|trans}}', '{{"Nov"|trans}}', '{{"Dec"|trans}}'],
dayNames: ['{{"Sunday"|trans}}', '{{"Monday"|trans}}', '{{"Tuesday"|trans}}', '{{"Wednesday"|trans}}', '{{"Thursday"|trans}}', '{{"Friday"|trans}}', '{{"Saturday"|trans}}'],
dayNamesMin: ['{{"S"|trans}}', '{{"M"|trans}}', '{{"T"|trans}}', '{{"W"|trans}}', '{{"T"|trans}}', '{{"F"|trans}}', '{{"S"|trans}}'],
dayNamesShort: ['{{"Sun"|trans}}', '{{"Mon"|trans}}', '{{"Tue"|trans}}', '{{"Wed"|trans}}', '{{"Thu"|trans}}', '{{"Fri"|trans}}', '{{"Sat"|trans}}'],
display: 'inline', // Specify display mode like: display: 'bottom' or omit setting to use default
controls: ['calendar'], // More info about controls: https://docs.mobiscroll.com/5-3-0/calendar#opt-controls
select : 'date',
returnFormat : 'iso8601',
{% if WH is not empty %}
defaultSelection : new Date('{{ WH.dateSurcharge|date('Y-m-d') }}T00:00:00'),
{% endif %}
//returnFormat : 'locale',
//lang : 'de',
/*min: min, // More info about min: https://docs.mobiscroll.com/5-3-0/calendar#opt-min
max: max, */ // More info about max: https://docs.mobiscroll.com/5-3-0/calendar#opt-max
showWeekNumbers: true,
firstDay: 1,
//headerText: 'Sie haben den {value} als Lieferdatum gewählt.',
pages: 'auto',
onPageLoading: function (event, inst) { // More info about onPageLoading: https://docs.mobiscroll.com/5-3-0/calendar#event-onPageLoading
console.log('Page loading');
getPrices(event.firstDay, function callback(bookings) {
// console.log('bookings',bookings);
inst.setOptions({
//labels: bookings.labels, // More info about labels: https://docs.mobiscroll.com/5-3-0/calendar#opt-labels
invalid: bookings.invalid, // More info about invalid: https://docs.mobiscroll.com/5-3-0/calendar#opt-invalid
colors : bookings.colors,
max : bookings.max,
min : bookings.min
});
labels = bookings.labels_index;
var html = '';
$.each(bookings.legends_colors,function(v,i){
html += '<div class="row grid-x"><div class="cell small-6"><span class="circle" style="background:'+i[0]+'">'+i[2]+'</span></div><div class="cell small-6" style="text-align: right;line-height: 32px;">'+ i[1]+' </div></div>';
});
$('#calendar-legend').html(html);
// console.log('valor general',$('#price_general_surcharge').val());
//var first_price_surcharge = $('.price_surcharge')[0];
if ($('#price_general_surcharge').val() == ""){
SetHeaderCustomer(bookings.min,bookings.first_price_surcharge);
$('.price_surcharge').each(function(){
// console.log('loading calendar');
$(this).val(bookings.first_price_surcharge);
});
$('#price_general_surcharge').val(bookings.first_price_surcharge);
}
});
},
onPageLoaded: function (event, inst) {
console.log('Page loaded');
SetCurrentDate();
/* console.log('currentVal Loaded',String(currentVal));
console.log('labels Loaded',labels);
console.log('recreated',recreated);
console.log('entra',recreated && currentVal != '');*/
if (recreated && currentVal != ''){
//console.log(currentVal);
inst.setVal(currentVal);
recreated = false;
var ps = labels[String(currentVal)];
//currentVal = '';
// var ps = undefined;
var error = '';
if (ps === undefined){
try{
if (typeof $('#mobiscroll').mobiscroll('getVal') === 'string') {
currentVal = $('#mobiscroll').mobiscroll('getVal');
ps = labels[currentVal];
$('.price_surcharge').val(ps);
// console.log('loaded',ps);
$('#price_general_surcharge').val(ps);
if (ps != undefined){
SetHeaderCustomer(currentVal,ps);
}
//$('#calculate').click();
}
}catch(ex){
console.log('error',ex);
}
//alert('Error to select date, please select again');
error = 'error';
}else{
SetHeaderCustomer(currentVal,ps);
$('.price_surcharge').val(ps);
$('#price_general_surcharge').val(ps);
$('#calculate').click();
}
}
},
onCellClick: function (event, inst) {
var date = new Date(event.date);
// console.log('select date', date);
var date_key = inst.value;
const offset = date.getTimezoneOffset()
var yourDate = new Date(date.getTime() - (offset*60*1000))
// console.log('date9', yourDate.toISOString().split('T')[0]);
date_key = yourDate.toISOString().split('T')[0];
var ps = labels[date_key];
/* console.log('date_key',date_key);
console.log('ps',ps);*/
SetCurrentDate(date_key);
var error = '';
if (ps === undefined){
//alert('Error to select date, please select again');
error = 'error';
}else{
SetHeaderCustomer(date_key,ps);
$('#date_surcharge').val(date_key);
$('.price_surcharge').val(ps);
$('#price_general_surcharge').val(ps);
// console.log('tiene ps',ps);
$('#calculate').click();
}
//console.log(event,date_key,ps,error);
}
});
}
function SetHeaderCustomer(date_surcharge,ps){
const url = $('#urlheader').val();
const header_id = $('#header_id').val();
$.ajax({
type: 'post',
url: url,
data: {'header_id':header_id,'date_surcharge': date_surcharge, 'ps': ps},
success: function (response) {
//console.log( $(obj).find('.diameters' + $(obj).data('id')),$(obj).data('id'));
// console.log(response);
}
});
}
function SetCurrentDate(d){
d = d == undefined ? $('#mobiscroll').mobiscroll('getVal') : d;
//var mydate = new Date($('#mobiscroll').mobiscroll('getVal'));
var date = d;
var arr = date.split('-');
var new_date = arr[2]+'.'+arr[1]+'.'+arr[0];
$('.headerCalendar').html("{{ 'Sie haben den'|trans }} " + new_date + " {{ 'als Lieferdatum gewählt.'|trans }}");
}
function getPrices(d, callback) {
var invalid = [],
labels = [],
colors = [];
//console.log('price_surcharge',$('.price_surcharge').val());
// console.log('price_surchargeT', PriceSurchargeGlobal);
var url_c = '{{ path('wi_cam_calendar_days',{'id':'idV'}) }}';
$.ajax({
type: 'get',
url: url_c.replace('idV',$('#header_id').val()),
//url: '?id='+$('#header_id').val(),
success: function (response) {
callback(response);
}
})
}
function getLegend(){
var url_c = '{{ path('wi_cam_calendar_days',{'id':'idV'}) }}';
$.ajax({
type: 'get',
url: url_c.replace('idV',$('#header_id').val()),
//url: '?id='+$('#header_id').val(),
success: function (response) {
var html = '';
$.each(response.legends_colors,function(v,i){
//html += '<span class="circle" style="background:'+i[0]+'">'+i[2]+'</span>'+ i[1]+' <br>';
html += '<div class="row grid-x"><div class="cell small-6"><span class="circle" style="background:'+i[0]+';color: '+i[3]+';">'+i[2]+'</span></div><div class="cell small-6" style="text-align: right;line-height: 32px;">'+ i[1]+' </div></div>';
});
$('#calendar-legend').html(html);
}
})
}
function setPositionsRows(send_request){
send_request = send_request == undefined ? true : send_request;
var ln = 0;
var positions = [];
$('.fileRow').each(function(){
ln++;
$(this).find('.position').html(ln);
var id = $(this).data('id');
var lp = {'identify':id,'order':ln};
positions.push(lp);
//console.log(lp);
if ($(this).hasClass('invalid')){
console.log('#row'+id,$('#row'+id).find('.pos_invalid'));
$('#row'+id).find('.pos_invalid').html(ln);
}
});
if (send_request){
$.ajax({
type: 'post',
url: '/de/upload/update_positions',
data: {'positions': positions},
success: function (response) {
console.log('update_positions');
}
});
}
}
$(document).ready(function(){
// $('#btSend').click();
});
</script>
<input type="hidden" value=" {{"Minimum purchase" | trans}}">
{% endblock %}