Example #1
0
 public function prepareForFrontend($data)
 {
     if (empty($data)) {
         return $data;
     }
     list($code, $id) = explode('/', $data);
     if ($code == 'product') {
         // TODO: Wirklich so laden?
         $product = Mage::getModel('catalog/product');
         $product->load($id);
         return $product->getProductUrl();
     } else {
         if ($code == 'category') {
             // TODO: Wirklich so laden?
             /** @var $product Mage_Catalog_Model_Category */
             $category = Mage::getModel('catalog/category');
             $category->load($id);
             return $category->getUrl();
         } else {
             if (is_numeric($data)) {
                 return Mage::Helper('cms/page')->getPageUrl($data);
             }
         }
     }
     if (substr($data, 0, 4) == 'http' || substr($data, 0, 1) == '.' || substr($data, 0, 1) == '/') {
         // do not touch http or relative links
         return $data;
     }
     return Mage::getUrl($data);
 }
 public function render(Varien_Object $row)
 {
     $product_id = $row->getEntityId();
     if ($product_id) {
         $requestData = Mage::helper('adminhtml')->prepareFilterString($this->getRequest()->getParam('top_filter'));
         if (empty($requestData)) {
             $requestData = Mage::Helper('inventoryreports')->getDefaultOptionsWarehouse();
         }
         $warehouse = $requestData['warehouse_select'];
         $gettime = Mage::Helper('inventoryreports')->getTimeSelected($requestData);
         $datefrom = $gettime['date_from'];
         $dateto = $gettime['date_to'];
         $warehouse_product = Mage::getModel('inventoryplus/warehouse_product')->getCollection()->addFieldToFilter('warehouse_id', $warehouse);
         $supplyneeds = array();
         $total_supplyneeds = 0;
         $method = Mage::getStoreConfig('inventory/supplyneed/supplyneeds_method');
         if ($datefrom && $dateto && $method == 2 && strtotime($datefrom) <= strtotime($dateto)) {
             $max_needs = Mage::helper('inventorysupplyneeds')->calMaxAverage($product_id, $datefrom, $dateto, $warehouse);
         } elseif ($datefrom && $dateto && $method == 1 && strtotime($datefrom) <= strtotime($dateto)) {
             $max_needs = Mage::helper('inventorysupplyneeds')->calMaxExponential($product_id, $datefrom, $dateto, $warehouse);
         } else {
             $max_needs = 0;
         }
         if ($max_needs > 0) {
             $supplyneeds[$product_id] = $max_needs;
             $total_supplyneeds += $max_needs;
         }
     }
     if ($total_supplyneeds == 0) {
         return '0';
     } else {
         return $total_supplyneeds;
     }
 }
 protected function _prepareCollection()
 {
     $requestData = Mage::helper('adminhtml')->prepareFilterString($this->getRequest()->getParam('top_filter'));
     if (empty($requestData)) {
         $requestData = Mage::Helper('inventoryreports')->getDefaultOptionsWarehouse();
     }
     $gettime = Mage::Helper('inventoryreports')->getTimeSelected($requestData);
     $collection = Mage::getModel('inventoryphysicalstocktaking/physicalstocktaking_product')->getCollection();
     /* Get product name and sku from catalog, because physicalstocktaking_product does not have them */
     if ($storeId = $this->getRequest()->getParam('store', 0)) {
         $collection->addStoreFilter($storeId);
     }
     $productAttributes = array('product_name' => 'name');
     foreach ($productAttributes as $alias => $attributeCode) {
         $tableAlias = $attributeCode . '_table';
         $attribute = Mage::getSingleton('eav/config')->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attributeCode);
         $collection->getSelect()->joinLeft(array($tableAlias => $attribute->getBackendTable()), "main_table.product_id = {$tableAlias}.entity_id AND {$tableAlias}.attribute_id={$attribute->getId()}", array($alias => 'value'));
     }
     $collection->join('catalog/product', 'product_id=`catalog/product`.entity_id', array('product_sku' => 'sku'));
     /* Endl get product name and sku from catalog */
     /* Join physicalstocktaking to get created_at */
     $collection->getSelect()->joinLeft(array('physicalstocktaking' => $collection->getTable('inventoryphysicalstocktaking/physicalstocktaking')), "main_table.physicalstocktaking_id = physicalstocktaking.physicalstocktaking_id", array('created_at', 'warehouse_id'));
     /* Endl join physicalstocktaking to get created_at */
     $collection->getSelect()->columns(array('difference' => new Zend_Db_Expr("(adjust_qty - old_qty)")));
     $collection->getSelect()->where("physicalstocktaking.created_at BETWEEN '" . $gettime['date_from'] . "' AND '" . $gettime['date_to'] . "'");
     if (isset($requestData['warehouse_select']) && $requestData['warehouse_select']) {
         $warehouse_id = $requestData['warehouse_select'];
         $collection->getSelect()->where("physicalstocktaking.warehouse_id = '{$warehouse_id}'");
     }
     $this->setCollection($collection);
     $this->_prepareTotals('adjust_qty,old_qty,difference');
     return parent::_prepareCollection();
 }
 protected function _prepareForm()
 {
     $counrtries = Mage::Helper('stores')->getCountryCollection();
     $form = new Varien_Data_Form();
     $stores_id = $this->getRequest()->getParam('id');
     $fieldset = $form->addFieldset('general', array('legend' => Mage::helper('core')->__('General Settings')));
     $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('tab_id' => 'page_tabs'));
     $formData = Mage::getModel('stores/state')->getStoreData($stores_id);
     $fieldset->addField('title', 'text', array('label' => Mage::helper('core')->__('Store Name'), 'title' => Mage::helper('core')->__('Store Name'), 'name' => 'title', 'width' => '50px', 'required' => true));
     $fieldset->addField('zip_code', 'text', array('label' => Mage::helper('core')->__('Zip Code'), 'title' => Mage::helper('core')->__('Zip Code'), 'name' => 'zip_code', 'style' => 'width:50px;', 'required' => false));
     $fieldset->addField('country', 'select', array('label' => Mage::helper('core')->__('Country'), 'title' => Mage::helper('core')->__('Country'), 'options' => $counrtries, 'name' => 'country', 'style' => 'width:250px;', 'required' => true));
     $fieldset->addField('state', 'text', array('label' => Mage::helper('core')->__('State (Full Name)'), 'title' => Mage::helper('core')->__('State (Full Name)'), 'name' => 'state', 'style' => 'width:250px;', 'required' => false));
     $fieldset->addField('city', 'text', array('label' => Mage::helper('core')->__('City'), 'title' => Mage::helper('core')->__('City'), 'name' => 'city', 'style' => 'width:250px;', 'required' => true));
     $fieldset->addField('address', 'text', array('label' => Mage::helper('core')->__('Address'), 'title' => Mage::helper('core')->__('Address'), 'name' => 'address', 'style' => 'width:250px;', 'required' => true));
     $fieldset->addField('is_all_products', 'checkbox', array('label' => Mage::helper('core')->__('Use All Products from WebSite Store'), 'title' => Mage::helper('core')->__('Use All Products from WebSite Store'), 'name' => 'is_all_products', 'checked' => $formData['is_all_products'] == 1 ? true : false, 'required' => false, 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig()));
     $fieldset->addField('phone', 'text', array('label' => Mage::helper('core')->__('Phone'), 'title' => Mage::helper('core')->__('Phone'), 'name' => 'phone', 'required' => false, 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig()));
     $fieldset->addField('fax', 'text', array('label' => Mage::helper('core')->__('Fax'), 'title' => Mage::helper('core')->__('Fax'), 'name' => 'fax', 'required' => false, 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig()));
     $fieldset->addField('picture_desc', 'textarea', array('label' => Mage::helper('core')->__('Description for Store\'s Photo'), 'title' => Mage::helper('core')->__('Description for Store\'s Photo'), 'name' => 'picture_desc', 'required' => false, 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig()));
     $fieldset->addField('relatlng', 'checkbox', array('label' => Mage::helper('core')->__('Update Lat/Lng after Save'), 'title' => Mage::helper('core')->__('Update Lat/Lng after Save'), 'name' => 'relatlng', 'required' => false, 'checked' => 'checked', 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig()));
     $fieldset->addField('lng', 'text', array('label' => Mage::helper('core')->__('Latitude'), 'title' => Mage::helper('core')->__('Latitude'), 'name' => 'lng', 'required' => false, 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig()));
     $fieldset->addField('lat', 'text', array('label' => Mage::helper('core')->__('Longitude'), 'title' => Mage::helper('core')->__('Longitude'), 'name' => 'lat', 'required' => false, 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig()));
     $formData['desc'] = unserialize($formData['desc']);
     $form->addValues($formData);
     $form->setFieldNameSuffix('storeform');
     $this->setForm($form);
 }
