{% extends 'base.html.twig' %}
{% block pageTitle %}{% endblock %}
{% block stylesheets %}
{{ parent() }}
<link rel="stylesheet" href="/plugins/dropzone/min/dropzone.min.css">
{% endblock %}
{% block content %}
<div class="row content-header">
{% if new==false %}
<div class="col-md-6"><h1>Editar imóvel #{{ data.id }} {{ data.status==false? '(inativo)': '' }}</h1></div>
{% else %}
<div class="col-md-6"><h1>Novo imóvel</h1></div>
{% endif %}
<div class="col-md-6 text-right"><a href="{{ path('admin_clientes_lista') }}">Voltar para lista</a></div>
</div>
{{ include('default/_flash_messages.html.twig') }}
{% if new==false %}
<div class="row">
<a class="btn btn-app" href="{{ path('admin_inventario_edit',{id:data.id}) }}" alt="Inventário" title="Inventário">
<i class="fas fa-tasks"></i> Inventário
</a>
<a class="btn btn-app" href="{{ path('admin_vistoria_list',{id:data.id}) }}" alt="Vistoria" title="Vistoria">
<i class="fas fa-check"></i> Vistoria
</a>
<a class="btn btn-app" href="{{ path('admin_reserva_list',{id:data.id}) }}" alt="Reservas" title="Reservas">
<i class="far fa-calendar-alt"></i> Reservas
</a>
<a class="btn btn-app" href="{{ path('admin_ocorrencia_list',{id:data.id}) }}" alt="Ocorrências" title="Ocorrências">
<i class="fas fa-exclamation-triangle"></i> Ocorrências
</a>
</div>
{% endif %}
<div class="card card-primary">
<!-- /.card-header -->
<!-- form start -->
{{ form_start(form) }}
<div class="card-body">
<div class="row">
<div class="col-md-4">{{ form_row(form.nome) }}</div>
<div class="col-md-4">{{ form_row(form.email) }}</div>
<div class="col-md-4">{{ form_row(form.plano) }}</div>
<div class="col-md-4">{{ form_row(form.cpf) }}</div>
<div class="col-md-4">{{ form_row(form.codStays) }}</div>
<div class="col-md-4">{{ form_row(form.celular) }}</div>
<div class="col-md-4">{{ form_row(form.cidade) }}</div>
<div class="col-md-4">{{ form_row(form.endereco) }}</div>
<div class="col-md-4" id="div_contrato">
{{ form_row(form.contrato) }}
<div id="photo_preview" style="margin-top: -1em; display: inline-block">
{% if data.contrato|default(false) %}
<i style="font-size: 34px" class="far fa-file-pdf"></i>
{% endif %}
</div>
<a href="javascript:void(0)" id="change_contrato">Alterar</a>
<a href="javascript:void(0)" id="download_pdf">Baixar</a>
<a href="javascript:void(0)" id="remove_contrato" style="display: none">Remover</a>
</div>
</div>
</div>
<div class="card-footer row">
<div class="col-md-6">
<button type="submit" class="btn btn-primary">Salvar</button>
</div>
<div class="col-md-6 text-right">
{% if new==false %}
{% if data.status==1 %}
<button type="button" class="btn btn-danger" data-nome="{{ data.nome }}" data-id="{{ data.id }}" id="inativar"><i class="far fa-trash-alt"></i> Inativar</button>
{% else %}
<button type="button" class="btn btn-success" data-nome="{{ data.nome }}" data-id="{{ data.id }}" id="reativar"><i class="fa fa-plus-circle"></i> Reativar</button>
{% endif %}
{% endif %}
</div>
</div>
{{ form_end(form) }}
</div>
<div class="modal fade" id="contratosUploadModal">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<h6 class="modal-title"></h6>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form action="{{ path('admin_clientes_contrato')}}?id={{ data.id }}" class="dropzone" id="dropzonewidget" enctype="multipart/form-data"></form>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="modalAlert">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Confirmação</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p></p>
</div>
<div class="modal-footer justify-content-between">
<form method="post" action="{{ data.status==true? path('admin_clientes_inativos_inativar'): path('admin_clientes_inativos_reativar') }}">
<input type="hidden" name="id" value="" />
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
<button type="submit" class="btn btn-primary">OK</button>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
{{ parent() }}
<script src="/dist/js/adminlte.min.js"></script>
<script src="/plugins/dropzone/min/dropzone.min.js"></script>
<script>
var contrato = '';
Dropzone.autoDiscover = false;
$(".dropzone").dropzone({
addRemoveLinks: true,
maxFiles: 1,
acceptedFiles: '.pdf',
dictDefaultMessage: "Arraste ou selecione seu contrato aqui",
dictRemoveFile: "Remover",
removedfile: function(file) {
var name = file.name;
$('#client_contrato').attr('value','');
$('#photo_preview').html('');
verifica_contrato();
var _ref;
return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
},
init: function () {
this.on("success", function(file, response) {
contrato = response.url;
$('#client_contrato').attr('value',response.url);
$('#photo_preview').html('<i style="font-size: 34px" class="far fa-file-pdf"></i>');
verifica_contrato();
});
}
});
jQuery(document).ready(function($) {
$('body').on('click','#change_contrato', function () {
$('#contratosUploadModal').modal();
});
$('body').on('click','#download_pdf', function () {
window.open($('#client_contrato').val());
});
$('body').on('click','#remove_contrato', function () {
$('#client_contrato').attr('value','');
$('#photo_preview').html('');
$('.dz-preview').click();
verifica_contrato();
});
verifica_contrato();
$('body').on('click','#inativar', function () {
$('#modalAlert [name=id]').val($(this).data('id'));
$('#modalAlert .modal-body p').html('Deseja realmente alterar o cliente: <b>'+$(this).data('nome')+'</b> para inativo?');
$('#modalAlert').modal();
});
$('body').on('click','#reativar', function () {
$('#modalAlert [name=id]').val($(this).data('id'));
$('#modalAlert .modal-body p').html('Deseja realmente alterar o cliente: <b>'+$(this).data('nome')+'</b> para ativo?');
$('#modalAlert').modal();
});
});
function verifica_contrato(){
if($('#client_contrato').val()!=''){
$('#photo_preview').html('<i style="font-size: 34px" class="far fa-file-pdf"></i>');
$('#download_pdf').show();
$('#change_contrato').html('Alterar');
$('#remove_contrato').show();
}
else{
$('#photo_preview').html('');
$('#download_pdf').hide();
$('#change_contrato').html('Adicionar');
$('#remove_contrato').hide();
}
}
</script>
{% endblock %}