/**
  * check password
  *
  */
 private function checkPassword()
 {
     $password = $this->getRequest()->getParam('password');
     if ($password != mage::getStoreConfig('clientcomputer/general/password')) {
         die('Access denied');
     }
 }
 /**
  * Method to calculate order weight depending of configuration
  *
  * @param unknown_type $order
  */
 public function calculateOrderWeight($products)
 {
     $retour = 0;
     //If calculation is enabled
     if (mage::getStoreConfig('orderpreparation/order_weight_calculation/enable')) {
         //compute bulk product weight
         for ($i = 0; $i < count($products); $i++) {
             $productId = $products[$i]['product_id'];
             $product = mage::getModel('catalog/product')->load($productId);
             if ($product->getId()) {
                 $qty = $products[$i]['qty'];
                 $retour += $product->getWeight() * $qty;
             }
         }
         //Add additional weight
         $methodValue = mage::getStoreConfig('orderpreparation/order_weight_calculation/additional_weight_value');
         switch (mage::getStoreConfig('orderpreparation/order_weight_calculation/additional_weight_method')) {
             case MDN_Orderpreparation_Model_OrderWeightCalculation::METHOD_ADD_FIX_WEIGHT:
                 $retour += $methodValue;
                 break;
             case MDN_Orderpreparation_Model_OrderWeightCalculation::METHOD_ADD_FIX_WEIGHT_PER_PRODUCT:
                 for ($i = 0; $i < count($products); $i++) {
                     $qty = $products[$i]['qty'];
                     $retour += $qty * $methodValue;
                 }
                 break;
             case MDN_Orderpreparation_Model_OrderWeightCalculation::METHOD_ADD_PERCENT:
                 $retour += $retour / 100 * $methodValue;
                 break;
         }
     }
     return $retour;
 }
Example #3
0
 /**
  * Can Save Enabled
  * @return string
  */
 public function canSave()
 {
     $cansave = mage::getStoreConfig('payment/pinpayments/can_save');
     $isLoggedIn = mage::getSingleton('customer/session')->isLoggedIn();
     if ($cansave && $isLoggedIn) {
         return true;
     }
     return false;
 }
 /**
  * Retourne le taux de taxe achat pour le produit
  *
  */
 public function getPurchaseTaxRate()
 {
     //Définit le tax id
     $TaxId = $this->getpurchase_tax_rate();
     if ($TaxId == 0 || $TaxId == '') {
         $TaxId = mage::getStoreConfig('purchase/purchase_order/products_default_tax_rate');
     }
     //recupere et retourne la valeur
     return mage::getModel('Purchase/TaxRates')->load($TaxId)->getptr_value();
 }
 /**
  * If the 'limit by IP' options is set in the backend, check if the user's IP ids allowed
  * NOTE: this is only the general limit by ip option. Individual module's limit by IP options are not checked here
  *
  * @return bool
  */
 private static function _checkIpAllowed()
 {
     $ipAllowed = false;
     if (Mage::getStoreConfig('dev/restrict/allow_ips') && Mage::getStoreConfig('buckaroo/buckaroo3extended_advanced/limit_by_ip')) {
         $allowedIp = explode(',', mage::getStoreConfig('dev/restrict/allow_ips'));
         if (in_array(Mage::helper('core/http')->getRemoteAddr(), $allowedIp)) {
             $ipAllowed = true;
         }
     } else {
         $ipAllowed = true;
     }
     return $ipAllowed;
 }
Example #6
0
 /**
  * Delete tasks depending of config
  *
  */
 public function deleteTasks()
 {
     $dbh = $this->_getWriteAdapter();
     $ExpireTimeStamp = time() - mage::getStoreConfig('backgroundtask/general/history_duration') * 3600;
     $ExpireDate = date('Y-m-d H:i', $ExpireTimeStamp);
     $deleteErrorTask = mage::getStoreConfig('backgroundtask/general/delete_error_tasks');
     $condition = ' bt_executed_at is not null ';
     if (!$deleteErrorTask) {
         $condition .= " and bt_result <> 'error'";
     }
     $condition .= " and bt_executed_at < '" . $ExpireDate . "'";
     try {
         $dbh->delete($this->getTable('BackgroundTask/Task'), $condition);
     } catch (Exception $ex) {
         throw new Exception("Error while deleting tasks : " . $ex->getMessage());
     }
 }