Example #5
0
 /**
  * Sets parameters for tempalte
  *
  * @return Celebros_Conversionpro_Block_Analytics_View
  */
 protected function _prepareLayout()
 {
     //running simulated search, to have the log handle down the page.
     //Mage::helper('conversionpro')->getCurrentLayer()->getProductCollection()->getFacetedData('');
     $this->setCustomerId(Mage::getStoreConfig('conversionpro/anlx_settings/cid'));
     $this->setHost(Mage::getStoreConfig('conversionpro/anlx_settings/host'));
     $product = $this->getProduct();
     //Set product click tracking params
     if (isset($product)) {
         $this->setProductSku($product->getSku());
         $this->setProductName(str_replace("'", "\\'", $product->getName()));
         $this->setProductPrice($product->getFinalPrice());
         $webSessionId = isset($_SESSION['core']['visitor_data']['session_id']) ? $_SESSION['core']['visitor_data']['session_id'] : session_id();
         $this->setWebsessionId($webSessionId);
     } else {
         $pageReferrer = Mage::getModel('core/url')->getBaseUrl() . $_SERVER['PHP_SELF'];
         $this->setPageReferrer($pageReferrer);
         //$this->setQwiserSearchSessionId(Mage::getSingleton('conversionpro/session')->getSearchSessionId());
         $this->setQwiserSearchSessionId($this->_generateGUID());
         $webSessionId = isset($_SESSION['core']['visitor_data']['session_id']) ? $_SESSION['core']['visitor_data']['session_id'] : session_id();
         $this->setWebsessionId($webSessionId);
         if (Mage::Helper('conversionpro')->hasSearchResults()) {
             $this->setQwiserSearchLogHandle(Mage::Helper('conversionpro')->getSearchResults()->GetLogHandle());
         }
     }
     return parent::_prepareLayout();
 }
Example #6
0
 /**
  * Hook to record all fron controller events
  * @param Varien_Event_Observer $observer 
  */
 public function controller_action_predispatch(Varien_Event_Observer $observer)
 {
     try {
         if (extension_loaded('newrelic')) {
             $controllerAction = $observer->getControllerAction();
             $request = $controllerAction->getRequest();
             $controllerName = explode("_", $request->getControllerName());
             if (Mage::getStoreConfig('newrelic/settings/ignore_admin_routes') && $request->getRouteName() == 'adminhtml' || $request->getModuleName() == 'admin' || in_array('adminhtml', $controllerName)) {
                 Mage::Helper('newrelic')->setAppName(false);
                 newrelic_ignore_transaction();
                 newrelic_ignore_apdex();
                 return $this;
             }
             if (mage::helper('newrelic')->ignoreModule($request->getModuleName()) === true) {
                 Mage::Helper('newrelic')->setAppName(false);
                 newrelic_ignore_transaction();
                 newrelic_ignore_apdex();
                 return $this;
             }
             if (Mage::getStoreConfig('newrelic/settings/named_transactions')) {
                 $route = $request->getRouteName() . '/' . $request->getControllerName() . '/' . $request->getActionName();
                 if (Mage::getStoreConfig('newrelic/settings/add_module_to_named_transactions')) {
                     $route .= ' (module: ' . $request->getModuleName() . ')';
                 }
                 newrelic_name_transaction($route);
                 Mage::Helper('newrelic')->setAppName(true);
                 return $this;
             }
         }
     } catch (Exception $e) {
         mage::logException($e);
     }
 }
 /**
  * Get parameters used for build add product to compare list urls
  *
  * @param   Mage_Catalog_Model_Product $product
  * @return  array
  */
 protected function _getUrlParams($product)
 {
     if (key_exists(Mage::Helper('salesperson/mapping')->getMapping('id'), $product->Field)) {
         $productId = $product->Field[Mage::Helper('salesperson/mapping')->getMapping('id')];
     }
     return array('product' => $productId, Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl());
 }
 protected function _prepareCollection()
 {
     $series = array();
     $total_data = array();
     $warehouse_name = array();
     $productIds = array();
     $difference = array();
     $phyids = '';
     $requestData = Mage::helper('adminhtml')->prepareFilterString($this->getRequest()->getParam('top_filter'));
     if (empty($requestData)) {
         $requestData = Mage::Helper('inventoryreports')->getDefaultOptionsWarehouse();
     }
     $gettime = Mage::Helper('inventoryreports')->getTimeSelected($requestData);
     $resource = Mage::getSingleton('core/resource');
     $readConnection = $resource->getConnection('core_read');
     $installer = Mage::getModel('core/resource');
     if ($requestData['warehouse_select']) {
         $warehouse_collection = Mage::getModel('inventoryplus/warehouse')->getCollection();
         $warehouse_id = $requestData['warehouse_select'];
         $query = 'SELECT DISTINCT p.product_id,t.physicalstocktaking_id
             FROM ' . $installer->getTableName("erp_inventory_physicalstocktaking t") . '
             LEFT JOIN ' . $installer->getTableName("erp_inventory_physicalstocktaking_product p") . '
             ON t.physicalstocktaking_id = p.physicalstocktaking_id
             WHERE t.status > 0 AND t.warehouse_id = "' . $warehouse_id . '" AND t.created_at BETWEEN "' . $gettime['date_from'] . '" AND "' . $gettime['date_to'] . '"
             ';
         $results = $readConnection->fetchAll($query);
         if ($results) {
             foreach ($results as $value) {
                 $productIds[] = $value['product_id'];
                 if ($phyids == '') {
                     $phyids = "('" . $value['physicalstocktaking_id'] . "'";
                 } else {
                     $phyids .= ',';
                     $phyids .= "'" . $value['physicalstocktaking_id'] . "'";
                 }
             }
             $phyids .= ")";
         } else {
             $phyids = "('0')";
         }
         $productIds = Mage::helper('inventoryreports')->checkProductInWarehouse($productIds, $warehouse_id);
         $collection = Mage::getModel('catalog/product')->getCollection()->addFieldToFilter('entity_id', array('in' => $productIds));
         $collection->joinField('old_qty', 'inventoryphysicalstocktaking/physicalstocktaking_product', 'old_qty', 'product_id=entity_id', '{{table}}.old_qty IS NOT NULL AND {{table}}.old_qty > 0 AND {{table}}.physicalstocktaking_id IN ' . $phyids, 'left');
         $collection->joinField('adjust_qty', 'inventoryphysicalstocktaking/physicalstocktaking_product', 'adjust_qty', 'product_id=entity_id', '{{table}}.adjust_qty IS NOT NULL AND {{table}}.adjust_qty > 0 AND {{table}}.physicalstocktaking_id IN ' . $phyids, 'left');
         $collection->getSelect()->columns(array('sum_old_qty' => new Zend_Db_Expr("SUM(at_old_qty.old_qty)")));
         $collection->getSelect()->columns(array('sum_adjust_qty' => new Zend_Db_Expr("SUM(at_adjust_qty.adjust_qty)")));
         $collection->getSelect()->columns(array('difference' => new Zend_Db_Expr("SUM(at_adjust_qty.adjust_qty) - SUM(at_old_qty.old_qty)")));
         //            $collection->getSelect()->columns(array('name' => new Zend_Db_Expr("e.name")));
         $collection->getSelect()->group('e.entity_id');
     }
     Mage::getSingleton('core/resource_iterator')->walk($collection->addAttributeToSelect('*')->getSelect(), array(array($this, 'collectionCallback')), array());
     $filterCollection = new Varien_Data_Collection();
     for ($i = 0; $i < count($this->_arr); $i++) {
         $filterCollection->addItem($this->_arr[$i]);
     }
     $this->setCollection($filterCollection);
     $this->_prepareTotals('sum_adjust_qty,sum_old_qty,difference');
     return parent::_prepareCollection();
 }
