Esempio n. 1
0
 public function actionIndex()
 {
     $model = new DengluForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $data = $_POST['DengluForm'];
         //print_r($data);die;
         $arr = Username::find()->where(['username' => $data['username']])->one();
         if ($arr) {
             if ($data['password'] == $arr['password']) {
                 $session = Yii::$app->session;
                 $session['user'] = ['id' => $arr['id'], 'username' => $arr['username']];
                 return $this->render('index');
             } else {
                 $aa['error'] = 1;
                 $aa['type'] = "<font color='red'>密码错误</font> 登录";
                 return $this->render('success', array('data' => $aa));
             }
         } else {
             $aa['error'] = 1;
             $aa['type'] = "<font color='red'>没有此用户</font> 登录";
             return $this->render('success', array('data' => $aa));
         }
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
Esempio n. 2
0
    function actionIndex()
    {
        //cari nama username yg buat tugas project
        $sql = 'SELECT username.username from username inner join tugas on (username.id_user = tugas.id_user)
				order by tugas.id_user DESC';
        $model = Username::findBySql($sql)->all();
        //cari nama tugas + jumlah user + finished working
        $sql1 = 'SELECT tugas.nama_tugas, tugas.tgl_mulai, tugas.tgl_akhir, count(bagi_tugas.id_tugas) as total_user, 
				count(bagi_tugas.tgl_selesai) as finished_working
				from tugas left outer join bagi_tugas on (tugas.id_tugas = bagi_tugas.id_tugas) 
				group by tugas.id_tugas order by tugas.id_tugas DESC';
        $model1 = Tugas::findBySql($sql1)->all();
        return $this->render('index', ['model' => $model, 'model1' => $model1]);
    }
Esempio n. 3
0
$form = ActiveForm::begin();
?>
		
		<b>Nama User : </b>
		<?php 
if ($model2->total_user != 0) {
    $sql = "SELECT * from username where id_user not in ({$join}) order by username ASC";
    ?>
			<?php 
    echo Html::activeDropDownList($model, 'id_user', ArrayHelper::map(Username::findBySql($sql)->all(), 'id_user', 'username'));
    ?>
		<?php 
} else {
    ?>
				<?php 
    echo Html::activeDropDownList($model, 'id_user', ArrayHelper::map(Username::find()->all(), 'id_user', 'username'));
    ?>
		<?php 
}
?>
		
		<p style='margin-bottom:5px'>&nbsp;</p>
		
		<div style='display:none'><?php 
echo $form->field($model, 'id_bagi_tugas')->textInput(['value' => $model5->max_id]);
?>
</div>
		<?php 
echo $form->field($model, 'pembagian_tugas')->textInput();
?>
	
Esempio n. 4
0
 public function actionLihat($id)
 {
     $model = $this->findModel($id);
     //cari nama username yg buat tugas project
     $sql = "SELECT id_user from tugas where id_tugas = {$id}";
     $model = Tugas::findBySql($sql)->one();
     $idUser = $model->id_user;
     $sql1 = "SELECT username, id_user from username where id_user = {$idUser}";
     $model1 = Username::findBySql($sql1)->one();
     //echo $model1->username;
     //cari nama tugas + jumlah user + finished working
     $sql2 = "SELECT tugas.id_tugas, tugas.nama_tugas, tugas.tgl_mulai, tugas.tgl_akhir, count(bagi_tugas.id_tugas) as total_user, \n\t\t\t\tcount(bagi_tugas.tgl_selesai) as finished_working\n\t\t\t\tfrom tugas left outer join bagi_tugas on (tugas.id_tugas = bagi_tugas.id_tugas) where tugas.id_tugas = {$id}\n\t\t\t\tgroup by tugas.id_tugas order by tugas.id_tugas DESC";
     $model2 = Tugas::findBySql($sql2)->one();
     //dapetin id_user di tabel bagi_tugas
     $sql3 = "SELECT * from bagi_tugas where id_tugas = {$id} order by id_user ASC";
     $model3 = Bagitugas::findBySql($sql3)->all();
     $list_user = array();
     $i = 0;
     foreach ($model3 as $data) {
         $list_user[$i] = $data->id_user;
         $i++;
     }
     //dapetin username di tabel username
     if (count($list_user) != 0) {
         $join = join(',', $list_user);
         $sql4 = "SELECT * from username where id_user in ({$join}) order by id_user ASC";
         $model4 = Username::findBySql($sql4)->all();
     } else {
         $join = null;
         $model4 = 0;
         //belum ada username di bagi_tugas
     }
     //maksimal id_bagi_tugas
     $sql5 = "SELECT max(id_bagi_tugas)+1 as max_id from bagi_tugas";
     $model5 = Bagitugas::findBySql($sql5)->one();
     $model5->max_id;
     $model = new Bagitugas();
     //save user ke bagi_tugas
     if ($model->load(Yii::$app->request->post())) {
         $model['tgl_selesai'] = null;
         if ($model->save()) {
             echo "\n\t\t\t\t<script>alert('berhasil ditambah');\n\t\t\t\twindow.location.href = 'index.php?r=site/lihat&id={$model['id_tugas']}';\n\t\t\t\t</script>";
             //return $this->redirect("index.php?r=site/lihat&id=$model[id_tugas]");
         }
     } else {
         //default loading
         return $this->render('lihat', ['model1' => $model1, 'model2' => $model2, 'model3' => $model3, 'model4' => $model4, 'model5' => $model5, 'join' => $join, 'model' => $model]);
     }
 }
Esempio n. 5
0
 /**
  * Finds the Username model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Username the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Username::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }