Commit a0dd962c by Andre Sihombing

Membuat fungsi database masuk ke tabel gaji

parent 9618f851
......@@ -118,4 +118,48 @@ class GajiController extends Controller
throw new NotFoundHttpException('The requested page does not exist.');
}
}
public function actionImport(){
$modelImport = new \yii\base\DynamicModel([
'fileImport'=>'File Import',
]);
$modelImport->addRule(['fileImport'],'required');
$modelImport->addRule(['fileImport'],'file',['extensions'=>'ods,xls,xlsx'],['maxSize'=>1024*1024]);
if(Yii::$app->request->post()){
$modelImport->fileImport = \yii\web\UploadedFile::getInstance($modelImport,'fileImport');
if($modelImport->fileImport && $modelImport->validate()){
$inputFileType = \PHPExcel_IOFactory::identify($modelImport->fileImport->tempName);
$objReader = \PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($modelImport->fileImport->tempName);
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
$baseRow = 2;
while(!empty($sheetData[$baseRow]['A'])){
$model = new \backend\modules\ubux\models\Gaji;
$model->tanggal_scan = (string)$sheetData[$baseRow]['A'];
$model->tanggal = (string)$sheetData[$baseRow]['B'];
$model->jam = (string)$sheetData[$baseRow]['C'];
$model->pin = (string)$sheetData[$baseRow]['D'];
$model->nip = (string)$sheetData[$baseRow]['E'];
$model->nama = (string)$sheetData[$baseRow]['F'];
$model->jabatan = (string)$sheetData[$baseRow]['G'];
$model->departemen = (string)$sheetData[$baseRow]['H'];
$model->kantor = (string)$sheetData[$baseRow]['I'];
$model->verifikasi = (string)$sheetData[$baseRow]['J'];
$model->i_o = (string)$sheetData[$baseRow]['K'];
$model->workcode = (string)$sheetData[$baseRow]['L'];
$model->mesin = (string)$sheetData[$baseRow]['M'];
$model->save();
$baseRow++;
}
Yii::$app->getSession()->setFlash('success','Success');
}else{
Yii::$app->getSession()->setFlash('error','Error');
}
}
return $this->render('import',[
'modelImport' => $modelImport,
]);
}
}
......@@ -3,7 +3,9 @@
namespace backend\modules\ubux\controllers;
use Yii;
use yii\data\ActiveDataProvider;
use backend\modules\ubux\models\Satpam;
use backend\modules\ubux\models\Pegawai;
use backend\modules\ubux\models\search\SatpamSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
......@@ -118,4 +120,13 @@ class SatpamController extends Controller
throw new NotFoundHttpException('The requested page does not exist.');
}
}
public function showPegawai()
{ $dataProvider = new ActiveDataProvider([
'query' => Pegawai::find(),
]);
return $dataProvider;
}
}
......@@ -18,6 +18,13 @@ use common\behaviors\DeleteBehavior;
* @property integer $pin
* @property integer $nip
* @property string $nama
* @property string $jabatan
* @property string $departemen
* @property string $kantor
* @property integer $verifikasi
* @property integer $i_o
* @property integer $workcode
* @property string $mesin
* @property integer $deleted
* @property string $deleted_at
* @property string $deleted_by
......@@ -26,9 +33,10 @@ use common\behaviors\DeleteBehavior;
* @property string $updated_at
* @property string $updated_by
* @property integer $jam_kerja_id
* @property integer $laporan_id
*
* @property UbuxJamKerja $jamKerja
* @property UbuxLaporan[] $ubuxLaporans
* @property UbuxLaporan $laporan
*/
class Gaji extends \yii\db\ActiveRecord
{
......@@ -37,7 +45,7 @@ class Gaji extends \yii\db\ActiveRecord
* behaviour to add created_at and updatet_at field with current datetime (timestamp)
* and created_by and updated_by field with current user id (blameable)
*/
/*public function behaviors(){
public function behaviors(){
return [
'timestamp' => [
'class' => TimestampBehavior::className(),
......@@ -49,7 +57,7 @@ class Gaji extends \yii\db\ActiveRecord
'class' => DeleteBehavior::className(),
]
];
}*/
}
/**
* @inheritdoc
......@@ -65,12 +73,13 @@ class Gaji extends \yii\db\ActiveRecord
public function rules()
{
return [
[['tanggal_scan', 'tanggal', 'jam', 'pin', 'nip', 'nama'], 'required'],
[['tanggal_scan', 'tanggal', 'jam', 'pin', 'nip', 'nama', 'jabatan', 'verifikasi', 'i_o', 'workcode', 'mesin'], 'required'],
[['tanggal_scan', 'tanggal', 'jam', 'deleted_at', 'created_at', 'updated_at'], 'safe'],
[['pin', 'nip', 'deleted', 'jam_kerja_id'], 'integer'],
[['nama'], 'string', 'max' => 45],
[['pin', 'nip', 'verifikasi', 'i_o', 'workcode', 'deleted', 'jam_kerja_id', 'laporan_id'], 'integer'],
[['nama', 'jabatan', 'departemen', 'kantor', 'mesin'], 'string', 'max' => 45],
[['deleted_by', 'created_by', 'updated_by'], 'string', 'max' => 32],
[['jam_kerja_id'], 'exist', 'skipOnError' => true, 'targetClass' => JamKerja::className(), 'targetAttribute' => ['jam_kerja_id' => 'jam_kerja_id']]
[['jam_kerja_id'], 'exist', 'skipOnError' => true, 'targetClass' => JamKerja::className(), 'targetAttribute' => ['jam_kerja_id' => 'jam_kerja_id']],
[['laporan_id'], 'exist', 'skipOnError' => true, 'targetClass' => Laporan::className(), 'targetAttribute' => ['laporan_id' => 'laporan_id']]
];
}
......@@ -87,6 +96,13 @@ class Gaji extends \yii\db\ActiveRecord
'pin' => 'Pin',
'nip' => 'Nip',
'nama' => 'Nama',
'jabatan' => 'Jabatan',
'departemen' => 'Departemen',
'kantor' => 'Kantor',
'verifikasi' => 'Verifikasi',
'i_o' => 'I O',
'workcode' => 'Workcode',
'mesin' => 'Mesin',
'deleted' => 'Deleted',
'deleted_at' => 'Deleted At',
'deleted_by' => 'Deleted By',
......@@ -95,6 +111,7 @@ class Gaji extends \yii\db\ActiveRecord
'updated_at' => 'Updated At',
'updated_by' => 'Updated By',
'jam_kerja_id' => 'Jam Kerja ID',
'laporan_id' => 'Laporan ID',
];
}
......@@ -109,8 +126,8 @@ class Gaji extends \yii\db\ActiveRecord
/**
* @return \yii\db\ActiveQuery
*/
public function getUbuxLaporans()
public function getLaporan()
{
return $this->hasMany(UbuxLaporan::className(), ['gaji_id' => 'gaji_id']);
return $this->hasOne(UbuxLaporan::className(), ['laporan_id' => 'laporan_id']);
}
}
......@@ -22,7 +22,7 @@ use common\behaviors\DeleteBehavior;
* @property string $updated_at
* @property string $updated_by
*
* @property UbuxGaji $gaji
* @property UbuxGaji[] $ubuxGajis
*/
class Laporan extends \yii\db\ActiveRecord
{
......@@ -31,7 +31,7 @@ class Laporan extends \yii\db\ActiveRecord
* behaviour to add created_at and updatet_at field with current datetime (timestamp)
* and created_by and updated_by field with current user id (blameable)
*/
/* public function behaviors(){
public function behaviors(){
return [
'timestamp' => [
'class' => TimestampBehavior::className(),
......@@ -43,7 +43,7 @@ class Laporan extends \yii\db\ActiveRecord
'class' => DeleteBehavior::className(),
]
];
}*/
}
/**
* @inheritdoc
......@@ -63,8 +63,7 @@ class Laporan extends \yii\db\ActiveRecord
[['gaji_id', 'deleted'], 'integer'],
[['deleted_at', 'created_at', 'updated_at'], 'safe'],
[['bulan_laporan'], 'string', 'max' => 45],
[['deleted_by', 'created_by', 'updated_by'], 'string', 'max' => 32],
[['gaji_id'], 'exist', 'skipOnError' => true, 'targetClass' => Gaji::className(), 'targetAttribute' => ['gaji_id' => 'gaji_id']]
[['deleted_by', 'created_by', 'updated_by'], 'string', 'max' => 32]
];
}
......@@ -90,8 +89,8 @@ class Laporan extends \yii\db\ActiveRecord
/**
* @return \yii\db\ActiveQuery
*/
public function getGaji()
public function getUbuxGajis()
{
return $this->hasOne(UbuxGaji::className(), ['gaji_id' => 'gaji_id']);
return $this->hasMany(UbuxGaji::className(), ['laporan_id' => 'laporan_id']);
}
}
......@@ -93,7 +93,7 @@ class Satpam extends \yii\db\ActiveRecord
*/
public function getUbuxJamKerjas()
{
return $this->hasMany(UbuxJamKerja::className(), ['satpam_id' => 'satpam_id']);
return $this->hasMany(JamKerja::className(), ['satpam_id' => 'satpam_id']);
}
/**
......@@ -101,6 +101,15 @@ class Satpam extends \yii\db\ActiveRecord
*/
public function getPegawai()
{
return $this->hasOne(HrdxPegawai::className(), ['pegawai_id' => 'pegawai_id']);
return $this->hasOne(Pegawai::className(), ['pegawai_id' => 'pegawai_id']);
}
public function showPegawai()
{ $dataProvider = new ActiveDataProvider([
'query' => Pegawai::find(),
]);
return $dataProvider;
}
}
......@@ -18,8 +18,8 @@ class GajiSearch extends Gaji
public function rules()
{
return [
[['gaji_id', 'pin', 'nip', 'deleted', 'jam_kerja_id'], 'integer'],
[['tanggal_scan', 'tanggal', 'jam', 'nama', 'deleted_at', 'deleted_by', 'created_at', 'created_by', 'updated_at', 'updated_by'], 'safe'],
[['gaji_id', 'pin', 'nip', 'verifikasi', 'i_o', 'workcode', 'deleted', 'jam_kerja_id', 'laporan_id'], 'integer'],
[['tanggal_scan', 'tanggal', 'jam', 'nama', 'jabatan', 'departemen', 'kantor', 'mesin', 'deleted_at', 'deleted_by', 'created_at', 'created_by', 'updated_at', 'updated_by'], 'safe'],
];
}
......@@ -62,14 +62,22 @@ class GajiSearch extends Gaji
'jam' => $this->jam,
'pin' => $this->pin,
'nip' => $this->nip,
'verifikasi' => $this->verifikasi,
'i_o' => $this->i_o,
'workcode' => $this->workcode,
'deleted' => $this->deleted,
'deleted_at' => $this->deleted_at,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'jam_kerja_id' => $this->jam_kerja_id,
'laporan_id' => $this->laporan_id,
]);
$query->andFilterWhere(['like', 'nama', $this->nama])
->andFilterWhere(['like', 'jabatan', $this->jabatan])
->andFilterWhere(['like', 'departemen', $this->departemen])
->andFilterWhere(['like', 'kantor', $this->kantor])
->andFilterWhere(['like', 'mesin', $this->mesin])
->andFilterWhere(['like', 'deleted_by', $this->deleted_by])
->andFilterWhere(['like', 'created_by', $this->created_by])
->andFilterWhere(['like', 'updated_by', $this->updated_by]);
......
......@@ -24,6 +24,20 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'nama')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'jabatan')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'departemen')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'kantor')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'verifikasi')->textInput() ?>
<?= $form->field($model, 'i_o')->textInput() ?>
<?= $form->field($model, 'workcode')->textInput() ?>
<?= $form->field($model, 'mesin')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'deleted')->textInput() ?>
<?= $form->field($model, 'deleted_at')->textInput() ?>
......@@ -40,6 +54,8 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'jam_kerja_id')->textInput() ?>
<?= $form->field($model, 'laporan_id')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
......
......@@ -29,6 +29,20 @@ use yii\widgets\ActiveForm;
<?php // echo $form->field($model, 'nama') ?>
<?php // echo $form->field($model, 'jabatan') ?>
<?php // echo $form->field($model, 'departemen') ?>
<?php // echo $form->field($model, 'kantor') ?>
<?php // echo $form->field($model, 'verifikasi') ?>
<?php // echo $form->field($model, 'i_o') ?>
<?php // echo $form->field($model, 'workcode') ?>
<?php // echo $form->field($model, 'mesin') ?>
<?php // echo $form->field($model, 'deleted') ?>
<?php // echo $form->field($model, 'deleted_at') ?>
......@@ -45,6 +59,8 @@ use yii\widgets\ActiveForm;
<?php // echo $form->field($model, 'jam_kerja_id') ?>
<?php // echo $form->field($model, 'laporan_id') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
......
<?php
use yii\widgets\ActiveForm;
use yii\helpers\Html;
?>
<h1>Import Data</h1>
<?php $form = ActiveForm::begin(['options'=>['enctype'=>'multipart/form-data']]);?>
<?= $form->field($modelImport,'fileImport')->fileInput() ?>
<?= Html::submitButton('Import',['class'=>'btn btn-primary']);?>
<?php ActiveForm::end();?>
\ No newline at end of file
......@@ -25,13 +25,20 @@ $this->params['breadcrumbs'][] = $this->title;
'columns' => [
['class' => 'yii\grid\SerialColumn'],
//'gaji_id',
'gaji_id',
'tanggal_scan',
'tanggal',
'jam',
'pin',
'nip',
'nama',
// 'nip',
// 'nama',
// 'jabatan',
// 'departemen',
// 'kantor',
// 'verifikasi',
// 'i_o',
// 'workcode',
// 'mesin',
// 'deleted',
// 'deleted_at',
// 'deleted_by',
......@@ -40,6 +47,7 @@ $this->params['breadcrumbs'][] = $this->title;
// 'updated_at',
// 'updated_by',
// 'jam_kerja_id',
// 'laporan_id',
['class' => 'yii\grid\ActionColumn'],
],
......
......@@ -35,14 +35,22 @@ $this->params['breadcrumbs'][] = $this->title;
'pin',
'nip',
'nama',
/*'deleted',
'jabatan',
'departemen',
'kantor',
'verifikasi',
'i_o',
'workcode',
'mesin',
'deleted',
'deleted_at',
'deleted_by',
'created_at',
'created_by',
'updated_at',
'updated_by',
'jam_kerja_id',*/
'jam_kerja_id',
'laporan_id',
],
]) ?>
......
......@@ -14,7 +14,7 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'bulan_laporan')->textInput(['maxlength' => true]) ?>
<!-- <?= $form->field($model, 'gaji_id')->textInput() ?>
<?= $form->field($model, 'gaji_id')->textInput() ?>
<?= $form->field($model, 'deleted')->textInput() ?>
......@@ -28,7 +28,7 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'updated_at')->textInput() ?>
<?= $form->field($model, 'updated_by')->textInput(['maxlength' => true]) ?> -->
<?= $form->field($model, 'updated_by')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
......
......@@ -28,16 +28,16 @@ $this->params['breadcrumbs'][] = $this->title;
<?= DetailView::widget([
'model' => $model,
'attributes' => [
//'laporan_id',
'laporan_id',
'bulan_laporan',
// 'gaji_id',
// 'deleted',
// 'deleted_at',
// 'deleted_by',
// 'created_at',
// 'created_by',
// 'updated_at',
// 'updated_by',
'gaji_id',
'deleted',
'deleted_at',
'deleted_by',
'created_at',
'created_by',
'updated_at',
'updated_by',
],
]) ?>
......
......@@ -19,17 +19,31 @@ $this->params['breadcrumbs'][] = $this->title;
<?= Html::a('Create Satpam', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
<?php
echo GridView::widget([
'dataProvider' => $this->context->showPegawai(),
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'satpam_id',
'aktif_star',
'aktif_end',
'pegawai_id',
'deleted',
'nama',
'user_name',
'tgl_lahir',
'tempat_lahir',
'nip',
'telepon',
'alamat',
'kecamatan',
'kota',
//'aktif_star',
//'aktif_end',
// 'pegawai_id',
// 'deleted',
// 'deleted_at',
// 'deleted_by',
// 'created_at',
......
......@@ -129,6 +129,7 @@ $this->beginPage();
<?php
MenuRenderer::renderSidebarMenu(\Yii::$app->params['sidebarMenu']);
?>
<li><a href="/cis-lite/backend/web/index.php/ubux/gaji/import"><i class="fa fa-circle-o text-red"></i> <span>Import</span></a></li>
<!-- <li class="header">LABELS</li>
<li><a href="#"><i class="fa fa-circle-o text-red"></i> <span>Important</span></a></li>
<li><a href="#"><i class="fa fa-circle-o text-yellow"></i> <span>Warning</span></a></li>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment