codeigniter js ajax загрузить календарь в view_home - PullRequest
0 голосов
/ 11 марта 2019

Эй, ребята, пытаясь загрузить js ajax календарь, все это работает, но когда я пытаюсь загрузить его с моим view_home, чтобы показать боковую панель и все. Календарь просто не показывает. У меня нет никакого опыта в этом, поэтому я не понимаю, в чем проблема. Я считаю, что это что-то простое.

// $ this-> load-> view ('view_home', $ dados); картинка 1 не показывает календарь

введите описание изображения здесь

$ this-> load-> view ('telas / calendar', $ dados); Рисунок 2 показывает календарь и все работы введите описание изображения здесь

CONTROLLER

  `function agenda() {

                            $this->table        = 'calendar';
                            $this->load->model('Globalmodel', 'modeldb'); 


                             $data_calendar = $this->modeldb->get_list($this->table);
                $calendar = array();
                foreach ($data_calendar as $key => $val) 
                {
                    $calendar[] = array(
                                    'id'    => intval($val->id), 
                                    'title' => $val->title, 
                                    'description' => trim($val->description), 
                                    'start' => date_format( date_create($val->start_date) ,"Y-m-d H:i:s"),
                                    'end'   => date_format( date_create($val->end_date) ,"Y-m-d H:i:s"),
                                    'color' => $val->color,
                                    );
                }

                                $dados = array();
                                $dados['get_data']          = json_encode($calendar);


    $dados ['telaativa'] = 'agenda';   esquerda colapsada em agenda 
    $dados ['tela'] = ('calendar');   

                            //  $this->load->view('view_home', $dados);
                             $this->load->view('telas/calendar', $dados); 
             }
`

VIEW_HOME

    `
        <!DOCTYPE html>
        <?php
    if ($this->session->userdata('logged_in')) {

        if (isset($tela)) {
            $tela = $tela;
        } else {
            $tela = 'view_dashboard';
        }
        ?>
        <html>
            <head>
....
            </head>
            <body class="hold-transition skin-blue sidebar-mini">


                    <?php
                    $this->load->view('template/header');
                    $this->load->view('template/topbar');
                    $this->load->view('template/sidebar');
                    $this->load->view('template/configbar');
                    if ($tela != '') {
                        $this->load->view('telas/' . $tela);
                    }
                    $this->load->view('template/footer');
                    $this->load->view('template/controlbar');
                    $this->load->view('template/js');
                    ?>
                    <!-- /.control-sidebar -->
                    <!-- Add the sidebar's background. This div must be placed
                         immediately after the control sidebar -->
                    <div class="control-sidebar-bg"></div>

                <!-- ./wrapper -->

                <!-- jQuery 2.2.3 -->
....
            </body>
        </html>
        <?php
    } else {
        redirect('login');
    }
    ?>
    `

КАЛЕНДАРЬ ПРОСМОТРА

