/** * Finds the Account model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param int $id * * @return Account the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { $id = Uuid::str2uuid($id); $payment = Payment::findOne($id); if ($payment === null) { throw new NotFoundHttpException('The requested page does not exist'); } return $payment; }
protected function findAccount($id) { $id = Uuid::str2uuid($id); $account = Account::findOne($id); if ($account === null) { throw new NotFoundHttpException('The requested page does not exist'); } return $account; }
* For the full copyright and license information, please view the LICENSE.md * file that was distributed with this source code. */ use wartron\yii2account\models\Account; use yii\bootstrap\Nav; use yii\web\View; use wartron\yii2uuid\helpers\Uuid; /** * @var View $this * @var Account $model * @var string $content */ $this->title = Yii::t('account-billing', 'Update Payment'); $this->params['breadcrumbs'][] = ['label' => Yii::t('account-billing', 'Billing Admin'), 'url' => ['/billing/admin']]; $this->params['breadcrumbs'][] = ['label' => Yii::t('account-billing', 'Payments'), 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => Uuid::uuid2str($model->id), 'url' => ['view', 'id' => Uuid::uuid2str($model->id)]]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="row"> <div class="col-md-3"> <div class="panel panel-default"> <div class="panel-body"> </div> </div> </div> <div class="col-md-9"> <div class="panel panel-default"> <div class="panel-body"> <?php echo $this->render('_form', ['model' => $model]);
<?php use yii\helpers\Html; use yii\helpers\Url; use yii\grid\GridView; use wartron\yii2uuid\helpers\Uuid; $module = Yii::$app->getModule('account'); $this->beginContent('@wartron/yii2account/views/admin/update.php', ['title' => 'Payments', 'account' => $account]); echo GridView::widget(['dataProvider' => $paymentDp, 'filterModel' => $paymentSearch, 'columns' => [['attribute' => 'id', 'value' => function ($m) { return Html::a(Uuid::uuid2str($m->id), ['/billing/admin-payment/view', 'id' => Uuid::uuid2str($m->id)]); }, 'format' => 'raw'], ['attribute' => 'status', 'value' => function ($m) { switch ($m->status) { case 1: return '<span class="label label-default">Paid</span>'; break; case 2: return '<span class="label label-warning">Unpaid</span>'; break; default: return ''; break; } }, 'format' => 'raw'], 'amount:cent', 'description', ['attribute' => 'created_at', 'format' => 'raw', 'value' => function ($m) { $relativeTime = \Yii::$app->formatter->asRelativeTime($m['created_at']); $formatedTime = \Yii::$app->formatter->asDatetime($m['created_at']); return '<span title="' . $formatedTime . '">' . $relativeTime . '</span>'; }]]]); $this->endContent();
<?php use wartron\yii2account\billing\models\search\BillableItem; use yii\data\ActiveDataProvider; use yii\grid\ActionColumn; use yii\grid\GridView; use yii\jui\DatePicker; use yii\helpers\Html; use yii\web\View; use yii\widgets\Pjax; use wartron\yii2uuid\helpers\Uuid; /** * @var View $this * @var ActiveDataProvider $dataProvider * @var AccountSearch $searchModel */ $this->title = Yii::t('account-billing', 'Manage Payments'); $this->params['breadcrumbs'][] = ['label' => Yii::t('account-billing', 'Billing Admin'), 'url' => ['/billing/admin']]; $this->params['breadcrumbs'][] = $this->title; Pjax::begin(); echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'layout' => "{items}\n{pager}", 'columns' => [['attribute' => 'id', 'value' => function ($m) { return Html::a(Uuid::uuid2str($m->id), ['view', 'id' => Uuid::uuid2str($m->id)]); }, 'format' => 'raw'], ['attribute' => 'status', 'filter' => [1 => 'Active', 2 => 'Inactive']], 'amount:cent', ['attribute' => 'created_at', 'value' => function ($model) { return date('Y-m-d G:i:s', $model->created_at); }, 'filter' => DatePicker::widget(['model' => $searchModel, 'attribute' => 'created_at', 'dateFormat' => 'php:Y-m-d', 'options' => ['class' => 'form-control']])], ['class' => ActionColumn::className(), 'options' => ['style' => 'width: 5%']]]]); Pjax::end();
/** * @inheritdoc */ public function findModel($id) { $id = Uuid::str2uuid($id); return parent::findModel($id); }
/** * @inheritdoc */ public function validateAttribute($model, $attribute) { $model->{$attribute} = Uuid::str2uuid($model->{$attribute}); }
<div class="panel panel-default"> <div class="panel-heading"> Payment History </div> <?php echo GridView::widget(['tableOptions' => ['class' => 'table table-stripped'], 'dataProvider' => $paymentDp, 'layout' => '{items}', 'columns' => [['attribute' => 'status', 'label' => '', 'value' => function ($m) { switch ($m->status) { case 1: return ' <i class="glyphicon glyphicon-check"></i> '; break; case 2: return ' <i class="glyphicon glyphicon-remove"></i> '; break; default: break; } }, 'format' => 'raw'], ['attribute' => 'id', 'value' => function ($m) { return Html::a(substr(Uuid::uuid2str($m->id), 0, 8) . "...", ['/billing/payment/view', 'id' => Uuid::uuid2str($m->id)]); }, 'format' => 'raw'], 'created_at:date', ['attribute' => 'amount', 'value' => function ($m) { return Yii::$app->formatter->asCurrency($m->amount / 100); }, 'format' => 'raw'], 'description', ['label' => 'Payment Method', 'value' => function ($m) { if ($m->billingaccount) { return '<i class="glyphicon glyphicon-credit-card"></i> ••••-••••-••••-' . $m->billingaccount->cc_last4; } return ""; }, 'format' => 'raw'], ['label' => 'Receipt', 'value' => function ($m) { return '<div class="text-center">' . Html::a('<i class="glyphicon glyphicon-download"></i>', ['/billing/payment/download', 'id' => Uuid::uuid2str($m->id)]) . '</div>'; }, 'headerOptions' => ['style' => 'text-align:center;'], 'format' => 'raw']]]); ?> </div>
/** * Finds the Account model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param int $id * * @return Account the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { $id = Uuid::str2uuid($id); $billable = BillableItem::findOne($id); if ($billable === null) { throw new NotFoundHttpException('The requested page does not exist'); } return $billable; }
public function createUUID() { return Uuid::uuid($this->uuidStrategy); }