예제 #1
0
 public function __construct()
 {
     try {
         $this->db = DB::init()->connect();
     } catch (Exception $ex) {
         $ex->getMessage();
     }
 }
예제 #2
0
 private function savePsychosocialSupportToDB($request, $benefiterId)
 {
     if ($request['psychosocial_statuses'] != null) {
         $psychosocialStatuses = $request['psychosocial_statuses'];
         foreach ($psychosocialStatuses as $psychosocialStatus) {
             \DB::table('benefiters_psychosocial_support')->insert($this->getPsychosocialSupportArrayForDBInsert($psychosocialStatus, $benefiterId));
         }
     }
 }
예제 #3
0
 public function __construct()
 {
     $this->greekStringConversion = new GreekStringConversionHelper();
     $this->genders = \DB::table('genders_lookup')->get();
     $this->allCountryAbandonReasons = \DB::table('country_abandon_reasons_lookup')->get();
     $this->countryList = \DB::table('countries_lookup')->get();
     $this->marital_statuses = \DB::table('marital_status_lookup')->get();
     $this->educations = \DB::table('education_lookup')->get();
     $this->binaryYesNo = \DB::table('binary_lookup')->get();
     $this->workTitles = \DB::table('work_title_list_lookup')->get();
     return $this->genders;
 }
예제 #4
0
 public function update($input)
 {
     foreach ($input as $id => $value) {
         $data['sent_at'] = DB::raw('NOW()');
         if ($value == 1) {
             $this->invite->update($id, $data);
             $invite = $this->inviteService->get($id);
             $emaildata['code'] = $invite->code;
             $emaildata['email'] = $invite->email;
             $this->mailService->sendInvite($emaildata);
         }
     }
     return true;
 }
예제 #5
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 public function create(array $data)
 {
     $data['email'] = strtolower($data['email']);
     $data['name'] = strtolower($data['name']);
     $date = new \DateTime();
     \DB::insert('insert into users_data (name, email, avatar, gender, full_name, bio, department, created_at, updated_at) values (?, ?, ?, ?, ?, ?, ?, ?, ?)', [$data['name'], $data['email'], '0', $data['gender'], $data['full_name'], '0', $data['department'], $date, $date]);
     \Schema::create('notification.inbox_' . $data['name'], function ($table) {
         $table->text('n_message', 500);
         $table->string('n_link');
         $table->string('n_sender');
         $table->boolean('n_read');
         $table->timestamps();
     });
     return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }
예제 #6
0
 protected function checkRolesForAction($action)
 {
     $reqRoles = $this->requiredRoles();
     $alterRegRoles = [];
     if ($reqRoles) {
         foreach ($reqRoles as $key => $value) {
             $alterRegRoles[strtolower($key . 'Action')] = $value;
         }
         if (array_key_exists($action = strtolower($action), $alterRegRoles)) {
             $roles = $alterRegRoles[$action];
             if (Session::get('user_id')) {
                 $user = PrivilegedUser::getUserRoleById(DB::init()->connect(), Session::get('user_id'));
             } else {
                 $user = ['role_id' => 5, 'role_name' => 'Guest'];
             }
             return in_array($user['role_id'], $roles);
         }
     }
     return TRUE;
 }
예제 #7
0
 public function createdb($dbname)
 {
     $prefix = 'laraapp_';
     $dbname = $prefix . $dbname;
     DB::statement('CREATE DATABASE IF NOT EXISTS ' . $dbname);
     configureConnectionByName($dbname, 'root', 'root');
     if (!Schema::hasTable('customer')) {
         Schema::create('customer', function ($t) {
             // auto increment id (primary key)
             $t->increments('id');
             $t->string('name');
             $t->integer('age')->nullable();
             $t->boolean('active')->default(1);
             $t->integer('role_id')->unsigned();
             $t->text('bio');
             // created_at, updated_at DATETIME
             $t->timestamps();
         });
     }
 }