Example #9
0
 /**
  * Clears the images on the CDN and the local cache.
  *
  * @return string
  */
 public function clearCache()
 {
     parent::clearCache();
     $cds = Mage::Helper('imagecdn')->factory();
     if ($cds->useCdn()) {
         $cds->clearCache();
     }
 }
Example #10
0
 public function getMenuItemUrl($menuItem)
 {
     if (!empty($menuItem->url)) {
         return $menuItem->url;
     } else {
         /* @var $page Mage_Cms_Model_Page */
         return Mage::Helper('cms/page')->getPageUrl($menuItem->cms_page_id);
     }
 }
Example #11
0
 /**
  * Static since a store config exception (caused by a module config error) cannot call magento's model objects.
  * If a store config exception occurs, the exception class logs it drect.
  * 
  * @param type $e
  */
 public static function pushEvent($e, $setAppName = true)
 {
     if (extension_loaded('newrelic')) {
         $message = $e->getMessage();
         $message = empty($message) ? get_class($e) : $message;
         if ($setAppName) {
             Mage::Helper('newrelic')->setAppName();
         }
         newrelic_notice_error($message, $e);
     }
 }
Example #12
0
 /**
  * Record a log event to new relic
  * 
  * @param type $event
  * @return type
  */
 public function recordEvent($event)
 {
     if (extension_loaded('newrelic')) {
         if (Mage::getStoreConfig('newrelic/settings/record_system_log') && !Mage::helper('newrelic')->ignoreMessage($event['message'], 'system_log')) {
             if ($event['priorityName'] == 'DEBUG' && Mage::getStoreConfig('newrelic/settings/system_log_ignore_debug')) {
                 return;
             }
             Mage::Helper('newrelic')->setAppName();
             newrelic_notice_error($this->_eventType . ': [' . $event['priorityName'] . '] ' . $event['message']);
         }
     }
 }
 public function getAnlxSearchResultFunction()
 {
     if (Mage::getStoreConfig('salesperson/anlx_settings/dc') == "" || Mage::getStoreConfig('salesperson/anlx_settings/cid') == "") {
         return "";
     }
     /*$observer = array('ssid' => Mage::Helper('salesperson')->getSalespersonApi()->results->SearchInformation->SessionId, 'logHandle' => Mage::Helper('salesperson')->getSalespersonApi()->results->GetLogHandle());
     		Mage::getModel('salesperson/observer')->sendResultAnlxInfo($observer);*/
     $dca = Mage::getStoreConfig('salesperson/anlx_settings/dc');
     $cid = Mage::getStoreConfig('salesperson/anlx_settings/cid');
     $results = Mage::Helper('salesperson')->getSalespersonApi()->results;
     $sessionId = $this->_getSession()->getSessionId();
     return Mage::getModel('salesperson/api_anlx_analyticsFunctions', array("G_DATA_COLLECTOR_ADDRESS" => $dca, "G_CUSTOMER_ID" => $cid, "G_CUSTOMER_NAME" => $cid, "G_PUBLIC_KEY" => ""))->Celebros_Analytics_SearchResults($results->SearchInformation->SessionId, $results->GetLogHandle(), $sessionId, '1', $sessionId, isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', (bool) Mage::getStoreConfig('salesperson/anlx_settings/protocol_connection'), true);
 }
 public function setOrderId()
 {
     $active = Mage::Helper('customorderid/data')->custom_order_id_active();
     $OrderEntityType = Mage::getModel('eav/entity_type')->load(self::SALES_ORDER, 'entity_type_code')->getData();
     $invoiceEntityType = Mage::getModel('eav/entity_type')->load(self::SALES_INVOICE, 'entity_type_code')->getData();
     $shipmentEntityType = Mage::getModel('eav/entity_type')->load(self::SALES_SHIPMENT, 'entity_type_code')->getData();
     $creditmemoEntityType = Mage::getModel('eav/entity_type')->load(self::SALES_CREDITMEMO, 'entity_type_code')->getData();
     $orderEnable = Mage::Helper('customorderid/data')->custom_order_enable();
     $invoiceEnable = Mage::Helper('customorderid/data')->custom_invoice_enable();
     $shippingEnable = Mage::Helper('customorderid/data')->custom_shipping_enable();
     $creditmemoEnable = Mage::Helper('customorderid/data')->custom_creditmemo_enable();
     if ($active) {
         //** Sales Order New Id
         if ($orderEnable) {
             $orderIdNew = Mage::Helper('customorderid/customorderid')->order();
             $this->newOrderIdSet($orderIdNew, $OrderEntityType['entity_type_id']);
         } else {
             $this->newOrderIdSet(self::SALES_DEFAULT_ID, $OrderEntityType['entity_type_id']);
         }
         //** Invoice New Order Id
         if ($invoiceEnable) {
             $invoiceIdNew = Mage::Helper('customorderid/customorderid')->invoice();
             $this->newOrderIdSet($invoiceIdNew, $invoiceEntityType['entity_type_id']);
         } else {
             $this->newOrderIdSet(self::SALES_DEFAULT_ID, $invoiceEntityType['entity_type_id']);
         }
         //** Shipment New Order Id
         if ($shippingEnable) {
             $shipmentNew = Mage::Helper('customorderid/customorderid')->shipment();
             $this->newOrderIdSet($shipmentNew, $shipmentEntityType['entity_type_id']);
         } else {
             $this->newOrderIdSet(self::SALES_DEFAULT_ID, $shipmentEntityType['entity_type_id']);
         }
         //** CreditMemo New Order Id
         if ($creditmemoEnable) {
             $creditMemoIdNew = Mage::Helper('customorderid/customorderid')->creditmemo();
             $this->newOrderIdSet($creditMemoIdNew, $creditmemoEntityType['entity_type_id']);
         } else {
             $this->newOrderIdSet(self::SALES_DEFAULT_ID, $creditmemoEntityType['entity_type_id']);
         }
         // $updateNewOrderId = Mage::getModel('eav/entity_store')->load($OrderEntityType['entity_type_id'], 'entity_type_id')->addData(array('increment_last_id'=> $orderIdNew))->save();
         // $OrderEntityStore = Mage::getModel('eav/entity_store')->load($invoiceEntityType['entity_type_id'], 'entity_type_id')->addData(array('increment_last_id'=> $invoiceIdNew))->save();
         // $OrderEntityStore = Mage::getModel('eav/entity_store')->load($shipmentEntityType['entity_type_id'], 'entity_type_id')->addData(array('increment_last_id'=> $shipmentNew))->save();
         // $OrderEntityStore = Mage::getModel('eav/entity_store')->load($creditmemoEntityType['entity_type_id'], 'entity_type_id')->addData(array('increment_last_id'=> $creditMemoIdNew))->save();
     } else {
         $this->newOrderIdSet(self::SALES_DEFAULT_ID, $OrderEntityType['entity_type_id']);
         $this->newOrderIdSet(self::SALES_DEFAULT_ID, $invoiceEntityType['entity_type_id']);
         $this->newOrderIdSet(self::SALES_DEFAULT_ID, $shipmentEntityType['entity_type_id']);
         $this->newOrderIdSet(self::SALES_DEFAULT_ID, $creditmemoEntityType['entity_type_id']);
     }
 }
Example #15
0
 public function getFullTaxInfo()
 {
     $taxClassAmount = Mage::helper('tax')->getCalculatedTaxes($this->getOrder());
     if (!empty($taxClassAmount)) {
         $shippingTax = Mage::helper('tax')->getShippingTax($this->getOrder());
         $taxClassAmount = array_merge($shippingTax, $taxClassAmount);
         $i = 0;
         $len = count($taxClassAmount);
         foreach ($taxClassAmount as $tax) {
             $tableHtmlPseudo = '';
             $taxTitle = Mage::Helper('core/string')->cleanString($tax['title']);
             $taxTitle = 'tax_' . preg_replace("[^A-Za-z0-9]", "", $taxTitle);
             $taxTitle = strtolower($taxTitle);
             $percent = $tax['percent'] ? ' (' . floatval($tax['percent']) . '%)' : '';
             $tableHtmlPseudo .= '<tr>';
             $tableHtmlPseudo .= '<td><span>' . $tax['title'] . '     ' . $percent . '</span></td>';
             $tableHtmlPseudo .= '<td><span>' . $this->getAmountPrefix() . $this->getOrder()->formatPriceTxt($tax['tax_amount']) . '</span></td>';
             $tableHtmlPseudo .= '</tr>';
             if ($i++ == 0) {
                 $tableHtml = '<table class="table-rates-tax"><tbody>';
             }
             $tableHtml .= $tableHtmlPseudo;
             if ($i == $len) {
                 $tableHtml .= '</tbody></table>';
             }
             $tax_info[] = array($taxTitle => array('value' => $this->getAmountPrefix() . $this->getOrder()->formatPriceTxt($tax['tax_amount']), 'label' => Mage::helper('tax')->__($tax['title']) . $percent . ':'), 'pseudotaxtable_data' => array('value' => $tableHtmlPseudo, 'label' => Mage::helper('tax')->__($rate['title']) . $percent . ':'), 'taxtable_data' => array('value' => $tableHtml, 'label' => Mage::helper('tax')->__($rate['title']) . $percent . ':'));
             $taxClassAmount = $tax_info;
         }
     } else {
         $rates = Mage::getResourceModel('sales/order_tax_collection')->loadByOrder($this->getOrder())->toArray();
         $fullInfo = Mage::getSingleton('tax/calculation')->reproduceProcess($rates['items']);
         $tax_info = array();
         if ($fullInfo) {
             foreach ($fullInfo as $info) {
                 if (isset($info['hidden']) && $info['hidden']) {
                     continue;
                 }
                 $_amount = $info['amount'];
                 foreach ($info['rates'] as $rate) {
                     $percent = $rate['percent'] ? ' (' . $rate['percent'] . '%)' : '';
                     $taxTitle = Mage::Helper('core/string')->cleanString($rate['title']);
                     $taxTitle = 'tax_' . preg_replace("[^A-Za-z0-9]", "", $taxTitle);
                     $taxTitle = strtolower($taxTitle);
                     $tax_info[] = array($taxTitle => array('value' => $this->getAmountPrefix() . $this->getOrder()->formatPriceTxt($_amount), 'label' => Mage::helper('tax')->__($rate['title']) . $percent . ':'));
                 }
             }
         }
         $taxClassAmount = $tax_info;
     }
     return $taxClassAmount;
 }
Example #16
0
 protected function _prepareColumns()
 {
     $configModel = Mage::getModel('utils/config');
     $carriersModel = Mage::getModel('utils/carriers');
     $this->addColumn("id", array("header" => Mage::helper("labels")->__("ID"), "align" => "right", "width" => "50px", "index" => "id"));
     $this->addColumn("carrier_id", array("header" => Mage::helper("labels")->__("Carrier Name"), "align" => "left", "index" => "carrier_id", "type" => "options", "options" => $configModel->toOptions($carriersModel->getCollection()->load(), array('id' => 'description'))));
     $this->addColumn("prefix", array("header" => Mage::helper("labels")->__("Prefix"), "align" => "left", "index" => "prefix"));
     $this->addColumn("suffix", array("header" => Mage::helper("labels")->__("Suffix"), "align" => "left", "index" => "suffix"));
     $this->addColumn("begin_code", array("header" => Mage::helper("labels")->__("Begin Code"), "align" => "left", "index" => "begin_code"));
     $this->addColumn("end_code", array("header" => Mage::helper("labels")->__("End Code"), "align" => "left", "index" => "end_code"));
     $this->addColumn("alarm", array("header" => Mage::helper("labels")->__("Alarm"), "align" => "left", "index" => "alarm"));
     $this->addColumn("enabled", array("header" => Mage::helper("labels")->__("Enabled"), "align" => "left", "index" => "enabled", "type" => "options", "options" => Mage::Helper('labels')->getYesNo()));
     return parent::_prepareColumns();
 }
Example #17
0
 public function handle($_vars)
 {
     if (!$_vars) {
         Mage::helper("icecore")->log("No Postback vars");
         die("ICEPAY postback page installed correctly.");
     }
     $this->_post = $_vars;
     if ($_vars['Status'] == Icepay_IceCore_Model_Config::STATUS_VERSION_CHECK) {
         $this->outputVersion($this->validateVersion());
     }
     Mage::helper("icecore")->log(serialize($_vars));
     $this->order = $this->orderModel->loadByIncrementId($_vars['OrderID']);
     $icepayTransaction = $this->sqlModel->loadPaymentByID($this->order->getRealOrderId());
     $this->storeID = $icepayTransaction["store_id"];
     $transActionID = $this->saveTransaction($_vars);
     $doSpecialActions = false;
     if ($_vars['Status'] == Icepay_IceCore_Model_Config::STATUS_AUTH) {
         if (Mage::helper('icecore')->isModuleInstalled('Icepay_AutoCapture')) {
             if (Mage::Helper('icepay_autocapture')->isAutoCaptureActive($this->storeID)) {
                 $_vars['Status'] = Icepay_IceCore_Model_Config::STATUS_SUCCESS;
             }
         }
     }
     if ($this->canUpdateBasedOnIcepayTable($icepayTransaction['status'], $_vars['Status'])) {
         /* creating the invoice causes major overhead! Status should to be updated and saved first */
         if ($_vars['Status'] == Icepay_IceCore_Model_Config::STATUS_SUCCESS) {
             $doSpecialActions = true;
         }
         // Update ICEPAY transaction info
         $newData = $icepayTransaction;
         $newData['update_time'] = now();
         $newData['status'] = $_vars['Status'];
         $newData['transaction_id'] = $_vars['PaymentID'];
         $this->sqlModel->changeStatus($newData);
         // Update order status
         if ($_vars['Status'] == Icepay_IceCore_Model_Config::STATUS_ERROR) {
             $this->order->cancel();
         } else {
             $this->order->setState($this->getMagentoState($_vars['Status']), $this->getMagentoStatus($_vars['Status']), Mage::helper('icecore')->__('Status of order changed'), true);
         }
     }
     $this->order->save();
     $this->sendMail($icepayTransaction['status'], $_vars['Status']);
     if ($doSpecialActions) {
         $extraMsg = $this->specialActions($_vars['Status'], $transActionID);
         $this->order->setState($this->getMagentoState($_vars['Status']), $this->getMagentoStatus($_vars['Status']), $extraMsg, false);
         $this->order->save();
     }
 }
 /**
  * prepare columns for this grid
  *
  * @return Magestore_Inventory_Block_Adminhtml_Inventory_Grid
  */
 protected function _prepareColumns()
 {
     $filterData = new Varien_Object();
     $requestData = Mage::helper('adminhtml')->prepareFilterString($this->getRequest()->getParam('top_filter'));
     if (empty($requestData)) {
         $requestData = Mage::Helper('inventoryreports')->getDefaultOptionsSupplier();
     }
     $this->addColumn('name', array('header' => Mage::helper('sales')->__('Product Name'), 'align' => 'left', 'index' => 'name'));
     $this->addColumn('total_ordered', array('header' => Mage::helper('sales')->__('Total Ordered'), 'align' => 'right', 'index' => 'total_ordered', 'width' => '100px', 'type' => 'number', 'filter_condition_callback' => array($this, '_filterTotalCallback')));
     $this->addColumn('total_canceled', array('header' => Mage::helper('sales')->__('Total Canceled'), 'align' => 'right', 'index' => 'total_canceled', 'width' => '100px', 'type' => 'number', 'filter_condition_callback' => array($this, '_filterTotalCallback')));
     $this->addColumn('total_refunded', array('header' => Mage::helper('sales')->__('Total Refunded'), 'align' => 'right', 'index' => 'total_refunded', 'width' => '100px', 'type' => 'number', 'filter_condition_callback' => array($this, '_filterTotalCallback')));
     $this->addColumn('total_sold', array('header' => Mage::helper('sales')->__('Total Sold'), 'align' => 'right', 'index' => 'total_sold', 'width' => '100px', 'type' => 'number', 'filter_condition_callback' => array($this, '_filterTotalCallback')));
     //        $this->addExportType('*/*/exportCsv', Mage::helper('inventoryreports')->__('CSV'));
     //        $this->addExportType('*/*/exportXml', Mage::helper('inventoryreports')->__('XML'));
     return parent::_prepareColumns();
 }
Example #19
0
 /**
  * Hijacks the normal GD2 save method to add ImageCDN hooks. Fails back to parent method
  * as appropriate.
  *
  * @param string $destination
  * @param string $newName
  * @return none
  */
 public function save($destination = null, $newName = null)
 {
     $cds = Mage::Helper('imagecdn')->factory();
     $compression = Mage::getStoreConfig('imagecdn/general/compression');
     if ($cds->useCdn()) {
         $temp = tempnam(sys_get_temp_dir(), 'cds');
         parent::save($temp);
         //Compress images?
         if ($this->_fileType == IMAGETYPE_JPEG && $compression > 0) {
             $convert = round((9 - $compression) * (100 / 8));
             //convert to imagejpeg's scale
             call_user_func('imagejpeg', $this->_imageHandler, $temp, $convert);
         } elseif ($this->_fileType == IMAGETYPE_PNG && $compression > 0) {
             $convert = round(($compression - 1) * (9 / 8));
             //convert to imagepng's scale
             call_user_func('imagepng', $this->_imageHandler, $temp, $convert);
         }
         $filename = !isset($destination) ? $this->_fileName : $destination;
         if (isset($destination) && isset($newName)) {
             $filename = $destination . "/" . $filename;
         } elseif (isset($destination) && !isset($newName)) {
             $info = pathinfo($destination);
             $filename = $destination;
             $destination = $info['dirname'];
         } elseif (!isset($destination) && isset($newName)) {
             $filename = $this->_fileSrcPath . "/" . $newName;
         } else {
             $filename = $this->_fileSrcPath . $this->_fileSrcName;
         }
         if ($cds->save($filename, $temp)) {
             @unlink($temp);
         } else {
             if (!is_writable($destination)) {
                 try {
                     $io = new Varien_Io_File();
                     $io->mkdir($destination);
                 } catch (Exception $e) {
                     throw new Exception("Unable to write file into directory '{$destinationDir}'. Access forbidden.");
                 }
             }
             @rename($temp, $filename);
             @chmod($filename, 0644);
         }
     } else {
         return parent::save($destination, $newName);
     }
 }
Example #20
0
    protected function _prepareForm()
    {
        $_fb05a43927cff438da7fdbd15552ff3227bd4b96 = new Varien_Data_Form();
        $this->setForm($_fb05a43927cff438da7fdbd15552ff3227bd4b96);
        $_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c = Mage::registry('current_customer');
        $_780559c4efd84bf65288edb8394a43a3aa300846 = $_fb05a43927cff438da7fdbd15552ff3227bd4b96->addFieldset('subloginconfiguration', array('legend' => Mage::helper('sublogin')->__('Sublogin Configuration')));
        $_fb05a43927cff438da7fdbd15552ff3227bd4b96->setHtmlIdPrefix('_subloginconfiguration');
        $_fb05a43927cff438da7fdbd15552ff3227bd4b96->setFieldNameSuffix('subloginconfiguration');
        $_780559c4efd84bf65288edb8394a43a3aa300846->addField('can_create_sublogins', 'select', array('label' => Mage::helper('sublogin')->__('Can create sublogins'), 'after_element_html' => '<br />' . Mage::helper('sublogin')->__('If allowed, customer can create sublogins in frontend area'), 'name' => 'can_create_sublogins', 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()));
        if (Mage::getStoreConfig('sublogin/projects/project266_active')) {
            $_780559c4efd84bf65288edb8394a43a3aa300846->addField('max_number_sublogins', 'text', array('label' => Mage::helper('sublogin')->__('Max. number of sublogins'), 'after_element_html' => Mage::helper('sublogin')->__('Configure the max. amount of sublogins the customer can create. 0 is unlimited.'), 'name' => 'max_number_sublogins', 'readonly' => true));
        } else {
            $_780559c4efd84bf65288edb8394a43a3aa300846->addField('max_number_sublogins', 'text', array('label' => Mage::helper('sublogin')->__('Max. number of sublogins'), 'after_element_html' => Mage::helper('sublogin')->__('Configure the max. amount of sublogins the customer can create. 0 is unlimited.'), 'name' => 'max_number_sublogins'));
        }
        $_64af779d81eb451f44e50893e14780ab31bf8125 = $_fb05a43927cff438da7fdbd15552ff3227bd4b96->addFieldset('sublogin', array('legend' => Mage::helper('sublogin')->__('Sublogins')));
        $_fb05a43927cff438da7fdbd15552ff3227bd4b96->setHtmlIdPrefix('_sublogin');
        $_fb05a43927cff438da7fdbd15552ff3227bd4b96->setFieldNameSuffix('sublogin');
        $_64af779d81eb451f44e50893e14780ab31bf8125->addField('sublogins', 'text', array('name' => 'sublogins'));
        $_2ecc41b28041667049b648881d5ff17111568699 = $_fb05a43927cff438da7fdbd15552ff3227bd4b96->getElement('sublogins')->getName();
        $_2289f66a254ac0ee1bb00efbd40a49e3e810d1f2 = $_fb05a43927cff438da7fdbd15552ff3227bd4b96->getElement('sublogins')->getHtmlId();
        $_168f685b62f9bec4ef848eff88e14ca431705084 = <<<EOH
<div style="width:100px">
                <img style="margin-top:1px;float:right"
                    id="{$_2289f66a254ac0ee1bb00efbd40a49e3e810d1f2}_row_{{index}}_expire_date_trig"
                    src="{$this->getSkinUrl('images/grid-cal.gif')}" />
                <input rel="{{index}}" class="input-text" type="text" value="{{expire_date}}"
                    name="{$_2ecc41b28041667049b648881d5ff17111568699}[{{index}}][expire_date]" id="{$_2289f66a254ac0ee1bb00efbd40a49e3e810d1f2}_row_{{index}}_expire_date"
                    readonly="readonly"
                    style="width:70px"
                    />
</div>
EOH;
        $_d2389373c4d226ef389a44a6ea431427c26dd7a9 = Mage::Helper('sublogin')->getGridFields($_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c, $_168f685b62f9bec4ef848eff88e14ca431705084);
        if (Mage::getStoreConfig('sublogin/general/edit_in_grid', $_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c->getStoreId())) {
            $_205d95c001c842f933e3b55fa4e902d5d2fdd0af = Mage::getModel('sublogin/sublogin')->getCollection()->addFieldToFilter('entity_id', $_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c->getId())->addOrder('id', 'ASC');
            $_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c->setSublogins($_205d95c001c842f933e3b55fa4e902d5d2fdd0af->getItems());
            $_fb05a43927cff438da7fdbd15552ff3227bd4b96->getElement('sublogins')->setRenderer(Mage::getSingleton('core/layout')->createBlock('sublogin/tableinput')->addAfterJs('mageb2b/sublogin/form.js')->setDisplay(array('idfield' => 'id', 'addbutton' => $this->__('Add'), 'fields' => $_d2389373c4d226ef389a44a6ea431427c26dd7a9)));
        } else {
            $_fb05a43927cff438da7fdbd15552ff3227bd4b96->getElement('sublogins')->setRenderer(Mage::getSingleton('core/layout')->createBlock('sublogin/customer_edit_tab_sublogin_gridContainer'));
        }
        if (!$_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c->getId()) {
            $_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c->setData('can_create_sublogins', 1);
        }
        $_fb05a43927cff438da7fdbd15552ff3227bd4b96->setValues($_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c->getData());
        $this->setForm($_fb05a43927cff438da7fdbd15552ff3227bd4b96);
        return $this;
    }
Example #21
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     $this->_setAmount(0);
     $this->_setBaseAmount(0);
     $quote = $address->getQuote();
     $val = Mage::Helper('adyen')->isPaymentFeeEnabled($quote);
     if ($address->getAllItems() && $val) {
         $currentAmount = $address->getPaymentFeeAmount();
         $fee = Mage::Helper('adyen')->getPaymentFeeAmount($quote);
         $balance = $fee - $currentAmount;
         $address->setPaymentFeeAmount($address->getQuote()->getStore()->convertPrice($balance));
         $address->setBasePaymentFeeAmount($balance);
         $address->setGrandTotal($address->getGrandTotal() + $address->getPaymentFeeAmount());
         $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBasePaymentFeeAmount());
     }
     return $this;
 }
 /**
  * prepare columns for this grid
  *
  * @return Magestore_Inventory_Block_Adminhtml_Inventory_Grid
  */
 protected function _prepareColumns()
 {
     $filterData = new Varien_Object();
     $requestData = Mage::helper('adminhtml')->prepareFilterString($this->getRequest()->getParam('top_filter'));
     if (empty($requestData)) {
         $requestData = Mage::Helper('inventoryreports')->getDefaultOptionsSupplier();
     }
     if ($supplierId = $requestData['supplier_select']) {
         $this->addColumn('product_name', array('header' => Mage::helper('inventoryreports')->__('Product Name'), 'align' => 'left', 'index' => 'product_name', 'filter_condition_callback' => array($this, '_filterProductNameCallback')));
         $this->addColumn('total_inventory', array('header' => Mage::helper('inventoryreports')->__('Total Qty Purchased'), 'align' => 'right', 'index' => 'total_inventory', 'type' => 'number', 'width' => '100px', 'filter_condition_callback' => array($this, '_filterTotalInventoryCallback'), 'renderer' => 'inventoryreports/adminhtml_reportcontent_reportbysupplier_renderer_inventory'));
     } else {
         $this->addColumn('supplier_name', array('header' => Mage::helper('inventoryreports')->__('Supplier name'), 'align' => 'left', 'index' => 'supplier_name'));
         $this->addColumn('total_inventory', array('header' => Mage::helper('inventoryreports')->__('Inventory by Supplier'), 'align' => 'right', 'index' => 'total_inventory', 'type' => 'number', 'width' => '100px', 'filter_condition_callback' => array($this, '_filterTotalInventoryCallback'), 'renderer' => 'inventoryreports/adminhtml_reportcontent_reportbysupplier_renderer_inventory'));
     }
     //        $this->addExportType('*/*/exportCsv', Mage::helper('inventoryreports')->__('CSV'));
     //        $this->addExportType('*/*/exportXml', Mage::helper('inventoryreports')->__('XML'));
     return parent::_prepareColumns();
 }
