Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Process::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, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'process_name', $this->process_name]);
     return $dataProvider;
 }
Example #2
0
if (Yii::$app->session->hasFlash('updateOK')) {
    ?>
<div class="alert alert-success">
    Updated successfully!
</div>
<?php 
}
?>


<br />

<?php 
$gridColumns = [['class' => '\\kartik\\grid\\SerialColumn'], ['label' => 'Work Time', 'attribute' => 'work_time', 'value' => function ($data) {
    return $data->work_time . ' hour(s)';
}, 'mergeHeader' => true, 'hAlign' => GridView::ALIGN_CENTER, 'mergeHeader' => true], ['label' => 'Team', 'attribute' => 'team.team_name', 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Team::find()->orderBy('team_name')->asArray()->all(), 'team_name', 'team_name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true], 'options' => ['placeholder' => 'Team']], 'mergeHeader' => true], ['label' => 'Process', 'attribute' => 'process.process_name', 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Process::find()->orderBy('process_name')->asArray()->all(), 'process_name', 'process_name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true], 'options' => ['placeholder' => 'Process']], 'mergeHeader' => true], ['label' => 'Work Details', 'attribute' => 'work_name', 'mergeHeader' => true], ['label' => 'Comment', 'attribute' => 'comment', 'mergeHeader' => true]];
?>

<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $gridColumns, 'hover' => true, 'striped' => false, 'headerRowOptions' => ['style' => 'color: black; background: #eee; border-color: #337ab7;']]);
?>