`
<html>

<div class="content-wrapper">
      <!-- Content Header (Page header) -->
      <section class="content-header">
            <h1>
                  Calendar
                  <small>Control panel</small>
            </h1>

            <ol class="breadcrumb">
                  <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
                  <li class="active">Calendar</li>
            </ol>
      </section>

      <!-- Main content --> 

          <section class="content">

            <div class="row">

<!--    <body>-->
<div class="box-body">
 <div class="box box-warning">



        <meta charset="utf-8" />
        <title>TESTE CALENDARIO CODEIGNITER</title>

        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta content="width=device-width, initial-scale=1" name="viewport" />
        <link rel="stylesheet" type="text/css" href="<?php echo base_url().'assets/css/bootstrap.min.css'; ?>">
        <link rel="stylesheet" type="text/css" href="<?php echo base_url().'assets/css/style.css'; ?>">
        <link rel="stylesheet" type="text/css" href="<?php echo base_url().'assets/font-awesome/css/font-awesome.min.css'; ?>">
        <link rel="stylesheet" type="text/css" href="<?php echo base_url().'assets/plugins/fullcalendar/fullcalendar.css'; ?>">
        <link rel="stylesheet" type="text/css" href="<?php echo base_url().'assets/plugins/bootstrap-datepicker/css/bootstrap-datepicker3.min.css'; ?>">



    <div class="container">

     <!--   <div class="page-content-wrapper">-->
            <div class="page-content">

                <div class="alert notification" style="display: none;">
                    <button class="close" data-close="alert"></button>
                    <p></p>
                </div>

                <div class="row">
                    <div class="col-md-6">


                        <div class="portlet light bordered">
                            <div class="portlet-body">
                                <div class="table-toolbar">
                                    <div class="row">
                                        <div class="col-md-3">
                                            <div class="btn-group">
                                                <a href="#" class="btn btn-primary add_calendar"> ADD NEW EVENT
                                                    <i class="fa fa-plus"></i>
                                                </a>
                                                <br>
                                                <br>
                                            </div>
                                        </div>
                                    </div>
                                </div>


                                <!-- place -->

                                <div class="box-body">



                                <div id="calendarIO"></div>

                                </div>
                                </div>

                                <div class="modal fade" id="create_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                                    <div class="modal-dialog" role="document">

                                        <div class="modal-content">
                                            <form class="form-horizontal" method="POST" action="POST" id="form_create">
                                                <input type="hidden" name="calendar_id" value="0">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                      <span aria-hidden="true">&times;</span>
                                                    </button>
                                                    <h4 class="modal-title" id="myModalLabel">Inserir evento</h4>
                                                </div>
                                                <div class="modal-body">

                                                    <div class="form-group">
                                                         <div class="alert alert-danger" style="display: none;"></div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="control-label col-sm-2">Titulo  <span class="required"> * </span></label>
                                                        <div class="col-sm-10">
                                                            <input type="text" name="title" class="form-control" placeholder="Titulo">
                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="control-label col-sm-2">Descrição</label>
                                                        <div class="col-sm-10">
                                                            <textarea name="description" rows="3" class="form-control"  placeholder="Inserir descrição"></textarea>
                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label for="color" class="col-sm-2 control-label">Cor</label>
                                                        <div class="col-sm-10">
                                                            <select name="color" class="form-control">
                                                                <option value="">Escolher</option>
                                                                <option style="color:#0071c5;" value="#0071c5">&#9724; Azul escuro</option>
                                                                <option style="color:#40E0D0;" value="#40E0D0">&#9724; Azul claro</option>
                                                                <option style="color:#008000;" value="#008000">&#9724; Verde</option>                       
                                                                <option style="color:#FFD700;" value="#FFD700">&#9724; Amarelo</option>
                                                                <option style="color:#FF8C00;" value="#FF8C00">&#9724; Laranja</option>
                                                                <option style="color:#FF0000;" value="#FF0000">&#9724; Vermelho</option>
                                                                <option style="color:#000;" value="#000">&#9724; Preto</option>
                                                            </select>
                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="control-label col-sm-2">Data inicio</label>
                                                        <div class="col-sm-10">
                                                            <div class="input-group input-medium date date-picker" data-date-format="yyyy-mm-dd" data-date-viewmode="years">
                                                                <input type="text" name="start_date" class="form-control" readonly>
                                                                <span class="input-group-addon"><i class="fa fa-calendar font-dark"></i></span>
                                                            </div>
                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="control-label col-sm-2">Data fim</label>
                                                        <div class="col-sm-10">
                                                            <div class="input-group input-medium date date-picker" data-date-format="yyyy-mm-dd" data-date-viewmode="years">
                                                                <input type="text" name="end_date" class="form-control" readonly>
                                                                <span class="input-group-addon"><i class="fa fa-calendar font-dark"></i></span>
                                                            </div>
                                                        </div>
                                                    </div>

                                                </div>
                                                <div class="modal-footer">
                                                    <a href="javascript::void" class="btn default" data-dismiss="modal">Cancelar</a>
                                                    <a class="btn btn-danger delete_calendar" style="display: none;">Apagar</a>
                                                    <button type="submit" class="btn green">Inserir</button>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                </div>

                                <!-- end place -->
                            </div>
                       </div>

                    </div>
                </div>
            </div>
       <!-- </div>-->
    </div>

                   </div>
                                   </div>
            <!-- /.row -->

<!--       </body>-->


          </section>

          </div>


    <script type="text/javascript" src="<?php echo base_url().'assets/js/jquery.min.js'; ?>"></script>      
    <script type="text/javascript" src="<?php echo base_url().'assets/js/moment.min.js'; ?>"></script>      
    <script type="text/javascript" src="<?php echo base_url().'assets/js/bootstrap.min.js'; ?>"></script>      
    <script type="text/javascript" src="<?php echo base_url().'assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.min.js'; ?>"></script>      
    <script type="text/javascript" src="<?php echo base_url().'assets/plugins/fullcalendar/fullcalendar.js'; ?>"></script>   
    <script type="text/javascript" src="<?php echo base_url().'assets/plugins/fullcalendar/locale/pt.js'; ?>"></script>
    <script type="text/javascript">
        var get_data        = '<?php echo $get_data; ?>';
        var backend_url     = '<?php echo base_url(); ?>';
        var base_url = '<?php echo base_url() ?>';


            function buscaInfo(perfil){
        var perfil = perfil;
        var url = base_url + "home/buscausuarioperfil";
        $.post(url, {
            perfil: perfil
        }, function (data) {
            $('#resultado').html(data);
        });
    }

        $(document).ready(function() {
            $('.date-picker').datepicker();
            $('#calendarIO').fullCalendar({
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,basicWeek,basicDay'
                },
                defaultDate: moment().format('YYYY-MM-DD'),
                editable: true,
                eventLimit: true, // allow "more" link when too many events
                selectable: true,
                selectHelper: true,
                select: function(start, end) {
                    $('#create_modal input[name=start_date]').val(moment(start).format('YYYY-MM-DD'));
                    $('#create_modal input[name=end_date]').val(moment(end).format('YYYY-MM-DD'));
                    $('#create_modal').modal('show');
                    save();
                    $('#calendarIO').fullCalendar('unselect');
                },
                eventDrop: function(event, delta, revertFunc) { // si changement de position
                    editDropResize(event);
                },
                eventResize: function(event,dayDelta,minuteDelta,revertFunc) { // si changement de longueur
                    editDropResize(event);
                },
                eventClick: function(event, element)
                {
                    deteil(event);
                    editData(event);
                    deleteData(event);
                },
                events: JSON.parse(get_data)
            });
        });

        $(document).on('click', '.add_calendar', function(){
            $('#create_modal input[name=calendar_id]').val(0);
            $('#create_modal').modal('show');  
        })

        $(document).on('submit', '#form_create', function(){

            var element = $(this);
            var eventData;
            $.ajax({
                url     : backend_url+'Home/save',
                type    : element.attr('method'),
                data    : element.serialize(),
                dataType: 'JSON',
                beforeSend: function()
                {
                    element.find('button[type=submit]').html('<i class="fa fa-spinner fa-spin" aria-hidden="true"></i>');
                },
                success: function(data)
                {
                    if(data.status)
                    {   
                        eventData = {
                            id          : data.id,
                            title       : $('#create_modal input[name=title]').val(),
                            description : $('#create_modal textarea[name=description]').val(),
                            start       : moment($('#create_modal input[name=start_date]').val()).format('YYYY-MM-DD HH:mm:ss'),
                            end         : moment($('#create_modal input[name=end_date]').val()).format('YYYY-MM-DD HH:mm:ss'),
                            color       : $('#create_modal select[name=color]').val()
                        };
                        $('#calendarIO').fullCalendar('renderEvent', eventData, true); // stick? = true
                        $('#create_modal').modal('hide');
                        element[0].reset();
                        $('.notification').removeClass('alert-danger').addClass('alert-primary').find('p').html(data.notif);
                    }
                    else
                    {
                        element.find('.alert').css('display', 'block');
                        element.find('.alert').html(data.notif);
                    }
                    element.find('button[type=submit]').html('Submit');
                },
                error: function (jqXHR, textStatus, errorThrown)
                {
                    element.find('button[type=submit]').html('Submit');
                    element.find('.alert').css('display', 'block');
                    element.find('.alert').html('Wrong server, please save again');
                }         
            });
            return false;
        })

        function editDropResize(event)
        {
            start = event.start.format('YYYY-MM-DD HH:mm:ss');
            if(event.end)
            {
                end = event.end.format('YYYY-MM-DD HH:mm:ss');
            }
            else
            {
                end = start;
            }

            $.ajax({
                url     : backend_url+'Home/save',
                type    : 'POST',
                data    : 'calendar_id='+event.id+'&title='+event.title+'&start_date='+start+'&end_date='+end,
                dataType: 'JSON',
                beforeSend: function()
                {
                },
                success: function(data)
                {
                    if(data.status)
                    {   
                        $('.notification').removeClass('alert-danger').addClass('alert-primary').find('p').html('Data success update');
                    }
                    else
                    {
                        $('.notification').removeClass('alert-primary').addClass('alert-danger').find('p').html('Data cant update');
                    }

                },
                error: function (jqXHR, textStatus, errorThrown)
                {
                    $('.notification').removeClass('alert-primary').addClass('alert-danger').find('p').html('Wrong server, please save again');
                }         
            });
        }



        function deteil(event)
        {
            $('#create_modal input[name=calendar_id]').val(event.id);
            $('#create_modal input[name=start_date]').val(moment(event.start).format('YYYY-MM-DD'));
            $('#create_modal input[name=end_date]').val(moment(event.end).format('YYYY-MM-DD'));
            $('#create_modal input[name=title]').val(event.title);
            $('#create_modal input[name=description]').val(event.description);
            $('#create_modal select[name=color]').val(event.color);
            $('#create_modal .delete_calendar').show();
            $('#create_modal').modal('show');
        }



    </script>

</html>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...