コード例 #1
0
 public function execute()
 {
     $startDate = $this->getHelper('M2ePro')->getCurrentGmtDate();
     $synchConfig = $this->modelFactory->getObject('Config\\Manager\\Synchronization');
     $synchConfig->setGroupValue('/ebay/templates/revise/total/', 'start_date', $startDate);
     $synchConfig->setGroupValue('/ebay/templates/revise/total/', 'last_listing_product_id', 0);
     $this->setAjaxContent(json_encode(array('start_date' => $this->localeDate->formatDate($startDate, \IntlDateFormatter::MEDIUM))), false);
 }
コード例 #2
0
 /**
  * @param $dataTime
  *
  * @return string
  */
 protected function _getEstimatedDate($dataTime)
 {
     $current = new \Zend_Date();
     $current->setTime(0);
     $nextNotificationDate = $current->add($dataTime['shipping'], \Zend_Date::HOUR);
     return $this->_timezone->formatDate('@' . $nextNotificationDate->getTimestamp());
 }
コード例 #3
0
 /**
  * Get RSS feed items
  *
  * @return array
  */
 protected function getEntries()
 {
     /** @var $resourceModel \Magento\Sales\Model\Resource\Order\Rss\OrderStatus */
     $resourceModel = $this->orderResourceFactory->create();
     $results = $resourceModel->getAllCommentCollection($this->order->getId());
     $entries = [];
     if ($results) {
         foreach ($results as $result) {
             $urlAppend = 'view';
             $type = $result['entity_type_code'];
             if ($type && $type != 'order') {
                 $urlAppend = $type;
             }
             $type = __(ucwords($type));
             $title = __('Details for %1 #%2', $type, $result['increment_id']);
             $description = '<p>' . __('Notified Date: %1', $this->localeDate->formatDate($result['created_at'])) . '<br/>' . __('Comment: %1<br/>', $result['comment']) . '</p>';
             $url = $this->urlBuilder->getUrl('sales/order/' . $urlAppend, ['order_id' => $this->order->getId()]);
             $entries[] = ['title' => $title, 'link' => $url, 'description' => $description];
         }
     }
     $title = __('Order #%1 created at %2', $this->order->getIncrementId(), $this->localeDate->formatDate($this->order->getCreatedAt()));
     $url = $this->urlBuilder->getUrl('sales/order/view', ['order_id' => $this->order->getId()]);
     $description = '<p>' . __('Current Status: %1<br/>', $this->order->getStatusLabel()) . __('Total: %1<br/>', $this->order->formatPrice($this->order->getGrandTotal())) . '</p>';
     $entries[] = ['title' => $title, 'link' => $url, 'description' => $description];
     return ['entries' => $entries];
 }
コード例 #4
0
 /**
  * Add refresh statistics links
  *
  * @param string $flagCode
  * @param string $refreshCode
  * @return $this
  */
 protected function _showLastExecutionTime($flagCode, $refreshCode)
 {
     $flag = $this->_objectManager->create('Magento\\Reports\\Model\\Flag')->setReportFlagCode($flagCode)->loadSelf();
     $updatedAt = 'undefined';
     if ($flag->hasData()) {
         $updatedAt = $this->timezone->formatDate($flag->getLastUpdate(), \IntlDateFormatter::MEDIUM, true);
     }
     $refreshStatsLink = $this->getUrl('reports/report_statistics');
     $directRefreshLink = $this->getUrl('reports/report_statistics/refreshRecent', ['code' => $refreshCode]);
     $this->messageManager->addNotice(__('Last updated: %1. To refresh last day\'s <a href="%2">statistics</a>, ' . 'click <a href="%3">here</a>.', $updatedAt, $refreshStatsLink, $directRefreshLink));
     return $this;
 }
コード例 #5
0
 /**
  * @param \Magento\Framework\Event\Observer $observer
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $observerData = $observer->getData();
     $orderId = $observerData['orderId'];
     $shipmentData = $observerData['shipmentData'];
     $order = $this->coreModel->_getOrder($orderId);
     $method = $order->getShippingMethod();
     if ($this->shipmentHelper->isMercadoEnviosMethod($method)) {
         $methodId = $shipmentData['shipping_option']['shipping_method_id'];
         $name = $shipmentData['shipping_option']['name'];
         $order->setShippingMethod('mercadoenvios_' . $methodId);
         $estimatedDate = $this->_timezone->formatDate($shipmentData['shipping_option']['estimated_delivery']['date']);
         $estimatedDate = __('(estimated date %1)', $estimatedDate);
         $shippingDescription = 'MercadoEnvíos - ' . $name . ' ' . $estimatedDate;
         $order->setShippingDescription($shippingDescription);
         try {
             $order->save();
             $this->shipmentHelper->log('Order ' . $order->getIncrementId() . ' shipping data set ', $shipmentData);
         } catch (\Exception $e) {
             $this->shipmentHelper->log("error when update shipment data: " . $e);
             $this->shipmentHelper->log($e);
         }
     }
 }
コード例 #6
0
ファイル: NewOrder.php プロジェクト: whoople/magento2-testing
 /**
  * Get RSS feed items
  *
  * @return array
  */
 public function getRssData()
 {
     $passDate = $this->dateTime->formatDate(mktime(0, 0, 0, date('m'), date('d') - 7));
     $newUrl = $this->rssUrlBuilder->getUrl(['_secure' => true, '_nosecret' => true, 'type' => 'new_order']);
     $title = __('New Orders');
     $data = ['title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8'];
     /** @var $order \Magento\Sales\Model\Order */
     $order = $this->orderFactory->create();
     /** @var $collection \Magento\Sales\Model\ResourceModel\Order\Collection */
     $collection = $order->getResourceCollection();
     $collection->addAttributeToFilter('created_at', ['date' => true, 'from' => $passDate])->addAttributeToSort('created_at', 'desc');
     $this->eventManager->dispatch('rss_order_new_collection_select', ['collection' => $collection]);
     $detailBlock = $this->layout->getBlockSingleton('Magento\\Sales\\Block\\Adminhtml\\Order\\Details');
     foreach ($collection as $item) {
         $title = __('Order #%1 created at %2', $item->getIncrementId(), $this->localeDate->formatDate($item->getCreatedAt()));
         $url = $this->urlBuilder->getUrl('sales/order/view', ['_secure' => true, 'order_id' => $item->getId(), '_nosecret' => true]);
         $detailBlock->setOrder($item);
         $data['entries'][] = ['title' => $title, 'link' => $url, 'description' => $detailBlock->toHtml()];
     }
     return $data;
 }
コード例 #7
0
ファイル: Order.php プロジェクト: niranjanssiet/magento2
 /**
  * Get formated order created date in store timezone
  *
  * @param   string $format date format type (short|medium|long|full)
  * @return  string
  */
 public function getCreatedAtFormated($format)
 {
     return $this->timezone->formatDate($this->timezone->scopeDate($this->getStore(), $this->getCreatedAt(), true), $format, true);
 }
