Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 7199 | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

<?php

$routeEvents = $this->url('calendar/events');
$routeNextEvents = $this->url('helpers/next-events');


$this->inlineScript()->appendFile($this->basePath('vendors/moment/moment-with-locales.js'));

$this->inlineScript()->appendFile($this->basePath('vendors/nprogress/nprogress.js'));
$this->headLink()->appendStylesheet($this->basePath('vendors/nprogress/nprogress.css'));

$this->headLink()->appendStylesheet($this->basePath('vendors/fullcalendar/fullcalendar.css'));
//$this->headLink()->appendStylesheet($this->basePath('vendors/fullcalendar-scheduler/dist/scheduler.css'));
//$this->headLink()->appendStylesheet($this->basePath('vendors/iCheck/skins/flat/green.css'));


$this->inlineScript()->appendFile($this->basePath('vendors/fullcalendar/lib/moment.min.js'));
$this->inlineScript()->appendFile($this->basePath('vendors/fullcalendar/fullcalendar.js'));
$this->inlineScript()->appendFile($this->basePath('vendors/fullcalendar/locale/es-us.js'));
//$this->inlineScript()->appendFile($this->basePath('vendors/fullcalendar-scheduler/dist/scheduler.js'));
//$this->inlineScript()->appendFile($this->basePath('vendors/iCheck/icheck.min.js'));
$this->inlineScript()->appendFile($this->basePath('vendors/popper/umd/popper.js'));

$this->inlineScript()->appendFile($this->basePath('vendors/jsrender/jsrender.js'));


$defaultDate = date('Y-m-d');

$this->inlineScript()->captureStart();
echo <<<JS
jQuery( document ).ready(function( $ ) {

    var data_resources  = new Array();
    var data_events = new Array();

    $.fn.reloadHelper = function() {


        NProgress.start();
        $.ajax({
            'dataType'  : 'json',
            'method'    : 'get',
            'url'       :  '$routeNextEvents',
            'data'      :  {
                t : moment().unix()
            },
        }).done(function(response) {
            if(response['success']) {
                $('#containerNextEvents').html( 
                    $('#templateNextEvents').render(response['data'])
                );
            } else {
                $.fn.showError(response['data']);
            }
        }).fail(function( jqXHR, textStatus, errorThrown) {
            $.fn.showError(textStatus);
        }).always(function() {
            NProgress.done();
        });     
    }

    $.fn.openBackend = function(url) {
        NProgress.start();
        $.ajax({
            'dataType'  : 'json',
            'method'    : 'get',
            'url'       :  url,
            'data'      :  $('#form').serialize(),
        }).done(function(response) {
            if(response['success']) {
              window.open(response['data'], '_backend')
            } else {
                $.fn.showError(response['data']);
            }
        }).fail(function( jqXHR, textStatus, errorThrown) {
            $.fn.showError(textStatus);
        }).always(function() {
            NProgress.done();
        });

    } 

    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay,listWeek'
          },
          defaultDate: '$defaultDate',
          editable: true,
          navLinks: true, // can click day/week names to navigate views
          eventLimit: true, // allow "more" link when too many events
          events: {
            url: '$routeEvents',
            error: function() {
              $('#script-warning').show();
            }
          },
          eventClick: function(event) {
            if (event.url) {
                setTimeout(() => {
                  $.fn.openBackend(event.url)
                }, 200);
                return false;
            }
          },
          eventRender: function(eventObj, \$el) {
            $('.popover').remove();
            \$el.popover({
                title: eventObj.title,
                content: eventObj.agenda,
                trigger: 'click', //'hover',
                placement: 'top',
                container: 'body',
                popperOptions : {
                    removeOnDestroy: true
                },  
                options : {
                    removeOnDestroy: true
                },  
                 html: true
            });
        },

    });

    $('body').on('click', 'a.goto-backend', function(e) {
        e.preventDefault();
        var action = $(this).attr('href');
        if(action) {
            $.fn.openBackend(action)
    }
    });

     $.fn.reloadHelper();

    

});
JS;
$this->inlineScript()->captureEnd();

$this->headLink()->appendStylesheet('/css/calendar.css');
$this->headLink()->appendStylesheet('/look-and-field/calendar.css');

?>
<section class="info-page">
        <div class="container">
                <div class="row">
                        <div id="calendar" class="col-12 col-md-8"></div>
                        
                        <div id="calendar-events" class="col-12 col-md-4">
                                <div class="task-widget">
                                        <div class="sd-title d-flex align-items-center justify-content-between"
                                                ><h3>Eventos y Tareas</h3>
                                        </div>
                                        <div id="containerNextEvents" class="d-flex flex-column" style="gap: 0.5rem; max-height: 500px; overflow: hidden scroll;">
                                                
                                        </div>
                                </div>  
                        </div>
                </div>
        </div>
</section>

<script id="templateNextEvents" type="text/x-jsrender">
    <a href="{{:url}}"  class="goto-backend" rel="noreferrer">
           <div class="calendar-event" style="{{:textColor}}; background: {{:backgroundColor}}">
               <h4><b>LABEL_EVENT: </b> {{:title}}</h4><span><b>LABEL_START: </b>{{:start}}</span>
           </div>
    </a>
</script>