Exemplo n.º 1
1
 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'));
 }
Exemplo n.º 2
0
 public function init()
 {
     parent::init();
     // Add Breadcrumb
     $this->addBreadCrumb(at('Salary Slip'));
     $this->title[] = at('Salary Slip');
 }
Exemplo n.º 3
0
function init($confFiles)
{
    addLibsDirToIncludePath();
    requireStandardLibs();
    $conf = readConfig($confFiles);
    $e = trim(at($conf, 'admin.email'));
    if (empty($e) && APPLICATION_ENV != 'development') {
        echo "Configuration parameter admin.email is not set! This is necessary to ensure " . "someone is notified of any errors that occur.";
        exit(-1);
    }
    error_reporting(E_ALL);
    ini_set('display_errors', APPLICATION_ENV == 'development');
    require_once 'spare-parts/error-handling.php';
    \SpareParts\ErrorHandling\initErrorHandling($e);
    require_once 'chipin/env/log.php';
    \Chipin\Log\configure();
    # To make PHP shut-up regarding a default time-zone not being set.
    date_default_timezone_set("America/New_York");
    $dbParam = function ($p) use($conf) {
        return $conf['resources.db.params.' . $p];
    };
    DB\setConnectionParams($driver = 'mysql', $dbName = $dbParam('dbname'), $username = $dbParam('username'), $password = $dbParam('password'), $host = $dbParam('host'));
    if (APPLICATION_ENV == 'development') {
        require_once 'chipin/debug.php';
    }
}
 public function getFieldValueForDisplay($field, $userId)
 {
     // Check to see if we have that field user combination
     $row = UserCustomFieldData::model()->find('field_id=:field AND user_id=:user', array(':field' => $field->id, ':user' => $userId));
     if ($row) {
         // Return the value
         $value = $row->value;
     } else {
         // Return default
         $value = $field->default_value;
     }
     if ($field->type == 'yesno') {
         $text = $value ? at('Yes') : at('No');
     } elseif ($field->type == 'checkbox') {
         $text = $value ? at('Checked') : at('Not Checked');
     } elseif ($field->type == 'dropdown') {
         $valueArray = UserCustomField::model()->convertExtraToArray($field->extra);
         $text = is_array($valueArray) && isset($valueArray[$value]) ? $valueArray[$value] : $value;
     } elseif ($field->type == 'multi') {
         $valueArray = UserCustomField::model()->convertExtraToArray($field->extra);
         $selectedValue = explode(',', $value);
         if (count($selectedValue)) {
             $arr = array();
             foreach ($selectedValue as $selectedVal) {
                 $arr[] = is_array($valueArray) && isset($valueArray[$selectedVal]) ? $valueArray[$selectedVal] : $selectedVal;
             }
             $text = implode(', ', $arr);
         } else {
             $text = is_array($valueArray) && isset($valueArray[$selectedValue]) ? $valueArray[$selectedValue] : $selectedValue;
         }
     } else {
         $text = $value;
     }
     return $text;
 }
 public function init()
 {
     parent::init();
     // Add Breadcrumb
     $this->addBreadCrumb(at('Attendance Schedulles'));
     $this->title[] = at('Attendance Schedulles');
 }
 public function init()
 {
     parent::init();
     // Add Breadcrumb
     $this->addBreadCrumb(at('My Employments History'));
     $this->title[] = at('My Employments History');
 }
Exemplo n.º 7
0
 public function init()
 {
     parent::init();
     // Add Breadcrumb
     $this->addBreadCrumb(at('Absence'));
     $this->title[] = at('Absence');
 }
 public function init()
 {
     parent::init();
     // Add Breadcrumb
     $this->addBreadCrumb(at('My Languages'));
     $this->title[] = at('My Languages');
 }
 public function init()
 {
     parent::init();
     // Check Access
     checkAccessThrowException('op_attendances_view');
     // Add Breadcrumb
     $this->addBreadCrumb(at('Attendances'));
     $this->title[] = at('Attendances');
 }
Exemplo n.º 10
0
 public function init()
 {
     parent::init();
     // Check Access
     checkAccessThrowException('op_payroll_payments_view');
     // Add Breadcrumb
     $this->addBreadCrumb(at('Employee\'s Salaries'));
     $this->title[] = at('Employee\'s Salaries');
 }
Exemplo n.º 11
0
 public function init()
 {
     parent::init();
     // Check Access
     checkAccessThrowException('op_payroll_allowance_groups_view');
     // Add Breadcrumb
     $this->addBreadCrumb(at('Allowance Groups'));
     $this->title[] = at('Allowances Groups');
 }