Example #23
0
 /**
  * Retrieve url for adding product to wishlist with params
  *
  * @param Celebros_Salesperson_Model_Api_QwiserProduct|Mage_Wishlist_Model_Item $product
  * @param array $param
  * @return  string|boolean
  */
 public function getAddUrlWithParams($item, array $params = array())
 {
     //Mage::log("wishlist");
     $productId = null;
     if ($item instanceof Celebros_Salesperson_Model_Api_QwiserProduct) {
         if (key_exists(Mage::Helper('salesperson/mapping')->getMapping('id'), $item->Field)) {
             $productId = $item->Field[Mage::Helper('salesperson/mapping')->getMapping('id')];
         }
     }
     if ($item instanceof Mage_Wishlist_Model_Item) {
         $productId = $item->getProductId();
     }
     if ($productId) {
         $params['product'] = $productId;
         return $this->_getUrlStore($item)->getUrl('wishlist/index/add', $params);
     }
     return false;
 }
Example #24
0
 /**
  * Provides the URL to the image on the CDN or fails back to the parent method as appropriate
  *
  * @return string
  */
 public function getImageUrl()
 {
     $path = false;
     if ($image = $this->getImage()) {
         $path = Mage::getBaseDir('media') . '/catalog/category/' . $image;
     }
     $cds = Mage::Helper('imagecdn')->factory();
     if ($path && $cds->useCdn()) {
         $fileExists = $cds->fileExists($path);
         if (!$fileExists) {
             $cds->save($path, $path);
         }
         $url = $cds->getUrl($path);
         if ($url) {
             return $url;
         }
     }
     return parent::getImageUrl();
 }
