/** * 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; } }
/** * Rule Engine Data Generator * @param $format none | json */ public function toRuleEngineData($format = 'none') { $data = array(); $data['qid'] = $this->qid; $data['name'] = $this->name->getValue(); $data['type'] = $this->type->getValue(); $data['op'] = $this->op->getValue(); $data['val'] = $this->val; $data['payoutCondition'] = $this->payoutCondition / 100; 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(); 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 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['slabType'] = $this->slabType->getValue(); $data['numLaps'] = $this->numLaps; $data['projectSku'] = $this->projectSku; $data['laps'] = array(); foreach ($this->laps as $idx => $lap) { $data['laps'][] = $lap->toRuleEngineData(); } if (strcasecmp($format, 'json') === 0) { return json_encode($data); } else { return $data; } }
/** * 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['slabType'] = $this->slabType->getValue(); // Condense the products pid into a single product pid array $data['products'] = $this->_condenseProductsPid(); $data['packs'] = $this->packs; $data['numSlabs'] = $this->numSlabs; $data['projectSku'] = $this->projectSku; $data['laps'] = array(); foreach ($this->laps as $idx => $lap) { $data['laps'][] = $lap->toRuleEngineData(); } if (strcasecmp($format, 'json') === 0) { return json_encode($data); } else { return $data; } }
/** * 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; } }