newEventQuery();
$query->setUser('default');
// Set to $query->setVisibility('private-magicCookieValue') if using
// MagicCookie auth
$query->setVisibility('private');
$query->setProjection('full');
$query->setOrderby('starttime');
$query->setFutureevents('false');
// Retrieve the event list from the calendar server
try {
$eventFeed = $service->getCalendarEventFeed($query);
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getMessage();
}
// Iterate through the list of events, outputting them as an HTML list
echo "
";
foreach ($eventFeed as $event) {
$g=mysql_num_rows(mysql_query("select id from tasks where google_calendar_task='".$event->id."' and assigned_user_id='2e72f487-d92b-954e-f50c-528b10ce81c9'"));
//echo $event->when[0];
$a=str_replace(" ",",",$event->when[0]);
$a=explode(",",$a);
list($month, $day0,$day1,$year1,$year2, $g1,$g2,$m1,$m2,$s1,$s2,$st,$st2,) = sscanf($a[1], "%d-%c%c-%c%cT%c%c:%c%c:%c%c+%d:%d Ends: %d-%c%c-%c%cT%c%c:%c%c:%c%c+%d:%d");
$date_start=$month.'-'.$day0.''.$day1.'-'.$year1.''.$year2.' '.$g1.''.$g2.':'.$m1.''.$m2.':'.$s1.''.$s2;
list($month, $day0,$day1,$year1,$year2, $g1,$g2,$m1,$m2,$s1,$s2,$st,$st2) = sscanf($a[3], "%d-%c%c-%c%cT%c%c:%c%c:%c%c+%d:%d");
$date_duo=$month.'-'.$day0.''.$day1.'-'.$year1.''.$year2.' '.$g1.''.$g2.':'.$m1.''.$m2.':'.$s1.''.$s2;
//echo $date_duo;
$date1 = new DateTime($date_duo);
$date2 = new DateTime(date("Y-m-d H:i:s"));
if($date1 > $date2){
$status='planned';
} else {
$status='made';
}
if($g==0){
echo "INSERT INTO `crm`.`tasks`
(`id`,
`name`,
`date_entered`,
`date_modified`,
`modified_user_id`,
`created_by`,
`description`,
`deleted`,
`assigned_user_id`,
`status`,
`date_due_flag`,
`date_due`,
`date_start_flag`,
`date_start`,
`parent_type`,
`parent_id`,
`contact_id`,
`priority`,
`project_id`,
`project_name`,
`project_task_id`,
`project_task_name`,
`google_calendar_task`,
`assigned_user_id2`)
VALUES
('".create_guid()."',
'".$event->title."',
'".date("Y-m-d H:i:s")."',
'".date("Y-m-d H:i:s")."',
'".$p['id']."',
'".$p['id']."',
'".$event->content."',
'0',
'".$p['id']."',
'".$status."',
'0',
'".$date_duo."',
'0',
'".$date_start."',
'null',
null,
null,
'Medium',
null,
null,
null,
null,
'".$event->id,"',
null);
";
}
// echo "- " . $event->title . " (Event ID: " . $event->id . ")Gdzie: ".implode($event->where)." Kiedy : ".implode($event->when)."
";
}
echo "
";
}
}