예제 #1
0
파일: Balances.php 프로젝트: ngchie/system
 public function getFilterFields()
 {
     $months = 6;
     $billruns = array();
     $timestamp = time();
     for ($i = 0; $i < $months; $i++) {
         $billrun_key = Billrun_Util::getBillrunKey($timestamp);
         if ($billrun_key >= '201401') {
             $billruns[$billrun_key] = $billrun_key;
         } else {
             break;
         }
         $timestamp = strtotime("1 month ago", $timestamp);
     }
     arsort($billruns);
     //		$plansModel = new PlansModel();
     //		$plansCursor = $plansModel->getData();
     //		$plans = array();
     //		foreach ($plansCursor as $p) {
     //			$plans[(string) $p->getId()->getMongoID()] = $p["name"];
     //		}
     $usage_filter_values = $this->getBalancesFields();
     unset($usage_filter_values['aid'], $usage_filter_values['sid'], $usage_filter_values['billrun_month'], $usage_filter_values['current_plan']);
     //		$usage_filter_values = array_merge($basic_columns, $extra_columns);
     $planNames = array_unique(array_keys(Billrun_Plan::getPlans()['by_name']));
     $planNames = array_combine($planNames, $planNames);
     $operators = array('equals' => '=', 'lt' => '<', 'lte' => '<=', 'gt' => '>', 'gte' => '>=');
     $filter_fields = array('aid' => array('key' => 'aid', 'db_key' => 'aid', 'input_type' => 'number', 'comparison' => 'equals', 'display' => 'Account id', 'default' => ''), 'sid' => array('key' => 'sid', 'db_key' => 'sid', 'input_type' => 'number', 'comparison' => 'equals', 'display' => 'Subscriber id', 'default' => ''), 'usage_type' => array('key' => 'manual_key', 'db_key' => 'nofilter', 'input_type' => 'multiselect', 'display' => 'Usage', 'values' => $usage_filter_values, 'singleselect' => 1, 'default' => array()), 'usage_filter' => array('key' => 'manual_operator', 'db_key' => 'nofilter', 'input_type' => 'multiselect', 'display' => '', 'values' => $operators, 'singleselect' => 1, 'default' => array()), 'usage_value' => array('key' => 'manual_value', 'db_key' => 'nofilter', 'input_type' => 'number', 'display' => '', 'default' => ''), 'plan' => array('key' => 'plan', 'db_key' => 'current_plan', 'input_type' => 'multiselect', 'comparison' => '$in', 'ref_coll' => 'plans', 'ref_key' => 'name', 'display' => 'Plan', 'values' => $planNames, 'default' => array()), 'billrun' => array('key' => 'billrun', 'db_key' => 'billrun_month', 'input_type' => 'multiselect', 'comparison' => '$in', 'display' => 'Billrun', 'values' => $billruns, 'default' => array()));
     return array_merge($filter_fields, parent::getFilterFields());
 }
예제 #2
0
 /**
  * 
  * @param Mongodloid_Entity $rate
  * @param string $usage_type
  * @param Billrun_Plan $plan
  * @todo move to plan class
  */
 protected function isUsageUnlimited($rate, $usage_type, $plan)
 {
     return $plan->isRateInBasePlan($rate, $usage_type) && $plan->isUnlimited($usage_type) || $plan->isRateInPlanGroup($rate, $usage_type) && $plan->isUnlimitedGroup($rate, $usage_type);
 }
예제 #3
0
 /**
  * 
  * @param Mongodloid_Entity $rate
  * @param string $usage_type
  * @param Billrun_Plan $plan
  */
 protected function isUsageUnlimited($rate, $usage_type, $plan)
 {
     return $plan->isRateInSubPlan($rate, $usage_type) && $plan->isUnlimited($usage_type);
 }