本文整理汇总了PHP中Receipt::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Receipt::model方法的具体用法?PHP Receipt::model怎么用?PHP Receipt::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Receipt
的用法示例。
在下文中一共展示了Receipt::model方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new UserCredit();
if (isset($_GET['user'])) {
$model->user_id = $_GET['user'];
}
$users_lists = BaseModel::getAll('Users', array("condition" => "is_admin = 0 "));
$users = array();
foreach ($users_lists as $user) {
$users[$user->id] = $user->first_name . ' ' . $user->last_name . '(' . $user->username . ')';
}
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['UserCredit'])) {
$receipt = Receipt::model()->findByPk('81dc3453-b570-11e5-9a98-3c07717072c4');
$model->attributes = $_POST['UserCredit'];
$model->receipt_no = $receipt->receipt;
if ($model->save()) {
if ($model->payment_status == 'a') {
$trans_model = new UserTrans();
$trans_model->tran_type = 'PAYMENT_RECEIVED';
$trans_model->user_id = $model->user_id;
$trans_model->credit = $model->amount;
$trans_model->credit_id = $model->id;
$trans_model->save();
}
$receipt->receipt = $receipt->receipt + 1;
$receipt->save();
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model, 'users' => $users));
}
示例2: actionPrint
public function actionPrint()
{
$id_member = !empty($_GET['id_member']) ? $_GET['id_member'] : '';
$member = Member::model()->findByPk($id_member);
if ($member === null) {
throw new CHttpException(400, 'Invalid request');
}
$receipt = Receipt::model()->find(array('condition' => 'id_member = :id_member', 'params' => array(':id_member' => $id_member), 'order' => 'receipt_date DESC'));
$last_update = is_null($receipt) ? $member->register_date : $receipt->receipt_date;
$user = User::model()->findByPk(Yii::app()->user->getId());
if ($user === null) {
throw new CHttpException(400, 'Invalid request');
}
$receipt = $this->renderPartial('_receipt', array('id_member' => $member->id_member, 'member_name' => $member->first_name . ' ' . $member->family_name, 'point' => $member->point, 'last_update' => date('d F Y', strtotime($last_update)), 'name' => $user->name), true, false);
echo CJSON::encode($receipt);
}