/**
  * Rule Engine Execution Data Generator for a Dealer
  * 
  * @param \Akzo\Dealer $dealer Dealer for which to generate execution data
  * @param boolean $format none | json
  */
 public function toRuleEngineDealerExecData(\Akzo\Dealer $dealer, $executionDataType, $format = 'none')
 {
     $data = array();
     // Plugin lap entry data
     $data['tplId'] = $this->tplId;
     $data['period'] = $this->period->toRuleEngineData();
     $data['product'] = $this->product;
     $data['projectSku'] = $this->projectSku;
     // Plugin the value / volume / qty data
     $vals = $this->_getSalesTargetData($dealer, $executionDataType);
     $data['value'] = $vals['value'];
     $data['volume'] = $vals['volume'];
     // Plugin the qty as per the lap Entry type
     if (strcasecmp($this->type->getValue(), \Akzo\Scheme\Data\Common\QuantityType::VALUE) === 0) {
         $data['qty'] = $vals['value'];
     } else {
         $data['qty'] = $vals['volume'];
     }
     // Add the qcList execution data
     $data['qcList'] = array();
     foreach ($this->qcList as $idx => $qc) {
         $data['qcList'][] = $qc->toRuleEngineDealerExecData($dealer, $executionDataType, 'none');
     }
     if (strcasecmp($format, 'json') === 0) {
         return json_encode($data);
     } else {
         return $data;
     }
 }
Exemple #2
0
 /**
  * Rule Engine Data Generator
  * @param $format none | json
  */
 public function toRuleEngineData($format = 'none')
 {
     $data = parent::toRuleEngineData();
     $data['period'] = $this->period->toRuleEngineData();
     $data['products'] = array();
     foreach ($this->products as $idx => $product) {
         $data['products'][] = $product->toRuleEngineData();
     }
     if (strcasecmp($format, 'json') === 0) {
         return json_encode($data);
     } else {
         return $data;
     }
 }