<?php 
if ($model->user_id === Yii::$app->user->identity->id) {
    ?>
    
<div class="form-group" style="text-align: right;">
    <?php 
    echo Html::a('<span class="glyphicon glyphicon-pencil"></span> Edit', 'index.php?r=timesheet/update&id=' . $model->id, ['class' => $model->status ? 'btn btn-primary disabled' : 'btn btn-primary']);
    ?>
    <?php 
Example #3
0
?>
    
    <?php 
foreach ($modelDetails as $i => $modelDetail) {
    ?>
        <div class="row work-detail work-detail-<?php 
    echo $i;
    ?>
">
            <div class="col-md-2" style="width: auto"><?php 
    echo $form->field($modelDetail, "[{$i}]team_id")->widget(Select2::className(), ['theme' => 'bootstrap', 'data' => $teamlist, 'options' => ['placeholder' => 'Select team'], 'pluginOptions' => ['allowClear' => true]]);
    ?>
</div>
            <div class="col-md-2">
                <?php 
    echo $form->field($modelDetail, "[{$i}]process_id")->dropDownList(ArrayHelper::map(Process::find()->all(), 'id', 'process_name'), ['prompt' => 'Select Process']);
    ?>
            </div>
            
            <div class="col-md-2"><?php 
    echo $form->field($modelDetail, "[{$i}]work_name")->textInput();
    ?>
</div>
            <div class="col-md-2"><?php 
    echo $form->field($modelDetail, "[{$i}]work_time")->textInput();
    ?>
</div>
            <div class="col-md-2"><?php 
    echo $form->field($modelDetail, "[{$i}]comment")->textInput();
    ?>
</div>
Example #4
0
use kartik\grid\ExpandRowColumn;
use common\models\User;
use frontend\models\Process;
use frontend\models\Timesheet;
use frontend\models\Team;
/* @var $this yii\web\View */
/* @var $searchModel frontend\models\WorkSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'HBLab Timesheets';
$this->params['breadcrumbs'][] = $this->title;
$formatter = Yii::$app->formatter;
?>
<div class="work-index container-fluid">

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

    <?php 
$gridColumns = [['attribute' => 'timesheet.date', 'format' => 'date', 'group' => true, 'groupOddCssClass' => false, 'groupEvenCssClass' => false, 'width' => '13em', 'filterType' => GridView::FILTER_DATE, 'filterWidgetOptions' => ['pluginOptions' => ['autoClose' => true, 'format' => 'yyyy-mm-dd'], 'removeButton' => false], 'hAlign' => GridView::ALIGN_CENTER], ['label' => 'User', 'attribute' => 'user.full_name', 'width' => '15em', 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(User::find()->orderBy('full_name')->asArray()->all(), 'full_name', 'full_name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true], 'options' => ['placeholder' => 'Full name']], 'group' => true, 'subGroupOf' => 0], ['attribute' => 'work_time', 'value' => function ($data) {
    return $data->work_time . ' hour(s)';
}, 'width' => '2em', 'mergeHeader' => true, 'hAlign' => GridView::ALIGN_CENTER], ['label' => 'Team', 'attribute' => 'team.team_name', 'width' => '5em', 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Team::find()->orderBy('team_name')->asArray()->all(), 'team_name', 'team_name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true], 'options' => ['placeholder' => 'Team']]], ['label' => 'Process', 'attribute' => 'process.process_name', 'width' => '9em', 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Process::find()->orderBy('process_name')->asArray()->all(), 'process_name', 'process_name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true], 'options' => ['placeholder' => 'Process']]], ['label' => 'Work Details', 'attribute' => 'work_name', 'mergeHeader' => true], ['label' => 'Comment', 'attribute' => 'comment', 'mergeHeader' => true], ['label' => 'Point', 'attribute' => 'timesheet.point', 'group' => true, 'groupOddCssClass' => false, 'groupEvenCssClass' => false, 'subGroupOf' => 1, 'width' => '2.2em', 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Timesheet::find()->orderBy('point')->asArray()->all(), 'point', 'point'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true], 'options' => ['placeholder' => 'Point']], 'hAlign' => GridView::ALIGN_CENTER], ['label' => 'Director Comment', 'attribute' => 'timesheet.director_comment', 'group' => true, 'groupOddCssClass' => false, 'groupEvenCssClass' => false, 'subGroupOf' => 1, 'mergeHeader' => true]];
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $gridColumns, 'hover' => TRUE, 'striped' => FALSE, 'rowOptions' => function ($model, $key, $index, $grid) {
    return ['id' => $model['timesheet_id'], 'onclick' => 'window.location.href = "index.php?r=timesheet/view&id="+this.id;'];
}, 'panel' => ['heading' => '<span class="glyphicon glyphicon-list-alt"></span>', 'type' => GridView::TYPE_DEFAULT], 'toolbar' => [['content' => Html::a('<i class="glyphicon glyphicon-plus"></i> Create', ['work/create2', 'id' => Yii::$app->user->identity->id], ['class' => 'btn btn-success'])], '{toggleData}', '{export}'], 'export' => ['fontAwesome' => false, 'label' => 'Export']]);
?>
</div>
Example #5
0
use kartik\editable\Editable;
use common\models\User;
use frontend\models\Process;
use frontend\models\Timesheet;
use frontend\models\Team;
/* @var $this yii\web\View */
/* @var $searchModel frontend\models\WorkSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Chấm điểm timesheet';
$this->params['breadcrumbs'][] = $this->title;
$formatter = Yii::$app->formatter;
?>
<div class="work-index container-fluid">

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

    <?php 
$gridColumns = [['attribute' => 'timesheet.date', 'format' => 'date', 'group' => true, 'groupOddCssClass' => false, 'groupEvenCssClass' => false, 'width' => '13em', 'filterType' => GridView::FILTER_DATE, 'filterWidgetOptions' => ['pluginOptions' => ['autoClose' => true, 'format' => 'yyyy-mm-dd'], 'removeButton' => false], 'hAlign' => GridView::ALIGN_CENTER], ['label' => 'User', 'attribute' => 'user.full_name', 'width' => '15em', 'group' => true, 'subGroupOf' => 0, 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(User::find()->orderBy('full_name')->asArray()->all(), 'full_name', 'full_name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true], 'options' => ['placeholder' => 'Full name']]], ['attribute' => 'work_time', 'value' => function ($data) {
    return $data->work_time . ' hour(s)';
}, 'width' => '2em', 'mergeHeader' => true, 'hAlign' => GridView::ALIGN_CENTER], ['label' => 'Team', 'attribute' => 'team.team_name', 'width' => '5em', 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Team::find()->orderBy('team_name')->asArray()->all(), 'team_name', 'team_name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true], 'options' => ['placeholder' => 'Team']]], ['label' => 'Process', 'attribute' => 'process.process_name', 'width' => '9em', 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Process::find()->orderBy('process_name')->asArray()->all(), 'process_name', 'process_name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true], 'options' => ['placeholder' => 'Process']]], ['label' => 'Work Details', 'attribute' => 'work_name', 'mergeHeader' => true], ['label' => 'Comment', 'attribute' => 'comment', 'mergeHeader' => true], ['class' => 'kartik\\grid\\EditableColumn', 'label' => 'Point', 'attribute' => 'timesheet.point', 'group' => true, 'groupOddCssClass' => false, 'groupEvenCssClass' => false, 'subGroupOf' => 1, 'width' => '2.2em', 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Timesheet::find()->orderBy('point')->asArray()->all(), 'point', 'point'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true], 'options' => ['placeholder' => 'Point']], 'hAlign' => GridView::ALIGN_CENTER, 'editableOptions' => ['header' => 'điểm', 'inputType' => \kartik\editable\Editable::INPUT_TEXT, 'format' => Editable::FORMAT_BUTTON, 'valueIfNull' => '<em style="color:red">Chưa chấm !</em>', 'preHeader' => '<i class="glyphicon glyphicon-edit"></i> Chấm ', 'type' => 'danger', 'placement' => 'left', 'options' => ['placeholder' => 'Chấm điểm ở đây']]], ['class' => 'kartik\\grid\\EditableColumn', 'label' => 'Director Comment', 'attribute' => 'timesheet.director_comment', 'group' => true, 'groupOddCssClass' => false, 'groupEvenCssClass' => false, 'subGroupOf' => 1, 'mergeHeader' => true, 'editableOptions' => ['header' => 'comment', 'inputType' => \kartik\editable\Editable::INPUT_TEXTAREA, 'valueIfNull' => '<em style="color:red">Chưa comment !</em>', 'preHeader' => '<i class="glyphicon glyphicon-edit"></i> Viết ', 'editableValueOptions' => ['style' => 'color: blue'], 'type' => 'warning', 'size' => 'lg', 'placement' => 'left', 'options' => ['placeholder' => 'Viết comment vào đây']]]];
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $gridColumns, 'hover' => TRUE, 'striped' => FALSE]);
?>
    
</div>
Example #6
0
 public function actionCreate2()
 {
     $formatter = Yii::$app->formatter;
     $work = new Work();
     $timesheet = new Timesheet();
     $isUpdated = false;
     $isCreated = false;
     if (Yii::$app->request->post()) {
         $formAttributes = Yii::$app->request->post('createForm');
         $date = $formAttributes['date'];
         $availTimesheet = Timesheet::find()->where(['date' => $date, 'user_id' => Yii::$app->user->identity->id])->one();
         if ($availTimesheet) {
             // timesheet is available
             if ($availTimesheet->status) {
                 Yii::$app->session->setFlash('CreateTimesheetFailed');
                 return $this->render('create');
             }
             $work->timesheet_id = $availTimesheet->id;
             $availTimesheet->updated_at = time();
             if ($availTimesheet->update()) {
                 $isUpdated = true;
             }
         } else {
             $timesheet->created_at = time();
             $timesheet->updated_at = time();
             $timesheet->date = $date;
             $timesheet->user_id = Yii::$app->user->identity->id;
             $timesheet->point = 0;
             $timesheet->director_comment = '';
             $timesheet->status = 0;
             if ($timesheet->save()) {
                 $isCreated = true;
             }
         }
         if ($isUpdated || $isCreated && ($work->timesheet_id = $timesheet->id)) {
             $process = Process::find()->where(['process_name' => $formAttributes['process_name']])->one();
             $team = Team::find()->where(['team_name' => $formAttributes['team_name']])->one();
             $work->process_id = $process->id;
             $work->team_id = $team->id;
             $work->work_time = $formAttributes['work_time'];
             $work->work_name = $formAttributes['work_name'];
             $work->comment = $formAttributes['comment'];
             $work->created_at = time();
             $work->updated_at = time();
             if ($work->save()) {
                 return $this->goBack();
             } else {
                 return $this->render('create');
             }
         }
     }
     return $this->render('create');
 }
Example #7
0
use frontend\models\TeamMember;
use common\models\User;
/* @var $this yii\web\View */
/* @var $model app\models\Timesheet */
$formatter = Yii::$app->formatter;
$this->title = $formatter->asDate($model->date, 'medium');
?>
<div class="timesheet-update">

<h1 style="text-align: center;"><?php 
echo Html::encode($this->title);
?>
</h1>
<br /><br /><br />
<?php 
$form = ActiveForm::begin();
echo TabularForm::widget(['form' => $form, 'dataProvider' => $dataProvider, 'attributes' => ['id' => ['type' => TabularForm::INPUT_TEXT, 'columnOptions' => ['hidden' => true]], 'work_time' => ['type' => TabularForm::INPUT_TEXT, 'label' => 'Work Time (hours)', 'columnOptions' => ['width' => '3em']], 'process_id' => ['type' => TabularForm::INPUT_WIDGET, 'widgetClass' => 'kartik\\widgets\\Select2', 'options' => ['data' => ArrayHelper::map(Process::find()->orderBy('process_name')->asArray()->all(), 'id', 'process_name')], 'label' => 'Process', 'columnOptions' => ['hAlign' => 'center', 'width' => '10em']], 'team_id' => ['type' => TabularForm::INPUT_WIDGET, 'widgetClass' => 'kartik\\widgets\\Select2', 'label' => 'Team', 'options' => ['data' => ArrayHelper::map(User::getUserTeams(Yii::$app->user->identity->id), 'id', 'team_name')], 'columnOptions' => ['hAlign' => 'center']], 'work_name' => ['type' => TabularForm::INPUT_TEXT, 'label' => 'Work Details', 'columnOptions' => ['hAlign' => 'center', 'width' => '15em']], 'comment' => ['type' => TabularForm::INPUT_TEXTAREA, 'label' => 'Comment', 'columnOptions' => ['hAlign' => 'center']]]]);
?>

<div class="form-group" style="text-align: right; margin-top: 20px;">
	<?php 
echo Html::submitButton('Save', ['class' => 'btn btn-success']);
?>
</div>

<?php 
ActiveForm::end();
?>

</div>
Example #8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProcess()
 {
     return $this->hasOne(Process::className(), ['id' => 'process_id']);
 }
Example #9
0
echo Html::encode($this->title);
?>
</h1>

<?php 
if (Yii::$app->session->hasFlash('CreateTimesheetFailed')) {
    ?>
<div class="alert alert-danger">
	Cannot create/update timesheet because it has been marked!
</div>
<?php 
}
?>

<?php 
echo Form::widget(['formName' => 'createForm', 'form' => $form, 'columns' => 6, 'columnOptions' => ['colSpan' => 2], 'autoGenerateColumns' => false, 'attributes' => ['date' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => 'kartik\\widgets\\DatePicker', 'options' => ['pluginOptions' => ['format' => 'yyyy-mm-dd', 'autoClose' => true], 'removeButton' => false]], 'work_time' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Work time (hours)']], 'process_name' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\widgets\\Select2', 'options' => ['options' => ['placeholder' => 'Process'], 'data' => ArrayHelper::map(Process::find()->orderBy('process_name')->asArray()->all(), 'process_name', 'process_name')]], 'team_name' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\widgets\\Select2', 'options' => ['options' => ['placeholder' => 'Team'], 'data' => ArrayHelper::map(User::getUserTeams(Yii::$app->user->identity->id), 'team_name', 'team_name')]], 'work_name' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Work details']], 'comment' => ['type' => Form::INPUT_TEXTAREA, 'options' => ['placeholder' => 'Comment something']]]]);
?>

<div class="form-group">
	<?php 
echo Html::resetButton('Reset', ['class' => 'btn btn-primary']);
?>
	<?php 
echo Html::submitButton('Create', ['class' => 'btn btn-success']);
?>
	
</div>


<?php 
ActiveForm::end();
Example #10
0
 /**
  * Finds the Process model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Process the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Process::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }