protected function getDateTime() { $date = $this->date; $time = $this->time; $ret = new DateTime(SLN_Func::filter($date, 'date') . ' ' . SLN_Func::filter($time, 'time')); return $ret; }
public static function processRequest($postType, $fieldList) { foreach ($fieldList as $k => $v) { $field = self::getFieldName($postType, $k); $meta[$field] = SLN_Func::filter($_POST[$field], $v); } return $meta; }
protected function bindValues($values) { $bb = $this->getPlugin()->getBookingBuilder(); $fields = array('firstname' => '', 'lastname' => '', 'email' => '', 'phone' => '', 'address' => ''); foreach ($fields as $field => $filter) { $data = isset($values[$field]) ? $values[$field] : ''; $bb->set($field, SLN_Func::filter($data, $filter)); } $bb->save(); }
/** * @param $this SLN_Admin_Settings */ function sln_availability_row($prefix, $row) { ?> <div class="col-md-12"> <div class="first-row"> <?php foreach (SLN_Func::getDays() as $k => $day) { ?> <div class="form-group"> <label> <?php SLN_Form::fieldCheckbox($prefix . "[days][{$k}]", isset($row['days'][$k]) ? 1 : null); ?> <?php echo substr($day, 0, 3); ?> </label> </div> <?php } ?> </div> <div class="second-row"> <?php foreach (array(0, 1) as $i) { ?> <?php foreach (array('from' => __('From', 'sln'), 'to' => __('To', 'sln')) as $k => $v) { ?> <div class="form-group"> <label for="<?php echo SLN_Form::makeID($prefix . "[{$k}][{$i}]"); ?> "> <?php echo $v; ?> </label> <?php SLN_Form::fieldTime($prefix . "[{$k}][{$i}]", $row[$k][$i]); ?> </div> <?php } ?> <?php } ?> </div> </div> <?php }
public function __toString() { $days = SLN_Func::getDays(); $ret = array(); foreach ($this->data['days'] as $d => $v) { $ret[] = $days[$d]; } $ret = implode('-', $ret); foreach ($this->times as $t) { $ret .= sprintf(' %s/%s', $t[0], $t[1]); } return $ret; }
protected function dispatchForm() { $bb = $this->getPlugin()->getBookingBuilder(); $values = isset($_POST['sln']) ? $_POST['sln'] : array(); if (!$bb->getLastBooking()) { $bb->set('note', SLN_Func::filter($values['note'])); $bb->create(); if ($this->getPlugin()->getSettings()->get('confirmation')) { $this->getPlugin()->sendMail('mail/summary', array('booking' => $bb->getLastBooking())); $this->getPlugin()->sendMail('mail/summary_admin', array('booking' => $bb->getLastBooking())); } } return true; }
public function getTimes($date) { $ret = array(); $avItems = $this->getItems(); $hb = $this->getHoursBeforeHelper(); foreach (SLN_Func::getMinutesIntervals() as $time) { $d = new DateTime($date->format('Y-m-d') . ' ' . $time); if ($avItems->isValidDatetime($d) && $this->isValidDate($d) && $this->isValidTime($d)) { $ret[$time] = $time; } } SLN_Plugin::addLog(__CLASS__ . ' getTimes ' . print_r($ret, true)); return $ret; }
public function manage_column($column, $post_id) { switch ($column) { case 'booking_status': echo SLN_Enum_BookingStatus::getLabel(get_post_meta($post_id, '_sln_booking_status', true)); break; case 'service_duration': $time = SLN_Func::filter(get_post_meta($post_id, '_sln_service_duration', true), 'time'); echo $time ? $time : '-'; break; case 'service_price': echo $this->getPlugin()->format()->money(get_post_meta($post_id, '_sln_service_price', true)); break; } }
protected function dispatchForm() { $bb = $this->getPlugin()->getBookingBuilder(); $values = $_POST['sln']; $date = SLN_Func::filter($values['date'], 'date'); $time = SLN_Func::filter($values['time'], 'time'); $bb->removeLastID()->setDate($date)->setTime($time); $obj = new SLN_Action_Ajax_CheckDate($this->getPlugin()); $obj->setDate($date)->setTime($time)->execute(); foreach ($obj->getErrors() as $err) { $this->addError($err); } if (!$this->getErrors()) { $bb->save(); return true; } }
public function getNotAvailableString() { foreach (SLN_Func::getDays() as $k => $day) { if ($this->getNotAvailableOn($k)) { $ret[] = $day; } } $ret = $ret ? __('on ', 'sln') . implode(', ', $ret) : ''; $from = $this->getNotAvailableFrom()->format('H:i'); $to = $this->getNotAvailableTo()->format('H:i'); if ($from != '00:00') { $ret .= __(' from ', 'sln') . $from; } if ($to != '00:00') { $ret .= __(' to ', 'sln') . $to; } return $ret; }
public function getUrl($id, $amount, $title) { $settings = $this->plugin->getSettings(); $url = SLN_Func::currPageUrl(); return $this->getBaseUrl() . "?" . http_build_query(array('notify_url' => add_query_arg('op', 'notify-' . $id, $url), 'return' => add_query_arg('op', 'success-' . $id, $url), 'cancel_return' => add_query_arg('op', 'cancel-' . $id, $url), 'cmd' => '_xclick', 'business' => $settings->getPaypalEmail(), 'currency_code' => $settings->getCurrency(), 'amount' => $amount, 'item_name' => $title)); }
public function getTotal() { $ret = 0; foreach ($this->getServices() as $s) { $ret = $ret + SLN_Func::filter($s->getPrice(), 'float'); } return $ret; }
public static function evalPickedDate($date) { $date = explode(' ', $date); foreach (SLN_Func::getMonths() as $k => $v) { if (strcasecmp($date[1], $v) == 0) { $ret = $date[2] . '-' . ($k < 10 ? '0' . $k : $k) . '-' . $date[0]; return $ret; } } throw new Exception('wrong date'); }
function getEndsAt() { $start = $this->getStartsAt(); //SLN_Plugin::addLog($this->getId().' duration '.$this->getDuration()->format('H:i')); $minutes = SLN_Func::getMinutesFromDuration($this->getDuration()); //SLN_Plugin::addLog($this->getId().' duration '.$minutes.' minutes'); if ($minutes == 0) { $minutes = 60; } $start->modify('+' . $minutes . ' minutes'); return $start; }
SLN_Form::fieldCheckbox($helper->getFieldName($postType, 'secondary'), $service->isSecondary()); ?> <br/><em><?php _e('Select this if you want this service considered as secondary level service', 'sln'); ?> </em> </div> </div> <div class="sln-clear"></div> </div> <h3><?php _e('Not available on', 'sln'); ?> </h3> <?php $days = SLN_Func::getDays(); ?> <div class="row"> <div class="col-md-12 services-notavailable"> <?php foreach ($days as $k => $day) { ?> <label> <?php SLN_Form::fieldCheckbox($helper->getFieldName($postType, 'notav_' . $k), $service->getNotAvailableOn($k)); ?> <?php echo substr($day, 0, 3); ?> </label> <?php
public static function fieldYear($name, $value, $settings = array()) { if ($value instanceof DateTime) { $value = $value->format('Y'); } $currY = date('Y'); self::fieldSelect($name, isset($settings['years']) ? $settings['years'] : SLN_Func::getYears($value < $currY ? $value : $currY - 1), $value, $settings); }
private function bindDates($dates) { $this->years = array(); $this->months = array(); $this->days = array(); $checkDay = $this->suggestedDate->format('Y-m-'); $checkMonth = $this->suggestedDate->format('Y-'); foreach ($dates as $date) { list($year, $month, $day) = explode('-', $date); $this->years[$year] = true; if (strpos($date, $checkMonth) === 0) { $this->months[$month] = true; } if (strpos($date, $checkDay) === 0) { $this->days[$day] = true; } $this->dates[] = $date; } foreach ($this->years as $k => $v) { $this->years[$k] = $k; } $months = SLN_Func::getMonths(); foreach ($this->months as $k => $v) { $this->months[$k] = $months[intval($k)]; } foreach ($this->days as $k => $v) { $this->days[$k] = $k; //. date_i18n(' l',strtotime($checkDay.$k)); } ksort($this->years); ksort($this->months); ksort($this->days); }
public function getHoursBeforeString() { $txt = SLN_Func::getIntervalItems(); $ret = $this->getHoursBefore(); if ($ret->from) { $ret->from = $txt[$ret->from]; } if ($ret->to) { $ret->to = $txt[$ret->to]; } return $ret; }