Beispiel #1
0
 function display($tpl = null)
 {
     if (JFactory::getUser()->get('guest')) {
         $msg = JText::_("ORDER_PLEASE_LOGIN_BEFORE");
         $redirectUrl = base64_encode("index.php?option=com_enmasse&view=orderList");
         $version = new JVersion();
         $joomla = $version->getShortVersion();
         if (substr($joomla, 0, 3) >= '1.6') {
             $link = JRoute::_("index.php?option=com_users&view=login&return=" . $redirectUrl, false);
         } else {
             $link = JRoute::_("index.php?option=com_user&view=login&return=" . $redirectUrl, false);
         }
         JFactory::getApplication()->redirect($link, $msg);
     }
     $orderList = JModel::getInstance('order', 'enmasseModel')->listForBuyer(JFactory::getUser()->id);
     for ($count = 0; $count < count($orderList); $count++) {
         $orderItemList = JModel::getInstance('orderItem', 'enmasseModel')->listByOrderId($orderList[$count]->id);
         $orderList[$count]->orderItem = $orderItemList[0];
         $orderList[$count]->display_id = EnmasseHelper::displayOrderDisplayId($orderList[$count]->id);
     }
     $this->assignRef('orderList', $orderList);
     $this->_setPath('template', JPATH_SITE . DS . "components" . DS . "com_enmasse" . DS . "theme" . DS . EnmasseHelper::getThemeFromSetting() . DS . "tmpl" . DS);
     $this->_layout = "order_list";
     parent::display($tpl);
 }
Beispiel #2
0
 function display($tpl = null)
 {
     // -------------------to re define server link
     $server = JURI::base();
     //-----------------------------------
     $cart = unserialize(JFactory::getSession()->get('cart'));
     $payGty = unserialize(JFactory::getSession()->get('payGty'));
     if (empty($payGty)) {
         $link = JRoute::_("index.php?option=com_enmasse&controller=deal", false);
         JFactory::getApplication()->redirect($link);
     }
     $orderId = JRequest::getVar('orderId');
     $returnUrl = $server . "/index.php?option=com_enmasse&controller=payment&task=returnUrl&orderId={$orderId}";
     $notifyUrl = $server . "/index.php?option=com_enmasse&controller=payment&task=notifyUrl&orderId={$orderId}";
     $cancelUrl = $server . "/index.php?option=com_enmasse&controller=payment&task=cancelUrl";
     $returnUrl .= "&payClass=" . $payGty->class_name;
     $notifyUrl .= "&payClass=" . $payGty->class_name;
     $setting = new JObject();
     $setting->currency = JModel::getInstance('setting', 'enmasseModel')->getCurrency();
     $setting->country = JModel::getInstance('setting', 'enmasseModel')->getCountry();
     $this->returnUrl = $returnUrl;
     $this->notifyUrl = $notifyUrl;
     $this->cancelUrl = $cancelUrl;
     $this->cart = $cart;
     $this->user = JModel::getInstance('user', 'enmasseModel')->getUser();
     $this->systemName = JModel::getInstance('setting', 'enmasseModel')->getCompanyName();
     $this->attributeConfig = json_decode($payGty->attribute_config);
     $this->orderDisplayId = EnmasseHelper::displayOrderDisplayId($orderId);
     $this->setting = $setting;
     $this->orderId = $orderId;
     $this->_setPath('template', JPATH_SITE . DS . "components" . DS . "com_enmasse" . DS . "helpers" . DS . "payGty" . DS . $payGty->class_name . DS);
     $this->_layout = "pay_gty";
     parent::display($tpl);
 }
