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

        <div class="page-body">

          <!-- Container-fluid starts-->
            <div class="container-fluid">
                <div class="row">
                 
                    <!-- Scroll - vertical dynamic Starts-->
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-body">
                                <div class="row">

                                    <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>
                                        <h3><span class="font-danger"> <%= lang_data.Tracking_ID %> </span>#<%= data.invoice %></h3>
                                    </div>

                                    <hr>

                                    <div class="d-flex justify-content-between align-items-center">
                                        <h5><%= lang_data.Package_Status %> 
                                            <% shipping_status_data.forEach((status) => { %>
                                                <% if (data.status == status.id) { %>

                                                    <span class="badge badge-info p-2"><%= status.status_name %></span>

                                                <% } %>
                                            <% }) %>
                                        </h5>
                                        <h5><%= lang_data.invoice_status %> 
                                            <% if (data.due_amount != '0') { %>
                                                <span class="badge badge-warning p-2">Pending</span>
                                            <% } else { %>
                                                <span class="badge badge-success p-2">Paid</span>
                                            <% } %>
                                        </h5>
                                        <div>
                                                <div class="dropdown">
                                                        <button class="dropbtn btn-pill btn-primary px-4 py-2" type="button"><%= lang_data.Action %></button>
                                                        <div class="dropdown-content myDropdown">
                                                            <% if (role_data.role == '1') { %>

                                                                <% if (data.due_amount != '0') { %>

                                                                    <a class="dropdown-item" href="/online_shopping/show_register_packages/<%= data.id %>"><i class="fa fa-search f-14"></i> <%= lang_data.Show_Details %></a>
                                                                    <a class="dropdown-item" href="/online_shopping/edit_register_packages/<%= data.id %>" id="edit_register_packages"><i class="fa fa-pencil f-14"></i> <%= lang_data.Edit_Package %></a>
                                                                    <a class="dropdown-item" href="#"><i class="icon-trash font-danger f-14"></i> <%= lang_data.Remove_Shipment %></a>
                                                                    <a class="dropdown-item" data-bs-toggle="modal" data-bs-target="#assigndriver_toggle" id="online_shopping_assign_driver" data-id="<%= data.id %>" data-name="<%= data.assign_driver %>"><i class="fa fa-car f-14"></i> <%= lang_data.Assign_Driver %></a>
                                                                    <a class="dropdown-item" href="/online_shopping/print_shipment/<%= data.id %>"><i class="fa fa-print f-14"></i> <%= lang_data.Print_Shipment %></a>
                                                                    
                                                                <% } else { %>

                                                                    <% if (data.shipping_status == "Delivered") { %>
                                                                        
                                                                        <a class="dropdown-item" href="/online_shopping/show_register_packages/<%= data.id %>"><i class="fa fa-search f-14"></i> <%= lang_data.Show_Details %></a>
                                                                        <a class="dropdown-item" href="/online_shopping/print_shipment/<%= data.id %>"><i class="fa fa-print f-14"></i> <%= lang_data.Print_Shipment %></a>
                                                                    <% } else { %>

                                                                        <a class="dropdown-item" href="/online_shopping/show_register_packages/<%= data.id %>"><i class="fa fa-search f-14"></i> <%= lang_data.Show_Details %></a>
                                                                        <a class="dropdown-item" data-bs-toggle="modal" data-bs-target="#assigndriver_toggle" id="online_shopping_assign_driver" data-id="<%= data.id %>" data-name="<%= data.assign_driver %>"><i class="fa fa-car f-14"></i> <%= lang_data.Assign_Driver %></a>
                                                                        <a class="dropdown-item" href="/online_shopping/print_shipment/<%= data.id %>"><i class="fa fa-print f-14"></i> <%= lang_data.Print_Shipment %></a>
                                                                    <% } %>

                                                                <% } %>

                                                            <% } else { %>

                                                                <% if (data.due_amount != '0') { %>

                                                                    <a class="dropdown-item" href="/online_shopping/show_register_packages/<%= data.id %>"><i class="fa fa-search f-14"></i> <%= lang_data.Show_Details %></a>
                                                                    <a class="dropdown-item" href="/online_shopping/print_shipment/<%= data.id %>"><i class="fa fa-print f-14"></i> <%= lang_data.Print_Shipment %></a>
                                                                   
                                                                <% } else { %>
                                                                        
                                                                    <a class="dropdown-item" href="/online_shopping/show_register_packages/<%= data.id %>"><i class="fa fa-search f-14"></i> <%= lang_data.Show_Details %></a>
                                                                    <a class="dropdown-item" href="/online_shopping/print_shipment/<%= data.id %>"><i class="fa fa-print f-14"></i> <%= lang_data.Print_Shipment %></a>
                                                                <% } %>

                                                            <% } %>
                                                            
                                                        </div>
                                                </div>
                                        </div>
                                    </div>

                                    <hr class="mt-3">

                                    <div class="col-4">
                                        <div>
                                            <h5><%= lang_data.Agency %></h5>
                                            <span><%= agency.agency_name %></span>
                                        </div>
                                        <div class="mt-4">
                                            <h5><%= lang_data.Estimated_delivery_date %></h5>
                                            <span><%= data.date.toLocaleDateString() %></span>
                                        </div>
                                        <div class="mt-4">
                                            <h5><%= lang_data.Delivery_time %></h5>
                                            <span><%= delivery_time.shipping_times %></span>
                                        </div>
                                        <div class="mt-4">
                                            <h5># <%= lang_data.tracking %></h5>
                                            <span><%= data.tracking_no %></span>
                                        </div>
                                    </div>

                                    <div class="col-4">
                                        <div>
                                            <h5><%= lang_data.Office %></h5>
                                            <span><%= office.office_name %></span>
                                        </div>
                                        <div class="mt-4">
                                            <h5><%= lang_data.Package_Type %></h5>
                                            <span><%= packaging.packaging_type %></span>
                                        </div>
                                        <div class="mt-4">
                                            <h5><%= lang_data.Payment_Methods %></h5>
                                            <span><%= shipping_modes.shipping_modes %></span>
                                        </div>
                                        <div class="mt-4">
                                            <h5><%= lang_data.Store %> / <%= lang_data.Supplier %></h5>
                                            <span><%= data.supplier %></span>
                                        </div>
                                    </div>

                                    <div class="col-4">
                                        <div>
                                            <h5> <%= lang_data.Shipping_Modes %></h5>
                                            <span><%= logistics_service.service_name %></span>
                                        </div>
                                        <div class="mt-4">
                                            <h5><%= lang_data.Courier_company %></h5>
                                            <span><%= courier_companies.companies_name %></span>
                                        </div>
                                        <div class="mt-4">
                                            <h5><%= lang_data.Purchase_price %></h5>
                                            <span class="invosymbol"><%= data.purchase_price %></span>
                                        </div>
                                    </div>

                                </div>
                            </div>
                        </div>


                        <!-- Tracking History -->

                        <div class="card">
                            <div class="card-body">
                                <div class="row">

                                    <h5><%= lang_data.Tracking_History %></h5>

                                    <hr>

                                    <div class="table-responsive theme-scrollbar">
                                        <table class="table" aria-label="table">
                                            <thead class="table-dark">
                                                <tr>
                                                    <th scope="col"><%= lang_data.Date_updated %></th>
                                                    <th scope="col"><%= lang_data.Time_update %></th>
                                                    <th scope="col"><%= lang_data.New_location %></th>
                                                    <th scope="col"><%= lang_data.Package_Status %></th>
                                                    <th scope="col"><%= lang_data.Remarks %></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <% tracking_data.forEach((data) => { %>
                                                    <tr>
                                                        <td><%= data.date.toLocaleDateString() %></td>
                                                        <td><%= data.time %></td>
                                                        <td><%= data.countries_name %></td>
                                                        <td><%= data.status_name %></td>
                                                        <td><%= data.message %></td>
                                                    </tr>
                                                <% }) %>
                                            </tbody>
                                        </table>
                                    </div>

                                </div>
                            </div>
                        </div>

                        <div class="card">
                            <div class="card-body">
                                <div class="row">

                                    <h5><%= lang_data.Shipping_details %></h5>

                                    <hr>

                                    <div class="table-responsive theme-scrollbar">
                                        <table class="table" aria-label="table">
                                            <thead class="table-dark">
                                                <tr>
                                                    <th scope="col"><%= lang_data.Package_Name %></th>
                                                    <th scope="col"><%= lang_data.Package_Description %></th>
                                                    <th scope="col"><%= lang_data.Amount %></th>
                                                    <th scope="col"><%= lang_data.Weight %></th>
                                                    <th scope="col"><%= lang_data.Length %></th>
                                                    <th scope="col"><%= lang_data.Width %></th>
                                                    <th scope="col"><%= lang_data.Height %></th>
                                                    <th scope="col"><%= lang_data.Weight_Vol %></th>
                                                    <th scope="col"><%= lang_data.Fixed_charge %></th>
                                                    <th scope="col"><%= lang_data.Declared_value %></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <% package_name_list.forEach((data, x) => { %>

                                                    <tr>
                                                        <td><%= data %></td>
                                                        <td><%= package_description_list[x] %></td>
                                                        <td class="invosymbol"><%= package_amount_list[x] %></td>
                                                        <td><%= weight_list[x] %></td>
                                                        <td><%= length_list[x] %></td>
                                                        <td><%= width_list[x] %></td>
                                                        <td><%= height_list[x] %></td>
                                                        <td><%= weight_vol_list[x] %></td>
                                                        <td class="invosymbol"><%= f_charge_list[x] %></td>
                                                        <td class="invosymbol"><%= decvalue_list[x] %></td>
                                                    </tr>
                                                <% }) %>
                                            </tbody>
                                        </table>

                                        <div class="col-12 mt-4">
                                            <div class="d-flex align-items-center justify-content-end">
                                                <div>
                                                    <span class="text-nowrap m-r-15"><%= lang_data.Subtotal %> :</span>
                                                    <span class="invosymbol"><%= data.subtotal %></span>
                                                </div>
                                            </div>
                                        </div>

                                        <hr class="my-2"> 

                                        <div class="col-12">
                                            <div class="d-flex align-items-center justify-content-between">
                                                <div>
                                                    <span class="text-nowrap m-r-15"><%= lang_data.Price_kg %> :</span>
                                                    <span class="invosymbol"><%= data.add_price_kg %></span>
                                                </div>
                                                <div>
                                                    <span class="text-nowrap m-r-15"><%= lang_data.Discount %> :</span>
                                                    <span class="invosymbol"><%= data.discount %></span>
                                                </div>
                                            </div>
                                        </div>

                                        <hr class="my-2"> 

                                        <div class="col-12">
                                            <div class="d-flex align-items-center justify-content-between">
                                                <div>
                                                    <span class="text-nowrap m-r-15"><%= lang_data.Weight %> :</span>
                                                    <span><%= data.total_weight %></span>
                                                </div>
                                                <div>
                                                    <span class="text-nowrap m-r-15"><%= lang_data.Value_assured %> :</span>
                                                    <span class="invosymbol"><%= data.add_value_assured %></span>
                                                </div>
                                            </div>
                                        </div>

                                        <hr class="my-2"> 

                                        <div class="col-12">
                                            <div class="d-flex align-items-center justify-content-between">
                                                <div>
                                                    <span class="text-nowrap m-r-15"><%= lang_data.Total_Weight_Vol %> :</span>
                                                    <span><%= data.total_weight_vol %></span>
                                                </div>
                                                <div>
                                                    <span class="text-nowrap m-r-15"><%= lang_data.Shipping_Insurance %> :</span>
                                                    <span class="invosymbol"><%= data.shipping_insurance %></span>
                                                </div>
                                            </div>
                                        </div>

                                        <hr class="my-2"> 

                                        <div class="col-12">
                                            <div class="d-flex align-items-center justify-content-between">
                                                <div>
                                                    <span class="text-nowrap m-r-15"><%= lang_data.Fixed_charge %> :</span>
                                                    <span class="invosymbol"><%= data.fixed_charge %></span>
                                                </div>
                                                <div>
                                                    <span class="text-nowrap m-r-15"><%= lang_data.Customs_Duties %> :</span>
                                                    <span class="invosymbol"><%= data.customs_duties %></span>
                                                </div>
                                            </div>
                                        </div>

                                        <hr class="my-2"> 

                                        <div class="col-12">
                                            <div class="d-flex align-items-center justify-content-between">
                                                <div>
                                                    <span class="text-nowrap m-r-15"><%= lang_data.Total_DecValue %> :</span>
                                                    <span class="invosymbol"><%= data.total_decvalue %></span>
                                                </div>
                                                <div>
                                                    <span class="text-nowrap m-r-15"><%= lang_data.Tax %> :</span>
                                                    <span class="invosymbol"><%= data.tax %></span>
                                                </div>
                                            </div>
                                        </div>

                                        <hr class="my-2"> 

                                        <div class="col-12">
                                            <div class="d-flex align-items-center justify-content-end">
                                                <div>
                                                    <span class="text-nowrap m-r-15"><%= lang_data.Declared_value %> :</span>
                                                    <span class="invosymbol"><%= data.declared_value %></span>
                                                </div>
                                            </div>
                                        </div>

                                        <hr class="my-2">

                                        <div class="col-12">
                                            <div class="d-flex align-items-center justify-content-end">
                                                <div>
                                                    <span class="text-nowrap m-r-15"><%= lang_data.Fixed_charge %> :</span>
                                                    <span class="invosymbol"><%= data.fixed_charge %></span>
                                                </div>
                                            </div>
                                        </div>

                                        <hr class="my-2">

                                        <div class="col-12">
                                            <div class="d-flex align-items-center justify-content-end">
                                                <div>
                                                    <span class="text-nowrap m-r-15"><%= lang_data.Reissue %> :</span>
                                                    <span class="invosymbol"><%= data.reissue %></span>
                                                </div>
                                            </div>
                                        </div>

                                        <hr class="my-2">

                                        <div class="col-12">
                                            <div class="d-flex align-items-center justify-content-end">
                                                <div>
                                                    <span class="text-nowrap m-r-15"><%= lang_data.Total %> :</span>
                                                    <span class="invosymbol"><%= data.total %></span>
                                                </div>
                                            </div>
                                        </div>

                                        <hr class="my-2">

                                    </div>

                                </div>
                            </div>
                        </div>

                        <!-- Sender details -->

                        <div class="card">
                            <div class="card-body">
                                <div class="row">

                                    <h5><%= lang_data.Sender_details %></h5>

                                    <hr>
                                    <% customers_address.forEach((customers_address, x) => { %>
                                        <% if (customers_address == data.customer_address) { %>
                                        
                                            <div class="col-4">
                                                <div>
                                                    <h5><%= lang_data.Name %></h5>
                                                    <span><%= sender_data.first_name %> <%= sender_data.last_name %></span>
                                                </div>
                                                <div class="mt-4">
                                                    <h5><%= lang_data.Address %></h5>
                                                    <span><%= customers_address %></span>
                                                </div>
                                            </div>

                                            <div class="col-4">
                                                <div>
                                                    <h5><%= lang_data.EMail %></h5>
                                                    <span><%= sender_data.email %></span>
                                                </div>
                                                <div class="mt-4">
                                                    <h5><%= lang_data.Country %></h5>
                                                    <% country_name.forEach((country_name) => { %>
                                                        <% if (country_name.id == customers_country[x] ) { %>

                                                            <span><%= country_name.countries_name %></span>
                                                        <% } %>
                                                    <% }) %>
                                                </div>
                                            </div>

                                            <div class="col-4">
                                                <div>
                                                    <h5><%= lang_data.Phone_No %></h5>
                                                    <span><%= sender_data.mobile %></span>
                                                </div>
                                                <div class="mt-4">
                                                    <h5><%= lang_data.City %></h5>
                                                    <% city_name.forEach((city_name) => { %>
                                                        <% if (city_name.id == customers_city[x] ) { %>

                                                            <span><%= city_name.city_name %></span>
                                                        <% } %>
                                                    <% }) %>
                                                </div>
                                            </div>
                                        <% } %>
                                    <% }) %>
                                </div>
                            </div>
                        </div>

                    </div>

                  <!-- Scroll - vertical dynamic Ends-->
                </div>
            </div>
            <!-- Container-fluid Ends-->
        </div>


        <!-- edit status modal-->

        <div class="modal fade" id="assigndriver_toggle" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenter" aria-hidden="true">
            <div class="modal-dialog modal-dialog-centered" role="document">
              <div class="modal-content">
                <div class="modal-header">
                  <h5 class="modal-title"><%= lang_data.Assign_Driver %></h5>
                  <button class="btn-close" type="button" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <form action="/online_shopping/assigndriver" method="post">
                    <div class="modal-body">
                    <div class="row">
                        <input type="hidden" id="hidden_id" name="hidden_id">
                        <div class="col-12">
                            <select class="js-example-basic-single" name="assign_driver" id="assign_driver_toggle" required>
                                <option value selected disabled>Search Driver</option>
                                <% drivers_list.forEach((data) => { %>
                                <option value="<%= data.id %>"> <%= data.first_name %> <%= data.last_name %></option>
                                <% }) %>
                            </select>
                        </div>
    
                    </div>
                    </div>
                    <div class="modal-footer">
                    <button class="btn btn-secondary" type="button" data-bs-dismiss="modal"><%= lang_data.Close %></button>
                    <button class="btn btn-primary" type="submit"><%= lang_data.Save_changes %></button>
                    </div>
                </form>
              </div>
            </div>
        </div>
        
        <%- include('./partials/footer'); -%>
        
    <%- include('./partials/script'); -%>

  </body>

</html>