本文整理汇总了PHP中Subscription::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Subscription::model方法的具体用法?PHP Subscription::model怎么用?PHP Subscription::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscription
的用法示例。
在下文中一共展示了Subscription::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModel
public function loadModel($id)
{
if (($model = Subscription::model()->findByPk($id)) === null) {
throw new CHttpException(404, 'Страница не найдена');
}
return $model;
}
示例2: actionIndex
public function actionIndex()
{
$subscription = Subscription::model()->findAll();
$data = UserSubscription::model()->getListUserSub();
$dataProvider = new CActiveDataProvider('Subscription');
$this->render('index', array('subscription' => $subscription, 'data' => $data, 'dataProvider' => $dataProvider));
}
示例3: actionCreditCard
public function actionCreditCard()
{
if (isset($_POST['card_number'])) {
// $email = $_POST['email'];
$card_number = $_POST['card_number'];
$payment_type = $_POST['payment_type'];
$exp_month = $_POST['exp_month'];
$exp_year = $_POST['exp_year'];
$csc = $_POST['csc'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$total = $_POST['total'];
$listener = new CardForm();
$card = $listener->doStoreCreditCardAPI($payment_type, $card_number, $exp_month, $exp_year, $csc, $first_name, $last_name);
//self::doSubmitCard($card_number, $payment_type, $exp_month, $exp_year, $csc, $first_name, $last_name, $total);
if ($card && Yii::app()->user->id > 0) {
$userCard = new UserCreditCard();
$userCard->user_id = Yii::app()->user->id;
$userCard->credit_card_id = $card;
$userCard->save();
$submit_card = $listener->doSaleAPI($card, $total);
if ($submit_card) {
$userSubscription = new UserSubscription();
$userSubscription->user_id = Yii::app()->user->id;
$userSubscription->subscription_id = $_GET['id'];
$userSubscription->date_from = date('Y-m-d');
$userSubscription->save();
}
$this->redirect(array('/site/index'), array('sale' => $card, 'token' => $submit_card));
// $this->redirect(array('site/index'), array('user_sub'=>$card, 'sub_id'=>$useSubs));
}
}
if (isset($_POST['card_id']) && Yii::app()->user->id > 0) {
$card_id = $_POST['card_id'];
$total = $_POST['total'];
$listener = new CardForm();
$submit_card = $listener->doSaleAPI($card_id, $total);
if ($submit_card) {
$userSubscription = new UserSubscription();
$userSubscription->user_id = Yii::app()->user->id;
$userSubscription->subscription_id = $_GET['id'];
$userSubscription->date_from = date('Y-m-d');
$userSubscription->save();
}
$this->redirect(array('/site/index'), array('sale' => $card, 'token' => $submit_card));
}
$userCard = UserCreditCard::model()->getCreditCard(Yii::app()->user->id);
$test = '';
if ($userCard && $userCard[0]->credit_card_id && Yii::app()->user->id > 0) {
$test = $userCard[0]->credit_card_id;
}
$sub = Subscription::model()->findByPk($_GET['id']);
$this->render('card', array('total' => $sub->subscription_value, 'card_saved' => $test));
}
示例4: run
public function run()
{
if (Yii::app()->user->isAuthenticated() === false) {
$this->controller->redirect(Yii::app()->user->loginUrl);
}
if (($user = Yii::app()->user->getProfile()) === null) {
Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('UserModule.user', 'User not found.'));
Yii::app()->user->logout();
$this->controller->redirect((array) '/user/account/login');
}
$subscriptions = Subscription::model()->user($user->id)->profile()->with('courseType', 'courseType.course')->findAll();
$this->controller->render('index', array('user' => $user, 'subscriptions' => $subscriptions));
}
示例5: run
public function run()
{
$this->log("Get list of ended full subscriptions");
$subscriptions = Subscription::model()->payments()->periodOver()->findAll();
if (!empty($subscriptions)) {
$this->log("List is not empty");
foreach ($subscriptions as $subscription) {
$subscription->finish();
$this->log("Subscription ID " . $subscription->id . ' deactivated.');
}
$this->log("Finish");
} else {
$this->log("Empty list");
}
}
示例6: actionSearch
public function actionSearch()
{
set_time_limit(0);
while (1) {
$array_subs = Subscription::model()->with('userSubscriptions')->findALl();
//$array_subs = Subscription::model()->with('userSubscriptions')->findAllByAttributes(array('ID'=>57));
foreach ($array_subs as $tiSubs) {
//delete all flights of subs
$this->deleteOldFlights($tiSubs);
$lowestPrice = new D_LowestPrice();
$this->_price = $lowestPrice->searchFlight($tiSubs);
//date backward
//search fail
if ((int) $this->_price == 0) {
continue;
}
$this->createHistoryPrice($tiSubs, (int) $this->_price);
$this->addFlightsOfSubscription($tiSubs, $lowestPrice);
$isModified = $this->modifyPriceOfSubscription($tiSubs);
if ($isModified) {
echo "subscription is modified \n";
$array_user_subs = $tiSubs->userSubscriptions;
print_r($array_user_subs);
foreach ($array_user_subs as $user_tiSubs) {
$tiUser = $user_tiSubs->iDUser;
if (!$tiUser->Pushable) {
continue;
}
echo "user is pushable\n";
if ((int) $this->_price < (int) $user_tiSubs->PriceLimit || $user_tiSubs->PriceLimit == NULL) {
$user_devices = $tiUser->userDevices;
foreach ($user_devices as $user_device) {
$this->_deviceToken = $user_device->Device_token;
$this->_id = $tiSubs->ID;
//$this->_deviceToken = "70a10324b2a2e4e6daaa8eee74a30c8bb196db31be43043cc94cb149d117aeb7";
//$this->_message = "asdf";
$this->_message = "您订阅的{$tiSubs->DepartCity}至{$tiSubs->ArriveCity}价格已更新至{$this->_price}";
echo "start to push\n";
$this->actionIndex();
}
}
}
}
sleep(1);
}
sleep(2);
}
}
示例7: processCheckout
public function processCheckout(CHttpRequest $request)
{
$amount = $request->getParam('OutSum');
$orderId = (int) $request->getParam('InvId');
$crc = strtoupper($request->getParam('SignatureValue'));
$subscription = Subscription::model()->findByPk($orderId);
if (null === $subscription) {
//echo Yii::t('site', 'Subscription with id = {id} not found!', array('{id}' => $orderId));
Yii::log(Yii::t('site', 'Subscription with id = {id} not found!', array('{id}' => $orderId)), CLogger::LEVEL_ERROR, self::LOG_CATEGORY);
return false;
}
if ($subscription->type != Subscription::TYPE_FULL) {
//echo Yii::t('site', 'Subscription with id = {id} is trial!', array('{id}' => $orderId));
Yii::log(Yii::t('site', 'Subscription with id = {id} is trial!', array('{id}' => $orderId)), CLogger::LEVEL_ERROR, self::LOG_CATEGORY);
return false;
}
if ($subscription->isPaid()) {
//echo Yii::t('site', 'Subscription with id = {id} already payed!', array('{id}' => $orderId));
Yii::log(Yii::t('site', 'Subscription with id = {id} already payed!', array('{id}' => $orderId)), CLogger::LEVEL_ERROR, self::LOG_CATEGORY);
return false;
}
$settings = $this->_getSettings();
$myCrc = strtoupper(md5("{$amount}:{$orderId}:" . $settings['password2']));
if ($myCrc !== $crc) {
//echo Yii::t('site', 'Error pay subscription with id = {id}! Bad crc!', array('{id}' => $orderId));
Yii::log(Yii::t('site', 'Error pay subscription with id = {id}! Bad crc!', array('{id}' => $orderId)), CLogger::LEVEL_ERROR, self::LOG_CATEGORY);
return false;
}
if ($amount != $subscription->getTotalCost()) {
//echo Yii::t('site', 'Error pay subscription with id = {id}! Incorrect price!', array('{id}' => $orderId));
Yii::log(Yii::t('site', 'Error pay subscription with id = {id}! Incorrect price!', array('{id}' => $orderId)), CLogger::LEVEL_ERROR, self::LOG_CATEGORY);
return false;
}
if ($subscription->pay()) {
echo "OK{$orderId}\n";
Yii::log(Yii::t('site', 'Success pay subscription with id = {id}!', array('{id}' => $orderId)), CLogger::LEVEL_INFO, self::LOG_CATEGORY);
return true;
} else {
//echo Yii::t('site', 'Error pay subscription with id = {id}! Error change status!', array('{id}' => $orderId));
Yii::log(Yii::t('site', 'Error pay subscription with id = {id}! Error change status!', array('{id}' => $orderId)), CLogger::LEVEL_ERROR, self::LOG_CATEGORY);
return false;
}
}
示例8: actionIndex
public function actionIndex($subs_id)
{
$subs = \Subscription::model()->findByAttributes(array('ID' => $subs_id));
$lowestPrice = new \D_LowestPrice();
$subs->CurrentPrice = (int) $lowestPrice->searchFlight($subs);
echo "now subs " . $subs_id . " current price is " . $subs->CurrentPrice . "\n";
try {
if (!$subs->save()) {
new \Error(5, null, json_encode($subs->getErrors()));
}
} catch (Exception $e) {
new \Error(5, null, $e->getMessage());
}
$date = new \DateGenerater();
$date = $date->getDateYMD("-");
$price = $subs->CurrentPrice;
$history_price = \HistoryPrice::model()->findAllByAttributes(array('ID_subscription' => $subs->ID, 'Date' => $date));
if ($history_price == NULL || count($history_price) == 0) {
$history_price = new HistoryPrice();
$history_price->ID_subscription = $subs->ID;
$history_price->Price = $price;
$history_price->Date = $date;
try {
$history_price->save();
} catch (Exception $e) {
new \Error(5, NULL, $e->getMessage());
}
} else {
//var_dump($history_price);
$history_price = $history_price[0];
if ($history_price->Price == $price) {
return;
}
$history_price->Price = $price < $history_price->Price ? $price : $history_price;
try {
$history_price->save();
} catch (Exception $e) {
new \Error(5, NULL, $e->getMessage());
}
}
}
示例9: run
public function run()
{
if (Yii::app()->user->isAuthenticated() === false) {
$this->controller->redirect(Yii::app()->user->loginUrl);
}
if (($user = Yii::app()->user->getProfile()) === null) {
Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('UserModule.user', 'User not found.'));
Yii::app()->user->logout();
$this->controller->redirect((array) '/user/account/login');
}
// Определяем программу, для которой необходимо загрузить интересные мысли
$programId = (int) Yii::app()->request->getParam('programId');
$program = CourseType::model()->published()->findByPk($programId);
// Определяем, подписан ли данный пользователь на эту программу
if (!$program || !Subscription::model()->isUserSubscribed($user, $program)) {
throw new CHttpException(404);
}
//$quotes = Quote::model()->user($user->id)->program($program->id)->findAll();
$dataProvider = new CActiveDataProvider(Quote::model()->user($user->id)->program($program->id)->with('user', 'courseType', 'block', 'block.entity', 'block.entity.day'), array('pagination' => array('pageVar' => 'page', 'pageSize' => 10), 'sort' => array('defaultOrder' => 't.id ASC')));
$this->controller->render('interest', array('program' => $program, 'dataProvider' => $dataProvider));
}
示例10: run
public function run()
{
$this->log("Get list of ended trial subscriptions");
$subscriptions = Subscription::model()->active()->trial()->ended()->findAll();
if (!empty($subscriptions)) {
$this->log("List is not empty");
foreach ($subscriptions as $subscription) {
// Проверяем, есть ли полная активная подписка на этот курс
$fullSubscription = Subscription::model()->payments()->user($subscription->user_id)->findByAttributes(array('course_type_id' => $subscription->course_type_id));
if (!$fullSubscription) {
$subscription->deactivate(true);
$this->log("Subscription ID " . $subscription->id . ' deactivated.');
} else {
$this->log("Subscription ID " . $subscription->id . ' - user already had full subscription');
}
}
$this->log("Finish");
} else {
$this->log("Empty list");
}
}
示例11: actionSearch
public function actionSearch()
{
//echo dirname(__FILE__);
set_time_limit(0);
while (1) {
$array_subs = Subscription::model()->with('userSubscriptions')->findALl();
var_dump($array_subs);
foreach ($array_subs as $tiSubs) {
//echo var_dump($tiSubs);
//echo "xxxxxxxxxxxxxxxx<br>";
$lowestPrice = new D_LowestPrice();
$this->_price = $lowestPrice->searchFlight($tiSubs);
$this->_date = $lowestPrice->date;
$this->createHistoryPrice($tiSubs, (int) $this->_price);
$isModified = $this->modifySubscription($tiSubs, (int) $this->_price);
if ($isModified) {
$array_user_subs = $tiSubs->userSubscriptions;
foreach ($array_user_subs as $user_tiSubs) {
$tiUser = $user_tiSubs->iDUser;
if (!$tiUser->Pushable) {
continue;
}
if ($this->_price < $user_tiSubs->PriceLimit || $user_tiSubs->PriceLimit == NULL) {
$user_devices = $tiUser->userDevices;
foreach ($user_devices as $user_device) {
$this->_deviceToken = $user_device->Device_token;
//$this->_deviceToken = "70a10324b2a2e4e6daaa8eee74a30c8bb196db31be43043cc94cb149d117aeb7";
//$this->_message = "asdf";
$this->_message = "您订阅的{$tiSubs->DepartCity}至{$tiSubs->ArriveCity}价格已更新至{$this->_price}";
$this->actionIndex();
}
}
}
}
}
sleep(300);
}
}
示例12: getListUserSub
public function getListUserSub()
{
// include 'SubscriptionController.php';
// include 'UsersController.php';
$arr = array();
$model = UserSubscription::model()->findAll();
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
} else {
foreach ($model as $m) {
$value_arr = array();
$sub = Subscription::model()->findByPk($m->subscription_id);
$userName = AccountProfile::model()->getFullName($m->user_id);
// $sub = SubscriptionController::loadModel($m->subscription_id);
// $user = UsersController::loadModel($m->user_id);
$value_arr['id'] = $m->user_subscription_id;
$value_arr['user_name'] = $userName;
$value_arr['subscription'] = $sub->subscription_value . '$/' . $sub->subscription_name;
$value_arr['date_from'] = $m->date_from;
$arr[] = $value_arr;
}
}
return $arr;
}
示例13: isUserSubscribed
public function isUserSubscribed(User $user, CourseType $courseType)
{
$criteria = new CDbCriteria();
$criteria->compare('t.status', self::STATUS_ACTIVE);
$criteria->compare('t.user_id', $user->id);
$criteria->compare('t.course_type_id', $courseType->id);
return Subscription::model()->exists($criteria);
}
示例14: actionSubscriptions
public function actionSubscriptions($id = null)
{
$parms = array();
if (isset($id)) {
$family = Families::model()->findByPk($id);
$parms['family'] = $family;
$parms['subscriptions'] = Subscription::model()->findAllByAttributes(array('family_id' => $family->id), array('order' => 'end_year ASC, end_month ASC'));
} else {
$parms['families'] = Families::model()->findAllByAttributes(array('disabled' => false));
}
$this->render('subscriptions', $parms);
}
示例15: function
<?php
echo $form->dropDownList($model, 'user_id', CHtml::listData(AccountProfile::model()->findAll(), 'account_id', function ($loc) {
return $loc->account_profile_given_name . ", " . $loc->account_profile_surname;
}), array('empty' => '--Select--'));
?>
<?php
echo $form->error($model, 'user_id');
?>
</div>
<div class="control-group ">
<?php
echo $form->labelEx($model, 'subscription_id');
?>
<?php
echo $form->dropDownList($model, 'subscription_id', CHtml::listData(Subscription::model()->findAll(), 'subscription_id', 'subscription_name'), array('empty' => '--Select--'));
?>
<?php
echo $form->error($model, 'subscription_id');
?>
</div>
<div class="control-group ">
<?php
echo $form->labelEx($model, 'date_from');
?>
<?php
$this->widget('ext.rezvan.RDatePicker', array('name' => 'UserSubscription[date_from]', 'value' => $model->date_from ? $model->date_from : date('Y-m-d'), 'options' => array('format' => 'yyyy-mm-dd', 'viewformat' => 'yyyy-mm-dd', 'placement' => 'right', 'todayBtn' => true)));
?>
<?php
echo $form->error($model, 'date_from');