protected function _prepareForm()
 {
     $form = new Varien_Data_Form();
     $dataObj = new Varien_Object(array('store_id' => '', 'store_name_in_store' => '', 'status_in_store' => '', 'description_in_store' => '', 'address_in_store' => '', 'city_in_store' => ''));
     if (Mage::getSingleton('adminhtml/session')->getStoreData()) {
         $data = Mage::getSingleton('adminhtml/session')->getStoreData();
         Mage::getSingleton('adminhtml/session')->setStoreData(null);
     } elseif (Mage::registry('store_data')) {
         $data = Mage::registry('store_data')->getData();
     }
     if (isset($data)) {
         $dataObj->addData($data);
     }
     if ($dataObj->getStoreId()) {
         $warehouse = Mage::getResourceModel('inventoryplus/warehouse_collection')->addFieldToFilter('storepickup_id', $dataObj->getStoreId())->getFirstItem();
         $dataObj->setData('warehouse_id', $warehouse->getId());
         $dataObj->setData('curr_warehouse_id', $warehouse->getId());
     }
     $this->setForm($form);
     $fieldset = $form->addFieldset('store_form', array('legend' => Mage::helper('storepickup')->__('Warehouse Information')));
     $fieldset->addField('warehouse_id', 'select', array('label' => Mage::helper('storepickup')->__('Linked Warehouse'), 'name' => 'warehouse_id', 'values' => $this->getWarehouseOptions(), 'onchange' => 'imStorePickup.changeWarehouse(this);', 'note' => $this->__('If you choose a warehouse, this Store information will be imported from the warehouse after saved.')));
     $fieldset->addField('curr_warehouse_id', 'hidden', array('name' => 'curr_warehouse_id'));
     if (Mage::getSingleton('adminhtml/session')->getStoreData()) {
         $form->setValues(Mage::getSingleton('adminhtml/session')->getStoreData());
         Mage::getSingleton('adminhtml/session')->setStoreData(null);
     } elseif (Mage::registry('store_data')) {
         $form->setValues($dataObj->getData());
     }
     parent::_prepareForm();
 }
 /**
  * Assign extra parameters to row
  *
  * @param Varien_Object $row
  */
 protected function _prepareArrayRow(Varien_Object $row)
 {
     $row->setData('option_extra_attr_' . $this->_getTemplateRenderer()->calcOptionHash($row->getData('template')), 'selected="selected"');
     $row->setData('option_extra_attr_' . $this->_getSendtypeRenderer()->calcOptionHash($row->getData('sendtype')), 'selected="selected"');
     $row->setData('option_extra_attr_' . $this->_getDatafieldRenderer()->calcOptionHash($row->getData('datafield')), 'selected="selected"');
     $row->setData('option_extra_attr_' . $this->_getFromadddressRenderer()->calcOptionHash($row->getData('fromaddress')), 'selected="selected"');
 }