コード例 #8
0
ファイル: AbstractPdf.php プロジェクト: aiesh/magento2
 /**
  * Insert order to pdf page
  *
  * @param \Zend_Pdf_Page &$page
  * @param \Magento\Sales\Model\Order $obj
  * @param bool $putOrderId
  * @return void
  */
 protected function insertOrder(&$page, $obj, $putOrderId = true)
 {
     if ($obj instanceof \Magento\Sales\Model\Order) {
         $shipment = null;
         $order = $obj;
     } elseif ($obj instanceof \Magento\Sales\Model\Order\Shipment) {
         $shipment = $obj;
         $order = $shipment->getOrder();
     }
     $this->y = $this->y ? $this->y : 815;
     $top = $this->y;
     $page->setFillColor(new \Zend_Pdf_Color_GrayScale(0.45));
     $page->setLineColor(new \Zend_Pdf_Color_GrayScale(0.45));
     $page->drawRectangle(25, $top, 570, $top - 55);
     $page->setFillColor(new \Zend_Pdf_Color_GrayScale(1));
     $this->setDocHeaderCoordinates(array(25, $top, 570, $top - 55));
     $this->_setFontRegular($page, 10);
     if ($putOrderId) {
         $page->drawText(__('Order # ') . $order->getRealOrderId(), 35, $top -= 30, 'UTF-8');
     }
     $page->drawText(__('Order Date: ') . $this->_localeDate->formatDate($order->getCreatedAtStoreDate(), 'medium', false), 35, $top -= 15, 'UTF-8');
     $top -= 10;
     $page->setFillColor(new \Zend_Pdf_Color_Rgb(0.93, 0.92, 0.92));
     $page->setLineColor(new \Zend_Pdf_Color_GrayScale(0.5));
     $page->setLineWidth(0.5);
     $page->drawRectangle(25, $top, 275, $top - 25);
     $page->drawRectangle(275, $top, 570, $top - 25);
     /* Calculate blocks info */
     /* Billing Address */
     $billingAddress = $this->_formatAddress($order->getBillingAddress()->format('pdf'));
     /* Payment */
     $paymentInfo = $this->_paymentData->getInfoBlock($order->getPayment())->setIsSecureMode(true)->toPdf();
     $paymentInfo = htmlspecialchars_decode($paymentInfo, ENT_QUOTES);
     $payment = explode('{{pdf_row_separator}}', $paymentInfo);
     foreach ($payment as $key => $value) {
         if (strip_tags(trim($value)) == '') {
             unset($payment[$key]);
         }
     }
     reset($payment);
     /* Shipping Address and Method */
     if (!$order->getIsVirtual()) {
         /* Shipping Address */
         $shippingAddress = $this->_formatAddress($order->getShippingAddress()->format('pdf'));
         $shippingMethod = $order->getShippingDescription();
     }
     $page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
     $this->_setFontBold($page, 12);
     $page->drawText(__('Sold to:'), 35, $top - 15, 'UTF-8');
     if (!$order->getIsVirtual()) {
         $page->drawText(__('Ship to:'), 285, $top - 15, 'UTF-8');
     } else {
         $page->drawText(__('Payment Method:'), 285, $top - 15, 'UTF-8');
     }
     $addressesHeight = $this->_calcAddressHeight($billingAddress);
     if (isset($shippingAddress)) {
         $addressesHeight = max($addressesHeight, $this->_calcAddressHeight($shippingAddress));
     }
     $page->setFillColor(new \Zend_Pdf_Color_GrayScale(1));
     $page->drawRectangle(25, $top - 25, 570, $top - 33 - $addressesHeight);
     $page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
     $this->_setFontRegular($page, 10);
     $this->y = $top - 40;
     $addressesStartY = $this->y;
     foreach ($billingAddress as $value) {
         if ($value !== '') {
             $text = array();
             foreach ($this->string->split($value, 45, true, true) as $_value) {
                 $text[] = $_value;
             }
             foreach ($text as $part) {
                 $page->drawText(strip_tags(ltrim($part)), 35, $this->y, 'UTF-8');
                 $this->y -= 15;
             }
         }
     }
     $addressesEndY = $this->y;
     if (!$order->getIsVirtual()) {
         $this->y = $addressesStartY;
         foreach ($shippingAddress as $value) {
             if ($value !== '') {
                 $text = array();
                 foreach ($this->string->split($value, 45, true, true) as $_value) {
                     $text[] = $_value;
                 }
                 foreach ($text as $part) {
                     $page->drawText(strip_tags(ltrim($part)), 285, $this->y, 'UTF-8');
                     $this->y -= 15;
                 }
             }
         }
         $addressesEndY = min($addressesEndY, $this->y);
         $this->y = $addressesEndY;
         $page->setFillColor(new \Zend_Pdf_Color_Rgb(0.93, 0.92, 0.92));
         $page->setLineWidth(0.5);
         $page->drawRectangle(25, $this->y, 275, $this->y - 25);
         $page->drawRectangle(275, $this->y, 570, $this->y - 25);
         $this->y -= 15;
         $this->_setFontBold($page, 12);
         $page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
         $page->drawText(__('Payment Method'), 35, $this->y, 'UTF-8');
         $page->drawText(__('Shipping Method:'), 285, $this->y, 'UTF-8');
         $this->y -= 10;
         $page->setFillColor(new \Zend_Pdf_Color_GrayScale(1));
         $this->_setFontRegular($page, 10);
         $page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
         $paymentLeft = 35;
         $yPayments = $this->y - 15;
     } else {
         $yPayments = $addressesStartY;
         $paymentLeft = 285;
     }
     foreach ($payment as $value) {
         if (trim($value) != '') {
             //Printing "Payment Method" lines
             $value = preg_replace('/<br[^>]*>/i', "\n", $value);
             foreach ($this->string->split($value, 45, true, true) as $_value) {
                 $page->drawText(strip_tags(trim($_value)), $paymentLeft, $yPayments, 'UTF-8');
                 $yPayments -= 15;
             }
         }
     }
     if ($order->getIsVirtual()) {
         // replacement of Shipments-Payments rectangle block
         $yPayments = min($addressesEndY, $yPayments);
         $page->drawLine(25, $top - 25, 25, $yPayments);
         $page->drawLine(570, $top - 25, 570, $yPayments);
         $page->drawLine(25, $yPayments, 570, $yPayments);
         $this->y = $yPayments - 15;
     } else {
         $topMargin = 15;
         $methodStartY = $this->y;
         $this->y -= 15;
         foreach ($this->string->split($shippingMethod, 45, true, true) as $_value) {
             $page->drawText(strip_tags(trim($_value)), 285, $this->y, 'UTF-8');
             $this->y -= 15;
         }
         $yShipments = $this->y;
         $totalShippingChargesText = "(" . __('Total Shipping Charges') . " " . $order->formatPriceTxt($order->getShippingAmount()) . ")";
         $page->drawText($totalShippingChargesText, 285, $yShipments - $topMargin, 'UTF-8');
         $yShipments -= $topMargin + 10;
         $tracks = array();
         if ($shipment) {
             $tracks = $shipment->getAllTracks();
         }
         if (count($tracks)) {
             $page->setFillColor(new \Zend_Pdf_Color_Rgb(0.93, 0.92, 0.92));
             $page->setLineWidth(0.5);
             $page->drawRectangle(285, $yShipments, 510, $yShipments - 10);
             $page->drawLine(400, $yShipments, 400, $yShipments - 10);
             //$page->drawLine(510, $yShipments, 510, $yShipments - 10);
             $this->_setFontRegular($page, 9);
             $page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
             //$page->drawText(__('Carrier'), 290, $yShipments - 7 , 'UTF-8');
             $page->drawText(__('Title'), 290, $yShipments - 7, 'UTF-8');
             $page->drawText(__('Number'), 410, $yShipments - 7, 'UTF-8');
             $yShipments -= 20;
             $this->_setFontRegular($page, 8);
             foreach ($tracks as $track) {
                 $maxTitleLen = 45;
                 $endOfTitle = strlen($track->getTitle()) > $maxTitleLen ? '...' : '';
                 $truncatedTitle = substr($track->getTitle(), 0, $maxTitleLen) . $endOfTitle;
                 $page->drawText($truncatedTitle, 292, $yShipments, 'UTF-8');
                 $page->drawText($track->getNumber(), 410, $yShipments, 'UTF-8');
                 $yShipments -= $topMargin - 5;
             }
         } else {
             $yShipments -= $topMargin - 5;
         }
         $currentY = min($yPayments, $yShipments);
         // replacement of Shipments-Payments rectangle block
         $page->drawLine(25, $methodStartY, 25, $currentY);
         //left
         $page->drawLine(25, $currentY, 570, $currentY);
         //bottom
         $page->drawLine(570, $currentY, 570, $methodStartY);
         //right
         $this->y = $currentY;
         $this->y -= 15;
     }
 }
コード例 #9
0
 /**
  * Retrieve formatting date
  *
  * @param   \Zend_Date|string|null $date
  * @param   string $format
  * @param   bool $showTime
  * @return  string
  */
 public function formatDate($date = null, $format = \Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT, $showTime = false)
 {
     return $this->_localeDate->formatDate($date, $format, $showTime);
 }