コード例 #1
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function search()
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $ugRows = Usergroup::model()->findAll('uid=:uid', array(':uid' => Yii::app()->user->getState("user_id")));
     $grps = [];
     foreach ($ugRows as $ug) {
         $grps[] = $ug['gid'];
     }
     /*Get Blocked Item  Ids*/
     $getRows = Blockeditem::model()->findAllByAttributes(array('blocked_for' => Yii::app()->user->getState("user_id"), 'flag' => 'U', 'unblock_by' => NULL));
     $biU = [];
     foreach ($getRows as $row) {
         $biU[] = $row['item_id'];
     }
     $getRows = Blockeditem::model()->findAllByAttributes(array('blocked_for' => $grps, 'flag' => 'G', 'unblock_by' => NULL));
     $biG = [];
     foreach ($getRows as $row) {
         $biG[] = $row['item_id'];
     }
     ////////////Blocked For All
     $getRows = Blockeditem::model()->findAllByAttributes(array('flag' => 'A', 'unblock_by' => NULL));
     $biA = [];
     foreach ($getRows as $row) {
         $biA[] = $row['item_id'];
     }
     $blockeditemtableIds = array_merge($biU, $biG);
     $blockeditemtableIds = array_unique(array_merge($blockeditemtableIds, $biA));
     $criteria = new CDbCriteria();
     $criteria->compare('category_id', $this->category_id, true);
     $criteria->compare('name', $this->name, true);
     $criteria->compare('location_id', $this->location_id);
     $criteria->compare('technical_incharge_id', $this->technical_incharge_id);
     $criteria->compare('status_id', $this->status_id);
     $criteria->compare('manufacturer_id', $this->manufacturer_id);
     $criteria->compare('cartridge_type_id', $this->cartridge_type_id);
     $criteria->compare('management_type_id', $this->management_type_id);
     $criteria->compare('threshold', $this->threshold);
     $criteria->compare('link_to', $this->link_to);
     $criteria->compare('image', $this->image, true);
     $criteria->compare('imageFileName', $this->imageFileName, true);
     $criteria->compare('imageFileType', $this->imageFileType, true);
     $criteria->compare('document', $this->document, true);
     $criteria->compare('documentFileName', $this->documentFileName, true);
     $criteria->compare('documentFileType', $this->documentFileType, true);
     $criteria->compare('is_deleted', $this->is_deleted);
     $criteria->addCondition("is_deleted = 0");
     $criteria->addNotInCondition('id', $blockeditemtableIds);
     if (isset($_GET['printerId'])) {
         $printerId = $_GET['printerId'];
         $criteria->addCondition("link_to = {$printerId}");
     }
     if (isset($_GET['category_id'])) {
         $a = $_GET['category_id'];
         $criteria->addCondition("category_id = '{$a}'");
     }
     return new CActiveDataProvider($this, array('criteria' => $criteria, 'pagination' => array('pageSize' => Yii::app()->user->getState('pageSize', 3))));
 }
コード例 #2
0
 public static function UpdateStatusOfConsumables($userId)
 {
     /*Get the user's group*/
     $ugRows = Usergroup::model()->findAll('uid=:uid', array(':uid' => $userId));
     $grps = [];
     foreach ($ugRows as $ug) {
         $grps[] = $ug['gid'];
     }
     /*Get Blocked Item Table Ids*/
     $getRows = BlockeditemUser::model()->findAllByAttributes(array('uid' => $userId));
     $biU = [];
     foreach ($getRows as $row) {
         $biU[] = $row['blockitem_id'];
     }
     $getRows = BlockeditemGroup::model()->findAllByAttributes(array('gid' => $grps));
     $biG = [];
     foreach ($getRows as $row) {
         $biG[] = $row['blockitem_id'];
     }
     ////////////Blocked For All
     $getRows = Blockeditem::model()->findAllByAttributes(array('flag' => 0));
     $biA = [];
     foreach ($getRows as $row) {
         $biA[] = $row['id'];
     }
     $blockeditemtableIds = array_merge($biU, $biG);
     $blockeditemtableIds = array_unique(array_merge($blockeditemtableIds, $biA));
     $consumableItemIds = Blockeditem::model()->findAllByAttributes(array('id' => $blockeditemtableIds));
     $consIds = [];
     foreach ($consumableItemIds as $row) {
         $consIds[] = $row['item_id'];
     }
     $getConsumables = Consumable::model()->findAll();
     foreach ($getConsumables as $cons) {
         $model = Consumable::model()->findByPk($cons['id']);
         if (in_array($cons['id'], $consIds)) {
             $model->isBlockedForMe = 1;
         } else {
             $model->isBlockedForMe = 0;
         }
         $model->update();
     }
 }
