本文整理汇总了PHP中SS_Datetime::Year方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_Datetime::Year方法的具体用法?PHP SS_Datetime::Year怎么用?PHP SS_Datetime::Year使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS_Datetime
的用法示例。
在下文中一共展示了SS_Datetime::Year方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parameterFields
public function parameterFields()
{
$fields = new FieldList();
// Check if any order exist
if (Order::get()->exists()) {
$first_order = Order::get()->sort('Created ASC')->first();
$months = array('All');
$statuses = Order::config()->statuses;
array_unshift($statuses, 'All');
for ($i = 1; $i <= 12; $i++) {
$months[] = date("F", mktime(0, 0, 0, $i + 1, 0, 0));
}
// Get the first order, then count down from current year to that
$firstyear = new SS_Datetime('FirstDate');
$firstyear->setValue($first_order->Created);
$years = array();
for ($i = date('Y'); $i >= $firstyear->Year(); $i--) {
$years[$i] = $i;
}
//Result Limit
$result_limit_options = array(0 => 'All', 50 => 50, 100 => 100, 200 => 200, 500 => 500);
$fields->push(DropdownField::create('Filter_Month', 'Filter by month', $months));
$fields->push(DropdownField::create('Filter_Year', 'Filter by year', $years));
$fields->push(DropdownField::create('Filter_Status', 'Filter By Status', $statuses));
$fields->push(DropdownField::create("ResultsLimit", "Limit results to", $result_limit_options));
}
return $fields;
}
示例2: parameterFields
public function parameterFields()
{
$fields = new FieldList();
if (class_exists("Subsite")) {
$first_order = Subsite::get_from_all_subsites("Order")->sort('Created', 'ASC')->first();
} else {
$first_order = Order::get()->sort('Created', 'ASC')->first();
}
// Check if any order exist
if ($first_order) {
// List all months
$months = array('All');
for ($i = 1; $i <= 12; $i++) {
$months[] = date("F", mktime(0, 0, 0, $i + 1, 0, 0));
}
// Get the first order, then count down from current year to that
$firstyear = new SS_Datetime('FirstDate');
$firstyear->setValue($first_order->Created);
$years = array();
for ($i = date('Y'); $i >= $firstyear->Year(); $i--) {
$years[$i] = $i;
}
// Order Status
$statuses = Order::config()->statuses;
array_unshift($statuses, 'All');
$fields->push(TextField::create('Filter_FirstName', 'Customer First Name'));
$fields->push(TextField::create('Filter_Surname', 'Customer Surname'));
$fields->push(TextField::create('Filter_StockID', 'Stock ID'));
$fields->push(TextField::create('Filter_ProductName', 'Product Name'));
$fields->push(DropdownField::create('Filter_Month', 'Month', $months));
$fields->push(DropdownField::create('Filter_Year', 'Year', $years));
$fields->push(DropdownField::create('Filter_Status', 'Order Status', $statuses));
}
return $fields;
}