Exemple #3
0
 /**
  * Rule Engine Execution Data Generator for a Dealer
  * 
  * @param \Akzo\Dealer $dealer Dealer for which to generate execution data
  * @param boolean $format none | json
  */
 public function toRuleEngineDealerExecData(\Akzo\Dealer $dealer, $executionDataType, $format = 'none')
 {
     $data = array();
     // Plugin lap entry data
     $data['tplId'] = $this->tplId;
     $data['period'] = $this->period->toRuleEngineData();
     if (!empty($this->currentPeriod) && $this->currentPeriod instanceof \Akzo\Scheme\Data\Common\Period) {
         $data['currentPeriod'] = $this->currentPeriod->toRuleEngineData();
     }
     if (!empty($this->previousPeriod) && $this->previousPeriod instanceof \Akzo\Scheme\Data\Common\Period) {
         $data['previousPeriod'] = $this->previousPeriod->toRuleEngineData();
     }
     //curr period & previous period
     // Condense the products pid into a single product pid array
     $data['products'] = $this->_condenseProductsPid($this->products);
     $data['packs'] = $this->packs;
     $data['projectSku'] = $this->projectSku;
     if (isset($this->payoutProducts) && !empty($this->payoutProducts)) {
         $data['payoutProducts'] = $this->_condenseProductsPid($this->payoutProducts);
         $payoutVals = $this->_getSalesTargetData($dealer, $executionDataType, $this->payoutProducts);
     }
     // Plugin the value / volume / qty data
     $vals = $this->_getSalesTargetData($dealer, $executionDataType, $this->products);
     // Plugin the qty as per the lap Entry type
     if (strcasecmp($this->type->getValue(), \Akzo\Scheme\Data\Common\QuantityType::VALUE) === 0) {
         $data['qty'] = $vals['value'];
     } else {
         if (strcasecmp($this->type->getValue(), \Akzo\Scheme\Data\Common\QuantityType::VOLUME) === 0) {
             $data['qty'] = $vals['volume'];
         } else {
             if (strcasecmp($this->type->getValue(), \Akzo\Scheme\Data\Common\QuantityType::GROWTH) === 0) {
                 $prevSalesData = \Akzo\Sales\Service::getInstance()->loadSalesDataFromDealer($dealer, $data['previousPeriod']);
                 $currSalesData = \Akzo\Sales\Service::getInstance()->loadSalesDataFromDealer($dealer, $data['currentPeriod']);
                 $data['qty'] = ($currSalesData['value'] / $prevSalesData['value'] - 1) * 100;
             }
         }
     }
     if (isset($data['payoutProducts']) && !empty($data['payoutProducts'])) {
         $data['value'] = $payoutVals['value'];
         $data['volume'] = $payoutVals['volume'];
     } else {
         $data['value'] = $vals['value'];
         $data['volume'] = $vals['volume'];
     }
     //third one with getsalesdata(prevPeriod) and getsalesdata(currPeriod) and get growth percentage a/b*100 from there
     // Add the qcList execution data
     $data['qcList'] = array();
     foreach ($this->qcList as $idx => $qc) {
         $data['qcList'][] = $qc->toRuleEngineDealerExecData($dealer, $executionDataType, 'none');
     }
     if (strcasecmp($format, 'json') === 0) {
         return json_encode($data);
     } else {
         return $data;
     }
 }
 /**
  * Rule Engine Execution Data Generator for a Dealer
  * 
  * @param \Akzo\Dealer $dealer Dealer for which to generate execution data
  * @param boolean $format none | json
  */
 public function toRuleEngineDealerExecData(\Akzo\Dealer $dealer, $executionDataType, $format = 'none')
 {
     $data = array();
     // Plugin lap entry data
     $data['tplId'] = $this->tplId;
     $data['period'] = $this->period->toRuleEngineData();
     // Condense the products pid into a single product pid array
     $data['product'] = $this->_condenseProductsPid();
     $data['packs'] = $this->packs;
     $data['projectSku'] = $this->projectSku;
     // Plugin the value / volume / qty data
     $vals = $this->_getSalesTargetData($dealer, $executionDataType);
     $data['value'] = $vals['value'];
     $data['volume'] = $vals['volume'];
     // For inBillEntries qty is same as volume
     $data['qty'] = $vals['volume'];
     if (strcasecmp($format, 'json') === 0) {
         return json_encode($data);
     } else {
         return $data;
     }
 }
Exemple #5
0
 /**
  * Rule Engine Data Generator
  * @param $format none | json
  */
 public function toRuleEngineData($format = 'none')
 {
     $data = array();
     $data['id'] = $this->id;
     $data['templateName'] = $this->templateName;
     $data['segment'] = $this->segment;
     $data['ppiType'] = $this->ppiType->getValue();
     $data['period'] = $this->period->toRuleEngineData();
     $data['numSlabs'] = $this->numSlabs;
     // Condense the products pid into a single product pid array
     $data['products'] = $this->_condenseProductsPid();
     $data['packs'] = $this->packs;
     $data['projectSku'] = $this->projectSku;
     $data['slabPayouts'] = array();
     foreach ($this->slabPayouts as $idx => $payout) {
         $data['slabPayouts'][] = $payout->toRuleEngineData();
     }
     if (strcasecmp($format, 'json') === 0) {
         return json_encode($data);
     } else {
         return $data;
     }
 }
Exemple #6
0
 /**
  * Rule Engine Data Generator
  * @param $format none | json
  */
 public function toRuleEngineData($format = 'none')
 {
     $data = array();
     $data['id'] = $this->id;
     $data['templateName'] = $this->templateName;
     $data['segment'] = $this->segment;
     $data['priType'] = $this->priType->getValue();
     $data['priProducts'] = array();
     foreach ($this->priProducts as $idx => $product) {
         $data['priProducts'][] = $product->toRuleEngineData();
     }
     $data['period'] = $this->period->toRuleEngineData();
     $data['numSlabs'] = $this->numSlabs;
     $data['projectSku'] = $this->projectSku;
     $data['priPayouts'] = array();
     foreach ($this->priPayouts as $idx => $payout) {
         $data['priPayouts'][] = $payout->toRuleEngineData();
     }
     if (strcasecmp($format, 'json') === 0) {
         return json_encode($data);
     } else {
         return $data;
     }
 }