예제 #8
0
 /**
  * Insert new Match
  *
  * @param  array  $data
  * @return Participant
  */
 public function create_match(array $data)
 {
     $players = Player::select('player_id', 'first_name', 'last_name', \DB::raw('CONCAT(first_name, " ", last_name) as full_name'))->lists('player_id', 'full_name');
     //check to see if players exist in Players table
     $err = '';
     if (!array_key_exists($data['player1'], $players)) {
         $err .= '  Not in Players table: ' . $data['player1'];
     }
     if (!array_key_exists($data['player2'], $players)) {
         $err .= '  Not in Players table: ' . $data['player2'];
     }
     if ($err == '') {
         $player1_id = $players[$data['player1']];
         $player2_id = $players[$data['player2']];
         $match = \DB::table('matches')->where('tournament_id', '=', $data['tournament_id'])->where('player1_id', '=', $player1_id)->where('player2_id', '=', $player2_id)->first();
         if (is_null($match)) {
             $match = Match::create(['player1_id' => $player1_id, 'player2_id' => $player2_id, 'winner_id' => $player1_id, 'tournament_id' => $data['tournament_id'], 'match_date' => $data['match_date'], 'match_type' => $data['match_type'], 'match_division' => $data['match_division']]);
         }
     }
 }
예제 #9
0
 public function editUserAction()
 {
     $fc = FrontController::getInstance();
     $model = new AdminModel('Редактирование пользователя');
     $userModel = new UserUpdateTableModel();
     $userModel->setTable('user');
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         $userModel->setData('userUpdate');
         $userModel->updateRecord();
         header('Location: /admin/profile/id/' . $userModel->getId());
         exit;
     } else {
         $id = filter_var($fc->getParams()['id'], FILTER_SANITIZE_NUMBER_INT);
         if (!$id) {
             header('Location: /admin/notFound');
             exit;
         }
         $userModel->setId($id);
         $user = [];
         $db = DB::init()->connect();
         $userModel->readRecordsById();
         $userModel->readUserAddress();
         $userModel->readUserPhones();
         $roles = PrivilegedUser::getUserRoleById($db, $id);
         $model->setData(['profile' => $userModel->getRecordsById(), 'contacts' => $userModel->getUserContacts(), 'role' => $roles, 'allRoles' => Role::getRoles($db), 'perms' => Role::getRolePerms($db, $roles['role_id'])->getPermissions()]);
     }
     $output = $model->render('../views/admin/user/editUser.php', 'admin');
     $fc->setPage($output);
 }
 /**
  * Determines if we have a DB connection.
  * 
  * @return boolean
  */
 public function hasDB()
 {
     if (!isset($this->db)) {
         try {
             $this->db = !!\DB::connection()->getDatabaseName();
         } catch (\Exception $e) {
             $this->db = false;
         }
     }
     return $this->db;
 }
예제 #11
0
 function __construct()
 {
     $this->db = DB::init()->connect();
 }
예제 #12
0
 private function getAllBenefitersForCsvFileDownload()
 {
     $queryString = "select b.*, gl.gender, msl.marital_status_title, el.education_title, wll.description " . "as legal_working_status, wtll.work_title, " . "carl.description as country_abandon_reason from benefiters as b " . "left join benefiters_legal_status as bls on b.id = bls.benefiter_id left join genders_lookup as gl " . "on b.gender_id = gl.id left join marital_status_lookup as msl on b.marital_status_id = msl.id " . "left join education_lookup as el on b.education_id = el.id left join working_legally_lookup as wll " . "on b.working_legally = wll.id left join work_title_list_lookup as wtll on b.work_title_id = wtll.id " . "left join country_abandon_reasons_lookup as carl on b.country_abandon_reason_id = carl.id " . "where deleted_at is null group by b.id";
     return \DB::select(\DB::raw($queryString));
 }
