/**
  * Surcharge la méthode after save pour mettre a jour les stocks
  *
  * @return Mage_Core_Model_Abstract
  */
 protected function _afterSave()
 {
     try {
         //appel le parent
         parent::_afterSave();
         //Define if shipment just created
         $creation = $this->getentity_id() != $this->getOrigData('entity_id');
         if ($creation) {
             //Create stock movements
             $order = $this->getOrder();
             foreach ($this->getAllItems() as $item) {
                 //retrieve informaiton
                 $qty = $this->getRealShippedQtyForItem($item);
                 try {
                     $StockMovement = mage::getmodel('Purchase/StockMovement')->setsm_product_id($item->getproduct_id())->setsm_type('order')->setsm_coef(-1)->setsm_qty($qty)->setsm_date(date('Y-m-d'))->setsm_ui($item->getId())->setsm_description(mage::helper('purchase')->__('Order #') . $this->getOrder()->getincrement_id())->save();
                 } catch (Exception $ex) {
                     //nothing, db constraint exception because stock movement already exists
                 }
                 //reset reserved qty
                 $orderItem = $item->getOrderItem();
                 $orderItem->setreserved_qty(0)->save();
             }
             //update order planning
             $orderId = $this->getOrder()->getId();
             mage::helper('BackgroundTask')->AddTask('Update planning for order ' . $orderId, 'purchase/Planning', 'updatePlanning', $orderId);
             //Met a jour les qte commandées pour le produit
             $order->UpdateProductsOrdererQty;
         }
     } catch (Exception $ex) {
         mage::log($ex->getMessage());
     }
     return $this;
 }
Example #2
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);
     }
 }
 /**
  * Return rewrite class info
  *
  * @return unknown
  */
 public function getRewriteClassesInformation()
 {
     if ($this->_rewriteClassesInformation == null) {
         $this->_rewriteClassesInformation = array();
         $t = explode(',', $this->getec_rewrite_classes());
         foreach ($t as $class) {
             //collect main information
             $class = trim($class);
             $classArray = array();
             $classArray['class'] = $class;
             $classInfo = explode('_', $class);
             $classArray['editor'] = trim($classInfo[0]);
             $classArray['module'] = trim($classInfo[1]);
             //collect config.xml file path
             $classArray['config_file_path'] = mage::helper('ExtensionConflict/Extension')->getConfigFilePath($classArray['editor'], $classArray['module']);
             //collect class path
             $classArray['class_path'] = mage::helper('ExtensionConflict/Extension')->getClassPath($class);
             //collect class declaration
             $classArray['class_declaration'] = mage::helper('ExtensionConflict/Extension')->getClassDeclaration($class);
             //collect new class declaration
             $classArray['new_class_declaration'] = 'class ' . $class . ' extends ';
             $this->_rewriteClassesInformation[] = $classArray;
         }
     }
     return $this->_rewriteClassesInformation;
 }