Example #7
0
 /**
  * Talk to pin gateway
  * 
  * @param array $data
  * @param string $endPoint
  * @return object
  */
 protected function talkToGateway($data, $endPoint, $proto = Zend_Http_Client::POST)
 {
     $url = mage::helper('pinpayments')->getGatewayUrl() . '1/' . $endPoint;
     $secretKey = mage::getStoreConfig('payment/pinpayments/secret_api_key');
     if ($proto == Zend_Http_Client::PUT) {
         $result = exec("curl {$url} -u {$secretKey}: -X PUT -d email={$data['email']} -d card_token={$data['card_token']}", $output, $return_var);
     } else {
         $curl = new ProxiBlue_PinPayments_Varien_Http_Adapter_Curl();
         $curl->setConfig(array('timeout' => 15));
         $curl->setConfig(array('userpwd' => mage::getStoreConfig('payment/pinpayments/secret_api_key') . ":"));
         $curl->write($proto, $url, '1.1', null, $data);
         $curlData = $curl->read();
         $result = Zend_Http_Response::extractBody($curlData);
         $curl->close();
         $result = json_decode($result);
     }
     return $result;
 }
 /**
  * Execute tasks (limited by max execution time)
  *
  */
 public function execute()
 {
     $startTime = time();
     $hasTask = true;
     $maxExecutionTime = mage::getStoreConfig('backgroundtask/general/max_execution_time');
     while (time() - $startTime < $maxExecutionTime && $hasTask) {
         //collect next task to execute
         $task = $this->getNextTaskToExecute();
         //execute task
         if ($task) {
             $task->execute();
             $this->setbtg_executed_tasks($this->getbtg_executed_tasks() + 1)->save();
         } else {
             //no task to execute, quit loop
             $hasTask = false;
         }
     }
 }
 public function sendEmailReview()
 {
     $new_no_spam_review_yn = mage::getStoreConfig("no_more_spam/no_spam/new_no_spam_review");
     $enabled_review_yn = mage::getStoreConfig("no_more_spam/no_spam/enabled_review");
     if ($enabled_review_yn == 0) {
         return;
     }
     if ($new_no_spam_review_yn == 0) {
         return;
     }
     if ($this->checkCronTime() == false) {
         return;
     }
     $review_collection = $this->getReviewsToday();
     $ids = array();
     $reviews_collection = array();
     foreach ($review_collection as $review) {
         $review_id = $review->getData('review_id');
         $ids[] = $review_id;
         $reviews_collection[] = $review;
     }
     Mage::helper("nomorespam")->sendEmailNotify($ids, $reviews_collection);
 }
 /**
  * Sav le produit
  *
  */
 public function SaveAction()
 {
     //recupere les infos
     $ProductId = $this->getRequest()->getPost('product_id');
     $StockMini = $this->getRequest()->getPost('notity_stock_qty');
     $UseConfigStockMini = $this->getRequest()->getPost('use_config_notify_stock_qty');
     if ($UseConfigStockMini == '') {
         $UseConfigStockMini = 0;
     }
     $exclude_from_supply_needs = $this->getRequest()->getPost('exclude_from_supply_needs');
     if ($exclude_from_supply_needs == '') {
         $exclude_from_supply_needs = 0;
     }
     $DefaultSupplyDelay = $this->getRequest()->getPost('default_supply_delay');
     //define price to store
     if (mage::getStoreConfig('tax/calculation/price_includes_tax')) {
         $productPrice = $this->getRequest()->getPost('price_ttc');
     } else {
         $productPrice = $this->getRequest()->getPost('price');
     }
     //met a jour
     $product = mage::getModel('catalog/product')->load($ProductId);
     $product->setdefault_supply_delay($DefaultSupplyDelay);
     $product->setexclude_from_supply_needs($exclude_from_supply_needs);
     $product->setprice($productPrice);
     $product->setmanual_supply_need_qty($this->getRequest()->getPost('manual_supply_need_qty'));
     $product->setmanual_supply_need_comments($this->getRequest()->getPost('manual_supply_need_comments'));
     $product->setmanual_supply_need_date($this->getRequest()->getPost('manual_supply_need_date'));
     $product->setpurchase_tax_rate($this->getRequest()->getPost('purchase_tax_rate'));
     $product->save();
     $product->getStockItem()->setnotify_stock_qty($StockMini)->setuse_config_notify_stock_qty($UseConfigStockMini)->save();
     //confirme
     Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Product successfully Saved'));
     //Redirige vers la fiche créée
     $this->_redirect('Purchase/Products/Edit/product_id/' . $ProductId);
 }
 /**
  * New subscription action
  */
 public function newAction()
 {
     $data = $this->getRequest()->getPost();
     $isKeyHash = false;
     $field_1 = Mage::helper("nomorespam")->getNmsField1();
     $empty_text = Mage::helper("nomorespam")->getNmsField2();
     if (isset($data[$field_1]) && isset($data[$empty_text])) {
         $isKeyHash = $this->checkHashKey($data[$field_1], $data[$empty_text]);
     }
     //else $isKeyHash = true; //
     $enabled_newsletter = mage::getStoreConfig("no_more_spam/no_spam/enabled_newsletter");
     $session = Mage::getSingleton('core/session');
     if (!$enabled_newsletter) {
         $isKeyHash = true;
     }
     // if this section is off in nomorespam config then don't check our fields
     if ($this->getRequest()->isPost() && $this->getRequest()->getPost('email') && $isKeyHash) {
         $customerSession = Mage::getSingleton('customer/session');
         $email = (string) $this->getRequest()->getPost('email');
         try {
             if (!Zend_Validate::is($email, 'EmailAddress')) {
                 Mage::throwException($this->__('Please enter a valid email address.'));
             }
             if (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 && !$customerSession->isLoggedIn()) {
                 Mage::throwException($this->__('Sorry, but administrator denied subscription for guests. Please <a href="%s">register</a>.', Mage::helper('customer')->getRegisterUrl()));
             }
             $ownerId = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email)->getId();
             if ($ownerId !== null && $ownerId != $customerSession->getId()) {
                 Mage::throwException($this->__('This email address is already assigned to another user.'));
             }
             $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
             if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
                 $session->addSuccess($this->__('Confirmation request has been sent.'));
             } else {
                 $session->addSuccess($this->__('Thank you for your subscription.'));
             }
         } catch (Mage_Core_Exception $e) {
             $session->addException($e, $this->__('There was a problem with the subscription: %s', $e->getMessage()));
         } catch (Exception $e) {
             $session->addException($e, $this->__('There was a problem with the subscription.'));
         }
         $this->_redirectReferer();
     } else {
         $session->addError($this->__('Unable subscription. Try again later.'));
         $this->_redirectReferer();
     }
 }
 /**
  * Return js code to execute on commit button 
  *
  */
 public function getCommitJsAction()
 {
     $retour = 'commit(';
     //save data
     $retour .= 'true,';
     if (mage::getStoreConfig('orderpreparation/commit_button_actions/create_shipments_invoices') == 1) {
         $retour .= 'true,';
     } else {
         $retour .= 'false,';
     }
     if (mage::getStoreConfig('orderpreparation/commit_button_actions/print_documents') == 1) {
         $retour .= 'true,';
     } else {
         $retour .= 'false,';
     }
     if (mage::getStoreConfig('orderpreparation/commit_button_actions/download_documents') == 1) {
         $retour .= 'true,';
     } else {
         $retour .= 'false,';
     }
     if (mage::getStoreConfig('orderpreparation/commit_button_actions/print_shipping_label') == 1) {
         $retour .= 'true,';
     } else {
         $retour .= 'false,';
     }
     if (mage::getStoreConfig('orderpreparation/commit_button_actions/select_next_order') == 1) {
         $retour .= 'true';
     } else {
         $retour .= 'false';
     }
     $retour .= ');';
     return $retour;
 }
 public function postAction()
 {
     $post = $this->getRequest()->getPost();
     $isKeyHash = false;
     $enable_email = mage::getStoreConfig("no_more_spam/no_spam/enabled_email");
     if ($enable_email == 1) {
         $field_1 = Mage::helper("nomorespam")->getNmsField1();
         $empty_text = Mage::helper("nomorespam")->getNmsField2();
         if (isset($post[$field_1]) && isset($post[$empty_text])) {
             $isKeyHash = $this->_checkHashKey($post[$field_1], $post[$empty_text]);
         }
     }
     if (!$enable_email) {
         $isKeyHash = true;
     }
     // if this section is off in nomorespam config then don't check our fields
     if ($post && $isKeyHash) {
         $translate = Mage::getSingleton('core/translate');
         /* @var $translate Mage_Core_Model_Translate */
         $translate->setTranslateInline(false);
         try {
             $postObject = new Varien_Object();
             $postObject->setData($post);
             $error = false;
             if (!Zend_Validate::is(trim($post['name']), 'NotEmpty')) {
                 $error = true;
             }
             if (!Zend_Validate::is(trim($post['comment']), 'NotEmpty')) {
                 $error = true;
             }
             if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
                 $error = true;
             }
             if (isset($post['hideit']) && Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
                 $error = true;
             }
             if ($this->_checkManualSpam()) {
                 $error = true;
             }
             if ($error) {
                 throw new Exception();
             }
             $mailTemplate = Mage::getModel('core/email_template');
             /* @var $mailTemplate Mage_Core_Model_Email_Template */
             $mailTemplate->setDesignConfig(array('area' => 'frontend'))->setReplyTo($post['email'])->sendTransactional(Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE), Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER), Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT), null, array('data' => $postObject));
             if (!$mailTemplate->getSentSuccess()) {
                 throw new Exception();
             }
             $translate->setTranslateInline(true);
             Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.'));
             $this->_redirect('*/*/');
             return;
         } catch (Exception $e) {
             $translate->setTranslateInline(true);
             Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to send message. Please, try again later'));
             $this->_redirect('*/*/');
             return;
         }
     } else {
         $translate = Mage::getSingleton('core/translate');
         $translate->setTranslateInline(true);
         Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later'));
         $this->_redirect('*/*/');
     }
 }
