protected function getDateTime()
 {
     $date = $this->date;
     $time = $this->time;
     $ret = new DateTime(SLN_Func::filter($date, 'date') . ' ' . SLN_Func::filter($time, 'time'));
     return $ret;
 }
 function getNotAvailableTime($key)
 {
     $post_id = $this->getId();
     $ret = apply_filters('sln_attendant_notav_' . $key, get_post_meta($post_id, '_sln_attendant_notav_' . $key, true));
     $ret = SLN_Func::filter($ret, 'time');
     return new DateTime('1970-01-01 ' . $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();
 }
 function getDuration()
 {
     $post_id = $this->getId();
     $ret = apply_filters('sln_booking_duration', get_post_meta($post_id, '_sln_booking_duration', true));
     if (empty($ret)) {
         $ret = '00:00';
     }
     $ret = SLN_Func::filter($ret, 'time');
     if ($ret == '00:00') {
         $ret = $this->evalDuration();
     }
     return new DateTime('1970-01-01 ' . $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 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 getTotal()
 {
     $ret = 0;
     foreach ($this->getServices() as $s) {
         $ret = $ret + SLN_Func::filter($s->getPrice(), 'float');
     }
     return $ret;
 }