Example #4
0
 protected function _prepareForm()
 {
     $form = new Varien_Data_Form();
     $this->setForm($form);
     $fieldset = $form->addFieldset('abrands_form', array('legend' => Mage::helper('abrands')->__('Item information')));
     $attribute = Mage::getModel('eav/entity_attribute')->getCollection()->addFieldToFilter('attribute_code', Mage::getStoreConfig('mpanel/catalog/brands'));
     $code = array();
     foreach ($attribute as $item) {
         $code[$item->getAttributeCode()] = $item->getFrontendLabel();
     }
     $fieldset->addfield('name_attr', 'select', array('label' => mage::helper('abrands')->__('Attribute'), 'name' => 'name_attr', 'values' => $code, 'onchange' => 'showOptions()'));
     $fieldset->addfield('option_id', 'select', array('label' => mage::helper('abrands')->__('Option'), 'name' => 'option_id', 'values' => '', 'onchange' => 'getOptionText()'));
     $fieldset->addfield('title', 'hidden', array('name' => 'title'));
     $fieldset->addField('filename', 'file', array('label' => Mage::helper('abrands')->__('File'), 'required' => false, 'name' => 'filename'));
     $fieldset->addField('content', 'text', array('name' => 'content', 'label' => Mage::helper('abrands')->__('Link'), 'title' => Mage::helper('abrands')->__('Link'), 'required' => false));
     $fieldset->addField('status', 'select', array('label' => Mage::helper('abrands')->__('Status'), 'name' => 'status', 'values' => array(array('value' => 1, 'label' => Mage::helper('abrands')->__('Enabled')), array('value' => 2, 'label' => Mage::helper('abrands')->__('Disabled')))));
     /*  $fieldset->addField('content', 'editor', array(
             'name'      => 'content',
             'label'     => Mage::helper('abrands')->__('Content'),
             'title'     => Mage::helper('abrands')->__('Content'),
             'style'     => 'width:700px; height:500px;',
             'wysiwyg'   => false,
             'required'  => true,
         )); */
     if (Mage::getSingleton('adminhtml/session')->getAbrandsData()) {
         $form->setValues(Mage::getSingleton('adminhtml/session')->getAbrandsData());
         Mage::getSingleton('adminhtml/session')->setAbrandsData(null);
     } elseif (Mage::registry('abrands_data')) {
         $form->setValues(Mage::registry('abrands_data')->getData());
     }
     return parent::_prepareForm();
 }
 public function render(Varien_Object $row)
 {
     //get planning
     $planning = $row->getPlanning();
     //if no planning found, try to load it from order id
     if ($planning == null) {
         $orderId = $row->getopp_order_id();
         $planning = mage::getModel('Purchase/SalesOrderPlanning')->load($orderId, 'psop_order_id');
     }
     if ($planning) {
         $html = '<div class="nowrap" style="text-align: left;">';
         if ($planning->getFullstockDate() != '') {
             $html .= mage::helper('purchase')->__('Prepare') . ' : <font color="' . $this->getColorForDate($planning->getFullstockDate()) . '">' . mage::helper('core')->formatDate($planning->getFullstockDate(), 'short') . '</font>';
         }
         if ($planning->getShippingDate() != '') {
             $html .= '<br>' . mage::helper('purchase')->__('Ship') . ' : <font color="' . $this->getColorForDate($planning->getShippingDate()) . '">' . mage::helper('core')->formatDate($planning->getShippingDate(), 'short') . '</font>';
         }
         if ($planning->getDeliveryDate() != '') {
             $html .= '<br>' . mage::helper('purchase')->__('Delivery') . ' <font color="' . $this->getColorForDate($planning->getDeliveryDate()) . '">: ' . mage::helper('core')->formatDate($planning->getDeliveryDate(), 'short') . '</font>';
         }
         $html .= '</div>';
     } else {
         $html = $this->__('No planning');
     }
     return $html;
 }
 /**
  * Retourne les taches pour une entité
  *
  * @param unknown_type $EntityType
  * @param unknown_type $EntityId
  */
 public function getTasksForEntity($EntityType, $EntityId, $Mode)
 {
     //Rajoute les filtres
     if ($EntityId != null) {
         $this->getSelect()->where('ot_entity_id=?', $EntityId);
     }
     if ($EntityType != null) {
         $this->getSelect()->where('ot_entity_type=?', $EntityType);
     }
     //ajoute les relations pour afficher le nom des utilisateurs (author & target)
     $this->getSelect()->join(array('user_author' => $this->getTable('admin/user')), '`user_author`.user_id=`main_table`.ot_author_user', array('user_author.username' => 'username'));
     $this->getSelect()->joinLeft(array('user_target' => $this->getTable('admin/user')), '`user_target`.user_id=`main_table`.ot_target_user', array('user_target.username' => 'username'));
     $this->getSelect()->joinLeft(array('tbl_category' => $this->getTable('Organizer/TaskCategory')), '`tbl_category`.otc_id=`main_table`.ot_category', array('tbl_category.otc_name' => 'otc_name'));
     switch ($Mode) {
         case 'late':
             $this->getSelect()->where('ot_finished=?', 0);
             $this->getSelect()->where('ot_deadline<=?', date('Y-m-d'));
             $this->getSelect()->where('ot_target_user is NULL or ot_target_user=?', mage::helper('Organizer')->getCurrentUserId());
             break;
         case 'notification':
             $this->getSelect()->where('ot_notification_read=?', 0);
             $this->getSelect()->where('ot_notify_date<=?', date('Y-m-d'));
             $this->getSelect()->where('ot_target_user is NULL or ot_target_user=?', mage::helper('Organizer')->getCurrentUserId());
             break;
         case 'mine':
             $this->getSelect()->where('ot_target_user='******'Organizer')->getCurrentUserId() . ' or ot_author_user='******'Organizer')->getCurrentUserId());
             break;
     }
     return $this;
 }
 /**
  * delete an action
  *
  */
 public function deleteFileAction()
 {
     $this->checkPassword();
     $fileName = $this->getRequest()->getParam('filename');
     $filepath = mage::helper('ClientComputer')->getExchangeDirectory() . $fileName;
     unlink($filepath);
 }
