/** * 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)); }
/** * Event listener method handles all Frontend actions * * @param Enlight_Event_EventArgs $args */ static function onPostRatepayDispatch(Enlight_Event_EventArgs $args) { $config = Shopware()->Plugins()->Frontend()->PigmbhRatePAYPayment()->Config(); Shopware()->Template()->addTemplateDir(dirname(__FILE__) . '/Views/Frontend/'); /** @var $request Enlight_Controller_Request_RequestHttp */ $request = $args->getSubject()->Request(); // just be active in the frontend and while the plugin is enabled if ($request->getModuleName() == 'frontend' && $config->multishopactive == true) { $view = $args->getSubject()->View(); Shopware()->Session()->pi_ratepay_rate_calc_path = Shopware()->Config()->get('basepath') . '/engine/Shopware/Plugins/Default/Frontend/PigmbhRatePAYPayment/Ratenrechner/'; // return if no template could be found. if(!$view->hasTemplate()) { return; } $userData = $view->sUserData; if(isset($userData['billingadress']['id'])) { Shopware()->Session()->RatepayCustomerId=$userData['billingadress']['id']; } $ratepayPayment=checkRatepayPayment($userData); if ($userData && $ratepayPayment) { checkBillingEqualShipping($userData, $view); checkB2BAllowed($userData, $view); if(Shopware()->Session()->ratepayB2BInvoice && $userData["additional"]["payment"]["name"] == "RatePAYInvoice" || Shopware()->Session()->ratepayB2BRate && $userData["additional"]["payment"]["name"] == "RatePAYRate" || Shopware()->Session()->ratepayB2BDebit && $userData["additional"]["payment"]["name"] == "RatePAYDebit" || Shopware()->Session()->ratePAYadressDiff) { $sql = "UPDATE `s_user` SET `paymentID` = ? WHERE `id` = ?"; Shopware()->Db()->query($sql, array( (int)Shopware()->Config()->Paymentdefault, (int)$userData['billingaddress']['userID'] )); } } $view->extendsTemplate('index/header.tpl'); //Checks if customer can pay with RatePAY, sets error messages and loads payment_fieldset template //Also implements fix for older templates and sets debit data // sViewport has been removed - instead $args->getSubject()->Request()->getControllerName() can be used if ($request->getControllerName() == 'account' || $request->getControllerName() == 'checkout' || $request->getControllerName() == 'register') { $basket = Shopware()->Session()->sOrderVariables['sBasket']; //gets userage and checks user data if ($userData) { $userAge = getUserAge($userData, $view); checkBillingEqualShipping($userData, $view); checkUserData($userData, $view, $userAge); checkB2BAllowed($userData, $view); $view->debitData = getEncodedDebitData($userData['billingaddress']['userID']); if(!isset($view->debitData)) $view->debitData = getDebitData(); } //displays surcharge at payment selection if($basket){ setSurcharge($basket, $view); Shopware()->Session()->pi_ratepay_Warenkorbbetrag = number_format($basket['AmountNumeric'], 2, ".", ""); } $view->activateDebit = $config->activate_debit; $view->extendsTemplate('register/payment_fieldset.tpl'); //Saves data entered in RatePAY form if ($request->getActionName() == 'savePayment') { $post = $args->getSubject()->Request()->getPost(); setDirectDebitSession($post); if (isset($post['saveRatepayInvoiceData']) || isset($post['saveRatepayRateData']) || isset($post['saveRatepayDebitData'])){ saveUserData($args); } elseif($post['register']['payment'] == getDebitPaymentId() || ($post['register']['payment']== getRatePaymentId() && Shopware()->Session()->RatepayDirectDebit)){ if(!checkDebitData($post)){ header('Location:'.str_replace("savePayment","payment",Shopware()->Config()->Host.$_SERVER['REQUEST_URI'])); //break; } else{ Shopware()->Session()->RatepayRateMissingBankData = false; Shopware()->Session()->RatepayDebitMissingBankData = false; saveDebitData($args); } } } //template fix and saving of direct debit selection for ratepay installment if($request->getActionName() == 'payment'){ if(Shopware()->Session()->RatepayDebitMissingBankData){ $view->RatepayDebitMissingBankData = true; } elseif(Shopware()->Session()->RatepayRateMissingBankData){ $view->RatepayRateMissingBankData = true; } } //Sets debit data if(Shopware()->Session()->RatepayDirectDebit){ $view->ratepayDebitPayType = Shopware()->Session()->RatepayDirectDebit; } //Extends checkout with RatePAY AGB, rate calculator and payment notices and also sets template vars if ($request->getControllerName() == 'checkout' && $request->getActionName() != 'finish' && $request->getActionName() != 'cart' && $request->sTargetAction != 'cart' && isset($ratepayPayment)) { $view->extendsTemplate('checkout/confirm.tpl'); setTemplateVars($view, $request, $config, $userData); } //Confirms RatePAY order at finish page if ($request->getControllerName() == 'checkout' && $request->getActionName() == 'finish' && $request->getActionName() != 'cart' && $ratepayPayment && !Shopware()->Session()->pi_ratepay_Confirm){ confirmPayment($config, $userData); } } } }
/** * Sets Bankdata to XXX * * @param Array $post Current request * @return boolean */ function checkDebitData($post) { if($post['register']['payment'] == getRatePaymentId()){ Shopware()->Session()->RatepayDebitMissingBankData = false; if(empty($post['ratepayRateDebit']['owner'])){ Shopware()->Session()->RatepayRateMissingBankData = true; Shopware()->Session()->RatepayOwner = false; return false; } else{ Shopware()->Session()->RatepayOwner = $post['ratepayDebit']['owner']; } if(empty($post['ratepayRateDebit']['accountnumber'])){ Shopware()->Session()->RatepayRateMissingBankData = true; Shopware()->Session()->RatepayAccountnumber = false; return false; } else{ Shopware()->Session()->RatepayAccountnumber = $post['ratepayDebit']['accountnumber']; } if(empty($post['ratepayRateDebit']['bankcode'])){ Shopware()->Session()->RatepayRateMissingBankData = true; Shopware()->Session()->RatepayBankcode = false; return false; } else{ Shopware()->Session()->RatepayBankcode = $post['ratepayDebit']['bankcode']; } if(empty($post['ratepayRateDebit']['bankname'])){ Shopware()->Session()->RatepayRateMissingBankData = true; Shopware()->Session()->RatepayBankname = false; return false; } else{ Shopware()->Session()->RatepayBankname = $post['ratepayDebit']['bankname']; } } elseif($post['register']['payment'] == getDebitPaymentId()){ Shopware()->Session()->RatepayRateMissingBankData = false; if(empty($post['ratepayDebit']['owner'])){ Shopware()->Session()->RatepayDebitMissingBankData = true; Shopware()->Session()->RatepayOwner = false; return false; } else{ Shopware()->Session()->RatepayOwner = $post['ratepayDebit']['owner']; } if(empty($post['ratepayDebit']['accountnumber'])){ Shopware()->Session()->RatepayDebitMissingBankData = true; Shopware()->Session()->RatepayAccountnumber = false; return false; } else{ Shopware()->Session()->RatepayAccountnumber = $post['ratepayDebit']['accountnumber']; } if(empty($post['ratepayDebit']['bankcode'])){ Shopware()->Session()->RatepayDebitMissingBankData = true; Shopware()->Session()->RatepayBankcode = false; return false; } else{ Shopware()->Session()->RatepayBankcode = $post['ratepayDebit']['bankcode']; } if(empty($post['ratepayDebit']['bankname'])){ Shopware()->Session()->RatepayDebitMissingBankData = true; Shopware()->Session()->RatepayBankname = false; return false; } else{ Shopware()->Session()->RatepayBankname = $post['ratepayDebit']['bankname']; } } return true; }