public function newPayment($id)
 {
     $model = new vPorderPayment();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['vPorderPayment'])) {
         $model->attributes = $_POST['vPorderPayment'];
         $model->parent_id = $id;
         if ($model->save()) {
             //Create System_ref
             $_ref = "AP-" . str_pad($model->id, 5, "0", STR_PAD_LEFT);
             vPorderPayment::model()->updateByPk((int) $model->id, array('payment_ref' => $_ref));
             $modelPO = $this->loadModel($id);
             if ($modelPO->payment >= $modelPO->sum_po) {
                 vPorder::model()->updateByPk((int) $modelPO->id, array('payment_state_id' => 2));
             }
             $this->redirect(array('view', 'id' => $id));
         }
     }
     return $model;
 }
Пример #2
0
<?php 
$this->widget('bootstrap.widgets.BootGridView', array('id' => 'u-order-detail-grid', 'dataProvider' => vPorderDetail::model()->search($model->id), 'itemsCssClass' => 'table table-striped table-bordered', 'template' => '{items}{pager}', 'columns' => array(array('header' => 'Item.', 'value' => '$data->item_id'), 'description', 'qty', 'uom', array('value' => 'Yii::app()->indoFormat->number($data->amount)', 'name' => 'amount', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('header' => 'Total', 'value' => 'Yii::app()->indoFormat->number($data->amount)', 'name' => 'amount', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')))));
?>
<br />
<b> Total: <?php 
echo Yii::app()->indoFormat->number($model->sum_po);
?>
</b>

<hr />

<h2>Payment History</h2>

<?php 
$this->widget('bootstrap.widgets.BootGridView', array('id' => 't-account-balance-grid', 'dataProvider' => vPorderPayment::model()->search($model->id), 'template' => '{items}{pager}', 'itemsCssClass' => 'table table-striped table-bordered', 'columns' => array('payment_date', array('header' => 'No Ref', 'value' => '$data->payment_ref'), array('header' => 'Payment Source', 'value' => '$data->payment_source->account_concat()'), array('header' => 'Payment Type', 'value' => '$data->payment_type_id'), array('header' => 'Effective Date', 'value' => '$data->effective_date'), array('name' => 'amount', 'value' => 'Yii::app()->indoFormat->number($data->amount)', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')))));
?>


<hr />

<?php 
if ($model->payment_state_id == 1 && $model->journal_state_id == 2) {
    echo $this->renderPartial('_create', array('model' => $modelPayment));
}
?>

<hr />
<?php 
echo CHtml::link('See Journal Detail >>', Yii::app()->createUrl('/m2/mAccpayable/viewRelated', array("id" => $model->id)));
?>