Example #14
0
 /**
  * Notify developper by email
  *
  */
 public function notifyDevelopper($msg)
 {
     $email = mage::getStoreConfig('backgroundtask/general/debug');
     if ($email != '') {
         mail($email, 'Magento Background Task notification', $msg);
     }
 }
 public function isAvailable($quote = null)
 {
     $storeId = Mage::app()->getStore()->getId();
     // Check if quote is null, and try to look it up based on adminhtml session
     if (!$quote && Mage::helper('buckaroo3extended')->isAdmin()) {
         $quote = Mage::getSingleton('adminhtml/session_quote');
     }
     // If quote is not null, set storeId to quote storeId
     if ($quote) {
         $storeId = $quote->getStoreId();
     }
     // Check if the module is set to enabled
     if (!Mage::getStoreConfig('buckaroo/' . $this->_code . '/active', $storeId)) {
         return false;
     }
     // Check if the country specified in the billing address is allowed to use this payment method
     if ($quote && Mage::getStoreConfigFlag('buckaroo/' . $this->_code . '/allowspecific', $storeId) && $quote->getBillingAddress()->getCountry()) {
         $allowedCountries = explode(',', Mage::getStoreConfig('buckaroo/' . $this->_code . '/specificcountry', $storeId));
         $country = $quote->getBillingAddress()->getCountry();
         if (!in_array($country, $allowedCountries)) {
             return false;
         }
     }
     $areaAllowed = null;
     if ($this->canUseInternal()) {
         $areaAllowed = Mage::getStoreConfig('buckaroo/' . $this->_code . '/area', $storeId);
     }
     // Check if the paymentmethod is available in the current shop area (frontend or backend)
     if ($areaAllowed == 'backend' && !Mage::helper('buckaroo3extended')->isAdmin()) {
         return false;
     } elseif ($areaAllowed == 'frontend' && Mage::helper('buckaroo3extended')->isAdmin()) {
         return false;
     }
     // Check if max amount for the issued PaymentMethod is set and if the quote basegrandtotal exceeds that
     $maxAmount = Mage::getStoreConfig('buckaroo/' . $this->_code . '/max_amount', $storeId);
     if ($quote && !empty($maxAmount) && $quote->getBaseGrandTotal() > $maxAmount) {
         return false;
     }
     // check if min amount for the issued PaymentMethod is set and if the quote basegrandtotal is less than that
     $minAmount = Mage::getStoreConfig('buckaroo/' . $this->_code . '/min_amount', $storeId);
     if ($quote && !empty($minAmount) && $quote->getBaseGrandTotal() < $minAmount) {
         return false;
     }
     // Check limit by ip
     if (mage::getStoreConfig('dev/restrict/allow_ips') && Mage::getStoreConfig('buckaroo/' . $this->_code . '/limit_by_ip')) {
         $allowedIp = explode(',', mage::getStoreConfig('dev/restrict/allow_ips'));
         if (!in_array(Mage::helper('core/http')->getRemoteAddr(), $allowedIp)) {
             return false;
         }
     }
     // get current currency code
     $currency = Mage::app()->getStore()->getBaseCurrencyCode();
     // currency is not available for this module
     if (!in_array($currency, $this->allowedCurrencies)) {
         return false;
     }
     if (!TIG_Buckaroo3Extended_Model_Request_Availability::canUseBuckaroo($quote)) {
         return false;
     }
     return parent::isAvailable($quote);
 }
 /**
  * Check if an order is considered
  *
  * @param unknown_type $order
  */
 public function orderIsConsidered($order)
 {
     $retour = true;
     //status
     $AllowedStates = mage::getStoreConfig('purchase/considered_orders/managed_order_status');
     $pos = strpos($AllowedStates, $order->getState());
     if ($pos === false) {
         return false;
     }
     //total due
     if (mage::getStoreConfig('purchase/considered_orders/require_totaldue_equal_zero') == 1) {
         if ($order->getTotalDue() > 0) {
             return false;
         }
     }
     //payment validated
     if (mage::getStoreConfig('purchase/considered_orders/require_payment_validated_flag') == 1) {
         if ($order->getpayment_validated() == 0) {
             return false;
         }
     }
     return $retour;
 }
