templates/invoices.import.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block body %}
  3. <div class="container">
  4.   <div class="row">
  5.     <div class="col s12">
  6.       <div class="card">
  7.         <div class="card-content">
  8.               <span class="card-title">Importa CSV Shopify</span>
  9.               <form action="{{ path('invoices_shopify_import') }}" method="POST" enctype="multipart/form-data">
  10.               <p>Da questa sezione hai la possibilità di importare un file CSV di Shopify, ed ottenere un file da importare in Dashboard.</p>
  11.                <div class="file-field input-field">
  12.                  <div class="btn">
  13.                     <span>Seleziona un file</span>
  14.                    <input type="file" name="file-shopify-csv">
  15.                  </div>
  16.                  <div class="file-path-wrapper">
  17.                       <input class="file-path validate" type="text">
  18.                  </div>
  19.              </div>
  20.              <button class="btn waves-effect waves-light" type="submit" name="action">Carica CSV</button>
  21.              </form>
  22.           </div>
  23.           <div class="card-content">
  24.               <span class="card-title">Importa Ordini da file CSV</span>
  25.               <form action="{{ path('invoices_import') }}" method="POST" enctype="multipart/form-data">
  26.               <p>Da questa sezione hai la possibilità di importare un file CSV delle fatture/corrispettivi, verificare quali sono gli ordini nuovi o esistenti, e confermare l'importazione.</p>
  27.                <div class="file-field input-field">
  28.                  <div class="btn">
  29.                     <span>Seleziona un file</span>
  30.                    <input type="file" name="file-csv">
  31.                  </div>
  32.                  <div class="file-path-wrapper">
  33.                       <input class="file-path validate" type="text">
  34.                  </div>
  35.              </div>
  36.              <button class="btn waves-effect waves-light" type="submit" name="action">Carica CSV</button>
  37.              </form>
  38.           </div>
  39.          </div>
  40.       </div>
  41.   </div>
  42.   
  43.   {% if checkNumerazioneFatture|length > 0 %}
  44.     <div id="checkNumerazioneFatture" class="card">
  45.         <div class="card-content" style="color:#F00">
  46.               <p class="alert alert-danger">ATTENZIONE! Il check sulla numerazione delle fatture per l'anno in corso ha restituito un errore:</p>
  47.               <hr/>
  48.               <p><b>Ultima fattura corretta: </b> {{ checkNumerazioneFatture['ultima_fattura_ok'] }} (Ordine {{ checkNumerazioneFatture['ultimo_ordine_ok'] }} del {{ checkNumerazioneFatture['ultima_fattura_ok_data']|date('Y-m-d') }})</p>
  49.               <p><b>Fattura errata: </b> {{ checkNumerazioneFatture['error_fattura'] }} (Ordine {{ checkNumerazioneFatture['error_order'] }} del {{ checkNumerazioneFatture['error_fattura_data']|date('Y-m-d') }})</p>
  50.           </div>
  51.       </div>
  52.   {% endif %}
  53.   {% if stats is not empty %}
  54.   <div class="row">
  55.     <div class="col s12">
  56.       <div class="card">
  57.           <div class="card-content">
  58.               <span class="card-title">Anteprima Importazione CSV</span>
  59.             <table class="striped">
  60.     <thead>
  61.         <tr><th></th><th>Total</th><th>IDs</th></tr>
  62.     </thead>
  63.     <tbody>
  64.         <tr>
  65.             <td><b style="color:#DD0">Nuovi</b></td>
  66.             <td><b>{{ stats.new }}</b></td>
  67. <td>
  68. {% for s in stats.new_ids %}
  69.         <i>{{ s }}</i> 
  70. {% endfor %}
  71. </td>
  72.         </tr>
  73.         
  74.         <tr>
  75.             <td><b style="color:#880">Esistenti</b></td>
  76.             <td><b>{{ stats.exist }}</b></td>
  77.             <td>
  78.             {% for s in stats.exist_ids %}
  79.                     <i>{{ s }}</i> 
  80.             {% endfor %}
  81.             </td>
  82.         </tr>    
  83.     </tbody>
  84. </table>
  85. <hr/>
  86.             {% if check_vat_errors|length > 0 %}
  87.                 <h4> Verifica Aliquote IVA</h4>
  88.                 {% for check in check_vat_errors %}
  89.                     <div class="card-content" style="border: 1px solid">
  90.                             <table>
  91.                                 <thead>
  92.                                     <tr>
  93.                                         <th>Ordine</th>
  94.                                         <th>Tax Rate Shopify</th>
  95.                                         <th>Tax Rate Paese (Dashboard) </th>
  96.                                         <th>Tax Rate Provincia (Dashboard) </th>
  97.                                         <th>Order Vat Rate (File) </th>
  98.                                         <th>Stato</th>
  99.                                     </tr>
  100.                                 </thead>
  101.                                 <tbody>
  102.                                     <tr class="{% if check['IsError'] != "OK" %}error{% endif %}">
  103.                                         <td>{{ check['Order'] }}</td>
  104.                                         <td>{{ check['Country'] }} {{ check['Shopify Country Rate'] }}%</td>
  105.                                         <td>{{ check['Shipping Country'] }} {{ check['Manebi Country Rate'] }}%</td>
  106.                                         <td>{{ check['Shipping Country'] }} {{ check['Province Tax Rate'] }}%</td>
  107.                                         <td>{{ check['OrderVatRate'] }}%</td>
  108.                                         <td><span class="">
  109.                                             {% if check['IsError'] == 'ERROR-ORDERVATRATE-DIFF-PROVINCETAXRATE' %}Order Vat Rate specificato ({{ check['OrderVatRate'] }}%) è diverso da quello della Provincia ({{ check['Province Tax Rate'] }}%){% endif %}
  110.                                             {% if check['IsError'] == 'ERROR-ORDERVATRATE-NULL' %}Order Vat Rate non è specificato{% endif %}
  111.                                             {% if check['IsError'] == 'ERROR-PROVINCETAXRATE-NULL' %}Vat Rate della Provincia non specificata in Dashboard{% endif %}
  112.                                             {% if check['IsError'] == 'OK' %}OK{% endif %}
  113.                                         </td>
  114.                                     </tr>
  115.                                 </tbody>
  116.                             </table>
  117.                     </div>
  118.                 {% endfor %}
  119.             {% endif %}
  120.             {% if has_vat_errors %}
  121.                 <p class="alert alert-danger"> <b>ATTENZIONE! Alcuni ordini presentano un Tax Rate su Shopify diverso da quello presente sulla piattaforma</b> </p>
  122.                 <hr />
  123.                 <p>Il paese potrebbe aver cambiato la propria aliquota IVA, si prega di controllare e segnalare a Tembo il nuovo valore del tax rate per il Paese o la Provincia.
  124.             </div>
  125.             {% else %}
  126.             <form action="{{ path('invoices_import') }}?loadInvoices=1" method="POST">
  127.                     <button class="waves-effect waves-light btn-large" style="background-color:#bd352e" type="submit" name="action">Conferma e Carica i dati</button>
  128.             </form>
  129.             {% endif %}
  130.           </div>
  131.         </div>
  132.       </div>
  133.   </div>
  134.   {% endif %}
  135.   
  136.   {% if load_results is not empty %}
  137.   <div class="row">
  138.     <div class="col s12">
  139.       <div class="card">
  140.           <div class="card-content">
  141.               <span class="card-title">Risultati del caricamento</span>
  142.             <table class="striped">
  143.     <thead>
  144.         <tr><th></th><th>Total</th><th>IDs</th></tr>
  145.     </thead>
  146.     <tbody>
  147.         <tr>
  148.             <td><b style="color:#DD0">Inserite</b></td>
  149.             <td><b>{{ load_results.inserted }}</b></td>
  150. <td>
  151. {% for s in load_results.inserted_ids %}
  152.         <i>{{ s }}</i> 
  153. {% endfor %}
  154. </td>
  155.         </tr>
  156.         
  157.         <tr>
  158.             <td><b style="color:#880">Modificate</b></td>
  159.             <td><b>{{ load_results.modified }}</b></td>
  160. <td>
  161. {% for s in load_results.modified_ids %}
  162.         <i>{{ s }}</i> 
  163. {% endfor %}
  164. </td>
  165.         </tr>
  166.         
  167.     </tbody>
  168.   </table>
  169.           </div>
  170.         </div>
  171.       </div>
  172.   </div>
  173.   {% endif %}
  174.   
  175. <div class="row">
  176.     <hr />
  177. </div>
  178. <div class="row">
  179.     <div class="col s12">
  180.       <div class="card">
  181.           <div class="card-content">
  182.               <span class="card-title">Log importazioni Fatture/Corrispettivi</span>
  183.             <p>Da questa sezione puoi annullare l'ultima importazione.</p>
  184.               <table class="table table-striped">
  185.                 <thead>
  186.                     <tr>
  187.                         <th>ID Importazione</th>
  188.                         <th>File</th>
  189.                         <th>Righe caricate</th>
  190.                         <th>Righe importate</th>
  191.                         <th>Data Upload File</th>
  192.                         <th>Data Conferma Importazione</th>
  193.                         <th>Data Eliminazione Importazione</th>
  194.                         <th></th>
  195.                     </tr>
  196.                 </thead>
  197.                 <tbody>
  198.                 {% for i in importazioni %}
  199.                     <tr>
  200.                         <td>{{ i.id }}</td>
  201.                         <td>{{ i.filename }}</td>
  202.                         <td>{{ i.rows_loaded }}</td>
  203.                         <td>{{ i.rows_processed }}</td>
  204.                         <td>{{ i.date_upload }}</td>
  205.                         <td>{{ i.date_import }}</td>
  206.                         <td>{{ i.date_delete }}</td>
  207.                         <td> {% if i.date_delete == NULL %}<button type="button" class="btn btn-red" style="background-color:#F00" onclick="Manebi.getInvoices({{ i. id }})"> X </button>{% endif %} </td>
  208.                     </tr>
  209.                 {% endfor %}
  210.                 </tbody>
  211.             </table>
  212.           </div>
  213.          </div>
  214.       </div>
  215.   </div>
  216. </div>
  217. <div id="genericPopup" class="modal modal-fixed-footer modal-fixed-header">
  218.         <div class="modal-header"></div>
  219.         <div class="modal-content">
  220.             <p class="alert alert-warning">Queste sono le righe associate a questa integrazione. Verificare  dati che saranno rimossi prima di procedere alla rimozione.</p>
  221.             <hr/>
  222.             <div id="invoices-table-results">
  223.                   <div class="row">
  224.                       <div class="col s4">Risultati: <span id="invoices-table-results-total"></span></div>
  225.                       <div id="invoices-table-results-actions" class="col s8"></div>
  226.                   </div>
  227.               </div>
  228.             <table id="invoices-table" class="striped fixed_header">
  229.                   <thead></thead>
  230.                   <tbody></tbody>
  231.               </table>
  232.         </div>
  233.         <div class="modal-footer">
  234.             <a id="button-delete-log-imports" href="#!" class="waves-effect waves-red btn btn-small" style="background-color: #F00" onclick="deleteLogImports(this)" data-id-log-imports="">CONFERMA ELIMINAZIONE DEI DATI DI QUESTA INTEGRAZIONE</a>
  235.             <a href="#!" class="modal-close waves-effect waves-green btn btn-small">CHIUDI</a>
  236.     </div>
  237. </div> 
  238. </div>
  239. {% endblock %}
  240. {% block javascripts %}
  241. <script src="{{ asset('tmb-data-table.v1_0.min.js') }}"></script>
  242. <script>
  243. var Manebi = {};
  244. var urlAjax = "{{ path('invoices_main') }}";
  245. var invoicesTableColumns =  {
  246.                     'Order': {'headerName': 'Ordine', 'value': 'Order', 'sortable': true},
  247.                     'Numero Fattura': {'headerName': 'Numero Fattura', 'value': 'Numero Fattura', 'sortable': true},
  248.                     'Corrispettivo': {'headerName': 'Corrispettivo', 'value': 'Corrispettivo', 'sortable': true},
  249.                     'Pagato il': {'headerName': 'Pagato il', 'value': 'Paid at', 'sortable': true},
  250. }
  251. //Get Invoices
  252. Manebi.getInvoices = function(id_log_imports)
  253. {
  254.     $.ajax({
  255.         url: urlAjax,
  256.         dataType: "json",
  257.         data: {
  258.             'filter': 1,
  259.             'filter-id-log-imports': id_log_imports
  260.         }
  261.     }).then(function(data) {
  262.         var actions = '';
  263.         tableIncassiPos = new TmbDataTable('invoices-table', invoicesTableColumns, {'pageSize': 100, 'selectable': true});
  264.         tableIncassiPos.setData(data.data).generateTable();
  265.         
  266.         popup = M.Modal.init(document.getElementById('genericPopup'), {'startingTop': '0%', 'endingTop': '0%', 'endingBottom': '10%'});
  267.         $("#button-delete-log-imports").attr("data-id-log-imports", id_log_imports);
  268.         popup.open();
  269.         //window.toggleElement('loader');
  270.     });
  271. }
  272. function deleteLogImports(el)
  273. {
  274.     var id_log_imports = $(el).attr('data-id-log-imports');
  275.     $.ajax({
  276.         url: "{{ path('invoices_import') }}/delete",
  277.         type: "POST",
  278.         dataType: "json",
  279.         data: {
  280.             'id_log_imports': id_log_imports,
  281.         }
  282.     }).then(function(data) {
  283.         var actions = '';
  284.         
  285.         alert('Fatture/Corrispettivi eliminati!');
  286.         window.location = window.location.href.replace(/\#.*/, '');
  287.     });
  288. }
  289. </script>
  290. {% endblock javascripts %}