예제 #13
0
 /**
  * To add ticker owener or joinee to push subscribed users
  * @param int $userId
  * @param int $tickerId
  * @param array $pushSubscribers
  * @return array $pushSubscribers
  */
 public static function getTickerOwnerOrJoinee($userId, $tickerId, $pushSubscribers)
 {
     $sql = \app\models\TickerInvities::where('ticker_id', '=', $tickerId)->where('status', '=', \DB::Raw(1));
     $tickerInvityData = $sql->get()->first();
     $id = 0;
     if (!empty($tickerInvityData)) {
         if ($tickerInvityData->requester_id == $userId) {
             $id = $tickerInvityData->invited_user_id;
         } else {
             $id = $tickerInvityData->requester_id;
         }
         $pushSubscribers[] = $id;
     }
     $pushSubscribers = array_unique($pushSubscribers);
     return $pushSubscribers;
 }
예제 #14
0
 public function getReportDataForRegisteredBenefiters()
 {
     try {
         // get benefiter registration number for any particular month.
         $benefitersCount = \DB::select(\DB::raw("select date_format(created_at, '%Y-%m') as created_at, count(id) as idcounter from benefiters group by date_format(created_at, '%Y %m')"));
         // $benefitersCount = \DB::select(\DB::raw("select created_at, count(id) as idcounter from benefiters group by year(created_at), month(created_at)"));
     } catch (\Exception $e) {
         Log::error("A problem occured while trying to count the users based on registration date.\n" . $e);
         return null;
     }
     Log::info("Returning result with users based on their registration date.");
     return $benefitersCount;
 }
예제 #15
0
 public function createRole(array $data)
 {
     $getid = \DB::table('users')->where('email', '=', $data['correo_electronico'])->where('user_login', '=', $data['nombre_usuario'])->where('num_identificacion', '=', $data['numero_identificacion'])->first();
     return RolesUsers::create(['user_id' => $getid->id, 'role_id' => $data['rol_usuario']]);
 }
예제 #16
0
 private function findLegalStatusIdFromName($legal_status)
 {
     // if $__legalStatuses is empty, then fill it with normalized legal statuses from DB...
     if (empty($this->__legalStatuses)) {
         $allLegalStatuses = \DB::table('legal_status_lookup')->get();
         foreach ($allLegalStatuses as $legalStatus) {
             $this->__legalStatuses[$legalStatus->id] = $this->greekStringConversion->grstrtoupper($legalStatus->description);
         }
     }
     // ...else use the existent array
     // normalize $legal_status
     $tmp = $this->greekStringConversion->grstrtoupper($legal_status);
     $id = array_search($tmp, $this->__legalStatuses);
     // if legal status was not found in $legalStatuses array
     // return null
     if (!$id) {
         $id = null;
     }
     return $id;
 }
예제 #17
0
 private function getDoctorIdFromName($doctorName)
 {
     $tmp = \DB::select(\DB::raw('select id from users where (user_role_id = 1 or user_role_id = 2) and (lastname like "%' . $doctorName . '%" or name like "%' . $doctorName . '%")'));
     if ($tmp != null) {
         Log::info("Returning the doctors ids.");
         return $tmp;
     } else {
         Log::error("Couldn't find the doctor's id");
         return null;
     }
 }
예제 #18
0
 protected function __construct()
 {
     $this->db = DB::init()->connect();
     $this->permissions = array();
 }
예제 #19
0
 public function getPermsByRoleIdAction()
 {
     header('Content-type: application/json; charset=utf-8');
     header('Cache-Control: no-store, no-cache');
     header('Expires: ' . date('r'));
     if (filter_has_var(INPUT_GET, 'id')) {
         $id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
     } else {
         throw new Exception('Не удалось получить id роли');
     }
     $perms = Role::getRolePerms(DB::init()->connect(), $id)->getPermissions();
     echo json_encode($perms);
 }
예제 #20
0
 private function findLawyerActionsFromLegalSessionId($legalSessionId)
 {
     return \DB::table('legal_lawyer_action')->where('legal_session_id', '=', $legalSessionId)->get();
 }
