public function save()
 {
     foreach ($this->getBreaksList() as $row) {
         $break = new AB_ScheduleItemBreak();
         $break->setData($row);
         if ($this->get('start_time') >= $break->get('start_time') || $break->get('start_time') >= $this->get('end_time') || $this->get('start_time') >= $break->get('end_time') || $break->get('end_time') >= $this->get('end_time')) {
             $break->delete();
         }
     }
     parent::save();
 }
 /**
  * Save entity to database.
  * Generate token before saving.
  *
  * @return int|false
  */
 public function save()
 {
     // Generate new token if it is not set.
     if ($this->get('token') == '') {
         $test = new self();
         do {
             $token = md5(uniqid(time(), true));
         } while ($test->loadBy(array('token' => $token)) === true);
         $this->set('token', $token);
     }
     return parent::save();
 }
 /**
  * Delete entity from database.
  *
  * @return bool|false|int
  */
 public function delete()
 {
     $parent_result = parent::delete();
     if ($parent_result && $this->get('google_event_id')) {
         $google = new AB_Google();
         $google->loadByStaffId($this->get('staff_id'));
         $google->delete($this->get('google_event_id'));
         return $parent_result;
     } else {
         return false;
     }
 }
 /**
  * Constructor.
  */
 public function __construct()
 {
     $this->table_name = 'ab_category';
     $this->schema = array('id' => array(), 'name' => array('format' => '%s'));
     parent::__construct();
 }
Example #5
0
 /**
  * Delete entity from database
  *(and delete event in Google Calendar if it exists).
  *
  * @return bool|false|int
  */
 public function delete()
 {
     $result = parent::delete();
     if ($result && $this->hasGoogleCalendarEvent()) {
         $this->deleteGoogleCalendarEvent();
     }
     return $result;
 }
 /**
  * Constructor.
  */
 public function __construct()
 {
     $this->table_name = 'ab_staff_service';
     $this->schema = array('id' => array(), 'staff_id' => array('format' => '%d'), 'service_id' => array('format' => '%d'), 'price' => array('format' => '%.2f', 'default' => '0'), 'capacity' => array('format' => '%d', 'default' => '1'));
     parent::__construct();
 }
 /**
  * Constructor.
  */
 public function __construct()
 {
     $this->table_name = 'ab_schedule_item_break';
     $this->schema = array('id' => array(), 'staff_schedule_item_id' => array('format' => '%d'), 'start_time' => array('format' => '%s'), 'end_time' => array('format' => '%s'));
     parent::__construct();
 }
 /**
  * Constructor.
  */
 public function __construct()
 {
     $this->table_name = 'ab_customer';
     $this->schema = array('id' => array(), 'name' => array('format' => '%s', 'default' => ''), 'phone' => array('format' => '%s', 'default' => ''), 'email' => array('format' => '%s', 'default' => ''), 'notes' => array('format' => '%s', 'default' => ''));
     parent::__construct();
 }
Example #9
0
 public function delete()
 {
     parent::delete();
     if ($this->get('avatar_path')) {
         unlink($this->get('avatar_path'));
     }
 }
 /**
  * Constructor.
  */
 public function __construct()
 {
     $this->table_name = 'ab_customer_appointment';
     $this->schema = array('id' => array(), 'customer_id' => array('format' => '%d'), 'appointment_id' => array('format' => '%d'), 'notes' => array('format' => '%s'), 'token' => array('format' => '%s'));
     parent::__construct();
 }