예제 #1
0
 public function getTeamListByUser($userid)
 {
     $teamlist = TeamMember::find()->where(['user_id' => $userid])->all();
     $teamid = [];
     foreach ($teamlist as $team) {
         $teamid[] = $team->team_id;
     }
     return $teamid;
 }
예제 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = TeamMember::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'team_id' => $this->team_id, 'user_id' => $this->user_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     return $dataProvider;
 }
예제 #3
0
파일: edit.php 프로젝트: vtdat/time_sheet
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use kartik\date\DatePicker;
use kartik\select2\Select2;
use frontend\models\Team;
use frontend\models\TeamMember;
/* @var $this yii\web\View */
/* @var $model app\models\User */
/* @var $form ActiveForm */
$this->title = 'Sửa Profile';
$this->params['breadcrumbs'][] = $this->title;
$user = $model;
$model->team = TeamMember::getTeamListByUser($id);
?>

<h1 style="text-align: center;"><?php 
echo Html::encode($this->title);
?>
</h1>

<div class="form-group row">
        <div ><?php 
echo Html::submitButton($model->role < 1 ? 'User' : 'Admin', ['class' => $model->role < 1 ? 'btn btn-default' : 'btn btn-primary']);
?>
</div>
</div>

    
예제 #4
0
use kartik\date\DatePicker;
use kartik\select2\Select2;
use frontend\models\TeamMember;
use frontend\models\Process;
?>

<?php 
$this->registerJs("\n    \$('.delete-button').click(function() {\n        var detail = \$(this).closest('.work-detail');    \n        detail.remove();\n    });\n");
?>

<?php 
$userid = Yii::$app->user->getId();
$teammember = TeamMember::findAll(['user_id' => $userid]);
$teamlist = [];
foreach ($teammember as $team) {
    $teamlist[$team->team_id] = TeamMember::getTeamName($team->team_id);
}
?>
<div class="work-form">
 
    <?php 
$form = ActiveForm::begin(['enableClientValidation' => false, 'id' => 'form-login', 'type' => ActiveForm::TYPE_INLINE, 'fieldConfig' => ['autoPlaceholder' => true, 'showErrors' => true]]);
?>
    <?php 
echo "<h2>Timesheet Date:</h2>";
?>
    
    <?php 
if (Yii::$app->session->hasFlash("NoModify")) {
    ?>
        <div class="alert alert-danger">Timesheet đã được Chấm điểm - Không thể add thêm</div>
예제 #5
0
파일: Team.php 프로젝트: vtdat/time_sheet
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTeamMembers()
 {
     return $this->hasMany(TeamMember::className(), ['team_id' => 'id']);
 }
예제 #6
0
 /**
  * Finds the TeamMember model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return TeamMember the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = TeamMember::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #7
0
파일: User.php 프로젝트: vtdat/time_sheet
 public function addTeam()
 {
     $addlist = [];
     $dellist = [];
     $teamlist = TeamMember::find()->where(['user_id' => $this->id])->all();
     foreach ($teamlist as $oldteam) {
         $flag = 0;
         foreach ($this->team as $i) {
             if ($oldteam->team_id == $i) {
                 $flag = 1;
             }
         }
         if ($flag == 0) {
             $dellist[] = $oldteam->team_id;
         }
     }
     foreach ($this->team as $newindex) {
         $flag = 0;
         foreach ($teamlist as $oldteam) {
             if ($oldteam->team_id == $newindex) {
                 $flag = 1;
             }
         }
         if ($flag == 0) {
             $addlist[] = $newindex;
         }
     }
     foreach ($addlist as $addindex) {
         $newteam = new TeamMember(['team_id' => $addindex, 'user_id' => $this->id]);
         $newteam->save();
     }
     foreach ($dellist as $delindex) {
         $deltarget = TeamMember::getObjectById($delindex, $this->id);
         $deltarget->delete();
     }
 }