src/Application/Internit/LeadBundle/Resources/views/Product/edit.html.twig line 1

Open in your IDE?
  1. {% extends "@ApplicationInternit/ContentBundle/Resources/views/template/standard_layout.html.twig" %}
  2. {% block javascripts %}
  3.     {{ parent() }}
  4.     <script href="{{ asset('/bundles/applicationinternitcontent/js/multiple-select.min.js') }}"></script>
  5.     <script src="{{ asset('/bundles/applicationinternitcontent/js/canonical.js') }}"></script>
  6.     <script type="text/javascript">
  7.     function copyToken() {
  8.         /* Get the text field */
  9.         copyText = document.getElementById("tokenIntegration");
  10.         /* Select the text field */
  11.         copyText.select();
  12.         copyText.setSelectionRange(0, 99999); /*For mobile devices*/
  13.         /* Copy the text inside the text field */
  14.         document.execCommand("copy");
  15.     }
  16.     $(document).ready(function() {
  17.         setTimeout(() =>{
  18.             let input = document.querySelectorAll('.changeRadio');
  19.             for( let item of input){
  20.                 item.ondblclick = function (){
  21.                     if(item.checked == true){
  22.                         let liId = item.closest('li').id;
  23.                         let lis = document.querySelectorAll(`.${liId}`);
  24.                         for( let li of lis){
  25.                             li.classList.remove("selected");
  26.                             li.classList.remove("active");
  27.                         }
  28.                         item.checked = false;
  29.                     }
  30.                 }
  31.             }
  32.         },2000)
  33.         var realStatePercents = {{ obj.realStatePercentByName|json_encode|raw }};
  34.         $(".broker-select").multipleSelect({
  35.                 selectAll: true,
  36.                 multiple: false,
  37.                 isOpen: true,
  38.                 filter: false,
  39.                 keepOpen: true,
  40.                 filterPlaceholder: 'Filtre as Imobiliárias ou corretores',
  41.                 placeholder: "Corretores",
  42.                 formatSelectAll () {
  43.                     return 'Selecionar Todos'
  44.                 },
  45.                 formatNoMatchesFound () {
  46.                     return 'Nenhum resultado'
  47.                 },
  48.                 labelTemplate: function ($el) {
  49.                     let rsCanonical = convertToCanonical($el.attr('label'));
  50.                     return '<i class="fa fa-building"></i>' +
  51.                             '<div class="imobPerc">' +
  52.                             '<p class="nameImob">' + $el.attr('label') + '</p>' +
  53.                             '<div class="imobInput">' +
  54.                             '<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"/>' +
  55.                             '<span>%</span>' +
  56.                             '</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>';
  57.                 },
  58.                 textTemplate: function ($el) {
  59.                     return '<i class="far fa-user"></i><p>' + $el.html() + '</p>';
  60.                 }
  61.             });
  62.         
  63.         let imobiliarisSelect = Array();
  64.         let corretoresSelect = Array();
  65.         {% for corretor in obj.productUsers %}
  66.             imobiliarisSelect.push('{{ corretor.realEstate.name }}');
  67.             corretoresSelect.push('{{corretor.realEstate.id}}:{{corretor.user.id}}');
  68.         {% endfor %}
  69.         if(corretoresSelect.length > 0){
  70.             //$(".broker-select").multipleSelect('setSelects', corretoresSelect)
  71.         }
  72.         setTimeout(()=>{
  73.             for (let i=0; i<imobiliarisSelect.length; i++){
  74.                 let element = $(`[name="escolha${imobiliarisSelect[i]}"]`)
  75.                 element.trigger('click')
  76.             }
  77.             for (let i=0; i<corretoresSelect.length; i++){
  78.                 $(`[value="${corretoresSelect[i]}"]`).click()
  79.             }
  80.         },500)
  81.         //console.log(corretoresSelect)
  82.         $('#js-submit-form').click(function(e){
  83.             var error = 0;
  84.             var msg = 'Campos obrigatórios não preenchidos:\n';
  85.             $(':input[required]').each(function(){            
  86.                 $(this).css('border','2px solid green');
  87.                 if($(this).val() == ''){
  88.                     msg += '\n' + $(this).next().text();
  89.                     $(this).css('border','2px solid red');
  90.                     if(error == 0)
  91.                         { 
  92.                             $(this).focus(); 
  93.                         }
  94.                     error = 1;
  95.                     
  96.                 }
  97.             });
  98.             if(error == 1) {
  99.                 alert('Campos obrigatórios não foram preenchidos.');        
  100.                 return false;
  101.             }
  102.         });
  103.     });
  104.     </script>    
  105.     <script type="text/javascript" src="{{ asset('bundles/applicationinternitlead/js/product-edit.js') }}"></script>
  106. {% endblock %}
  107. {% block stylesheets %}
  108.     {{ parent() }}
  109.     <link rel="stylesheet" href="{{ asset('/bundles/applicationinternitcontent/css/formularios.css') }}"/>
  110.     <link rel="stylesheet" href="{{ asset('/bundles/applicationinternitcontent/css/productBundle.css') }}"/>
  111.     <link rel="stylesheet" href="{{ asset('/bundles/applicationinternitcontent/css/multiple-select.min.css') }}"/>
  112. {% endblock %}
  113. {% block title %}
  114.     Edição de campanha
  115. {% endblock %}
  116. {% block sonata_admin_content %}
  117.     <div class="meusDados">
  118.         {% for flashMessage in app.session.flashbag.get('flash_create_success') %}
  119.             <div class="caixa-resposta">
  120.                 <div class="resposta active" id="r-sucess">
  121.                     <i class="far fa-check-circle"></i>
  122.                     <p>Salvo com sucesso</p>
  123.                 </div>
  124.             </div>
  125.         {% endfor %}
  126.         {% for flashMessage in app.session.flashbag.get('flash_create_error') %}
  127.             <div class="caixa-resposta">
  128.                 <div class="resposta active" id="r-error">
  129.                     <i class="far fa-times-circle"></i>
  130.                     <p>{{ flashMessage|raw }}</p>
  131.                 </div>
  132.             </div>
  133.         {% endfor %}
  134.         <div class="titleDefault">
  135.             <div class="group">
  136.                 <h3>Editar Campanha</h3>
  137.                 <a class="btn-voltar" href="{{ path('admin_internit_lead_product_list')}}"><i class="fas fa-arrow-left"></i>Voltar</a>
  138.             </div>
  139.         </div>
  140.         
  141.         <div class="contentProductCreate edit">
  142.                 {{ form_start(form) }}
  143.                     <div class="boxDefault">
  144.                         <div class="my-custom-class-for-errors">
  145.                             {{ form_errors(form) }}
  146.                         </div>
  147.                         <div class="formulario">
  148.                             <div class="fieldset">
  149.                                 <div class="flex">
  150.                                     <div class="col inputBox">
  151.                                         {{ form_widget(form.name) }}
  152.                                         {{ form_label(form.name) }}
  153.                                     </div>
  154.                                 </div>
  155.                                 <div class="flex">
  156.                                     <div class="col inputBox">
  157.                                         {{ form_widget(form.email) }}
  158.                                         {{ form_label(form.email) }}
  159.                                     </div>
  160.                                 </div>
  161.                                 <div class="flex">
  162.                                     <div class="col inputBox">
  163.                                         {{ form_widget(form.description) }}
  164.                                         {{ form_label(form.description) }}
  165.                                     </div>
  166.                                 </div>
  167.                                 <div class="flex">
  168.                                     <div class="col inputBox">
  169.                                         <input readonly id="tokenIntegration" type="text" value="{{ obj.token }}">
  170.                                         <label for="token">Código para implementação:</label>
  171.                                     </div>
  172.                                 </div>
  173.                                 <div class="row row-space">
  174.                                     <div class="col-md-4">
  175.                                         <div class="col inputBox">
  176.                                             {{ form_widget(form.vivaReal) }}
  177.                                             {{ form_label(form.vivaReal) }}
  178.                                         </div>
  179.                                     </div>
  180.                                     <div class="col-md-4">
  181.                                         <div class="col inputBox">
  182.                                             {{ form_widget(form.zap) }}
  183.                                             {{ form_label(form.zap) }}
  184.                                         </div>
  185.                                     </div>
  186.                                     <div class="col-md-4">
  187.                                         <div class="col inputBox">
  188.                                             {{ form_widget(form.olx) }}
  189.                                             {{ form_label(form.olx) }}
  190.                                         </div>
  191.                                     </div>
  192.                                 </div>
  193.                                 <br>
  194.                                 <div class="flex btns-create">
  195.                                     <div class="flex buttons-create" id="" onclick="copyToken()">
  196.                                         <i class="far fa-copy"></i>
  197.                                         <input type="button" class="" value="Copiar Código">
  198.                                     </div>
  199.                                     <button class="flex buttons-create" type="submit" id="js-submit-form">
  200.                                         <i class="far fa-save"></i>
  201.                                         <span>Salvar</span>
  202.                                     </button>
  203.                                 </div>
  204.                             </div>
  205.                         </div>    
  206.                     </div>
  207.                     <div class="boxDefault">
  208.                         <div class="formulario">
  209.                             <div class="fieldset">
  210.                                 <p class="text-imob">Selecioner a imobiliaria/corretor para recebimento dos leads em rodizio.</p>
  211.                                 <div class="flex">
  212.                                     <div class="col">
  213.                                         {# <i class="fas fa-search"></i> #}
  214.                                         <div class="accordion-head">
  215.                                             <p>Imobiliária</p>
  216.                                             <div class="options">
  217.                                                 <p>Enviar Todos</p>
  218.                                                 <p>Escolher Corretor</p>
  219.                                             </div>
  220.                                         </div>
  221.                                         {{ form_label(form.productUsers) }}
  222.                                         {{ form_widget(form.productUsers) }}
  223.                                     </div>
  224.                                 </div>
  225.                             </div>
  226.                         </div>    
  227.                     </div>
  228.                     <div style="display:none;">{{ form_widget(form.realStatePercents) }}</div>
  229.                 {{ form_end(form) }}
  230.             </div>
  231.         </div>
  232.     <div class="meusDados" style="margin-top: 20px;">
  233.         <div class="titleDefault col-12">
  234.             <div class="row">
  235.                 <div class="col-12">
  236.                     <h3>Imobiliárias Ativas </h3>
  237.                     <span class="" style="font-size: 15px">Listagem de Imobiliárias regularmente ativas na campanha e suas estatísticas.</span>
  238.                 </div>
  239.                 <div class="col-12">
  240.                     <table class="table table-striped table-bordered">
  241.                         <thead class="thead-dark">
  242.                         <tr style="font-size: 16px">
  243.                             <th scope="col">#</th>
  244.                             <th scope="col">id</th>
  245.                             <th scope="col">Imobiliária</th>
  246.                             <th scope="col">Porcentagem %</th>
  247.                             <th scope="col">Leads Recebidos</th>
  248.                             <th scope="col">Leads Recebidos + Extra Leads</th>
  249.                             <th scope="col">Extra Leads</th>
  250.                             <th scope="col">Ver Corretores</th>
  251.                             <th scope="col">Primeiro recebido:</th>
  252.                             <th scope="col">Ultimo recebido</th>
  253.                         </tr>
  254.                         </thead>
  255.                         <tbody>
  256.                         {% set totalLeads = 0 %}
  257.                         {% for index,realState in obj.getRealStateProductInfo %}
  258.                             {% if realState['percent'] != 0 %}
  259.                             {% set totalLeads = totalLeads + realState['qtdLeads'] %}
  260.                             <tr style="font-size: 16px">
  261.                                 <th scope="row">{{ index+1 }}</th>
  262.                                 <th scope="row">{{ realState['id'] }}</th>
  263.                                 <td>{{ realState['name'] }}</td>
  264.                                 <td><b>{{ realState['percent'] }}</b>%</td>
  265.                                 <td><b>{{ realState['qtdLeads'] }}</b> Leads</td>
  266.                                 <td><b>{{ realState['qtdLeads'] + realState['extraLeads'] }}</b> Leads</td>
  267.                                 <td>
  268.                                     <b>{{ realState['extraLeads'] }}</b> Leads
  269.                                     <a type="button" data-toggle="modal" data-target="#modalExtraLead-{{ realState['id'] }}">
  270.                                          <i class="fas fa-edit"></i>
  271.                                     </a>
  272.                                 </td>
  273.                                 <td class="text-center">
  274.                                     <a href="javascript:void(0)" onclick="openCorretorList({{ realState['id'] }})">
  275.                                         <b>Corretores ({{ realState['corretores']|length }})</b>
  276.                                     </a>
  277.                                 </td>
  278.                                 <td><b>{{ realState['firstLead']|date('d/m/Y h:i:s') }}</b> </td>
  279.                                 <td><b>{{ realState['lastLead']|date('d/m/Y h:i:s') }}</b> </td>
  280.                             </tr>
  281.                             <div class="modal fade" id="modalExtraLead-{{ realState['id'] }}" tabindex="-1" role="dialog">
  282.                                 <div class="modal-dialog" role="document">
  283.                                     <div class="modal-content">
  284.                                         <div class="modal-header">
  285.                                             <h5 class="modal-title">{{ realState['name'] }} - Leads Extra</h5>
  286.                                         </div>
  287.                                         <div class="modal-body">
  288.                                             <br>
  289.                                             <form action="{{ path('admin_internit_lead_product_saveExtraLeads') }}" method="get">
  290.                                                 <input type="hidden" name="realStateId" value="{{ realState['id'] }}">
  291.                                                 <input type="hidden" name="product" value="{{ obj.id }}">
  292.                                                 <div class="form-group">
  293.                                                     <label style="font-size: 12px">Extra Leads</label>
  294.                                                     <input type="number" class="form-control" name="extraLeads" value="{{ realState['extraLeads'] }}">
  295.                                                     <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>
  296.                                                 </div>
  297.                                                 <br><br>
  298.                                                 <div class="float-right">
  299.                                                     <button type="button" class="btn btn-secondary" data-dismiss="modal">Sair</button>
  300.                                                     <button type="submit" class="btn btn-primary">Atualizar</button>
  301.                                                 </div>
  302.                                             </form>
  303.                                         </div>
  304.                                     </div>
  305.                                 </div>
  306.                             </div>
  307.                             {% endif %}
  308.                         {% endfor %}
  309.                         </tbody>
  310.                     </table>
  311.                 </div>
  312.                 <div class="col-12">
  313.                     <h3>Total de Leads Recebidos: <b>{{ totalLeads }}</b></h3>
  314.                 </div>
  315.                 {% for index,realState in obj.getRealStateProductInfo %}
  316.                 <div class="col-12 allCorretoresList" id="corretor-list-{{ realState['id'] }}" style="display: none">
  317.                     <hr>
  318.                     <br>
  319.                     <div class="row">
  320.                         <div class="col-6">
  321.                             <h3> Corretores Ativos - <b>{{ realState['name'] }}</b></h3>
  322.                         </div>
  323.                         {% set lastPosition = 0 %}
  324.                         {% for index,corretor in realState['corretores'] %}
  325.                             {% set lastPosition = index  %}
  326.                         {% endfor %}
  327.                         {% set nextPosition = realState['turn']  %}
  328.                         {% if nextPosition > lastPosition %}
  329.                             {% set nextPosition = 0 %}
  330.                         {% endif %}
  331.                         <div class="col-6 text-right" >
  332.                             <h3> Próximo da fila - (<b>{{ nextPosition + 1 }}</b>)</h3>
  333.                         </div>
  334.                     </div>
  335.                     <table class="table table-striped table-bordered">
  336.                         <thead class="thead-dark">
  337.                         <tr style="font-size: 16px">
  338.                             <th scope="col">Posição na fila</th>
  339.                             <th scope="col">Nome</th>
  340.                             <th scope="col">Email</th>
  341.                             <th scope="col">Qtd Leads Recebidos</th>
  342.                         </tr>
  343.                         </thead>
  344.                         <tbody>
  345.                             {% for index,corretor in realState['corretores'] %}
  346.                                 <tr style="font-size: 16px">
  347.                                     <th scope="row">{{ index + 1 }}</th>
  348.                                     <th scope="row">{{ corretor['name'] }}</th>
  349.                                     <th scope="row">{{ corretor['email'] }}</th>
  350.                                     <th scope="row">{{ corretor['qtdLeads'] }}</th>
  351.                                 </tr>
  352.                             {% endfor %}
  353.                         </tbody>
  354.                     </table>
  355.                 </div>
  356.                 {% endfor %}
  357.             </div>
  358.         </div>
  359.     </div>
  360.     <script>
  361.         let openCorretorList = (realStateId)=>{
  362.             let div = $(`#corretor-list-${realStateId}`)
  363.             let allCorretores = $(`.allCorretoresList`)
  364.             if(div.css('display') === 'none') {
  365.                 allCorretores.css('display', 'none')
  366.                 div.css('display', 'block')
  367.             }else{
  368.                 allCorretores.css('display', 'none')
  369.             }
  370.             const scrollingElement = (document.scrollingElement || document.body);
  371.             scrollingElement.scrollTop = scrollingElement.scrollHeight;
  372.         }
  373.     </script>
  374. {% endblock %}