templates/vehicledocs/edit.html.twig line 1
{% form_theme docsForm 'form/fields-file.html.twig' %}
{% extends 'vehicle_tabs.html.twig' %}
{% block page_title %} {{ "Documents"|trans({},'vehicles') }} {% endblock %}
{% block flash_messages %}
{{ parent() }}
{% include 'form_validation.html.twig' with {'current_form': docsForm} %}
{% endblock %}
{% block stylesheets %}
{{ parent() }}
<style>
#images button{
font-size: 12px !important;
padding: 10px 12px !important;
}
#appbundle_vehicles_vehicleRegistrations {display: none !important;}
</style>
{% endblock %}
{% block tabs2_body %}
{% set DOCS_TYPES = constant('App\\Entity\\VehicleDocTypes::DOC_TYPES') %}
{% set CLIENT_TYPES = constant('App\\Entity\\VehicleClients::CLIENT_TYPES') %}
<div class="table-responsive">
{{ form_start(docsForm) }}
<table class="table table-bordered vehicleDocs">
{# Display vehicle registration's document fields if it exists #}
{% if docsForm.vehicleRegistrations.registrationDoc.receivedDocType is defined %}
<tr>
<td>{{ form_label(docsForm.vehicleRegistrations.registrationDoc.receivedDocType) }}</td>
<td class="skin-minimal">
<div class="form-group">
{{ form_widget(docsForm.vehicleRegistrations.registrationDoc.receivedDocType) }}
{{ form_errors(docsForm.vehicleRegistrations.registrationDoc.receivedDocType) }}
</div>
</td>
<td>
<div class="form-group">
{% set imageSrc = null %}
{% if registrationDocImage is not null %}
{% set imageSrc = asset(vehicle_uploaded_files ~ '/' ~ vehicle.vehicleId ~ '/' ~ registrationDocImage) %}
<img class="selectedImage imgShow" src="{{imageSrc}}" />
{% endif %}
{#{{ form_widget(docsForm.vehicleRegistrations.registrationDoc.imagePath, { 'attr': {'style': 'display:none !important'} }) }}
{{ form_errors(docsForm.vehicleRegistrations.registrationDoc.imagePath, { 'attr': {'style': 'display:none !important'} }) }}#}
</div>
</td>
</tr>
{% endif %}
{# Display vehicle's documents fields #}
{% for document in docsForm.vehicleDocument %}
<tr>
<td>{#{ document.vars.value.docType.docTypeId }#}
{# Get the label from either imagePath or receivedDocType #}
{% if document.imagePath is defined %}
{{ form_label(document.imagePath) }}
{% elseif document.receivedDocType is defined %}
{{ form_label(document.receivedDocType) }}
{% endif %}
</td>
<td class="skin-minimal">
<div class="form-group">
{% if document.receivedDocType is defined %}
{{ form_widget(document.receivedDocType) }}
{{ form_errors(document.receivedDocType) }}
{% endif %}
{% if document.vehicle is defined %}
<div class="">
{{ form_label(document.vehicle.inspectionExpirationDate, null, {'label_attr' : {'class': 'control-label'} }) }}
<div class='input-group date datetimepicker'>
{{ form_widget(document.vehicle.inspectionExpirationDate, {'attr' : {'class': 'form-control'} }) }}
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
</div>
{{ form_errors(document.vehicle.inspectionExpirationDate) }}
</div>
{% endif %}
{% if document.vars.data.docType.docTypeId == DOCS_TYPES.insurance %}
<div class="row">
<div class="col-md-6">
{{ form_label(docsForm.insuranceStartDate, null, {'label_attr' : {'class': 'control-label'} }) }}
<div class='input-group date datetimepicker'>
{{ form_widget(docsForm.insuranceStartDate, {'attr' : {'class': 'form-control'} }) }}
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
</div>
{{ form_errors(docsForm.insuranceStartDate) }}
</div>
<div class="col-md-6">
{{ form_label(docsForm.insuranceExpiryDate, null, {'label_attr' : {'class': 'control-label'} }) }}
<div class='input-group date datetimepicker'>
{{ form_widget(docsForm.insuranceExpiryDate, {'attr' : {'class': 'form-control'} }) }}
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
</div>
{{ form_errors(docsForm.insuranceExpiryDate) }}
</div>
</div>
{% endif %}
</div>
</td>
<td>
{% if document.imagePath is defined %}
<div class="row" id="images">
<div class="col-lg-4">
{{ form_widget(document.imagePath) }}
{{ form_errors(document.imagePath) }}
{% if document.imagePath.vars.image_url is null %}
<img class="imgShow" src="" alt="" width="100" height="100"> {#if there isn't image #}
{% endif %}
{{ form_row(document.clearImage) }} {# the hidden field flag that indicates that an image delete action needed #}
</div>
<div class="col-lg-8">
<p id="choose" class="btn btn-primary choose" >{{ 'select image' | trans({}, 'messages') }}</p>
<p id="image_reset" class="btn btn-warning image_reset" >{{ 'reset' | trans({}, 'messages') }}</p>
<p id="removeDoc" class="btn btn-danger removeDoc" >{{ 'clear image' | trans({}, 'messages') }}</p>
</div>
</div>
{% endif %}
</td>
</tr>
{% endfor %}
<tr>
<td><label>{{ 'owner identity photo' | trans({}, 'vehicles') }}</label></td>
<td>
{% if ownerPhoto is not null %}
{{ 'Yes' | trans }}
{% else %}
{{ 'No' | trans }}
{% endif %}
</td>
<td>
{% if ownerPhoto is not null %}
{% if vehicle.vehicleRegistrations.vehicleOwner.getClientType == CLIENT_TYPES.user %}
<img class="imgShow" src="{{ asset(users_uploaded_files ~ '/' ~ ownerId ~ '/' ~ ownerPhoto) }}" style="width: 100px;">
{% elseif vehicle.vehicleRegistrations.vehicleOwner.getClientType == CLIENT_TYPES.company %}
<img class="imgShow" src="{{ asset(companies_uploaded_files ~ '/' ~ ownerId ~ '/' ~ ownerPhoto) }}"style="width: 100px;">
{% endif %}
{% endif %}
</td>
</tr>
</table>
{#{{ form_widget(docsForm) }}#}
<input type="submit" value="{{ 'Save' |trans }}" class="btn btn-success" />
{{ form_end(docsForm) }}
<br>
{# Vehicle Activity Estimation#}
<div class="panel panel-info">
<div class="panel-heading">{{ 'Estimation of Sheikh Exhibitions' | trans({}, 'vehicles') }}</div>
<div class="panel-body">
<table class="table table-bordered vehicle" id="estimation">
<thead>
<tr>
<th>{{ 'Value Before' | trans({}, 'vehicles') }}</th>
<th>{{ 'Value After' | trans({}, 'vehicles') }}</th>
<th>{{ 'partsEstimation' | trans({}, 'vehicles') }}</th>
<th>{{ 'Estimation Document' | trans({}, 'vehicles') }}</th>
<th></th>
</tr>
</thead>
<tbody>
{% for estimate in estimation %}
<tr>
<td>{{ estimate.estimateValBefore }}</td>
<td>{{ estimate.estimateValAfter }}</td>
<td>{{ estimate.partsEstimation }}</td>
<td>
{% if estimate.imagePath is not null %}
<img src="{{ asset(estimate.imagePath) }}" style="width: 100px; height: 55px;" />
{% endif %}
</td>
<td>
{% set activityId = estimate.activityId %}
{% set vehicleId = estimate.RtsVehicleId %}
{% if activityId is null %}
{% set activityId = 0 %}
{% set vehicleId = estimate.vehicleId %}
{% endif %}
<a href="{{ path('vehicleRtsActivitiesEstimateValEdit', {'vehicleId': vehicleId, 'activityId':activityId , 'estimateId': estimate.estimationId}) }}" title="{{ 'editEstimation' | trans({}, 'vehicles') }}">
<span class="fa fa-pencil"></span>
</a>
</td>
</tr>
{% endfor %}
<tr><td colspan="8"><a href="{{ path('vehicleRtsActivitiesEstimateVal_new', {'vehicleId': vehicle.vehicleId, 'activityId': '0'}) }}" class="btn btn-success">{{ 'createVehicleRtsActivitiesEstimateVal' | trans({}, 'vehicles') }}</a></td></tr>
</tbody>
</table>
</div>
</div>
</div>
{# Security Notices #}
<div class="panel panel-info">
<div class="panel-heading">{{ 'securityNotes' | trans({}, 'vehicles') }}</div>
<div class="panel-body">
<table class="table table-bordered vehicle" id="securityNotes">
<thead>
<tr>
<th>{{ 'Notes Type' | trans({}, 'vehicles') }}</th>
<th>{{ 'Notes Date' | trans({}, 'vehicles') }}</th>
<th>{{ 'revocation date' | trans({}, 'vehicles') }}</th>
<th>{{ 'Followup date' | trans({}, 'vehicles') }}</th>
<th>{{ 'Is Effective' | trans({}, 'vehicles') }}</th>
<th>{{ 'Image' | trans({}, 'vehicles') }}</th>
<th></th>
</tr>
</thead>
<tbody>
{% for security_notice in security_notices %}
<tr>
<td> {{ security_notice.noticeType|trans( {}, "vehicles" ) }}
</td>
<td>{% if security_notice.noticeDate %}{{ security_notice.noticeDate|date('Y-m-d') }}{% endif %}</td>
<td>{% if security_notice.revocationDate %}{{ security_notice.revocationDate|date('Y-m-d') }}{% endif %}</td>
<td>{% if security_notice.followupDate %}{{ security_notice.followupDate|date('Y-m-d') }}{% endif %}</td>
<td>{% if security_notice.isEffective %}{{ "Effective"|trans( {}, "vehicles" ) }}{% else %}{{ "Ineffective"|trans( {}, "vehicles" ) }}{% endif %}</td>
<td>
{% if security_notice.noteDoc and security_notice.noteDoc.imageWebPath is not null %}
<img class="imgShow" src="{{ asset(security_notice.noteDoc.imageWebPath) }}" style="height:55px;width:55px;" />
{% endif %}
</td>
<td>
<div class="btn-group btn-group-justified" style="width: 50% !important; display: unset;">
<a href="{{ path('vehiclesecuritynotices_edit', { 'noticeId': security_notice.noticeId }) }}" class="btn btn-success" style="margin-left: 10px">
<i class="fa fa-edit"></i>
</a>
{% if is_granted('ROLE_FOLLOW_UP_OFFICER') == true %}
<a href="{{ path('vehiclesecuritynotices_delete', { 'noticeId': security_notice.noticeId }) }}" class="btn btn-danger" onclick="return confirm('{{ "Are you sure?"|trans() }}')">
<i class="fa fa-trash"></i>
</a>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
<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>
</tbody>
</table>
</div>
</div>
</div>
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script>
$(function () {
//set tabs2 as an active tab
$( "#vehicle_tabs .tabs2" ).addClass( "active" );
delete_record=function(notice_id){
var del_url="{{ path('vehiclesecuritynotices_delete', { 'noticeId': 0 }) }}";
del_url = del_url.replace("0",notice_id);
var obj={
noticeId:notice_id
};
$.ajax({
url: del_url,
method: 'post',
data: obj,
success: function(response){
//window.location(response.url);
alert("working");
}
});
};
$('.datetimepicker').datetimepicker({
locale: 'en-gb',
sideBySide: true,
format:'YYYY-MM-DD',
icons: {
previous: 'fa fa-arrow-right',
next: 'fa fa-arrow-left'
}
});
//#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
$(".docImg").hide();
$(".docImg").change(function(){
let input = $(this);
readURL(this, $(this).next('img'));
});
$(".choose").click(function(e){
e.preventDefault();
let input = $(this).parent().parent().find("input[type='file']");
input.click();
});
//unset the input file field and also unset the thumbnail view of the image
$(".image_reset").click(function(e){
e.preventDefault();
var input = $(this).parent().parent().find("input[type='file']");
input.replaceWith(input.val('').clone(true));
$(this).parent().parent().find("img").attr('src','').width(100).height(100).hide();
$(this).parent().parent().find("input[type='hidden']").attr('value','0'); //reset the clearImage actions if it was pressed
});
$(".removeDoc").click(function(e){
e.preventDefault();
var input = $(this).parent().parent().find("input[type='file']");
input.replaceWith(input.val('').clone(true));
$(this).parent().parent().find("img").attr('src','').width(150).height(150).hide();
$(this).parent().parent().find("input[type='hidden']").attr('value','1');
});
function readURL(input , selectImage) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$(selectImage)
.attr('src', e.target.result)
.width(100)
.height(100).show();
};
reader.readAsDataURL(input.files[0]);
}
}
/*================= for image show ==============*/
$(document).on("click", ".vehicleDocs img",function(){
var srcImg = $(this).attr("src");
if(srcImg != undefined){
if(srcImg.length > 0 ){
swal({
imageUrl: srcImg,
showCloseButton: true,
confirmButtonText: '<a href = "'+ $(this).attr("src") + '" target="_blank"><i class="fa fa-print icon_color_gold"></i></a>'
});
}
}
});
});
</script>
{% endblock %}