Example #8
0
 /**
  * Method called each time an object is saved (and changed :)
  *
  */
 public function model_save_after(Varien_Event_Observer $observer)
 {
     //check if enabled
     if (!Mage::getStoreConfig('barcodelabel/general/enable')) {
         return false;
     }
     $object = $observer->getEvent()->getObject();
     $objectType = mage::helper('BarcodeLabel')->getObjectType($object);
     // detect if the module saved is a product
     if ($objectType == "catalog/product") {
         if ($object->getId() != $object->getOrigData('entity_id')) {
             // check if barcode is already done, if not error message are showing
             $barcodeAttributeName = Mage::helper('BarcodeLabel')->getBarcodeAttribute();
             if (strlen($barcodeAttributeName) == 0) {
                 throw new Exception('Barcode attribute not set, create an attribute an save it : in system > configuration > barcodelabel');
             }
             $barcode = $object->getData($barcodeAttributeName);
             if (empty($barcode)) {
                 // generate barcode
                 Mage::helper('BarcodeLabel/Generation')->storeBarcode($object->getId());
             }
         } else {
             // check if barcode is already done, if not error message are showing
             $barcodeAttributeName = Mage::helper('BarcodeLabel')->getBarcodeAttribute();
             if (strlen($barcodeAttributeName) == 0) {
                 throw new Exception('Barcode attribute not set, create an attribute an save it : in system > configuration > barcodelabel');
             }
             $barcode = $object->getData($barcodeAttributeName);
             if (empty($barcode)) {
                 // generate barcode
                 Mage::helper('BarcodeLabel/Generation')->storeBarcode($object->getId());
             }
         }
     }
 }
 public function render(Varien_Object $row)
 {
     $ProductId = $row->getId();
     $url = $this->getUrl('Purchase/Orders/AddProductToOrder', array('ProductId' => $ProductId, 'OrderId' => $this->getColumn()->getpo_num()));
     $html = '<a href="' . $url . '">' . mage::helper('purchase')->__('Add') . '</a>';
     return $html;
 }
 /**
  * Update carriers
  *
  */
 public function UpdateCarriersAction()
 {
     mage::helper('purchase/ShippingDelay')->updateCarriers();
     //confirme
     Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Carriers list updated'));
     //Redirige vers la fiche créée
     $this->_redirect('Purchase/ShippingDelay/List');
 }
Example #11
0
 /**
  * Return planning object
  *
  * @return unknown
  */
 public function getPlanning()
 {
     if ($this->_planning == null) {
         $quote = $this->getQuote();
         $this->_planning = mage::helper('purchase/Planning')->getEstimationForQuote($quote);
     }
     return $this->_planning;
 }
Example #12
0
 public function getTask()
 {
     if ($this->_task == null) {
         $this->_task = Mage::getModel('Organizer/Task');
         $this->_task->setot_author_user(mage::helper('Organizer')->getCurrentUserId());
         $this->_task->setot_entity_type($this->getEntityType());
         $this->_task->setot_entity_id($this->getEntityId());
         $this->_task->setot_entity_description(mage::helper('Organizer')->getEntityDescription($this->getEntityType(), $this->getEntityId()));
     }
     return $this->_task;
 }
 /**
  * Retourne les commentaires pour toues les commandes sélectionnées
  *
  */
 public function getAllComments()
 {
     $retour = '';
     $collection = Mage::getSingleton('Orderpreparation/ordertoprepare')->getFullStockOrdersFromCache();
     foreach ($collection as $item) {
         $comments = mage::helper('Organizer')->getEntityCommentsSummary('order', $item->getopp_order_id(), true);
         if ($comments != '') {
             $retour .= '<a href="' . $this->getUrl('adminhtml/sales_order/view', array('order_id' => $item->getopp_order_id())) . '"><b>Order #' . $item->getopp_order_increment_id() . '</b></a> : ' . $comments;
         }
     }
     return $retour;
 }
 /**
  * Dispatch order and update planning
  *
  */
 protected function _afterSave()
 {
     parent::_afterSave();
     $order = $this->getOrder();
     //plan update for ordered and reserved qty for products
     foreach ($this->getAllItems() as $item) {
         $productId = $item->getProductId();
         mage::helper('BackgroundTask')->AddTask('Update stock for product ' . $productId . ' (from credit memo aftersave)', 'purchase', 'UpdateProductStock', $productId);
     }
     //dispatch order in order preparation tabs
     mage::helper('BackgroundTask')->AddTask('Dispatch order #' . $order->getId(), 'Orderpreparation', 'dispatchOrder', $order->getId());
 }
 public function DeleteVirtualModuleAction()
 {
     //delete file
     $filePath = Mage::app()->getConfig()->getTempVarDir() . '/ExtensionConflict/VirtualNamespace/VirtualModule/etc/config.xml';
     if (file_exists($filePath)) {
         unlink($filePath);
     }
     //refresh list
     mage::helper('ExtensionConflict')->RefreshList();
     //redirect
     Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Virtual Module deleted and List refreshed'));
     $this->_redirect('ExtensionConflict/Admin/List');
 }
