本文整理匯總了PHP中Page_Controller::getCurrentSubscription方法的典型用法代碼示例。如果您正苦於以下問題:PHP Page_Controller::getCurrentSubscription方法的具體用法?PHP Page_Controller::getCurrentSubscription怎麽用?PHP Page_Controller::getCurrentSubscription使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Page_Controller
的用法示例。
在下文中一共展示了Page_Controller::getCurrentSubscription方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getCMSFields
public function getCMSFields()
{
// callback function
$dataSource = function ($memberId) {
$member = Member::get()->byID($memberId);
// Get the Page controller
$Page_Ctrl = new Page_Controller();
$subscription = $Page_Ctrl->getCurrentSubscription($memberId);
if ($subscription) {
switch ($subscription->ProductID) {
case 1:
$productArray = array(4);
break;
case 2:
$productArray = array(5);
break;
case 3:
$productArray = array(6);
break;
}
} else {
$productArray = array(1, 2, 3, 7);
}
return Product::get()->filter(array('ID' => $productArray))->map('ID', 'Name')->toArray();
};
// callback function
$memberDataSource = function ($keyword) {
return Member::get()->where("FirstName like '%{$keyword}%' OR Surname like '%{$keyword}%'")->map('ID', 'Name')->toArray();
};
$fields = parent::getCMSFields();
if ($this->ID) {
$fields->replaceField('SubscriptionID', new ReadonlyField('SubscriptionID'));
$fields->replaceField('StartDate', new ReadonlyField('StartDate'));
$fields->replaceField('ExpireDate', new ReadonlyField('ExpireDate'));
$fields->replaceField('Status', new ReadonlyField('Status'));
$fields->replaceField('IsTrial', new ReadonlyField('IsTrial'));
$fields->replaceField('SubscriptionCount', new ReadonlyField('SubscriptionCount'));
$fields->replaceField('MemberID', new ReadonlyField('MemberID'));
if (!$this->Status) {
$fields->replaceField('ProductID', new ReadonlyField('ProductID'));
$fields->replaceField('ReasonCancelled', new ReadonlyField('ReasonCancelled'));
}
$fields->replaceField('OrderID', new ReadonlyField('OrderID'));
}
if ($this->ID && $this->Status) {
$products = $fields->dataFieldByName('ProductID');
$products->setDisabledItems(array(4, 5, 6, 7, 10));
$fields->replaceField('MemberID', new HiddenField('MemberID', $this->MemberID));
$reasons = array("I didn't use the product as much as I anticipated" => "I didn't use the product as much as I anticipated", "The cost was too high" => "The cost was too high", "I had technical problems generating heatmaps" => "I had technical problems generating heatmaps", "I have changed jobs/careers" => "I have changed jobs/careers", "I had problems with customer service" => "I had problems with customer service", "I didn't find the heatmaps helpful" => "I didn't find the heatmaps helpful", "Other (you may contact us support@attentionwizard.com with additional feedback)" => "Other (you may contact us support@attentionwizard.com with additional feedback)");
$fields->replaceField('ReasonCancelled', new CheckboxSetField('ReasonCancelled', 'Reason Cancelled', $reasons));
}
if (!$this->ID) {
$fields->addFieldToTab("Root.Main", new TextField('Keyword', 'Enter a keyword to search a member'), 'MemberID');
$keyword = $fields->dataFieldByName('Keyword');
$memberId = DependentDropdownField::create('MemberID', 'Member', $memberDataSource)->setDepends($keyword)->setEmptyString('(Select a member)');
$fields->replaceField('MemberID', $memberId);
$members = $fields->dataFieldByName('MemberID');
$products = DependentDropdownField::create('ProductID', 'Product', $dataSource)->setDepends($members)->setEmptyString('(Select a product)');
$fields->replaceField('ProductID', $products);
$fields->removeByName('Status');
$fields->removeByName('SubscriptionID');
$fields->removeByName('StartDate');
$fields->removeByName('ExpireDate');
$fields->removeByName('IsTrial');
$fields->removeByName('SubscriptionCount');
$fields->removeByName('ReasonCancelled');
$fields->removeByName('OrderID');
$fields->addFieldToTab("Root.Main", new TextField('Quantity', 'Quantity(Required if Prepaid)'));
}
return $fields;
}