Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fitur Pesanan Penjualan / Sales Order : Draft
- Loading branch information
1 parent
ee0e7b5
commit d099357
Showing
10 changed files
with
519 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
<?php | ||
|
||
class PesananpenjualanController extends Controller | ||
{ | ||
|
||
/** | ||
* Displays a particular model. | ||
* @param integer $id the ID of the model to be displayed | ||
*/ | ||
public function actionView($id) | ||
{ | ||
$this->render('view', [ | ||
'model' => $this->loadModel($id), | ||
]); | ||
} | ||
|
||
/** | ||
* Creates a new model. | ||
* If creation is successful, the browser will be redirected to the 'view' page. | ||
*/ | ||
public function actionTambah() | ||
{ | ||
$this->layout = '//layouts/box_kecil'; | ||
$model = new PesananPenjualan; | ||
|
||
// Uncomment the following line if AJAX validation is needed | ||
// $this->performAjaxValidation($model); | ||
|
||
if (isset($_POST['PesananPenjualan'])) { | ||
$model->attributes = $_POST['PesananPenjualan']; | ||
if ($model->save()) | ||
$this->redirect(['view', 'id' => $model->id]); | ||
} | ||
|
||
$customerList = Profil::model()->findAll([ | ||
'select' => 'id, nama', | ||
'condition' => 'id>' . Profil::AWAL_ID . ' and tipe_id=' . Profil::TIPE_CUSTOMER, | ||
'order' => 'nama']); | ||
|
||
$this->render('tambah', [ | ||
'model' => $model, | ||
'customerList' => $customerList, | ||
]); | ||
} | ||
|
||
/** | ||
* Updates a particular model. | ||
* @param integer $id the ID of the model to be updated | ||
*/ | ||
public function actionUbah($id) | ||
{ | ||
$model = $this->loadModel($id); | ||
|
||
// Uncomment the following line if AJAX validation is needed | ||
// $this->performAjaxValidation($model); | ||
|
||
if (isset($_POST['PesananPenjualan'])) { | ||
$model->attributes = $_POST['PesananPenjualan']; | ||
if ($model->save()) | ||
$this->redirect(['view', 'id' => $id]); | ||
} | ||
|
||
$this->render('ubah', [ | ||
'model' => $model, | ||
]); | ||
} | ||
|
||
/** | ||
* Deletes a particular model. | ||
* If deletion is successful, the browser will be redirected to the 'admin' page. | ||
* @param integer $id the ID of the model to be deleted | ||
*/ | ||
public function actionHapus($id) | ||
{ | ||
$this->loadModel($id)->delete(); | ||
|
||
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser | ||
if (!isset($_GET['ajax'])) | ||
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : ['index']); | ||
} | ||
|
||
/** | ||
* Manages all models. | ||
*/ | ||
public function actionIndex() | ||
{ | ||
$model = new PesananPenjualan('search'); | ||
$model->unsetAttributes(); // clear any default values | ||
if (isset($_GET['PesananPenjualan'])) | ||
$model->attributes = $_GET['PesananPenjualan']; | ||
|
||
$this->render('index', [ | ||
'model' => $model, | ||
]); | ||
} | ||
|
||
/** | ||
* Returns the data model based on the primary key given in the GET variable. | ||
* If the data model is not found, an HTTP exception will be raised. | ||
* @param integer $id the ID of the model to be loaded | ||
* @return PesananPenjualan the loaded model | ||
* @throws CHttpException | ||
*/ | ||
public function loadModel($id) | ||
{ | ||
$model = PesananPenjualan::model()->findByPk($id); | ||
if ($model === null) | ||
throw new CHttpException(404, 'The requested page does not exist.'); | ||
return $model; | ||
} | ||
|
||
/** | ||
* Performs the AJAX validation. | ||
* @param PesananPenjualan $model the model to be validated | ||
*/ | ||
protected function performAjaxValidation($model) | ||
{ | ||
if (isset($_POST['ajax']) && $_POST['ajax'] === 'pesanan-penjualan-form') { | ||
echo CActiveForm::validate($model); | ||
Yii::app()->end(); | ||
} | ||
} | ||
|
||
/** | ||
* render nomor | ||
* @param obj $data | ||
* @return string nomor, beserta link yang sesuai | ||
*/ | ||
public function renderLinkNomor($data) | ||
{ | ||
switch ($data->status) { | ||
case PesananPenjualan::STATUS_BATAL: | ||
return $data->nomor; | ||
break; | ||
|
||
case PesananPenjualan::STATUS_JUAL: | ||
return '<a href="' . $this->createUrl('view', ['id' => $data->id]) . '">' . $data->nomor . '</a>'; | ||
break; | ||
|
||
case PesananPenjualan::STATUS_PESAN: | ||
return '<a href="' . $this->createUrl('ubah', ['id' => $data->id]) . '">' . $data->nomor . '</a>'; | ||
break; | ||
} | ||
} | ||
|
||
/** | ||
* render link actionUbah jika belum ada nomor | ||
* @param obj $data | ||
* @return string tanggal, beserta link jika masih draft (belum ada nomor) | ||
*/ | ||
public function renderLinkTanggalToUbah($data) | ||
{ | ||
if (!isset($data->nomor)) { | ||
$return = '<a href="' . | ||
$this->createUrl('ubah', ['id' => $data->id, 'uid' => $data->updated_by]) . '">' . | ||
$data->tanggal . '</a>'; | ||
} else { | ||
$return = $data->tanggal; | ||
} | ||
return $return; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/* @var $this PesananpenjualanController */ | ||
/* @var $model PesananPenjualan */ | ||
/* @var $form CActiveForm */ | ||
?> | ||
|
||
<div class="form"> | ||
|
||
<?php | ||
$form = $this->beginWidget('CActiveForm', | ||
[ | ||
'id' => 'pesanan-penjualan-form', | ||
// Please note: When you enable ajax validation, make sure the corresponding | ||
// controller action is handling ajax validation correctly. | ||
// There is a call to performAjaxValidation() commented in generated controller code. | ||
// See class documentation of CActiveForm for details on this. | ||
'enableAjaxValidation' => false, | ||
]); | ||
?> | ||
|
||
<?php echo $form->errorSummary($model, 'Error: Perbaiki input', null, ['class' => 'panel callout']); ?> | ||
|
||
|
||
<div class="row"> | ||
<div class="small-12 columns"> | ||
<?php echo $form->labelEx($model, 'profil_id'); ?> | ||
<?php | ||
echo $form->dropDownList($model, 'profil_id', CHtml::listData($customerList, 'id', 'nama'), | ||
[ | ||
'empty' => 'UMUM', | ||
'autofocus' => 'autofocus' | ||
]); | ||
?> | ||
<?php echo $form->error($model, 'profil_id', ['class' => 'error']); ?> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="small-12 medium-6 columns"> | ||
<input id="checkbox_profil" type="checkbox" name="semua_profil"><label for="checkbox_profil">Tampilkan semua profil</label> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="small-12 columns"> | ||
<?php | ||
echo CHtml::submitButton($model->isNewRecord ? 'Tambah' : 'Simpan', ['class' => 'tiny bigfont button']); | ||
?> | ||
</div> | ||
</div> | ||
|
||
<?php $this->endWidget(); ?> | ||
|
||
</div> |
Oops, something went wrong.