public function actionLogout() { alog(at("User logged out.")); AdminUser::model()->deleteAll('userid=:id', array(':id' => Yii::app()->user->id)); Yii::app()->user->logout(); fok(at('Thank You! You are now logged out.')); $this->redirect(array('/login')); }
/** * Logout action */ public function actionLogout() { // Log Message alog(at("User logged out.")); // Delete records for this users from admin logged in AdminUser::model()->deleteAll('userid=:id', array(':id' => Yii::app()->user->id)); Yii::app()->user->logout(); fok(at('Thank You! You are now logged out.')); $this->redirect(array('/admin/login')); }
public function moveDataToRecap() { try { $query = "\n\t\t\t\tINSERT INTO attendance_presences_recap (employee_id, date, shift_id, check_in, check_out, break_out, break_in, total_hours, is_late, created_at ) \n\t\t\t\tSELECT employee_id, date, shift_id\n\t\t\t\t\t, min(case type when 'CI' then presence_date else NULL end) as `CheckIn`\n\t\t\t\t\t, max(case type when 'CO' then presence_date else NULL end) as `CheckOut`\n\t\t\t\t\t, max(case type when 'BO' then presence_date else NULL end) as `BreakOut`\n\t\t\t\t\t, min(case type when 'BI' then presence_date else NULL end) as `BreakIn`\n\t\t\t\t\t, 0, 0, now()\n\t\t\t\tFROM (SELECT employee_id, date, case type when 'LV' then 2 else (case type when 'S' then 3 else (case when shift_id IS NULL then 1 else shift_id end) end) end AS `shift_id`, type, presence_date\n\t\t\t\t\t\tFROM `attendance_presences`\n\t\t\t\t\t\tWHERE date BETWEEN '" . $this->start_date . "' AND '" . $this->end_date . "') AS A\n\t\t\t\tGROUP BY employee_id, date, shift_id\n\t\t\t"; $command = Yii::app()->db->createCommand($query); $command->execute(); fok(at('Data recapitulation successfully Generated.')); } catch (Exception $e) { ferror(at('Failed to generate data recapitulation. \\n' . $e)); exit; $transaction->rollBack(); } }
public function actionIndex() { // Submitted form if (isset($_POST['dashboard_staff_message'])) { // Check access checkAccessThrowException('op_dashboard_update_staff_message'); // Update message Setting::model()->updateSettingByKey('dashboard_staff_message', $_POST['dashboard_staff_message']); // Log Message alog(at("Updated Staff Message")); // Updated redirect fok(at('Message Saved.')); $this->redirect(array('index')); } $logModel = new AdminLog(); $this->render('index', array('logModel' => $logModel)); }
public function ImportFile($model, $table, $columns) { if ($model->validate()) { $csvFile = CUploadedFile::getInstance($model, 'file'); $tempLoc = $csvFile->getTempName(); $rnd = rand(0, 9999); $fileName = importPaths("{$rnd}-{$csvFile}"); $csvFile->saveAs($fileName); $sql = "LOAD DATA INFILE '" . $fileName . "'\n\t\t\t\tINTO TABLE `" . $table . "`\n\t\t\t\tFIELDS TERMINATED BY ','\n\t\t\t\tENCLOSED BY '\"'\n\t\t\t\tLINES TERMINATED BY '\r\n'\n\t\t\t\tIGNORE 1 LINES\n\t\t\t\t({$columns})\n\t\t\t\t"; $connection = Yii::app()->db; $transaction = $connection->beginTransaction(); try { $connection->createCommand($sql)->execute(); $transaction->commit(); fok(at('Data successfully imported.')); } catch (Exception $e) { ferror(at('Failed to import data. \\n' . $e)); exit; $transaction->rollBack(); } } }
/** * Delete help topic action */ public function actionDelete() { // Check Access checkAccessThrowException('op_helptopics_delete'); if (isset($_GET['id']) && ($model = HelpTopic::model()->findByPk($_GET['id']))) { alog(at("Deleted Help Topic '{name}'.", array('{name}' => $model->name))); $model->delete(); fok(at('Help Topic Deleted.')); $this->redirect(array('helptopics/index')); } else { $this->redirect(array('helptopics/index')); } }
/** * Delete help topic action */ public function actionDelete() { // Check Access checkAccessThrowException('op_personalmessages_delete'); if (isset($_GET['id']) && ($model = PersonalMessageTopic::model()->findByPk($_GET['id']))) { alog(at("Deleted Personal Message '{name}'.", array('{name}' => $model->title))); // Make sure we are allowed to delete this if ($model->author_id != Yii::app()->user->id) { ferror(at('Sorry, You are not the author of this personal message so you can not delete it.')); alog(at("Tried Deleting a Personal Message '{name}' When he is not the author.", array('{name}' => $model->title))); $this->redirect(getReferrer('personalmessages/index')); } $model->delete(); fok(at('Personal Message Deleted.')); $this->redirect(array('personalmessages/index')); } else { $this->redirect(array('personalmessages/index')); } }
/** * Delete field action */ public function actionDelete() { // Check Access checkAccessThrowException('op_usercustomfields_deleteposts'); if (isset($_GET['id']) && ($model = UserCustomField::model()->findByPk($_GET['id']))) { alog(at("Deleted Custom Field '{name}'.", array('{name}' => $model->title))); $model->delete(); fok(at('Field Deleted.')); $this->redirect(array('usercustomfields/index')); } else { $this->redirect(array('usercustomfields/index')); } }
/** * Revert setting action */ public function actionrevertsetting() { // Check Access checkAccessThrowException('op_settings_revert_settings'); if (isset($_GET['id'])) { $setting = Setting::model()->findByPk($_GET['id']); Setting::model()->updateByPk($_GET['id'], array('value' => $setting->default_value)); if ($setting) { $setting->value = $setting->default_value; // Store setting and run the php code for storing // Evaluate php code if ($setting->php) { $show = 0; $save = 0; $store = 1; eval($setting->php); } } // Log Message alog(at("Reverted Setting '{name}'", array('{name}' => $setting->title))); // Clear cache Yii::app()->settings->clearCache(); fok(at('Setting Reverted.')); $this->redirect(array('setting/viewgroup', 'id' => $setting->category)); } else { $this->redirect(array('setting/index')); } }
/** * Delete page action */ public function actionDelete() { // Check Access checkAccessThrowException('op_custompages_deletepages'); if (isset($_GET['id']) && ($model = CustomPage::model()->findByPk($_GET['id']))) { alog(at("Deleted Custom Page '{name}'.", array('{name}' => $model->title))); $model->delete(); fok(at('Page Deleted.')); $this->redirect(array('custompages/index')); } else { $this->redirect(array('custompages/index')); } }
/** * adding auth item child relationships */ public function actionAddItemChild() { // Check Access checkAccessThrowException('op_permission_add_item_child'); $model = new AuthItemChild(); $roles = AuthItem::model()->findAll(array('order' => 'type DESC, name ASC')); $_roles = array(); if (count($roles)) { foreach ($roles as $role) { $_roles[AuthItem::model()->types[$role->type]][$role->name] = $role->description . ' (' . $role->name . ')'; } } // Did we choose a parent already? if (isset($_GET['parent']) && $_GET['parent'] != '') { $model->parent = $_GET['parent']; } if (isset($_POST['AuthItemChild'])) { if (isset($_POST['AuthItemChild']['child']) && count($_POST['AuthItemChild']['child'])) { // We need to delete all child items selected up until now $existsalready = AuthItemChild::model()->findAll('parent=:parent', array(':parent' => $model->parent)); if (count($existsalready)) { foreach ($existsalready as $existitem) { Yii::app()->authManager->removeItemChild($existitem->parent, $existitem->child); } } $added = 0; foreach ($_POST['AuthItemChild']['child'] as $childItem) { $model->child = $childItem; if ($model->validate()) { $added++; } } // Get model parent $authItem = AuthItem::model()->find('name=:name', array(':name' => $model->parent)); fok(at('{number} Child item(s) Added.', array('{number}' => $added))); // Log Message alog(at("Added {number} child items for {name}", array('{number}' => $added, '{name}' => $model->parent))); if ($authItem) { $this->redirect(array('view', 'id' => $authItem->id, '#' => 'tabs-2')); } else { $this->redirect(array('index')); } } } // Selected values $selected = AuthItemChild::model()->findAll('parent=:parent', array(':parent' => $model->parent)); $_selected = array(); if (count($selected)) { foreach ($selected as $select) { $_selected[] = $select->child; } } $model->child = $_selected; // Add Breadcrumb $this->addBreadCrumb(at('Adding Child Permissions')); $this->title[] = at('Adding Child Permissions'); $this->render('child_form', array('model' => $model, 'roles' => $_roles)); }
/** * Delete page action */ public function actionDelete() { // Check Access checkAccessThrowException('op_blog_deleteposts'); if (isset($_GET['id']) && ($model = BlogPost::model()->findByPk($_GET['id']))) { alog(at("Deleted Blog Post '{name}'.", array('{name}' => $model->title))); $model->delete(); fok(at('Page Deleted.')); $this->redirect(array('blog/index')); } else { $this->redirect(array('blog/index')); } }
public function actionGenerateSalary($id) { $model = $this->loadModel($id); $message = $model->generateNewStandardSalaries(); if ($message == '') { fok('New salary standard generated successfully.'); } else { ferror($message); } $this->render('generate', array('model' => $model)); }
/** * Delete user */ public function actionDelete($id) { // Check Access checkAccessThrowException('op_users_delete'); $model = User::model()->findByPk($id); if ($model) { // Log Message alog(at("Deleted user: '******'.", array('{name}' => $model->name))); $model->delete(); fok(at('User Deleted!')); } else { throw new CHttpException(404, at('Sorry, That record was not found.')); } }
/** * Delete city action */ public function actionDelete() { // Check Access checkAccessThrowException('op_uscities_deletepages'); if (isset($_GET['id']) && ($model = USCity::model()->findByPk($_GET['id']))) { alog(at("Deleted City Record '{name}'.", array('{name}' => $model->city_name))); $model->delete(); fok(at('City Record Deleted.')); $this->redirect(array('city/index')); } else { $this->redirect(array('city/index')); } }
public function moveDataImport($table_name, $table_name_temp) { try { $query = "\n\t\t\t\tINSERT INTO " . $table_name . " (employee_id, date, shift_id, type, presence_date) \n\t\t\t\tSELECT * \n\t\t\t\tFROM " . $table_name_temp . "\n\t\t\t\tWHERE concat(employee_id, date, case when shift_id IS NULL then '' else shift_id end, type, case when presence_date IS NULL then '' else presence_date end) NOT IN \n\t\t\t\t\t(SELECT concat(employee_id, date, case when shift_id IS NULL then '' else shift_id end, type, case when presence_date IS NULL then '' else presence_date end) \n\t\t\t\t\tFROM " . $table_name . ");\n\t\t\t"; $command = Yii::app()->db->createCommand($query); $command->execute(); fok(at('Data successfully Saved.')); } catch (Exception $e) { ferror(at('Failed to save data. \\n' . $e)); exit; $transaction->rollBack(); } }
/** * Revert a string to it's original form */ public function actionRevert() { // Check Access checkAccessThrowException('op_language_translate'); $id = getRParam('id', 0); $string = getRParam('string', 0); // Check if it exists $model = Language::model()->findByPk($id); if (!$model) { ferror(at('That language was not found.')); $this->redirect(array('index')); } // Grab the string and source $source = SourceMessage::model()->findByPk($string); $stringdata = Message::model()->find('language_id=:lang AND id=:id', array(':id' => $string, ':lang' => $id)); if (!$source || !$stringdata) { ferror(at('That language string was not found.')); $this->redirect(array('index')); } // Update the stringdata based on the soruce Message::model()->updateAll(array('translation' => $source->message), 'language_id=:lang AND id=:id', array(':id' => $string, ':lang' => $id)); fok(at('String Reverted.')); $this->redirect(array('language/view', 'id' => $id)); }
/** * Delete Form Template action */ public function actionDelete() { // Check Access checkAccessThrowException('op_formtemplate_delete'); if (isset($_GET['id']) && ($model = FormTemplate::model()->findByPk($_GET['id']))) { alog(at("Deleted Form Template '{name}'.", array('{name}' => $model->title))); $model->delete(); fok(at('Form Template Deleted.')); $this->redirect(array('formtemplate/index')); } else { $this->redirect(array('formtemplate/index')); } }
/** * Sync theme */ public function actionSync($id) { // Check Access checkAccessThrowException('op_theme_sync'); if ($model = Theme::model()->findByPk($id)) { $total = $model->SyncTheme(); alog(at("Synced Theme '{name}'.", array('{name}' => $model->name))); fok(at('Theme Synced. Total {n} files synced.', array('{n}' => $total))); $this->redirect(array('themes/index')); } else { $this->redirect(array('themes/index')); } }