Example #25
0
 /**
  * Retrieve url for add product to cart
  *
  * @param   Mage_Catalog_Model_Product $product
  * @return  string
  */
 public function getAddUrl($product, $additional = array())
 {
     $continueUrl = Mage::helper('core')->urlEncode($this->getCurrentUrl());
     $urlParamName = Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED;
     if (key_exists(Mage::Helper('salesperson/mapping')->getMapping('id'), $product->Field)) {
         $routeParams = array($urlParamName => $continueUrl, 'product' => $product->Field[Mage::Helper('salesperson/mapping')->getMapping('id')]);
     }
     if (!empty($additional)) {
         $routeParams = array_merge($routeParams, $additional);
     }
     //        if ($product->hasUrlDataObject()) {
     //            $routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
     //            $routeParams['_store_to_url'] = true;
     //        }
     if ($this->_getRequest()->getRouteName() == 'checkout' && $this->_getRequest()->getControllerName() == 'cart') {
         $routeParams['in_cart'] = 1;
     }
     return $this->_getUrl('checkout/cart/add', $routeParams);
 }
Example #26
0
 protected function _prepareForm()
 {
     $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/*/save'), 'method' => 'post', 'enctype' => 'multipart/form-data'));
     $categoryId = (int) $this->getRequest()->getParam('id');
     if ($categoryId <= 0) {
         return parent::_prepareForm();
     }
     $kwixoCategoryMapping = Mage::getModel('ops/kwixo_category_mapping')->loadByCategoryId($categoryId);
     $storeId = (int) $this->getRequest()->getParam('store');
     $fieldset = $form->addFieldset('ops_form', array('legend' => Mage::helper('ops/data')->__('Categories configuration')));
     $fieldset->addField('storeId', 'hidden', array('required' => true, 'name' => 'storeId', 'value' => $storeId));
     $fieldset->addField('id', 'hidden', array('required' => false, 'name' => 'id', 'value' => $kwixoCategoryMapping->getId()));
     $fieldset->addField('category_id', 'hidden', array('required' => true, 'name' => 'category_id', 'value' => $categoryId));
     $fieldset->addField('kwixoCategory_id', 'select', array('label' => Mage::Helper('ops/data')->__('Kwixo category'), 'class' => 'required-entry', 'required' => true, 'name' => 'kwixoCategory_id', 'value' => $kwixoCategoryMapping->getKwixoCategoryId(), 'values' => Mage::getModel('ops/source_kwixo_productCategories')->toOptionArray()));
     $fieldset->addField('applysubcat', 'checkbox', array('label' => Mage::Helper('ops/data')->__('Apply to sub-categories'), 'name' => 'applysubcat'));
     $form->setUseContainer(true);
     $this->setForm($form);
     return parent::_prepareForm();
 }
 /**
  * prepare columns for this grid
  *
  * @return Magestore_Inventory_Block_Adminhtml_Inventory_Grid
  */
 protected function _prepareColumns()
 {
     $filterData = new Varien_Object();
     $requestData = Mage::helper('adminhtml')->prepareFilterString($this->getRequest()->getParam('top_filter'));
     if (empty($requestData)) {
         $requestData = Mage::Helper('inventoryreports')->getDefaultOptionsWarehouse();
     }
     $warehouseId = $requestData['warehouse_select'];
     if (!$warehouseId) {
         //die; //
         $this->addColumn('warehouse_name', array('header' => Mage::helper('inventoryreports')->__('Warehouse Name'), 'align' => 'left', 'index' => 'warehouse_name'));
         $this->addColumn('total_product', array('header' => Mage::helper('inventoryreports')->__('Total No. of Products'), 'align' => 'right', 'index' => 'total_product', 'type' => 'number', 'width' => '100px', 'filter_condition_callback' => array($this, '_filterCallback')));
     } else {
         $this->addColumn('name', array('header' => Mage::helper('inventoryreports')->__('Product Name'), 'align' => 'left', 'index' => 'name', 'filter_condition_callback' => array($this, '_filterCallback')));
         $this->addColumn('product_id', array('header' => Mage::helper('inventoryreports')->__('Image'), 'align' => 'right', 'index' => 'product_id', 'type' => 'number', 'width' => '100px', 'filter' => false, 'renderer' => 'inventoryreports/adminhtml_reportcontent_reportbywarehouse_renderer_productimage'));
     }
     //        $this->addExportType('*/*/exportCsv', Mage::helper('inventoryreports')->__('CSV'));
     //        $this->addExportType('*/*/exportXml', Mage::helper('inventoryreports')->__('XML'));
     return parent::_prepareColumns();
 }
 protected function _prepareCollection()
 {
     $filterData = new Varien_Object();
     $requestData = Mage::helper('adminhtml')->prepareFilterString($this->getRequest()->getParam('top_filter'));
     $gettime = Mage::Helper('inventoryreports')->getTimeSelected($requestData);
     if (!$requestData['warehouse_select']) {
         //All warehouses
         $installer = Mage::getModel('core/resource');
         $collection = Mage::getModel('inventoryplus/warehouse_shipment')->getCollection();
         $collection->getSelect()->joinLeft(array('order' => $installer->getTableName('sales_flat_order')), 'main_table.order_id = order.entity_id', array('count(distinct main_table.order_id) as total_order', 'main_table.warehouse_name'))->where('order.created_at BETWEEN "' . $gettime['date_from'] . '" and "' . $gettime['date_to'] . '" AND main_table.warehouse_id > 0 ')->group('main_table.warehouse_id');
     } else {
         //Warehouse selected
         $installer = Mage::getModel('core/resource');
         $collection = Mage::getModel('inventoryplus/warehouse_shipment')->getCollection();
         $collection->getSelect()->distinct(true)->joinLeft(array('order' => $installer->getTableName('sales_flat_order')), 'main_table.order_id = order.entity_id', array('order.increment_id', 'order.created_at', 'order.base_grand_total', 'order.grand_total'))->joinLeft(array('item' => $installer->getTableName('sales_flat_order_item')), 'order.entity_id = item.order_id', array('sum(item.qty_ordered) as qty_order', 'sum(item.qty_shipped) as qty_ship', 'sum(item.qty_refunded) as qty_refund'))->where('main_table.warehouse_id = ' . $requestData['warehouse_select'] . ' AND order.created_at BETWEEN "' . $gettime['date_from'] . '" and "' . $gettime['date_to'] . '"')->group('main_table.order_id');
     }
     //Zend_Debug::Dump($collection->getSelect()->__toString());die();
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
 /**
  * Get all config data to pass to javascript (array) and jsonencode.
  *
  * @return mixed
  */
 public function getConfig()
 {
     $center = explode(",", Mage::Helper('dpd')->getGoogleMapsCenter());
     $this->_configArray["saveParcelUrl"] = $this->getUrl('dpd/ajax/saveparcel', array('_secure' => true));
     $this->_configArray["invalidateParcelUrl"] = $this->getUrl('dpd/ajax/invalidateparcel', array('_secure' => true));
     $this->_configArray["windowParcelUrl"] = $this->getUrl('dpd/ajax/windowindex', array('_secure' => true));
     $this->_configArray["ParcelUrl"] = $this->getUrl('dpd/ajax/index', array('_secure' => true));
     $this->_configArray["gmapsCenterlat"] = $center[0];
     $this->_configArray["gmapsCenterlng"] = $center[1];
     $this->_configArray["gmapsHeight"] = Mage::getStoreConfig('carriers/dpdparcelshops/google_maps_height') . 'px';
     $this->_configArray["loadingmessage"] = '<span class="message">' . $this->__('Loading DPD parcelshop map based on your address...') . '</span>';
     $this->_configArray["gmapsWidth"] = Mage::getStoreConfig('carriers/dpdparcelshops/google_maps_width') . 'px';
     $this->_configArray["gmapsIcon"] = Mage::getDesign()->getSkinUrl('images/dpd/icon_parcelshop.png');
     $this->_configArray["gmapsIconShadow"] = Mage::getDesign()->getSkinUrl('images/dpd/icon_parcelshop_shadow.png');
     $this->_configArray["gmapsCustomIcon"] = Mage::getStoreConfig('carriers/dpdparcelshops/google_maps_icon') ? Mage::getBaseUrl('media') . "dpd/" . Mage::getStoreConfig('carriers/dpdparcelshops/google_maps_icon') : "";
     $this->_configArray["gmapsDisplay"] = (bool) Mage::getStoreConfig('carriers/dpdparcelshops/google_maps_display');
     $this->_configArray["loaderimage"] = $this->getSkinUrl('images/dpd/ajax-loader.gif');
     $this->_configArray["freeShippingOnCustom"] = (bool) Mage::getStoreConfig('carriers/dpdparcelshops/custom_parcelshops_free_shipping');
     return Mage::helper('core')->jsonEncode($this->_configArray);
 }
 protected function _prepareCollection()
 {
     $resource = Mage::getModel('core/resource');
     $filterData = new Varien_Object();
     $requestData = Mage::helper('adminhtml')->prepareFilterString($this->getRequest()->getParam('top_filter'));
     if (empty($requestData)) {
         $requestData = Mage::helper('inventoryreports')->getDefaultOptionsWarehouse();
     }
     $gettime = Mage::Helper('inventoryreports')->getTimeSelected($requestData);
     if (!$requestData['warehouse_select']) {
         //All Warehouses
         $collection = Mage::getModel('inventorywarehouse/sendstock')->getCollection()->addFieldToFilter('status', 1);
         $collection->getSelect()->columns('SUM(total_products) AS total_sent')->where('created_at BETWEEN "' . $gettime['date_from'] . '" and "' . $gettime['date_to'] . '"')->group('warehouse_name_from');
     } else {
         //  WAREHOUSE SELECTED
         $collection = Mage::getModel('inventorywarehouse/sendstock_product')->getCollection();
         $collection->getSelect()->join(array('sendstock' => $resource->getTableName('erp_inventory_warehouse_sendstock')), 'sendstock.warehouse_sendstock_id = main_table.warehouse_sendstock_id', array('main_table.product_name', 'sum(main_table.qty) as total_sent', 'sendstock.created_at', 'main_table.product_name'))->where('sendstock.status = 1 and sendstock.warehouse_id_from = ' . $requestData['warehouse_select'] . ' and sendstock.created_at BETWEEN "' . $gettime['date_from'] . '" and "' . $gettime['date_to'] . '"')->group('main_table.product_id');
     }
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }