public function manageAction($id = false) { $this->permission('manage'); $model = new \modules\pm\models\Pm_projects(); $user = new \modules\users\models\Users(); $team_project = new \modules\pm\models\Pm_teams_projects(false); $model->attributes = $this->input->post(); if ($id) { $model->pm_project_id = $id; } if (!$id) { $model->created = date("Y-m-d H:i:s"); } $users = []; foreach ($user->get() as $item) { $users[$item->user_id] = $item->fullname; } if ($id) { $model->pm_project_id = $id; } $team_project->_select = "pm_team_project_id, pm_team_id, pm_project_id"; $teams = Form_helper::queryToDropdown('pm_teams', 'pm_team_id', 'title'); if ($pid = $model->save()) { foreach ($this->input->post('pm_teams') as $teamproject) { $team_project->pm_team_id = $teamproject; $team_project->pm_project_id = $pid; $team_project->save(); } Uri_helper::redirect("management/pm_projects"); } else { return $this->render('pm_projects/manage', ['item' => $id ? $model->get() : null, 'team' => $teams, 'user' => $users, 'team_project' => $id ? $team_project->get() : null]); } }
public function indexAction() { // echo $_post['username'] . '<br>'; // echo $_post['password'] . '<br>'; // echo $_post['code'] . '<br>'; $model = new \modules\users\models\Users(); $model->email = $_GET['username']; $model->password = $_GET['password']; // print_r($model->get()) . '<br>'; // print_r($model->get()); if ($data = $model->get()) { $model1 = new \modules\brightery\models\brightery_licenses(); $model1->license_code = $_GET['code']; $model1->status = 'active'; $model1->user_id = $data[0]->user_id; if ($data1 = $model1->get()) { $data1[0]->brightery_license_id; $res = $this->database->query('select max(due_date) from brightery_invoices where brightery_license_id= ' . $data1[0]->brightery_license_id . ' AND status= "paid" GROUP BY brightery_license_id HAVING max(due_date) < now()')->result(); if ($res) { echo json_encode(['status' => 'success', 'code' => rand(0, 1000)]); } } else { echo json_encode(['status' => 'faild', 'message' => 'license not found']); } } else { echo json_encode(['status' => 'faild', 'message' => 'user not found']); } exit; }
public function loginAction($ajax = false) { $this->layout = 'ajax'; $login = new \modules\users\models\Users('login'); $resp = ['accessGranted' => false, 'errors' => '', 'redirect' => '']; // For ajax response if ($login->validate()) { $resp['accessGranted'] = true; $resp['redirect'] = Uri_helper::url(); $this->input->cookie('failed-attempts', 0); $userInfo = $this->permissions->getUserInformation(); $this->input->cookie('fullname', $userInfo->fullname); $this->input->cookie('email', $userInfo->email); $this->input->cookie('password', $userInfo->password); $this->input->cookie('image', $userInfo->image); } else { // Failed Attempts $fa = $this->input->cookie('failed-attempts') ? $this->input->cookie('failed-attempts') : 0; $fa++; $this->input->cookie('failed-attempts', $fa); // Error message $resp['errors'] = $this->Language->phrase('please_enter_a_valid_email_and_password') . $fa; } return json_encode($resp); }
public function indexAction() { $user = new \modules\users\models\Users(); $user->user_id = $id; $user->_select = "user_id, fullname, email, password, image, gender, birthdate"; return $this->render('commerce_dashboard/index', ['item' => $user->get()]); }
public function manageAction($id = false) { $this->permission('manage'); $model = new \modules\pm\models\Pm_teams(); $user = new \modules\users\models\Users(); $team_users = new \modules\pm\models\Pm_team_users(false); $model->attributes = $this->Input->post(); if ($id) { $model->pm_team_id = $id; } if (!$id) { $model->created = date("Y-m-d H:i:s"); } $users = []; foreach ($user->get() as $item) { $users[$item->user_id] = $item->fullname; } $team_users->_select = "pm_team_users_id , pm_team_id, user_id,pm_role_id"; $roles = Form_helper::queryToDropdown('pm_roles', 'pm_role_id', 'title'); if ($tid = $model->save()) { if ($id) { $team_users->pm_team_id = $id; $team_users->delete(); } foreach ($this->input->post('add_user_id') as $key => $member_role) { $team_users->user_id = $member_role; $team_users->pm_team_id = $tid; $team_users->pm_role_id = $this->input->post('add_pm_role_id.' . $key); $team_users->save(); } Uri_helper::redirect('management/pm_teams'); } else { return $this->render('pm_teams/manage', ['item' => $id ? $model->get() : null, 'team_users' => $id ? $team_users->get() : null, 'roles' => $roles, 'user' => $users]); } }
public function indexAction($offset = 0) { $this->permission('index'); $this->language->load("clinic_patients"); $model = new \modules\users\models\Users(); $model->_select = "user_id, fullname"; $this->load->library('pagination'); $model->_limit = $this->config->get('limit'); $model->_offset = $offset; $config = ['url' => Uri_helper::url('management/clinic_patients/index'), 'total' => $model->get(true), 'limit' => $model->_limit, 'offset' => $model->_offset]; return $this->render('clinic_patients/index', ['items' => $model->get(), 'pagination' => $this->Pagination->generate($config)]); }
public function indexAction($id = false) { if (!$id) { return Brightery::error404(); } $this->permission('index'); $users = new \modules\users\models\Users(); $users->_select = "user_id,fullname,image,status,\n (SELECT usergroups.name FROM usergroups WHERE usergroups.usergroup_id = users.usergroup_id) AS usergroup\n "; $users->user_id = $id; $teams = new \modules\pm\models\Pm_team_users(); $teams->_select = "pm_team_users_id, user_id,\n (SELECT pm_teams.title FROM pm_teams WHERE pm_teams.pm_team_id = Pm_team_users.pm_team_id) AS team,\n (SELECT pm_roles.title FROM pm_roles WHERE pm_roles.pm_role_id = Pm_team_users.pm_role_id) AS role\n "; $teams->user_id = $id; $project_count = $this->database->query("SELECT COUNT(*) AS projects\n FROM (\n SELECT DISTINCT `pm_projects`.`pm_project_id`\n FROM `brighterycms`.`pm_projects`\n RIGHT JOIN `brighterycms`.`pm_teams_projects`ON (`pm_teams_projects`.`pm_project_id` = `pm_projects`.`pm_project_id`)\n INNER JOIN `brighterycms`.`pm_teams` ON (`pm_teams_projects`.`pm_team_id` = `pm_teams`.`pm_team_id`)\n INNER JOIN `brighterycms`.`pm_team_users` ON (`pm_team_users`.`pm_team_id` = `pm_teams`.`pm_team_id`)\n WHERE (`pm_team_users`.`user_id` = {$id})\n ) t;")->row(); $issue_count = $this->database->query("SELECT COUNT(*) AS issues\n FROM (\n SELECT pm_history.pm_issue_id\n FROM\n `brighterycms`.`pm_history`\n INNER JOIN `brighterycms`.`pm_issues`\n ON (`pm_history`.`pm_issue_id` = `pm_issues`.`pm_issue_id`)\n WHERE (`pm_history`.`actions` ='assign' AND `pm_history`.`to_user_id` = {$id})\n ) s;")->row(); $assign = $this->database->query("SELECT pm_issues.title AS issue_title ,pm_issues.pm_issue_id, actions = 'assign' AS assign ,\n DATETIME AS assigned_date , NAME AS priority , pm_priorities.color AS p_color , pm_issue_statues.`title` AS statues , pm_issue_statues.`color` AS s_color\n FROM pm_issues JOIN pm_history\n ON pm_issues.`pm_issue_id`= pm_history.`pm_issue_id`\n JOIN users\n ON users.user_id = pm_history.to_user_id\n JOIN pm_priorities\n ON pm_priorities.`pm_priority_id` = pm_issues.`pm_priority_id`\n JOIN pm_issue_statues\n ON pm_issue_statues.`pm_issue_statues_id` = pm_issues.`pm_issue_statues_id`\n WHERE pm_history.to_user_id = {$id}")->result(); $actions = $this->database->query("SELECT *, 'Infraction' AS actions , (SELECT pm_issues.`title` FROM pm_issues WHERE pm_issues.`pm_issue_id` = pm_infractions.`pm_issue_id`) AS issue_title FROM `pm_infractions`\n WHERE pm_infractions.`user_id` = {$id}\n UNION\n SELECT *, 'Reputation' AS actions , (SELECT pm_issues.`title` FROM pm_issues WHERE pm_issues.`pm_issue_id` = pm_reputations.`pm_issue_id`) AS issue_title FROM `pm_reputations`\n WHERE pm_reputations.`user_id` = {$id}")->result(); return $this->render('pm_user_profile/index', ['item' => $users->get(), 'teams' => $teams->get(), 'assign' => $assign, 'actions' => $actions, 'project_count' => $project_count, 'issue_count' => $issue_count]); }
public function get_user_informationAction($id = NULL) { if (!$id) { return Brightery::error404(); } $this->layout = 'ajax'; $user = new \modules\users\models\Users(); $user->_select = "`users`.`fullname`, `users`.`gender`, `users`.`email`, (SELECT phone FROM user_phones WHERE `primary` = '1' AND user_phones.user_id = users.user_id LIMIT 1) AS phone"; $user->user_id = $id; return json_encode(['user' => $user->get()]); }
public function checkAction($id, $old_password) { if ($old_password) { $check = new \modules\users\models\Users(); $check->user_id = $id; $check->password = md5($old_password); if ($check->get()) { return true; } else { return false; } } }
public function saveAction() { $email = $this->input->post('email'); $date = $this->input->post('date'); $time = $this->input->post('time'); $clinic_doctor_id = $this->input->post('clinic_doctor_id'); $clinic_doctor_reservation_type_id = $this->input->post('clinic_doctor_reservation_type_id'); $model = new \modules\users\models\Users(); $model->_select = "user_id"; $model->email = $email; if ($model->get()) { $user = $model->get(); $user_id = $user[0]->user_id; $model_res = new \modules\clinic\models\Clinic_reservations(FALSE); $model_res->created = date("Y-m-d H:i:s"); $model_res->time = $time; $model_res->date = $date; $model_res->user_id = $user_id; $model_res->clinic_doctor_id = $clinic_doctor_id; $model_res->clinic_doctor_reservation_type_id = $clinic_doctor_reservation_type_id; $model_res->clinic_reservation_status = 'pending'; $model_res->status = ''; if ($model_res->save()) { return true; } else { return false; } } else { return false; } }
function get_schedule($datenew, $time, $doctor_id) { $i = []; $date = $datenew; $date_new = $this->get_newDate(); foreach ($time as $key => $value) { $key = new reserved(); $i[$value] = $key; $i[$value]->time = $value; } /////////////////////////////Clinic Schedules/////////////////////////// $model_schedule = new Clinic_schedules(); $model_schedule->_select = 'day , from_time , to_time , status'; $model_schedule->clinic_doctor_id = $doctor_id; // $model_schedule->status = 'on'; $res = $model_schedule->get(); foreach ($date as $key => $value) { $day = $date[$key]->day; $d = $date[$key]->date; foreach ($i as $k => $v) { $i[$k]->schedule->{$day}->date = $d; $i[$k]->schedule->{$day}->day = $day; $i[$k]->schedule->{$day}->status = ''; $i[$k]->schedule->{$day}->from_time = ''; $i[$k]->schedule->{$day}->to_time = ''; foreach ($res as $value) { if ($day == $value->day && $value->status == 'on') { $i[$k]->schedule->{$day}->day_status = 'on'; } } foreach ($res as $tare) { if ($tare->day == $day) { $tare->date = $d; // if($tare->status == 'on') // $tare-> } } } } $count = 0; foreach ($res as $keyy => $value) { /////////////////////////////Clinic Reservations/////////////////////////// $model_reservations = new Clinic_reservations(); $model_reservations->_select = 'clinic_reservation_id, user_id , date , time '; $model_reservations->date = $res[$keyy]->date; $model_reservations->clinic_doctor_id = $doctor_id; $dates = $model_reservations->get(); if ($dates) { foreach ($dates as $key => $value) { foreach ($date_new as $keyy => $valuee) { if ($date_new[$keyy]->date == $dates[$key]->date) { $time = $dates[$key]->time; $date = $dates[$key]->date; $user_id = $dates[$key]->user_id; /////////////////////get day//////////////////////////////////////// $timestamp = strtotime($date); $day = date("l", $timestamp); //////////////////////get full name from users////////////////////// $user = new \modules\users\models\Users(); $user->_select = 'fullname'; $user->user_id = $user_id; $user->status = 'active'; $res_name = $user->get(); $fullname = $res_name->fullname; //////////////////insert in array/////////////////////////////////// if (isset($i[$time]->schedule->{$day})) { $test = $i[$time]->schedule->{$day}; $test->time = $time; $test->day = $day; $test->date = $date; $test->fullname = $fullname; $test->status = 'reserved'; } } } } } } Clinic_schedules::$result_final = $res; return $i; }