コード例 #3
0
 public function search2()
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $ugRows = Usergroup::model()->findAll('uid=:uid', array(':uid' => Yii::app()->user->getState("user_id")));
     $grps = [];
     foreach ($ugRows as $ug) {
         $grps[] = $ug['gid'];
     }
     /*Get Blocked Item  Ids*/
     $getRows = Blockeditem::model()->findAllByAttributes(array('blocked_for' => Yii::app()->user->getState("user_id"), 'flag' => 'U', 'unblock_by' => NULL));
     $biU = [];
     foreach ($getRows as $row) {
         $biU[] = $row['item_id'];
     }
     $getRows = Blockeditem::model()->findAllByAttributes(array('blocked_for' => $grps, 'flag' => 'G', 'unblock_by' => NULL));
     $biG = [];
     foreach ($getRows as $row) {
         $biG[] = $row['item_id'];
     }
     ////////////Blocked For All
     $getRows = Blockeditem::model()->findAllByAttributes(array('flag' => 'A', 'unblock_by' => NULL));
     $biA = [];
     foreach ($getRows as $row) {
         $biA[] = $row['item_id'];
     }
     $blockeditemtableIds = array_merge($biU, $biG);
     $blockeditemtableIds = array_unique(array_merge($blockeditemtableIds, $biA));
     $criteria = new CDbCriteria();
     $criteria->compare('id', $this->id);
     $criteria->compare('commodity_id', $this->commodity_id);
     $criteria->compare('category_id', $this->category_id, true);
     $criteria->compare('link_to', $this->link_to);
     $criteria->compare('name', $this->name, true);
     $criteria->compare('location_id', $this->location_id);
     $criteria->compare('technical_incharge_id', $this->technical_incharge_id);
     $criteria->compare('size', $this->size);
     $criteria->compare('status_id', $this->status_id);
     $criteria->compare('monitor_type_id', $this->monitor_type_id);
     $criteria->compare('manufacturer_id', $this->manufacturer_id);
     $criteria->compare('serial_number', $this->serial_number);
     $criteria->compare('management_type_id', $this->management_type_id);
     $criteria->compare('comments', $this->comments, true);
     $criteria->compare('document', $this->document, true);
     $criteria->compare('documentFileName', $this->documentFileName, true);
     $criteria->compare('documentFileType', $this->documentFileType, true);
     $criteria->compare('image', $this->image, true);
     $criteria->compare('imageFileName', $this->imageFileName, true);
     $criteria->compare('imageFileType', $this->imageFileType, true);
     $criteria->compare('enable_financial', $this->enable_financial, true);
     $criteria->compare('available_on_loan', $this->available_on_loan, true);
     $criteria->compare('has_microphone', $this->has_microphone, true);
     $criteria->compare('has_speaker', $this->has_speaker, true);
     $criteria->compare('has_subD', $this->has_subD, true);
     $criteria->compare('has_BNC', $this->has_BNC, true);
     $criteria->compare('has_DVI', $this->has_DVI, true);
     $criteria->compare('has_pivot', $this->has_pivot, true);
     $criteria->compare('has_HDMI', $this->has_HDMI, true);
     $criteria->compare('has_displayport', $this->has_displayport, true);
     $criteria->compare('is_deleted', $this->is_deleted);
     $criteria->addCondition("is_deleted = 0");
     $criteria->addNotInCondition('id', $blockeditemtableIds);
     if (isset($_GET['category_id'])) {
         $a = $_GET['category_id'];
         $criteria->addCondition("category_id = '{$a}'");
     }
     return new CActiveDataProvider($this, array('criteria' => $criteria, 'pagination' => false));
 }
コード例 #4
0
    <?php 
echo $form->errorSummary($model);
?>
    <?php 
$groupName = $_GET['groupName'];
?>
    
    <h1> Manage Group <span style="color:#B40431"><?php 
echo "{$groupName}";
?>
</h1>
    <?php 
echo "<br/>";
?>
                   <?php 
$this->widget('ext.multiselects.XMultiSelects', array('id' => 'listbuilder', 'leftTitle' => 'Group Users', 'leftName' => 'Usergroup[groupusers][]', 'leftList' => Usergroup::model()->findUsersByGroup($_GET['groupId']), 'rightTitle' => 'Other Users', 'rightName' => 'Usergroup[otherusers][]', 'rightList' => Usergroup::model()->findUsersNotInGroup($_GET['groupId']), 'size' => 20, 'width' => '200px'));
?>
               
    <div style="text-align: center;">
    <?php 
echo CHtml::submitButton('Update', array('submit' => array('usergroup/moveusers', 'groupId' => $_GET['groupId'])), array('color' => TbHtml::BUTTON_COLOR_SUCCESS, 'size' => TbHtml::BUTTON_SIZE_DEFAULT));
?>
    </div

    <?php 
$this->endWidget();
?>

</div><!-- form -->
コード例 #5
0
ファイル: _form.php プロジェクト: anjanababu/Asset-Management
/* @var $model Usergroup */
/* @var $form TbActiveForm */
?>

<div class="form">

    <?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'usergroup-form', 'enableAjaxValidation' => false));
?>

    <p class="help-block">Fields with <span class="required">*</span> are required.</p>

    <?php 
echo $form->errorSummary($model);
?>
                <?php 
$this->widget('ext.multiselects.XMultiSelects', array('leftTitle' => 'Group Users', 'leftName' => 'Usergroup[][1]', 'leftList' => Usergroup::model()->findUsersByGroup(1), 'rightTitle' => 'Other Users', 'rightName' => 'Usergroup[][1]', 'rightList' => Usergroup::model()->findUsersNotInGroup(1), 'size' => 20, 'width' => '200px'));
?>
    
    <div class="form-actions">
    <?php 
echo TbHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('color' => TbHtml::BUTTON_COLOR_PRIMARY, 'size' => TbHtml::BUTTON_SIZE_LARGE));
?>
    </div>

    <?php 
$this->endWidget();
?>

</div><!-- form -->
コード例 #6
0
?>
</option>
                </select>
            </li>
            <!-- added by Gaurang 2014-04-14 -->
            <li>
                <?php 
$Project_Manager = getGlobalSetting('Project_Manager');
?>
                <label for='Project_Manager'><?php 
$clang->eT("Select Project Manager User Group");
?>
</label>
                <?php 
//$project_manager = Contact_title::model()->findAll();
$project_manager = Usergroup::model()->findAll();
$project_manager_list = CHtml::listData($project_manager, 'ugid', 'name');
echo CHtml::dropDownList('Project_Manager', $Project_Manager, $project_manager_list, array('prompt' => 'Select Project Manager User Group'));
?>
            </li>
            <li>
                <?php 
$Own_Panel = getGlobalSetting('Own_Panel');
?>
                <label for='Own_Panel'><?php 
$clang->eT("Select Internal Company");
?>
</label>
                <?php 
//$own_panel = getCompanyDetail();
$sql = "SELECT * FROM {{view_company}} WHERE company_type LIKE '%V%'";
コード例 #7
0
ファイル: view.php プロジェクト: anjanababu/Asset-Management
</span>
<?php 
echo CHtml::link('<i class="icon-pencil"></i>', array('update', 'id' => $model->id), array('class' => 'btn-warning btn buttonDesign', 'title' => 'Update'));
echo CHtml::link('<i class="icon-trash"></i>', '#', array('class' => 'btn-warning btn buttonDesign', 'title' => 'Delete', 'submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?'));
?>
</h1>

<table>
    <tr><td>
<?php 
$this->widget('ext.DetailView4Col', array('htmlOptions' => array('class' => 'table table-striped table-condensed table-hover'), 'data' => $model, 'attributes' => array('name', 'password', 'organisation_id', 'pw_md5', 'email', 'phone', 'phones', 'mobile', 'fn', 'ln', 'active', 'id_auth', 'auth_method', 'last_login', 'date_mod', 'designation')));
?>
        </td>
        <td>
<?php 
$grps = Usergroup::model()->findAllByAttributes(array('uid' => $model->id));
$depts = Userdept::model()->findAllByAttributes(array('uid' => $model->id));
echo "<table class='table table-bordered'>";
if (count($depts) == 0) {
    echo "<tr style='background:#F7819F;color:white'><td>{$model->name} doesn't belong to any department</td></tr>";
} else {
    echo "<tr style='background:#F5A9A9;'><th colspan='2'>Departments</th></tr>";
    foreach ($depts as $d) {
        $department = Dept::model()->findByAttributes(array('id' => $d['dept_id']));
        $deptName = $department['name'];
        echo "<tr><td colspan='2'>{$deptName}</td></tr>";
    }
}
if (count($grps) == 0) {
    echo "<tr style='background:#F7819F;color:white'><td>{$model->name} doesn't belong to any group</td></tr>";
} else {
コード例 #8
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Usergroup::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #9
0
 /**
  * @param int $id the id (primary key) of person
  * @param int $gid
  */
 public function updateUserGroup($userId, $newGroupId, $flag)
 {
     if ($flag == 0) {
         // Remove
         $oldModel = Usergroup::model()->find(array('select' => 'id', 'condition' => 'uid =:uid AND gid =:gid', 'params' => array(':uid' => $userId, ':gid' => $newGroupId)));
         if (isset($oldModel['id'])) {
             Usergroup::model()->findByPk($oldModel['id'])->delete();
         }
     } else {
         if ($flag == 1) {
             //Add
             $newmodel = new Usergroup();
             $newmodel->gid = $newGroupId;
             $newmodel->uid = $userId;
             $newmodel->save();
         }
     }
 }
コード例 #10
0
 /**
  * Move users between Australia and New Zealand.
  * This method is used by XMultiSelects widget.
  */
 public function actionMoveUsers()
 {
     // 1. Delete the users which were already present but not present now
     // 2. Add new users
     // 3. Maintain the current user
     if (isset($_POST['Usergroup']['groupusers'])) {
         $presentGroupUsers = $_POST['Usergroup']['groupusers'];
         //contains uids
         foreach ($presentGroupUsers as $user) {
             //1. Check already a group member?
             $allreadyMember = Usergroup::model()->find('uid =:uid AND gid =:gid', array(':uid' => $user, ':gid' => $_GET['groupId']));
             if (!isset($allreadyMember['id'])) {
                 Usergroup::model()->updateUserGroup($user, $_GET['groupId'], 1);
             }
             //Add
         }
         //3. User Removed?
         $pgu = implode(',', $presentGroupUsers);
         $removedUsers = User::model()->findAll(array('select' => 'id', 'condition' => "id NOT IN({$pgu})"));
         if (count($removedUsers) == 0) {
         } else {
             foreach ($removedUsers as $user) {
                 // remove
                 $a = $user['id'];
                 Usergroup::model()->updateUserGroup($a, $_GET['groupId'], 0);
             }
         }
     }
     //Yii::app()->user->setFlash('saved',Yii::t('ui','Data successfully saved!'));
     $this->redirect(array('usergroup/admin'));
 }
コード例 #11
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)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         $model->pw_md5 = md5($_POST['User']['password']);
         if ($model->save()) {
             /* REMOVE PAST GRPS*/
             $pastGrps = Usergroup::model()->findAllByAttributes(array('uid' => $id));
             foreach ($pastGrps as $ug) {
                 $m = Usergroup::model()->findByPk($ug['id']);
                 $m->delete();
             }
             /* ADD NEW GRPS */
             if (isset($_POST['User']['g_id'])) {
                 $grps = $_POST['User']['g_id'];
                 foreach ($grps as $grp) {
                     $model1 = new Usergroup();
                     $model1->uid = $model->id;
                     $model1->gid = $grp;
                     $model1->save();
                 }
             }
             /* REMOVE PAST DEPTS*/
             $pastDepts = Userdept::model()->findAllByAttributes(array('uid' => $id));
             foreach ($pastDepts as $ud) {
                 $m = Userdept::model()->findByPk($ud['id']);
                 $m->delete();
             }
             /* ADD NEW DEPTS */
             if (isset($_POST['User']['dept_id'])) {
                 $depts = $_POST['User']['dept_id'];
                 foreach ($depts as $d) {
                     $model1 = new Userdept();
                     $model1->uid = $model->id;
                     $model1->dept_id = $d;
                     $model1->save();
                 }
             }
             $this->redirect(array('view', 'id' => $model->id));
         }
     } else {
         $grpsRow = Usergroup::model()->findAllByAttributes(array('uid' => $id));
         $grps = [];
         foreach ($grpsRow as $row) {
             $grps[] = $row['gid'];
         }
         $model->g_id = $grps;
         $deptsRow = Userdept::model()->findAllByAttributes(array('uid' => $id));
         $depts = [];
         foreach ($deptsRow as $row) {
             $depts[] = $row['dept_id'];
         }
         $model->dept_id = $depts;
     }
     $this->render('update', array('model' => $model));
 }