Example #16
0
 /**
  * when saving, update supply needs for product (if concerned)
  *
  */
 protected function _afterSave()
 {
     parent::_afterSave();
     //If reserved qty change, update order planning
     $reservedQtyChanged = $this->getreserved_qty() != $this->getOrigData('reserved_qty');
     $qtyToShip = $this->getqty_ordered() - $this->getRealShippedQty() - $this->getqty_canceled() - $this->getqty_refunded();
     if ($reservedQtyChanged && $qtyToShip > 0) {
         //add a task to update order planning
         $orderId = $this->getorder_id();
         mage::helper('BackgroundTask')->AddTask('Update planning for order ' . $orderId, 'purchase/Planning', 'updatePlanning', $orderId);
     }
     return $this;
 }
 /**
  * Release product
  *
  */
 public function ReleaseAction()
 {
     $productId = $this->getRequest()->getParam('product_id');
     $orderId = $this->getRequest()->getParam('order_id');
     $product = mage::getModel('catalog/product')->load($productId);
     mage::helper('purchase/ProductReservation')->releaseProductForOrder($orderId, $productId);
     //redirect
     Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Product released'));
     if ($this->getRequest()->getParam('return_to_order') == '') {
         $this->_redirect('Purchase/Products/Edit', array('product_id' => $productId, 'tab' => 'pending_orders'));
     } else {
         $this->_redirect('adminhtml/sales_order/view', array('order_id' => $orderId));
     }
 }
 /**
  * Dessine l'entete du tableau avec la liste des produits
  *
  * @param unknown_type $page
  */
 public function drawTableHeader(&$page)
 {
     //entetes de colonnes
     $this->y -= 15;
     $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12);
     $page->drawText(mage::helper('purchase')->__('Qty'), 15, $this->y, 'UTF-8');
     $page->drawText(mage::helper('purchase')->__('Manufacturer'), 70, $this->y, 'UTF-8');
     $page->drawText(mage::helper('purchase')->__('Sku'), 180, $this->y, 'UTF-8');
     $page->drawText(mage::helper('purchase')->__('Product'), 310, $this->y, 'UTF-8');
     //barre grise fin entete colonnes
     $this->y -= 8;
     $page->drawLine(10, $this->y, $this->_BLOC_ENTETE_LARGEUR, $this->y);
     $this->y -= 15;
 }
 public function render(Varien_Object $row)
 {
     $entity = $this->getColumn()->getentity();
     $entity_id = $row->getId();
     if ($this->getColumn()->getentity_id_field() != '') {
         $entity_id = $row->getData($this->getColumn()->getentity_id_field());
     }
     $content = mage::helper('Organizer')->getEntityCommentsSummary($entity, $entity_id, true);
     $html = '';
     if ($content != '') {
         $html = '<a href="#" class="lien-popup"><img src="' . $this->getSkinUrl('images/Organizer/comments.gif') . '"><span>' . $content . '</span></a>';
     }
     return $html;
 }
 public function getAllOptions()
 {
     if (!$this->_options) {
         $config = Mage::getStoreConfig('carriers');
         foreach ($config as $code => $methodConfig) {
             if (Mage::getStoreConfigFlag('carriers/' . $code . '/active')) {
                 $this->_options[] = array('value' => $code, 'label' => !empty($methodConfig['title']) ? $methodConfig['title'] : 'empty');
             }
         }
         //Ajoute un elt vide
         $this->_options[] = array('value' => '', 'label' => mage::helper('purchase')->__('none'));
     }
     return $this->_options;
 }
