public function load($staff_id) { $data = $this->wpdb->get_results(' SELECT c.name AS category_name, s.* FROM ' . AB_Category::getTableName() . ' c INNER JOIN ' . AB_Service::getTableName() . ' s ON c.id = s.category_id ', ARRAY_A); if (!$data) { $data = array(); } $this->uncategorized_services = AB_Service::query('s')->where('s.category_id', null)->fetchArray(); $staff_services = AB_StaffService::query('ss')->select('ss.service_id, ss.price, ss.capacity')->where('ss.staff_id', $staff_id)->fetchArray(); if ($staff_services) { foreach ($staff_services as $staff_service) { $this->selected[$staff_service['service_id']] = array('price' => $staff_service['price'], 'capacity' => $staff_service['capacity']); } } foreach ($data as $row) { if (!isset($this->collection[$row['category_id']])) { $abCategory = new AB_Category(); $abCategory->set('id', $row['category_id']); $abCategory->set('name', $row['category_name']); $this->collection[$row['category_id']] = $abCategory; } unset($row['category_name']); $abService = new AB_Service($row); $this->category_services[$row['category_id']][] = $abService->get('id'); $this->collection[$row['category_id']]->addService($abService); } }
function update_7_3() { add_option('ab_appearance_text_info_third_step_guest', ''); $staff_members = AB_Staff::query('s')->select('s.id, s.full_name')->fetchArray(); foreach ($staff_members as $staff) { do_action('wpml_register_single_string', 'bookly', 'staff_' . $staff['id'], $staff['full_name']); } $categories = AB_Category::query('c')->select('c.id, c.name')->fetchArray(); foreach ($categories as $category) { do_action('wpml_register_single_string', 'bookly', 'category_' . $category['id'], $category['name']); } $services = AB_Service::query('s')->select('s.id, s.title')->fetchArray(); foreach ($services as $service) { do_action('wpml_register_single_string', 'bookly', 'service_' . $service['id'], $service['title']); } }
/** * @param int $id * @return mixed */ private function getServiceCollection($id = 0) { $services = AB_Service::query('s')->select('s.*, COUNT(staff.id) AS total_staff, GROUP_CONCAT(DISTINCT staff.id) AS staff_ids')->leftJoin('AB_StaffService', 'ss', 'ss.service_id = s.id')->leftJoin('AB_Staff', 'staff', 'staff.id = ss.staff_id')->whereRaw('s.category_id = %d OR !%d', array($id, $id))->groupBy('s.id')->sortBy('ISNULL(s.position), s.position'); return $services->fetchArray(); }