Beispiel #3
0
 function display($tpl = null)
 {
     $task = JRequest::getWord('task');
     $userId = JFactory::getUser()->id;
     switch ($task) {
         case 'show':
             $arOrderId = JModel::getInstance('deliverer', 'EnmasseModel')->getOrdersByUserId($userId);
             $orderList = JModel::getInstance('order', 'EnmasseModel')->getOrdersByIds(empty($arOrderId) ? array(0) : $arOrderId);
             for ($count = 0; $count < count($orderList); $count++) {
                 $orderItemList = JModel::getInstance('orderItem', 'enmasseModel')->listByOrderId($orderList[$count]->id);
                 $oOrderDeliverer = JModel::getInstance('OrderDeliverer', 'enmasseModel')->getByOrderId($orderList[$count]->id);
                 $orderList[$count]->orderItem = $orderItemList[0];
                 $orderList[$count]->status = $oOrderDeliverer->status;
                 $orderList[$count]->display_id = EnmasseHelper::displayOrderDisplayId($orderList[$count]->id);
             }
             $this->assignRef('orderList', $orderList);
             $this->_setPath('template', JPATH_SITE . DS . "components" . DS . "com_enmasse" . DS . "theme" . DS . EnmasseHelper::getThemeFromSetting() . DS . "tmpl" . DS);
             $this->_layout = "deliverer_order_list";
             parent::display($tpl);
             break;
         case 'edit':
             $orderId = JRequest::getVar('id', 0, 'method', 'int');
             $oOrderDeliverer = JModel::getInstance('OrderDeliverer', 'enmasseModel')->getByOrderId($orderId);
             if (!$oOrderDeliverer) {
                 $link = JRoute::_("index.php?option=com_enmasse&controller=deliverer&task=show");
                 $msg = JText::_('INVALID_ORDER_ID_MSG');
                 JFactory::getApplication()->redirect($link, $msg, 'error');
             }
             $oOrder = JModel::getInstance('order', 'EnmasseModel')->getById($orderId);
             $oOrder->delivery_status = $oOrderDeliverer->status;
             $this->oOrder = $oOrder;
             $this->oOrderItemList = JModel::getInstance('orderItem', 'enmasseModel')->listByOrderId($oOrder->id);
             $this->_setPath('template', JPATH_SITE . DS . "components" . DS . "com_enmasse" . DS . "theme" . DS . EnmasseHelper::getThemeFromSetting() . DS . "tmpl" . DS);
             $this->_layout = "deliverer_order_edit";
             parent::display($tpl);
             break;
         default:
             $link = JRoute::_("index.php?option=com_enmasse&controller=deliverer&task=show");
             JFactory::getApplication()->redirect($link);
     }
 }
