<!-- templates/declarations/detail.html -->
{% extends "base.html" %}

{% block title %}Goods Declaration {{ declaration.custom_file_no }}{% endblock %}

{% block content %}
<div class="container mt-4">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h2>Goods Declaration: {{ declaration.custom_file_no }}</h2>
       
    </div>
    

    <div class="card mb-4">
        <div class="card-header">
            <h5>Document Information</h5>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-md-6">
                    <dl class="row">
                        <dt class="col-sm-5">2. Declaration Type:</dt>
                        <dd class="col-sm-6">{{ declaration.declaration_type }}</dd>

                        <dt class="col-sm-5">3. Valuation Method:</dt>
                        <dd class="col-sm-6">{{ declaration.valuation_method }}</dd>

                        <dt class="col-sm-5">4. Prevous Ref:</dt>
                        <dd class="col-sm-6">{{ declaration.previous_ref }}</dd>

                        <dt class="col-sm-5">6. Custome Office:</dt>
                        <dd class="col-sm-6">{{ declaration.custome_office }}</dd>

                    </dl>
                </div>
                <div class="col-md-6">
                    <dl class="row">
                        

                        

                        <dt class="col-sm-5">8. IGM/EGM NO & DT:</dt>
                        <dd class="col-sm-6">{{ declaration.igm_egm_dt }}</dd>

                        <dt class="col-sm-5">9. DRY PORT IGM/EGM NO:</dt>
                        <dd class="col-sm-6">{{ declaration.dryport_igm_egm }}</dd>

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

    <div class="card mb-4">
        <div class="card-header">
            <h5>Parties Information</h5>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-md-6">
                    <h6>1. Exporter/Consignor</h6>
                    <p><strong>{{ declaration.exporter_name }}</strong><br>
                    {{ declaration.exporter_address|linebreaks }}</p>
                </div>
                <div class="col-md-6">
                    <h6>10. Importer/Consignee</h6>
                    <p><strong>{{ declaration.importer_name }}</strong><br>
                    {{ declaration.importer_address|linebreaks }}</p>
                    
                </div>
                <div class="col-md-6">
                    <h6>11. DECLARANT (OTHER THAN IMPORTER/EXPORTER)</h6>
                    <p>{{ declaration.declaration_otherthan }}<br>
                    </p>
                </div>
            </div>
            <div class="col-md-6">
                <div class="row">
                
                   
                
                                           
                </div>
            </div>
            <div class="col-md-6">    
                <div class="row">
                    
   
                </div>
            </div>
        </div>
    </div>

    <div class="card mb-4">
        <div class="card-header">
            <h5>Information</h5>
        </div>
    
        <div class="card-body">
            <div class="row">
                <div class="col-md-6">
                    <dl class="row">
                        <dt class="col-sm-5">12. TEL:</dt>
                        <dd class="col-sm-6">{{ declaration.tel }}</dd>
                        <dt class="col-sm-5">14. NTN Number:</dt>
                        <dd class="col-sm-6">{{ declaration.ntn_number }}</dd>
                                      
                    </dl>
                </div>
                <div class="col-md-6">
                    <dl class="row">
                        
                        <dt class="col-sm-5">13. C.H.A.L. No:</dt>
                        <dd class="col-sm-6">{{ declaration.chal_no }}</dd> 
                        <dt class="col-sm-5">15. STR Number:</dt>
                        <dd class="col-sm-6">{{ declaration.str_number }}</dd>   
                    </dl>
                </div>
                <div class="col-md-6">
                    <dl class="row">
                        <dt class="col-sm-5">16. WAREHOUSE LIC NO:</dt>
                        <dd class="col-sm-6">{{ declaration.warehouse_lic }}</dd>
                        <dt class="col-sm-5">19. WAREHOUSE LIC NO:</dt>
                        <dd class="col-sm-6">{{ declaration.lc_dd_no }}</dd>

                        
                    </dl>
                </div>
                <div class="col-md-6">
                    <dl class="row">
                        <dt class="col-sm-5">17. TRANSACTION TYPE:</dt>
                        <dd class="col-sm-6">{{ declaration.transaction_type }}</dd>   
                        
                        <dt class="col-sm-5">20. COUNTRY OF DESTINATION:</dt>
                        <dd class="col-sm-6">{{ declaration.country_of_destination }}</dd>   
                    </dl>
                </div>
                <div class="col-md-6">
                    <dl class="row">
                        <dt class="col-sm-5">21. CURRENCY NAME & CODE:</dt>
                        <dd class="col-sm-6">{{ declaration.currency_name_code }}</dd>   
                        
                        <dt class="col-sm-5">23. BL/AWB Info:</dt>
                        <dd class="col-sm-6">{{ declaration.bl_awb_con_info }}</dd>   
                    </dl>
                </div>
                <div class="col-md-6">
                    <dl class="row">
                        <dt class="col-sm-5">22. Vessel Mode:</dt>
                        <dd class="col-sm-6">{{ declaration.vessel_mode }}</dd>   
                        
                        <dt class="col-sm-5">24. EXCHANGE RATE:</dt>
                        <dd class="col-sm-6">{{ declaration.exchange_rate }}</dd>   
                    </dl>
                </div>
                <div class="col-md-6">
                    <dl class="row">
                        <dt class="col-sm-5">25. PORT OF SHIPMENT:</dt>
                        <dd class="col-sm-6">{{ declaration.port_of_shipment }}</dd>   
                        
                        <dt class="col-sm-5">27. PORT OF DISCHARGE:</dt>
                        <dd class="col-sm-6">{{ declaration.port_of_discharge }}</dd>   
                    </dl>
                </div>
                <div class="col-md-6">
                    <dl class="row">
                        <dt class="col-sm-5">26. PAYMENT TERMS:</dt>
                        <dd class="col-sm-6">{{ declaration.payment_terms }}</dd>   
                        
                        <dt class="col-sm-5">28. PLACE OF DELIVERY:</dt>
                        <dd class="col-sm-6">{{ declaration.place_of_delivery }}</dd>   
                    </dl>
                </div>
                <div class="col-md-6">
                    <dl class="row">
                        <dt class="col-sm-5">29. DELIVERY TERMS:</dt>
                        <dd class="col-sm-6">{{ declaration.delivery_terms }}</dd>   
                        
                        <dt class="col-sm-5">31. NUMBER OF PACKAGES:</dt>
                        <dd class="col-sm-6">{{ declaration.number_of_packages }}</dd> 
                           
                    </dl>
                </div>
                <div class="col-md-6">
                    <dl class="row">                          
                        <dt class="col-sm-5">30. MARKS/CONTAINER No:</dt>
                        <dd class="col-sm-6">{{ declaration.marks_container_no }}</dd>
                        <dt class="col-sm-5">32. TYPE OF PACKAGE:</dt>
                        <dd class="col-sm-6">{{ declaration.package_type }}</dd>   
                    </dl>
                </div>
                <div class="col-md-6">
                    <dl class="row">                          
                        <dt class="col-sm-5">33. GROSS WEIGHT:</dt>
                        <dd class="col-sm-6">{{ declaration.gross_weight }}</dd>
                        <dt class="col-sm-5">34. VOLUME M3:</dt>
                        <dd class="col-sm-6">{{ declaration.volume_m3 }}</dd>
                        
                    </dl>
                </div>
                <div class="col-md-6">
                    <dl class="row">          
                        <dt class="col-sm-5">NET WEIGHT:</dt>
                        <dd class="col-sm-6">{{ declaration.net_weight }}</dd>
                        <dt class="col-sm-5">35. DESCRIPTION:</dt>
                        <dd class="col-sm-6">{{ declaration.gen_desc_goods }}</dd>                            
                    </dl>
                </div>
            </div>
        </div>

    </div>


    <div class="card mb-4">
        <div class="card-header d-flex justify-content-between align-items-center">
            <h5 class="mb-0">Goods Items ({{ declaration.items.count }})</h5>
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th>Item No</th>
                            <th>Description</th>                            
                            <th>Quantity</th>
                            <th>CO Code</th>
                            <th>SRO No</th>
                            <th>HS Code</th>
                            <th>Unit Value</th>
                                                   
                            <th>Actions</th>               
                        </tr>
                    </thead>
                    <tbody>
                        {% for item in declaration.items.all %}
                        <tr>
                            <td>{{ item.item_number }}</td>
                            <td>{{ item.description }}</td>
                            <td>{{ item.quantity }} {{ item.unit_type }}</td>
                            <td>{{ item.co_code }}</td>
                            <td>{{ item.sro_number }}</td>
                            <td>{{ item.hs_code }}</td>                            
                            <td>{{ item.unit_value }}</td>
                            
                            <td>
                                <a href="{% url 'edit_goods_item' item.pk %}" class="btn btn-sm btn-outline-primary">View / Edit</a>
                              </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>

 

    <div class="card mb-4">
        <div class="card-header">
            <h5>Shipping Information</h5>
        </div>
    
        <div class="card-body">
            <div class="row">
                <div class="col-md-6">
                    <dl class="row">
                        <dt class="col-sm-5">49. SRO/Test Report No:</dt>
                        <dd class="col-sm-6">{{ declaration.sro_test_report_no }}</dd>
                        <dt class="col-sm-5">51. FREIGHT:</dt>
                        <dd class="col-sm-6">{{ declaration.freight }}</dd>
                                      
                    </dl>
                </div>
                <div class="col-md-6">
                    <dl class="row">
                        
                        <dt class="col-sm-5">50. FOB VALUE:</dt>
                        <dd class="col-sm-6">{{ declaration.fob_value }}</dd> 
                        <dt class="col-sm-5">52. CFR VALUE:</dt>
                        <dd class="col-sm-6">{{ declaration.cfr_value }}</dd>   
                    </dl>
                </div>
                <div class="col-md-6">
                    <dl class="row">
                        <dt class="col-sm-5">53. INSURANCE:</dt>
                        <dd class="col-sm-6">{{ declaration.insurance }}</dd>
                        <dt class="col-sm-5">55. OTHER CHARGES:</dt>
                        <dd class="col-sm-6">{{ declaration.other_charges }}</dd>

                        
                    </dl>
                </div>
                <div class="col-md-6">
                    <dl class="row">
                        <dt class="col-sm-5">54. LANDING CHARGES:</dt>
                        <dd class="col-sm-6">{{ declaration.landing_charges }}</dd>   
                        
                        <dt class="col-sm-5">56. ASSESSED VALUE PKR:</dt>
                        <dd class="col-sm-6">{{ declaration.assessed_pkr }}</dd>   
                    </dl>
                </div>
                <div class="col-md-6">
                    <dl class="row">
                        <dt class="col-sm-5">57. TOTAL REBATE CLAIM/ PROV:</dt>
                        <dd class="col-sm-6">{{ declaration.rebate_prov }}</dd>   
                        
                        <dt class="col-sm-5">59. REVENUE RECOVER:</dt>
                        <dd class="col-sm-6">{{ declaration.revenue_recover }}</dd>   
                    </dl>
                </div>
                <div class="col-md-6">
                    <dl class="row">
                        <dt class="col-sm-5">58. MACHINE NO:</dt>
                        <dd class="col-sm-6">{{ declaration.machine_number }}</dd>   
                        
                        <dt class="col-sm-5">60. AMOUNT (PKR):</dt>
                        <dd class="col-sm-6">{{ declaration.amount_pkr }}</dd>   
                    </dl>
                </div>
                
                
            </div>
        </div>

    </div>




    <div class="d-flex justify-content-between">
        <a href="{% url 'job_dashboard' declaration.job.id %}" class="btn btn-secondary">
            <i class="bi bi-arrow-left"></i> Back to Dashboard
        </a>
        <div>
            <a href="{% url 'edit_declaration' declaration.pk %}" class="btn btn-warning me-2">Edit Declaration</a>

            <a href="{{ declaration.original_file.url }}" class="btn btn-primary me-2" target="_blank">
                <i class="bi bi-file-earmark-pdf"></i> View Original PDF
            </a>
            <button class="btn btn-success" onclick="window.print()">
                <i class="bi bi-printer"></i> Print
            </button>
        </div>
    </div>
</div>
{% endblock %}