Example #1
0
 /**
  * add new column, additional attributes and joins are stored on the configuration singleton to add them at the event observer
  *
  * @param Varien_Object $params
  */
 protected function _addAction($params)
 {
     $columnConfig = array();
     $blockId = $params->getBlock()->getId();
     /**
      * @var FireGento_GridControl_Model_Config $config
      */
     $config = Mage::getSingleton('firegento_gridcontrol/config');
     foreach ($params->getAction()->children() as $attribute) {
         // 4 special cases
         if ($attribute->getName() == 'index') {
             $config->addCollectionUpdate(FireGento_GridControl_Model_Config::TYPE_ADD_ATTRIBUTE, $blockId, (string) $attribute);
         } else {
             if ($attribute->getName() == 'joinAttribute') {
                 $config->addCollectionUpdate(FireGento_GridControl_Model_Config::TYPE_JOIN_ATTRIBUTE, $blockId, (string) $attribute);
                 continue;
             } else {
                 if ($attribute->getName() == 'joinField') {
                     $config->addCollectionUpdate(FireGento_GridControl_Model_Config::TYPE_JOIN_FIELD, $blockId, (string) $attribute);
                     continue;
                 } else {
                     if ($attribute->getName() == 'join') {
                         $config->addCollectionUpdate(FireGento_GridControl_Model_Config::TYPE_JOIN, $blockId, array('table' => (string) $attribute['table'], 'condition' => (string) $attribute['condition'], 'field' => (string) $attribute['field'], 'column' => $params->getColumn()->getName()));
                         continue;
                     } else {
                         if ($attribute->getName() == 'options') {
                             if (strpos((string) $attribute, '::') !== false) {
                                 list($_module, $_method) = explode('::', (string) $attribute);
                                 $_module = Mage::getSingleton($_module);
                                 $_call = array($_module, $_method);
                                 if (is_callable($_call)) {
                                     $columnConfig['options'] = call_user_func($_call);
                                     continue;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if (count($attribute->children())) {
             // in case of arrays as attribute values
             $optionArray = array();
             foreach ($attribute->children() as $option) {
                 $optionArray[(string) $option->key] = (string) $option->value;
             }
             $columnConfig[$attribute->getName()] = $optionArray;
         } else {
             // standard string attribute
             $columnConfig[$attribute->getName()] = (string) $attribute;
         }
     }
     if (isset($columnConfig['header'])) {
         $columnConfig['header'] = $params->getBlock()->__($columnConfig['header']);
     }
     // add column to grid block
     $params->getBlock()->addColumn($params->getColumn()->getName(), $columnConfig);
 }
 public function render(Varien_Object $row)
 {
     if ($row->getAction()) {
         return;
     }
     $productId = $row->getParentId() ? $row->getParentId() : $row->getEntityId();
     $stockHistoryUrl = $this->getUrl('inventoryreportsadmin/adminhtml_product/chart', array('id' => $productId));
     $html = "<a href='' onclick='window.open( " . "\"" . $stockHistoryUrl . "\"" . "," . "\"" . $this->__('Stock History') . "\"" . "," . "\"" . 'scrollbars=yes, resizable=yes, width=520, height=540, top=50, left=300' . "\"" . "); " . "return false;' target='_blank'>" . $this->__('Stock History') . '</a>';
     return $html;
 }
Example #3
0
 public function render(Varien_Object $row)
 {
     //get row order ids
     if ($row->getAction()) {
         return;
     }
     $movementIds = $row->getAllMovementId();
     $filter = 'movementids=' . $movementIds;
     $filter = base64_encode($filter);
     $productUrl = Mage::helper("adminhtml")->getUrl('adminhtml/inr_product/details', array('top_filter' => $filter, "_secure" => Mage::app()->getStore()->isCurrentlySecure()));
     $html = "<a href='' onclick='window.open( " . "\"" . $productUrl . "\"" . "," . "\"" . $this->__('Order List') . "\"" . "," . "\"" . 'scrollbars=yes, resizable=yes, width=1000, height=600, top=50, left=300' . "\"" . "); return false;' target='_blank'>" . $this->__('Show Product List') . "</a>";
     return $html;
 }
 public function render(Varien_Object $row)
 {
     //get row order ids
     if ($row->getAction()) {
         return;
     }
     $orderIds = $row->getAllOrderId();
     $filter .= 'orderids=' . $orderIds;
     $filter = base64_encode($filter);
     $orderUrl = Mage::helper("adminhtml")->getUrl('inventoryreportsadmin/adminhtml_sales/orders', array('top_filter' => $filter, "_secure" => Mage::app()->getStore()->isCurrentlySecure()));
     $html .= "<a href='' onclick='window.open( " . "\"" . $orderUrl . "\"" . "," . "\"" . $this->__('_blank') . "\"" . "," . "\"" . 'scrollbars=yes, resizable=yes, width=1000, height=600, top=50, left=300' . "\"" . "); return false;' target='_blank'>" . $this->__('View Orders List') . "</a>";
     return $html;
 }
Example #5
0
 public function render(Varien_Object $row)
 {
     //get row order ids
     if ($row->getAction()) {
         return;
     }
     $orderIds = $row->getAllOrderId();
     $filter = 'orderids=' . $orderIds;
     $filter = base64_encode($filter);
     $orderUrl = Mage::helper("adminhtml")->getUrl('adminhtml/inr_sales/orders', array('top_filter' => $filter, "_secure" => Mage::app()->getStore()->isCurrentlySecure()));
     $html = "<a href='' onclick='window.open( " . "\"" . $orderUrl . "\"" . "," . "\"" . $this->__('_blank') . "\"" . "," . "\"" . 'scrollbars=yes, resizable=yes, width=1000, height=600, top=50, left=300' . "\"" . "); return false;' target='_blank'>" . $this->__('View Orders List') . "</a>";
     if ($this->getColumn()->getGrid()->isSalesSKUReport()) {
         $productId = $row->getProductId();
         $stockHistoryUrl = $this->getUrl('adminhtml/inr_product/chart', array('id' => $productId));
         $html = "<a href='' onclick='window.open( " . "\"" . $stockHistoryUrl . "\"" . "," . "\"" . $this->__('Stock History') . "\"" . "," . "\"" . 'scrollbars=yes, resizable=yes, width=520, height=540, top=50, left=300' . "\"" . "); " . "return false;' target='_blank'>" . $this->__('Stock History') . '</a> <br/>' . $html;
     }
     return $html;
 }
 public function render(Varien_Object $row)
 {
     if ($row->getAction()) {
         return;
     }
     //get row order ids
     $purchaseorderIds = $row->getAllPurchaseOrderId();
     $filter .= 'purchaseorderids=' . $purchaseorderIds;
     $filter = base64_encode($filter);
     $orderUrl = Mage::helper("adminhtml")->getUrl('inventoryreportsadmin/adminhtml_inventoryreports/purchaseorder', array('top_filter' => $filter, '_secure' => Mage::app()->getStore()->isCurrentlySecure()));
     $html .= "<a href='' onclick='window.open( " . "\"" . $orderUrl . "\"" . "," . "\"" . $this->__('Order List') . "\"" . "," . "\"" . 'scrollbars=yes, resizable=yes, width=1000, height=600, top=50, left=300' . "\"" . "); " . "return false;' target='_blank'>" . $this->__('View Orders List') . "</a>";
     //show only in report by sku
     if ($this->getColumn()->getGrid()->isPOSKUReport()) {
         $productId = $row->getParentId() ? $row->getParentId() : $row->getProductId();
         $stockHistoryUrl = $this->getUrl('inventoryreportsadmin/adminhtml_product/chart', array('id' => $productId));
         $html = "<a href='' onclick='window.open( " . "\"" . $stockHistoryUrl . "\"" . "," . "\"" . $this->__('Stock History') . "\"" . "," . "\"" . 'scrollbars=yes, resizable=yes, width=520, height=540, top=50, left=300' . "\"" . "); " . "return false;' target='_blank'>" . $this->__('Stock History') . '</a> <br/>' . $html;
     }
     return $html;
 }
Example #7
0
 /**
  * Parse xml response and return result
  *
  * @param string $response
  * @return Mage_Shipping_Model_Rate_Result|Varien_Object
  */
 protected function _parseXmlResponse($response)
 {
     $r = $this->_rawRequest;
     $costArr = array();
     $priceArr = array();
     $errorTitle = 'Unable to retrieve quotes';
     $tr = get_html_translation_table(HTML_ENTITIES);
     unset($tr['<'], $tr['>'], $tr['"']);
     $response = str_replace(array_keys($tr), array_values($tr), $response);
     if (strlen(trim($response)) > 0) {
         if (strpos(trim($response), '<?xml') === 0) {
             $xml = simplexml_load_string($response);
             if (is_object($xml)) {
                 if (is_object($xml->Faults) && is_object($xml->Faults->Fault) && is_object($xml->Faults->Fault->Code) && is_object($xml->Faults->Fault->Description) && is_object($xml->Faults->Fault->Context)) {
                     $code = (string) $xml->Faults->Fault->Code;
                     $description = $xml->Faults->Fault->Description;
                     $context = $xml->Faults->Fault->Context;
                     $this->_errors[$code] = Mage::helper('usa')->__('Error #%s : %s (%s)', $code, $description, $context);
                 } else {
                     if ($r->getDestCountryId() == self::USA_COUNTRY_ID) {
                         if ($xml->Shipment) {
                             foreach ($xml->Shipment as $shipXml) {
                                 $this->_parseXmlObject($shipXml);
                             }
                         } else {
                             $this->_errors[] = Mage::helper('usa')->__('Shipment is not available.');
                         }
                     } else {
                         $shipXml = $xml->IntlShipment;
                         $this->_parseXmlObject($shipXml);
                     }
                     $shipXml = $r->getDestCountryId() == self::USA_COUNTRY_ID ? $xml->Shipment : $xml->IntlShipment;
                 }
             }
         } else {
             $this->_errors[] = Mage::helper('usa')->__('The response is in wrong format.');
         }
     }
     if ($this->_rawRequest->getAction() == 'GenerateLabel') {
         $result = new Varien_Object();
         if (!empty($this->_errors)) {
             $result->setErrors(implode($this->_errors, '; '));
         } else {
             if ($xml !== false) {
                 if ($r->getDestCountryId() == self::USA_COUNTRY_ID) {
                     $shippingLabelContent = base64_decode((string) $xml->Shipment->Label->Image);
                     $trackingNumber = (string) $xml->Shipment->ShipmentDetail->AirbillNbr;
                 } else {
                     $shippingLabelContent = base64_decode((string) $xml->IntlShipment->Label->Image);
                     $trackingNumber = (string) $xml->IntlShipment->ShipmentDetail->AirbillNbr;
                 }
             }
             $result->setShippingLabelContent($shippingLabelContent);
             $result->setTrackingNumber($trackingNumber);
         }
         return $result;
     } else {
         $result = Mage::getModel('shipping/rate_result');
         if ($this->_dhlRates) {
             foreach ($this->_dhlRates as $rate) {
                 $method = $rate['service'];
                 $data = $rate['data'];
                 $rate = Mage::getModel('shipping/rate_result_method');
                 $rate->setCarrier('dhl');
                 $rate->setCarrierTitle($this->getConfigData('title'));
                 $rate->setMethod($method);
                 $rate->setMethodTitle($data['term']);
                 $rate->setCost($data['price_total']);
                 $rate->setPrice($data['price_total']);
                 $result->append($rate);
             }
         } else {
             if (!empty($this->_errors)) {
                 $error = Mage::getModel('shipping/rate_result_error');
                 $error->setCarrier('dhl');
                 $error->setCarrierTitle($this->getConfigData('title'));
                 $error->setErrorMessage($this->getConfigData('specificerrmsg'));
                 $result->append($error);
             }
         }
         return $result;
     }
 }
Example #8
0
 public function getPostUrl(Varien_Object $dialog)
 {
     $url = $this->getUrl(str_replace('*', 'post', $dialog->getAction()));
     return $this->_commonHelper()->getCore()->urlEncode($url);
 }