Beispiel #4
0
 /**
  * 
  * Create bill with PDF format, return file location.
  * @param integer $nOrderId order id that need to print bill.
  * @param string $dest whether save to the file or echo direct to web browser (for preview).
  * @return string name of created file with absolute path. 
  */
 public static function createPDF($nOrderId, $dest = 'F')
 {
     $oOrder = JModel::getInstance('order', 'enmasseModel')->getById($nOrderId);
     if (empty($oOrder)) {
         return null;
     }
     $buyer = json_decode($oOrder->buyer_detail);
     $arOrderItem = JModel::getInstance('orderItem', 'enmasseModel')->listByOrderId($nOrderId);
     $sOderDetail = '<table border="1"><tr valign="middle"><th align="center" style="width:30px;">' . JText::_("BILL_TEMPLATE_ORDER_DETAIL_NO") . '</th><th style="width:60px;">' . JText::_("BILL_TEMPLATE_ORDER_DETAIL_QUANTITY") . '</th><th style="width:50px;">' . JText::_("BILL_TEMPLATE_ORDER_DETAIL_DEAL_ID") . '</th><th align="center" style="width:320px; ">' . JText::_("BILL_TEMPLATE_ORDER_DETAIL_DEAL_DESC") . '</th><th style="width:50px;">' . JText::_("BILL_TEMPLATE_ORDER_DETAIL_UNIT_PRICE") . '</th><th style="width:50px;">' . JText::_("BILL_TEMPLATE_ORDER_DETAIL_TAX") . '</th><th style="width:80px;">' . JText::_("BILL_TEMPLATE_ORDER_DETAIL_TOTAL") . '</th></tr>';
     $oPayGty = JModel::getInstance('payGty', 'enmasseModel')->getById($oOrder->pay_gty_id);
     if (empty($oPayGty)) {
         $oPayGty = new JObject();
         $oPayGty->name = "";
     }
     $count = 1;
     foreach ($arOrderItem as $oItem) {
         $sOderDetail .= '<tr valign="middle"><td >' . $count++ . '</td><td >' . $oItem->qty . '</td><td >' . $oItem->pdt_id . '</td><td style="width:300px;text-align: left">' . $oItem->description . '</td><td >' . $oItem->unit_price . '</td><td >' . '</td><td >' . $oItem->total_price . '</td></tr>';
     }
     $sOderDetail .= '<tr><td colspan="7" style="text-align:right" >Total Amount: ' . $oOrder->total_buyer_paid . '</td></tr></table>';
     $db = JFactory::getDbo();
     $query = "SELECT *\n\t\t\t\t\t\tFROM #__enmasse_bill_template\n\t\t\t\t\t\tWHERE slug_name = " . $db->quote(self::$BUYER_RECEIPT_TMPL_NAME);
     $db->setQuery($query);
     $oBillTmpl = $db->loadObject();
     $sTmpl = $oBillTmpl->content;
     $arParam = array();
     $arParam['[BUYER_NAME]'] = $buyer->name;
     $arParam['[BUYER_EMAIL]'] = $buyer->email;
     $arParam['[BILL_NUMBER]'] = EnmasseHelper::displayOrderDisplayId($oOrder->id);
     $arParam['[BILL_DATE]'] = DatetimeWrapper::getDatetimeOfNow();
     $arParam['[PAYMENT_METHOD]'] = $oPayGty->name;
     $arParam['[BILL_DETAIL]'] = $sOderDetail;
     $arParam['[BILL_DESCRIPTION]'] = $oOrder->description;
     //ADD style for table
     $sTmpl = '<style>p{margin: 8px 0px }table {border-collapse:collapse;} td, th{text-align: center} th{height: 40px}</style>' . $sTmpl;
     $arSearch = array_keys($arParam);
     $sTmpl = str_replace($arSearch, $arParam, $sTmpl);
     //-----------------------------
     //process for image tag because there have the difference source path between
     //html2pdf and richtext editor(using for edit bill template),image tag
     //was wrong source path and it cause html2pdf error
     $sPattern = '/(<img\\s+src=")(.*)(")/i';
     if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") {
         $sReplace = '$1' . JPATH_SITE . DS . '\\$2$3';
     } else {
         $sReplace = '$1' . JPATH_SITE . DS . '$2$3';
     }
     $sTmpl = preg_replace($sPattern, $sReplace, $sTmpl);
     require_once dirname(__FILE__) . '/html2pdf/html2pdf.class.php';
     try {
         $sOutFileName = "bill_preview.pdf";
         if ($dest == 'F') {
             $sOutFileName = JPATH_ADMINISTRATOR . DS . "components" . DS . "com_enmasse" . DS . "bills" . DS . EnmasseHelper::displayOrderDisplayId($oOrder->id) . ".pdf";
             if (file_exists($sOutFileName)) {
                 unlink($sOutFileName);
             }
         }
         $html2pdf = new HTML2PDF('P', 'A4', 'en');
         $html2pdf->setDefaultFont('Arial');
         $html2pdf->writeHTML($sTmpl);
         $html2pdf->Output($sOutFileName, $dest);
     } catch (HTML2PDF_exception $e) {
         return;
     }
     return $sOutFileName;
 }
Beispiel #5
0
</script>

<form action="index.php" method="post" name="adminForm" id="adminForm">
<div class="width-100 fltrt">
<fieldset class="adminform"><legend><?php 
echo JText::_('ORDER_DETAIL');
?>
</legend>
<table class="admintable">
	<tr>
		<td width="100" align="right" class="key" valign="top"><?php 
echo JText::_('ORDER_ID');
?>
</td>
		<td><?php 
echo EnmasseHelper::displayOrderDisplayId($order_row->id);
?>
</td>
	</tr>
	<tr>
		<td width="100" align="right" class="key" valign="top"><?php 
echo JText::_('ORDER_COMMENT');
?>
</td>
		<td><textarea name="description" cols=40 rows=3><?php 
echo $order_row->description;
?>
</textarea>
		</td>
	</tr>
	<tr>
echo JText::_("ORDER_EDITING") . "&nbsp;" . EnmasseHelper::displayOrderDisplayId($this->oOrder->id);
?>
</h4>
</div>
<div class="row row_space">
	<div class="delivery_detail_edit">
		<form action="index.php" method="post" name="adminForm">
			<table>
				<tr>
					<td valign="top"><?php 
echo JText::_('ORDER_ID');
?>
</td>
					<td>
						<?php 
echo EnmasseHelper::displayOrderDisplayId($this->oOrder->id);
?>
						<input type="hidden" value="<?php 
echo $this->oOrder->id;
?>
" name="id"/>
					</td>
				</tr>
				<tr>
					<td valign="top"><?php 
echo JText::_('ORDER_DEAL_NAME');
?>
</td>
					<td><?php 
echo $this->oOrderItemList[0]->description;
?>