templates/vehicledocs/edit.html.twig line 1

  1. {% form_theme docsForm 'form/fields-file.html.twig' %}
  2. {% extends 'vehicle_tabs.html.twig' %}
  3. {% block page_title %} {{ "Documents"|trans({},'vehicles') }} {% endblock %}
  4. {% block flash_messages %}
  5.     {{ parent() }}
  6.     {% include 'form_validation.html.twig' with {'current_form': docsForm} %}
  7. {% endblock %}
  8. {% block stylesheets %}
  9.     {{ parent() }}
  10.     <style>
  11.         #images button{
  12.             font-size: 12px !important;
  13.             padding: 10px 12px  !important;
  14.         }
  15.         #appbundle_vehicles_vehicleRegistrations {display: none !important;}
  16.     </style>
  17. {% endblock %}
  18. {% block tabs2_body %}
  19.     {% set DOCS_TYPES = constant('App\\Entity\\VehicleDocTypes::DOC_TYPES') %}
  20.     {% set CLIENT_TYPES = constant('App\\Entity\\VehicleClients::CLIENT_TYPES') %}
  21.     <div class="table-responsive">
  22.     {{ form_start(docsForm) }}
  23.     
  24.     <table class="table table-bordered vehicleDocs">
  25.         {# Display vehicle registration's document fields if it exists #}
  26.         {% if docsForm.vehicleRegistrations.registrationDoc.receivedDocType is defined %}
  27.         <tr>
  28.             <td>{{ form_label(docsForm.vehicleRegistrations.registrationDoc.receivedDocType) }}</td>
  29.             <td class="skin-minimal">
  30.                 <div class="form-group">
  31.                 {{ form_widget(docsForm.vehicleRegistrations.registrationDoc.receivedDocType) }}
  32.                 {{ form_errors(docsForm.vehicleRegistrations.registrationDoc.receivedDocType) }}
  33.                 </div>
  34.             </td>
  35.             <td>
  36.                 <div class="form-group">
  37.                     {% set imageSrc = null %}
  38.                     {% if registrationDocImage is not null %}
  39.                         {% set imageSrc = asset(vehicle_uploaded_files ~ '/' ~ vehicle.vehicleId ~ '/' ~ registrationDocImage) %}
  40.                         <img  class="selectedImage imgShow" src="{{imageSrc}}"    />
  41.                     {% endif %}
  42.                     {#{{ form_widget(docsForm.vehicleRegistrations.registrationDoc.imagePath, { 'attr': {'style': 'display:none !important'} }) }}
  43.                     {{ form_errors(docsForm.vehicleRegistrations.registrationDoc.imagePath, { 'attr': {'style': 'display:none !important'} }) }}#}          
  44.                 </div>
  45.             </td>
  46.         </tr>
  47.         {% endif %}
  48.         
  49.         {# Display vehicle's documents fields #}
  50.         {% for document in docsForm.vehicleDocument %}
  51.             <tr>
  52.                 <td>{#{ document.vars.value.docType.docTypeId }#}
  53.                 {# Get the label from either imagePath or receivedDocType #}
  54.                 {% if document.imagePath is defined %}
  55.                     {{ form_label(document.imagePath) }}
  56.                 {% elseif document.receivedDocType is defined %}
  57.                     {{ form_label(document.receivedDocType) }}
  58.                 {% endif %}
  59.                 </td>
  60.                 <td class="skin-minimal">
  61.                 <div class="form-group">
  62.                 {% if document.receivedDocType is defined %}
  63.                     {{ form_widget(document.receivedDocType) }}
  64.                     {{ form_errors(document.receivedDocType) }}
  65.                 {% endif %}
  66.                 {% if document.vehicle is defined %}
  67.                     <div class="">
  68.                         {{ form_label(document.vehicle.inspectionExpirationDate, null, {'label_attr' : {'class': 'control-label'} }) }}
  69.                         <div class='input-group date datetimepicker'>
  70.                             {{ form_widget(document.vehicle.inspectionExpirationDate, {'attr' : {'class': 'form-control'} }) }}
  71.                             <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
  72.                         </div>
  73.                         {{ form_errors(document.vehicle.inspectionExpirationDate) }}
  74.                     </div>
  75.                 {% endif %}
  76.                   {% if document.vars.data.docType.docTypeId == DOCS_TYPES.insurance %}
  77.                     <div class="row">
  78.                         <div class="col-md-6">
  79.                             {{ form_label(docsForm.insuranceStartDate, null, {'label_attr' : {'class': 'control-label'} }) }}
  80.                             <div class='input-group date datetimepicker'>
  81.                                 {{ form_widget(docsForm.insuranceStartDate, {'attr' : {'class': 'form-control'} }) }}
  82.                                 <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
  83.                             </div>
  84.                             {{ form_errors(docsForm.insuranceStartDate) }}
  85.                         </div>
  86.                         <div class="col-md-6">
  87.                             {{ form_label(docsForm.insuranceExpiryDate, null, {'label_attr' : {'class': 'control-label'} }) }}
  88.                             <div class='input-group date datetimepicker'>
  89.                                 {{ form_widget(docsForm.insuranceExpiryDate, {'attr' : {'class': 'form-control'} }) }}
  90.                                 <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
  91.                             </div>
  92.                             {{ form_errors(docsForm.insuranceExpiryDate) }}
  93.                         </div>
  94.                     </div>
  95.                 {% endif %}
  96.                 </div>
  97.                 </td>
  98.                 <td>
  99.                 {% if document.imagePath is defined %}
  100.                     <div class="row" id="images">
  101.                         <div class="col-lg-4">
  102.                             {{ form_widget(document.imagePath) }}
  103.                             {{ form_errors(document.imagePath) }}
  104.                             {% if document.imagePath.vars.image_url is null   %}
  105.                              <img class="imgShow" src="" alt="" width="100" height="100"> {#if there isn't image #}
  106.                             {%  endif %}
  107.                             {{ form_row(document.clearImage) }} {# the hidden field flag that indicates that an image delete action needed #}
  108.                         </div>
  109.                         <div class="col-lg-8">
  110.                             <p id="choose" class="btn btn-primary choose"  >{{ 'select image' | trans({}, 'messages') }}</p>
  111.                             <p id="image_reset" class="btn btn-warning image_reset"   >{{ 'reset' | trans({}, 'messages') }}</p>
  112.                             <p id="removeDoc" class="btn btn-danger removeDoc"   >{{ 'clear image' | trans({}, 'messages') }}</p>
  113.                         </div>
  114.                     </div>
  115.                 {% endif %}
  116.                 </td>
  117.             </tr>
  118.         {% endfor %}
  119.         <tr>
  120.             <td><label>{{ 'owner identity photo' | trans({}, 'vehicles') }}</label></td>
  121.             <td>
  122.                 {% if ownerPhoto is not null %}
  123.                     {{ 'Yes' | trans }}
  124.                 {% else %}
  125.                     {{ 'No' | trans }}
  126.                 {% endif %}
  127.             </td>
  128.             <td>
  129.                 {% if ownerPhoto is not null %}
  130.                     {% if vehicle.vehicleRegistrations.vehicleOwner.getClientType == CLIENT_TYPES.user %}
  131.                         <img class="imgShow" src="{{ asset(users_uploaded_files ~ '/' ~ ownerId ~ '/' ~ ownerPhoto) }}" style="width: 100px;">
  132.                     {% elseif vehicle.vehicleRegistrations.vehicleOwner.getClientType == CLIENT_TYPES.company %}
  133.                         <img class="imgShow" src="{{ asset(companies_uploaded_files ~ '/' ~ ownerId ~ '/' ~ ownerPhoto) }}"style="width: 100px;">
  134.                     {% endif %}
  135.                 {% endif %}
  136.             </td>
  137.         </tr>
  138.     </table>
  139.         {#{{ form_widget(docsForm) }}#}
  140.         <input type="submit" value="{{ 'Save' |trans }}" class="btn btn-success" />
  141.     {{ form_end(docsForm) }}
  142.     <br>
  143.         {# Vehicle Activity Estimation#}
  144.         <div class="panel panel-info">
  145.             <div class="panel-heading">{{ 'Estimation of Sheikh Exhibitions' | trans({}, 'vehicles') }}</div>
  146.             <div class="panel-body">
  147.                 <table class="table table-bordered vehicle" id="estimation">
  148.                     <thead>
  149.                     <tr>
  150.                         <th>{{ 'Value Before' | trans({}, 'vehicles') }}</th>
  151.                         <th>{{ 'Value After' | trans({}, 'vehicles') }}</th>
  152.                         <th>{{ 'partsEstimation' | trans({}, 'vehicles') }}</th>
  153.                         <th>{{ 'Estimation Document' | trans({}, 'vehicles') }}</th>
  154.                         <th></th>
  155.                     </tr>
  156.                     </thead>
  157.                     <tbody>
  158.                     {% for estimate in estimation %}
  159.                         <tr>
  160.                             <td>{{ estimate.estimateValBefore }}</td>
  161.                             <td>{{ estimate.estimateValAfter }}</td>
  162.                             <td>{{ estimate.partsEstimation }}</td>
  163.                             <td>
  164.                                 {% if estimate.imagePath is not null %}
  165.                                     <img src="{{ asset(estimate.imagePath) }}" style="width: 100px; height: 55px;" />
  166.                                 {% endif %}
  167.                             </td>
  168.                             <td>
  169.                                 {% set activityId = estimate.activityId %}
  170.                                 {% set vehicleId = estimate.RtsVehicleId %}
  171.                                 {% if activityId is  null  %}
  172.                                     {% set activityId = 0 %}
  173.                                     {% set vehicleId = estimate.vehicleId %}
  174.                                 {% endif %}
  175.                                 <a href="{{ path('vehicleRtsActivitiesEstimateValEdit', {'vehicleId': vehicleId, 'activityId':activityId , 'estimateId': estimate.estimationId}) }}" title="{{ 'editEstimation' | trans({}, 'vehicles') }}">
  176.                                     <span class="fa fa-pencil"></span>
  177.                                 </a>
  178.                             </td>
  179.                         </tr>
  180.                     {% endfor %}
  181.                     <tr><td colspan="8"><a href="{{ path('vehicleRtsActivitiesEstimateVal_new', {'vehicleId': vehicle.vehicleId, 'activityId': '0'}) }}" class="btn btn-success">{{ 'createVehicleRtsActivitiesEstimateVal' | trans({}, 'vehicles') }}</a></td></tr>
  182.                     </tbody>
  183.                 </table>
  184.             </div>
  185.         </div>
  186.     </div>
  187.     {# Security Notices #}
  188.     <div class="panel panel-info">
  189.         <div class="panel-heading">{{ 'securityNotes' | trans({}, 'vehicles') }}</div>
  190.         <div class="panel-body">
  191.             <table class="table table-bordered vehicle" id="securityNotes">
  192.         <thead>
  193.             <tr>
  194.                 <th>{{ 'Notes Type' | trans({}, 'vehicles') }}</th>
  195.                 <th>{{ 'Notes Date' | trans({}, 'vehicles') }}</th>
  196.                 <th>{{ 'revocation date' | trans({}, 'vehicles') }}</th>
  197.                 <th>{{ 'Followup date' | trans({}, 'vehicles') }}</th>
  198.                 <th>{{ 'Is Effective' | trans({}, 'vehicles') }}</th>
  199.                 <th>{{ 'Image' | trans({}, 'vehicles') }}</th>
  200.                 <th></th>
  201.             </tr>
  202.         </thead>
  203.         <tbody>
  204.             {% for security_notice in security_notices %}
  205.                 <tr>
  206.                     <td> {{ security_notice.noticeType|trans( {}, "vehicles" ) }}
  207.                     </td>
  208.                     <td>{% if security_notice.noticeDate %}{{ security_notice.noticeDate|date('Y-m-d') }}{% endif %}</td>
  209.                     <td>{% if security_notice.revocationDate %}{{ security_notice.revocationDate|date('Y-m-d')  }}{% endif %}</td>
  210.                     <td>{% if security_notice.followupDate %}{{ security_notice.followupDate|date('Y-m-d')  }}{% endif %}</td>
  211.                     <td>{% if security_notice.isEffective %}{{ "Effective"|trans( {}, "vehicles" ) }}{% else %}{{ "Ineffective"|trans( {}, "vehicles" ) }}{% endif %}</td>
  212.                     <td>
  213.                         {% if security_notice.noteDoc and security_notice.noteDoc.imageWebPath is not null %}
  214.                             <img class="imgShow" src="{{ asset(security_notice.noteDoc.imageWebPath) }}" style="height:55px;width:55px;" />
  215.                         {% endif %}
  216.                     </td>
  217.                     <td>
  218.                         <div class="btn-group btn-group-justified" style="width: 50% !important; display: unset;">
  219.                             <a href="{{ path('vehiclesecuritynotices_edit', { 'noticeId': security_notice.noticeId }) }}" class="btn btn-success" style="margin-left: 10px">
  220.                                 <i class="fa fa-edit"></i>
  221.                             </a>
  222.                             {% if is_granted('ROLE_FOLLOW_UP_OFFICER') == true %}
  223.                                 <a href="{{ path('vehiclesecuritynotices_delete', { 'noticeId': security_notice.noticeId }) }}" class="btn btn-danger" onclick="return confirm('{{ "Are you sure?"|trans() }}')">
  224.                                     <i class="fa fa-trash"></i>
  225.                                 </a>
  226.                             {% endif %}
  227.                         </div>
  228.                     </td>
  229.                 </tr>
  230.             {% endfor %}
  231.             <tr><td colspan="8"><a href="{{ path('vehiclesecuritynotices_new', { 'vehicleId': vehicle.vehicleId }) }}" class="btn btn-success">{{ 'Add new security note' | trans({}, 'vehicles') }}</a></td></tr>
  232.         </tbody>
  233.     </table>
  234.         </div>
  235.     </div>
  236.     </div>
  237. {% endblock %}
  238. {% block javascripts %}
  239.     {{ parent() }}
  240.     <script>
  241.         $(function () {
  242.             //set tabs2 as an active tab
  243.             $( "#vehicle_tabs .tabs2" ).addClass( "active" );
  244.  delete_record=function(notice_id){
  245.         var del_url="{{ path('vehiclesecuritynotices_delete', { 'noticeId': 0 }) }}";
  246.             del_url = del_url.replace("0",notice_id);
  247.             var obj={
  248.                 noticeId:notice_id
  249.             };
  250.             $.ajax({
  251.                 url: del_url,
  252.                 method: 'post',
  253.                 data: obj,
  254.             success: function(response){
  255.                 //window.location(response.url);
  256.                  alert("working");
  257.             }
  258.             });
  259.         };
  260.             $('.datetimepicker').datetimepicker({
  261.                 locale: 'en-gb',
  262.                 sideBySide: true,
  263.                 format:'YYYY-MM-DD',
  264.                 icons: {
  265.                     previous: 'fa fa-arrow-right',
  266.                     next: 'fa fa-arrow-left'
  267.                 }
  268.             });
  269.             //#appbundle_vehicles_vehicleDocument_1_imagePath, #appbundle_vehicles_vehicleDocument_2_imagePath, #appbundle_vehicles_vehicleDocument_3_imagePath, #appbundle_vehicles_vehicleDocument_4_imagePath, #appbundle_vehicles_vehicleDocument_5_imagePath
  270.             $(".docImg").hide();
  271.             $(".docImg").change(function(){
  272.                 let input = $(this);
  273.                 readURL(this, $(this).next('img'));
  274.             });
  275.             $(".choose").click(function(e){
  276.                 e.preventDefault();
  277.                 let input = $(this).parent().parent().find("input[type='file']");
  278.                 input.click();
  279.             });
  280.             //unset the input file field and also unset the thumbnail view of the image
  281.             $(".image_reset").click(function(e){
  282.                 e.preventDefault();
  283.                 var input = $(this).parent().parent().find("input[type='file']");
  284.                 input.replaceWith(input.val('').clone(true));
  285.                 $(this).parent().parent().find("img").attr('src','').width(100).height(100).hide();
  286.                 $(this).parent().parent().find("input[type='hidden']").attr('value','0'); //reset the clearImage actions if it was pressed
  287.             });
  288.             $(".removeDoc").click(function(e){
  289.                 e.preventDefault();
  290.                 var input = $(this).parent().parent().find("input[type='file']");
  291.                 input.replaceWith(input.val('').clone(true));
  292.                 $(this).parent().parent().find("img").attr('src','').width(150).height(150).hide();
  293.                 $(this).parent().parent().find("input[type='hidden']").attr('value','1');
  294.             });
  295.             function readURL(input , selectImage) {
  296.                 if (input.files && input.files[0]) {
  297.                     var reader = new FileReader();
  298.                     reader.onload = function (e) {
  299.                         $(selectImage)
  300.                             .attr('src', e.target.result)
  301.                             .width(100)
  302.                             .height(100).show();
  303.                     };
  304.                     reader.readAsDataURL(input.files[0]);
  305.                 }
  306.             }
  307.             /*================= for image show ==============*/
  308.             $(document).on("click", ".vehicleDocs img",function(){
  309.                 var srcImg = $(this).attr("src");
  310.                 if(srcImg != undefined){
  311.                     if(srcImg.length > 0 ){
  312.                         swal({
  313.                             imageUrl: srcImg,
  314.                             showCloseButton: true,
  315.                             confirmButtonText: '<a href = "'+ $(this).attr("src") + '" target="_blank"><i class="fa fa-print icon_color_gold"></i></a>'
  316.                         });
  317.                     }
  318.                 }
  319.             });
  320.         });
  321.     </script>
  322. {% endblock %}