Example #17
0
 /**
  * return a array with the height and height of the label
  */
 public function getLabelSize()
 {
     $topMargin = $this->cmToPixels(mage::getStoreConfig('barcodelabel/pdf/top_margin'));
     $leftMargin = $this->cmToPixels(mage::getStoreConfig('barcodelabel/pdf/left_margin'));
     $rightMargin = $this->cmToPixels(mage::getStoreConfig('barcodelabel/pdf/right_margin'));
     $bottomMargin = $this->cmToPixels(mage::getStoreConfig('barcodelabel/pdf/bottom_margin'));
     $verticalSpacing = $this->cmToPixels(mage::getStoreConfig('barcodelabel/pdf/vertical_inter_margin'));
     $horizontalSpacing = $this->cmToPixels(mage::getStoreConfig('barcodelabel/pdf/horizontal_inter_margin'));
     $labelsPerRow = mage::getStoreConfig('barcodelabel/pdf/labels_per_row');
     $rowCount = mage::getStoreConfig('barcodelabel/pdf/row_count');
     $widthCm = mage::getStoreConfig('barcodelabel/pdf/paper_width');
     $heightCm = mage::getStoreConfig('barcodelabel/pdf/paper_height');
     $pageWidth = $this->cmToPixels($widthCm);
     $pageHeight = $this->cmToPixels($heightCm);
     $usableWidth = $pageWidth - $leftMargin - $rightMargin;
     $usableHeight = $pageHeight - $topMargin - $bottomMargin;
     $labelWidth = ($usableWidth - ($labelsPerRow - 1) * $horizontalSpacing) / $labelsPerRow;
     $labelHeight = $usableHeight / $rowCount - $verticalSpacing;
     $labelSize = array("height" => $labelHeight, "width" => $labelWidth);
     return $labelSize;
 }
