本文整理汇总了PHP中Plan类的典型用法代码示例。如果您正苦于以下问题:PHP Plan类的具体用法?PHP Plan怎么用?PHP Plan使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Plan类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAdmin
public function actionAdmin()
{
$model = new Plan('search');
$model->unsetAttributes();
if (isset($_GET['Plan'])) {
$model->setAttributes($_GET['Plan']);
}
$this->render('admin', array('model' => $model));
}
示例2: getShortestPath
public function getShortestPath(Plan $plan)
{
$mutation = $this->selection->getMutations();
$places = $plan->getPlaces();
$from = array_shift($places);
$roadmap = new Roadmap($places);
$roadmap->addPlace($from);
$roadmaps = $this->sortRoadmaps($this->explodeRoadmaps([$roadmap]));
return $roadmaps[0];
}
示例3: testPayload
public function testPayload()
{
$price = new Price();
$plan = new Plan();
foreach ($this->payload as $testCase) {
echo "Testing case: " . json_encode($testCase) . "\n";
$price->setPricePerMinute($testCase["price"]["ppm"]);
$plan->setMinutes($testCase["plan"]["min"]);
$plan->setFareAdditionalMin($testCase["plan"]["fare"]);
$this->assertEquals($plan->calculateCallCost($price, $testCase["duration"]), $testCase["result"]);
}
}
示例4: 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()));
}
示例5: 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;
}
示例6: ProrataDiscount
public static function ProrataDiscount($account_id, $month_sub, $plan_data, $new_plan_cost, $rem_day, $num_of_days, $prorata_bal)
{
$plan_det = Plan::where('account_id', '=', $account_id)->get()->first();
$old_plan_code = $plan_det->plan_code;
$old_plan_amount = PlanCostDetail::where('plan_code', '=', $old_plan_code)->get()->first()->plan_cost;
$old_plan_cost = round($old_plan_amount + $old_plan_amount * 0.14);
$prorata_dis = $old_plan_cost - $prorata_bal;
if ($month_sub == 'Monthly') {
if ($plan_data != 0) {
$prorata_cost = $new_plan_cost;
$prorata_dis = $prorata_dis;
$plan_amount = $new_plan_cost - $prorata_dis;
return array("plan_amount" => $plan_amount, "prorata_dis" => $prorata_dis, "prorata_cost" => $prorata_cost);
} else {
$plan_amount = round($rem_day * ($new_plan_cost / $num_of_days)) - $prorata_dis;
//var_dump($plan_cost_tax); die;
$prorata_cost = $plan_amount;
$prorata_dis = $new_plan_cost - $prorata_cost;
return array("plan_amount" => $plan_amount, "prorata_dis" => $prorata_dis, "prorata_cost" => $prorata_cost);
}
} else {
$plan_amount = $new_plan_cost;
$prorata_cost = $new_plan_cost;
$prorata_dis = 0;
return array("plan_amount" => $plan_amount, "prorata_dis" => $prorata_dis, "prorata_cost" => $prorata_cost);
}
}
示例7: search
/**
* Search Licenses
*/
static function search($q = NULL, $param = NULL, $product_code = NULL)
{
$_tbl_licenses = License::getTableName();
$_tbl_licensesUses = LicensesUses::getTableName();
$_tbl_transactions = Transaction::getTableName();
$_tbl_purchases = Purchase::getTableName();
$_tbl_products = Product::getTableName();
$_tbl_plans = Plan::getTableName();
$_tbl_buyers = Buyer::getTableName();
$fields = array("{$_tbl_licenses}.*", DB::raw("COUNT({$_tbl_licensesUses}.id) AS totalUsed"), "{$_tbl_buyers}.first_name", "{$_tbl_buyers}.last_name", "{$_tbl_buyers}.email", "{$_tbl_products}.code", "{$_tbl_plans}.code AS plan_code", "{$_tbl_products}.api_key");
$licenses = DB::table($_tbl_licenses)->leftJoin($_tbl_licensesUses, "{$_tbl_licensesUses}.license_id", '=', "{$_tbl_licenses}.id")->join($_tbl_transactions, "{$_tbl_transactions}.id", '=', "{$_tbl_licenses}.transaction_id")->join($_tbl_plans, "{$_tbl_transactions}.plan_id", '=', "{$_tbl_plans}.id")->join($_tbl_purchases, "{$_tbl_purchases}.id", '=', "{$_tbl_transactions}.purchase_id")->join($_tbl_products, "{$_tbl_products}.id", '=', "{$_tbl_purchases}.product_id")->join($_tbl_buyers, "{$_tbl_buyers}.id", '=', "{$_tbl_purchases}.buyer_id")->select($fields)->groupBy("{$_tbl_licenses}.id");
$q = $q ? $q : Input::get('q');
$param = $param ? $param : Input::get('param');
if ($q) {
if ($param == "key") {
$licenses = $licenses->where("license_key", '=', $q);
}
if ($param == "email") {
$licenses = $licenses->where("email", '=', $q);
}
if ($product_code) {
$licenses = $licenses->where($_tbl_licenses . ".license_key", 'LIKE', strtoupper($product_code) . '-%');
}
}
return $licenses->orderBy($_tbl_licenses . '.created_at', 'DESC')->paginate(25);
}
示例8: postGenerateLicense
/**
* Generate license
*/
public function postGenerateLicense()
{
$rules = array('transaction_id' => 'required');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('admin/utilities/generate-license')->withErrors($validator)->withInput();
} else {
$transaction_id = Input::get('transaction_id');
if ($transaction = Transaction::where('id', '=', $transaction_id)->first()) {
if ($license = License::where('transaction_id', '=', $transaction_id)->first()) {
Session::flash('alert_error', '<strong>Ooops!</strong> License for given transaction already exists.');
return Redirect::to('admin/licenses?q=' . $license->license_key . '¶m=key');
}
$plan = Plan::where('id', '=', $transaction->plan_id)->first();
if ($plan->has_license) {
$product = Product::where('id', '=', $plan->product_id)->first();
$license_key = License::generate($product->code);
// Save license
$license = new License();
$license->license_key = $license_key;
$license->transaction_id = $transaction_id;
$license->allowed_usage = $plan->license_allowed_usage;
$license->save();
Session::flash('alert_message', '<strong>Well done!</strong> You successfully have generated license key.');
return Redirect::to('admin/licenses?q=' . $license_key . '¶m=key');
} else {
Session::flash('alert_error', '<strong>Ooops!</strong> This plan does not allow to generate a license key.');
return Redirect::to('admin/utilities/generate-license');
}
} else {
Session::flash('alert_error', '<strong>Ooops!</strong> Transaction was not found.');
return Redirect::to('admin/utilities/generate-license');
}
}
}
示例9: 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);
}
示例10: plan
public function plan()
{
$plans = Plan::where('account_id', '=', $this->account_id)->get();
if (count($plans) != 0) {
return $plans->first();
}
return null;
}
示例11: testTraerPlanesCompletosSinAnios
function testTraerPlanesCompletosSinAnios()
{
$planIdSinAnios = 5;
$params = array('recursive' => 3, 'conditions' => array('Plan.id' => $planIdSinAnios));
$ps = $this->Plan->__findCompleto($buscaroSoloContar = 'buscar', $params);
$this->assertEqual(count($ps), 1);
$this->assertTrue(empty($ps[0]['Anio']));
}
示例12: 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;
}
示例13: 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));
}
示例14: retrieveOrCreatePlan
/**
* Verify that a plan with a given ID exists, or create a new one if it does
* not.
*/
protected static function retrieveOrCreatePlan($id)
{
self::authorizeFromEnv();
try {
$plan = Plan::retrieve($id);
} catch (Error\InvalidRequest $exception) {
$plan = Plan::create(array('id' => $id, 'amount' => 0, 'currency' => 'usd', 'interval' => 'month', 'name' => 'Gold Test Plan'));
}
}
示例15: get_delete
public function get_delete($id = NULL)
{
$plan = Plan::find($id);
if (empty($plan)) {
return View::make('msg.error')->with('error', 'Plan doesn\'t exist.');
}
$plan->delete();
return Redirect::to('/admin/plan/overview');
}