{% extends 'admin.html.twig' %}

{% block title %}Details Asset Register - Cross World Group{% endblock %}

{% block body %}

<!-- Title Start  -->
        <div class="app-page-title">
            <div class="page-title-wrapper">
                <div class="page-title-heading">
                    <div class="page-title-icon">
                        <i class="pe-7s-menu icon-gradient bg-ripe-malin text-success">
                        </i>
                    </div>
                    <div><h3>Asset Register</h3>
                        
                    </div>
                </div>
                
                <div class="page-title-actions">
                    <div class="d-inline-block dropdown">
                        <nav class="" aria-label="breadcrumb">
                                    <ol class="breadcrumb">
                                        <li class="breadcrumb-item"><a href="#">Home</a></li>
                                        <li class="breadcrumb-item"><a href="{{ path('assetregister_index') }}">Asset Register List</a></li>
                                        <li class="active breadcrumb-item" aria-current="page">Details</li>
                                    </ol>
                                </nav>
                    </div>
                </div>   
                
            </div>
        </div>    
            
        <ul class="body-tabs body-tabs-layout tabs-animated body-tabs-animated nav">
            
            <li class="nav-item">
                <a role="tab" class="nav-link active"  href="{{ path('assetregister_edit', {'id': assetregister.id}) }}">
                    <span><i class="fa fa-edit"> Edit</i></span>
                </a>
            </li>
            <li class="nav-item">
                <a role="tab" class="nav-link active"  href="{{ path('assetregister_index') }}">
                    <span><i class="fa fa-list"> Asset Register List</i></span>
                </a>
            </li>
                <li class="nav-item">
                   {{ include('assetregister/_delete_form.html.twig') }}
                {# <a role="tab" class="nav-link"  href="{{ path('company_delete', {'id': company.id}) }}" onclick="return confirm('Are you sure you want to permanent delete this item?');">
                    <span><i class="fa fa-trash-o"> Delete</i></span>
                </a> #}
            </li>
        </ul> <!-- Title End  --> 
        
        <!-- Tab Start  --> 
        <div class="tab-content">
        
            <!-- Table Tab Start  --> 
            <div class="tab-pane tabs-animation fade show active" id="tab-content-0" role="tabpanel">
                <div class="main-card mb-3 card">
                    <div class="card-body"> <h5 class="card-title">{{ assetregister.assetname.name }} Details</h5>
                    
                    
                        <div class="table table-striped table-hover">
                        
                            <table class="mb-0 table">
                                
                                <tbody>
                                                                              
                               
                                <tr>
                                    <th width="25%">Group</th>
                                     <th width="3%">: </th>
                                    <td>{{ assetregister.groups.name }}</td>
                                </tr>

                                 <tr>
                                    <th>Subgroup</th>
                                     <th>: </th>
                                    <td>{{ assetregister.subgroup.name }}</td>
                                </tr>
                                  <tr>
                                    <th>Asset Name</th>
                                     <th>: </th>
                                    <td>{{ assetregister.assetname.name }}</td>
                                </tr>
                                 <tr>
                                    <th>Serial No</th>
                                     <th>: </th>
                                    <td>{{ assetregister.serialno }}</td>
                                </tr>
                                 <tr>
                                    <th>Unit</th>
                                     <th>: </th>
                                    <td>{{ assetregister.unit.name }}</td>
                                </tr>
                                 <tr>
                                    <th>Quantity</th>
                                     <th>: </th>
                                    <td>{{ assetregister.quantity }}</td>
                                </tr>
                                 <tr>
                                    <th>Acquisition Cost</th>
                                    <th>: </th>
                                    <td>{{ assetregister.acquisitioncost }}</td>
                                </tr>
                                 <tr>
                                    <th>Acquisition Date</th>
                                     <th>: </th>
                                    <td>{{ assetregister.acquisitiondate ? assetregister.acquisitiondate|date('Y-m-d') : '' }}</td>
                                </tr>
                                 <tr>
                                    <th>Vendor</th>
                                     <th>: </th>
                                    <td>{{ assetregister.vendor.name}}</td>
                                </tr>
                                 <tr>
                                    <th>Business Unit</th>
                                     <th>: </th>
                                    <td>{{ assetregister.businessunit.name }}</td>
                                </tr>
                                 <tr>
                                    <th>Location</th>
                                     <th>: </th>
                                    <td>{{ assetregister.location ? assetregister.location.name : '' }}</td>
                                </tr>
                                 <tr>
                                    <th>Document</th>
                                    <th>: </th>
                                    <td>
                                  {% if assetregister.docpath != null %}  
                                  {% if assetregister.docpath|split('.')|last == 'pdf' %}
                                    <embed src="{{ asset('admin/docuploads/' ~ assetregister.docpath) }}" width="800" height="400" type='application/pdf'>                                      
                                  {% else %}   
                                    <img src="{{ asset('admin/docuploads/' ~ assetregister.docpath) }}" height="500" width="800" />
                                  {% endif %}
                                   {% endif %}
                                    </td>
                                </tr>
                                  <tr>
                                    <th>Remarks</th>
                                     <th>: </th>
                                    <td>{{ assetregister.remarks }}</td>
                                </tr>
                              
                               
                                </tbody>
                            </table>
                        </div>

                
                              <h5 class="card-title">ASSET DISPOSAL</h5>
                                         <div class="table table-bordered table-responsive table-striped table-hover" >
										
                                            <table class="mb-0 table">
                                                <thead>
                                                <tr>
                                                    <th>#</th>
                                                    <th>Disposal Date</th>
                                                    <th>Disposal Amount</th>
                                                    <th>Remarks</th>
                                                                                                    
                                                </tr>
                                                </thead>
                                                <tbody>
                                                  {% set totalAmount = 0 %}
                                                  {% for assetdisposal in assetregister.assetdisposals %}
                                                    {% set counter = ( counter | default(0) ) + 1 %}  
                                                    {% set totalAmount = ( totalAmount | default(0) ) + assetdisposal.disposalamount %}                                                 
                                                    <tr>
                                                      <td>{{ counter }}</td>
                                                      <td>{{ assetdisposal.disposaldate|date('d-m-Y') }} </td>                                                      
                                                      <td>{{ assetdisposal.disposalamount|number_format(2, '.', ',') }} </td>
                                                      <td>{{ assetdisposal.remarks }} </td>
                                                    
                                                    </tr>
                                                  {% else %}
                                                  <tr>
                                                    <td colspan="9">No records found</td>
                                                    
                                                  </tr>
                                                 {% endfor %}
                                                  <tr>
                                                    <td colspan="2" style="text-align:right;"> <strong>Total Amount: </strong></td>
                                                    <td><strong>{{ totalAmount|number_format(2, '.', ',') }}</strong> </td>
                                                    <td> </td>
                                                  </tr>
                                                </tbody>
                                            </table>
                      

                                        </div>


  
    <a href="{{ path('assetregister_disposal', {'id': assetregister.id}) }}" class="btn btn-primary btn-sm" data-toggle="tooltip" data-placement="top" title="Asset Disposal"><i class="fa fa-edit"> Disposal</i></a>
                                            
            
                    </div>
                </div>
                

            

                
            </div> <!-- Table Tab End  --> 
                                        
        </div> <!-- Tab End  --> 




{% endblock %}

