public function authenticate() { $userName = strtolower(trim($this->username, '')); $encriptPassword = UsefullFunction::encriptPassword($this->password); $user = Users::model()->find(array('condition' => 'username=:username AND status=:status', 'params' => array(':username' => $userName, ':status' => Users::STATUS_ACTIVE))); if ($user === NULL) { $this->errorCode = self::ERROR_USERNAME_INVALID; } elseif ($user->password !== $encriptPassword) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { //$this->setState('userType', $user->typeId); $user->loginCount = $user->loginCount + 1; $user->ipAddress = $_SERVER['SERVER_ADDR']; $user->save(); $this->setState('userid', $user->id); $this->setState('username', $user->username); $this->setState('userType', $user->typeId); $this->_id = $user->id; if ($user->typeId != Users::IS_ADMIN) { Yii::app()->session['userBy'] = $user->id; Yii::app()->session['userType'] = $user->typeId; } //$this->setState('lastLoginTime', $user->lastLoginTime); $this->errorCode = self::ERROR_NONE; } return !$this->errorCode; }
/** * 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) { $msg = ''; $model = $this->loadModel($id); $oldPass = $model->password; $model->password = ''; // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['Users'])) { $model->attributes = $_POST['Users']; $model->username = strtolower(trim($model->username, '')); if (strlen($model->password) > 0) { $model->password = UsefullFunction::encriptPassword($model->password); } else { $model->password = $oldPass; } if ($model->save()) { $msg = "<div class='alert alert-success fade in'><i data-dismiss='alert' class='icon-remove close'></i>Users Update Successfully</div>"; } } $this->render('_form', array('model' => $model, 'msg' => $msg)); }
/* @var $this SaleslistController */ /* @var $model Saleslist */ $this->breadcrumbs = array('Saleslists' => array('admin'), 'Manage'); $this->menu = array(array('label' => 'Create Saleslist', 'url' => array('create')), array('label' => 'Manage Saleslist', 'url' => array('admin')), array('label' => 'Import CSV', 'url' => array('csvImport'))); ?> <h1>Manage Saleslists</h1> <div class="search-form" style="display:none"> </div><!-- search-form --> <?php Yii::app()->clientScript->registerScript('re-install-date-picker', "function reinstallDatePicker(id, data)\n {\n \$('#date').datepicker({'dateFormat':'yy-mm-dd'});\n \$('#dateSecond').datepicker({'dateFormat':'yy-mm-dd'});\n \n }"); $pageSize = Yii::app()->user->getState('pageSize', Yii::app()->params['defaultPageSize']); $this->widget('zii.widgets.grid.CGridView', array('id' => 'saleslist-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'afterAjaxUpdate' => 'reinstallDatePicker', 'columns' => array(array('header' => 'Sl.', 'value' => '$row+1'), 'customerName', 'productName', array('name' => 'date', 'type' => 'raw', 'value' => '$data->date', 'filter' => $this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'attribute' => 'date', 'htmlOptions' => array('id' => 'date'), 'options' => array('dateFormat' => 'yy-mm-dd')), true)), array('name' => 'date', 'type' => 'raw', 'value' => '$data->date', 'filter' => $this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'attribute' => 'dateSecond', 'htmlOptions' => array('id' => 'dateSecond'), 'options' => array('dateFormat' => 'yy-mm-dd')), true)), array('name' => 'status', 'value' => 'Lookup::getStatus($data->status)', 'filter' => CHtml::activeDropDownList($model, 'status', UsefullFunction::typeStatus('Lookup', 'status'), array('empty' => 'All'))), array('class' => 'CButtonColumn', 'template' => '{view}{update}{delete}', 'buttons' => array(), 'deleteButtonLabel' => 'Delete', 'deleteButtonOptions' => array('style' => 'width:50px;', 'class' => 'delete_class', 'id' => 'delete_id'), 'deleteConfirmation' => 'Are you sure?', 'updateButtonLabel' => 'Update', 'updateButtonOptions' => array('style' => 'width:50px;', 'class' => 'update_class', 'id' => 'update_id'), 'viewButtonLabel' => 'View', 'viewButtonOptions' => array('style' => 'width:50px;', 'class' => 'view_class', 'id' => 'view_id'), 'visible' => true, 'header' => 'String Header', 'headerHtmlOptions' => array('style' => 'color:red;'), 'header' => CHtml::dropDownList('pageSize', $pageSize, array(5 => 5, 10 => 10, 20 => 20, 30 => 30), array('onchange' => "\$.fn.yiiGridView.update('saleslist-grid',{ data:{pageSize: \$(this).val() }})")))))); /* array( 'class'=>'CButtonColumn', //template details 'template'=>'{view}{update}{delete}', //button details 'buttons'=>array(), //delete details //'afterDelete'=>'function(link,success,data){alert("success");}', 'deleteButtonImageUrl'=>Yii::app()->baseUrl.'/image/delete.png', 'deleteButtonLabel'=>'Delete', 'deleteButtonOptions'=>array('style'=>'width:50px;','class'=>'delete_class','id'=>'delete_id',), 'deleteConfirmation'=>'Are you sure?', //update details 'updateButtonImageUrl'=>Yii::app()->baseUrl.'/image/update.png',
<?php /* @var $this UsersController */ /* @var $model Users */ $this->breadcrumbs = array('Users' => array('index'), 'Manage'); $this->menu = array(array('label' => 'Add User', 'url' => array('create'))); ?> <h1>Manage Users</h1> <div class="search-form" style="display:none"> </div><!-- search-form --> <?php $pageSize = Yii::app()->user->getState('pageSize', Yii::app()->params['defaultPageSize']); $this->widget('zii.widgets.grid.CGridView', array('id' => 'users-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('header' => 'SL.No', 'value' => '$row+1'), 'name', 'username', 'email', array('name' => 'status', 'value' => 'Lookup::getStatus($data->status)', 'filter' => CHtml::activeDropDownList($model, 'status', UsefullFunction::typeStatus('Lookup', 'status'), array('empty' => 'All'))), array('class' => 'CButtonColumn', 'deleteConfirmation' => "js:'Do you really want to delete record with ID '+\$(this).parent().parent().children(':nth-child(2)').text()+'?'", 'header' => CHtml::dropDownList('pageSize', $pageSize, array(5 => 5, 10 => 10, 20 => 20, 30 => 30), array('onchange' => "\$.fn.yiiGridView.update('users-grid',{ data:{pageSize: \$(this).val() }})"))))));
echo $form->labelEx($model, 'typeId'); ?> <?php echo $form->dropDownList($model, 'typeId', UsefullFunction::typeStatus('Lookup', 'userType'), array('class' => 'form-control')); ?> <?php echo $form->error($model, 'typeId'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'status'); ?> <?php echo $form->dropDownList($model, 'status', UsefullFunction::typeStatus('Lookup', 'status'), array('class' => 'form-control')); ?> <?php echo $form->error($model, 'status'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton($model->isNewRecord ? 'Save' : 'Update'); ?> </div> <?php $this->endWidget(); ?>