本文整理汇总了PHP中Transaction::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Transaction::model方法的具体用法?PHP Transaction::model怎么用?PHP Transaction::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transaction
的用法示例。
在下文中一共展示了Transaction::model方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionconfirm
public function actionconfirm()
{
if (!isset($_POST['result']) || !isset($_POST['x_invoice']) || !isset($_POST['x_iduser']) || !isset($_POST['x_document'])) {
Yii::app()->user->setFlash('error', Yii::t('translation', 'Error unexpexted'));
$this->redirect(Yii::app()->request->baseUrl . "/deposit/");
}
$user = Yii::app()->user->data();
$invo = Invoices::model()->findByAttributes(array('id_user' => $user->id, 'invoice_number' => $_POST['x_invoice']));
if (!is_null($invo)) {
$invo->astropay_result = $_POST['result'];
$invo->status = $_POST['result'] - 5;
$invo->id_astropay = $_POST['x_document'];
$invo->save();
$tran = Transaction::model()->findByAttributes(array('id_trans' => $invo->id_trans));
switch ($invo->astropay_result) {
case 6:
$tran->status = 2;
break;
case 7:
$tran->status = 0;
break;
case 8:
$tran->status = 2;
break;
case 9:
$tran->status = 1;
break;
}
$tran->save();
$this->redirect(Yii::app()->request->baseUrl . "/deposit/");
} else {
Yii::app()->user->setFlash('error', Yii::t('translation', 'Error unexpexted'));
$this->redirect(Yii::app()->request->baseUrl . "/deposit/");
}
}
示例2: historyAction
function historyAction()
{
$userId = $this->signedInUser()->id;
if ($this->isGuest()) {
$this->redirect("Site", "login");
}
$boughtItems = Transaction::model()->findAll(array("userId" => $userId));
$items = array_map(function ($tran) {
return $tran->getItem();
}, $boughtItems);
return $this->render("history.html.haml", array("items" => $items));
}
示例3: run
/**
* What to do when this action will be called.
*
* Just render the `index` view file from current controller.
*/
public function run()
{
if (Yii::app()->user->isGuest) {
$this->controller->layout = '//layouts/landing';
$this->controller->render('landing');
} else {
$this->controller->layout = '//layouts/main';
$user = Yii::app()->user->data();
$balance = Balance::model()->findAllByAttributes(array('id_user' => $user->id));
$transactions = Transaction::model()->findAllByAttributes(array('id_user' => $user->id), new CDbCriteria(array('order' => 'create_time DESC', 'limit' => 10)));
$this->controller->render('home', array('transactions' => $transactions, 'balance' => $balance));
}
}
示例4: hasTransaction
public function hasTransaction($attribute, $param)
{
if (!$this->hasErrors()) {
if ($this->method == 'all') {
$hasTr = Transaction::model()->findAll('customer_id=:cid and invoice_id is null', array(':cid' => $this->cid));
} else {
if ($this->method == 'not_all') {
$hasTr = Transaction::model()->findAll('customer_id=:cid and invoice_id is null and MONTH(FROM_UNIXTIME(created)) = :month', array(':cid' => $this->cid, ':month' => $this->trans_month));
} else {
if ($this->method == 'custom') {
$hasTr = $this->trans_id;
}
}
}
if (count($hasTr) == 0) {
$this->addError('', 'Invoice cannot created because there\'s no transaction available ');
}
}
}
示例5: actionIndex
public function actionIndex()
{
if (Yii::app()->user->isGuest) {
$this->render('index');
} else {
$user = Yii::app()->user->data();
$criteria = new CDbCriteria();
$criteria->condition = 'id_user = :id';
$criteria->order = 'update_time DESC, create_time DESC';
$criteria->params = array(':id' => $user->id);
$count = Transaction::model()->count($criteria);
$pages = new CPagination($count);
$pages->setPageSize(Yii::app()->params['defaultListPerPage']);
$pages->applyLimit($criteria);
// the trick is here!
$transactions = Transaction::model()->findAll($criteria);
$this->render('transactions', array('transactions' => $transactions, 'pages' => $pages));
}
}
示例6: date
<div class="row">
<?php
echo $form->labelEx($model, 'acquisition_date');
?>
<?php
if ($model->isNewRecord == '1') {
$model->acquisition_date = date('Y-m-d');
}
?>
<?php
$form->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'attribute' => 'acquisition_date', 'value' => $model->acquisition_date, 'options' => array('showButtonPanel' => true, 'changeYear' => true, 'dateFormat' => 'yy-mm-dd')));
?>
<?php
echo $form->error($model, 'acquisition_date');
?>
</div><!-- row -->
<!--
<label><?php
echo GxHtml::encode($model->getRelationLabel('transactions'));
?>
</label>
<?php
echo $form->checkBoxList($model, 'transactions', GxHtml::encodeEx(GxHtml::listDataEx(Transaction::model()->findAllAttributes(null, true)), false, true));
?>
-->
<?php
echo GxHtml::submitButton(Yii::t('app', 'Save'));
$this->endWidget();
?>
</div><!-- form -->
示例7: loadModel
/**
* 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 the ID of the model to be loaded
*/
public function loadModel($id)
{
$model = Transaction::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例8: actionView
public function actionView($id)
{
$model = Transaction::model()->findByPk($id);
$this->render('view', array('model' => $model));
}
示例9: actionRemoveproperty
public function actionRemoveproperty($id)
{
$userId = Yii::app()->user->getState('id');
//all users can remove itself from property member's list
if (!UserAccessTable::checkUser2PropertyAccess($userId, $id, UserAccessTable::GUEST)) {
Yii::app()->request->redirect(basePath('app/gallery'));
}
$user2property = User2property::model()->findByAttributes(array('userId' => $userId, 'propertyId' => $id));
if ($user2property->getAttribute('access') != UserAccessTable::OWNER) {
//email to member (NOT admin)
$this->layout = "emailmaster";
$body = $this->render("../emails/emailItselfRemove", array('name' => $user2property->user->getAttribute('firstname') . ' ' . $user2property->user->getAttribute('lastname'), 'propertyName' => $user2property->property->getAttribute('property_name')), true);
MailHelper::send($body, "SharedKey - Removed Property", array($user2property->user->getAttribute('email')));
//clear calendar events first
$calendar = new Calendar();
$calendar = $calendar->findAllByAttributes(array('linkid' => $user2property->getAttribute('id')));
foreach ($calendar as $cal) {
$cal->delete();
}
//for not property Administrator we just remove a link to property
$user2property->delete();
if ($this->_isAllUserPropertiesDeactivated($userId)) {
//removed last property need remove user
$this->removeUser($userId);
return;
}
Yii::app()->request->redirect(basePath('app/properties'));
return;
}
//member is administrator we need cancel RecurringPaymentsProfile and deactivate property
//lets find last transaction
$transaction = Transaction::model()->findByAttributes(array('userid' => $userId, 'propertyid' => $id));
if (!$transaction) {
//no previous transactions not need to refund
}
$userApi = sharedkeyApi::create('usersAPI');
$userEmail = Yii::app()->user->getState('email');
$userApi->addParams(array('email' => $userEmail));
$byEmail = json_decode($userApi->byEmail('get'));
$userData = (array) $byEmail->data;
$userData['property_id'] = $id;
//close RecurringPaymentsProfile
if ($transaction) {
YII::app()->user->setState("addPropertyEmailed", true);
$temp = PayPalHelper::cancelRecurringPaymentsProfile($transaction->getAttribute('pp_PROFILEID'), $userData);
}
//do deactivated
$property = Properties::model()->findByPk($id);
$property->isdeactivated = 1;
$property->edt = new CDbExpression('NOW()');
//$property->trialPeriodStartDate = null;
$property->save();
$this->layout = "emailmaster";
//mail to admin
$token = uniqid();
$body = $this->render("../emails/emailAdminAfterRemove", array('name' => Yii::app()->user->getState('firstname') . ' ' . Yii::app()->user->getState('lastname'), 'propertyName' => $property->getAttribute('property_name'), 'url' => basePathByHost("/app/changeactiveproperty/" . $property->getAttribute("id")) . '?token=' . $token), true);
MailHelper::send($body, "SharedKey - Removed Property", array($userEmail));
//informative other user about property deactivated
$users2properties = User2property::model()->with('user')->findAll('propertyId=:propertyId', array(':propertyId' => $id));
foreach ($users2properties as $key => $u2p) {
if ($u2p->getAttribute('access') == UserAccessTable::OWNER) {
continue;
}
}
if ($this->_isAllUserPropertiesDeactivated($userId)) {
$user = User::model()->find('id=:id', array(':id' => $userId));
$user->verificationToken = $token;
$user->save();
$this->redirect(basePath('user/logout'));
return;
}
Yii::app()->request->redirect(basePath('app/properties'));
}
示例10: processAccounts
function processAccounts(&$accounts, $from_dt, $to_dt, $accts, $depth = 0)
{
foreach ($accts as $acct) {
$ph = $acct->placeholder;
$account = array('name' => $acct->name, 'depth' => $depth, 'placeholder' => $ph);
if (!isset($ph)) {
$trans = Transaction::model()->findAll("created < '{$from_dt}' and account_id = " . $acct->id);
$obal = 0;
foreach ($trans as $tr) {
if ('credit' === $tr->type) {
$obal += $tr->amount;
} else {
$obal -= $tr->amount;
}
}
$trans = Transaction::model()->findAll("created between '{$from_dt}' and '{$to_dt}' and account_id = " . $acct->id);
$cr = $deb = 0;
foreach ($trans as $tr) {
if ('credit' === $tr->type) {
$cr += $tr->amount;
} else {
$deb += $tr->amount;
}
}
$cbal = $obal + $cr - $deb;
$account['obal'] = $obal;
$account['credit'] = $cr;
$account['debit'] = $deb;
$account['cbal'] = $cbal;
}
array_push($accounts, $account);
$children = $acct->childAccounts;
if ($children) {
processAccounts($accounts, $from_dt, $to_dt, $children, $depth + 1);
}
}
}
示例11: beforeDelete
public function beforeDelete()
{
Transaction::model()->updateAll(array('invoice_id' => NULL), 'invoice_id = :invoice_id', array(':invoice_id' => $this->id));
return parent::beforeDelete();
}
示例12: afterSave
public function afterSave()
{
if ($this->isNewRecord) {
//for the tracker
$tracker = new OrderTracking('OrderCreated');
$tracker->shipments_id = $this->primaryKey;
$tracker->save();
//for shipment event
$shipment_event = new ShipmentEvent();
$shipment_event->shipment_id = $this->id;
$shipment_event->status = $this->shipping_status;
$shipment_event->event_time = $this->event_time;
if ($this->getScenario() == 'api-requestpickup') {
$shipment_event->user_id = 0;
} else {
$shipment_event->user_id = Yii::app()->user->id;
}
$shipment_event->setScenario('order');
$shipment_event->save();
if (!empty($this->customer_id)) {
$trans = new Transaction();
$trans->shipment_id = $this->id;
$trans->customer_id = $this->customer_id;
$trans->created = $this->created;
$trans->charges = $this->shipping_charges;
$trans->total = $this->charges;
$trans->save();
}
} else {
if ($this->getScenario() != 'event') {
$shipment_event = new ShipmentEvent();
$shipment_event->shipment_id = $this->id;
$shipment_event->status = $this->shipping_status;
$shipment_event->event_time = time();
$shipment_event->user_id = Yii::app()->user->id;
$shipment_event->with_mde = 1;
$shipment_event->setScenario('order');
$shipment_event->save();
}
if (!empty($this->customer_id)) {
$trans = Transaction::model()->findByAttributes(array('shipment_id' => $this->id));
$trans->shipment_id = $this->id;
$trans->customer_id = $this->customer_id;
$trans->created = $this->created;
$trans->charges = $this->shipping_charges;
$trans->total = $this->charges;
$trans->save();
}
}
}
示例13: getStock
public function getStock($upToDate = '')
{
$criteria = new CDbCriteria();
$criteria->select = "SUM(Qty) AS Qty";
if ($upToDate != '') {
$criteria->condition = "(Oper <> '1' OR OperDate = '0000-00-00' OR (Oper = 1 AND AffectStock = 1)) AND OperDate <= '" . $upToDate . "' AND item_id = '" . $this->id . "'";
} else {
$criteria->condition = "(Oper <> '1' OR OperDate = '0000-00-00' OR (Oper = 1 AND AffectStock = 1)) AND item_id = '" . $this->id . "'";
}
$stock = Transaction::model()->query($criteria);
return $stock->Qty;
}
示例14: actionGenerate
public function actionGenerate($id)
{
$html2pdf = Yii::app()->ePdf->HTML2PDF();
$model = $this->loadModel($id);
$invoice_transaction = Transaction::model()->findAllByAttributes(array('invoice_id' => $id));
$total_amount = 0;
foreach ($invoice_transaction as $key) {
$total_amount = $total_amount + $key->total;
}
$customer = Customer::model()->findByPk($model->customer_id);
$html2pdf->WriteHTML($this->renderPartial('pdf_invoice', array('customer' => $customer, 'model' => $model, 'invoice_transaction' => $invoice_transaction, 'total_amount' => $total_amount), true));
$html2pdf->Output('document.pdf', EYiiPdf::OUTPUT_TO_BROWSER);
}