public function formatData($data) { $date = \Zend_Date::now(); $timestart = new \Zend_Date($data['calendar'] . ' ' . $data['slotinput'] . ':00', 'dd-MM-YYYY HH:mm:ss'); //$timestart = \Zend_Date::now(); $location = \Object\Location::getById($data['locationid'], 1); if ($location instanceof \Object\Location) { $societe = $location->getSociete(); $serving = \Object\Serving::getById($data['servinginput'], 1); if ($serving instanceof \Object\Serving) { $mealduration = $serving->getMealduration(); } $end = $timestart->getTimestamp() + $mealduration * 60; $timeend = new \Zend_Date($end); $guest = \Object\Guest::getByEmail($data['email'], 1); if (!$guest instanceof \Object\Guest) { $guest = new \Object\Guest(); $guest->updateData(array('tel' => $data['tel'], 'email' => $data['email'], 'lastname' => $data['lastname'], 'societe' => $societe, 'dateregister' => $date, 'location' => $location)); } } $result = array(); $result['id'] = $data['id']; $result['method'] = $data['method']; $result['tel'] = $data['tel']; $result['email'] = $data['email']; $result['lastname'] = $data['lastname']; $result['partysize'] = $data['partysize']; $result['person'] = $data['person']; $result['societe'] = $societe; $result['location'] = $location; $result['guest'] = $guest; $result['serving'] = $serving; $result['start'] = $timestart; $result['datereservation'] = $timestart; $result['end'] = $timeend; return $result; }