<?php
global $conn;

/* Session variable
$_SESSION['project_id']
$_SESSION['project_name']
$_SESSION['option_calendar'] valor:  project | user | company | departament | meeting
$_SESSION['language']
$_SESSION['user_id']
$_SESSION['login'] 
$_SESSION['email'] 
$_SESSION['username']
$_SESSION['company_id']
$_SESSION['dept_id']
 * ----------Currently unused ------------------
$_SESSION['nav_start'];
$_SESSION['nav_end']
 * ----------------------------------------------
 */

// $site       = $_SESSION['config'][array_search('URL', array_column($_SESSION['config'], 'name'))][value].'/';
// $ajax_mes   = $_SESSION['config'][array_search('MEETINGS_AJAX', array_column($_SESSION['config'], 'name'))][value].'?';

if ($_SESSION['language'] == 'Spanish') {
    $language = 'es'; // Spanish
} else {
    $language = 'en'; // English
}
$now = substr(now(),0,10);

$str1 = <<<EOD
 <style>
    html, body {
      margin: 0;
      padding: 0;
      font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
      font-size: 14px;
    }
    #calendar {
      max-width: 900px;
      margin: 40px auto;
    }
  </style>

<meta charset='utf-8' />
<link href='fullcalendar/packages/core/main.css' rel='stylesheet' />
<link href='fullcalendar/packages/daygrid/main.css' rel='stylesheet' />
<link href='fullcalendar/packages/timegrid/main.css' rel='stylesheet' />
<link href='fullcalendar/packages/list/main.css' rel='stylesheet' />
<script src='fullcalendar/packages/core/main.js'></script>
<script src='fullcalendar/packages/interaction/main.js'></script>
<script src='fullcalendar/packages/daygrid/main.js'></script>
<script src='fullcalendar/packages/timegrid/main.js'></script>
<script src='fullcalendar/packages/list/main.js'></script>

<script src='fullcalendar/packages/core/locales-all.min.js'></script>

<script>
    var initialLocaleCode = '$language';
    
    document.addEventListener('DOMContentLoaded', function() {
    var calendarEl = document.getElementById('calendar');

    var calendar = new FullCalendar.Calendar(calendarEl, {
      plugins: ['interaction', 'dayGrid', 'timeGrid', 'list' ],
      header: {
        left: 'prev,next today',
        center: 'title',
        right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
      },
      // defaultView: 'dayGridMonth',
      defaultDate: '$now',
      timeZone: 'UTC', // the default 'local' (unnecessary to specify)
      locale: initialLocaleCode,
      businessHours: {
	// days of week. an array of zero-based day of week integers (0=Sunday)
	daysOfWeek: [ 1, 2, 3, 4, 5 ], // Monday - Thursday
	startTime: '08:00', // a start time (08am in this example)
	endTime: '18:00', // an end time (6pm in this example)
        },
        
      weekNumbers: true,
      weekNumbersWithinDays: true,
      weekNumberCalculation: 'ISO',
      
      editable: true,
      navLinks: true, // can click day/week names to navigate views
      eventLimit: true, // allow "more" link when too many events
      
      eventClick: function(info) {
	// alert('Event: ' + info.event.title + '\\n' + info.event.id + '...' + info.event.extendedProps.description );
	// console.log(info);
	// alert('Coordinates: ' + info.jsEvent.pageX + ',' + info.jsEvent.pageY);
	// alert('View: ' + info.view.type);
	// change the border color just for fun
	// info.el.style.borderColor = 'red';
				var meeting = info.event.id;
				var url = "calendar_view.php?editid1="+meeting;
				var header = '<h2 data-itemtype="view_header" data-itemid="view_header" data-pageid="10">'+'Meeting: '+ meeting+'</h2>' ;
				window.popup = Runner.displayPopup({
                    url: url,
                    width: 800,
                    height: 550,
                    header: header
		});
	},

      events: {
        url: 'calendar_ajax.php'
      }
        
    });
    calendar.render();
  });

</script>
  <div id='calendar'></div>

EOD;

echo $str1;


?>