Example #21
0
 public function getImportContentAsCombo($name, $currentValue)
 {
     $formats = mage::helper('Orderpreparation/FieldFormat')->getImportContents();
     $retour = '<select name="' . $name . '" id="' . $name . '">';
     $retour .= '<option value=""></option>';
     foreach ($formats as $key => $value) {
         $selected = '';
         if ($key == $currentValue) {
             $selected = ' selected ';
         }
         $retour .= '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>';
     }
     $retour .= '</select>';
     return $retour;
 }
 /**
  * Save datas
  *
  */
 public function SaveAction()
 {
     //retrieve and remove items
     $config = $this->getRequest()->getPost('config');
     $targetConfig = array();
     for ($i = 0; $i < count($config); $i++) {
         if (!isset($config[$i]['delete'])) {
             $targetConfig[] = $config[$i];
         }
     }
     //save
     mage::helper('purchase/ProductAvailability')->saveConfig($targetConfig);
     //Confirm & redirect
     Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Data saved'));
     $this->_redirect('Purchase/ProductAvailability/List');
 }
Example #23
0
 /**
  * Clear the carousel cache daily.
  * This will allow the carousels to rebuild taking into account any changes on scheduled items in the carousel.
  * The next time it is viewed, a carousel will load the latest (in scheduled) items for display
  */
 public static function clearCache()
 {
     try {
         // use global tag, whuch will clear all carousels
         $tag = array(Doghouse_Carousel_Block_Carousel::CACHE_GROUP);
         mage::helper('dhcarousel')->clearCache($tag);
         // pageCache only listens to adminhtml requests to clear, so force it to clear
         if (Mage::app()->useCache('full_page')) {
             $fpc = mage::getModel('enterprise_pagecache/observer');
             if (is_object($fpc)) {
                 $fpc->cleanCache();
             }
         }
     } catch (Exception $e) {
         mage::logException($e);
     }
 }
 /**
  * rafraichit le cache pour les supply needs
  *
  */
 public function RefreshListAction()
 {
     //create backgroundtask group
     $taskGroup = 'refresh_suppy_needs';
     mage::helper('BackgroundTask')->AddGroup($taskGroup, mage::helper('purchase')->__('Refresh Supply Needs'), 'Purchase/SupplyNeeds/Grid');
     //empty table
     Mage::getResourceModel('Purchase/SupplyNeeds')->TruncateTable();
     //collect product ids
     $ids = mage::getModel('Purchase/SupplyNeeds')->getCandidateProductIds();
     for ($i = 0; $i < count($ids); $i++) {
         //add tasks to group
         $productId = $ids[$i]['product_id'];
         mage::helper('BackgroundTask')->AddTask('Update supply needs for product #' . $productId, 'purchase', 'updateSupplyNeedsForProduct', $productId, $taskGroup);
     }
     //execute task group
     mage::helper('BackgroundTask')->ExecuteTaskGroup($taskGroup);
 }
Example #25
0
 /**
  * Talk to pin gateway
  * 
  * @param array $data
  * @param string $endPoint
  * @return object
  */
 protected function talkToGateway($data, $endPoint, $proto = Zend_Http_Client::POST)
 {
     $url = mage::helper('pinpayments')->getGatewayUrl() . '1/' . $endPoint;
     $secretKey = mage::getStoreConfig('payment/pinpayments/secret_api_key');
     if ($proto == Zend_Http_Client::PUT) {
         $result = exec("curl {$url} -u {$secretKey}: -X PUT -d email={$data['email']} -d card_token={$data['card_token']}", $output, $return_var);
     } else {
         $curl = new ProxiBlue_PinPayments_Varien_Http_Adapter_Curl();
         $curl->setConfig(array('timeout' => 15));
         $curl->setConfig(array('userpwd' => mage::getStoreConfig('payment/pinpayments/secret_api_key') . ":"));
         $curl->write($proto, $url, '1.1', null, $data);
         $curlData = $curl->read();
         $result = Zend_Http_Response::extractBody($curlData);
         $curl->close();
         $result = json_decode($result);
     }
     return $result;
 }
