Commit e2949847 by Andre Sihombing

Memperbaiki import

parent c1099927
......@@ -4,6 +4,7 @@ namespace backend\modules\ubux\controllers;
use Yii;
use backend\modules\ubux\models\Gaji;
use backend\modules\ubux\models\Laporan;
use backend\modules\ubux\models\search\GajiSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
......@@ -24,7 +25,7 @@ class GajiController extends Controller
],
],
];
}
}
/**
* Lists all Gaji models.
......@@ -71,6 +72,36 @@ class GajiController extends Controller
}
}
/*public function actionCreate()
{
$model = new Gaji();
if ($model->load(Yii::$app->request->post())) {
$Pmodel = new Laporan();
$Pmodel->bulan_laporan = $model->bulan_laporan;
if($Pmodel->save()){
$model->laporan_id = $Pmodel->laporan_id;
if($model->validate()){
// echo $model->aktif_star . " " . $model->aktif_end . " " . $Pmodel->tgl_lahir . " " . $Pmodel->alamat;
$model->save();
return $this->redirect(['view', 'id' => $model->gaji_id]);
}else{
$errors = $model->errors;
print_r(array_values($errors));
}
}else{
$errors = $Pmodel->errors;
print_r(array_values($errors));
}
} else {
return $this->render('create', [
'model' => $model,
]);
}
}*/
/**
* Updates an existing Gaji model.
* If update is successful, the browser will be redirected to the 'view' page.
......@@ -119,7 +150,7 @@ class GajiController extends Controller
}
}
public function actionImport(){
public function actionImport($id){
$searchModel = new GajiSearch();
$modelImport = new \yii\base\DynamicModel([
'fileImport'=>'File Import',
......@@ -150,6 +181,7 @@ class GajiController extends Controller
$model->i_o = (string)$sheetData[$baseRow]['K'];
$model->workcode = (string)$sheetData[$baseRow]['L'];
$model->mesin = (string)$sheetData[$baseRow]['M'];
$model->laporan_id = $id;
$model->save();
$baseRow++;
}
......
<?php
namespace backend\modules\ubux\controllers;
use Yii;
use backend\modules\ubux\models\Husband;
use backend\modules\ubux\models\Wife;
use backend\modules\ubux\models\search\HusbandSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* HusbandController implements the CRUD actions for Husband model.
*/
class HusbandController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all Husband models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new HusbandSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Husband model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Husband model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
/*public function actionCreate()
{
$model = new Husband();
$wife = new Wife();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
if ($wife->load(Yii::$app->request->post()) && $wife->save()) {
return $this->redirect(['view', 'id' => $wife->id]);
}
else {
return $this->render('create',array(
'model'=>$model,
'wife'=>$wife,
));
}
}*/
/*public function actionCreate()
{
$model=new Husband;
$wife=new Wife;
if(isset($_POST['Husband']))
{
$model->attributes=$_POST['Husband'];
}
if(isset($_POST['Wife']))
{
$wife->attributes=$_POST['Wife'];
}
$valid=$model->validate();
$valid=$wife->validate() && $valid;
if($valid)
{
if($model->save() && $wife->save())
$this->redirect(array('view','id'=>$model->id));
}
else {
return $this->render('create',array(
'model'=>$model,
'wife'=>$wife,
));
}
}*/
public function actionCreate()
{
$model = new Husband();
$wife = new Wife();
if ($model->load(Yii::$app->request->post()) && $wife->load(Yii::$app->request->post())) {
$transaction = Yii::$app->db->beginTransaction();
if($model->save(false) && $model->addWife($wife)) {
$transaction->commit();
return $this->redirect(['view', 'id' => $model->id]);
}
else {
$transaction->rollBack();
}
}
return $this->render('create', [
'model' => $model,
'wife' => $wife
]);
}
/**
* Updates an existing Husband 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);
$wife = $model->wife;
if ($model->load(Yii::$app->request->post()) && $wife->load(Yii::$app->request->post())) {
$transaction = Yii::$app->db->beginTransaction();
if($model->save(false) && $model->addWife($wife)) {
$transaction->commit();
return $this->redirect(['view', 'id' => $model->id]);
}
else {
$transaction->rollBack();
}
}
return $this->render('update', [
'model' => $model,
'wife' => $wife
]);
}
/*public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}*/
/**
* Deletes an existing Husband model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the Husband model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Husband the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Husband::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}
......@@ -4,6 +4,7 @@ namespace backend\modules\ubux\controllers;
use Yii;
use backend\modules\ubux\models\Laporan;
use backend\modules\ubux\models\Gaji;
use backend\modules\ubux\models\search\LaporanSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
......@@ -118,4 +119,5 @@ class LaporanController extends Controller
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}
......@@ -38,7 +38,7 @@ use common\behaviors\DeleteBehavior;
*/
class Gaji extends \yii\db\ActiveRecord
{
//public $bulanLaporan;
/**
* 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)
......@@ -116,6 +116,6 @@ class Gaji extends \yii\db\ActiveRecord
*/
public function getLaporan()
{
return $this->hasOne(UbuxLaporan::className(), ['laporan_id' => 'laporan_id']);
return $this->hasOne(Laporan::className(), ['laporan_id' => 'laporan_id']);
}
}
<?php
namespace backend\modules\ubux\models;
use Yii;
use common\behaviors\TimestampBehavior;
use common\behaviors\BlameableBehavior;
use common\behaviors\DeleteBehavior;
/**
* This is the model class for table "husband".
*
* @property integer $id
* @property string $name
* @property integer $deleted
* @property string $deleted_at
* @property string $created_at
* @property string $updated_at
* @property string $deleted_by
* @property string $created_by
* @property string $updated_by
*
* @property Wife[] $wives
*/
class Husband 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(){
return [
'timestamp' => [
'class' => TimestampBehavior::className(),
],
'blameable' => [
'class' => BlameableBehavior::className(),
],
'delete' => [
'class' => DeleteBehavior::className(),
]
];
}*/
/**
* @inheritdoc
*/
public static function tableName()
{
return 'husband';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['deleted'], 'integer'],
[['deleted_at', 'created_at', 'updated_at'], 'safe'],
[['name'], 'string', 'max' => 45],
[['deleted_by', 'created_by', 'updated_by'], 'string', 'max' => 32]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'name' => 'Name',
'deleted' => 'Deleted',
'deleted_at' => 'Deleted At',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
'deleted_by' => 'Deleted By',
'created_by' => 'Created By',
'updated_by' => 'Updated By',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getWives()
{
return $this->hasMany(Wife::className(), ['husband_id' => 'id']);
}
public function addWife($wife)
{
$wife->link('husband', $this); // isi nilai husband_id
return $wife->save(false);
}
}
......@@ -60,8 +60,8 @@ class Laporan extends \yii\db\ActiveRecord
public function rules()
{
return [
[['deleted', 'jam_kerja_id'], 'integer'],
[['deleted_at', 'created_at', 'updated_at'], 'safe'],
[['laporan_id', 'deleted', 'jam_kerja_id'], 'integer'],
[['laporan_id', 'deleted_at', 'created_at', 'updated_at'], 'safe'],
[['bulan_laporan'], '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']]
......@@ -90,9 +90,8 @@ class Laporan extends \yii\db\ActiveRecord
/**
* @return \yii\db\ActiveQuery
*/
public function getUbuxGajis()
{
return $this->hasMany(UbuxGaji::className(), ['laporan_id' => 'laporan_id']);
public function getGaji(){
return $this->hasOne(Gaji::className(), ['laporan_id' => 'laporan_id']);
}
/**
......
<?php
namespace backend\modules\ubux\models;
use Yii;
use common\behaviors\TimestampBehavior;
use common\behaviors\BlameableBehavior;
use common\behaviors\DeleteBehavior;
/**
* This is the model class for table "wife".
*
* @property integer $husband_id
* @property string $name
*
* @property Husband $husband
*/
class Wife 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(){
return [
'timestamp' => [
'class' => TimestampBehavior::className(),
],
'blameable' => [
'class' => BlameableBehavior::className(),
],
'delete' => [
'class' => DeleteBehavior::className(),
]
];
}*/
/**
* @inheritdoc
*/
public static function tableName()
{
return 'wife';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['husband_id'], 'required'],
[['husband_id'], 'integer'],
[['name'], 'string', 'max' => 45],
[['husband_id'], 'exist', 'skipOnError' => true, 'targetClass' => Husband::className(), 'targetAttribute' => ['husband_id' => 'id']]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'husband_id' => 'Husband ID',
'name' => 'Name',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getHusband()
{
return $this->hasOne(Husband::className(), ['id' => 'husband_id']);
}
public function addWife($wife)
{
$wife->link('husband', $this); // isi nilai husband_id
return $wife->save(false);
}
}
<?php
namespace backend\modules\ubux\models\search;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\ubux\models\Husband;
/**
* HusbandSearch represents the model behind the search form about `backend\modules\ubux\models\Husband`.
*/
class HusbandSearch extends Husband
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'deleted'], 'integer'],
[['name', 'deleted_at', 'created_at', 'updated_at', 'deleted_by', 'created_by', 'updated_by'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Husband::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'deleted' => $this->deleted,
'deleted_at' => $this->deleted_at,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'deleted_by', $this->deleted_by])
->andFilterWhere(['like', 'created_by', $this->created_by])
->andFilterWhere(['like', 'updated_by', $this->updated_by]);
return $dataProvider;
}
}
......@@ -12,9 +12,6 @@ use yii\widgets\ActiveForm;
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'gaji_id')->textInput() ?>
<?= $form->field($model, 'laporan_id')->textInput() ?>
<?= $form->field($model, 'tanggal_scan')->textInput() ?>
......@@ -42,19 +39,7 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'mesin')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'deleted')->textInput() ?>
<?= $form->field($model, 'deleted_at')->textInput() ?>
<?= $form->field($model, 'deleted_by')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'created_at')->textInput() ?>
<?= $form->field($model, 'created_by')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'updated_at')->textInput() ?>
<?= $form->field($model, 'update_by')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
......
......@@ -46,7 +46,7 @@ $this->params['breadcrumbs'][] = $this->title;
// 'created_at',
// 'created_by',
// 'updated_at',
// 'update_by',
// 'updated_by',
['class' => 'yii\grid\ActionColumn'],
],
......
......@@ -6,7 +6,7 @@ use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\ubux\models\Gaji */
$this->title = $model->gaji_id;
//$this->title = $model->gaji_id;
$this->params['breadcrumbs'][] = ['label' => 'Gajis', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
......@@ -49,7 +49,7 @@ $this->params['breadcrumbs'][] = $this->title;
'created_at',
'created_by',
'updated_at',
'update_by',
'updated_by',
],
]) ?>
......
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\ubux\models\Husband */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="husband-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($wife, 'name')->textInput(['maxlength' => true]) ?>
<!-- <?= $form->field($model, 'deleted')->textInput() ?>
<?= $form->field($model, 'deleted_at')->textInput() ?>
<?= $form->field($model, 'created_at')->textInput() ?>
<?= $form->field($model, 'updated_at')->textInput() ?>
<?= $form->field($model, 'deleted_by')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'created_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']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\ubux\models\search\HusbandSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="husband-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'name') ?>
<?= $form->field($model, 'deleted') ?>
<?= $form->field($model, 'deleted_at') ?>
<?= $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<?php // echo $form->field($model, 'deleted_by') ?>
<?php // echo $form->field($model, 'created_by') ?>
<?php // echo $form->field($model, 'updated_by') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\ubux\models\Husband */
$this->title = 'Create Husband';
$this->params['breadcrumbs'][] = ['label' => 'Husbands', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="husband-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
'wife' => $wife
]) ?>
</div>
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\ubux\models\search\HusbandSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Husbands';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="husband-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a('Create Husband', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'name',
'deleted',
'deleted_at',
'created_at',
// 'updated_at',
// 'deleted_by',
// 'created_by',
// 'updated_by',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\ubux\models\Husband */
$this->title = 'Update Husband: ' . ' ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Husbands', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="husband-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
'wife' => $wife
]) ?>
</div>
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\ubux\models\Husband */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Husbands', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="husband-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'name',
'deleted',
'deleted_at',
'created_at',
'updated_at',
'deleted_by',
'created_by',
'updated_by',
],
]) ?>
</div>
......@@ -25,11 +25,11 @@ $this->params['breadcrumbs'][] = $this->title;
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'laporan_id',
// 'laporan_id',
'bulan_laporan',
'deleted',
'deleted_at',
'deleted_by',
// 'deleted',
// 'deleted_at',
// 'deleted_by',
// 'created_at',
// 'created_by',
// 'updated_at',
......
......@@ -23,21 +23,22 @@ $this->params['breadcrumbs'][] = $this->title;
'method' => 'post',
],
]) ?>
<?= Html::a('Import', ['gaji/import', 'id' => $model->laporan_id], ['class' => 'btn btn-info']) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'laporan_id',
//'laporan_id',
'bulan_laporan',
'deleted',
/*'deleted',
'deleted_at',
'deleted_by',
'created_at',
'created_by',
'updated_at',
'updated_by',
'jam_kerja_id',
'jam_kerja_id',*/
],
]) ?>
......
......@@ -13,6 +13,8 @@ use yii\jui\DatePicker;
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'nama')->textInput() ?>
<?= $form->field($model, 'aktif_star')->widget(\yii\jui\DatePicker::classname(), [
'language' => 'id',
'dateFormat' => 'yyyy-MM-dd',
......@@ -23,7 +25,6 @@ use yii\jui\DatePicker;
'dateFormat' => 'yyyy-MM-dd',
]) ?>
<?= $form->field($model, 'nama')->textInput() ?>
<?= $form->field($model, 'nip')->textInput() ?>
......
......@@ -23,13 +23,14 @@ $this->params['breadcrumbs'][] = $this->title;
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
// /['class' => 'yii\grid\SerialColumn'],
'satpam_id',
'pegawai.nama',
'pegawai.nip',
'pegawai.alamat',
'aktif_star',
'aktif_end',
'pegawai_id',
'deleted',
['class' => 'yii\grid\ActionColumn'],
],
......
......@@ -6,7 +6,7 @@ use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\ubux\models\Satpam */
$this->title = $model->satpam_id;
//$this->title = $model->satpam_id;
$this->params['breadcrumbs'][] = ['label' => 'Satpams', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
......
......@@ -129,7 +129,8 @@ $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><a href="/cis-lite/backend/web/index.php/ubux/laporan"><i class="fa fa-circle-o text-red"></i> <span>Buat Laporan</span></a></li>
<li><a href="/cis-lite/backend/web/index.php/ubux/satpam"><i class="fa fa-circle-o text-red"></i> <span>Olah Satpam</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