function updatestatus($order_id, $status, $comment = '', $send_mail = 1, $store_id = 0) { global $mainframe; $params = JComponentHelper::getParams('com_quick2cart'); $comquick2cartHelper = new comquick2cartHelper(); switch ($status) { case 'C': /// to reduce stock $usestock = $params->get('usestock'); $outofstock_allowship = $params->get('outofstock_allowship'); if ($usestock == 1) { $comquick2cartHelper->updateItemStock($order_id); } $comquick2cartHelper->updateStoreFee($order_id); } $mainframe = JFactory::getApplication(); $db = JFactory::getDBO(); if ($send_mail == 1) { if (!empty($store_id)) { $query = 'SELECT o.status FROM `#__kart_order_item` as o WHERE o.order_id =' . $order_id . ' AND o.`store_id`=' . $store_id . ' order by `order_item_id`'; //die(" work is in progress(store product status change) die in helper "); } else { $query = "SELECT o.status FROM #__kart_orders as o WHERE o.id =" . $order_id; } $db->setQuery($query); $order_oldstatus = $db->loadResult(); } $res = new stdClass(); // UPDATING STORE ORDER CHANGES if (!empty($store_id)) { // change ORDER_ITEM STATUS// here i want order_item_id to update status of all order item releated to store $isOrderStatusChanged = $comquick2cartHelper->updateOrderItemStatus($order_id, $store_id, $status); if (empty($isOrderStatusChanged)) { // return ; } } else { // IF admin changes ORDER status $res->status = $status; $res->id = $order_id; if (!$db->updateObject('#__kart_orders', $res, 'id')) { return 2; } $isOrderStatusChanged = $comquick2cartHelper->updateOrderItemStatus($order_id, 0, $status); // UPDATE ORDER ITEM STATUS ALSO } //START Q2C Sample development $query = "SELECT o.* FROM #__kart_orders as o WHERE o.id =" . $order_id; $db->setQuery($query); $orderobj = $db->loadObject(); $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('system'); $result = $dispatcher->trigger('Onq2cOrderUpdate', array($orderobj)); //Call the plugin and get the result //END Q2C Sample development if ($send_mail == 1 && $order_oldstatus != $status) { $params = JComponentHelper::getParams('com_quick2cart'); //$adminemails = comquick2cartHelper::adminMails(); $query = "SELECT ou.user_id,ou.user_email,ou.firstname FROM #__kart_users as ou WHERE ou.address_type='BT' AND ou.order_id = " . $order_id; $db->setQuery($query); $orderuser = $db->loadObjectList(); //Change for backward compatiblity for user info not saving order id against it if (empty($orderuser)) { $query = "SELECT ou.user_id,ou.user_email,ou.firstname\n\t\t\t\tFROM #__kart_users as ou \n\t\t\t\tWHERE ou.address_type='BT' AND ou.order_id IS NULL AND ou.user_id = (SELECT o.user_info_id FROM #__kart_orders as o WHERE o.id =" . $order_id . ")"; $db->setQuery($query); $orderuser = $db->loadObjectList(); } $orderuser = $orderuser[0]; switch ($status) { case 'C': $orderstatus = JText::_('QTC_CONFR'); /*for invoice*/ $jinput = JFactory::getApplication()->input; $jinput->set('orderid', $order_id); $order = $order_bk = $comquick2cartHelper->getorderinfo($order_id); $this->orderinfo = $order['order_info']; $this->orderitems = $order['items']; $this->orders_site = 1; $this->orders_email = 1; $this->order_authorized = 1; if ($this->orderinfo[0]->address_type == 'BT') { $billemail = $this->orderinfo[0]->user_email; } else { if ($this->orderinfo[1]->address_type == 'BT') { $billemail = $this->orderinfo[1]->user_email; } } $fullorder_id = $order['order_info'][0]->prefix . $order_id; if (!JFactory::getUser()->id && $params->get('guest')) { $jinput->set('email', md5($billemail)); } // check for view override $view = $comquick2cartHelper->getViewpath('orders', 'invoice'); ob_start(); include $view; $invoicehtml = ob_get_contents(); ob_end_clean(); /*for invoice*/ break; case 'RF': $orderstatus = JText::_('QTC_REFUN'); break; case 'S': $orderstatus = JText::_('QTC_SHIP'); break; case 'E': $orderstatus = JText::_('QTC_ERR'); break; case 'P': $orderstatus = JText::_('QTC_PENDIN'); break; default: $orderstatus = $status; break; } $fullorder_id = $orderobj->prefix . $order_id; if (!empty($store_id)) { $productStatus = $comquick2cartHelper->getProductStatus($order_id); $body = JText::sprintf('QTC_STORE_PRODUCT_STATUS_CHANGE_BODY', $productStatus); } else { $body = JText::_('QTC_STATUS_CHANGE_BODY'); } $site = $mainframe->getCfg('sitename'); if ($comment) { $comment = str_replace('{COMMENT}', $comment, JText::_('QTC_COMMENT_TEXT')); $find = array('{ORDERNO}', '{STATUS}', '{SITENAME}', '{NAME}', '{COMMENTTEXT}'); $replace = array($fullorder_id, $orderstatus, $site, $orderuser->firstname, $comment); } else { $find = array('{ORDERNO}', '{STATUS}', '{SITENAME}', '{NAME}', '{COMMENTTEXT}'); $replace = array($fullorder_id, $orderstatus, $site, $orderuser->firstname, ''); } $body = str_replace($find, $replace, $body); $guest_email = ''; if (!$orderuser->user_id && $params->get('guest')) { $guest_email = "&email=" . md5($orderuser->user_email); } $Itemid = $comquick2cartHelper->getitemid('index.php?option=com_quick2cart&view=orders'); $link = JURI::root() . substr(JRoute::_('index.php?option=com_quick2cart&view=orders&layout=order' . $guest_email . '&orderid=' . $order_id . '&Itemid=' . $Itemid), strlen(JURI::base(true)) + 1); $order_link = '<a href="' . $link . '">' . JText::_('QTC_ORDER_GUEST_LINK') . '</a>'; $body = str_replace('{LINK}', $order_link, $body); $body = nl2br($body); if (!empty($invoicehtml)) { $body = $body . '<div>' . JText::_('QTC_ORDER_INVOICE_IN_MAIL') . '</div>'; $invoicehtml = $body . $invoicehtml; $invoicesubject = JText::sprintf('QTC_INVOICE_MAIL_SUB', $site, $fullorder_id); $comquick2cartHelper->sendmail($orderuser->user_email, $invoicesubject, $invoicehtml, $params->get('sale_mail')); } else { $subject = JText::sprintf('QTC_STATUS_CHANGE_SUBJECT', $fullorder_id); $comquick2cartHelper->sendmail($orderuser->user_email, $subject, $body, $params->get('sale_mail')); } } }
/** * Render view. * * @param array $tpl An optional associative array of configuration settings. * * @since 1.0 * @return null */ public function display($tpl = null) { $user = JFactory::getUser(); $mainframe = JFactory::getApplication(); require_once JPATH_SITE . '/components/com_quick2cart/helpers/media.php'; // create object of media helper class $this->media = new qtc_mediaHelper(); $model = $this->getModel('cartcheckout'); $input = JFactory::getApplication()->input; $layout = $input->get('layout', ''); // Send to joomla's registration of guest ckout is off if ($layout == 'cancel' || $layout == 'orderdetails') { $input->set('remote', 1); $sacontroller = new quick2cartController(); $sacontroller->execute('clearcart'); } else { $params = $this->params = JComponentHelper::getParams('com_quick2cart'); $guestcheckout = $params->get('guest'); if ($guestcheckout == 0 && !$user->id) { $itemid = $input->get('Itemid'); // $uri=JRoute::_('index.php?option=com_quick2cart&view=cartcheckout&Itemid=' . $itemid,false); $rurl = 'index.php?option=com_quick2cart&view=cartcheckout&Itemid=' . $itemid; $returnurl = base64_encode($rurl); $mainframe->redirect(JRoute::_('index.php?option=com_users&return=' . $returnurl, false), $msg); } // GETTING CART ITEMS JLoader::import('cart', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models'); // $cartmodel = new Quick2cartModelcart; // $cart = $cartmodel->getCartitems(); // Amol change $cartCheckoutModel = new Quick2cartModelcartcheckout(); $cart = $cartCheckoutModel->getCheckoutCartitemsDetails(); // Amol change end $this->cart = $cart; $session = JFactory::getSession(); $cops = $session->get('coupon'); if (!empty($cops)) { // Check for expiry $cop_array = array(); foreach ($cops as $cop) { $valid_coupan = $model->getcoupon($cop['code']); if (!empty($valid_coupan)) { $cop_array[] = $cop; } } $this->coupon = $cop_array; } else { $this->coupon = array(); } $user = JFactory::getUser(); if ($user->id != 0) { $userdata = $model->userdata(); $this->userdata = $userdata; } if ($layout == 'payment') { $orders_site = '1'; $orderid = $session->get('order_id'); $comquick2cartHelper = new comquick2cartHelper(); $order = $comquick2cartHelper->getorderinfo($orderid); if (!empty($order)) { if (is_array($order)) { $this->orderinfo = $order['order_info']; $this->orderitems = $order['items']; } elseif ($order == 0) { $this->undefined_orderid_msg = 1; } // $payhtml = $model->getpayHTML($order['order_info'][0]->processor,$orderid); JLoader::import('payment', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models'); $paymodel = new Quick2cartModelpayment(); $payhtml = $paymodel->getHTML($order['order_info'][0]->processor, $orderid); $this->payhtml = $payhtml[0]; } else { $this->undefined_orderid_msg = 1; } $orders_site = '1'; $this->orders_site = $orders_site; // Make cart empty JLoader::import('cart', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models'); $Quick2cartModelcart = new Quick2cartModelcart(); $Quick2cartModelcart->empty_cart(); } else { // START Q2C Sample development $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('system'); // Call the plugin and get the result $result = $dispatcher->trigger('OnBeforeq2cCheckoutCartDisplay'); $beforecart = ''; if (!empty($result)) { $beforecart = $result[0]; } $this->beforecart = $beforecart; $result = $dispatcher->trigger('OnAfterq2cCheckoutCartDisplay'); $aftercart = ''; if (!empty($result)) { $aftercart = $result[0]; } $this->aftercart = $aftercart; // END Q2C Sample development // Q2C Sample development - ADD TAB in ckout page $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('system'); $result = $dispatcher->trigger('qtcaddTabOnCheckoutPage', array($this->cart)); $this->addTab = ''; $this->addTabPlace = ''; if (!empty($result)) { $this->addTab = $result[0]; $this->addTabPlace = !empty($result[0]['tabPlace']) ? $result[0]['tabPlace'] : ''; } // END - Q2C Sample development - ADD TAB in ckout page // Trigger plg to add plg after shipping tab // GETTING country $country = $this->get("Country"); $this->country = $country; } // Getting GETWAYS $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('payment'); // $params->get( 'gateways' ) = array('0' => 'paypal','1'=>'Payu'); if (!is_array($params->get('gateways'))) { $gateway_param[] = $params->get('gateways'); } else { $gateway_param = $params->get('gateways'); } if (!empty($gateway_param)) { $gateways = $dispatcher->trigger('onTP_GetInfo', array($gateway_param)); } $this->gateways = $gateways; } $this->_setToolBar(); parent::display($tpl); }
/** * public function to build Invoice HTML & send it to buyer * * @param INTEGER $order_id order_id * @param STRING $status status * @param STRING $comment comment * @param INTEGER $send_mail send_mail * @param INTEGER $store_id store_id * * @return boolean */ public function sendInvoice($order_id, $status, $comment = '', $send_mail = 1, $store_id = 0) { $mainframe = JFactory::getApplication(); $db = JFactory::getDBO(); $params = JComponentHelper::getParams('com_quick2cart'); $comquick2cartHelper = new comquick2cartHelper(); // Load language file as require from backend add product. JFactory::getLanguage()->load('com_quick2cart', JPATH_SITE); // START Q2C Sample development $query = "SELECT o.* FROM #__kart_orders as o WHERE o.id =" . $order_id; $db->setQuery($query); $orderobj = $db->loadObject(); // $adminemails = comquick2cartHelper::adminMails(); $query = "SELECT ou.user_id,ou.user_email,ou.firstname FROM #__kart_users as ou WHERE ou.address_type='BT' AND ou.order_id = " . $order_id; $db->setQuery($query); $orderuser = $db->loadObjectList(); // Change for backward compatiblity for user info not saving order id against it if (empty($orderuser)) { $query = "SELECT ou.user_id,ou.user_email,ou.firstname\n\t\tFROM #__kart_users as ou\n\t\tWHERE ou.address_type='BT' AND ou.order_id IS NULL AND ou.user_id = (SELECT o.user_info_id FROM #__kart_orders as o WHERE o.id =" . $order_id . ")"; $db->setQuery($query); $orderuser = $db->loadObjectList(); } $orderuser = $orderuser[0]; $jinput = JFactory::getApplication()->input; $jinput->set('orderid', $order_id); $order = $order_bk = $comquick2cartHelper->getorderinfo($order_id); $this->orderinfo = $order['order_info']; $this->orderitems = $order['items']; $this->orders_site = 1; $this->orders_email = 1; $this->order_authorized = 1; if ($this->orderinfo[0]->address_type == 'BT') { $billemail = $this->orderinfo[0]->user_email; } elseif ($this->orderinfo[1]->address_type == 'BT') { $billemail = $this->orderinfo[1]->user_email; } $fullorder_id = $order['order_info'][0]->prefix . $order_id; if (!JFactory::getUser()->id && $params->get('guest')) { $jinput->set('email', md5($billemail)); $this->calledFromOnePageCkout = 1; } // Check for view override $view = $comquick2cartHelper->getViewpath('orders', 'invoice'); ob_start(); include $view; $invoicehtml = ob_get_contents(); ob_end_clean(); $fullorder_id = $orderobj->prefix . $order_id; if (!empty($store_id)) { $productStatus = $comquick2cartHelper->getProductStatus($order_id); $body = JText::sprintf('QTC_STORE_PRODUCT_STATUS_CHANGE_BODY', $productStatus); } else { $body = JText::_('COM_QUICK2CART_INVOICE_BODY'); } $site = $mainframe->getCfg('sitename'); if ($comment) { $comment = str_replace('{COMMENT}', $comment, JText::_('QTC_COMMENT_TEXT')); $find = array('{ORDERNO}', '{STATUS}', '{SITENAME}', '{NAME}', '{COMMENTTEXT}'); $replace = array($fullorder_id, JText::_('QTC_CONFR'), $site, $orderuser->firstname, $comment); } else { $find = array('{ORDERNO}', '{STATUS}', '{SITENAME}', '{NAME}', '{COMMENTTEXT}'); $replace = array($fullorder_id, JText::_('QTC_CONFR'), $site, $orderuser->firstname, ''); } $body = str_replace($find, $replace, $body); $guest_email = ''; if (!$orderuser->user_id && $params->get('guest')) { $guest_email = "&email=" . md5($orderuser->user_email); } $Itemid = $comquick2cartHelper->getitemid('index.php?option=com_quick2cart&view=orders'); $tempLink = JRoute::_('index.php?option=com_quick2cart&view=orders&layout=order' . $guest_email . '&orderid=' . $order_id . '&Itemid=' . $Itemid); $link = JUri::root() . substr($tempLink, strlen(JUri::base(true)) + 1); $order_link = '<a href="' . $link . '">' . JText::_('QTC_ORDER_GUEST_LINK') . '</a>'; $body = str_replace('{LINK}', $order_link, $body); $body = nl2br($body); // GETTING BODY AND MAIL SUBJECT if (!empty($invoicehtml)) { $body = $body . '<div>' . JText::_('QTC_ORDER_INVOICE_IN_MAIL') . '</div>'; $body = $body . $invoicehtml; $subject = JText::sprintf('QTC_INVOICE_MAIL_SUB', $site, $fullorder_id); } else { $subject = JText::sprintf('QTC_STATUS_CHANGE_SUBJECT', $fullorder_id); } // Call the plugin and get the result $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('system'); $result = $dispatcher->trigger('OnBeforeq2cOrderUpdateEmail', array($orderobj, $subject, $body)); if (!empty($result[0])) { $subject = $result[0][0]; $body = $result[0][1]; } //print $body; die; // Send mail $comquick2cartHelper->sendmail($orderuser->user_email, $subject, $body, $params->get('sale_mail')); }