Example #26
0
 /**
  * Execute task
  *
  */
 public function execute()
 {
     $error = false;
     $status = 'success';
     try {
         //Collect helper
         $helper = mage::helper($this->getbt_helper());
         $params = unserialize($this->getbt_params());
         $helper->{$this->getbt_method()}($params);
     } catch (Exception $ex) {
         $error = $ex->getMessage();
         $error .= $ex->getTraceAsString();
         $status = 'error';
     }
     //Save execution information
     $this->setbt_executed_at(date('Y-m-d H:i'))->setbt_result_description($error)->setbt_result($status)->save();
     return $this;
 }
 /**
  * Return label matching to delay & store
  *
  * @param unknown_type $storeId
  * @param unknown_type $days
  */
 public function getLabel($storeCode, $days)
 {
     //default value
     $retour = mage::helper('purchase')->__('Average supply delay : %s days', $days);
     //parse config
     $config = $this->getConfig();
     if (is_array($config)) {
         for ($i = 0; $i < count($config); $i++) {
             if ($days >= $config[$i]['from'] && $days <= $config[$i]['to']) {
                 $retour = mage::helper('purchase')->__('Average supply delay : ') . $config[$i]['label'];
                 //check for store values
                 if (isset($config[$i][$storeCode])) {
                     if ($config[$i][$storeCode] != '') {
                         $retour = mage::helper('purchase')->__('Average supply delay : ') . $config[$i][$storeCode];
                     }
                 }
             }
         }
     }
     return $retour;
 }
 public function render(Varien_Object $row)
 {
     $html = '';
     //retrieve information
     $productId = $this->getColumn()->getproduct_id();
     $collection = mage::getModel('sales/order_item')->getCollection()->addFieldToFilter('order_id', $row->getId())->addFieldToFilter('product_id', $productId);
     $orderItemRow = null;
     foreach ($collection as $item) {
         $orderItemRow = $item;
     }
     if ($orderItemRow != null) {
         $remainingQty = $orderItemRow->getRemainToShipQty();
         $reserveUrl = Mage::helper('adminhtml')->getUrl('Purchase/ProductReservation/Reserve', array('product_id' => $productId, 'order_id' => $row->getId()));
         $releaseUrl = Mage::helper('adminhtml')->getUrl('Purchase/ProductReservation/Release', array('product_id' => $productId, 'order_id' => $row->getId()));
         if ($orderItemRow->getreserved_qty() == 0 && $remainingQty > 0) {
             $html .= '<a href="' . $reserveUrl . '">' . mage::helper('purchase')->__('Reserve') . '</a><br>';
         }
         if ($orderItemRow->getreserved_qty() > 0) {
             $html .= '<a href="' . $releaseUrl . '">' . mage::helper('purchase')->__('Release') . '</a>';
         }
     }
     return $html;
 }
 public function getPdf($orders = array())
 {
     $this->_beforeGetPdf();
     $this->_initRenderer('invoice');
     //on cree le pdf que si il n'est pas déja défini( ca permet de mettre plrs documents dans le mm pdf (genre une facture, un BL ....)
     $this->pdf = new Zend_Pdf();
     $style = new Zend_Pdf_Style();
     $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 10);
     //cree la nouvelle page
     $titre = mage::helper('purchase')->__('Order Comments');
     $settings = array();
     $settings['title'] = $titre;
     $settings['store_id'] = 0;
     $page = $this->NewPage($settings);
     $this->y -= $this->_ITEM_HEIGHT * 2;
     $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.2));
     $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 10);
     //Rajoute les commandes avec commentaires
     foreach ($orders as $order) {
         $comments = mage::helper('Organizer')->getEntityCommentsSummary('order', $order->getorder_id(), false);
         if ($comments != '') {
             $realOrder = mage::getModel('sales/order')->load($order->getorder_id());
             $page->drawText(mage::helper('purchase')->__('Order # ') . $realOrder->getIncrementId(), 15, $this->y, 'UTF-8');
             $comments = $this->WrapTextToWidth($page, $comments, 450);
             $offset = $this->DrawMultilineText($page, $comments, 150, $this->y, 10, 0.2, 11);
             $this->y -= 8 + $offset;
             $page->drawLine(10, $this->y, $this->_BLOC_ENTETE_LARGEUR, $this->y);
             $this->y -= 15;
         }
     }
     //dessine le pied de page
     $this->drawFooter($page);
     //rajoute la pagination
     $this->AddPagination($this->pdf);
     $this->_afterGetPdf();
     return $this->pdf;
 }
Example #30
0
 public function getPagerUrl()
 {
     $cur_url = mage::helper('core/url')->getCurrentUrl();
     $new_url = preg_replace('/\\&p=.*/', '', $cur_url);
     $url = strtok($new_url, '?');
     return $url;
 }