Example #3
0
 protected function _prepareForm()
 {
     $form = new Varien_Data_Form();
     $blockData = Mage::registry(AW_Autorelated_Adminhtml_ShoppingcartblockController::BLOCK_REGISTRY_KEY);
     if (!$blockData instanceof Varien_Object) {
         $blockData = new Varien_Object();
     }
     $fieldset = $form->addFieldset('general', array('legend' => $this->__('General')));
     $fieldset->addField('name', 'text', array('name' => 'name', 'label' => $this->__('Name'), 'required' => true));
     if ($blockData->getData('status') === null) {
         $blockData->setData('status', 1);
     }
     $fieldset->addField('status', 'select', array('name' => 'status', 'label' => $this->__('Status'), 'required' => true, 'values' => Mage::getModel('awautorelated/source_status')->toOptionArray()));
     if (!Mage::app()->isSingleStoreMode()) {
         $fieldset->addField('store', 'multiselect', array('name' => 'store[]', 'label' => $this->__('Store View'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true)));
     } else {
         $blockData->setStore(Mage::app()->getStore(true)->getId());
         $fieldset->addField('store', 'hidden', array('name' => 'store[]'));
     }
     if ($blockData->getData('customer_groups') === null) {
         $blockData->setData('customer_groups', array(Mage_Customer_Model_Group::CUST_GROUP_ALL));
     }
     $fieldset->addField('customer_groups', 'multiselect', array('name' => 'customer_groups[]', 'label' => $this->__('Customer groups'), 'title' => $this->__('Customer groups'), 'required' => true, 'values' => Mage::getModel('awautorelated/source_customer_groups')->toOptionArray()));
     $fieldset->addField('priority', 'text', array('name' => 'priority', 'label' => $this->__('Priority'), 'title' => $this->__('Priority'), 'required' => false));
     $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
     $fieldset->addField('date_from', 'date', array('name' => 'date_from', 'label' => $this->__('Date From'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'input_format' => Varien_Date::DATE_INTERNAL_FORMAT, 'format' => $dateFormatIso));
     $fieldset->addField('date_to', 'date', array('name' => 'date_to', 'label' => $this->__('Date To'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'input_format' => Varien_Date::DATE_INTERNAL_FORMAT, 'format' => $dateFormatIso));
     $positionSourceModel = Mage::getModel('awautorelated/source_position');
     $fieldset->addField('position', 'select', array('name' => 'position', 'label' => $this->__('Position'), 'title' => $this->__('Position'), 'required' => true, 'values' => $positionSourceModel->toOptionArray(AW_Autorelated_Model_Source_Type::SHOPPING_CART_BLOCK)));
     $form->setValues($blockData->toArray());
     $this->setForm($form);
 }
Example #4
0
 /**
  * After attribute is saved upload file to media
  * folder and save it to its associated product.
  *
  * @param  Mage_Catalog_Model_Product $object
  * @return Jvs_FileAttribute_Model_Attribute_Backend_File
  */
 public function afterSave($object)
 {
     $value = $object->getData($this->getAttribute()->getName());
     if (is_array($value) && !empty($value['delete'])) {
         $object->setData($this->getAttribute()->getName(), '');
         $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
         return;
     }
     try {
         $uploadedFile = new Varien_Object();
         $uploadedFile->setData('name', $this->getAttribute()->getName());
         $uploadedFile->setData('allowed_extensions', array('jpg', 'jpeg', 'gif', 'png', 'tif', 'tiff', 'mpg', 'mpeg', 'mp3', 'wav', 'pdf', 'txt'));
         Mage::dispatchEvent('jvs_fileattribute_allowed_extensions', array('file' => $uploadedFile));
         $uploader = new Mage_Core_Model_File_Uploader($this->getAttribute()->getName());
         $uploader->setAllowedExtensions($uploadedFile->getData('allowed_extensions'));
         $uploader->setAllowRenameFiles(true);
         $uploader->setFilesDispersion(true);
         $uploader->save(Mage::getBaseDir('media') . '/catalog/product');
     } catch (Exception $e) {
         return $this;
     }
     $fileName = $uploader->getUploadedFileName();
     if ($fileName) {
         $object->setData($this->getAttribute()->getName(), $fileName);
         $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
     }
     return $this;
 }
Example #5
0
 /**
  * Formating date value before save
  *
  * Should set (bool, string) correct type for empty value from html form,
  * neccessary for farther proccess, else date string
  *
  * @param Varien_Object $object
  * @throws Mage_Eav_Exception
  * @return Mage_Eav_Model_Entity_Attribute_Backend_Datetime
  */
 public function beforeSave($object)
 {
     $attributeName = $this->getAttribute()->getName();
     $_formated = $object->getData($attributeName . '_is_formated');
     if (!$_formated && $object->hasData($attributeName)) {
         try {
             if (Mage::app()->getLocale()->getLocale() == 'fa_IR') {
                 require_once Mage::getBaseDir('lib') . '/pdate/pdate.php';
                 if ($object->getData($attributeName) != NULL) {
                     list($j_y, $j_m, $j_d) = explode('/', $object->getData($attributeName));
                     $gregorianlArray = jalali_to_gregorian($j_y, $j_m, $j_d);
                     $date = implode('-', $gregorianlArray);
                     $object->setData($attributeName, $date);
                 }
             }
             $value = $this->formatDate($object->getData($attributeName));
         } catch (Exception $e) {
             throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Invalid date'));
         }
         if (is_null($value)) {
             $value = $object->getData($attributeName);
         }
         //Mage::log( "$attributeName, $value ") ;
         $object->setData($attributeName, $value);
         $object->setData($attributeName . '_is_formated', true);
     }
     return $this;
 }
 public function editAction()
 {
     $id = $this->getRequest()->getParam('id');
     $shippingrate = new Varien_Object();
     //Mage::getModel('shipping/carrier_tablerate');
     if ($id) {
         // Load record
         $resource = Mage::getResourceModel('shipping/carrier_tablerate');
         $adapter = Mage::getSingleton('core/resource')->getConnection('core_read');
         $binds = array('id' => $id);
         $query = "select * FROM {$resource->getMainTable()} WHERE `pk` = :id";
         $data = $adapter->fetchRow($query, $binds);
         // Check if record is loaded
         if (!$data) {
             Mage::getSingleton('adminhtml/session')->addError($this->__('This Shipping Rate no longer exists.'));
             $this->_redirect('*/*/');
             return;
         } else {
             $shippingrate->setData($data);
         }
     } else {
         // for new rates set the default country to the country of the store
         $shippingrate->setData('dest_country_id', Mage::getStoreConfig('general/country/default'));
         $shippingrate->setData('website_id', Mage::app()->getRequest()->getParam('website'));
     }
     Mage::register('shippingrate', $shippingrate);
     $this->_initAction();
     $this->renderLayout();
 }
 protected function _prepareArrayRow(Varien_Object $row)
 {
     $row->setData('option_extra_attr_' . $this->getRenderer('attribute')->calcOptionHash($row->getAttribute()), 'selected="selected"');
     $row->setData('option_extra_attr_' . $this->getRenderer('searchable')->calcOptionHash($row->getSearchable()), 'selected="selected"');
     $row->setData('option_extra_attr_' . $this->getRenderer('searchable')->calcOptionHash($row->getRetrievable()), 'selected="selected"');
     $row->setData('option_extra_attr_' . $this->getRenderer('order')->calcOptionHash($row->getOrder()), 'selected="selected"');
 }
Example #8
0
 public function getJsonConfig(){
     $_secure = false;
     $sheme = Mage::app()->getRequest()->getScheme();
     if ($sheme=='https'){
         $_secure = true;
     }
     
     $merchantId = Mage::getStoreConfig('payment/incontext/merchantid');
     $isActive = Mage::getStoreConfig('payment/incontext/enable');
     
     $environment = 'production';
     if (Mage::getStoreConfig('payment/incontext/sandbox')){
         $environment = 'sandbox';
     }
     
     if (empty($merchantId)){
         $isActive = false;
     }
     
     $config = new Varien_Object();
     $config->setData('isActive', $isActive);
     $config->setData('environment', $environment);
     $config->setData('merchantid',  $merchantId);   
     $config->setData('setExpressCheckout', $this->getUrl('incontext/express/start', array('_secure' => $_secure)));
     $config->setData('setExpressCheckoutUk', $this->getUrl('incontext/expressuk/start', array('_secure' => $_secure)));
     
     return Mage::helper('core')->jsonEncode($config);
 }
 /**
  * Authorize payment method
  *
  * @param Varien_Object $payment
  * @param float $amount
  *
  * @throws Exception Payment could not be executed
  *
  * @return Iways_PayPalPlus_Model_Payment
  */
 public function authorize(Varien_Object $payment, $amount)
 {
     $paymentId = Mage::app()->getRequest()->getParam('paymentId');
     $payerId = Mage::app()->getRequest()->getParam('PayerID');
     try {
         if (Mage::getStoreConfig('payment/iways_paypalplus_payment/transfer_reserved_order_id')) {
             Mage::getModel('iways_paypalplus/api')->patchInvoiceNumber($paymentId, $payment->getOrder()->getIncrementId());
         }
     } catch (\Exception $e) {
         Mage::logException($e);
     }
     /**
      * @var \PayPal\Api\Payment $ppPayment
      */
     $ppPayment = Mage::getModel('iways_paypalplus/api')->executePayment($paymentId, $payerId);
     Mage::getSingleton('customer/session')->setPayPalPaymentId(null);
     Mage::getSingleton('customer/session')->setPayPalPaymentPatched(null);
     if (!$ppPayment) {
         Mage::throwException('Payment could not be executed.');
     }
     if ($paymentInstructions = $ppPayment->getPaymentInstruction()) {
         $payment->setData('ppp_pui_reference_number', $paymentInstructions->getReferenceNumber());
         $payment->setData('ppp_pui_instruction_type', $paymentInstructions->getInstructionType());
         $payment->setData('ppp_pui_payment_due_date', Mage::helper('iways_paypalplus')->convertDueDate($paymentInstructions->getPaymentDueDate()));
         $payment->setData('ppp_pui_note', $paymentInstructions->getNote());
         $bankInsctructions = $paymentInstructions->getRecipientBankingInstruction();
         $payment->setData('ppp_pui_bank_name', $bankInsctructions->getBankName());
         $payment->setData('ppp_pui_account_holder_name', $bankInsctructions->getAccountHolderName());
         $payment->setData('ppp_pui_international_bank_account_number', $bankInsctructions->getInternationalBankAccountNumber());
         $payment->setData('ppp_pui_bank_identifier_code', $bankInsctructions->getBankIdentifierCode());
         $payment->setData('ppp_pui_routing_number', $bankInsctructions->getRoutingNumber());
         $ppAmount = $paymentInstructions->getAmount();
         $payment->setData('ppp_pui_amount', $ppAmount->getValue());
         $payment->setData('ppp_pui_currency', $ppAmount->getCurrency());
     }
     $transactionId = null;
     try {
         $transactions = $ppPayment->getTransactions();
         if ($transactions && isset($transactions[0])) {
             $resource = $transactions[0]->getRelatedResources();
             if ($resource && isset($resource[0])) {
                 $sale = $resource[0]->getSale();
                 $transactionId = $sale->getId();
                 if ($sale->getState() == self::PENDING) {
                     $payment->setIsTransactionPending(true);
                 }
             }
         }
     } catch (Exception $e) {
         $transactionId = $ppPayment->getId();
     }
     $payment->setTransactionId($transactionId);
     $payment->setParentTransactionId($ppPayment->getId());
     if ($ppPayment->getState() == self::PPP_STATUS_APPROVED) {
         $payment->setStatus(self::STATUS_APPROVED);
     }
     return $this;
 }
 protected function _prepareArrayRow(Varien_Object $row)
 {
     $date_from = $row->getData('date_from') ? Mage::helper('core')->formatDate($row->getData('date_from'), Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, false) : "";
     $date_end = $row->getData('date_end') ? Mage::helper('core')->formatDate($row->getData('date_end'), Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, false) : "";
     $row->setData('date_from', $date_from);
     $row->setData('date_end', $date_end);
     $row->setData('option_extra_attr_' . $this->_getCalculationTypeReferrerRenderer()->calcOptionHash($row->getData('calculation_type_referrer')), 'selected="selected"');
     $row->setData('option_extra_attr_' . $this->_getCalculationTypeReferredRenderer()->calcOptionHash($row->getData('calculation_type_referred')), 'selected="selected"');
 }
Example #11
0
 private function _processPeriod($collection, $period)
 {
     switch ($period) {
         case 'day':
             return $collection;
             break;
         case 'month':
             $index = 1;
             break;
         case 'year':
             $index = 0;
             break;
     }
     $fields = array('abandoned_carts_num', 'abandoned_carts_price', 'abandoned_items_num', 'recovered_carts_num', 'ordered_carts_num', 'ordered_carts_price', 'ordered_items_num', 'av_back_time', 'target_letter_step');
     $date = $collection->getFirstItem()->getDate();
     $dateArray = explode('-', $date);
     $val = $dateArray[$index];
     $returnCollection = new Varien_Data_Collection();
     $object = new Varien_Object();
     //$counterABT=0;
     $counterTLS = 0;
     foreach ($collection as $item) {
         $dateArray = explode('-', $item->getDate());
         if ($dateArray[$index] != $val) {
             $val = $dateArray[$index];
             /*if($counterABT)
               {
                   $object->setData('av_back_time',$object->getData('av_back_time')/$counterABT);
               }*/
             if ($counterTLS) {
                 $object->setData('target_letter_step', $object->getData('target_letter_step') / $counterTLS);
             }
             $returnCollection->addItem($object);
             $object = new Varien_Object();
             $counterABT = 0;
             $counterTLS = 0;
         }
         $object->setDate($item->getDate());
         //if($item->getData('av_back_time'))$counterABT++;
         if ($item->getData('target_letter_step')) {
             $counterTLS++;
         }
         foreach ($fields as $field) {
             $object->setData($field, $object->getData($field) + $item->getData($field));
         }
     }
     /*if($counterABT)
       {
           $object->setData('av_back_time',$object->getData('av_back_time')/$counterABT);
       }*/
     if ($counterTLS) {
         $object->setData('target_letter_step', $object->getData('target_letter_step') / $counterTLS);
     }
     $returnCollection->addItem($object);
     return $returnCollection;
 }
Example #12
0
 public function sendReportEmail()
 {
     $websites = Mage::app()->getWebsites(true);
     $helper = Mage::helper('affiliateplus/config');
     foreach ($websites as $website) {
         if (!$website->getConfig('affiliateplus/email/is_sent_report')) {
             continue;
         }
         $periodData = array('week' => array('date' => 'w', 'label' => $helper->__('last week')), 'month' => array('date' => 'j', 'label' => $helper->__('last month')), 'year' => array('date' => 'z', 'label' => $helper->__('last year')));
         $period = $website->getConfig('affiliateplus/email/report_period');
         if (date($periodData[$period]['date']) != 1) {
             continue;
         }
         $store = $website->getDefaultStore();
         if (!$store) {
             continue;
         }
         $storeId = $store->getId();
         $accounts = Mage::getResourceModel('affiliateplus/account_collection')->addFieldToFilter('main_table.status', 1)->addFieldToFilter('main_table.notification', 1);
         $accounts->getSelect()->joinLeft(array('e' => $accounts->getTable('customer/entity')), 'main_table.customer_id	= e.entity_id', array('website_id'))->where('e.website_id = ?', $website->getId())->where('e.is_active = 1');
         //edit by Sally
         $date = new Zend_Date();
         $to = $date->toString();
         //$to = Mage::helper('core')->formatDate($date,'medium', true);
         $to = Mage::getModel('core/locale')->storeDate(Mage::app()->getStore(), $to, true)->toString('dd-MM-YYYY HH:mm:ss');
         $function = 'sub' . ucfirst($period);
         $fromDate = $date->{$function}(1)->toString('YYYY-MM-dd');
         $from = $date->toString();
         // $from = Mage::helper('core')->formatDate($date,'medium', true);
         $from = Mage::getModel('core/locale')->storeDate(Mage::app()->getStore(), $from, true)->toString('dd-MM-YYYY HH:mm:ss');
         //end by Sally
         $translate = Mage::getSingleton('core/translate');
         $translate->setTranslateInline(false);
         $template = $website->getConfig('affiliateplus/email/report_template');
         $sender = Mage::getStoreConfig('trans_email/ident_sales', $store);
         foreach ($accounts as $account) {
             $statistic = new Varien_Object();
             $transactions = Mage::getResourceModel('affiliateplus/transaction_collection')->addFieldToFilter('account_id', $account->getId());
             $transactions->getSelect()->reset(Zend_Db_Select::COLUMNS)->where('date(created_time) >= ?', $fromDate)->columns(array('status', 'sales' => 'SUM(`total_amount`)', 'transactions' => 'COUNT(`transaction_id`)', 'commissions' => 'SUM(`commission`+`commission`*`percent_plus`+`commission_plus`)'))->group('status');
             foreach ($transactions as $transaction) {
                 if ($transaction->getStatus() == 1) {
                     $statistic->setData('complete', $transaction->getData());
                 } elseif ($transaction->getStatus() == 2) {
                     $statistic->setData('pending', $transaction->getData());
                 } elseif ($transaction->getStatus() == 3) {
                     $statistic->setData('cancel', $transaction->getData());
                 }
             }
             $actions = Mage::getResourceModel('affiliateplus/action_collection');
             $actions->getSelect()->reset(Zend_Db_Select::COLUMNS)->where('account_id = ?', $account->getId())->where('type = ?', 2)->where('created_date >= ?', $fromDate)->columns(array('clicks' => 'SUM(totals)', 'unique' => 'SUM(is_unique)'))->group('account_id');
             $statistic->setData('click', $actions->getFirstItem()->getData());
             $mailTemplate = Mage::getModel('core/email_template')->setDesignConfig(array('area' => 'frontend', 'store' => $storeId))->sendTransactional($template, $sender, $account->getEmail(), $account->getName(), array('store' => $store, 'account' => $account, 'statistic' => $statistic, 'period' => $helper->__($period), 'label' => $periodData[$period]['label'], 'from' => $from, 'to' => $to));
         }
         $translate->setTranslateInline(true);
     }
 }
Example #13
0
 public function getConfig($data = array())
 {
     $config = new Varien_Object();
     $config->setData(array('enabled' => $this->isEnabled(), 'hidden' => $this->isHidden(), 'use_container' => false, 'add_variables' => false, 'add_widgets' => false, 'no_display' => false, 'translator' => Mage::helper('cms'), 'files_browser_window_url' => Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/cms_wysiwyg_images/index'), 'files_browser_window_width' => (int) Mage::getConfig()->getNode('adminhtml/cms/browser/window_width'), 'files_browser_window_height' => (int) Mage::getConfig()->getNode('adminhtml/cms/browser/window_height'), 'encode_directives' => true, 'directives_url' => Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/cms_wysiwyg/directive'), 'popup_css' => Mage::getBaseUrl('js') . 'mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css', 'content_css' => Mage::getBaseUrl('js') . 'mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css', 'width' => '100%', 'plugins' => array()));
     $config->setData('directives_url_quoted', preg_quote($config->getData('directives_url')));
     if (is_array($data)) {
         $config->addData($data);
     }
     return $config;
 }
 /**
  * Also serialize additional information
  *
  * @param Varien_Object $payment
  */
 protected function _beforeSave(Varien_Object $payment)
 {
     $additionalInformation = $payment->getData('additional_information');
     if (empty($additionalInformation)) {
         $payment->setData('additional_information', null);
     } elseif (is_array($additionalInformation)) {
         $payment->setData('additional_information', serialize($additionalInformation));
     }
     parent::_beforeSave($payment);
 }
Example #15
0
	/**
	 * Sets the parameter array
	 *
	 * @param array $params
	 */
	public function setParams($params)
	{
		if ($params instanceof Varien_Object) {
			$this->_params = $params;
		}
		else {
			$this->_params->setData($params);
		}
		
		return $this;
	}
 public function submitTicketAction()
 {
     $data = $this->getRequest()->getPost();
     if ($data) {
         $translate = Mage::getSingleton('core/translate');
         /* @var $translate Mage_Core_Model_Translate */
         $translate->setTranslateInline(false);
         try {
             $postObject = new Varien_Object();
             $postObject->setData($data);
             $postObject->setData('ip', $_SERVER['REMOTE_ADDR']);
             $error = false;
             if (!Zend_Validate::is(trim($postObject['name']), 'NotEmpty')) {
                 $error = true;
             }
             if (!Zend_Validate::is(trim($postObject['subject']), 'NotEmpty')) {
                 $error = true;
             }
             if (!Zend_Validate::is(trim($postObject['comment']), 'NotEmpty')) {
                 $error = true;
             }
             if (!Zend_Validate::is(trim($postObject['email']), 'EmailAddress')) {
                 $error = true;
             }
             if ($error) {
                 throw new Exception();
             }
             if (Mage::helper('kayako')->isCaptchaEnabled()) {
                 $secretKey = Mage::helper('kayako')->getCaptchaSecretKey();
                 $responseString = $postObject['g-recaptcha-response'];
                 $userIp = $postObject['ip'];
                 $responseUrl = 'https://www.google.com/recaptcha/api/siteverify?secret=' . $secretKey . '&response=' . $responseString . '&remoteip=' . $userIp;
                 $response = file_get_contents($responseUrl);
                 $jsonResponse = json_decode($response, true);
                 if ($jsonResponse['success'] != 1) {
                     throw new Exception();
                 }
             }
             $ticket = Mage::getModel('kayako/ticket');
             $createTicket = $ticket->createTicket($data);
             $translate->setTranslateInline(true);
             Mage::getSingleton('customer/session')->addSuccess(Mage::helper('kayako')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.'));
             $this->_redirect('contacts');
             return;
         } catch (Exception $e) {
             $translate->setTranslateInline(true);
             Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later.'));
             $this->_redirect('contacts');
             return;
         }
     } else {
         $this->_redirect('contacts');
     }
 }
 public function getPdf($html)
 {
     $mailPdf = new Varien_Object();
     $pdf = $this->loadPdf();
     $pdf->WriteHTML($this->getCss(), 1);
     $pdf->WriteHTML($html);
     $mailPdf->setData('htmltemplate', $html);
     $output = $pdf->Output($this->getFileName(), 'S');
     $mailPdf->setData('pdfbody', $output);
     $mailPdf->setData('filename', $this->getFileName());
     return $mailPdf;
 }
 protected function _prepareArrayRow(Varien_Object $row)
 {
     $date_from = $row->getData('date_from') ? Mage::helper('core')->formatDate($row->getData('date_from'), Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, false) : "";
     $date_end = $row->getData('date_end') ? Mage::helper('core')->formatDate($row->getData('date_end'), Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, false) : "";
     $row->setData('date_from', $date_from);
     $row->setData('date_end', $date_end);
     if (is_array($row->getData('group_id')) && sizeof($row->getData('group_id'))) {
         foreach ($row->getData('group_id') as $value) {
             $row->setData('option_extra_attr_' . $this->_getCustomerGroupRenderer('group_id')->calcOptionHash($value), 'selected="selected"');
         }
     }
 }
 /**
  * Prepare existing row data object
  *
  * @param Varien_Object
  */
 protected function _prepareArrayRow(Varien_Object $row)
 {
     $data = $row->getData();
     $country = isset($data['_id']) ? $data['_id'] : false;
     if ($country) {
         unset($data['_id']);
         $row->setData('option_extra_attr_' . $this->_getCountryRenderer()->calcOptionHash($country), 'selected="selected"');
         foreach ($data as $cardType) {
             $row->setData('option_extra_attr_' . $this->_getCcTypesRenderer()->calcOptionHash($cardType), 'selected="selected"');
         }
     }
 }
 /**
  * @return Varien_Object
  */
 protected function dispatchEvent()
 {
     $settings = new Varien_Object();
     $settings->setData('have_to_filter_methods', false);
     $allowedMethods = new Varien_Object();
     $settings->setData('allowed_methods', $allowedMethods);
     $paymentData = $this->getRequest()->getPost('payment', array());
     $selectedMethod = $paymentData['method'];
     $parameters = array('settings' => $settings, 'quote' => $this->getOnepage()->getQuote(), 'selected_method' => $selectedMethod, 'payment_data' => $paymentData, 'full_action_name' => $this->getFullActionName('/'));
     // Dispatch Event
     Mage::dispatchEvent($this->eventPrefix . '_verify_payment', $parameters);
     return $settings;
 }
Example #21
0
 /**
  * prepare collection for block to display
  *
  * @return Magestore_Bannerslider_Block_Adminhtml_Bannerslider_Grid
  */
 protected function _prepareCollection()
 {
     $collection = Mage::helper('bannerslider')->getStandardSlider();
     $collectionGrid = new Varien_Data_Collection();
     foreach ($collection as $value) {
         $rowObject = new Varien_Object();
         $rowObject->setData('id', $value['value']);
         $rowObject->setData('title', $value['label']);
         $collectionGrid->addItem($rowObject);
     }
     $this->setCollection($collectionGrid);
     return parent::_prepareCollection();
 }
 protected function _prepareRelatedTabData(Varien_Object $object)
 {
     $relatedProducts = $object->getData('related_products');
     $object->setData('related_products_count', $relatedProducts->getData('count'));
     $object->setData('show_out_of_stock', $relatedProducts->getData('show_out_of_stock'));
     $order = $relatedProducts->getData('order');
     if (!is_array($order)) {
         $order = array();
     }
     $object->setData('order', isset($order['type']) ? $order['type'] : null);
     $object->setData('order_attribute', isset($order['attribute']) ? $order['attribute'] : null);
     $object->setData('order_direction', isset($order['direction']) ? $order['direction'] : null);
     return $object;
 }
Example #23
0
 protected function _prepareCollection()
 {
     $collection = new Varien_Data_Collection();
     $monthsTrad = array('1' => 'Janvier', '2' => 'Février', '3' => 'Mars', '4' => 'Avril', '5' => 'Mai', '6' => 'Juin', '7' => 'Juillet', '8' => 'Août', '9' => 'Septembre', '10' => 'Octobre', '11' => 'Novembre', '12' => 'Décembre');
     $tab = array();
     $calendarCollection = Mage::getModel('compta_calendar/calendar')->getCollection();
     foreach ($calendarCollection as $calendar) {
         $dateValues = Mage::helper('core')->jsonDecode($calendar->getValues());
         foreach ($dateValues as $day => $nhour) {
             $customer = Mage::getModel('compta_customer/customer')->load($calendar->getCustomerId());
             $delayPaiement = $customer->getPaiementDelay();
             $yyyy_mm = substr($day, 0, 7);
             if (!isset($tab[$yyyy_mm][$calendar->getCustomerId()]['nbhour'])) {
                 $tab[$yyyy_mm][$calendar->getCustomerId()]['nbhour'] = 0;
             }
             $tab[$yyyy_mm][$calendar->getCustomerId()]['nbhour'] += $nhour;
             $tab[$yyyy_mm][$calendar->getCustomerId()]['delay'] = $delayPaiement;
         }
     }
     $prevision = array();
     foreach ($tab as $monthYYYYmm => $customerId) {
         foreach ($customerId as $cId => $data) {
             $addDay = $data['delay'] ? $data['delay'] : "0";
             $nextMonthDate = date('Y-m', strtotime("+1 months +{$addDay} days", strtotime($monthYYYYmm . '-01')));
             $customer = Mage::getModel('compta_customer/customer')->load($calendar->getCustomerId());
             if (!isset($prevision[$nextMonthDate])) {
                 $prevision[$nextMonthDate] = 0;
             }
             $prevision[$nextMonthDate] += $customer->getThm() * $data['nbhour'];
         }
     }
     $currentMonth = (int) date('m');
     for ($m = $currentMonth; $m <= $currentMonth + 5; $m++) {
         $findMe = date('Y') . '-' . sprintf("%'.02d", $m);
         $object = new Varien_Object();
         if (!isset($prevision[$findMe])) {
             $total = 0;
         } else {
             $total = $prevision[$findMe];
         }
         $object->setData('month', $monthsTrad[$m]);
         $object->setData('amount', $total);
         $object->setData('amount_net', Mage::helper('compta_invoice')->toNet($total));
         $collection->addItem($object);
         unset($object);
     }
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
Example #24
0
 public function getFormData()
 {
     if ($this->hasData('form_data')) {
         return $this->getData('form_data');
     }
     $formData = new Varien_Object();
     if ($data = Mage::getSingleton('core/session')->getRegisterLuckydraw()) {
         $formData->setData($data);
         Mage::getSingleton('core/session')->setRegisterLuckydraw(null);
     } elseif ($this->getIsCustomerLogin()) {
         $formData->setData($this->getCustomer()->getData());
     }
     $this->setData('form_data', $formData);
     return $this->getData('form_data');
 }
Example #25
0
 /**
  * Return Wysiwyg config as Varien_Object
  *
  * Config options description:
  *
  * enabled:                 Enabled Visual Editor or not
  * hidden:                  Show Visual Editor on page load or not
  * use_container:           Wrap Editor contents into div or not
  * no_display:              Hide Editor container or not (related to use_container)
  * translator:              Helper to translate phrases in lib
  * files_browser_*:         Files Browser (media, images) settings
  * encode_directives:       Encode template directives with JS or not
  *
  * @param $data Varien_Object constructor params to override default config values
  * @return Varien_Object
  */
 public function getConfig($data = array())
 {
     $config = new Varien_Object();
     $design = Mage::getDesign();
     $config->setData(array('enabled' => $this->isEnabled(), 'hidden' => $this->isHidden(), 'use_container' => false, 'add_variables' => true, 'add_widgets' => true, 'no_display' => false, 'translator' => Mage::helper('Mage_Cms_Helper_Data'), 'encode_directives' => true, 'directives_url' => Mage::getSingleton('Mage_Adminhtml_Model_Url')->getUrl('*/cms_wysiwyg/directive'), 'popup_css' => $design->getSkinUrl('mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css'), 'content_css' => $design->getSkinUrl('mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css'), 'width' => '100%', 'plugins' => array()));
     $config->setData('directives_url_quoted', preg_quote($config->getData('directives_url')));
     if (Mage::getSingleton('Mage_Admin_Model_Session')->isAllowed('cms/media_gallery')) {
         $config->addData(array('add_images' => true, 'files_browser_window_url' => Mage::getSingleton('Mage_Adminhtml_Model_Url')->getUrl('*/cms_wysiwyg_images/index'), 'files_browser_window_width' => (int) Mage::getConfig()->getNode('adminhtml/cms/browser/window_width'), 'files_browser_window_height' => (int) Mage::getConfig()->getNode('adminhtml/cms/browser/window_height')));
     }
     if (is_array($data)) {
         $config->addData($data);
     }
     Mage::dispatchEvent('cms_wysiwyg_config_prepare', array('config' => $config));
     return $config;
 }
 /**
  * Before Attribute Save Process
  *
  * @param Varien_Object $object
  * @return Mage_Catalog_Model_Category_Attribute_Backend_Sortby
  */
 public function beforeSave($object)
 {
     $attributeCode = $this->getAttribute()->getName();
     if ($attributeCode == 'available_sort_by') {
         $data = $object->getData($attributeCode);
         if (!is_array($data)) {
             $data = array();
         }
         $object->setData($attributeCode, join(',', $data));
     }
     if (is_null($object->getData($attributeCode))) {
         $object->setData($attributeCode, false);
     }
     return $this;
 }
 /**
  * Unserialize Varien_Object field in an object
  *
  * @param Mage_Core_Model_Abstract $object
  * @param string $field
  * @param mixed $defaultValue
  */
 protected function _unserializeField(Varien_Object $object, $field, $defaultValue = null)
 {
     $value = $object->getData($field);
     if (empty($value)) {
         $object->setData($field, $defaultValue);
     } elseif (!is_array($value) && !is_object($value)) {
         $unserializedValue = false;
         try {
             $unserializedValue = Mage::helper('core/unserializeArray')->unserialize($value);
         } catch (Exception $e) {
             Mage::logException($e);
         }
         $object->setData($field, $unserializedValue);
     }
 }
Example #28
0
 /**
  * Prepare data before save
  *
  * @param Varien_Object $object
  * @return Mage_Eav_Model_Entity_Attribute_Backend_Store
  */
 protected function _beforeSave($object)
 {
     if (!$object->getData($this->getAttribute()->getAttributeCode())) {
         $object->setData($this->getAttribute()->getAttributeCode(), Mage::app()->getStore()->getId());
     }
     return $this;
 }
Example #29
0
 /**
  * Factory method to get proper action instance
  *
  * @param array $config
  * @throws \Exception
  */
 public function assign(array $config)
 {
     $action = $parameters = NULL;
     if (!isset($config[self::F_PARAMETERS]) && sizeof($config) >= 2) {
         $parameters = array_pop($config);
         if (!is_array($parameters)) {
             $parameters = (array) $parameters;
         }
     } elseif (isset($config[self::F_PARAMETERS])) {
         $parameters = $config[self::F_PARAMETERS];
     }
     $action = (string) array_shift($config);
     if (NULL === $action || NULL === $parameters) {
         throw new \Exception(sprintf('Invalid action entry - %s', var_export($config, TRUE)));
     }
     $raw = $action;
     list($scope, $action) = explode('/', $raw, 2);
     // drop all hard spaces
     $action = str_replace('_', '', $action);
     // unlike Mage::helper() this one returns FALSE when model is not found
     // change whole config to use new action name and remove this ugly hack
     // we can't have default namespace, but in config we have such entry
     $scope = $scope == 'default' ? $scope . 'scope' : $scope;
     $className = '\\Nexway\\SetupManager\\Util\\Processor\\Action\\' . ucfirst($scope) . '\\' . ucfirst($action);
     $base = new $className();
     if (FALSE === $base) {
         throw new \Exception(sprintf('Invalid action - %s/%s', $scope, $action));
     }
     $parametersObject = new \Varien_Object();
     $parametersObject->setData($parameters);
     return $base->setAction($action)->setScope($scope)->setParameters($parametersObject);
 }
Example #30
0
 /**
  * Save uploaded file and set its name to category
  *
  * @param Varien_Object $object
  */
 public function afterSave($object)
 {
     $value = $object->getData($this->getAttribute()->getName());
     if (is_array($value) && !empty($value['delete'])) {
         $object->setData($this->getAttribute()->getName(), '');
         $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
         return;
     }
     $path = Mage::getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS;
     try {
         $uploader = new Mage_Core_Model_File_Uploader($this->getAttribute()->getName());
         $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
         $uploader->setAllowRenameFiles(true);
         $uploader->addValidateCallback(Mage_Core_Model_File_Validator_Image::NAME, new Mage_Core_Model_File_Validator_Image(), "validate");
         $result = $uploader->save($path);
         $object->setData($this->getAttribute()->getName(), $result['file']);
         $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
     } catch (Exception $e) {
         if ($e->getCode() != Mage_Core_Model_File_Uploader::TMP_NAME_EMPTY) {
             Mage::logException($e);
         }
         /** @TODO ??? */
         return;
     }
 }