/**
  * Edit usertype
  *
  * @return Response
  */
 public function editUserType(Request $request)
 {
     //Validate the Request
     $this->validate($request, ['id' => 'numeric', 'name' => 'required|unique:user_types|max:255']);
     $ut = UserType::find($request->id);
     $ut->name = $request->name;
     $ut->save();
     return Redirect::to('admin/usertype');
 }
示例#2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = UserType::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['UserTypeID' => $this->UserTypeID]);
     $query->andFilterWhere(['like', 'UserTypeDescription', $this->UserTypeDescription]);
     return $dataProvider;
 }
示例#3
0
 /**
  * Updates an existing User model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $userTypes = ArrayHelper::map(\app\models\UserType::find()->all(), 'user_type_id', 'user_type');
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->user_id]);
     } else {
         return $this->render('update', ['model' => $model, 'userTypes' => $userTypes]);
     }
 }
示例#4
0
 public function actionUserform($id = null)
 {
     $user = new \app\models\User();
     if (!empty($id)) {
         $user = \app\models\User::find()->where(['id' => $id])->one();
     }
     $post = Yii::$app->request->post();
     if (!empty($post)) {
         $user->branch_id = $post['User']['branch_id'];
         $user->user_type_id = $post['User']['user_type_id'];
         $user->fname = $post['User']['fname'];
         $user->lname = $post['User']['lname'];
         $user->usr = $post['User']['usr'];
         $user->pwd = $post['User']['pwd'];
         $user->tel = $post['User']['tel'];
         $user->email = $post['User']['email'];
         $user->status = 'use';
         $user->created_at = new \yii\db\Expression('NOW()');
         if ($user->save()) {
             return $this->redirect(['user']);
         }
     }
     $branchs = \app\models\Branch::find()->all();
     $userTypes = \app\models\UserType::find()->all();
     $branchIds = \yii\helpers\ArrayHelper::map($branchs, 'id', 'name');
     $userTypeIds = \yii\helpers\ArrayHelper::map($userTypes, 'id', 'name');
     return $this->render('//config/user_form', ['user' => $user, 'branchIds' => $branchIds, 'userTypeIds' => $userTypeIds]);
 }
示例#5
0

<!-- 
<?php 
echo Html::a("Create user type", Yii::$app->urlManager->createUrl(['security/create-user-type']), ["class" => ["btn", "btn-primary"]]);
?>
<table border = "1" style="border-collapse:collapse">
	<tr>
		<th>No</th>
		<th>User Type Name</th>
		<th>Role Name</th>
		<th>Action</th>
	</tr>
<?php 
$i = 1;
foreach (UserType::find()->with('role0')->asArray()->all() as $key => $value) {
    ?>
	<tr>
		<td><?php 
    echo $i;
    ?>
</td>
		<td><?php 
    echo $value['name'];
    ?>
</td>
		<td><?php 
    echo $value['role0']['name'];
    ?>
</td>
		<td>
示例#6
0
	<div class="form-group">
		<div class="col-lg-offset-1 col-lg-11">
			<?php 
echo Html::input("text", "sec_answer", "autocom", ["required" => "required"]);
?>
		</div>
	</div>

	<label>User type will be attached</label>

	<div class="form-group">
		<div class="col-lg-offset-1 col-lg-11">
			<ul>
			<?php 
foreach (UserType::find()->asArray()->all() as $key => $value) {
    echo "<li>";
    echo Html::radio("user_type", false, ["label" => $value["name"], "value" => $value["id"]]);
    echo "</li>";
}
?>
			</ul>
		</div>
	</div>

	<div class="form-group">
		<div class="col-lg-offset-1 col-lg-11">
			<?php 
echo Html::submitButton('Save', ['class' => 'btn btn-primary']);
?>
		</div>
示例#7
0
文件: _form.php 项目: abutouq/video
</div>
    </div>
    <div class="row">
        <div class="col-lg-6"> <?php 
echo $form->field($contactModel, 'phone_number')->textInput();
?>
</div>
        <div class="col-lg-6"> <?php 
echo $form->field($contactModel, 'fax')->textInput();
?>
</div>
    </div>
    <div class="row">
        <div class="col-lg-6">
            <?php 
echo $form->field($model, 'users_types_id')->dropDownList(ArrayHelper::map(UserType::find()->all(), 'id', 'type_name'), ['prompt' => 'Select user type']);
?>
        </div>
        <div class="col-lg-6">
            <?php 
echo $form->field($model, 'country_id')->widget(Select2::classname(), ['name' => 'state_12', 'theme' => Select2::THEME_DEFAULT, 'data' => Country::getAllCountries(), 'options' => ['placeholder' => 'Select a state ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-6">
            <?php 
echo $form->field($model, 'start_date')->widget(DatePicker::className(), ['type' => DatePicker::TYPE_COMPONENT_APPEND, 'pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']]);
?>
        </div>
        <div class="col-lg-6">
示例#8
0
<?php

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use app\models\Role;
use app\models\UserType;
$myUserType = UserType::find()->where(['id' => Yii::$app->request->get()['id']])->asArray()->one();
?>




<div class="col-md-12">
    <div class="widget widget-green">
        <div class="widget-title">
            <div class="widget-controls">
				<a href="#" class="widget-control widget-control-full-screen" data-toggle="tooltip" data-placement="top" title="" data-original-title="Full Screen"><i class="fa fa-expand"></i></a>
				<a href="#" class="widget-control widget-control-full-screen widget-control-show-when-full" data-toggle="tooltip" data-placement="left" title="" data-original-title="Exit Full Screen"><i class="fa fa-expand"></i></a>
				<a href="#" class="widget-control widget-control-refresh" data-toggle="tooltip" data-placement="top" title="" data-original-title="Refresh"><i class="fa fa-refresh"></i></a>
				<a href="#" class="widget-control widget-control-minimize" data-toggle="tooltip" data-placement="top" title="" data-original-title="Minimize"><i class="fa fa-minus-circle"></i></a>
			</div>
            <h3><i class="fa fa-ok-circle"></i>Update user type for<i><b><?php 
echo $myUserType['name'];
?>
</b></i></h3>
        </div>
			<div class="widget-content">
				<div class="row">
					<div class="col-md-12">
						
						<?php