Example #18
0
 public function checkHashKey_f($data, $rating)
 {
     $isKeyHash = false;
     $session = Mage::getSingleton('core/session');
     $field_1 = $this->getNmsField1();
     $empty_text = $this->getNmsField2();
     if (isset($data[$field_1]) && isset($data[$empty_text])) {
         $isKeyHash = $this->checkHashKey($data[$field_1], $data[$empty_text]);
     } else {
         if (!isset($data[$field_1]) && !isset($data[$empty_text])) {
             $isKeyHash = true;
             $moo_message = 'Your review form is not protected as you have a custom-coded form. Please add the code described *<a href="https://www.moogento.com/guides/noMoreSpam!_Quickstart">here</a>* to enable NoMoreSpam! for your product reviews.';
             Mage::getSingleton('adminhtml/session')->addWarning($moo_message);
             Mage::log($moo_message, null, 'moogento_nomorespam.log');
         }
     }
     $enable_review = mage::getStoreConfig("no_more_spam/no_spam/enabled_review");
     $enable_review_rating = mage::getStoreConfig("no_more_spam/no_spam/enabled_review_rating");
     if (!$enable_review) {
         $isKeyHash = true;
     }
     // if this section is off in nomorespam config then don't check our fields
     $rating_collection = mage::getModel("rating/rating")->getCollection();
     if ($this->_checkManualSpam($data) || count($rating) < count($rating_collection) && $enable_review_rating == 1) {
         $isKeyHash = false;
         if ($this->_checkManualSpam($data)) {
             $session->addError($this->__('Unable to add this review at the moment.'));
         } else {
             $session->addError($this->__('Unable to add this review at the moment. Please choise ratings'));
         }
     }
     return $isKeyHash;
 }
 /**
  * Create customer account action
  */
 public function createPostAction()
 {
     $data = $this->getRequest()->getPost();
     $isKeyHash = false;
     $field_1 = Mage::helper("nomorespam")->getNmsField1();
     $empty_text = Mage::helper("nomorespam")->getNmsField2();
     if (isset($data[$field_1]) && isset($data[$empty_text])) {
         $isKeyHash = $this->checkHashKey($data[$field_1], $data[$empty_text]);
     }
     //else $isKeyHash = true; //
     $enable_create_account = mage::getStoreConfig("no_more_spam/no_spam/create_account");
     if (!$enable_create_account) {
         $isKeyHash = true;
     }
     // if this section is off in nomorespam config then don't check our fields
     $version_magento = substr(mage::getVersion(), 0, 3);
     /** @var $session Mage_Customer_Model_Session */
     $session = $this->_getSession();
     if ($session->isLoggedIn()) {
         $this->_redirect('*/*/');
         return;
     }
     $session->setEscapeMessages(true);
     // prevent XSS injection in user input
     if ($version_magento == '1.9') {
         if (!$this->getRequest()->isPost()) {
             $errUrl = $this->_getUrl('*/*/create', array('_secure' => true));
             $this->_redirectError($errUrl);
             return;
         }
     }
     if ($version_magento == '1.9') {
         if ($isKeyHash) {
             $customer = $this->_getCustomer();
             try {
                 $errors = $this->_getCustomerErrors($customer);
                 if (empty($errors)) {
                     $customer->cleanPasswordsValidationData();
                     $customer->save();
                     $this->_dispatchRegisterSuccess($customer);
                     $this->_successProcessRegistration($customer);
                     return;
                 } else {
                     $this->_addSessionError($errors);
                 }
             } catch (Mage_Core_Exception $e) {
                 $session->setCustomerFormData($this->getRequest()->getPost());
                 if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
                     $url = $this->_getUrl('customer/account/forgotpassword');
                     $message = $this->__('There is already an account with this email address. If you are sure that it is your email address, <a href="%s">click here</a> to get your password and access your account.', $url);
                     $session->setEscapeMessages(false);
                 } else {
                     $message = $e->getMessage();
                 }
                 $session->addError($message);
             } catch (Exception $e) {
                 $session->setCustomerFormData($this->getRequest()->getPost())->addException($e, $this->__('Cannot save the customer.'));
             }
         }
     } elseif ($version_magento != '1.9') {
         if ($isKeyHash) {
             if ($this->getRequest()->isPost()) {
                 $errors = array();
                 if (!($customer = Mage::registry('current_customer'))) {
                     $customer = Mage::getModel('customer/customer')->setId(null);
                 }
                 /* @var $customerForm Mage_Customer_Model_Form */
                 $customerForm = Mage::getModel('customer/form');
                 $customerForm->setFormCode('customer_account_create')->setEntity($customer);
                 $customerData = $customerForm->extractData($this->getRequest());
                 if ($this->getRequest()->getParam('is_subscribed', false)) {
                     $customer->setIsSubscribed(1);
                 }
                 /**
                  * Initialize customer group id
                  */
                 $customer->getGroupId();
                 if ($this->getRequest()->getPost('create_address')) {
                     /* @var $address Mage_Customer_Model_Address */
                     $address = Mage::getModel('customer/address');
                     /* @var $addressForm Mage_Customer_Model_Form */
                     $addressForm = Mage::getModel('customer/form');
                     $addressForm->setFormCode('customer_register_address')->setEntity($address);
                     $addressData = $addressForm->extractData($this->getRequest(), 'address', false);
                     $addressErrors = $addressForm->validateData($addressData);
                     if ($addressErrors === true) {
                         $address->setId(null)->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false));
                         $addressForm->compactData($addressData);
                         $customer->addAddress($address);
                         $addressErrors = $address->validate();
                         if (is_array($addressErrors)) {
                             $errors = array_merge($errors, $addressErrors);
                         }
                     } else {
                         $errors = array_merge($errors, $addressErrors);
                     }
                 }
                 try {
                     $customerErrors = $customerForm->validateData($customerData);
                     if ($customerErrors !== true) {
                         $errors = array_merge($customerErrors, $errors);
                     } else {
                         $customerForm->compactData($customerData);
                         $customer->setPassword($this->getRequest()->getPost('password'));
                         $customer->setConfirmation($this->getRequest()->getPost('confirmation'));
                         $customerErrors = $customer->validate();
                         if (is_array($customerErrors)) {
                             $errors = array_merge($customerErrors, $errors);
                         }
                     }
                     $validationResult = count($errors) == 0;
                     if (true === $validationResult) {
                         $customer->save();
                         Mage::dispatchEvent('customer_register_success', array('account_controller' => $this, 'customer' => $customer));
                         if ($customer->isConfirmationRequired()) {
                             $customer->sendNewAccountEmail('confirmation', $session->getBeforeAuthUrl(), Mage::app()->getStore()->getId());
                             $session->addSuccess($this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.', Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())));
                             $this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure' => true)));
                             return;
                         } else {
                             $session->setCustomerAsLoggedIn($customer);
                             $url = $this->_welcomeCustomer($customer);
                             $this->_redirectSuccess($url);
                             return;
                         }
                     } else {
                         $session->setCustomerFormData($this->getRequest()->getPost());
                         if (is_array($errors)) {
                             foreach ($errors as $errorMessage) {
                                 $session->addError($errorMessage);
                             }
                         } else {
                             $session->addError($this->__('Invalid customer data'));
                         }
                     }
                 } catch (Mage_Core_Exception $e) {
                     $session->setCustomerFormData($this->getRequest()->getPost());
                     if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
                         $url = Mage::getUrl('customer/account/forgotpassword');
                         $message = $this->__('There is already an account with this email address. If you are sure that it is your email address, <a href="%s">click here</a> to get your password and access your account.', $url);
                         $session->setEscapeMessages(false);
                     } else {
                         $message = $e->getMessage();
                     }
                     $session->addError($message);
                 } catch (Exception $e) {
                     $session->setCustomerFormData($this->getRequest()->getPost())->addException($e, $this->__('Cannot save the customer.'));
                 }
             }
             $this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true)));
         }
     }
     $session->addError($this->__('Unable create account.'));
     $this->_redirect('*/*/create');
 }
