templates/themes/ottcomputer/wicam/index.html.twig line 1

Open in your IDE?
  1. {% extends 'content.cad2cut.html.twig' %}
  2. {% block body_classes %}{% spaceless %}
  3.     is-ctl-product is-act-detail is-calculation custom-bg
  4. {% endspaceless %}{% endblock %}
  5. {% block container_inner %}
  6.     {{ include('includes/modal-confirm-offer.html.twig') }}
  7.     <script>
  8.         const MSG_UPLOAD_ERROR = '{{ "One or more files cannot be read."|trans }}';
  9.         const MSG_MAX_UPLOAD_FILES = '{{ "You cannot send more than %maxUploadFiles% files at the same time."|trans({'%maxUploadFiles%':maxUploadFiles}) }}'
  10.         const MSG_MAX_UPLOAD_FILES_NOT_LOGIN = '{{ "For further calculation please register in our webshop or log in to your existing account."|trans }}'
  11.         const REMOVE_FILE = '{{ 'Remove File'|trans }}'
  12.         const MSG_DELETE_NOTE = '{{ 'Are you sure to delete this note?'|trans }}'
  13.         const MSG_DELETE_OPTION = '{{ 'Are you sure to delete this option?'|trans }}'
  14.     </script>
  15.     {% if toEdit %}
  16.         <style>
  17.             header,footer{
  18.                 display:none;
  19.             }
  20.         </style>
  21.     {% endif %}
  22.     {% set header_id = "" %}
  23.     {% set wicam_header_id = "" %}
  24.     {% set date_surcharge = "" %}
  25.     {% if WH is not empty %}
  26.         {% set header_id = WH.wicamHeaderId %}
  27.         {% set wicam_header_id = WH.wicamHeaderId %}
  28.         {% set guid = WH.guid %}
  29.         {% set date_surcharge = WH.dateSurcharge | date('Y-m-d') %}
  30.     {% endif %}
  31. <div class="grid-x grid-margin-x">
  32.     <input type="hidden" id="guid" name="guid" value="{{ guid }}">
  33.     <input type="hidden" id="header_id" name="header_id" value="{{ header_id }}">
  34.     <input type="hidden" id="wicam_header_id" name="wicam_header_id" value="{{ wicam_header_id }}">
  35.     <input type="hidden" id="urlheader" value="{{ path('wi_cam_set_header') }}">
  36.     <input type="hidden" id="date_surcharge" value="{{ date_surcharge }}">
  37.     <input type="hidden" id="url_calculate" value="{{ path('wi_cam_calculate') }}">
  38.     <input type="hidden" id="url_multiple_surcharges" value="{{ path('multiple_surcharges') }}">
  39.     <input type="hidden" id="url_add_item" value="{{ path('calculation_addItem') }}">
  40.     <input type="hidden" id="messageMissingFields" value="{{ "Please enter/select the missing values!"|trans }}">
  41.     <input type="hidden" id="maxUploadFiles" value="{{ maxUploadFiles }}">
  42.     <input type="hidden" id="isLoggedIn" value="{{ isLoggedIn }}">
  43.     <span id="editModal"></span>
  44.     <div class="cell medium-9" id="detail-content">
  45.         <div class="grid-x grid-margin-x">
  46.             <div class="cell small-12 medium-6">
  47.                 <form action="{{ path('wi_cam_upload') }}" id="WiCamFiles" style="height: 100%">
  48.                     <h3><b>{{ "CAD Datei hochladen"|trans }}</b></h3>
  49.                     <div class="dz-message needsclick">
  50.                         {{ "Drop %maxUploadFiles% files here or click to upload."|trans({'%maxUploadFiles%':maxUploadFiles}) }}
  51.                         <br>
  52.                         <div id="messageLimitFiles" class="hide" style="color: red">
  53.                             {{ "For further calculation please register in our webshop or log in to your existing account."|trans }}
  54.                         </div><button type="button" class="button margin-top-1">{{ "CAD Datei hochladen"|trans }}</button>
  55.                     </div>
  56.                 </form>
  57.             </div>
  58.             <div class="cell small-12 medium-6">
  59.                 <form class="custom-form" action="{{ path('wi_cam_send') }}" data-generate="{{ path('wi_cam_generate') }}" id="WiCamSend">
  60.                     <h3 class="text-left"><b>{{ "Choose Shape"|trans }}</b></h3>
  61.                     <div class="owl-carousel owl-carousel-custom-form owl-theme">
  62.                         {% for sh in shapes %}
  63.                             <div class="item" data-id="{{ sh.id }}">
  64.                                 <img src="{{ sh.smallImage }}" style="height: 90px;width: auto;" title="{{ sh.description|trans }}" alt="{{ sh.description|trans }}">
  65.                             </div>
  66.                         {% endfor %}
  67.                     </div>
  68.                     <button type="button" id="btChooseShape" name="btChooseShape"  class="button">{{ "Choose Shape"|trans }}</button>
  69.                 </form>
  70.             </div>
  71.         </div>
  72.         <form action="{{ path('wi_cam_send') }}" data-generate="{{ path('wi_cam_generate') }}" id="WiCamSend" style="margin-top:10px;">
  73.             <button type="button" id="btSend" class="button secondary disabled">{{ "Send Files" | trans }}</button>
  74.             <!--<button type="button" id="btChooseShape" name="btChooseShape"  class="button secondary">{{ "Choose Shape"|trans }}</button>-->
  75.         </form>
  76.         <ul id="files" style="display:none;">
  77.             <!-- <input type="hidden" id="a20efaea-3369-4fb9-a3ba-ff3be7179cf1" data-name="Ronde_Lochblech_002.dxf" value="6109b05cc84cb.dxf"> -->
  78.         </ul>
  79.         {% set general_setting_box_show = general_setting_box  ? '' : 'hide' %}
  80.         <div class="listing-header callout {{ general_setting_box_show }}">
  81.             <div class="header-options">
  82.                {% if toEdit %}
  83.                    {% if is_granted('ROLE_ADMIN') %}
  84.                        <input type="hidden" id="action-load-customers" value="{{ path('wi_cam_load_customer') }}">
  85.                        <div class="grid-x align-spaced align-middle grid-margin-x">
  86.                            <div class="cell small-12 medium-12">
  87.                                <label>{{ "Representative" | trans }}:</label>
  88.                                <select id="representative" name="representative">
  89.                                    {% if representatives is not empty %}
  90.                                        <option></option>
  91.                                        {% for representative in representatives %}
  92.                                            {% set selected = ' ' %}
  93.                                            {% if WH is not empty %}
  94.                                                {% if WH.representativeId|default(0) == representative.id %}
  95.                                                    {% set selected = 'selected' %}
  96.                                                {% endif %}
  97.                                            {% endif %}
  98.                                            <option value="{{ representative.id }}" {{ selected }} >{{ representative.firstName }} {{ representative.lastName }}</option>
  99.                                        {% endfor %}
  100.                                    {% endif %}
  101.                                </select>
  102.                            </div>
  103.                        </div>
  104.                    {% endif %}
  105.                {% endif %}
  106.                 {% if isRepresentativeOrAdmin %}
  107.                     <div class="grid-x align-spaced align-middle grid-margin-x">
  108.                         <div class="cell small-12 medium-12">
  109.                             <label>{{ "Customer" | trans }}:</label>
  110.                             <select id="customer" name="customer">
  111.                                 {% if customers is not empty %}
  112.                                     <option></option>
  113.                                     {% for customer in customers %}
  114.                                         {% set selected = ' ' %}
  115.                                         {% if WH is not empty %}
  116.                                             {% if WH.customerId|default(0) == customer.id %}
  117.                                                 {% set selected = 'selected' %}
  118.                                             {% endif %}
  119.                                         {% endif %}
  120.                                         <option value="{{ customer.id }}" {{ selected }} >{{ customer.name }} {{ customer.lastName }}</option>
  121.                                     {% endfor %}
  122.                                 {% endif %}
  123.                             </select>
  124.                         </div>
  125.                     </div>
  126.                 {% endif %}
  127.                 <div class="grid-x align-spaced align-middle grid-margin-x">
  128.                     <div class="cell small-4 medium-2" data-url="{{ path('wi_cam_postcodes') }}">
  129.                         <label>{{ "PLZ (Pflichtfeld)" | trans }}</label>
  130.                         <input readonly="readonly" type="text" name="plz" id="plz" value="{{ WH is not empty ? WH.plz : "" }}">
  131.                         <input type="hidden" name="plz_value" id="plz_value" value="">
  132.                     </div>
  133.                     <div class="cell small-8 medium-10">
  134.                         <label>&nbsp;</label>
  135.                         <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 : '')}}">
  136.                     </div>
  137.                 </div>
  138.                 <hr>
  139.                 <div class="grid-x align-spaced align-middle grid-margin-x">
  140.                     <div class="cell small-12 medium-4">
  141.                         <label>{{"Material Grades" | trans}}</label>
  142.                         <select id="materialgrade_filter" class="materialgrade_filter">
  143.                             <option value="0">{{"Choose one" | trans}}</option>
  144.                             {%  for mg in materialgrades %}
  145.                                 {% set selected = ' ' %}
  146.                                 {% if materialgrades|length == 1 %}
  147.                                     {% set selected = ' selected ' %}
  148.                                 {% endif %}
  149.                                 <option value="{{ mg.id }}" {{ selected }} >{{ mg.description }}</option>
  150.                             {% endfor %}
  151.                         </select>
  152.                     </div>
  153.                     <div class="cell small-12 medium-4">
  154.                         <label>{{"Dicke"|trans}}</label>
  155.                         <select id="thickness_filter" class="thickness_filter">
  156.                             <option value="0">{{"Choose one" | trans}}</option>
  157.                             {%  for th in thickness %}
  158.                                 <option value="{{ th.id }}">{{ th.value }} mm</option>
  159.                             {% endfor %}
  160.                         </select>
  161.                     </div>
  162.                     <div class=" cell small-12 medium-4">
  163.                         <label>{{"Stück"|trans}}</label>
  164.                         <div class="input-group expanded amount" style="margin-bottom:1rem;">
  165.                             <button class="button minus" type="button" disabled>-</button>
  166.                             <input name="amount_filter"
  167.                                    id="amount_filter"
  168.                                    type="number" value="0"
  169.                                    oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
  170.                                    maxlength="6"
  171.                                    max="9999"
  172.                                    pattern="number"
  173.                                    class="amount amount_value_filter" style="padding:0px;"/>
  174.                             <button class="button plus" type="button">+</button>
  175.                         </div>
  176.                     </div>
  177.                 </div>
  178.                  <div class="grid-x align-spaced align-middle grid-margin-x">
  179.                     <div class="cell small-12 medium-8">
  180.                         <label>{{"Surcharges" | trans}}</label>
  181.                         {%  for mg in surcharges_items %}
  182.                             <label class="container_surcharge" >
  183.                                 <input type="checkbox" class="surcharges_chk_filter" name="surcharges_chk_filter" value="{{ mg.id }}">
  184.                                 <span class="">{{ mg.descriptions[app.request.locale] }}</span>
  185.                             </label>
  186.                         {% endfor %}
  187.                     </div>
  188.                      <div class="cell small-12 medium-2">
  189.                          <label>&nbsp;</label>
  190.                          <span>
  191.                             <button type="button" id="btApplyFilter" class="button secondary expand top tooltip-detail" data-tooltip aria-haspopup="true"
  192.                                     data-disable-hover="false" data-allow-html="true"
  193.                                     tabindex="2"
  194.                                     title="{{ "Die folgenden Einstellungen auf alle Bauteile des aktuellen Angebots anwenden" | trans }}">{{ "Apply for all" | trans }}</button>
  195.                         </span>
  196.                      </div>
  197.                      <div class="cell small-12 medium-2">
  198.                          <label>&nbsp;</label>
  199.                          <span>
  200.                             <button type="button" id="btDeleteInvalid" data-open="ShowInvalidData" class="button expand top tooltip-detail" data-tooltip aria-haspopup="true"
  201.                                     data-disable-hover="false" data-allow-html="true"
  202.                                     tabindex="2"
  203.                                     title="{{ "Sie haben ungültige Dateien, wollen Sie diese löschen?" | trans }}" style="display:none;">
  204.                                 <i class="fas fa-exclamation-triangle" style="
  205.                                     position: absolute;
  206.                                     top: 3px;
  207.                                     right: 3px;
  208.                                     font-size: 1.1em;
  209.                                     color:#cc4b37;
  210.                                 "></i>
  211.                                 <span class="invalid_amount"></span>&nbsp;
  212.                                 <span class="single_invalid_text" style="display: none;">{{ "ungültige Datei"|trans }}</span>
  213.                                 <span class="multiple_invalid_text">{{ "ungültige Dateien"|trans }}</span>
  214.                             </button>
  215.                         </span>
  216.                      </div>
  217.                      <span id="calculate"></span>
  218.                  </div>
  219.             </div>
  220.         </div>
  221.         <div id="fileResponse" data-total="{{ path('wi_cam_total') }}">
  222.             {% if WH is not empty %}
  223.                 {{ files|raw }}
  224.             {% endif %}
  225.         </div>
  226.         <DIV id="preview-template" style="display: none;">
  227.             <DIV class="dz-preview dz-file-preview">
  228.                 <DIV class="dz-image"><IMG data-dz-thumbnail=""></DIV>
  229.                 <DIV class="dz-details">
  230.                     <DIV class="dz-size"><SPAN data-dz-size=""></SPAN></DIV>
  231.                     <DIV class="dz-filename"><SPAN data-dz-name=""></SPAN></DIV>
  232.                 </DIV>
  233.                 <DIV class="dz-progress"><SPAN class="dz-upload"
  234.                                                data-dz-uploadprogress=""></SPAN></DIV>
  235.                 <div class="dz-error-message" style="top:95px"><span data-dz-errormessage="">{{ "Error"|trans }}</span></div>
  236.                 <div class="dz-success-mark">
  237.                 </div>
  238.                 <div class="dz-error-mark">
  239.                 </div>
  240.             </DIV>
  241.         </DIV>
  242.     </div>
  243.     <div class="cell medium-3" data-sticky-container>
  244.         <div class="sticky" data-sticky data-margin-top="2" data-sticky-on="medium"
  245.              data-check-every="0"
  246.              data-anchor="detail-content">
  247.             <div id="buyboxLoading" class="modal-loading"><div class="loader"></div></div>
  248.             <input type="text" id="price_general_surcharge" class="hide" value="{{ WH is not empty ? WH.priceSurchargeId|default(0) }}">
  249.             <div class="show-for-medium" id="buybox-large">
  250.                 {{ include('includes/buybox-wicam.html.twig') }}
  251.             </div>
  252.             <div>
  253.                 {{ include('includes/wicam-calendar.html.twig',{'notes':notes}) }}
  254.             </div>
  255.         </div>
  256.     </div>
  257. </div>
  258. <div class="hide-for-medium">
  259.     {{ include('includes/buybox-wicam-mobile.html.twig') }}
  260. </div>
  261. <div class="reveal" id="LoadingModal" data-reveal data-close-on-click="false" data-close-on-esc="false">
  262.     <h3>{{ "Sending Files" | trans }} <img src="{{ asset('build/unionstahl/images/loading.gif','unionstahl') }}" width="50" class="loading-modal-img"/></h3>
  263.     <hr>
  264.     <p>{{ "We process your files... it won't take much longer." | trans }}</p>
  265.     <div id="list_files">
  266.     </div>
  267.     <button type="button" class="button custom-close-reveal-modal hide" disabled id="closeLoadingModal">Close</button>
  268. </div>
  269. <div class="reveal" id="LoadingDetail" data-reveal data-close-on-click="false" data-close-on-esc="false">
  270.     <h3>{{ "Loading Details" | trans }} <img src="{{ asset('build/unionstahl/images/loading.gif','unionstahl') }}" width="50" /></h3>
  271.     <hr>
  272.     <p>{{ "We process your data... it won't take much longer." | trans }}</p>
  273. </div>
  274.     <div class="reveal" id="ShowInvalidData" data-reveal data-close-on-click="false" data-close-on-esc="false">
  275.         <h3>{{ "Ungültige Dateien" | trans }} </h3>
  276.         <hr>
  277.         <span class="single-invalid">{{ "Sie haben 1 ungültige Datei, wollen Sie diese löschen?"|trans }}</span>
  278.         <span class="multiple-invalids_str" style="display: none;">{{ "Sie haben #fileNumber ungültige Dateien, wollen Sie diese löschen?"|trans }}</span>
  279.         <span class="multiple-invalids"></span>
  280.         <div class="article-listing-header  callout hide-for-small-only" style="    border: 0px;/* padding: 1rem; */margin-bottom: 0.5rem;">
  281.             <div class="grid-x align-justify align-middle grid-margin-x">
  282.                 <div class="cell small-1 font-bold">
  283.                     {{"Pos"|trans}}
  284.                 </div>
  285.                 <div class="cell small-5 font-bold">
  286.                     {{"Dateiname"|trans}}
  287.                 </div>
  288.                 <div class="cell small-6 font-bold">
  289.                     {{"Hinweis"|trans}}
  290.                 </div>
  291.             </div>
  292.         </div>
  293.         <div id="invalid_list_files"></div>
  294.         <button class="close-button" data-close aria-label="Close modal" type="button">
  295.             <span aria-hidden="true">&times;</span>
  296.         </button>
  297.         <hr>
  298.         <button type="button" class="button" id="btDeleteAllInvalidFiles">
  299.             {{ "Ungültige Dateien aus Bestellung entfernen"|trans }}
  300.         </button>
  301.     </div>
  302.     <div class="reveal" id="DeleteConfirmation" data-reveal data-close-on-click="false" data-close-on-esc="false">
  303.         <h3>{{ "Bestätigung erforderlich" | trans }}</h3>
  304.         <input type="hidden" id="row_identification">
  305.         <hr>
  306.         <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>
  307.         <p id="delete_str_show">{{ "Are you sure to delete this position?" | trans }}</p>
  308.         <hr>
  309.         <button type="button" id="btDeleteRow" class="button secondary">{{ "Ja, Position entfernen"|trans }}</button>
  310.         <button type="button" class="button primary white-borders" style="vertical-align: top;" data-close>{{ "Nein, Position beibehalten"|trans }}</button>
  311.     </div>
  312.     <div class="large reveal" id="ShapeModal" data-reveal>
  313.         <input type="hidden" id="url_properties" value="{{ path('shape_properties') }}">
  314.         <input type="hidden" id="url_results" value="{{ path('calculation_results') }}">
  315.         <input type="hidden" name="shapeId" id="shapeId" value="">
  316.         <input type="hidden" name="WiCamIdentify" id="WCamIdentify" value="">
  317.         <div class="grid-container" id="ShapeList">
  318.             <h3>{{ "Choose a shape"|trans }}</h3>
  319.             <ul class="tabs" data-tabs id="deeplinked-tabs">
  320.                 <li class="tabs-title is-active"><a href="#panel1d" aria-selected="true">{{ "Form"|trans }}</a></li>
  321. {#                <li class="tabs-title"><a href="#panel2d">{{ "Most Frequently"|trans }}</a></li>#}
  322.             </ul>
  323.             <div class="tabs-content" data-tabs-content="deeplinked-tabs">
  324.                 <div class="tabs-panel is-active" id="panel1d">
  325.                     <div class="grid-x shapeContainer">
  326.                         {% for sh in shapes %}
  327.                             <div class="cell small-6 medium-2 large-2">
  328.                                 <div class="card shape" data-id="{{ sh.id }}">
  329.                                     <div class="card-section">
  330.                                         <img src="{{ sh.image }}" style="height: 100px;">
  331.                                         <h5>{{ sh.description|trans }}</h5>
  332.                                     </div>
  333.                                 </div>
  334.                             </div>
  335.                         {% endfor %}
  336.                     </div>
  337.                  </div>
  338.                 <div class="tabs-panel" id="panel2d">
  339.                     <div class="grid-x shapeContainer">
  340.                         {% for sh in shapesFrequently %}
  341.                             <div class="cell small-6 medium-2 large-2">
  342.                                 <div class="card shape" data-id="{{ sh.id }}">
  343.                                     <div class="card-section">
  344.                                         <img src="{{ sh.image }}" style="height: 100px;">
  345.                                         <h5>{{ sh.description }}</h5>
  346.                                     </div>
  347.                                 </div>
  348.                             </div>
  349.                         {% endfor %}
  350.                     </div>
  351.                 </div>
  352.             </div>
  353.         </div>
  354.         <div class="grid-container" id="CalculationInfo">
  355.             <div class="info">Loading...</div>
  356.             <button class="button primary white-borders" id="btBack">{{ "Back"|trans }}</button>
  357.             <button class="button secondary" id="btAddToOverview" disabled>{{ "Add"|trans }}</button>
  358.         </div>
  359.         <button class="close-button" data-close aria-label="Close modal" type="button">
  360.             <span aria-hidden="true">&times;</span>
  361.         </button>
  362.     </div>
  363.     <div class="large reveal" id="calculationModal" data-reveal>
  364.         <h3>{{"Calculation Form"|trans}} - <span class="title"></span></h3>
  365.     </div>
  366. {% endblock %}
  367. {% block javascripts_extend %}
  368. <style>
  369.     @media (max-width: 767px) {
  370.         .sticky {
  371.             padding-top: 0 !important;
  372.             position: initial !important;
  373.         }
  374.     }
  375.     #btAddToOverview {
  376.         float: right;
  377.     }
  378.     .dropzone{
  379.         max-height: 365px;
  380.         overflow: auto;
  381.     }
  382.     .dropzone .dz-preview{
  383.         margin: 11px;
  384.     }
  385.     .dropzone .dz-message{
  386.         margin: 0;
  387.     }
  388.     .required{
  389.         border: 1px solid #cc4b37;
  390.     }
  391.     .lb_circle{
  392.         display: inline-block;
  393.     }
  394.     #list_files .row{
  395.         width: 90%;
  396.     }
  397.     #list_files{
  398.         max-height: 270px;
  399.         overflow: auto;
  400.     }
  401.     .label.alert{
  402.         background: #FF8716;
  403.     }
  404.     .select2-container--default .select2-selection--single{
  405.         padding-top: 5px;
  406.         padding-bottom: 5px;
  407.         height: 38px;
  408.     }
  409.     .select2-container--default .select2-selection--single .select2-selection__arrow{
  410.         height: 36px;
  411.     }
  412. </style>
  413. <link rel="stylesheet" href="{{ asset('assets/jquery/mobiscroll.custom/css/mobiscroll.jquery.min.css?v=1.3') }}">
  414. <script src="{{ asset('assets/jquery/mobiscroll.custom/js/mobiscroll.jquery.min.js') }}"></script>
  415. <script>
  416.     var labels = [];
  417.     try{
  418.         mobiscroll.setOptions({
  419.             locale: mobiscroll.localeEn,                 // Specify language like: locale: mobiscroll.localePl or omit setting to use default
  420.             theme: 'ios',                                // Specify theme like: theme: 'ios' or omit setting to use default
  421.             themeVariant: 'light'                    // More info about themeVariant: https://docs.mobiscroll.com/5-3-0/calendar#opt-themeVariant
  422.         });
  423.     }catch (e) {
  424.     }
  425.     $(function () {
  426.         //createCalendar();
  427.         $('#fileResponse').sortable({
  428.             connectWith: "#fileResponse",
  429.             handle: ".position",
  430.             stop: function() {
  431.                 setPositionsRows();
  432.             }
  433.         });
  434.     });
  435.     function DestroyCalendar(){
  436.         $('.headerCalendar').html('');
  437.         $('#mobiscroll').mobiscroll('destroy');
  438.         $('#calendar-legend').html('');
  439.     }
  440.     var recreated = false;
  441.     var currentVal = "";
  442.     var PriceSurchargeGlobal = 0;
  443.     function createCalendar(){
  444.         try{
  445.             if (typeof $('#mobiscroll').mobiscroll('getVal') === 'string') {
  446.                 currentVal = $('#mobiscroll').mobiscroll('getVal');
  447.             }
  448.             $('#mobiscroll').mobiscroll('destroy');
  449.         }catch(ex){
  450.         }
  451.        // console.log('currentVal',currentVal);
  452.         recreated = true;
  453.         var now = new Date(),
  454.             currYear = now.getFullYear(),
  455.             currMonth = now.getMonth(),
  456.             currDay = now.getDate(),
  457.             min = new Date(currYear, currMonth, currDay),
  458.             max = new Date(currYear, currMonth + 6, currDay);
  459.         // Mobiscroll Calendar initialization
  460.         $('#mobiscroll').mobiscroll().datepicker({
  461.             locale: 'de',
  462.             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}}'],
  463.             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}}'],
  464.             dayNames: ['{{"Sunday"|trans}}', '{{"Monday"|trans}}', '{{"Tuesday"|trans}}', '{{"Wednesday"|trans}}', '{{"Thursday"|trans}}', '{{"Friday"|trans}}', '{{"Saturday"|trans}}'],
  465.             dayNamesMin: ['{{"S"|trans}}', '{{"M"|trans}}', '{{"T"|trans}}', '{{"W"|trans}}', '{{"T"|trans}}', '{{"F"|trans}}', '{{"S"|trans}}'],
  466.             dayNamesShort: ['{{"Sun"|trans}}', '{{"Mon"|trans}}', '{{"Tue"|trans}}', '{{"Wed"|trans}}', '{{"Thu"|trans}}', '{{"Fri"|trans}}', '{{"Sat"|trans}}'],
  467.             display: 'inline',                       // Specify display mode like: display: 'bottom' or omit setting to use default
  468.             controls: ['calendar'],                  // More info about controls: https://docs.mobiscroll.com/5-3-0/calendar#opt-controls
  469.             select : 'date',
  470.             returnFormat : 'iso8601',
  471.             {% if WH is not empty %}
  472.             defaultSelection : new Date('{{ WH.dateSurcharge|date('Y-m-d') }}T00:00:00'),
  473.             {% endif %}
  474.             //returnFormat : 'locale',
  475.             //lang : 'de',
  476.             /*min: min,                                // More info about min: https://docs.mobiscroll.com/5-3-0/calendar#opt-min
  477.             max: max,   */                             // More info about max: https://docs.mobiscroll.com/5-3-0/calendar#opt-max
  478.             showWeekNumbers: true,
  479.             firstDay: 1,
  480.             //headerText: 'Sie haben den {value} als Lieferdatum gewählt.',
  481.             pages: 'auto',
  482.             onPageLoading: function (event, inst) {  // More info about onPageLoading: https://docs.mobiscroll.com/5-3-0/calendar#event-onPageLoading
  483.                 console.log('Page loading');
  484.                 getPrices(event.firstDay, function callback(bookings) {
  485.                   //  console.log('bookings',bookings);
  486.                     inst.setOptions({
  487.                         //labels: bookings.labels,     // More info about labels: https://docs.mobiscroll.com/5-3-0/calendar#opt-labels
  488.                         invalid: bookings.invalid,    // More info about invalid: https://docs.mobiscroll.com/5-3-0/calendar#opt-invalid
  489.                         colors : bookings.colors,
  490.                         max : bookings.max,
  491.                         min : bookings.min
  492.                     });
  493.                     labels = bookings.labels_index;
  494.                     var html = '';
  495.                     $.each(bookings.legends_colors,function(v,i){
  496.                         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]+'&nbsp;&nbsp;</div></div>';
  497.                     });
  498.                     $('#calendar-legend').html(html);
  499.                 //    console.log('valor general',$('#price_general_surcharge').val());
  500.                     //var first_price_surcharge = $('.price_surcharge')[0];
  501.                     if ($('#price_general_surcharge').val() == ""){
  502.                         SetHeaderCustomer(bookings.min,bookings.first_price_surcharge);
  503.                         $('.price_surcharge').each(function(){
  504.                       //      console.log('loading calendar');
  505.                             $(this).val(bookings.first_price_surcharge);
  506.                         });
  507.                         $('#price_general_surcharge').val(bookings.first_price_surcharge);
  508.                     }
  509.                 });
  510.             },
  511.             onPageLoaded: function (event, inst) {
  512.                 console.log('Page loaded');
  513.                 SetCurrentDate();
  514.                /* console.log('currentVal Loaded',String(currentVal));
  515.                 console.log('labels Loaded',labels);
  516.                 console.log('recreated',recreated);
  517.                 console.log('entra',recreated && currentVal != '');*/
  518.                 if (recreated && currentVal != ''){
  519.                     //console.log(currentVal);
  520.                     inst.setVal(currentVal);
  521.                     recreated = false;
  522.                     var ps = labels[String(currentVal)];
  523.                     //currentVal = '';
  524.                    // var ps = undefined;
  525.                     var error = '';
  526.                     if (ps === undefined){
  527.                         try{
  528.                             if (typeof $('#mobiscroll').mobiscroll('getVal') === 'string') {
  529.                                 currentVal = $('#mobiscroll').mobiscroll('getVal');
  530.                                 ps = labels[currentVal];
  531.                                 $('.price_surcharge').val(ps);
  532.                                // console.log('loaded',ps);
  533.                                 $('#price_general_surcharge').val(ps);
  534.                                 if (ps != undefined){
  535.                                     SetHeaderCustomer(currentVal,ps);
  536.                                 }
  537.                                 //$('#calculate').click();
  538.                             }
  539.                         }catch(ex){
  540.                             console.log('error',ex);
  541.                         }
  542.                         //alert('Error to select date, please select again');
  543.                         error = 'error';
  544.                     }else{
  545.                         SetHeaderCustomer(currentVal,ps);
  546.                         $('.price_surcharge').val(ps);
  547.                         $('#price_general_surcharge').val(ps);
  548.                         $('#calculate').click();
  549.                     }
  550.                 }
  551.             },
  552.             onCellClick: function (event, inst) {
  553.                 var date = new Date(event.date);
  554.                // console.log('select date', date);
  555.                 var date_key = inst.value;
  556.                 const offset = date.getTimezoneOffset()
  557.                 var yourDate = new Date(date.getTime() - (offset*60*1000))
  558.                // console.log('date9', yourDate.toISOString().split('T')[0]);
  559.                 date_key = yourDate.toISOString().split('T')[0];
  560.                 var ps = labels[date_key];
  561.                /* console.log('date_key',date_key);
  562.                 console.log('ps',ps);*/
  563.                 SetCurrentDate(date_key);
  564.                 var error = '';
  565.                 if (ps === undefined){
  566.                     //alert('Error to select date, please select again');
  567.                     error = 'error';
  568.                 }else{
  569.                     SetHeaderCustomer(date_key,ps);
  570.                     $('#date_surcharge').val(date_key);
  571.                     $('.price_surcharge').val(ps);
  572.                     $('#price_general_surcharge').val(ps);
  573.                    // console.log('tiene ps',ps);
  574.                     $('#calculate').click();
  575.                 }
  576.                 //console.log(event,date_key,ps,error);
  577.             }
  578.         });
  579.     }
  580.     function SetHeaderCustomer(date_surcharge,ps){
  581.         const url = $('#urlheader').val();
  582.         const header_id = $('#header_id').val();
  583.         $.ajax({
  584.             type: 'post',
  585.             url: url,
  586.             data: {'header_id':header_id,'date_surcharge': date_surcharge, 'ps': ps},
  587.             success: function (response) {
  588.                 //console.log( $(obj).find('.diameters' + $(obj).data('id')),$(obj).data('id'));
  589.              //   console.log(response);
  590.             }
  591.         });
  592.     }
  593.     function SetCurrentDate(d){
  594.         d = d == undefined ? $('#mobiscroll').mobiscroll('getVal') : d;
  595.         //var mydate = new Date($('#mobiscroll').mobiscroll('getVal'));
  596.         var date =  d;
  597.         var arr = date.split('-');
  598.         var new_date = arr[2]+'.'+arr[1]+'.'+arr[0];
  599.         $('.headerCalendar').html("{{ 'Sie haben den'|trans }} " + new_date + " {{ 'als Lieferdatum gewählt.'|trans }}");
  600.     }
  601.     function getPrices(d, callback) {
  602.         var invalid = [],
  603.             labels = [],
  604.             colors = [];
  605.         //console.log('price_surcharge',$('.price_surcharge').val());
  606.        // console.log('price_surchargeT', PriceSurchargeGlobal);
  607.         var url_c = '{{ path('wi_cam_calendar_days',{'id':'idV'}) }}';
  608.         $.ajax({
  609.             type: 'get',
  610.             url: url_c.replace('idV',$('#header_id').val()),
  611.             //url: '?id='+$('#header_id').val(),
  612.             success: function (response) {
  613.                 callback(response);
  614.             }
  615.         })
  616.     }
  617.     function getLegend(){
  618.         var url_c = '{{ path('wi_cam_calendar_days',{'id':'idV'}) }}';
  619.         $.ajax({
  620.             type: 'get',
  621.             url: url_c.replace('idV',$('#header_id').val()),
  622.             //url: '?id='+$('#header_id').val(),
  623.             success: function (response) {
  624.                 var html = '';
  625.                 $.each(response.legends_colors,function(v,i){
  626.                     //html += '<span class="circle" style="background:'+i[0]+'">'+i[2]+'</span>'+ i[1]+'&nbsp;&nbsp;<br>';
  627.                     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]+'&nbsp;&nbsp;</div></div>';
  628.                 });
  629.                 $('#calendar-legend').html(html);
  630.             }
  631.         })
  632.     }
  633.     function setPositionsRows(send_request){
  634.         send_request = send_request == undefined ? true : send_request;
  635.         var ln = 0;
  636.         var positions = [];
  637.         $('.fileRow').each(function(){
  638.             ln++;
  639.             $(this).find('.position').html(ln);
  640.             var id = $(this).data('id');
  641.             var lp = {'identify':id,'order':ln};
  642.             positions.push(lp);
  643.             //console.log(lp);
  644.             if ($(this).hasClass('invalid')){
  645.                 console.log('#row'+id,$('#row'+id).find('.pos_invalid'));
  646.                 $('#row'+id).find('.pos_invalid').html(ln);
  647.             }
  648.         });
  649.         if (send_request){
  650.             $.ajax({
  651.                 type: 'post',
  652.                 url: '/de/upload/update_positions',
  653.                 data: {'positions': positions},
  654.                 success: function (response) {
  655.                     console.log('update_positions');
  656.                 }
  657.             });
  658.         }
  659.     }
  660.     $(document).ready(function(){
  661.        // $('#btSend').click();
  662.     });
  663. </script>
  664. <input type="hidden" value=" {{"Minimum purchase" |  trans}}">
  665. {% endblock %}