<?php
        $xcrud = Xcrud::get_instance();  
        $xcrud->table('events');
      //  $xcrud->columns('datum,maincategorie,subcategorie,cost,comment');
        $xcrud->duplicate_button();
        $xcrud->change_type('simple_upload', 'file', '', array('not_rename'=>true, 'path' => '../uploads/events'));
        $xcrud->change_type('image', 'image', false, array(
                                                    'width' => 450,
                                                    'path' => '../uploads/events',
                                                    'thumbs' => array(array(
                                                            'height' => 55,
                                                            'width' => 120,
                                                            'crop' => true,
                                                            'marker' => '_th'))));
        $xcrud->benchmark(true);
    /*    $xcrud->label(array(
            'maincategorie' => 'Főkategória', 
            'subcategorie' => 'Alkategória',
            'datum' => 'Dátum',
            'created' => 'Rögzítve',
            'cost' => 'Költség',
            'comment' => 'Megjegyzés',
        ));
       $xcrud->highlight_row('cost', '<=', -500, '#8DED79');
    $xcrud->highlight('priceEach', '>', -300, '#9ADAFF');
        $xcrud->pass_default('datum', date('Y-m-d'));
        $xcrud->pass_default('created', date('Y-m-d H:i:s'));
       $xcrud->before_list('chart_data', 'functions.php');
        $xcrud->field_callback('maincategorie','cat_input');
        $xcrud->field_callback('subcategorie','cat_input');
       //$grid_data = $xcrud->chart_data( 'functions.php');
        $xcrud->change_type('cost', 'text', '', array('maxlength'=>100));
        $xcrud->before_insert('math_input', 'functions.php');
        $xcrud->before_update('math_input', 'functions.php');
        //$xrcud->before_list_callback($grid_data, $xcrud);
       //print_r($xcrud->result);
        //$xcrud->change_type('created', 'hidden', false);
        $xcrud->sum('cost', 'align-center', 'Total {value}');
        $xcrud->create_action('my_action','my_function'); */
     echo Xcrud::load_css();
        echo Xcrud::load_js();    
    ?>
    <button class="xcrud-action" data-task="action" data-action="my_action">GO!</button> 
    <button onclick="Xcrud.request('.xcrud-ajax',Xcrud.list_data('.xcrud-ajax',{task:'list',primary:270}))">Edit entry </button>

<!-- Resources -->

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.23.0/moment.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.10.0/fullcalendar.js"></script>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.10.0/fullcalendar.min.css" type="text/css" media="all" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.10.0/fullcalendar.print.css" type="text/css" media="all" />

    <script type="text/javascript">
     console.log(''+ JSON.stringify(Xcrud));
jQuery(document).on("xcrudafterrequest",function(event,container){

 
});
</script>

<script>
var chart2 ="";
 $(document).ready(function () {
    $.ajax({ 
     /*   type: 'POST', 
        url: '../demos/ownpages/ajax_fc.php', 
        data: { 
            start: '2017-01-01',
            end: '2018-12-31',
            table: 'ktsgkbank'
        }, 
        dataType: 'json',
        success: function (daata) { 
        // console.log(daata);
            var chart = AmCharts.makeChart( "chartdiv", {
                  "type": "pie",
                  "theme": "none",
                  "dataProvider": daata.pie,
                  "valueField": "loss",
                  "titleField": "cat",
                  "outlineAlpha": 0.1,
                  "depth3D": 15,
                  "balloonText": "[[title]]<br><span style='font-size:14px'><b>[[value]]</b> ([[percents]]%)</span>",
                  "angle": 30,
                  "export": {
                    "enabled": true
                  }
                } );
            var chart3 = AmCharts.makeChart("chartdiv3", {
                "type": "serial",
            	"theme": "none",
                "legend": {
                    "horizontalGap": 10,
                    "maxColumns": 1,
                    "position": "right",
            		"useGraphSettings": true,
            		"markerSize": 10
                },
                "dataProvider":daata.compare.data,
                "valueAxes": [{
                    "stackType": "regular",
                    "axisAlpha": 0.3,
                    "gridAlpha": 0
                }],
                "graphs":daata.compare.graph,
                "categoryField": "type",
                "categoryAxis": {
                    "gridPosition": "start",
                    "axisAlpha": 0,
                    "gridAlpha": 0,
                    "position": "left"
                },
                "export": {
                	"enabled": true
                 }
            
            });
        }*/
      
    }); 
    $('#calendar').fullCalendar({
          header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay,listWeek'
          },
          defaultDate: '2019-01-26',
          navLinks: true, // can click day/week names to navigate views
          editable: true,
          selectable: true,
          eventLimit: true, // allow "more" link when too many events
          events: {
            url: '../demos/ownpages/calendarajax.php',
            error: function() {
              $('#script-warning').show();
            }
          },
          loading: function(bool) {
            $('#loading').toggle(bool);
          },
          eventRender: function(event, el) {
            // render the timezone offset below the event title
            if (event.start.hasZone()) {
              el.find('.fc-title').after(
                $('<div class="tzo"/>').text(event.start.format('Z'))
              );
            }
          },
          dayClick: function(date) {
            console.log('dayClick', date.format());
          },
          select: function(startDate, endDate) {
            console.log('select', startDate.format(), endDate.format());
          }
        });
});

</script>

<div class="row">
    <div class="col-md-12">
        <?echo $xcrud->render();?>
    </div>
    <div class="col-md-12">
        <div id='calendar'></div>
    </div>
  
</div>