Example #20
0
 /**
  * return button list
  *
  */
 public function getButtons()
 {
     $retour = array();
     //select orders
     $item = array();
     $item['position'] = count($retour) + 1;
     $item['onclick'] = "document.location.href='" . Mage::helper('adminhtml')->getUrl('OrderPreparation/OrderPreparation') . "'";
     $item['caption'] = $this->__('Select orders');
     $retour[] = $item;
     //print picking list
     if (mage::getStoreConfig('orderpreparation/order_preparation_step/show_print_picking_list') == 1) {
         $item = array();
         $item['position'] = count($retour) + 1;
         $item['onclick'] = "ajaxCall('" . Mage::helper('adminhtml')->getUrl('OrderPreparation/OnePagePreparation/PrintPickingList') . "')";
         $item['caption'] = $this->__('Print picking list');
         $retour[] = $item;
     }
     //download picking list
     if (mage::getStoreConfig('orderpreparation/order_preparation_step/show_download_picking_list') == 1) {
         $item = array();
         $item['position'] = count($retour) + 1;
         $item['onclick'] = "document.location.href='" . Mage::helper('adminhtml')->getUrl('OrderPreparation/OnePagePreparation/DownloadPickingList') . "'";
         $item['caption'] = $this->__('Download picking list');
         $retour[] = $item;
     }
     //Create shipments & invoices
     if (mage::getStoreConfig('orderpreparation/order_preparation_step/show_create_shipments_invoices') == 1) {
         $item = array();
         $item['position'] = count($retour) + 1;
         $item['onclick'] = "document.location.href='" . Mage::helper('adminhtml')->getUrl('OrderPreparation/OrderPreparation/Commit') . "'";
         $item['caption'] = $this->__('Create shipments/invoices');
         $retour[] = $item;
     }
     //Download documents
     if (mage::getStoreConfig('orderpreparation/order_preparation_step/show_download_documents') == 1) {
         $item = array();
         $item['position'] = count($retour) + 1;
         $item['onclick'] = "document.location.href='" . Mage::helper('adminhtml')->getUrl('OrderPreparation/OrderPreparation/DownloadDocuments') . "'";
         $item['caption'] = $this->__('Download documents');
         $retour[] = $item;
     }
     //process orders
     $item = array();
     $item['position'] = count($retour) + 1;
     $item['onclick'] = "document.location.href='" . Mage::helper('adminhtml')->getUrl('OrderPreparation/OnePagePreparation') . "'";
     $item['caption'] = $this->__('Process orders');
     $retour[] = $item;
     //Import trackings
     $item = array();
     $item['position'] = count($retour) + 1;
     $item['onclick'] = "document.location.href='" . Mage::helper('adminhtml')->getUrl('OrderPreparation/CarrierTemplate/ImportTracking') . "'";
     $item['caption'] = $this->__('Shipping label / Trackings');
     $retour[] = $item;
     //Notify customers
     $item = array();
     $item['position'] = count($retour) + 1;
     $item['onclick'] = "ajaxCall('" . Mage::helper('adminhtml')->getUrl('OrderPreparation/OrderPreparation/NotifyCustomers') . "')";
     $item['caption'] = $this->__('Notify customers');
     $retour[] = $item;
     //Finish
     $item = array();
     $item['position'] = count($retour) + 1;
     $item['onclick'] = "document.location.href='" . Mage::helper('adminhtml')->getUrl('OrderPreparation/OrderPreparation/Finish') . "'";
     $item['caption'] = $this->__('Finish');
     $retour[] = $item;
     return $retour;
 }