Exemplo n.º 12
0
 public function init()
 {
     parent::init();
     // Check Access
     checkAccessThrowException('op_payroll_ump_view');
     // Add Breadcrumb
     $this->addBreadCrumb(at('Regional Minimum Wage'));
     $this->title[] = at('Regional Minimum Wage');
 }
Exemplo n.º 13
0
 public function init()
 {
     parent::init();
     // Check Access
     checkAccessThrowException('op_reference_educations_view');
     // Add Breadcrumb
     $this->addBreadCrumb(at('Educations'));
     $this->title[] = at('Educations');
 }
Exemplo n.º 14
0
function uploadFileDone($cmd, $volumes, $result)
{
    // Get result
    if (isset($result['added'])) {
        foreach ($result['added'] as $dir) {
            alog(at("Media Manager: Upload Completed '{name}'", array('{name}' => $dir['name'])));
        }
    }
}
Exemplo n.º 15
0
 public function init()
 {
     parent::init();
     // Check Access
     checkAccessThrowException('op_payroll_cities_view');
     // Add Breadcrumb
     $this->addBreadCrumb(at('Area Cities'));
     $this->title[] = at('Area Cities');
 }
Exemplo n.º 16
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $this->layout = 'content-home';
     $this->addBreadCrumb(at('Dashboard'));
     $this->title[] = at('Dashboard');
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     $this->render('index');
 }
 public function init()
 {
     parent::init();
     // Check Access
     checkAccessThrowException('op_masters_employee_employments_view');
     // Add Breadcrumb
     $this->addBreadCrumb(at('Employments'));
     $this->title[] = at('Employee Employments');
 }
Exemplo n.º 18
0
 public function init()
 {
     parent::init();
     // Check Access
     checkAccessThrowException('op_masters_positions_view');
     // Add Breadcrumb
     $this->addBreadCrumb(at('Positions'));
     $this->title[] = at('Positions');
 }
 public function init()
 {
     parent::init();
     // Check Access
     checkAccessThrowException('op_payroll_standard_salary_view');
     // Add Breadcrumb
     $this->addBreadCrumb(at('Standard Salary'));
     $this->title[] = at('Standard Salary');
 }
 public function init()
 {
     parent::init();
     // Check Access
     checkAccessThrowException('op_employee_termination_view');
     // Add Breadcrumb
     $this->addBreadCrumb(at('Employee Termination'));
     $this->title[] = at('Employee Termination');
 }
Exemplo n.º 21
0
 /**
  * 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'));
 }
Exemplo n.º 22
0
 /**
  * @param $where
  * @param $project
  * @param $map
  * @param $coords
  * @param $action
  */
 public static function logEvent($where, $project, $map, $coords, $action)
 {
     $event = array('dt' => time(), 'who' => at($_COOKIE, 'lme_auth_currentuserid', 0), 'where' => $where, 'project' => $project, 'map' => $map, 'coords' => $coords, 'action' => $action);
     try {
         $query = "INSERT INTO lme_eventlog\r\n            (dt, who, where, project, map, coords, action)\r\n            VALUES\r\n            (:dt, :who, :where, :project, :map, :coords, :action)";
         $sth = Config::getconnection()->prepare($query);
         $sth->execute($event);
     } catch (\PDOException $e) {
         die($e->getMessage());
     }
 }
Exemplo n.º 23
0
 public function checkName()
 {
     if ($this->isNewRecord) {
         if (AuthItem::model()->exists('name=LOWER(:name)', array(':name' => strtolower($this->name)))) {
             $this->addError('name', at('Sorry, That name is already in use.'));
         }
     } else {
         if (AuthItem::model()->exists('name=LOWER(:name) AND id!=:id', array(':id' => $this->id, ':name' => strtolower($this->name)))) {
             $this->addError('name', at('Sorry, That name is already in use.'));
         }
     }
 }
 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();
     }
 }
Exemplo n.º 25
0
 /**
  * init
  */
 public function init()
 {
     // Check Access
     checkAccessThrowException('op_media_view');
     // Make sure uploads directory is set
     if (!getParam('uploads_dir')) {
         throw new CHttpException(500, Yii::t('media', 'Sorry, You must set the uploads directory first. From the top menu Go to Tools -> Settings -> Missing Settings.'));
     }
     parent::init();
     // Add Breadcrumb
     $this->addBreadCrumb(at('Media Manager'));
     $this->title[] = at('Media Manager');
 }
