if (isset($_POST[$day . 'opentime'])) { $opentime = $_POST[$day . 'opentime']; } if (isset($_POST[$day . 'closetime'])) { $closetime = $_POST[$day . 'closetime']; } try { $bhourday = $location->getBusinessHourByDay($day); if (count($bhourday) == 0) { $bhour = new BusinessHour(); $bhour->setProperty('locationid', $locationid); $bhour->setProperty('day', $day); $bhour->setProperty('dataowneruserid', $dataowneruserid); } else { $bhourid = $bhourday[0]['id']; $bhour = BusinessHour::get($bhourid, $userid); } $bhour->setProperty('opentime', $opentime); $bhour->setProperty('closetime', $closetime); $bhour->setProperty('datachangebyuserid', $userid); $bhour->setProperty('isclosed', Database::DBFALSE); if (empty($opentime) || empty($closetime)) { $bhour->setProperty('opentime', ''); $bhour->setProperty('closetime', ''); $bhour->setProperty('isclosed', Database::DBTRUE); } $bhour->save(); } catch (Exception $e) { $errormessage = $e->getMessage(); trigger_error($errormessage, E_USER_WARNING); $formmessage = $errormessage;
if (!isset($_POST['responseuri'])) { header("Location: restaurants"); exit; } $responseuri = $_POST['responseuri']; if (!isset($_POST['id'])) { header("Location: restaurants"); exit; } $locationid = $_POST['id']; try { $location = Location::get($locationid, $userid); $locationname = $location->getProperty('name'); $bhours = $location->getHours(); foreach ($bhours as $bhourrow) { BusinessHour::deleteBusinessHour($bhourrow['id'], $userid); } $contactinfo = $location->getContactInfo(); foreach ($contactinfo as $cirow) { ContactInfo::deleteInfo($cirow['id'], $userid); } Location::deleteLocation($locationid, $userid); $formmessage = 'Location "' . $locationname . '" deleted.'; $formmessageclass = 'green'; break; } catch (Exception $e) { $formmessage = $e->getMessage(); trigger_error($formmessage); $formmessageclass = 'red'; break; }