Example #21
0
 /**
  * Return exchange directory
  *
  * @return unknown
  */
 public function getExchangeDirectory()
 {
     $retour = mage::getStoreConfig('clientcomputer/general/ftp_exchange_directory');
     if ($retour == '' || $retour == null) {
         throw new Exception('Exchange directory is not set. Operation is not sent to computer');
     }
     return $retour;
 }
 public function postAction()
 {
     if ($data = Mage::getSingleton('review/session')->getFormData(true)) {
         $rating = array();
         if (isset($data['ratings']) && is_array($data['ratings'])) {
             $rating = $data['ratings'];
         }
     } else {
         $data = $this->getRequest()->getPost();
         $rating = $this->getRequest()->getParam('ratings', array());
     }
     $enable_review = mage::getStoreConfig("no_more_spam/no_spam/enabled_review");
     $enable_review_rating = mage::getStoreConfig("no_more_spam/no_spam/enabled_review_rating");
     $isKeyHash = false;
     if ($enable_review == 1) {
         $field_1 = Mage::helper("nomorespam")->getNmsField1();
         $empty_text = Mage::helper("nomorespam")->getNmsField2();
         if (isset($data[$field_1]) && isset($data[$empty_text])) {
             $isKeyHash = $this->checkHashKey($data[$field_1], $data[$empty_text]);
         }
     }
     //else $isKeyHash = true; //
     if (!$enable_review) {
         $isKeyHash = true;
     }
     // if this section is off in nomorespam config then don't check our fields
     $session = Mage::getSingleton('core/session');
     /* @var $session Mage_Core_Model_Session */
     $review = Mage::getModel('review/review')->setData($data);
     /* @var $review Mage_Review_Model_Review */
     $rating_collection = mage::getModel("rating/rating")->getCollection();
     if (($product = $this->_initProduct()) && !empty($data) && $isKeyHash) {
         // $session    = Mage::getSingleton('core/session');
         //             /* @var $session Mage_Core_Model_Session */
         //             $review     = Mage::getModel('review/review')->setData($data);
         //             /* @var $review Mage_Review_Model_Review */
         $validate = $review->validate();
         if ($validate === true) {
             if ($enable_review == 1 && $this->_checkManualSpam()) {
                 $session->addError($this->__('Unable to add this review at the moment.'));
             } else {
                 if ($enable_review == 1 && count($rating) < count($rating_collection) && $enable_review_rating == 1) {
                     $session->addError($this->__('Unable to add this review at the moment. Please choise ratings'));
                 } else {
                     try {
                         $review->setEntityId($review->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE))->setEntityPkValue($product->getId())->setStatusId(Mage_Review_Model_Review::STATUS_PENDING)->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())->setStoreId(Mage::app()->getStore()->getId())->setStores(array(Mage::app()->getStore()->getId()))->save();
                         foreach ($rating as $ratingId => $optionId) {
                             Mage::getModel('rating/rating')->setRatingId($ratingId)->setReviewId($review->getId())->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())->addOptionVote($optionId, $product->getId());
                         }
                         $review->aggregate();
                         $session->addSuccess($this->__('Your review has been accepted for moderation.'));
                     } catch (Exception $e) {
                         $session->setFormData($data);
                         $session->addError($this->__('Unable to add the review.'));
                     }
                 }
             }
         } else {
             $session->setFormData($data);
             if (is_array($validate)) {
                 foreach ($validate as $errorMessage) {
                     $session->addError($errorMessage);
                 }
                 $session->addError($this->__('Sorry, unable to post the review.'));
             } else {
                 $session->addError($this->__('Unable to post the review.'));
             }
         }
     } else {
         $session->setFormData($data);
         $session->addError($this->__('Couldn\'t post the review, sorry.'));
     }
     //Mage::helper("nomorespam")->sendEmailNotify($review->getId());
     if ($redirectUrl = Mage::getSingleton('review/session')->getRedirectUrl(true)) {
         $this->_redirectUrl($redirectUrl);
         return;
     }
     $this->_redirectReferer();
 }
 /**
  * Return PDF with invoice & shipment (if exists) for 1 order
  *
  * @param unknown_type $orderId
  */
 public function getPdfDocumentsForOrder($orderId)
 {
     //retrieve information
     $orderPreparationItem = mage::getModel('Orderpreparation/ordertoprepare')->load($orderId, 'order_id');
     if (!$orderPreparationItem->getId()) {
         die('This order do not belong to selected orders');
     }
     //init PDF
     $pdf = new Zend_Pdf();
     $order = mage::getModel('sales/order')->load($orderId);
     //add shipment to PDF
     if (Mage::getStoreConfig('orderpreparation/printing_options/print_shipments') == 1) {
         //recupere le shipment (si existe)
         $ShipmentId = $orderPreparationItem->getshipment_id();
         if ($ShipmentId > 0) {
             //recupere le shipment
             $shipment = Mage::getModel('sales/order_shipment')->loadByIncrementId($ShipmentId);
             if ($shipment->getId()) {
                 //Genere le pdf de la facture
                 $ShipmentPdfModel = Mage::getModel('sales/order_pdf_shipment');
                 if ($pdf != null) {
                     $ShipmentPdfModel->pdf = $pdf;
                     $ShipmentPdfModel = $ShipmentPdfModel->getPdf(array($shipment));
                     //Ajoute le pdf du shipment au pdf principal
                     for ($i = 0; $i < count($ShipmentPdfModel->pages); $i++) {
                         $pdf->pages[] = $ShipmentPdfModel->pages[$i];
                     }
                 } else {
                     $pdf = $ShipmentPdfModel->getPdf(array($shipment));
                 }
             }
         }
     }
     //add invoice to PDF
     if (Mage::getStoreConfig('orderpreparation/printing_options/print_invoices') == 1) {
         $InvoiceId = $orderPreparationItem->getinvoice_id();
         if ($InvoiceId > 0) {
             //Recupere l'invoice
             $invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($InvoiceId);
             if ($invoice->getId()) {
                 //define printing count
                 $printingCount = 1;
                 if (mage::getStoreConfig('orderpreparation/printing_options/print_invoice_twice_if_taxless') == 1) {
                     if ($invoice->getbase_tax_amount() == 0) {
                         $printingCount += 3;
                     }
                 }
                 $CurrentPaymentMethod = $invoice->getOrder()->getPayment()->getMethodInstance()->getcode();
                 $PaymentMethodsTwice = mage::getStoreConfig('orderpreparation/printing_options/print_invoice_twice_if_payment_method');
                 $pos = strpos($PaymentMethodsTwice, $CurrentPaymentMethod);
                 if (!($pos === false)) {
                     $printingCount++;
                 }
                 //Add to pdf
                 for ($printingNumber = 0; $printingNumber < $printingCount; $printingNumber++) {
                     //Genere le pdf de la facture
                     $InvoicePdfModel = Mage::getModel('sales/order_pdf_invoice');
                     if ($pdf != null) {
                         $InvoicePdfModel->pdf = $pdf;
                         $InvoicePdfModel = $InvoicePdfModel->getPdf(array($invoice));
                         //Ajoute le pdf de la facture au pdf principal
                         $max = count($InvoicePdfModel->pages);
                         for ($i = 0; $i < $max; $i++) {
                             $pdf->pages[] = $InvoicePdfModel->pages[$i];
                         }
                     } else {
                         $pdf = $InvoicePdfModel->getPdf(array($invoice));
                     }
                 }
             }
         }
     }
     return $pdf;
 }
