/** * Saves userdata entered in payment fieldset * * @param Enlight_Event_EventArgs $args Arguments * @param Array $userBirthday Userbirthday */ function saveUserData(Enlight_Event_EventArgs $args) { $userData = array(); $post = $args->getSubject()->Request()->getPost(); $userData = $args->getSubject()->View()->sUserData; $paymentId = 0; if ($post['saveRatepayRateData']) { saveUserDataInDB($args, 'rate'); $paymentId = getRatePaymentId(); }elseif($post['saveRatepayDebitData']){ saveUserDataInDB($args, 'debit'); $paymentId = getDebitPaymentId(); }else{ saveUserDataInDB($args, 'invoice'); $paymentId = getInvoicePaymentId(); } $sql = "SELECT `birthday`, `phone`, `company`, `ustid` FROM `s_user_billingaddress` WHERE `id` = ?"; $newData = Shopware()->Db()->fetchRow($sql, array((int)$userData['billingaddress']['id'])); if (($newData['company'] && !$newData['ustid']) || (!$newData['phone'] && $newData['ustid'])) $companyFlag = true; if ($newData['birthday'] != "0000-00-00" && $newData['birthday'] && !$companyFlag && !$args->getSubject()->View()->pi_ratepay_toyoung) { $sql = "UPDATE `s_user` SET `paymentID` = ? WHERE `id` = ?"; Shopware()->Db()->query($sql, array((int)$post['register']['payment'],(int)$userData['billingaddress']['userID'])); } }
/** * Event listener method that saves the cart min/max in the plugin configuration for showing RatePAY * * @param Enlight_Event_EventArgs $args */ public function onRatepayBackendPlugin($config = null) { //Checking if the Config Form is getting saved and the Config is saved for this Plugin if (!is_null($config)) { $invoiceId = getInvoicePaymentId(); $rateId = getRatePaymentId(); $debitId = getDebitPaymentId(); $sql = "SELECT * FROM s_core_shops"; $results = Shopware()->Db()->fetchAll($sql); foreach($results as $shop) { //Deleting old Rules for Min and Max Basket $sql = "DELETE FROM `s_core_rulesets` WHERE(`paymentID` = ? OR `paymentID` = ? OR `paymentID` = ?) AND `rule1` like 'SUBSHOP' AND `value1` like ? AND (`rule2` like 'ORDERVALUELESS' OR `rule2` like 'ORDERVALUEMORE')"; Shopware()->Db()->query($sql, array((int)$invoiceId, (int)$rateId, (int)$debitId, $shop['id'])); } foreach($config as $shopId => $shopConfig) { foreach($shopConfig as $name=>$value) { switch($name) { case 'basket_min_invoice': $this->_saveMinMaxToRuleset($shopId, $invoiceId, 'ORDERVALUELESS', $value); break; case 'basket_max_invoice': $this->_saveMinMaxToRuleset($shopId, $invoiceId, 'ORDERVALUEMORE', $value); break; case 'basket_min_rate': $this->_saveMinMaxToRuleset($shopId, $rateId, 'ORDERVALUELESS', $value); break; case 'basket_max_rate': $this->_saveMinMaxToRuleset($shopId, $rateId, 'ORDERVALUEMORE', $value); break; case 'basket_min_debit': $this->_saveMinMaxToRuleset($shopId, $debitId, 'ORDERVALUELESS', $value); break; case 'basket_max_debit': $this->_saveMinMaxToRuleset($shopId, $debitId, 'ORDERVALUEMORE', $value); break; } } } } }
/** * Gets data for stats. Delivers JASON String * * @see templates/backend/plugins/PigmbhRatePAYPayment/index.php * @throws RatePAYException */ public function getStatsUmsatzMonatAction() { $this->View()->setTemplate(); $sql = "SELECT MONTH(ordertime) as month ,SUM(invoice_amount) as invoice_amount FROM s_order WHERE paymentID = ? OR paymentID = ? OR paymentID = ? GROUP BY month"; $counter = Shopware()->Db()->fetchAll($sql, array((int)getInvoicePaymentId(), (int)getRatePaymentId(), (int)getDebitPaymentId())); $counter > 12? $start = $counter - 12: $start = 0; $sql = "SELECT MONTH(ordertime) as month ,SUM(invoice_amount) as invoice_amount FROM s_order WHERE paymentID = ? OR paymentID = ? OR paymentID = ? GROUP BY month ORDER BY ordertime LIMIT " . (int)$start . ",12"; $orders = Shopware()->Db()->fetchAll($sql, array((int)getInvoicePaymentId(), (int)getRatePaymentId(), (int)getDebitPaymentId())); for ($i = 0; $i < sizeof($orders); $i++) { $orders[$i]['total'] = intval($orders[$i]['invoice_amount']); switch ($orders[$i]['month']) { case 1: $orders[$i]['month'] = 'Januar'; break; case 2: $orders[$i]['month'] = 'Februar'; break; case 3: $orders[$i]['month'] = 'März'; break; case 4: $orders[$i]['month'] = 'April'; break; case 5: $orders[$i]['month'] = 'Mai'; break; case 6: $orders[$i]['month'] = 'Juni'; break; case 7: $orders[$i]['month'] = 'Juli'; break; case 8: $orders[$i]['month'] = 'August'; break; case 9: $orders[$i]['month'] = 'September'; break; case 10: $orders[$i]['month'] = 'Oktober'; break; case 11: $orders[$i]['month'] = 'November'; break; case 12: $orders[$i]['month'] = 'Dezember'; break; default: $orders[$i]['month'] = "Monat"; } } echo json_encode(array("mytotal" => $counter, "items" => $orders)); }