/**
  * Given an array of shifts, return xml formatted the way the monthly.js plugin
  * needs it
  *
  * @var array $shifts
  * @return formatetd xml
  *
  * @todo this bit of business logic really probably ought to go elsewhere, but
  * I don't understand laravel 5 well enough yet to know exactly where
  */
 protected function getScheduleXml($shifts)
 {
     $scheduleXml = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><monthly/>');
     foreach ($shifts as $shift) {
         // get the employee who is scheduled for this shift
         $employee = User::find($shift->employee_id);
         $name = $employee ? $employee->name : "Open shift";
         $color = $employee ? $employee->color : "grey";
         $url = $employee ? "/contact/" . $employee->id : "";
         $shiftXml = $scheduleXml->addChild('event');
         $shiftXml->addChild('id', $shift->id);
         $shiftXml->addChild('name', $name);
         $shiftXml->addChild('startdate', $shift->start_time->format("Y-m-d"));
         $shiftXml->addChild('enddate', $shift->end_time->format("Y-m-d"));
         $shiftXml->addChild('starttime', $shift->start_time->format("H:i"));
         $shiftXml->addChild('endtime', $shift->end_time->format("H:i"));
         $shiftXml->addChild('color', $color);
         $shiftXml->addChild('url', $url);
     }
     return $scheduleXml->asXML();
 }