Exemplo n.º 26
0
 /**
  * Возвращаем ревизию информации о гексе по айди
  * @param $revision_id
  * @return array
  */
 public function getRevisionById($revision_id)
 {
     try {
         $query = "SELECT title, content, editor, edit_reason\r\n            FROM lme_map_tiles_data\r\n            WHERE id = :revision_id ";
         $sth = $this->connection->prepare($query);
         $sth->execute(array('revision_id' => $revision_id));
         $row = $sth->fetch(\PDO::FETCH_ASSOC);
         $info = array('message' => 'Fork revision #' . $revision_id, 'text' => $row['content'], 'title' => $row['title'], 'edit_reason' => "" . $row['edit_reason'], 'editor_name' => at($_COOKIE, 'kw_trpg_lme_auth_editorname', ""));
     } catch (\PDOException $e) {
         die($e->getMessage());
     }
     return $info;
 }
Exemplo n.º 27
0
 public function init()
 {
     // Login required
     if (Yii::app()->getController()->id != 'login') {
         $returnUrl = Yii::app()->request->getUrl();
         if (strpos($returnUrl, '/admin') === false) {
             $returnUrl = array('/admin');
         }
         Yii::app()->user->setReturnUrl($returnUrl);
     }
     // Make sure we have access
     if (!Yii::app()->user->id || !checkAccess('admin')) {
         // Do we need to login
         if (!Yii::app()->user->id && Yii::app()->getController()->id != 'login') {
             $this->redirect(array('/admin/login'));
         }
         // Make sure we are not in login page
         if (Yii::app()->getController()->id != 'login') {
             throw new CHttpException(at('Sorry, You are not allowed to enter this section.'));
         }
     }
     // Make sure we have a valid admin user record
     if (Yii::app()->getController()->id != 'login' && Yii::app()->user->id && !AdminUser::model()->exists('userid=:id', array(':id' => Yii::app()->user->id))) {
         Yii::app()->user->logout();
         ferror(at('Your session expired. Please login.'));
         $this->redirect(array('/admin/login'));
     }
     // Check if we haven't clicked more then X amount of time
     $maxIdleTime = 60 * 60 * getParam('admin_logged_in_time', 5);
     // 5 hour default
     // Were we using an old session
     if (Yii::app()->getController()->id != 'login' && time() - $maxIdleTime > Yii::app()->session['admin_clicked']) {
         // Loguser out and redirect to login
         AdminUser::model()->deleteAll('userid=:id', array(':id' => Yii::app()->user->id));
         Yii::app()->user->logout();
         ferror(at('Your session expired. Please login.'));
         $this->redirect(array('/admin/login'));
     }
     // Delete old records
     AdminUser::model()->deleteAll('lastclick_time < :time', array(':time' => time() - $maxIdleTime));
     // Update only if this is not an ajax request
     if (!request()->isAjaxRequest) {
         // Update record info
         Yii::app()->session['admin_clicked'] = time();
         AdminUser::model()->updateAll(array('lastclick_time' => time(), 'location' => Yii::app()->getController()->id), 'userid=:id', array(':id' => Yii::app()->user->id));
     }
     // Add Breadcrumb
     $this->addBreadCrumb(at('Dashboard'), array('index/index'));
     parent::init();
 }
Exemplo n.º 28
0
 /**
  * Check we are not violating anything
  */
 public function checkLoop()
 {
     if ($this->parent == $this->child) {
         $this->addError('child', at('Cannot add child as an item of itself.'));
     }
     try {
         if (!Yii::app()->authManager->hasItemChild($this->parent, $this->child)) {
             // Create an auth item based on those parameters
             Yii::app()->authManager->addItemChild($this->parent, $this->child);
         }
     } catch (CException $e) {
         $this->addError('child', $e->getMessage());
     }
 }
Exemplo n.º 29
0
 /**
  * User manager index
  */
 public function actionLoginHistory()
 {
     // Check Access
     checkAccessThrowException('op_loginhistory_view');
     $model = new AdminLoginHistory('search');
     $model->unsetAttributes();
     if (isset($_GET['AdminLoginHistory'])) {
         $model->attributes = $_GET['AdminLoginHistory'];
     }
     // Add Breadcrumb
     $this->addBreadCrumb(at('Login History'));
     $this->title[] = at('Admin Login History');
     $this->render('login_history', array('model' => $model));
 }
Exemplo n.º 30
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $this->addBreadCrumb(at('Update') . ' #' . $id);
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['ReferenceGeoDistricts'])) {
         $model->attributes = $_POST['ReferenceGeoDistricts'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('update', array('model' => $model));
 }