<!DOCTYPE html>
<html lang="en">
  
<head>
    <title><%= lang_data.shipments %> <%= lang_data.Report %></title>
    <%- include('./partials/meta'); -%>

</head>
<body>
    <%- include('./partials/header_sidebar'); -%> 

        <div class="page-body">
            <div class="container-fluid">
                <div class="page-title">
                    <div class="row">
                        <div class="col-sm-6">
                            <h3><%= lang_data.Report %></h3>
                        </div>
                        <div class="col-sm-6">
                            <ol class="breadcrumb">
                                <li class="breadcrumb-item"><a href="/index"><i data-feather="home"></i></a></li>
                                <li class="breadcrumb-item"><a href="/report/shipment"><%= lang_data.shipments %> <%= lang_data.Report %></a></li>
                            </ol>
                        </div>
                    </div>
                </div>
            </div>
            <!-- Container-fluid starts-->
            <div class="container-fluid">
                <div class="row">
                            
                    <!-- Scroll - vertical dynamic Starts-->
                    <div class="col-sm-12">
                        <div class="card">
                            <div class="card-header pb-0 d-flex justify-content-between">
                                <h4><%= lang_data.shipments %> <%= lang_data.Report %></h4>
                            </div>
                            
                            <input type="hidden" id="rates_sym" value="<%= accessdata.data.site_currency %>">
                            <input type="hidden" id="rates_pla" value="<%= accessdata.data.currency_placement %>">
                            <input type="hidden" id="thousands_replace" value="<%= accessdata.data.thousands_separator %>">

                            <div class="card-body">

                                <div class="row mb-3">
                                    <div class="col-6">
                                      <div class="col-form-label"><%= lang_data.Start_Date %></div>
                                      <input class="form-control digits shipment" type="date" id="shipment_start_date">
                                    </div>
                                    
                                    <div class="col-6">
                                      <div class="col-form-label"><%= lang_data.End_Date %></div>
                                      <input class="form-control digits shipment" type="date" id="shipment_end_date">
                                    </div>
                                </div>

                                <div class="dt-ext table-responsive theme-scrollbar">
                                    <table class="display" id="export-button" aria-label="table">
                                        <thead>
                                            <tr>
                                                <th class="d-none"></th>
                                                <th>#</th>
                                                <th><%= lang_data.Tracking %></th>
                                                <th><%= lang_data.date %></th>
                                                <th><%= lang_data.Sender %></th>
                                                <th><%= lang_data.Recipient %></th>
                                                <th><%= lang_data.Payment %></th>
                                                <th><%= lang_data.status %></th>
                                                <th><%= lang_data.total_cost %></th>
                                                <th><%= lang_data.invoice_status %></th>
                                            </tr>
                                        </thead>
                                        <tbody id="shipment_tbody">
                                            <% var no = 1 %>
                                            <% shipment_list.forEach((data) => { %>
                                                <tr>
                                                    <td class="d-none"></td>
                                                    <td><%= no %></td>
                                                    <td class="text-nowrap"><%= data.invoice %></td>
                                                    <td class="text-nowrap"><%= data.date.toLocaleDateString() %></td>
                                                    <td class="text-nowrap"><%= data.customers_firstname %> <%= data.customers_lastname %></td>
                                                    <td class="text-nowrap"><%= data.client_firstname %> <%= data.client_lastname %></td>
                                                    <td class="text-nowrap"><%= data.payment_type_name %></td>
                                                    <td class="text-nowrap">
                                                        <% if (data.shipping_status == 'Delivered') { %>
                                                            <span class="badge badge-success p-2">Delivered</span>
                                                        <% } else if (data.shipping_status == 'Pending Approval') { %>
                                                            <% if (role_data.role == '1') { %>

                                                                <span class="badge badge-primary p-2">Complete shipment</span>
                                                            <% } else { %>

                                                                <span class="badge badge-danger p-2">Pending approval</span>
                                                            <% } %>
                                                        <% } else if (data.shipping_status == 'Pending') { %>

                                                            <span class="badge badge-warning p-2"><%= data.shipping_status %></span>
                                                        <% } else if (data.delivery_status == '2') { %>

                                                            <span class="badge badge-danger p-2"><%= data.shipping_status %></span>
                                                        <% } else if (data.shipping_status == null) { %>
                                                            
                                                                <span class="badge badge-success p-2"><%= data.delivery_status %></span>
                                                        <% } else { %>   
                                                            <span class="badge badge-info p-2"><%= data.shipping_status %></span>
                                                        <% } %>
                                                    </td>
                                                    <td class="invosymbol text-nowrap"><%= data.total %></td>
                                                    <td class="text-nowrap">
                                                        <% if (data.due_amount == "0") { %> 
                                                            <span class="badge badge-success p-2">Paid</span>
                                                        <% } else { %> 
                                                            <% if (role_data.role == '1') { %>

                                                                <span class="badge badge-warning p-2">Pending</span>
                                                            <% } else { %>
                                                                    
                                                                <span class="badge badge-warning p-2">Charge Payment</span>
                                                            <% } %>
                                                        <% } %>
                                                    </td>
                                                </tr>
                                            <% no++ %>
                                            <% }) %>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- Scroll - vertical dynamic Ends-->
                </div>
            </div>
        <!-- Container-fluid Ends-->
        </div>

        <%- include('./partials/footer'); -%>
        
    <%- include('./partials/script'); -%>

</body>

</html>