{% extends "@ApplicationInternit/ContentBundle/Resources/views/template/standard_layout.html.twig" %}
{% block javascripts %}
{{ parent() }}
<script href="{{ asset('/bundles/applicationinternitcontent/js/multiple-select.min.js') }}"></script>
<script src="{{ asset('/bundles/applicationinternitcontent/js/canonical.js') }}"></script>
<script type="text/javascript">
function copyToken() {
/* Get the text field */
copyText = document.getElementById("tokenIntegration");
/* Select the text field */
copyText.select();
copyText.setSelectionRange(0, 99999); /*For mobile devices*/
/* Copy the text inside the text field */
document.execCommand("copy");
}
$(document).ready(function() {
setTimeout(() =>{
let input = document.querySelectorAll('.changeRadio');
for( let item of input){
item.ondblclick = function (){
if(item.checked == true){
let liId = item.closest('li').id;
let lis = document.querySelectorAll(`.${liId}`);
for( let li of lis){
li.classList.remove("selected");
li.classList.remove("active");
}
item.checked = false;
}
}
}
},2000)
var realStatePercents = {{ obj.realStatePercentByName|json_encode|raw }};
$(".broker-select").multipleSelect({
selectAll: true,
multiple: false,
isOpen: true,
filter: false,
keepOpen: true,
filterPlaceholder: 'Filtre as Imobiliárias ou corretores',
placeholder: "Corretores",
formatSelectAll () {
return 'Selecionar Todos'
},
formatNoMatchesFound () {
return 'Nenhum resultado'
},
labelTemplate: function ($el) {
let rsCanonical = convertToCanonical($el.attr('label'));
return '<i class="fa fa-building"></i>' +
'<div class="imobPerc">' +
'<p class="nameImob">' + $el.attr('label') + '</p>' +
'<div class="imobInput">' +
'<input type="number" name="{{ form.vars.name }}[realStatePercents]['+rsCanonical+'][percent]" id="realStatePercent-'+rsCanonical+'" class="percent-realstate" value="'+realStatePercents[$el.attr('label')]+'" min="0" max="100"/>' +
'<span>%</span>' +
'</div></div><div class="imobLabel"><label class="check-all-label"><input type="radio" class="check-all changeRadio" name="escolha' + $el.attr('label') + '"/><span class="checkmark"></span></label> <label class="accordion-open-label"><input type="radio" class="accordion-open changeRadio" name="escolha' + $el.attr('label') + '"/><span class="checkmark"></span></label></div>';
},
textTemplate: function ($el) {
return '<i class="far fa-user"></i><p>' + $el.html() + '</p>';
}
});
let imobiliarisSelect = Array();
let corretoresSelect = Array();
{% for corretor in obj.productUsers %}
imobiliarisSelect.push('{{ corretor.realEstate.name }}');
corretoresSelect.push('{{corretor.realEstate.id}}:{{corretor.user.id}}');
{% endfor %}
if(corretoresSelect.length > 0){
//$(".broker-select").multipleSelect('setSelects', corretoresSelect)
}
setTimeout(()=>{
for (let i=0; i<imobiliarisSelect.length; i++){
let element = $(`[name="escolha${imobiliarisSelect[i]}"]`)
element.trigger('click')
}
for (let i=0; i<corretoresSelect.length; i++){
$(`[value="${corretoresSelect[i]}"]`).click()
}
},500)
//console.log(corretoresSelect)
$('#js-submit-form').click(function(e){
var error = 0;
var msg = 'Campos obrigatórios não preenchidos:\n';
$(':input[required]').each(function(){
$(this).css('border','2px solid green');
if($(this).val() == ''){
msg += '\n' + $(this).next().text();
$(this).css('border','2px solid red');
if(error == 0)
{
$(this).focus();
}
error = 1;
}
});
if(error == 1) {
alert('Campos obrigatórios não foram preenchidos.');
return false;
}
});
});
</script>
<script type="text/javascript" src="{{ asset('bundles/applicationinternitlead/js/product-edit.js') }}"></script>
{% endblock %}
{% block stylesheets %}
{{ parent() }}
<link rel="stylesheet" href="{{ asset('/bundles/applicationinternitcontent/css/formularios.css') }}"/>
<link rel="stylesheet" href="{{ asset('/bundles/applicationinternitcontent/css/productBundle.css') }}"/>
<link rel="stylesheet" href="{{ asset('/bundles/applicationinternitcontent/css/multiple-select.min.css') }}"/>
{% endblock %}
{% block title %}
Edição de campanha
{% endblock %}
{% block sonata_admin_content %}
<div class="meusDados">
{% for flashMessage in app.session.flashbag.get('flash_create_success') %}
<div class="caixa-resposta">
<div class="resposta active" id="r-sucess">
<i class="far fa-check-circle"></i>
<p>Salvo com sucesso</p>
</div>
</div>
{% endfor %}
{% for flashMessage in app.session.flashbag.get('flash_create_error') %}
<div class="caixa-resposta">
<div class="resposta active" id="r-error">
<i class="far fa-times-circle"></i>
<p>{{ flashMessage|raw }}</p>
</div>
</div>
{% endfor %}
<div class="titleDefault">
<div class="group">
<h3>Editar Campanha</h3>
<a class="btn-voltar" href="{{ path('admin_internit_lead_product_list')}}"><i class="fas fa-arrow-left"></i>Voltar</a>
</div>
</div>
<div class="contentProductCreate edit">
{{ form_start(form) }}
<div class="boxDefault">
<div class="my-custom-class-for-errors">
{{ form_errors(form) }}
</div>
<div class="formulario">
<div class="fieldset">
<div class="flex">
<div class="col inputBox">
{{ form_widget(form.name) }}
{{ form_label(form.name) }}
</div>
</div>
<div class="flex">
<div class="col inputBox">
{{ form_widget(form.email) }}
{{ form_label(form.email) }}
</div>
</div>
<div class="flex">
<div class="col inputBox">
{{ form_widget(form.description) }}
{{ form_label(form.description) }}
</div>
</div>
<div class="flex">
<div class="col inputBox">
<input readonly id="tokenIntegration" type="text" value="{{ obj.token }}">
<label for="token">Código para implementação:</label>
</div>
</div>
<div class="row row-space">
<div class="col-md-4">
<div class="col inputBox">
{{ form_widget(form.vivaReal) }}
{{ form_label(form.vivaReal) }}
</div>
</div>
<div class="col-md-4">
<div class="col inputBox">
{{ form_widget(form.zap) }}
{{ form_label(form.zap) }}
</div>
</div>
<div class="col-md-4">
<div class="col inputBox">
{{ form_widget(form.olx) }}
{{ form_label(form.olx) }}
</div>
</div>
</div>
<br>
<div class="flex btns-create">
<div class="flex buttons-create" id="" onclick="copyToken()">
<i class="far fa-copy"></i>
<input type="button" class="" value="Copiar Código">
</div>
<button class="flex buttons-create" type="submit" id="js-submit-form">
<i class="far fa-save"></i>
<span>Salvar</span>
</button>
</div>
</div>
</div>
</div>
<div class="boxDefault">
<div class="formulario">
<div class="fieldset">
<p class="text-imob">Selecioner a imobiliaria/corretor para recebimento dos leads em rodizio.</p>
<div class="flex">
<div class="col">
{# <i class="fas fa-search"></i> #}
<div class="accordion-head">
<p>Imobiliária</p>
<div class="options">
<p>Enviar Todos</p>
<p>Escolher Corretor</p>
</div>
</div>
{{ form_label(form.productUsers) }}
{{ form_widget(form.productUsers) }}
</div>
</div>
</div>
</div>
</div>
<div style="display:none;">{{ form_widget(form.realStatePercents) }}</div>
{{ form_end(form) }}
</div>
</div>
<div class="meusDados" style="margin-top: 20px;">
<div class="titleDefault col-12">
<div class="row">
<div class="col-12">
<h3>Imobiliárias Ativas </h3>
<span class="" style="font-size: 15px">Listagem de Imobiliárias regularmente ativas na campanha e suas estatísticas.</span>
</div>
<div class="col-12">
<table class="table table-striped table-bordered">
<thead class="thead-dark">
<tr style="font-size: 16px">
<th scope="col">#</th>
<th scope="col">id</th>
<th scope="col">Imobiliária</th>
<th scope="col">Porcentagem %</th>
<th scope="col">Leads Recebidos</th>
<th scope="col">Leads Recebidos + Extra Leads</th>
<th scope="col">Extra Leads</th>
<th scope="col">Ver Corretores</th>
<th scope="col">Primeiro recebido:</th>
<th scope="col">Ultimo recebido</th>
</tr>
</thead>
<tbody>
{% set totalLeads = 0 %}
{% for index,realState in obj.getRealStateProductInfo %}
{% if realState['percent'] != 0 %}
{% set totalLeads = totalLeads + realState['qtdLeads'] %}
<tr style="font-size: 16px">
<th scope="row">{{ index+1 }}</th>
<th scope="row">{{ realState['id'] }}</th>
<td>{{ realState['name'] }}</td>
<td><b>{{ realState['percent'] }}</b>%</td>
<td><b>{{ realState['qtdLeads'] }}</b> Leads</td>
<td><b>{{ realState['qtdLeads'] + realState['extraLeads'] }}</b> Leads</td>
<td>
<b>{{ realState['extraLeads'] }}</b> Leads
<a type="button" data-toggle="modal" data-target="#modalExtraLead-{{ realState['id'] }}">
<i class="fas fa-edit"></i>
</a>
</td>
<td class="text-center">
<a href="javascript:void(0)" onclick="openCorretorList({{ realState['id'] }})">
<b>Corretores ({{ realState['corretores']|length }})</b>
</a>
</td>
<td><b>{{ realState['firstLead']|date('d/m/Y h:i:s') }}</b> </td>
<td><b>{{ realState['lastLead']|date('d/m/Y h:i:s') }}</b> </td>
</tr>
<div class="modal fade" id="modalExtraLead-{{ realState['id'] }}" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{{ realState['name'] }} - Leads Extra</h5>
</div>
<div class="modal-body">
<br>
<form action="{{ path('admin_internit_lead_product_saveExtraLeads') }}" method="get">
<input type="hidden" name="realStateId" value="{{ realState['id'] }}">
<input type="hidden" name="product" value="{{ obj.id }}">
<div class="form-group">
<label style="font-size: 12px">Extra Leads</label>
<input type="number" class="form-control" name="extraLeads" value="{{ realState['extraLeads'] }}">
<small class="form-text text-muted" style="font-size: 10px">Quantidade de leads a serem adicionados a imobiliária de modo a auxiliar na contabilidade das informações</small>
</div>
<br><br>
<div class="float-right">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Sair</button>
<button type="submit" class="btn btn-primary">Atualizar</button>
</div>
</form>
</div>
</div>
</div>
</div>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
<div class="col-12">
<h3>Total de Leads Recebidos: <b>{{ totalLeads }}</b></h3>
</div>
{% for index,realState in obj.getRealStateProductInfo %}
<div class="col-12 allCorretoresList" id="corretor-list-{{ realState['id'] }}" style="display: none">
<hr>
<br>
<div class="row">
<div class="col-6">
<h3> Corretores Ativos - <b>{{ realState['name'] }}</b></h3>
</div>
{% set lastPosition = 0 %}
{% for index,corretor in realState['corretores'] %}
{% set lastPosition = index %}
{% endfor %}
{% set nextPosition = realState['turn'] %}
{% if nextPosition > lastPosition %}
{% set nextPosition = 0 %}
{% endif %}
<div class="col-6 text-right" >
<h3> Próximo da fila - (<b>{{ nextPosition + 1 }}</b>)</h3>
</div>
</div>
<table class="table table-striped table-bordered">
<thead class="thead-dark">
<tr style="font-size: 16px">
<th scope="col">Posição na fila</th>
<th scope="col">Nome</th>
<th scope="col">Email</th>
<th scope="col">Qtd Leads Recebidos</th>
</tr>
</thead>
<tbody>
{% for index,corretor in realState['corretores'] %}
<tr style="font-size: 16px">
<th scope="row">{{ index + 1 }}</th>
<th scope="row">{{ corretor['name'] }}</th>
<th scope="row">{{ corretor['email'] }}</th>
<th scope="row">{{ corretor['qtdLeads'] }}</th>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endfor %}
</div>
</div>
</div>
<script>
let openCorretorList = (realStateId)=>{
let div = $(`#corretor-list-${realStateId}`)
let allCorretores = $(`.allCorretoresList`)
if(div.css('display') === 'none') {
allCorretores.css('display', 'none')
div.css('display', 'block')
}else{
allCorretores.css('display', 'none')
}
const scrollingElement = (document.scrollingElement || document.body);
scrollingElement.scrollTop = scrollingElement.scrollHeight;
}
</script>
{% endblock %}