templates/role/user/ticket/intervention/activity/single.html.twig line 1

Open in your IDE?
  1. {% extends 'role/user/ticket/intervention/index.html.twig' %}
  2. {% block title %}Ticket - Intervento - Attività{% endblock %}
  3. {% block pageTitleH1 %}Ticket - Intervento - Attività{% endblock %}
  4. {% block pageTitleBreadcrumb %}
  5.     <li class="breadcrumb-item"><a href="{{ path ('user_ticket_sheet', {'ticketId':ticket.id}) }}">Ticket</a></li>
  6.     <li class="breadcrumb-item"><a href="javascript:void(0)">Intervento</a></li>
  7.     <li class="breadcrumb-item"><a href="javascript:void(0)">Attività</a></li>
  8. {% endblock %}
  9. {% block subMenuLeft %}
  10.     <li class="nav-item"><a class="nav-link" href="{{ path ('user_ticket_intervention_activity_summary', {'interventionId':intervention.id}) }}">Riassunto</a></li>
  11. {% endblock %}
  12. {% block subMenuRight %}
  13. {% endblock %}
  14. {% block interventionContent %}
  15.     <div class="row">
  16.         <div class="col-12">
  17.             <h4 class="form_title"><a onclick="showClientWarehouse()" class="cursor_p">Visualizza/Nascondi magazzino cliente</a></h4>
  18.             <hr class="m_t_none">
  19.             <div id="clientWarehouse" style="display:none">
  20.                 {% if ticket.client.warehouse.products|length > 0 %}
  21.                     <table class="table table_no_padding responsive_font_size">
  22.                         <tbody>
  23.                             {% for p in ticket.client.warehouse.products %}
  24.                                 {% if loop.index > 1 %}
  25.                                     <tr><th colspan="2" style="padding-top: 10px!important; padding-bottom: 10px!important;border-bottom-width: 0px;"><hr style="height:1px !important; margin:0px"></th></tr>
  26.                                 {% endif %}
  27.                                 <tr>
  28.                                     <th class="td_w_100p" style="border-bottom: 0px">Modello</th>
  29.                                     <td style="border-bottom: 0px">{{ p.model.name }} ({{ p.model.sku }})</td>
  30.                                 </tr>
  31.                                 <tr>
  32.                                     <th style="border-bottom: 0px">Termid</th>
  33.                                     <td style="border-bottom: 0px">{{ p.termid }}</td>
  34.                                 </tr>
  35.                                 <tr>
  36.                                     <th style="border-bottom: 0px">Matr. Produttore</th>
  37.                                     <td style="border-bottom: 0px">{% if p.codeProducer != null %}<a href="javascript: copyToClipboard({{ p.id }}, 'producer')" class="underline" data-bs-toggle="tooltip" title="Copia matricola">{{ p.codeProducer }}</a>{% else %}---{% endif %}</td>
  38.                                 </tr>
  39.                                 <tr>
  40.                                     <th style="border-bottom: 0px">Matr. Fornitore</th>
  41.                                     <td style="border-bottom: 0px">{% if p.codeSupplier != null %}<a href="javascript: copyToClipboard({{ p.id }}, 'supplier')" class="underline" data-bs-toggle="tooltip" title="Copia matricola">{{ p.codeSupplier }}</a>{% else %}---{% endif %}</td>
  42.                                 </tr>
  43.                                 <input type="hidden" id="product_{{ p.id }}_producer" value="{{ p.codeProducer }}">
  44.                                 <input type="hidden" id="product_{{ p.id }}_supplier" value="{{ p.codeSupplier }}">
  45.                             {% endfor %}
  46.                         </tbody>
  47.                     </table>
  48.                 {% else %}
  49.                     <div class="style-msg infomsg">
  50.                         <div class="sb-msg responsive_font_size">
  51.                             <i class="icon-info-sign"></i><strong>Info:</strong> Nessuna matricola registrata presente su questo cliente!
  52.                         </div>
  53.                     </div>
  54.                 {% endif %}
  55.             </div>
  56.         </div>
  57.     </div>
  58.     <input type="hidden" id="can_submit_withdraw" value="0">
  59.     <input type="hidden" id="can_submit_installation" value="0">
  60.     <input type="hidden" id="can_submit_actual" value="0">
  61.     {{ form_start(form, {'attr': {'novalidate': 'novalidate', 'id':'form'}}) }} 
  62.         <div class="row">
  63.             <div class="col-12">
  64.                 <h4 class="form_title">Dettaglia l'attività: {{ activityType.value }}</h4>
  65.                 <hr class="m_t_none">
  66.             </div>
  67.         </div>
  68.         {# Ritiro #}
  69.         {% if activityType.producerWithdrawMandatory or activityType.supplierWithdrawMandatory %}
  70.             {% if activityType.producerWithdrawMandatory %}
  71.                 <div class="row form-group">
  72.                     <div class="col-10 col-lg-11">
  73.                         <label class="form_label">Ritiro - Matricola produttore*</label>
  74.                         <div {{ form_errors(form.producerWithdraw) }}>
  75.                             {{ form_widget(form.producerWithdraw, {'attr':{'inputmode':'search', 'onKeyDown':'updateButtonSubmit()', 'onBlur':'onBlurManageBarcode("producer_withdraw")'}}) }}
  76.                         </div>
  77.                     </div>
  78.                     <div class="col-2 col-lg-1 txt_a_c">
  79.                         <a href="javascript:openScanditModal('producer_withdraw', 'produttore')"><img src="{{ asset (icon_frame) }}" width="38" class="icon_pr m_t_33p" data-bs-toggle="tooltip" title="Scansiona"></a>
  80.                     </div>
  81.                 </div>
  82.             {% else %}
  83.                 {{ form_widget(form.producerWithdraw, {'attr':{'class':'display_n'}}) }}
  84.             {% endif %}
  85.             {% if activityType.supplierWithdrawMandatory %}
  86.                 <div class="row form-group">
  87.                     <div class="col-10 col-lg-11">
  88.                         <label class="form_label">Ritiro - Matricola fornitore*</label>
  89.                         <div {{ form_errors(form.supplierWithdraw) }}>
  90.                             {{ form_widget(form.supplierWithdraw, {'attr':{'onKeyDown':'updateButtonSubmit()', 'onBlur':'onBlurManageBarcode("supplier_withdraw")'}}) }}
  91.                         </div>
  92.                     </div>
  93.                     <div class="col-2 col-lg-1 txt_a_c">
  94.                         <a href="javascript:openScanditModal('supplier_withdraw', 'fornitore')"><img src="{{ asset (icon_frame) }}" width="38" class="icon_pr m_t_33p" data-bs-toggle="tooltip" title="Scansiona"></a>
  95.                     </div>
  96.                 </div>
  97.             {% else %}
  98.                 {{ form_widget(form.supplierWithdraw, {'attr':{'class':'display_n'}}) }}
  99.             {% endif %}
  100.             <div class="row form-group" id="row_model_withdraw">
  101.                 <div class="col-10 col-lg-11">
  102.                     <label class="form_label">Ritiro - Modello</label>
  103.                     <div {{ form_errors(form.modelWithdraw) }}>
  104.                         {{ form_widget(form.modelWithdraw, {'attr':{'class':'form-control', 'readonly':true}} ) }}
  105.                     </div>
  106.                 </div>
  107.                 <div class="col-2 col-lg-1 txt_a_c">
  108.                     <a href="javascript: selectFromWarehouse('withdraw')"><img src="{{ asset (icon_selection) }}" width="38" class="icon_pr m_t_33p" data-bs-toggle="tooltip" title="Seleziona"></a>
  109.                 </div>
  110.                 <div class="col-12 switch" id="row_component_withdraw" style="display: none">
  111.                 </div>
  112.             </div>
  113.         {% else %}
  114.             {{ form_widget(form.modelWithdraw, {'attr':{'class':'display_n'}}) }}
  115.             {{ form_widget(form.producerWithdraw, {'attr':{'class':'display_n'}}) }}
  116.             {{ form_widget(form.supplierWithdraw, {'attr':{'class':'display_n'}}) }}
  117.         {% endif %}
  118.         {# Installazione #}
  119.         {% if activityType.producerInstallationMandatory or activityType.supplierInstallationMandatory %}
  120.             {% if activityType.producerInstallationMandatory %}
  121.                 <div class="row form-group">
  122.                     <div class="col-10 col-lg-11">
  123.                         <label class="form_label">Installazione - Matricola produttore*</label>
  124.                         <div {{ form_errors(form.producerInstallation) }}>
  125.                             {{ form_widget(form.producerInstallation, {'attr':{'inputmode':'search','onKeyDown':'updateButtonSubmit()', 'onBlur':'onBlurManageBarcode("producer_installation")'}}) }}
  126.                         </div>
  127.                     </div>
  128.                     <div class="col-2 col-lg-1 txt_a_c">
  129.                         <a href="javascript:openScanditModal('producer_installation', 'produttore')"><img src="{{ asset (icon_frame) }}" width="38" class="icon_pr m_t_33p" data-bs-toggle="tooltip" title="Scansiona"></a>
  130.                     </div>
  131.                 </div>
  132.             {% else %}
  133.                 {{ form_widget(form.producerInstallation, {'attr':{'class':'display_n'}}) }}
  134.             {% endif %}
  135.             {% if activityType.supplierInstallationMandatory %}
  136.                 <div class="row form-group">
  137.                     <div class="col-10 col-lg-11">
  138.                         <label class="form_label">Installazione - Matricola fornitore*</label>
  139.                         <div {{ form_errors(form.supplierInstallation) }}>
  140.                             {{ form_widget(form.supplierInstallation, {'attr':{'onKeyDown':'updateButtonSubmit()', 'onBlur':'onBlurManageBarcode("supplier_installation")'}}) }}
  141.                         </div>
  142.                     </div>
  143.                     <div class="col-2 col-lg-1 txt_a_c">
  144.                         <a href="javascript:openScanditModal('supplier_installation', 'fornitore')"><img src="{{ asset (icon_frame) }}" width="38" class="icon_pr m_t_33p" data-bs-toggle="tooltip" title="Scansiona"></a>
  145.                     </div>
  146.                 </div>
  147.             {% else %}
  148.                 {{ form_widget(form.supplierInstallation, {'attr':{'class':'display_n'}}) }}
  149.             {% endif %}
  150.             <div class="row form-group" id="row_model_installation">
  151.                 <div class="col-10 col-lg-11">
  152.                     <label class="form_label">Installazione - Prodotto</label>
  153.                     <div {{ form_errors(form.modelInstallation) }}>
  154.                         {{ form_widget(form.modelInstallation, {'attr':{'readonly':true}} ) }}
  155.                     </div>
  156.                 </div>
  157.                 <div class="col-2 col-lg-1 txt_a_c">
  158.                     <a href="tel:{{ company.phoneSupportTechnician }}"><img class="icon_red m_t_33p" width="38" src="{{ asset (icon_telephone) }}" data-bs-toggle="tooltip" title="Ho un problema"/></a>
  159.                 </div>
  160.             </div>
  161.         {% else %}
  162.             {{ form_widget(form.modelInstallation, {'attr':{'class':'display_n'}}) }}
  163.             {{ form_widget(form.producerInstallation, {'attr':{'class':'display_n'}}) }}
  164.             {{ form_widget(form.supplierInstallation, {'attr':{'class':'display_n'}}) }}
  165.         {% endif %}
  166.         {# Attuale #}
  167.         {% if activityType.producerActualMandatory or activityType.supplierActualMandatory %}
  168.             {% if activityType.producerActualMandatory %}
  169.                 <div class="row form-group">
  170.                     <div class="col-10 col-lg-11">
  171.                         <label class="form_label">Attuale - Matricola produttore*</label>
  172.                         <div {{ form_errors(form.producerActual) }}>
  173.                             {{ form_widget(form.producerActual, {'attr':{'inputmode':'search', 'onKeyDown':'updateButtonSubmit()', 'onBlur':'onBlurManageBarcode("producer_actual")'}}) }}
  174.                         </div>
  175.                     </div>
  176.                     <div class="col-2 col-lg-1 txt_a_c">
  177.                         <a href="javascript:openScanditModal('producer_actual', 'produttore')"><img src="{{ asset (icon_frame) }}" width="38" class="icon_pr m_t_33p" data-bs-toggle="tooltip" title="Scansiona"></a>
  178.                     </div>
  179.                 </div>
  180.             {% else %}
  181.                 {{ form_widget(form.producerActual, {'attr':{'class':'display_n'}}) }}
  182.             {% endif %}
  183.             {% if activityType.supplierActualMandatory %}
  184.                 <div class="row form-group">
  185.                     <div class="col-10 col-lg-11">
  186.                         <label class="form_label">Attuale - Matricola fornitore*</label>
  187.                         <div {{ form_errors(form.supplierActual) }}>
  188.                             {{ form_widget(form.supplierActual, {'attr':{'onKeyDown':'updateButtonSubmit()', 'onBlur':'onBlurManageBarcode("supplier_actual")'}}) }}
  189.                         </div>
  190.                     </div>
  191.                     <div class="col-2 col-lg-1 txt_a_c">
  192.                         <a href="javascript:openScanditModal('supplier_actual', 'fornitore')"><img src="{{ asset (icon_frame) }}" width="38" class="icon_pr m_t_33p" data-bs-toggle="tooltip" title="Scansiona"></a>
  193.                     </div>
  194.                 </div>
  195.             {% else %}
  196.                 {{ form_widget(form.supplierActual, {'attr':{'class':'display_n'}}) }}
  197.             {% endif %}
  198.             <div class="row form-group" id="row_model_actual">
  199.                 <div class="col-10 col-lg-11">
  200.                     <label class="form_label">Attuale - Modello</label>
  201.                     <div {{ form_errors(form.modelActual) }}>
  202.                         {{ form_widget(form.modelActual, {'attr':{'readonly':true}} ) }}
  203.                     </div>
  204.                 </div>
  205.                 <div class="col-2 col-lg-1 txt_a_c">
  206.                     <a href="javascript: selectFromWarehouse('actual')"><img src="{{ asset (icon_selection) }}" width="38" class="icon_pr m_t_33p" data-bs-toggle="tooltip" title="Seleziona"></a>
  207.                 </div>
  208.             </div>
  209.         {% else %}
  210.             {{ form_widget(form.modelActual, {'attr':{'class':'display_n'}}) }}
  211.             {{ form_widget(form.producerActual, {'attr':{'class':'display_n'}}) }}
  212.             {{ form_widget(form.supplierActual, {'attr':{'class':'display_n'}}) }}
  213.         {% endif %}
  214.         <div class="row m_t_50p">
  215.             <div class="col-12 txt_a_c">
  216.                 <a id="button_submit" href="javascript: void()" class="button button-3d button-small button-grey">Inserisci</a>
  217.             </div>
  218.         </div>
  219.         {{ form_widget(form.productWithdrawId) }}
  220.         {{ form_widget(form.modelWithdrawId) }}
  221.         {{ form_widget(form.scanOrManualProducerWithdraw) }}
  222.         {{ form_widget(form.scanOrManualProducerWithdrawCode) }}
  223.         {{ form_widget(form.scanOrManualSupplierWithdraw) }}
  224.         {{ form_widget(form.scanOrManualSupplierWithdrawCode) }}
  225.         {{ form_widget(form.productActualId) }}
  226.         {{ form_widget(form.modelActualId) }}
  227.         {{ form_widget(form.scanOrManualProducerActual) }}
  228.         {{ form_widget(form.scanOrManualProducerActualCode) }}
  229.         {{ form_widget(form.scanOrManualSupplierActual) }}
  230.         {{ form_widget(form.scanOrManualSupplierActualCode) }}
  231.         {{ form_widget(form.productInstallationId) }}
  232.         {{ form_widget(form.scanOrManualProducerInstallation) }}
  233.         {{ form_widget(form.scanOrManualProducerInstallationCode) }}
  234.         {{ form_widget(form.scanOrManualSupplierInstallation) }}
  235.         {{ form_widget(form.scanOrManualSupplierInstallationCode) }}
  236.         
  237.         <input type="hidden" name="activityTypeId" value="{{ activityType.id }}">
  238.         <input type="hidden" name="ticketId" value="{{ ticket.id }}">
  239.     {{ form_end(form) }}
  240.     <div id="selectProductModal" class="modal fade" tabindex="-1" role="dialog">
  241.         <div class="modal-dialog modal-lg" role="document">
  242.             <div class="modal-content">
  243.                 <div class="modal-header"><h3 class="modal-title">Seleziona prodotto dal magazzino cliente</h3></div>
  244.                 <div class="modal-body">
  245.                     <div class="row">
  246.                         <div class="col-12 overflow_a">
  247.                             <table id="table_products" class="table table-sm responsive_font_size">
  248.                                 <thead>
  249.                                     <tr>
  250.                                         <td colspan="2"><input type="text" class="form-control font_12" id="filter_search_product" onKeyPress="searchProducts()" onBlur="searchProducts()"/></td>
  251.                                     </tr>
  252.                                 </thead>
  253.                                 <tbody id="tbody_products">
  254.                                 </tbody>
  255.                             </table>
  256.                         </div>
  257.                     </div>
  258.                 </div>
  259.                 <div class="modal-footer txt_a_c">
  260.                     <a href="javascript:void(0)" class="button button-3d button-mini button-pr" data-bs-dismiss="modal">Chiudi</a>
  261.                 </div>
  262.             </div>
  263.         </div>
  264.     </div>
  265.     <div id="selectModelModal" class="modal fade" tabindex="-1" role="dialog">
  266.         <div class="modal-dialog modal-lg" role="document">
  267.             <div class="modal-content">
  268.                 <div class="modal-header"><h3 class="modal-title">Seleziona modello</h3></div>
  269.                 <div class="modal-body">
  270.                     <div class="row">
  271.                         <div class="col-12 overflow_a">
  272.                             <table id="table_models" class="table table-sm responsive_font_size">
  273.                                 <thead>
  274.                                     <tr>
  275.                                         <td colspan="5" class="txt_a_c"><a href="javascript: updateSelectCodeModal('products')" class="button button-3d button-mini button-pr">Cerca prodotto nel magazzino cliente</a></td>
  276.                                     </tr>
  277.                                     <tr>
  278.                                         <td><input type="text" class="form-control font_12" id="filter_search_model" onKeyPress="searchModels()" onBlur="searchModels()"/></td>
  279.                                         <td class="td_action"><a href="tel:{{ company.phoneSupportTechnician }}" data-bs-toggle="tooltip" title="Richiedi inserimento nuovo"><img class="icon_red" src="{{ asset (icon_telephone) }}" /></a></td>
  280.                                     </tr>
  281.                                 </thead>
  282.                                 <tbody id="tbody_models">
  283.                                 </tbody>
  284.                             </table>
  285.                         </div>
  286.                     </div>
  287.                 </div>
  288.                 <div class="modal-footer txt_a_c">
  289.                     <a href="javascript:void(0)" class="button button-3d button-mini button-pr" data-bs-dismiss="modal">Chiudi</a>
  290.                 </div>
  291.             </div>
  292.         </div>
  293.     </div>
  294.     <input type="hidden" id="selected_type">
  295.     <input type="hidden" id="scanned_type">
  296.     <div id="modalWarehouseOther" class="modal fade" tabindex="-1" role="dialog">
  297.         <div class="modal-dialog" role="document">
  298.             <div class="modal-content">
  299.                 <div class="modal-header"><h3 class="modal-title">Magazzino non corrispondente</h3></div>            
  300.                 <div class="modal-body">
  301.                     <input type="hidden" id="move_product_id">
  302.                     <input type="hidden" id="move_type">
  303.                     <div class="row">
  304.                         <div class="col-12 txt_a_c">
  305.                             <input type="hidden" id="move_product_type" />
  306.                             <label class="modal_subtitle">Attenzione!</label>
  307.                             <p class="modal_paragraph">La matricola corrisponde a un prodotto che è presente nel magazzino <span id="move_warehouse_nickname" class="f_w_b"></span>!</p>
  308.                             {% if app.user.accountTypology != "technician" %}
  309.                                 <p class="modal_paragraph">Cliccando sul bottone <a class='button button-3d button-mini button-green' href='javascript:void(0)'>sposta</a> lo inserirai nel magazzino corretto per poter chiudere l'intervento.<br>Si è sicuri di voler proseguire?</p>
  310.                             {% else %}
  311.                                 <a href="tel:{{ company.phoneSupportTechnician }}"><img class="icon_red m_t_33p" width="38" src="{{ asset (icon_telephone) }}" data-bs-toggle="tooltip" title="Ho un problema"/></a>
  312.                             {% endif %}
  313.                         </div>
  314.                     </div>
  315.                 </div>
  316.                 <div class="modal-footer">
  317.                     {% if app.user.accountTypology != "technician" %}
  318.                         <a href="javascript:void(0)" class="button button-3d button-mini button-red f_left" data-bs-dismiss="modal">Annulla</a>
  319.                         <a href="javascript:moveProduct()" class="button button-3d button-mini button-green f_right">Sposta</a>
  320.                     {% else %}
  321.                         <a href="javascript:void(0)" class="button button-3d button-mini button-red" data-bs-dismiss="modal">Annulla</a>
  322.                     {% endif %}
  323.                 </div>
  324.             </div>
  325.         </div>
  326.     </div>
  327.     <div id="scanditReaderModal" class="modal fade" tabindex="-1" role="dialog">
  328.         <div class="modal-dialog modal-lg" role="document">
  329.             <div class="modal-content">
  330.                 <div class="modal-header"><h3 class="modal-title">Inquadra matricola <span id="scandit_code_type" class="color_w"></span></h3></div>                
  331.                 <div class="modal-body">
  332.                     <input type="hidden" id="scandit_reader_active" value="0">
  333.                     <div id="data-capture-view"></div>
  334.                     <a id="scandit_button_scan" href="javascript: scanditUpdateScan(1)" class="button button-3d button-mini button-green" style="position: fixed; bottom: 30%; right: 10px;">Attiva scansione</a>
  335.                 </div>
  336.                 <div class="modal-footer txt_a_c">
  337.                     <a href="javascript:void(0)" class="button button-3d button-mini button-pr" data-bs-dismiss="modal">Chiudi</a>
  338.                 </div>
  339.             </div>
  340.         </div>
  341.     </div>
  342. {% endblock %}
  343. {% block javascripts %}
  344.     {{ parent() }}
  345.     {% include 'components/js/scandit_js.html.twig' with {'action':'intervention'} %}
  346.     {% if activityType.pos %}{% set posAccessory = "POS" %}{% else %}{% set posAccessory = "Accessorio" %}{% endif %}
  347.     <script>
  348.         $(document).ready(function(){
  349.             {% if activityType.producerWithdrawMandatory or activityType.supplierWithdrawMandatory %}
  350.                 showWithdrawModelComponent(document.getElementById('form_intervention_activity_modelWithdrawId').value);
  351.             {% endif %}
  352.             {% if activityType.producerWithdrawMandatory == false and activityType.supplierWithdrawMandatory == false %}
  353.                 updateCanSubmitField("producer_withdraw", 1);
  354.             {% endif %}
  355.             {% if activityType.producerActualMandatory == false and activityType.supplierActualMandatory == false %}
  356.                 updateCanSubmitField("producer_actual", 1);
  357.             {% endif %}
  358.             {% if activityType.producerInstallationMandatory == false and activityType.supplierInstallationMandatory == false %}
  359.                 updateCanSubmitField("producer_installation", 1);
  360.             {% endif %}
  361.             updateButtonSubmit();
  362.         });
  363.             
  364.         document.body.addEventListener("keypress", function(e) {
  365.             if(e.key == 'Enter' || e.key == 'Tab'){
  366.                 switch(document.activeElement.id){
  367.                     case 'form_intervention_activity_producerWithdraw': var type = 'producer_withdraw'; break;
  368.                     case 'form_intervention_activity_supplierWithdraw': var type = 'supplier_withdraw'; break;
  369.                     case 'form_intervention_activity_producerInstallation': var type = 'producer_installation'; break;
  370.                     case 'form_intervention_activity_supplierInstallation': var type = 'supplier_installation'; break;
  371.                     case 'form_intervention_activity_producerActual': var type = 'producer_actual'; break;
  372.                     case 'form_intervention_activity_supplierActual': var type = 'supplier_actual'; break;
  373.                     default: break;
  374.                 }
  375.                 document.activeElement.blur();
  376.             }
  377.         });
  378.         
  379.         function openScanditModal(type, label){
  380.             document.getElementById('scanned_type').value = type;
  381.             document.getElementById('scandit_code_type').innerHTML = label;
  382.             $('#scanditReaderModal').modal({backdrop: 'static', keyboard: false}).modal("show");
  383.         }
  384.         
  385.         function closeModal(){
  386.             document.getElementById('scandit_reader_active').value = 0;
  387.             $('#scanditReaderModal').modal('hide');
  388.         }
  389.         
  390.         function selectFromWarehouse(type){
  391.             var typeVal = '';
  392.             document.getElementById('selected_type').value = type;
  393.             switch(type){
  394.                 case 'actual': typeVal = 'Actual'; break;
  395.                 case 'withdraw': typeVal = 'Withdraw'; break;
  396.                 default: break;
  397.             }
  398.             if(document.getElementById('form_intervention_activity_producer' + typeVal).value != '' || document.getElementById('form_intervention_activity_supplier' + typeVal).value != ''){
  399.                 searchModels();
  400.                 $('#selectModelModal').modal({backdrop: 'static', keyboard: false}).modal("show");
  401.             }
  402.             else{
  403.                 searchProducts();
  404.                 $('#selectProductModal').modal({backdrop: 'static', keyboard: false}).modal("show");
  405.             }        
  406.         }
  407.         function updateSelectCodeModal(table){
  408.             if(table == 'models'){
  409.                 searchModels();
  410.                 $('#selectProductModal').modal('hide');
  411.                 $('#selectModelModal').modal({backdrop: 'static', keyboard: false}).modal("show");
  412.             }
  413.             else{
  414.                 searchProducts();
  415.                 $('#selectModelModal').modal('hide');
  416.                 $('#selectProductModal').modal({backdrop: 'static', keyboard: false}).modal("show");
  417.             }
  418.         }
  419.         {# PRODUCTS #}
  420.         function searchProducts(){
  421.             var type = document.getElementById('selected_type').value;
  422.             var filter = document.getElementById('filter_search_product').value;
  423.             $.post('{{ path ("user_ticket_intervention_activity_product_search") }}', {ticketId:"{{ ticket.id }}", interventionId:"{{ intervention.id }}", activityTypeId:"{{ activityType.id }}", type:type, filter: filter, isPos:"{{ isPos }}"}, function(response){ 
  424.                 if(response.code == 200 && response.success){
  425.                     var tbody = document.getElementById('tbody_products');
  426.                     tbody.innerHTML = '';
  427.                     var products = JSON.parse(response.products);
  428.                     
  429.                     if(products.length > 0){
  430.                         for(i=0; i<products.length; i++){
  431.                             var tr = document.createElement('tr');
  432.                             var td = document.createElement('td');
  433.                             var tdSel = document.createElement('td');
  434.                             td.innerHTML = '<table class="table table_no_padding b_none m_b_none"><tr><th class="td_w_120p">Modello</th><td id="model_' + products[i].id + '">' + products[i].modelName + '</td></tr><tr><th>Matr. produttore</th><td id="code_producer_' + products[i].id + '">' + products[i].codeProducer + '</td></tr><tr><th id="code_supplier_' + products[i].id + '">Matr. fornitore</th><td>' + products[i].codeSupplier + '</td></tr></table>';
  435.                             tdSel.className = 'td_action';
  436.                             tdSel.innerHTML = '<a href="javascript: selectProduct(' + products[i].id + ')" data-bs-toggle="tooltip" title="Seleziona"><img class="icon_green" src="{{ asset (icon_select) }}" /></a>';
  437.                             tr.appendChild(td);
  438.                             tr.appendChild(tdSel);
  439.                             tbody.appendChild(tr);
  440.                         }
  441.                     }
  442.                     else{
  443.                         var tr = document.createElement('tr');
  444.                         var td = document.createElement('td');
  445.                         td.setAttribute('colspan', '2');
  446.                         td.innerHTML = 'La ricerca non ha trovato prodotti, <a href="javascript: updateSelectCodeModal(\'models\')" class="button button-3d button-mini button-pr">Inserisci nuovo modello</a>';
  447.                         tr.appendChild(td);
  448.                         tbody.appendChild(tr);
  449.                     }
  450.                 }
  451.             }, "json");
  452.         }
  453.         function selectProduct(productId){
  454.             if(document.getElementById('selected_type').value == 'withdraw'){
  455.                 document.getElementById('form_intervention_activity_modelWithdrawId').value = null;
  456.                 document.getElementById('form_intervention_activity_productWithdrawId').value = productId;
  457.                 document.getElementById('form_intervention_activity_modelWithdraw').value = document.getElementById('model_' + productId).innerHTML;
  458.                 document.getElementById('form_intervention_activity_producerWithdraw').value = document.getElementById('code_producer_' + productId).innerHTML;
  459.                 document.getElementById('form_intervention_activity_supplierWithdraw').value = document.getElementById('code_supplier_' + productId).innerHTML;
  460.             }
  461.             if(document.getElementById('selected_type').value == 'installation'){
  462.                 document.getElementById('form_intervention_activity_modelInstallationId').value = null;
  463.                 document.getElementById('form_intervention_activity_productInstallationId').value = productId;
  464.                 document.getElementById('form_intervention_activity_modelInstallation').value = document.getElementById('model_' + productId).innerHTML;
  465.                 document.getElementById('form_intervention_activity_producerInstallation').value = document.getElementById('code_producer_' + productId).innerHTML;
  466.                 document.getElementById('form_intervention_activity_supplierInstallation').value = document.getElementById('code_supplier_' + productId).innerHTML;
  467.             }
  468.             if(document.getElementById('selected_type').value == 'actual'){
  469.                 document.getElementById('form_intervention_activity_modelActualId').value = null;
  470.                 document.getElementById('form_intervention_activity_productActualId').value = productId;
  471.                 document.getElementById('form_intervention_activity_modelActual').value = document.getElementById('model_' + productId).innerHTML;
  472.                 document.getElementById('form_intervention_activity_producerActual').value = document.getElementById('code_producer_' + productId).innerHTML;
  473.                 document.getElementById('form_intervention_activity_supplierActual').value = document.getElementById('code_supplier_' + productId).innerHTML;
  474.             }
  475.             $('#selectProductModal').modal({backdrop: 'static', keyboard: false}).modal("hide");
  476.         }
  477.         {# MODELS #}
  478.         function searchModels(){
  479.             var filter = document.getElementById('filter_search_model').value;
  480.             $.post('{{ path ("user_ticket_intervention_activity_model_search") }}', {interventionId: "{{ intervention.id }}", activityTypeId:"{{ activityType.id }}", isPos:"{{ isPos }}", filter: filter}, function(response){ 
  481.                 if(response.code == 200 && response.success){
  482.                     var tbody = document.getElementById('tbody_models');
  483.                     tbody.innerHTML = '';
  484.                     var models = JSON.parse(response.models);
  485.                     
  486.                     if(models.length > 0){
  487.                         for(i=0; i<models.length; i++){
  488.                             var tr = document.createElement('tr');
  489.                             var td = document.createElement('td');
  490.                             var tdName = document.createElement('td');
  491.                             var tdSel = document.createElement('td');
  492.                             
  493.                             td.innerHTML = '<table class="table table_no_padding b_none m_b_none"><tr><th class="td_w_70p">Modello</th><td id="name_' + models[i].id + '">' + models[i].name + '<td><tr><th>Cat/S.Cat</th><td>' + models[i].category + '/' + models[i].subcategory + '</td></tr><tr><th>Produttore</th><td>' + models[i].producer + '</td></tr></table>';
  494.                             tdSel.className = 'td_action';
  495.                             tdSel.innerHTML = '<a href="javascript: selectModel(' + models[i].id + ')" data-bs-toggle="tooltip" title="Seleziona"><img class="icon_green" src="{{ asset (icon_select) }}" /></a>';
  496.                             tr.appendChild(td);
  497.                             tr.appendChild(tdSel);
  498.                             tbody.appendChild(tr);
  499.                         }
  500.                     }
  501.                     else{
  502.                         var tr = document.createElement('tr');
  503.                         var td = document.createElement('td');
  504.                         td.setAttribute('colspan', '2');
  505.                         td.innerHTML = 'La ricerca non ha trovato modelli. Controlla la correttezza della ricerca o richiedi di inserire il modello attraverso il pulsante telefono.';
  506.                         tr.appendChild(td);
  507.                         tbody.appendChild(tr);
  508.                     }
  509.                 }
  510.             }, "json");
  511.         }
  512.         function selectModel(modelId){
  513.             if(document.getElementById('selected_type').value == 'withdraw'){
  514.                 document.getElementById('form_intervention_activity_modelWithdrawId').value = modelId;
  515.                 document.getElementById('form_intervention_activity_modelWithdraw').value = document.getElementById('name_' + modelId).innerHTML;
  516.                 showWithdrawModelComponent(modelId);
  517.             }
  518.             if(document.getElementById('selected_type').value == 'installation'){
  519.                 document.getElementById('form_intervention_activity_modelInstallationId').value = modelId;
  520.                 document.getElementById('form_intervention_activity_modelInstallation').value = document.getElementById('name_' + modelId).innerHTML;
  521.             }
  522.             if(document.getElementById('selected_type').value == 'actual'){
  523.                 document.getElementById('form_intervention_activity_modelActualId').value = modelId;
  524.                 document.getElementById('form_intervention_activity_modelActual').value = document.getElementById('name_' + modelId).innerHTML;
  525.             }
  526.             $('#selectModelModal').modal({backdrop: 'static', keyboard: false}).modal("hide");
  527.         }
  528.         function showWithdrawModelComponent(modelId){
  529.             $.post('{{ path ("user_ticket_intervention_activity_model_components") }}', {activityTypeId: "{{ activityType.id }}", modelId: modelId}, function(response){ 
  530.                 if(response.code == 200 && response.success){
  531.                     var components = JSON.parse(response.components);
  532.                     
  533.                     var rowComponent = document.getElementById('row_component_withdraw');
  534.                     rowComponent.innerHTML = '';
  535.                     rowComponent.className = 'col-12 switch m_t_20p';
  536.                     var table = document.createElement('table');
  537.                     table.className = "table b_none table_no_padding m_none";
  538.                     if(components.length == 0){
  539.                         var tr = document.createElement('tr');
  540.                         tr.innerHTML = '<td style="border-bottom: 2px solid #fff!important;"><label class="m_b_none l_s_none f_w_500 p_tb_0p">Nessun componente associato a questo modello</label></td>';
  541.                         table.appendChild(tr);
  542.                     }
  543.                     else{
  544.                         var label = document.createElement('label');
  545.                         label.className = 'm_b_none l_s_none f_w_500';
  546.                         label.innerHTML = 'Seleziona i componenti che hai ritirato insieme al prodotto/modello';
  547.                         for(i=0; i<components.length; i++){
  548.                             var tr = document.createElement('tr');
  549.                             tr.innerHTML = '<td class="td_w_40p" style="border-bottom: 2px solid #fff!important;"><input id="component_' + components[i].id + '" class="switch-toggle switch-flat-mini switch-toggle-flat" type="checkbox" name="component_' + components[i].id + '"><label for="component_' + components[i].id + '" class="m_b_none p_tb_0p"></label></td><td class="txt_a_l" style="border-bottom: 2px solid #fff!important;"><label class="m_b_none l_s_none f_w_500 p_tb_0p">' + components[i].name + '</label></td>';
  550.                             table.appendChild(tr);
  551.                         }
  552.                         rowComponent.appendChild(label);
  553.                     }
  554.                     rowComponent.appendChild(table);
  555.                     rowComponent.style.display = 'block';
  556.                 }
  557.             }, "json");
  558.         }
  559.         
  560.         function onBlurManageBarcode(type){
  561.             document.getElementById("move_type").value = type;
  562.             switch(type){
  563.                 case 'producer_withdraw': 
  564.                     document.getElementById("move_product_type").value = "withdraw";
  565.                     var codeTypeLabel = "produttore";
  566.                     var code = document.getElementById('form_intervention_activity_producerWithdraw').value;
  567.                     if(document.getElementById('form_intervention_activity_scanOrManualProducerWithdrawCode').value != code){
  568.                         document.getElementById('form_intervention_activity_scanOrManualProducerWithdrawCode').value = code;
  569.                         document.getElementById('form_intervention_activity_scanOrManualProducerWithdraw').value = 'manual';
  570.                     }
  571.                     break;
  572.                 case 'supplier_withdraw': 
  573.                     document.getElementById("move_product_type").value = "withdraw";
  574.                     var codeTypeLabel = "fornitore";
  575.                     var code = document.getElementById('form_intervention_activity_supplierWithdraw').value;
  576.                     if(document.getElementById('form_intervention_activity_scanOrManualSupplierWithdrawCode').value != code){
  577.                         document.getElementById('form_intervention_activity_scanOrManualSupplierWithdrawCode').value = code;
  578.                         document.getElementById('form_intervention_activity_scanOrManualSupplierWithdraw').value = 'manual';
  579.                     }
  580.                     break;
  581.                 case 'producer_installation': 
  582.                     document.getElementById("move_product_type").value = "installation";
  583.                     var codeTypeLabel = "produttore";
  584.                     var code = document.getElementById('form_intervention_activity_producerInstallation').value;
  585.                     if(document.getElementById('form_intervention_activity_scanOrManualProducerInstallationCode').value != code){
  586.                         document.getElementById('form_intervention_activity_scanOrManualProducerInstallationCode').value = code;
  587.                         document.getElementById('form_intervention_activity_scanOrManualProducerInstallation').value = 'manual';
  588.                     }
  589.                     break;
  590.                 case 'supplier_installation': 
  591.                     document.getElementById("move_product_type").value = "installation";
  592.                     var codeTypeLabel = "fornitore";
  593.                     var code = document.getElementById('form_intervention_activity_supplierInstallation').value;
  594.                     if(document.getElementById('form_intervention_activity_scanOrManualSupplierInstallationCode').value != code){
  595.                         document.getElementById('form_intervention_activity_scanOrManualSupplierInstallationCode').value = code;
  596.                         document.getElementById('form_intervention_activity_scanOrManualSupplierInstallation').value = 'manual';
  597.                     }
  598.                     break;
  599.                 case 'producer_actual': 
  600.                     document.getElementById("move_product_type").value = "actual";
  601.                     var codeTypeLabel = "produttore";
  602.                     var code = document.getElementById('form_intervention_activity_producerActual').value;
  603.                     if(document.getElementById('form_intervention_activity_scanOrManualProducerActualCode').value != code){
  604.                         document.getElementById('form_intervention_activity_scanOrManualProducerActualCode').value = code;
  605.                         document.getElementById('form_intervention_activity_scanOrManualProducerActual').value = 'manual';
  606.                     }
  607.                     break;
  608.                 case 'supplier_actual': 
  609.                     document.getElementById("move_product_type").value = "actual";
  610.                     var codeTypeLabel = "fornitore";
  611.                     var code = document.getElementById('form_intervention_activity_supplierActual').value;
  612.                     if(document.getElementById('form_intervention_activity_scanOrManualSupplierActualCode').value != code){
  613.                         document.getElementById('form_intervention_activity_scanOrManualSupplierActualCode').value = code;
  614.                         document.getElementById('form_intervention_activity_scanOrManualSupplierActual').value = 'manual';
  615.                     }
  616.                     break;
  617.                 default: break;
  618.             }
  619.             checkCodePost(type, code, codeTypeLabel);
  620.         }
  621.         function manageBarcode(code){
  622.             var type = document.getElementById('scanned_type').value;
  623.             switch(type){
  624.                 case 'producer_withdraw':
  625.                     document.getElementById("move_product_type").value = "withdraw";
  626.                     var codeTypeLabel = "produttore";
  627.                     document.getElementById('form_intervention_activity_scanOrManualProducerWithdrawCode').value = code;
  628.                     document.getElementById('form_intervention_activity_scanOrManualProducerWithdraw').value = 'scan';
  629.                     break;
  630.                 case 'supplier_withdraw': 
  631.                     document.getElementById("move_product_type").value = "withdraw";
  632.                     var codeTypeLabel = "fornitore";
  633.                     document.getElementById('form_intervention_activity_scanOrManualSupplierWithdrawCode').value = code;
  634.                     document.getElementById('form_intervention_activity_scanOrManualSupplierWithdraw').value = 'scan';
  635.                     break;
  636.                 case 'producer_installation':
  637.                     document.getElementById("move_product_type").value = "installation";
  638.                     var codeTypeLabel = "produttore";
  639.                     document.getElementById('form_intervention_activity_scanOrManualProducerInstallationCode').value = code;
  640.                     document.getElementById('form_intervention_activity_scanOrManualProducerInstallation').value = 'scan';
  641.                     break;
  642.                 case 'supplier_installation': 
  643.                     document.getElementById("move_product_type").value = "installation";
  644.                     var codeTypeLabel = "fornitore";
  645.                     document.getElementById('form_intervention_activity_scanOrManualSupplierInstallationCode').value = code;
  646.                     document.getElementById('form_intervention_activity_scanOrManualSupplierInstallation').value = 'scan';
  647.                     break;
  648.                 case 'producer_actual':
  649.                     document.getElementById("move_product_type").value = "actual";
  650.                     var codeTypeLabel = "produttore";
  651.                     document.getElementById('form_intervention_activity_scanOrManualProducerActualCode').value = code;
  652.                     document.getElementById('form_intervention_activity_scanOrManualProducerActual').value = 'scan';
  653.                     break;
  654.                 case 'supplier_actual': 
  655.                     document.getElementById("move_product_type").value = "actual";
  656.                     var codeTypeLabel = "fornitore";
  657.                     document.getElementById('form_intervention_activity_scanOrManualSupplierActualCode').value = code;
  658.                     document.getElementById('form_intervention_activity_scanOrManualSupplierActual').value = 'scan';
  659.                     break;
  660.                 default: break;
  661.             }
  662.             checkCodePost(type, code, codeTypeLabel);
  663.         }
  664.         
  665.         function checkCodePost(type, code, codeTypeLabel){
  666.             var code = code.toUpperCase();
  667.             $.post('{{ path ("user_ticket_intervention_activity_product_search_code") }}', {ticketId:"{{ ticket.id }}", interventionId:"{{ intervention.id }}", activityTypeId:"{{ activityType.id }}", type:type, code:code}, function(response){ 
  668.                 var response = JSON.parse(response);
  669.                 var canSubmit = false;
  670.                 if(response.code == 200 && response.success)
  671.                 {
  672.                     if(response.found){
  673.                         // Se trovato prodotto
  674.                         var product = JSON.parse(response.product);
  675.                         if(product.posAccessoryOk){
  676.                             // Se POS o Accessorio coerente con il tipo di attività
  677.                             if(product.supplierOk){
  678.                                 // Se il fornitore è tra quelli del prodotto
  679.                                 if(product.otherWarehouse == 1){
  680.                                     // Se non è nel magazzino corretto
  681.                                     if(product.canMove == 1){
  682.                                         document.getElementById('move_product_id').value = product.id;
  683.                                         document.getElementById('move_warehouse_nickname').innerHTML = product.otherWarehouseNickname;
  684.                                         $('#modalWarehouseOther').modal({backdrop: 'static', keyboard: false}).modal('show');
  685.                                         updateCanSubmitField(type, 0);
  686.                                     }
  687.                                     else{
  688.                                         // Se installazione e non posso muovere
  689.                                         printAlertWarning("Il prodotto trovato con codice " + codeTypeLabel + " \"" + code + "\" non può essere spostato perché non è nello stato corretto!");
  690.                                         updateCanSubmitField(type, 0);
  691.                                     }
  692.                                 }
  693.                                 else{
  694.                                     // Se in magazzino corretto
  695.                                     switch(type){
  696.                                         case 'producer_withdraw': 
  697.                                         case 'supplier_withdraw': 
  698.                                             document.getElementById('form_intervention_activity_productWithdrawId').value = product.id;
  699.                                             document.getElementById('form_intervention_activity_modelWithdraw').value = product.model;
  700.                                             document.getElementById('form_intervention_activity_producerWithdraw').value = product.codeProducer;
  701.                                             document.getElementById('form_intervention_activity_supplierWithdraw').value = product.codeSupplier;
  702.                                             showWithdrawModelComponent(product.model.id);
  703.                                             updateCanSubmitField(type, 1);
  704.                                             break;
  705.                                         case 'producer_installation': 
  706.                                         case 'supplier_installation':
  707.                                             // Faccio canMove solo qua perché negli altri 2 casi è sul magazzino cliente e non hanno i trasferimenti
  708.                                             if(product.canMove == 1){
  709.                                                 document.getElementById('form_intervention_activity_productInstallationId').value = product.id;
  710.                                                 document.getElementById('form_intervention_activity_modelInstallation').value = product.model;
  711.                                                 document.getElementById('form_intervention_activity_producerInstallation').value = product.codeProducer;
  712.                                                 document.getElementById('form_intervention_activity_supplierInstallation').value = product.codeSupplier;
  713.                                                 updateCanSubmitField(type, 1);
  714.                                             }
  715.                                             else{
  716.                                                 // Se installazione e non posso muovere
  717.                                                 printAlertWarning("Il prodotto trovato con codice " + codeTypeLabel + " \"" + code + "\" non può essere spostato perché non è in stato disponibile!");
  718.                                                 updateCanSubmitField(type, 0);
  719.                                             }
  720.                                             break;
  721.                                         case 'producer_actual': 
  722.                                         case 'supplier_actual':
  723.                                             document.getElementById('form_intervention_activity_productActualId').value = product.id;
  724.                                             document.getElementById('form_intervention_activity_modelActual').value = product.model;
  725.                                             document.getElementById('form_intervention_activity_producerActual').value = product.codeProducer;
  726.                                             document.getElementById('form_intervention_activity_supplierActual').value = product.codeSupplier;
  727.                                             updateCanSubmitField(type, 1);
  728.                                             break;
  729.                                         default: break;
  730.                                     }
  731.                                 }
  732.                             }
  733.                             else{
  734.                                 // Se fornitore ticket non è tra i fornitori prodotto
  735.                                 printAlertWarning("Il prodotto trovato con codice " + codeTypeLabel + " \"" + code + "\" non può essere usato per il fornitore {{ ticket.supplier.name }}!");
  736.                                 updateCanSubmitField(type, 0);
  737.                             }
  738.                         }
  739.                         else{
  740.                             // Se POS o Accessorio non coerente con l'attività
  741.                             printAlertWarning("Il prodotto trovato con codice " + codeTypeLabel + " \"" + code + "\" non può essere usato per questo tipo di intervento, selezionare un {{ posAccessory }}!");
  742.                             updateCanSubmitField(type, 0);
  743.                         }
  744.                     }
  745.                     else{
  746.                         // Se non ho trovato prodotto
  747.                         if(code != ''){
  748.                             switch(type){
  749.                                 case 'producer_withdraw': 
  750.                                     document.getElementById('form_intervention_activity_producerWithdraw').value = code;
  751.                                     document.getElementById('form_intervention_activity_modelWithdraw').value = '';
  752.                                     document.getElementById('row_component_withdraw').className = 'col-12';
  753.                                     document.getElementById('row_component_withdraw').innerHTML = '';
  754.                                     printAlertInfo("Il codice " + codeTypeLabel + " è utilizzabile, seleziona il modello prima di proseguire!");
  755.                                     updateCanSubmitField(type, 1);
  756.                                     break;
  757.                                 case 'supplier_withdraw': 
  758.                                     document.getElementById('form_intervention_activity_supplierWithdraw').value = code;
  759.                                     document.getElementById('form_intervention_activity_modelWithdraw').value = '';
  760.                                     document.getElementById('row_component_withdraw').className = 'col-12';
  761.                                     document.getElementById('row_component_withdraw').innerHTML = '';
  762.                                     printAlertInfo("Il codice " + codeTypeLabel + " è utilizzabile, seleziona il modello prima di proseguire!");
  763.                                     updateCanSubmitField(type, 1);
  764.                                     break;
  765.                                 case 'producer_installation':
  766.                                     document.getElementById('form_intervention_activity_producerInstallation').value = code;
  767.                                     document.getElementById('form_intervention_activity_modelInstallation').value = '';
  768.                                     printAlertWarning("Nessun prodotto trovato con codice " + codeTypeLabel + " nel magazzino tecnico!");
  769.                                     updateCanSubmitField(type, 0);
  770.                                     break;
  771.                                 case 'supplier_installation':
  772.                                     document.getElementById('form_intervention_activity_supplierInstallation').value = code;
  773.                                     document.getElementById('form_intervention_activity_modelInstallation').value = '';
  774.                                     printAlertWarning("Nessun prodotto trovato con codice " + codeTypeLabel + " nel magazzino tecnico!");
  775.                                     updateCanSubmitField(type, 0);
  776.                                     break;
  777.                                 case 'producer_actual': 
  778.                                     document.getElementById('form_intervention_activity_producerActual').value = code;
  779.                                     document.getElementById('form_intervention_activity_modelActual').value = '';
  780.                                     printAlertInfo("Il codice " + codeTypeLabel + " è utilizzabile, seleziona il modello prima di proseguire!");
  781.                                     updateCanSubmitField(type, 1);
  782.                                     break;
  783.                                 case 'supplier_actual': 
  784.                                     document.getElementById('form_intervention_activity_supplierActual').value = code;
  785.                                     document.getElementById('form_intervention_activity_modelActual').value = '';
  786.                                     printAlertInfo("Il codice " + codeTypeLabel + " è utilizzabile, seleziona il modello prima di proseguire!");
  787.                                     updateCanSubmitField(type, 1);
  788.                                     break;
  789.                                 default: break;
  790.                             }
  791.                         }
  792.                     }
  793.                 }
  794.                 closeModal();
  795.                 updateButtonSubmit();
  796.             });
  797.         }
  798.         function showClientWarehouse(){
  799.             if(document.getElementById("clientWarehouse").style.display == "block")
  800.                 document.getElementById("clientWarehouse").style.display = "none";
  801.             else
  802.                 document.getElementById("clientWarehouse").style.display = "block";
  803.         }
  804.         function moveProduct(){
  805.             var productId = document.getElementById('move_product_id').value;
  806.             var type = document.getElementById("move_product_type").value;
  807.             $.post('{{ path ("user_ticket_intervention_activity_move_product", {"interventionId": intervention.id }) }}', {productId:productId, type: type}, function(response){ 
  808.                 if(response.code == 200 && response.success){
  809.                     printAlertSuccess('Prodotto spostato correttamente!');
  810.                     $('#modalWarehouseOther').modal('hide');
  811.                     onBlurManageBarcode(document.getElementById("move_type").value);
  812.                 }
  813.             }, "json");
  814.         }
  815.         function submitForm(){
  816.             triggerLoading();
  817.             $('#form').submit();
  818.         }
  819.         function updateCanSubmitField(type, value){
  820.             switch(type){
  821.                 case 'producer_withdraw': 
  822.                 case 'supplier_withdraw': 
  823.                     document.getElementById('can_submit_withdraw').value = value;
  824.                     break;
  825.                 case 'producer_installation': 
  826.                 case 'supplier_installation':
  827.                     document.getElementById('can_submit_installation').value = value;
  828.                     break;
  829.                 case 'producer_actual': 
  830.                 case 'supplier_actual':
  831.                     document.getElementById('can_submit_actual').value = value;
  832.                     break;
  833.                 default: break;
  834.             }
  835.         }
  836.         function updateButtonSubmit(){
  837.             var csW = document.getElementById('can_submit_withdraw').value;
  838.             var csA = document.getElementById('can_submit_actual').value;
  839.             var csI = document.getElementById('can_submit_installation').value;
  840.             var buttonSubmit = document.getElementById('button_submit');
  841.             if(csW == 1 && csA == 1 && csI == 1){
  842.                 buttonSubmit.className = "button button-3d button-small button-green";
  843.                 buttonSubmit.href = "javascript: submitForm()";
  844.             }
  845.             else{
  846.                 buttonSubmit.className = "button button-3d button-small button-grey";
  847.                 buttonSubmit.href = "javascript: void()";
  848.             }
  849.         }
  850.     </script>
  851. {% endblock %}