<?php

//appt types
$ar_res = array();
$sql = "SELECT id FROM mgw_calendar_appt_type WHERE 1";
if(!$res = $conn->Execute($sql)) exit(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__));
while($row=$res->FetchRow()){$ar_res[]=$row["id"];}

if (!in_array('0',$ar_res)) {
	$sql = "INSERT INTO mgw_calendar_appt_type (id, type, color) VALUES (0, 'meeting', '#CDF5F5')";
	if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
}

if (!in_array('1',$ar_res)) {
	$sql = "INSERT INTO mgw_calendar_appt_type (id, type, color) VALUES (1, 'appointment', '#CDB9F5')";
	if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
}

if (!in_array('3',$ar_res)) {
	$sql = "INSERT INTO mgw_calendar_appt_type (id, type, color) VALUES (3, 'formation', '#CDB985')";
	if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
}

if (!in_array('4',$ar_res)) {
	$sql = "INSERT INTO mgw_calendar_appt_type (id, type, color) VALUES (4, 'rest', '#c0c0c0')";
	if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
}


//appt classes
$ar_res = array();
$sql = "SELECT id FROM mgw_calendar_class WHERE 1";
if(!$res = $conn->Execute($sql)) exit(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__));
while($row=$res->FetchRow()){$ar_res[]=$row["id"];}

if (!in_array('0',$ar_res)) {
	$sql = "INSERT INTO mgw_calendar_class (id, class, color) VALUES (0, 'subjected', '#FF5D5D')";
	if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
}

if (!in_array('1',$ar_res)) {
	$sql = "INSERT INTO mgw_calendar_class (id, class, color) VALUES (1, 'standby', '#FFC371')";
	if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
}

if (!in_array('2',$ar_res)) {
	$sql = "INSERT INTO mgw_calendar_class (id, class, color) VALUES (2, 'validated', '#0A9B0A')";
	if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
}

if (!in_array('3',$ar_res)) {
	$sql = "INSERT INTO mgw_calendar_class (id, class, color) VALUES (3, 'aborted', '#888888')";
	if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
}


//location types
$ar_res = array();
$sql = "SELECT id FROM mgw_calendar_location_type WHERE 1";
if(!$res = $conn->Execute($sql)) exit(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__));
while($row=$res->FetchRow()){$ar_res[]=$row["id"];}

if (!in_array('0',$ar_res)) {
	$sql = "INSERT INTO mgw_calendar_location_type (id, location_type) VALUES (0, 'in-house')";
	if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
}

if (!in_array('1',$ar_res)) {
	$sql = "INSERT INTO mgw_calendar_location_type (id, location_type) VALUES (1, 'outside')";
	if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
}


//scheduling types
$ar_res = array();
$sql = "SELECT id FROM mgw_calendar_scheduling_type WHERE 1";
if(!$res = $conn->Execute($sql)) exit(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__));
while($row=$res->FetchRow()){$ar_res[]=$row["id"];}

if (!in_array('0',$ar_res)) {
	$sql = "INSERT INTO mgw_calendar_scheduling_type (id, type) VALUES (0, 'time')";
	if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
}

if (!in_array('1',$ar_res)) {
	$sql = "INSERT INTO mgw_calendar_scheduling_type (id, type) VALUES (1, 'morning')";
	if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
}

if (!in_array('2',$ar_res)) {
	$sql = "INSERT INTO mgw_calendar_scheduling_type (id, type) VALUES (2, 'afternoon')";
	if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
}

if (!in_array('3',$ar_res)) {
	$sql = "INSERT INTO mgw_calendar_scheduling_type (id, type) VALUES (3, 'wholeday')";
	if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
}

?>