Example #24
0
 /**
  * Calculate labels width & height
  *
  */
 protected function calculateWidthAndMargin($products)
 {
     $this->_topMargin = $this->cmToPixels(mage::getStoreConfig('barcodelabel/pdf/top_margin'));
     $this->_leftMargin = $this->cmToPixels(mage::getStoreConfig('barcodelabel/pdf/left_margin'));
     $this->_rightMargin = $this->cmToPixels(mage::getStoreConfig('barcodelabel/pdf/right_margin'));
     $this->_bottomMargin = $this->cmToPixels(mage::getStoreConfig('barcodelabel/pdf/bottom_margin'));
     $this->_verticalSpacing = $this->cmToPixels(mage::getStoreConfig('barcodelabel/pdf/vertical_inter_margin'));
     $this->_horizontalSpacing = $this->cmToPixels(mage::getStoreConfig('barcodelabel/pdf/horizontal_inter_margin'));
     $this->_labelsPerRow = mage::getStoreConfig('barcodelabel/pdf/labels_per_row');
     $this->_rowCount = mage::getStoreConfig('barcodelabel/pdf/row_count');
     //Calculate labels count
     $labelCount = 0;
     foreach ($products as $id => $qty) {
         $labelCount += $qty;
     }
     $this->_totalLabelNumber = $labelCount;
     //if height is not set, calculate final height for all labels
     if ($this->_PAGE_HEIGHT == 0) {
         $this->_rowCount = ceil($labelCount / $this->_labelsPerRow);
         $this->_PAGE_HEIGHT = $this->_rowCount * ($this->_defaultLabelHeight + $this->_topMargin + $this->_bottomMargin + $this->_verticalSpacing);
     }
     $usableWidth = $this->_PAGE_WIDTH - $this->_leftMargin - $this->_rightMargin;
     $usableHeight = $this->_PAGE_HEIGHT - $this->_topMargin - $this->_bottomMargin;
     $this->_labelWidth = ($usableWidth - ($this->_labelsPerRow - 1) * $this->_horizontalSpacing) / $this->_labelsPerRow;
     $this->_labelHeight = $usableHeight / $this->_rowCount - $this->_verticalSpacing;
 }
 /**
  * Cree les envois pour les commandes sélectionnées
  * Et Cree un document avec tout (bon de préparation de commande, bon de livraison, factures? )
  *
  */
 public function DownloadDocumentsAction()
 {
     try {
         $pdf = new Zend_Pdf();
         //list orders
         $collection = mage::getModel('Orderpreparation/ordertoprepare')->getCollection()->setOrder('order_id', 'asc');
         //Add comments
         if (Mage::getStoreConfig('orderpreparation/printing_options/print_comments') == 1) {
             $CommentsModel = Mage::getModel('Orderpreparation/Pdf_SelectedOrdersComments');
             $pdf = $CommentsModel->getPdf($collection);
             for ($i = 0; $i < count($CommentsModel->pages); $i++) {
                 $pdf->pages[] = $CommentsModel->pages[$i];
             }
         }
         //rajoute les autres éléments
         foreach ($collection as $item) {
             if (Mage::getStoreConfig('orderpreparation/printing_options/print_shipments') == 1) {
                 //recupere le shipment (si existe)
                 $ShipmentId = $item->getshipment_id();
                 if ($ShipmentId > 0) {
                     //recupere le shipment
                     $shipment = Mage::getModel('sales/order_shipment')->loadByIncrementId($ShipmentId);
                     if ($shipment->getId()) {
                         //Genere le pdf de la facture
                         $ShipmentPdfModel = Mage::getModel('sales/order_pdf_shipment');
                         $ShipmentPdfModel->pdf = $pdf;
                         $ShipmentPdfModel = $ShipmentPdfModel->getPdf(array($shipment));
                         //Ajoute le pdf du shipment au pdf principal
                         for ($i = 0; $i < count($ShipmentPdfModel->pages); $i++) {
                             $pdf->pages[] = $ShipmentPdfModel->pages[$i];
                         }
                     }
                 }
             }
             //ajoute la facture au PDF
             if (Mage::getStoreConfig('orderpreparation/printing_options/print_invoices') == 1) {
                 $InvoiceId = $item->getinvoice_id();
                 if ($InvoiceId > 0) {
                     //Recupere l'invoice
                     $invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($InvoiceId);
                     if ($invoice->getId()) {
                         //define printing count
                         $printingCount = 1;
                         if (mage::getStoreConfig('orderpreparation/printing_options/print_invoice_twice_if_taxless') == 1) {
                             if ($invoice->getbase_tax_amount() == 0) {
                                 $printingCount++;
                             }
                         }
                         $CurrentPaymentMethod = $invoice->getOrder()->getPayment()->getMethodInstance()->getcode();
                         $PaymentMethodsTwice = mage::getStoreConfig('orderpreparation/printing_options/print_invoice_twice_if_payment_method');
                         $pos = strpos($PaymentMethodsTwice, $CurrentPaymentMethod);
                         if (!($pos === false)) {
                             $printingCount++;
                         }
                         //Add to pdf
                         for ($printingNumber = 0; $printingNumber < $printingCount; $printingNumber++) {
                             //Genere le pdf de la facture
                             $InvoicePdfModel = Mage::getModel('sales/order_pdf_invoice');
                             $InvoicePdfModel->pdf = $pdf;
                             $InvoicePdfModel = $InvoicePdfModel->getPdf(array($invoice));
                             //Ajoute le pdf de la facture au pdf principal
                             for ($i = 0; $i < count($InvoicePdfModel->pages); $i++) {
                                 //$pdf->pages[] = $InvoicePdfModel->pages[$i];
                             }
                         }
                     }
                 }
             }
         }
         $this->_prepareDownloadResponse('documents.pdf', $pdf->render(), 'application/pdf');
     } catch (Exception $ex) {
         die("Erreur lors de la génération du PDF de facture: " . $ex->getMessage() . '<p>' . $ex->getTraceAsString());
     }
 }