本文整理汇总了PHP中Plan::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Plan::model方法的具体用法?PHP Plan::model怎么用?PHP Plan::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plan
的用法示例。
在下文中一共展示了Plan::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
/**
* Lists all models.
*/
public function actionIndex()
{
$model = new PurchasedPlan();
$form = new PurchasePlanForm();
if (isset($_POST['PurchasedPlan'])) {
$form->attributes = $_POST['PurchasedPlan'];
if ($form->validate()) {
if ($_POST['PurchasedPlan']['realPayment'] == 0) {
//$form->purchasePlan($this->getPlanType());
$this->redirect(array('index'));
} else {
$wl = WhiteLabel::model()->findByPk(Yii::app()->user->getWhiteLabelId());
if ($wl == null) {
throw new Exception("Account doesn't exist");
}
$plan = Plan::model()->findByAttributes(array('plan_id' => $form->plan_id, 'wlabel_id' => Yii::app()->user->getWhiteLabelId(), 'type' => $this->getPlanType()));
if ($plan == null) {
throw new Exception("Plan doesn't exist");
}
if ($wl->payment_type == PaymentType::TYPE_PAYPAL) {
$this->processPayPalPayment($wl, $plan);
} else {
if ($wl->payment_type == PaymentType::TYPE_AUTHORIZENET) {
$this->processAuthnetPayment($wl, $plan);
}
}
exit;
}
}
}
if (isset($_GET['PurchasedPlan'])) {
$model->attributes = $_GET['PurchasedPlan'];
}
$this->render('index', array('model' => $model, 'planType' => $this->getPlanType()));
}
示例2: getDataProvider
/**
*
* 改进:使用延迟绑定,将这个函数写在父类里面
*返回某个用户所发布的所有计划列表
* @return CActiveDataProvider $dataProvider 返回CActiveDataProvider对象
* 使用attach的好处是随时绑定,不一定在初始化的时候绑定
*/
public function getDataProvider(CFormModel &$condition)
{
$this->attachBehaviors(array('NearScopeBehavior' => array('class' => 'ext.behavior.NearScopeBehavior', 'latitude' => $condition->latitude, 'longitude' => $condition->longitude)));
$dataProvider = new CActiveDataProvider(Plan::model()->unexpired()->near()->with('user'), array('pagination' => array('pageSize' => 20)));
$dataProvider->setCriteria($this->addCondition($condition));
return $dataProvider;
}
示例3: actionDetail
/**
*
* 查看plan的详细。在里面就包括了评论等具体的内容,注意,评论则需要分页。
* 因为plan本身已经返回,所以只返回评论的内容。
*/
public function actionDetail($planId)
{
$plan = Plan::model()->findByPk('planId', 'planId=:planId', array(':planId' => $planId));
$dataProvider = $plan->getComments();
$this->page($dataProvider);
$data = array('data' => $dataProvider);
$this->render('detail', $data);
}
示例4: purchasePlan
public function purchasePlan($planType, $advertiserId = '')
{
$transaction = Yii::app()->db->beginTransaction();
try {
// load plan and its plan limits
if ($planType == PlanType::ADVERTISER_PLAN) {
$plan = Plan::model()->findByAttributes(array('plan_id' => $this->plan_id, 'wlabel_id' => Yii::app()->user->getWhiteLabelId(), 'type' => $planType));
} else {
$plan = Plan::model()->findByAttributes(array('plan_id' => $this->plan_id, 'type' => $planType));
}
if ($plan == null) {
throw new Exception("Plan doesn't exist");
}
$planLimits = PlanLimit::model()->findAllByAttributes(array('plan_id' => $plan->plan_id));
if ($planLimits == null) {
// throw new Exception("Plan Limits don't exist");
}
// create new purchased_plans record
$purchasedPlan = new PurchasedPlan();
$purchasedPlan->plan_id = $plan->plan_id;
if ($planType == PlanType::ADVERTISER_PLAN) {
$purchasedPlan->wlabel_id = $plan->wlabel_id;
} else {
$purchasedPlan->wlabel_id = $this->wlabel_id;
}
$purchasedPlan->type = $plan->type;
if ($planType == PlanType::ADVERTISER_PLAN) {
if (Yii::app()->user->isAdvertiser()) {
$purchasedPlan->advertiser_id = Yii::app()->user->getAdvertiserId();
} else {
$purchasedPlan->advertiser_id = $advertiserId;
}
} else {
}
$purchasedPlan->method = 0;
$purchasedPlan->price = $plan->price;
$purchasedPlan->date_created = date("Y-m-d h:i:s");
if (!$purchasedPlan->validate()) {
throw new Exception("Plan purchase cannot be saved: " . $this->putErrorsToString($purchasedPlan->getErrors()));
}
$purchasedPlan->save();
// create new purchased_plans payments record
$purchasedPlanPayment = new PurchasedPlanPayment();
$purchasedPlanPayment->pplan_id = $purchasedPlan->pplan_id;
$purchasedPlanPayment->date_paid = $purchasedPlan->date_created;
$purchasedPlanPayment->date_expire = Date('y-m-d', strtotime("+{$plan->duration} day"));
$purchasedPlanPayment->transaction_id = 'TEST_PAYMENT';
if (!$purchasedPlanPayment->validate()) {
throw new Exception("Plan payment cannot be saved: " . $this->putErrorsToString($purchasedPlanPayment->getErrors()));
}
$purchasedPlanPayment->save();
} catch (Exception $e) {
$transaction->rollBack();
throw new CHttpException(400, 'DB Exception: ' . $e->getMessage());
}
$transaction->commit();
return false;
}
示例5: actionIndex
public function actionIndex()
{
$this->layout = 'login';
$wlabelId = isset($_REQUEST['wid']) ? $_REQUEST['wid'] : '';
if ($wlabelId == '') {
throw new CHttpException(404, 'Bad parameter wid');
}
$planId = isset($_REQUEST['pid']) ? $_REQUEST['pid'] : '';
if ($planId == '') {
throw new CHttpException(404, 'Bad parameter pid');
}
$advertiserId = isset($_REQUEST['aid']) ? $_REQUEST['aid'] : '';
if ($advertiserId == '') {
throw new CHttpException(404, 'Bad parameter aid');
}
$returnUrl = isset($_REQUEST['return']) ? $_REQUEST['return'] : '';
if ($returnUrl == '') {
throw new CHttpException(404, 'Bad parameter return');
}
$wl = WhiteLabel::model()->findByPk(Yii::app()->user->getWhiteLabelId());
if ($wl == null) {
throw new Exception("Account doesn't exist");
}
$plan = Plan::model()->findByAttributes(array('plan_id' => $planId, 'wlabel_id' => $wlabelId));
if ($plan == null) {
throw new CHttpException(404, 'Cannot find plan!');
}
$advertiser = Advertiser::model()->findByAttributes(array('advertiser_id' => $planId, 'wlabel_id' => $advertiserId));
if ($plan == null) {
throw new CHttpException(404, 'Cannot find advertiser!');
}
$form = new AuthorizenetPaymentForm();
if (isset($_POST['AuthorizenetPaymentForm'])) {
$form->attributes = $_POST['AuthorizenetPaymentForm'];
$form->advertiser_id = $advertiserId;
$form->wlabel_id = $wlabelId;
$form->plan_id = $plan->plan_id;
$form->refId = $plan->plan_id;
$form->name = "Plan Subscription";
$form->unit = "days";
$form->totalOccurrences = 999;
$form->trialOccurrences = 0;
$form->trialAmount = 0;
$form->startDate = date('Y-m-d');
$form->length = $plan->duration;
$form->amount = $plan->price;
if ($form->validate()) {
if ($form->sendCreateSubscription($wl, $plan)) {
$this->redirect($returnUrl);
}
}
}
if (isset($_GET['AuthorizenetPaymentForm'])) {
$form->attributes = $_GET['AuthorizenetPaymentForm'];
}
$this->render('form_authnet_payment', array('model' => $form));
}
示例6: actionIndex
public function actionIndex()
{
$plan = Plan::model();
$searchForm = $this->initParams('SearchForm', 'new');
$dataProvider = $plan->getDataProvider($searchForm);
$this->page($dataProvider, true);
$data = array('search' => $searchForm, 'dataProvider' => $dataProvider);
$this->render('index', $data);
}
示例7: actionIndex
public function actionIndex()
{
$tempForm = $this->initParams('TempForm', 'new');
$data = array('tempForm' => $tempForm);
if ($tempForm->validate()) {
$plan = Plan::model();
$dataProvider = $plan->getDataProvider($tempForm);
$this->page($dataProvider);
$data = array_merge($data, array('dataProvider' => $dataProvider));
} else {
$this->error->capture($tempForm);
}
$this->render('index', $data);
}
示例8: actionIndex
public function actionIndex()
{
$plan = Plan::Model();
$plan->setScenario('detail');
$data = array('model' => Plan::model());
if (isset($_POST['Plan'])) {
$plan->attributes = $_POST['Plan'];
}
if ($plan->validate()) {
$dataProvider = new CActiveDataProvider(PlanComment::model()->with('user'), array('criteria' => array('condition' => 'planId=' . $plan->planId, 'order' => 'commentId DESC'), 'pagination' => array('pageSize' => 10)));
$data = array_merge($data, array('dataProvider' => $dataProvider));
$this->page($dataProvider);
} else {
$this->error->capture($plan);
}
$this->render('index', $data);
}
示例9: purchasePlan
public function purchasePlan($subscriptionId, $advertiserId = '')
{
$transaction = Yii::app()->db->beginTransaction();
try {
// load plan and its plan limits
$plan = Plan::model()->findByAttributes(array('plan_id' => $this->plan_id, 'wlabel_id' => $this->wlabel_id));
if ($plan == null) {
throw new Exception("Plan doesn't exist");
}
// create new purchased_plans record
$purchasedPlan = new PurchasedPlan();
$purchasedPlan->plan_id = $plan->plan_id;
$purchasedPlan->wlabel_id = $plan->wlabel_id;
$purchasedPlan->type = $plan->type;
$purchasedPlan->duration = $plan->duration;
$purchasedPlan->method = PaymentType::TYPE_AUTHORIZENET;
$purchasedPlan->subscription_id = $subscriptionId;
$purchasedPlan->advertiser_id = $this->advertiser_id;
$purchasedPlan->method = 0;
$purchasedPlan->price = $plan->price;
$purchasedPlan->date_created = date("Y-m-d h:i:s");
if (!$purchasedPlan->validate()) {
throw new Exception("Plan purchase cannot be saved: " . $this->putErrorsToString($purchasedPlan->getErrors()));
}
$purchasedPlan->save();
// create new purchased_plans payments record
$purchasedPlanPayment = new PurchasedPlanPayment();
$purchasedPlanPayment->pplan_id = $purchasedPlan->pplan_id;
$purchasedPlanPayment->date_paid = $purchasedPlan->date_created;
$purchasedPlanPayment->date_expire = Date('Y-m-d', strtotime("+{$plan->duration} day"));
$purchasedPlanPayment->transaction_id = 'AUTHNET_INIT_PAYMENT';
if (!$purchasedPlanPayment->validate()) {
throw new Exception("Plan payment cannot be saved: " . $this->putErrorsToString($purchasedPlanPayment->getErrors()));
}
$purchasedPlanPayment->save();
} catch (Exception $e) {
$transaction->rollBack();
throw new CHttpException(400, 'DB Exception: ' . $e->getMessage());
}
$transaction->commit();
return true;
}
示例10: init
public function init()
{
// Yii::app()->clientScript->registerCoreScript( "https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js", CClientScript::POS_HEAD);
// Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl.'/js/jquery-1.5.2.min.js',CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile(Yii::app()->assetManager->publish('js/scriptbreaker-multiple-accordion-1.js'), CClientScript::POS_BEGIN);
// Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl.'/js/scriptbreaker-multiple-accordion-1.js',CClientScript::POS_HEAD);
$criteria = new CDbCriteria();
if ($this->columns != null) {
$cri = "";
foreach ($this->columns as $row) {
if (strlen($row[0]) > 0) {
$cri[] = $row[0];
}
}
$criteria->with = $cri;
}
$this->rows = $this->model->findAll($criteria);
$this->line_open = false;
$this->position = 0;
if (strlen($this->action) == 0) {
$this->prows = Plan::model()->findAll();
}
}
示例11: actionIndex
public function actionIndex()
{
$status = UserStatus::model()->findByPk(Yii::app()->user->userId);
$refreshTime = $status->refreshTime;
$result = Plan::model()->findAllByAttributes(array('userId' => Yii::app()->user->userId));
$primaryKeys = array();
foreach ($result as $value) {
array_push($primaryKeys, $value->primaryKey);
}
$criteria = new CDbCriteria();
$criteria->addInCondition('planId', $primaryKeys);
$criteria->addCondition('createTime>=' . $refreshTime);
$inbox = PlanComment::model()->findAll($criteria);
$count = count($inbox);
if ($count > 0) {
$this->send(ERROR_NONE, $inbox, false, array('count' => $count), false);
}
//传递一个已读未读的标志位
if (isset($_POST['read'])) {
$status->refreshTime = time();
$status->save();
}
$this->render('index');
}
示例12: array
<?php
$form = $this->beginWidget('CActiveForm', array('id' => 'plan-limit-form', 'enableAjaxValidation' => false));
?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php
echo $form->errorSummary($modelPlanLimit);
?>
<div class="row">
<?php
echo $form->labelEx($modelPlanLimit, 'plan_id');
?>
<?php
echo $form->dropDownList($modelPlanLimit, 'plan_id', CHtml::listData(Plan::model()->findAllByType(PlanType::WHITELABEL_PLAN), 'plan_id', 'name'), array('' => ''));
?>
<?php
echo $form->error($modelPlanLimit, 'plan_id');
?>
</div>
<div class="row">
<?php
echo $form->labelEx($modelPlanLimit, 'resource_type');
?>
<?php
echo $form->dropDownList($modelPlanLimit, 'resource_type', CHtml::listData(PlanResourceType::findAllByType(PlanType::WHITELABEL_PLAN), 'id', 'name'));
?>
<?php
示例13: getList
public function getList($planId)
{
$dataProvider = new CActiveDataProvider(Plan::model(), array('criteria' => array('condition' => 'planId=' . $planId, 'order' => 'planId DESC'), 'pagination' => array('pageSize' => 20)));
return $dataProvider;
}
示例14: 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 = Plan::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例15: actionAjaxReqord
public function actionAjaxReqord()
{
$val1 = $_POST['p_id'];
$val2 = $_POST['c_id'];
$this->widget('ext.OrderlistWidget', array('model' => Plan::model(), 'columns' => array('id', 'coox', 'cooy'), 'class' => 'nx', 'filter' => 'ptype="line"', 'id' => 'id', 'togo' => '##', 'next' => 'next', 'par_id' => $val1, 'cur_id' => $val2, 'par' => 'region_id', 'level' => 1));
Yii::app()->end();
}