public function getWorkingTimesByMonth($doctorId, $year, $month) { $bind = ['partnerId' => Config::getInstance()->partnerId, 'doctorId' => $doctorId, 'year' => $year, 'month' => $month]; $where = "partnerId = :partnerId AND doctorId = :doctorId AND YEAR(`date`) = :year AND MONTH(`date`) = :month"; $arr = $this->db->select('workingTimes', $where, $bind, "*", "`date` ASC, `startTime` ASC"); $res = []; foreach ($arr as $row) { $key = $row['date']; if (!isset($res[$key])) { $res[$key] = []; } $res[$key][] = ['startTime' => substr($row['startTime'], 0, -3), 'endTime' => substr($row['endTime'], 0, -3)]; } return $res; }
function deleteUserById($userId) { $bind = ['partnerId' => Config::getInstance()->partnerId, 'userId' => $userId]; $user = $this->db->select('users', 'partnerId = :partnerId AND userId = :userId', $bind); if (count($user) == 1) { $user = $user[0]; $userId = $user['userId']; switch ($user['role']) { case Defines::ROLE_DOCTOR: $this->db->delete('doctors', 'doctorId = :userId', ['userId' => $userId]); break; case Defines::ROLE_CLIENT: $this->db->delete('clients', 'clientId = :userId', ['userId' => $userId]); break; } return $this->db->delete('users', 'userId = :userId', ['userId' => $userId]); } return false; }
public function getOrdersByMonth($doctorId, $year, $month) { $bind = ['partnerId' => Config::getInstance()->partnerId, 'doctorId' => $doctorId, 'year' => $year, 'month' => $month]; $where = ['partnerId = :partnerId', 'doctorId = :doctorId', '((YEAR(orders.start) = :year AND MONTH(orders.start) = :month) OR (YEAR(orders.end) = :year AND MONTH(orders.end) = :month))']; return $this->db->select('orders', implode(' AND ', $where), $bind); }