예제 #21
0
 public function processWorkTime($emp_mx_id, $punch_date)
 {
     $total_work_time = 0;
     $in_times = [];
     $out_times = [];
     $difference = 0;
     $total_out_time = 0;
     $total_work_time = \DB::select(" SELECT\n                                         TIMESTAMPDIFF(MINUTE, MIN(punch_trg_datetime), MAX(punch_trg_datetime)) total_time\n                                      FROM tik_tok_attendance\n                                      WHERE emp_mx_id = '{$emp_mx_id}' AND\n                                            punch_trg_date = '{$punch_date}' AND DATE_FORMAT(punch_trg_datetime , '%H') >= 8 ;\n                                     ")[0]->total_time;
     //Latha and Alex
     if ($emp_mx_id != 'MX057' || $emp_mx_id != 'MX076') {
         $all_in_time_array = \DB::select("SELECT punch_trg_datetime FROM tik_tok_attendance WHERE punch_trg_date = '{$punch_date}' AND emp_mx_id = '{$emp_mx_id}' AND punch_type = 'In' AND DATE_FORMAT(punch_trg_datetime , '%H') >= 8 ORDER BY punch_trg_datetime,punch_trg_id ASC ;");
         $all_out_time_array = \DB::select("SELECT punch_trg_datetime FROM tik_tok_attendance WHERE punch_trg_date = '{$punch_date}' AND emp_mx_id = '{$emp_mx_id}' AND punch_type = 'Out' AND DATE_FORMAT(punch_trg_datetime , '%H') >= 8 ORDER BY punch_trg_datetime,punch_trg_id ASC ;");
         foreach ($all_in_time_array as $all_in_time_array_item) {
             $in_times[] = $all_in_time_array_item->punch_trg_datetime;
         }
         foreach ($all_out_time_array as $all_out_time_array_item) {
             $out_times[] = $all_out_time_array_item->punch_trg_datetime;
         }
         $in_time_count = count($in_times);
         $out_time_count = count($out_times);
         if ($in_time_count == $out_time_count) {
             foreach ($out_times as $key => $out_time_value) {
                 if (!empty($in_times[$key + 1])) {
                     $num_temp = $key + 1;
                     $difference = \DB::connection('mysql_dummy')->select(" SELECT TIMESTAMPDIFF(MINUTE, '{$in_times[$num_temp]}', '{$out_time_value}' ) difference ; ")[0];
                     $total_work_time += $difference->difference;
                     $total_out_time += abs($difference->difference);
                 }
             }
         } else {
             if ($in_time_count > $out_time_count) {
                 $evaluate_date = new \DateTime($in_times[$in_time_count - 1]);
                 $num_temp = $in_time_count - 1;
                 if (intval($evaluate_date->format('H')) < 19) {
                 }
                 $difference = \DB::connection('mysql_dummy')->select(" SELECT TIMESTAMPDIFF(MINUTE, '{$in_times[$num_temp]}', '{$punch_date} 19:30:00' ) difference ; ")[0];
                 $total_work_time += $difference->difference;
             }
         }
     }
     return "{$total_work_time},{$total_out_time}";
 }
예제 #22
0
 /**
  * Create contributor and connect to book.
  * @param  [int] $book_id Id of book.
  * @param  [type] $data    [description]
  * @param  [type] $avatar  [description]
  * @return [type]          [description]
  */
 public function createContributorAndConnectBook($book_id, $data, $avatar)
 {
     $user = $this->model->create(['lastname' => $data['name'], 'blurb' => $data['blurb'], 'email' => $data['email'], 'twitter_id' => $data['twitter_id'], 'github' => $data['github'], 'avatar' => $avatar]);
     DB::table('book_author')->insert(['author_id' => $user->id, 'book_id' => $book_id, 'is_main' => 2, 'royalty' => 0, 'is_accepted' => 1, 'message' => '']);
 }
예제 #23
0
 private function getAllReferrals()
 {
     return \DB::table('benefiter_referrals_lookup')->get();
 }